2022-07-15 00:05:00 -04:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
|
|
use jsonrpsee::RpcModule;
|
|
|
|
|
|
|
|
|
|
use sp_blockchain::{Error as BlockchainError, HeaderBackend, HeaderMetadata};
|
|
|
|
|
use sc_transaction_pool_api::TransactionPool;
|
|
|
|
|
use sp_block_builder::BlockBuilder;
|
|
|
|
|
use sp_api::ProvideRuntimeApi;
|
|
|
|
|
|
|
|
|
|
pub use sc_rpc_api::DenyUnsafe;
|
|
|
|
|
|
2022-10-20 01:05:36 -04:00
|
|
|
use serai_runtime::{opaque::Block, AccountId, Balance, Index};
|
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
|
2022-07-17 17:18:56 -04:00
|
|
|
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>
|
|
|
|
|
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
|
|
|
|
|
+ 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-07-16 21:06:54 -04:00
|
|
|
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
|
2022-07-15 00:05:00 -04:00
|
|
|
|
|
|
|
|
Ok(module)
|
|
|
|
|
}
|