I'm trying to generate documentation for substrate RPC queries using the meta
property in the @polkadot/api
library. Something like api.query.<pallet>.<storageitem/extrinsic>.meta
. This gives me most of the data that i need, except for what appears to the types for the parameters/return type of the RPCs. For these, i seem to be presented with an index mapping like the following:
{
name: 'palletVersion',
modifier: 'Required',
type: { plain: 2 },
fallback: '0x',
docs: [ 'Returns the current pallet version from storage' ]
}
For plain types, and for what i assume are custom types (under the "type" key)
{
name: 'Votes',
modifier: 'Optional',
type: { map: { hashers: [Array], key: 83, value: 6 } },
fallback: '0x00',
docs: [
' A lookup mapping (epoch, call_hash) to a bitmask representing the votes for each validator.'
]
}
My question is: What is the most efficient way to dereference these integers (which i assume reference types in a datastructure somewhere) so that my documentation can easily show the base types required for the parameters and return signature of each RPC call?