Closed
Description
Currently subxt is great of supporting storage
and transactions
but as substrate is increasingly moving towards these runtime RPC APIs which is a bit more work to use in context of subxt.
The runtime RPC APIs works as follows:
- make a RPC call to
state_call(method, call_data)
- method: is the name of the runtime API such as
TransactionPaymentCallApi_query_call_info
- call_data: is the custom types that the certain runtime API takes as input (encoded/decoded as a tuple in the same order as they are defined)
One is example is when I tried to get TransactionPaymentCallApi::query_call_info(call: Call, len: u32)
working:
let tx = runtime::tx().election_provider_multi_phase().submit_unsigned(Default::default(), SolutionOrSnapshotSize { voters, targets });
// call_data is (Call, len)
let call_data = {
let mut buffer = Vec::new();
// this is already encoded so just push it to buffer directly
let encoded_call = client.tx().call_data(&tx).unwrap();
// this needs to be encoded....
let encoded_len = encoded_call.len() as u32;
buffer.extend(encoded_call);
encoded_len.encode_to(&mut buffer);
Bytes(buffer)
};
let bytes: Bytes = client
.rpc()
.client
.request(
"state_call",
rpc_params!["TransactionPaymentCallApi_query_call_info", call_data],
)
.await
.unwrap();
It's easy to get wrong if you are not really familiar how scale encoding
works
Thus, it would be great if subxt could generate these runtime APIs similar to how transactions and storage are supported by subxt but I don't know whether it possible to fetch these via the metadata or something else like inspecting the WASM blob.....