Additional data needed in contract events endpoint
Is your feature request related to a problem? Please describe.
Because there is no total key, no block number, no timestamp whatsoever, and no way to sort the output (desc/asc), we have to query all the contract events instead of just the data for the last five cycles (all we need).
If we put offset 0, we see the most recent records instead of the oldest records. But to only query the records up until five cycles ago, we don't need ALL contract events (until our loop returns less than the 'limit'), but just until block number or timestamp is 'less than' X.
Describe the solution you'd like
I'd like total, blocknumber, and timestamp per event in the output and maybe even a sort as query parameter. That way, we can do: total - total db records = records to retrieve.
Endpoint: https://docs.hiro.so/apis/stacks-blockchain-api/reference/smart-contracts/events Link to point in source code: https://github.com/hirosystems/stacks-blockchain-api/blob/develop/src/api/routes/contract.ts#L100
The events are ordered by block-height.
The data is also returned by the query but not published.
This can be fixed in https://github.com/hirosystems/stacks-blockchain-api/blob/develop/src/api/controllers/db-controller.ts#L392
To get the paging right, having the tip as query parameter is important.