Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Ability to create custom getters #2271

Closed
adamdossa opened this issue Apr 12, 2019 · 2 comments
Closed

Ability to create custom getters #2271

adamdossa opened this issue Apr 12, 2019 · 2 comments
Labels
Z7-question Issue is a question. Closer should answer.

Comments

@adamdossa
Copy link
Contributor

In the decl_storage! block it is possible to specify a getter function, which is then exposed over the JSON RPC API.

The documentation says that functions in the modules public "call" list are either signed, root or inherents - but it seems like getters introduce another class (since they can be called externally without signing the transaction).

Is it possible to create these types of functions directly? This would be similar to a view function in Solidity - for example I may want to take two values from storage, sum them, and return the value (to an external caller).

@adamdossa
Copy link
Contributor Author

Motivation for this is to have these functions exposed over the RPC API (similar to the way getters are, without needing to provide an origin).

@bkchr
Copy link
Member

bkchr commented Apr 13, 2019

We don't expose any function defined in decl_storage! directly over the Json Rpc Api. We expose a Rpc call to access the storage and the js app can build the key it requires out of Metadata.

We currently don't support extending the Rpc api in a simple way. You could create your own runtime api with decl_runtime_apis! and call this runtime api from your Rpc call.

@rphmeier rphmeier added the Z7-question Issue is a question. Closer should answer. label Apr 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Z7-question Issue is a question. Closer should answer.
Projects
None yet
Development

No branches or pull requests

3 participants