mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 09:31:12 +00:00
RPC to query transaction fee + weight + info (#3876)
* initial version for testing * New version that compiles * optional at block parameter * Fix some more view grumbles. * Update srml/transaction-payment/src/lib.rs
This commit is contained in:
@@ -8,7 +8,9 @@ edition = "2018"
|
||||
client = { package = "substrate-client", path = "../../core/client" }
|
||||
jsonrpc-core = "13.2.0"
|
||||
node-primitives = { path = "../primitives" }
|
||||
node-runtime = { path = "../runtime" }
|
||||
sr-primitives = { path = "../../core/sr-primitives" }
|
||||
srml-contracts-rpc = { path = "../../srml/contracts/rpc/" }
|
||||
srml-transaction-payment-rpc = { path = "../../srml/transaction-payment/rpc/" }
|
||||
srml-system-rpc = { path = "../../srml/system/rpc/" }
|
||||
transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" }
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use node_primitives::{Block, AccountId, Index, Balance};
|
||||
use node_runtime::UncheckedExtrinsic;
|
||||
use sr_primitives::traits::ProvideRuntimeApi;
|
||||
use transaction_pool::txpool::{ChainApi, Pool};
|
||||
|
||||
@@ -42,18 +43,23 @@ pub fn create<C, P, M>(client: Arc<C>, pool: Arc<Pool<P>>) -> jsonrpc_core::IoHa
|
||||
C: Send + Sync + 'static,
|
||||
C::Api: srml_system_rpc::AccountNonceApi<Block, AccountId, Index>,
|
||||
C::Api: srml_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance>,
|
||||
C::Api: srml_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance, UncheckedExtrinsic>,
|
||||
P: ChainApi + Sync + Send + 'static,
|
||||
M: jsonrpc_core::Metadata + Default,
|
||||
{
|
||||
use srml_system_rpc::{System, SystemApi};
|
||||
use srml_contracts_rpc::{Contracts, ContractsApi};
|
||||
use srml_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
|
||||
|
||||
let mut io = jsonrpc_core::IoHandler::default();
|
||||
io.extend_with(
|
||||
SystemApi::to_delegate(System::new(client.clone(), pool))
|
||||
);
|
||||
io.extend_with(
|
||||
ContractsApi::to_delegate(Contracts::new(client))
|
||||
ContractsApi::to_delegate(Contracts::new(client.clone()))
|
||||
);
|
||||
io.extend_with(
|
||||
TransactionPaymentApi::to_delegate(TransactionPayment::new(client))
|
||||
);
|
||||
io
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ timestamp = { package = "srml-timestamp", path = "../../srml/timestamp", default
|
||||
treasury = { package = "srml-treasury", path = "../../srml/treasury", default-features = false }
|
||||
utility = { package = "srml-utility", path = "../../srml/utility", default-features = false }
|
||||
transaction-payment = { package = "srml-transaction-payment", path = "../../srml/transaction-payment", default-features = false }
|
||||
transaction-payment-rpc-runtime-api = { package = "srml-transaction-payment-rpc-runtime-api", path = "../../srml/transaction-payment/rpc/runtime-api/", default-features = false }
|
||||
|
||||
[build-dependencies]
|
||||
wasm-builder-runner = { package = "substrate-wasm-builder-runner", version = "1.0.4", path = "../../core/utils/wasm-builder-runner" }
|
||||
@@ -103,5 +104,6 @@ std = [
|
||||
"treasury/std",
|
||||
"utility/std",
|
||||
"transaction-payment/std",
|
||||
"transaction-payment-rpc-runtime-api/std",
|
||||
"version/std",
|
||||
]
|
||||
|
||||
@@ -50,6 +50,8 @@ use version::NativeVersion;
|
||||
use primitives::OpaqueMetadata;
|
||||
use grandpa::{AuthorityId as GrandpaId, AuthorityWeight as GrandpaWeight};
|
||||
use im_online::sr25519::{AuthorityId as ImOnlineId};
|
||||
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
|
||||
use contracts_rpc_runtime_api::ContractExecResult;
|
||||
use system::offchain::TransactionSubmitter;
|
||||
|
||||
#[cfg(any(feature = "std", test))]
|
||||
@@ -661,9 +663,7 @@ impl_runtime_apis! {
|
||||
value: Balance,
|
||||
gas_limit: u64,
|
||||
input_data: Vec<u8>,
|
||||
) -> contracts_rpc_runtime_api::ContractExecResult {
|
||||
use contracts_rpc_runtime_api::ContractExecResult;
|
||||
|
||||
) -> ContractExecResult {
|
||||
let exec_result = Contracts::bare_call(
|
||||
origin,
|
||||
dest.into(),
|
||||
@@ -681,9 +681,20 @@ impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl transaction_payment_rpc_runtime_api::TransactionPaymentApi<
|
||||
Block,
|
||||
Balance,
|
||||
UncheckedExtrinsic,
|
||||
> for Runtime {
|
||||
fn query_info(uxt: UncheckedExtrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
|
||||
TransactionPayment::query_info(uxt, len)
|
||||
}
|
||||
}
|
||||
|
||||
impl substrate_session::SessionKeys<Block> for Runtime {
|
||||
fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
|
||||
let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s).expect("Seed is an utf8 string"));
|
||||
let seed = seed.as_ref().map(|s| rstd::str::from_utf8(&s)
|
||||
.expect("Seed is an utf8 string"));
|
||||
SessionKeys::generate(seed)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user