Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate pallet RPC calls #416

Closed
ascjones opened this issue Jan 31, 2022 · 5 comments
Closed

Generate pallet RPC calls #416

ascjones opened this issue Jan 31, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@ascjones
Copy link
Contributor

ascjones commented Jan 31, 2022

It would be nice to generate methods for calling pallet RPC endpoints e.g. contracts_instantiate

This is to avoid having to write code such as this, which at present requires importing or copying the definitions of the request and response types.

In order to do this we would require some metadata to be generated for these calls on the Substrate side.

Once the metadata is available it should be relatively straightforward to generate the rpc calls. Could look something like:

api.rpc().contracts().instantiate(request)

@ascjones
Copy link
Contributor Author

@athei has pointed out that this should not be restricted to pallet RPCs, that if we have RPC metadata then we can also generate the client code for any "core" rpc methods (see Rpc).

One key distinction is that some "core" rpcs need to be defined up front, particularly author_submitExtrinsic so would need to handle that.

@athei
Copy link
Member

athei commented Feb 28, 2022

The generated type can implement some traits that provide the RPCs that are required for subxt.

@ascjones
Copy link
Contributor Author

Once we have paritytech/substrate#11648 this can then be all done via state_call. Related use-ink/cargo-contract#701

@niklasad1
Copy link
Member

Right, I opened #631 for that not sure if I should close that and rely on this issue.

If you rename it to runtime API calls or something then I'm happy closing #631

@ascjones
Copy link
Contributor Author

Yours is more detailed/up to date.

Superseded by #631

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants