feat: add useRcBlockFormat parameter for RC block response formatting#1872
feat: add useRcBlockFormat parameter for RC block response formatting#1872
Conversation
|
closes: #1821 |
andrew-ifrita
left a comment
There was a problem hiding this comment.
Looks fine, so I will approve.
It may be a cleaner and cut down on all the duplication if we just have a responseFormatter middleware. It will also cut down on human error as endpoints are added and changed if someone forgets to add this formatting. It also give a single place to look for output formatting, which we could later document and would probably be nice to know as a developer coming in with little context.
Naming-wise, I would consider a better name, but I am not sure what to suggest. Something like format=rc might work and might be more intuitive and flexible but I am uncertain on the naming side.
I totally agree, i think this would be a good ethos to bring to polkadot-rest-api. I'll merge for now and create a follow up issue. |
Summary
Adds
useRcBlockFormatquery parameter to control response format when usinguseRcBlock=true.array(default): Returns existing array formatobject: Wraps response withrcBlockinfo andparachainDataPerBlockarrayExample
GET /accounts/{accountId}/balance-info?at=1000000&useRcBlock=true&useRcBlockFormat=object
Returns:
{ "rcBlock": { "hash": "0x...", "parentHash": "0x...", "number": "1000000" }, "parachainDataPerBlock": [...] }