vega
vega copied to clipboard
Block Explorer API - Fetch block/blocks
~#6789~ #6959 requests a new Block Explorer backend endpoint that can return transactions by block height. This ticket is another new API - fetching blocks (and their decoded contents)
What we have now in Block Explorer
The Tendermint RPC endpoint blockchain
is used to fetch a list of recent blocks (e.g. https://tm.n00.stagnet1.vega.xyz/blockchain)
When a user navigates in to the block specifically, the ID is sent to the current explorer API (see #6789) to get the transaction contents. Soon this page will be augmented with data from GraphQL, which will make it dependent on 4 different APIs. We can reduce that by two by removing the dependency on the tendermint API and the old, unsupported URL by addinga nd endpoint to fetch recent blocks
Task
- [ ] Add a new REST block explorer endpoint to return most recent block
- [ ] Data returned should use tendermint RPC, but with TXs decoded
- [ ] Add a new REST block explorer endpoint to return recent blocks, with a height range, for pagination
- [ ] Additional field on block: epoch for block (https://docs.vega.xyz/mainnet/api/rest/data-v2/trading-data-service-get-epoch#get-epoch exists, but is separate)
Related: #6959
Current tendermint calls:
- https://tm.be.testnet.vega.xyz/blockchain?maxHeight=586846&minHeight=586825 - this is used to produce the infinite scrolling list (e.g. http://localhost:3000/blocks).
- https://tm.n00.sandbox.vega.xyz/block?height=2246743 - this is used to produce the block by ID page (e.g.http://localhost:3000/blocks/586823), although the client does a lot more than just this query to build up this page