Crate pallet_block_producer_fees_rpc

Source
Expand description

Json RPC for the Block Producer Fees pallet

§Contents

This crate provides the [BlockProducerFeesRpcApiServer] trait defining the JsonRPC method to display block producer fees and its concrete implementation BlockProducerFeesRpc.

§Usage - PC Builders

To use the Json RPC service defined in this crate, first make your runtime implement sp_block_producer_fees::BlockProducerFeesApi. Eg. assuming the pallet BlockProducerFeesPallet in your runtime uses AccountId as the account id type, the following should be included in your impl_runtime_apis block:

impl BlockProducerFeesApi<Block, AccountId> for Runtime
{
	fn get_all_fees() -> Vec<(AccountId, sp_block_producer_fees::PerTenThousands)> {
		BlockProducerFees::get_all_latest().map(|(account_id, (_slot, fee))| (account_id, fee)).collect()
	}
}

Afterwards, the BlockProducerFeesRpc Json RPC service can be added into the Json RPC stack of your node. Example where AccountId type parameter is set to AccountId32:

use jsonrpsee::RpcModule;
use std::sync::Arc;
use sp_block_producer_fees::*;
use pallet_block_producer_fees_rpc::*;

fn create_rpc<C, Block>(client: Arc<C>) -> Result<RpcModule<()>, Box<dyn std::error::Error>>
where
  C: Send + Sync + 'static,
  Block: sp_runtime::traits::Block,
  C: sp_api::ProvideRuntimeApi<Block>,
  C: sp_blockchain::HeaderBackend<Block>,
  C::Api: BlockProducerFeesApi<Block, sp_runtime::AccountId32>
{
    let mut module = RpcModule::new(());
    module.merge(BlockProducerFeesRpc::new(client.clone()).into_rpc())?;
    // other RPC modules
    Ok(module)
}

Structs§

BlockProducerFeesRpc
Concrete implementation of [BlockProducerFeesRpcApiServer] that uses [BlockProducerFeesRpcApi] for querying runtime storage.
FeesSettings
Fees settings for given account

Traits§

BlockProducerFeesRpcClient
Client implementation for the BlockProducerFeesRpc RPC API.
BlockProducerFeesRpcServer
Server trait implementation for the BlockProducerFeesRpc RPC API.