zeitgeistpm / zeitgeist

An evolving blockchain for prediction markets and futarchy.
https://zeitgeist.pm
GNU General Public License v3.0
170 stars 41 forks source link

Expose rpc call type metadata for stronger polkadot.js typegen. #803

Open yornaath opened 1 year ago

yornaath commented 1 year ago

Currently some of our custom rpc calls like swaps.getSpotPrice(s) does not automatically show up in the polkadotjs ui even though they are listed when calling rpc.methods() and I think for the same reason the polkadot.js typegen isnt producing types for it. It seems like the metadata isnt exposing these methods correctly.

Screenshot 2022-09-26 at 22 54 29

Chralt98 commented 1 year ago

In polkadot js apps console you will get API/INIT: RPC methods not decorated: swaps_getSpotPrice, swaps_getSpotPriceAt, swaps_getSpotPrices, swaps_poolAccountId, swaps_poolAccountIdAt, swaps_poolSharesId, swaps_poolSharesIdAt and API/INIT: zeitgeist/46: Not decorating unknown runtime apis: 0xba8173bf23b2e6f8/1, SwapsApi/1

https://substrate.stackexchange.com/questions/2210/custom-rpcs-not-decorated

Seems like we need to add the input and output parameter types of the swaps api calls inside the polkadot js apps repository here with this instruction.

It seems pretty useful to create our own package for type-definitions of zeitgeist like Acala does here and here. That way, we don't have to push new changes every time on the polkadot js apps repo. Here you can see an example of a custom rpc call type definition. Here are the polkadot js apps type and rpc definitions of Moonbeam.

It's interesting that Astar for example has this type definitions but their custom rpc runtime apis like "web3" or "eth" are shown in the apps front end. I assume those are standard rpc methods that are already known by the front end... But I can't prove this assumption right now.