2022-07-15 00:05:00 -04:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
use jsonrpsee::RpcModule;
|
|
|
|
|
|
|
|
|
|
use sp_blockchain::{Error as BlockchainError, HeaderBackend, HeaderMetadata};
|
|
|
|
|
use sp_block_builder::BlockBuilder;
|
|
|
|
|
use sp_api::ProvideRuntimeApi;
|
|
|
|
|
|
2023-01-28 01:47:13 -05:00
|
|
|
use serai_runtime::{
|
|
|
|
|
primitives::{SubstrateAmount, PublicKey},
|
2023-12-06 09:53:06 -05:00
|
|
|
Nonce, Block,
|
2023-01-28 01:47:13 -05:00
|
|
|
};
|
2022-07-15 00:05:00 -04:00
|
|
|
|
2023-01-20 11:00:18 -05:00
|
|
|
pub use sc_rpc_api::DenyUnsafe;
|
|
|
|
|
use sc_transaction_pool_api::TransactionPool;
|
2022-07-15 00:05:00 -04:00
|
|
|
|
|
|
|
|
pub struct FullDeps<C, P> {
|
|
|
|
|
pub client: Arc<C>,
|
|
|
|
|
pub pool: Arc<P>,
|
2022-07-15 01:26:07 -04:00
|
|
|
pub deny_unsafe: DenyUnsafe,
|
2022-07-15 00:05:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn create_full<
|
2022-07-15 01:26:07 -04:00
|
|
|
C: ProvideRuntimeApi<Block>
|
|
|
|
|
+ HeaderBackend<Block>
|
|
|
|
|
+ HeaderMetadata<Block, Error = BlockchainError>
|
|
|
|
|
+ Send
|
|
|
|
|
+ Sync
|
|
|
|
|
+ 'static,
|
|
|
|
|
P: TransactionPool + 'static,
|
2022-07-15 00:05:00 -04:00
|
|
|
>(
|
2022-07-15 01:26:07 -04:00
|
|
|
deps: FullDeps<C, P>,
|
2022-07-15 00:05:00 -04:00
|
|
|
) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
|
2022-07-15 01:26:07 -04:00
|
|
|
where
|
2023-07-18 23:52:37 -04:00
|
|
|
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, PublicKey, Nonce>
|
2023-01-28 01:47:13 -05:00
|
|
|
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, SubstrateAmount>
|
2022-07-17 17:18:56 -04:00
|
|
|
+ BlockBuilder<Block>,
|
2022-07-15 01:26:07 -04:00
|
|
|
{
|
2022-07-15 00:05:00 -04:00
|
|
|
use substrate_frame_rpc_system::{System, SystemApiServer};
|
2022-07-16 21:06:54 -04:00
|
|
|
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
|
2022-07-15 00:05:00 -04:00
|
|
|
|
|
|
|
|
let mut module = RpcModule::new(());
|
|
|
|
|
let FullDeps { client, pool, deny_unsafe } = deps;
|
|
|
|
|
|
2022-07-22 02:34:36 -04:00
|
|
|
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
|
2022-10-21 01:08:15 -05:00
|
|
|
module.merge(TransactionPayment::new(client).into_rpc())?;
|
2022-07-15 00:05:00 -04:00
|
|
|
|
|
|
|
|
Ok(module)
|
|
|
|
|
}
|