substrate_api_client/api/runtime_api/
transaction_payment_call.rs1use super::{RuntimeApi, RuntimeApiClient};
15use crate::{api::Result, rpc::Request};
16use ac_primitives::{config::Config, FeeDetails, RuntimeDispatchInfo, Weight};
17#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
18use alloc::boxed::Box;
19use alloc::vec;
20use sp_core::Encode;
21
22#[maybe_async::maybe_async(?Send)]
23pub trait TransactionPaymentCallApi: RuntimeApi {
24 type FeeDetails;
25 type RuntimeDispatchInfo;
26 type Balance;
27 type Weight;
28
29 async fn query_call_fee_details<Call: Encode>(
31 &self,
32 call: Call,
33 length: u32,
34 at_block: Option<Self::Hash>,
35 ) -> Result<Self::FeeDetails>;
36
37 async fn query_call_info<Call: Encode>(
39 &self,
40 call: Call,
41 length: u32,
42 at_block: Option<Self::Hash>,
43 ) -> Result<Self::RuntimeDispatchInfo>;
44
45 async fn query_length_to_fee_call(
47 &self,
48 length: u32,
49 at_block: Option<Self::Hash>,
50 ) -> Result<Self::Balance>;
51
52 async fn query_weight_to_fee_call(
54 &self,
55 weight: Self::Weight,
56 at_block: Option<Self::Hash>,
57 ) -> Result<Self::Balance>;
58}
59
60#[maybe_async::maybe_async(?Send)]
61impl<T, Client> TransactionPaymentCallApi for RuntimeApiClient<T, Client>
62where
63 T: Config,
64 Client: Request,
65{
66 type FeeDetails = FeeDetails<T::Balance>;
67 type RuntimeDispatchInfo = RuntimeDispatchInfo<T::Balance>;
68 type Balance = T::Balance;
69 type Weight = Weight;
70
71 async fn query_call_fee_details<Call: Encode>(
72 &self,
73 call: Call,
74 length: u32,
75 at_block: Option<Self::Hash>,
76 ) -> Result<Self::FeeDetails> {
77 self.runtime_call(
78 "TransactionPaymentCallApi_query_call_fee_details",
79 vec![call.encode(), length.encode()],
80 at_block,
81 )
82 .await
83 }
84
85 async fn query_call_info<Call: Encode>(
86 &self,
87 call: Call,
88 length: u32,
89 at_block: Option<Self::Hash>,
90 ) -> Result<Self::RuntimeDispatchInfo> {
91 self.runtime_call(
92 "TransactionPaymentCallApi_query_call_info",
93 vec![call.encode(), length.encode()],
94 at_block,
95 )
96 .await
97 }
98
99 async fn query_length_to_fee_call(
100 &self,
101 length: u32,
102 at_block: Option<Self::Hash>,
103 ) -> Result<Self::Balance> {
104 self.runtime_call(
105 "TransactionPaymentCallApi_query_length_to_fee",
106 vec![length.encode()],
107 at_block,
108 )
109 .await
110 }
111
112 async fn query_weight_to_fee_call(
113 &self,
114 weight: Self::Weight,
115 at_block: Option<Self::Hash>,
116 ) -> Result<Self::Balance> {
117 self.runtime_call(
118 "TransactionPaymentCallApi_query_weight_to_fee",
119 vec![weight.encode()],
120 at_block,
121 )
122 .await
123 }
124}