avail_rust_client/clients/
runtime_api.rs

1use avail_rust_core::{
2	Error, H256,
3	ext::codec,
4	from_substrate::{FeeDetails, RuntimeDispatchInfo},
5};
6
7use crate::Client;
8
9#[derive(Clone)]
10pub struct RuntimeApi {
11	client: Client,
12}
13
14impl RuntimeApi {
15	pub fn new(client: Client) -> Self {
16		Self { client }
17	}
18
19	pub async fn call<T: codec::Decode>(&self, method: &str, data: &[u8], at: Option<H256>) -> Result<T, Error> {
20		avail_rust_core::runtime_api::call_raw(&self.client.rpc_client, method, data, at).await
21	}
22
23	pub async fn transaction_payment_query_info(
24		&self,
25		extrinsic: Vec<u8>,
26		at: Option<H256>,
27	) -> Result<RuntimeDispatchInfo, Error> {
28		avail_rust_core::runtime_api::api_transaction_payment_query_info(&self.client.rpc_client, extrinsic, at).await
29	}
30
31	pub async fn transaction_payment_query_fee_details(
32		&self,
33		extrinsic: Vec<u8>,
34		at: Option<H256>,
35	) -> Result<FeeDetails, Error> {
36		avail_rust_core::runtime_api::api_transaction_payment_query_fee_details(&self.client.rpc_client, extrinsic, at)
37			.await
38	}
39
40	pub async fn transaction_payment_query_call_info(
41		&self,
42		call: Vec<u8>,
43		at: Option<H256>,
44	) -> Result<RuntimeDispatchInfo, Error> {
45		avail_rust_core::runtime_api::api_transaction_payment_query_call_info(&self.client.rpc_client, call, at).await
46	}
47
48	pub async fn transaction_payment_query_call_fee_details(
49		&self,
50		call: Vec<u8>,
51		at: Option<H256>,
52	) -> Result<FeeDetails, Error> {
53		avail_rust_core::runtime_api::api_transaction_payment_query_call_fee_details(&self.client.rpc_client, call, at)
54			.await
55	}
56}