Skip to content

Support Runtime Api calls #520

Closed
@haerdib

Description

@haerdib

So far the api-client does not support runtime api calls. The goal of this issue is to facilitate runtime api calls, in general, and provide helper functions for the runtime api calls of the most commonly used pallets.

Available Runtime Calls: https://polkadot.js.org/docs/polkadot/runtime

Hands on testing: https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frpc.dotters.network%2Fkusama#/runtime

Subxt has already put some thoughts into it: see paritytech/subxt#918

Task description

Implement helper functions, just like our rpc calls

async fn get_account_info(
&self,
address: &Self::AccountId,
) -> Result<Option<AccountInfo<Self::Index, Self::AccountData>>> {
let storagekey: StorageKey = self.metadata().storage_map_key::<Self::AccountId>(
"System",
"Account",
address.clone(),
)?;

that directly access the node api and return the information.

Example code from subxt:

// Create a dynamically runtime API payload that calls the
// `AccountNonceApi_account_nonce` function.
let account = dev::alice().public_key();
let runtime_api_call = subxt::dynamic::runtime_api_call(
    "AccountNonceApi",
    "account_nonce",
    vec![Value::from_bytes(account)],
);

And as reference: here's the call executed by the rpc: https://github.com/paritytech/subxt/blob/9a8fc33f2fe830009011e997773071099101d69b/subxt/src/runtime_api/runtime_types.rs#L43-L106

Already implemented:

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions