Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds transaction payment rpc in minimal template #4516

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions templates/minimal/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ sp-block-builder = { path = "../../../substrate/primitives/block-builder" }
sp-io = { path = "../../../substrate/primitives/io" }
sp-runtime = { path = "../../../substrate/primitives/runtime" }

pallet-transaction-payment-rpc = { path = "../../../substrate/frame/transaction-payment/rpc" }
substrate-frame-rpc-system = { path = "../../../substrate/utils/frame/rpc/system" }

# Once the native runtime is gone, there should be little to no dependency on FRAME here, and
Expand Down
5 changes: 4 additions & 1 deletion templates/minimal/node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
#![warn(missing_docs)]

use jsonrpsee::RpcModule;
use runtime::interface::{AccountId, Nonce, OpaqueBlock};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use runtime::interface::{AccountId, Balance, Nonce, OpaqueBlock};
use sc_transaction_pool_api::TransactionPool;
use sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata};
use std::sync::Arc;
Expand Down Expand Up @@ -55,12 +56,14 @@ where
+ 'static,
C::Api: sp_block_builder::BlockBuilder<OpaqueBlock>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<OpaqueBlock, Balance>,
P: TransactionPool + 'static,
{
let mut module = RpcModule::new(());
let FullDeps { client, pool, deny_unsafe } = deps;

module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;

Ok(module)
}
26 changes: 26 additions & 0 deletions templates/minimal/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,32 @@ impl_runtime_apis! {
}
}

impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentCallApi<
Block,
interface::Balance,
RuntimeCall
> for Runtime
{
fn query_call_info(
call: RuntimeCall,
len: u32,
) -> RuntimeDispatchInfo<interface::Balance> {
TransactionPayment::query_call_info(call, len)
}
fn query_call_fee_details(
call: RuntimeCall,
len: u32,
) -> FeeDetails<interface::Balance> {
TransactionPayment::query_call_fee_details(call, len)
}
fn query_weight_to_fee(weight: Weight) -> interface::Balance {
TransactionPayment::weight_to_fee(weight)
}
fn query_length_to_fee(length: u32) -> interface::Balance {
TransactionPayment::length_to_fee(length)
}
}

impl sp_genesis_builder::GenesisBuilder<Block> for Runtime {
fn build_state(config: Vec<u8>) -> sp_genesis_builder::Result {
build_state::<RuntimeGenesisConfig>(config)
Expand Down
Loading