5 stable releases

1.15.1 Oct 15, 2024
1.15.0 Sep 19, 2024
1.6.2 May 10, 2024
1.6.1 May 6, 2024
1.6.0 May 2, 2024

#8 in #ismp

Download history 126/week @ 2024-09-17 19/week @ 2024-09-24 8/week @ 2024-10-01 156/week @ 2024-10-15 3/week @ 2024-10-22 9/week @ 2024-11-05

168 downloads per month

Apache-2.0 and GPL-3.0-or-later…

220KB
3.5K SLoC

Pallet ISMP RPC

Exports a jsonrpsee handler implementation which provides the neccessary RPC interface for handling ISMP RPC requests.

Usage

/// Full client dependencies
pub struct FullDeps<C, P, B> {
    /// The client instance to use.
    pub client: Arc<C>,
    /// Transaction pool instance.
    pub pool: Arc<P>,
    /// Whether to deny unsafe calls
    pub deny_unsafe: DenyUnsafe,
    /// Backend used by the node.
    pub backend: Arc<B>,
}

/// Instantiate all full RPC extensions.
pub fn create_full<C, P>(
    deps: FullDeps<C, P>,
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
    where
        C: ProvideRuntimeApi<Block>,
        C: HeaderBackend<Block> + HeaderMetadata<Block, Error = BlockChainError> + 'static,
        C: Send + Sync + 'static,
        C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
        C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
        C::Api: BlockBuilder<Block>,
        // pallet_ismp_runtime_api bound
        C::Api: pallet_ismp_runtime_api::IsmpRuntimeApi<Block, H256>,
        P: TransactionPool + 'static,
{
    use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
    use substrate_frame_rpc_system::{System, SystemApiServer};

    let mut module = RpcModule::new(());
    let FullDeps { client, pool, deny_unsafe, backend } = deps;

    module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
    module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
    // IsmpRpcHander goes here
    module.merge(IsmpRpcHandler::new(client, backend)?.into_rpc())?;


    Ok(module)
}

License

This library is licensed under the Apache 2.0 License, Copyright (c) 2024 Polytope Labs.

Dependencies

~90–130MB
~2.5M SLoC