diff --git a/bin/node-template/node/src/rpc.rs b/bin/node-template/node/src/rpc.rs index 7edae4d81474f..981f375d0b462 100644 --- a/bin/node-template/node/src/rpc.rs +++ b/bin/node-template/node/src/rpc.rs @@ -39,14 +39,14 @@ where C::Api: BlockBuilder, P: TransactionPool + 'static, { - use pallet_transaction_payment_rpc::{TransactionPaymentApiServer, TransactionPaymentRpc}; - use substrate_frame_rpc_system::{SystemApiServer, SystemRpc}; + 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 } = deps; - module.merge(SystemRpc::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?; - module.merge(TransactionPaymentRpc::new(client).into_rpc())?; + module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?; + module.merge(TransactionPayment::new(client).into_rpc())?; // Extend this RPC with a custom API by using the following syntax. // `YourRpcStruct` should have a reference to a client, which is needed diff --git a/bin/node/rpc/src/lib.rs b/bin/node/rpc/src/lib.rs index 05aa973e102b1..e5b666195e1bc 100644 --- a/bin/node/rpc/src/lib.rs +++ b/bin/node/rpc/src/lib.rs @@ -37,12 +37,10 @@ use jsonrpsee::RpcModule; use node_primitives::{AccountId, Balance, Block, BlockNumber, Hash, Index}; use sc_client_api::AuxStore; use sc_consensus_babe::{Config, Epoch}; -use sc_consensus_babe_rpc::BabeRpc; use sc_consensus_epochs::SharedEpochChanges; use sc_finality_grandpa::{ FinalityProofProvider, GrandpaJustificationStream, SharedAuthoritySet, SharedVoterState, }; -use sc_finality_grandpa_rpc::GrandpaRpc; use sc_rpc::SubscriptionTaskExecutor; pub use sc_rpc_api::DenyUnsafe; use sc_transaction_pool_api::TransactionPool; @@ -120,15 +118,15 @@ where B: sc_client_api::Backend + Send + Sync + 'static, B::State: sc_client_api::backend::StateBackend>, { - use pallet_contracts_rpc::{ContractsApiServer, ContractsRpc}; - use pallet_mmr_rpc::{MmrApiServer, MmrRpc}; - use pallet_transaction_payment_rpc::{TransactionPaymentApiServer, TransactionPaymentRpc}; - use sc_consensus_babe_rpc::BabeApiServer; - use sc_finality_grandpa_rpc::GrandpaApiServer; + use pallet_contracts_rpc::{Contracts, ContractsApiServer}; + use pallet_mmr_rpc::{Mmr, MmrApiServer}; + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use sc_consensus_babe_rpc::{Babe, BabeApiServer}; + use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer}; use sc_rpc::dev::{Dev, DevApiServer}; - use sc_sync_state_rpc::{SyncStateRpc, SyncStateRpcApiServer}; - use substrate_frame_rpc_system::{SystemApiServer, SystemRpc}; - use substrate_state_trie_migration_rpc::StateMigrationApiServer; + use sc_sync_state_rpc::{SyncState, SyncStateApiServer}; + use substrate_frame_rpc_system::{System, SystemApiServer}; + use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer}; let mut io = RpcModule::new(()); let FullDeps { client, pool, select_chain, chain_spec, deny_unsafe, babe, grandpa } = deps; @@ -142,15 +140,15 @@ where finality_provider, } = grandpa; - io.merge(SystemRpc::new(client.clone(), pool, deny_unsafe).into_rpc())?; + io.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?; // Making synchronous calls in light client freezes the browser currently, // more context: https://github.com/paritytech/substrate/pull/3480 // These RPCs should use an asynchronous caller instead. - io.merge(ContractsRpc::new(client.clone()).into_rpc())?; - io.merge(MmrRpc::new(client.clone()).into_rpc())?; - io.merge(TransactionPaymentRpc::new(client.clone()).into_rpc())?; + io.merge(Contracts::new(client.clone()).into_rpc())?; + io.merge(Mmr::new(client.clone()).into_rpc())?; + io.merge(TransactionPayment::new(client.clone()).into_rpc())?; io.merge( - BabeRpc::new( + Babe::new( client.clone(), shared_epoch_changes.clone(), keystore, @@ -161,7 +159,7 @@ where .into_rpc(), )?; io.merge( - GrandpaRpc::new( + Grandpa::new( subscription_executor, shared_authority_set.clone(), shared_voter_state, @@ -172,14 +170,11 @@ where )?; io.merge( - SyncStateRpc::new(chain_spec, client.clone(), shared_authority_set, shared_epoch_changes)? + SyncState::new(chain_spec, client.clone(), shared_authority_set, shared_epoch_changes)? .into_rpc(), )?; - io.merge( - substrate_state_trie_migration_rpc::MigrationRpc::new(client.clone(), backend, deny_unsafe) - .into_rpc(), - )?; + io.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?; io.merge(Dev::new(client, deny_unsafe).into_rpc())?; Ok(io) diff --git a/client/beefy/rpc/src/lib.rs b/client/beefy/rpc/src/lib.rs index ea35678a48b8f..c248d33cb6c23 100644 --- a/client/beefy/rpc/src/lib.rs +++ b/client/beefy/rpc/src/lib.rs @@ -100,17 +100,17 @@ pub trait BeefyApi { } /// Implements the BeefyApi RPC trait for interacting with BEEFY. -pub struct BeefyRpcHandler { +pub struct Beefy { signed_commitment_stream: BeefySignedCommitmentStream, beefy_best_block: Arc>>, executor: SubscriptionTaskExecutor, } -impl BeefyRpcHandler +impl Beefy where Block: BlockT, { - /// Creates a new BeefyRpcHandler instance. + /// Creates a new Beefy Rpc handler instance. pub fn new( signed_commitment_stream: BeefySignedCommitmentStream, best_block_stream: BeefyBestBlockStream, @@ -131,8 +131,7 @@ where } #[async_trait] -impl BeefyApiServer - for BeefyRpcHandler +impl BeefyApiServer for Beefy where Block: BlockT, { @@ -174,24 +173,20 @@ mod tests { use sp_runtime::traits::{BlakeTwo256, Hash}; use substrate_test_runtime_client::runtime::Block; - fn setup_io_handler() -> (RpcModule>, BeefySignedCommitmentSender) - { + fn setup_io_handler() -> (RpcModule>, BeefySignedCommitmentSender) { let (_, stream) = BeefyBestBlockStream::::channel(); setup_io_handler_with_best_block_stream(stream) } fn setup_io_handler_with_best_block_stream( best_block_stream: BeefyBestBlockStream, - ) -> (RpcModule>, BeefySignedCommitmentSender) { + ) -> (RpcModule>, BeefySignedCommitmentSender) { let (commitment_sender, commitment_stream) = BeefySignedCommitmentStream::::channel(); - let handler = BeefyRpcHandler::new( - commitment_stream, - best_block_stream, - sc_rpc::testing::test_executor(), - ) - .expect("Setting up the BEEFY RPC handler works"); + let handler = + Beefy::new(commitment_stream, best_block_stream, sc_rpc::testing::test_executor()) + .expect("Setting up the BEEFY RPC handler works"); (handler.into_rpc(), commitment_sender) } diff --git a/client/consensus/babe/rpc/src/lib.rs b/client/consensus/babe/rpc/src/lib.rs index d5f21606c62ed..af19d410346e3 100644 --- a/client/consensus/babe/rpc/src/lib.rs +++ b/client/consensus/babe/rpc/src/lib.rs @@ -49,7 +49,7 @@ pub trait BabeApi { } /// Provides RPC methods for interacting with Babe. -pub struct BabeRpc { +pub struct Babe { /// shared reference to the client. client: Arc, /// shared reference to EpochChanges @@ -64,8 +64,8 @@ pub struct BabeRpc { deny_unsafe: DenyUnsafe, } -impl BabeRpc { - /// Creates a new instance of the BabeRpc handler. +impl Babe { + /// Creates a new instance of the Babe Rpc handler. pub fn new( client: Arc, shared_epoch_changes: SharedEpochChanges, @@ -79,7 +79,7 @@ impl BabeRpc { } #[async_trait] -impl BabeApiServer for BabeRpc +impl BabeApiServer for Babe where B: BlockT, C: ProvideRuntimeApi @@ -239,7 +239,7 @@ mod tests { fn test_babe_rpc_module( deny_unsafe: DenyUnsafe, - ) -> BabeRpc> { + ) -> Babe> { let builder = TestClientBuilder::new(); let (client, longest_chain) = builder.build_with_longest_chain(); let client = Arc::new(client); @@ -250,7 +250,7 @@ mod tests { let epoch_changes = link.epoch_changes().clone(); let keystore = create_temp_keystore::(Sr25519Keyring::Alice).0; - BabeRpc::new(client.clone(), epoch_changes, keystore, config, longest_chain, deny_unsafe) + Babe::new(client.clone(), epoch_changes, keystore, config, longest_chain, deny_unsafe) } #[tokio::test] diff --git a/client/finality-grandpa/rpc/src/lib.rs b/client/finality-grandpa/rpc/src/lib.rs index cb51d71b20bf4..bdb86c125e20a 100644 --- a/client/finality-grandpa/rpc/src/lib.rs +++ b/client/finality-grandpa/rpc/src/lib.rs @@ -66,7 +66,7 @@ pub trait GrandpaApi { } /// Provides RPC methods for interacting with GRANDPA. -pub struct GrandpaRpc { +pub struct Grandpa { executor: SubscriptionTaskExecutor, authority_set: AuthoritySet, voter_state: VoterState, @@ -74,9 +74,9 @@ pub struct GrandpaRpc { finality_proof_provider: Arc, } impl - GrandpaRpc + Grandpa { - /// Prepare a new [`GrandpaRpc`] + /// Prepare a new [`Grandpa`] Rpc handler. pub fn new( executor: SubscriptionTaskExecutor, authority_set: AuthoritySet, @@ -91,7 +91,7 @@ impl #[async_trait] impl GrandpaApiServer> - for GrandpaRpc + for Grandpa where VoterState: ReportVoterState + Send + Sync + 'static, AuthoritySet: ReportAuthoritySet + Send + Sync + 'static, @@ -243,7 +243,7 @@ mod tests { fn setup_io_handler( voter_state: VoterState, ) -> ( - RpcModule>, + RpcModule>, GrandpaJustificationSender, ) where @@ -256,7 +256,7 @@ mod tests { voter_state: VoterState, finality_proof: Option>, ) -> ( - RpcModule>, + RpcModule>, GrandpaJustificationSender, ) where @@ -266,7 +266,7 @@ mod tests { let finality_proof_provider = Arc::new(TestFinalityProofProvider { finality_proof }); let executor = Arc::new(TaskExecutor::default()); - let rpc = GrandpaRpc::new( + let rpc = Grandpa::new( executor, TestAuthoritySet, voter_state, diff --git a/client/rpc/src/state/mod.rs b/client/rpc/src/state/mod.rs index 4b5b74950a486..232be4edc8aab 100644 --- a/client/rpc/src/state/mod.rs +++ b/client/rpc/src/state/mod.rs @@ -167,7 +167,7 @@ pub fn new_full( executor: SubscriptionTaskExecutor, deny_unsafe: DenyUnsafe, rpc_max_payload: Option, -) -> (StateApi, ChildState) +) -> (State, ChildState) where Block: BlockT + 'static, Block::Hash: Unpin, @@ -192,17 +192,17 @@ where rpc_max_payload, )); let backend = Box::new(self::state_full::FullState::new(client, executor, rpc_max_payload)); - (StateApi { backend, deny_unsafe }, ChildState { backend: child_backend }) + (State { backend, deny_unsafe }, ChildState { backend: child_backend }) } /// State API with subscriptions support. -pub struct StateApi { +pub struct State { backend: Box>, /// Whether to deny unsafe calls deny_unsafe: DenyUnsafe, } -impl StateApiServer for StateApi +impl StateApiServer for State where Block: BlockT + 'static, Client: Send + Sync + 'static, diff --git a/client/sync-state-rpc/src/lib.rs b/client/sync-state-rpc/src/lib.rs index 02a22a838b8b2..9540d94c57918 100644 --- a/client/sync-state-rpc/src/lib.rs +++ b/client/sync-state-rpc/src/lib.rs @@ -37,7 +37,7 @@ //! ``` //! //! If the [`LightSyncStateExtension`] is not added as an extension to the chain spec, -//! the [`SyncStateRpc`] will fail at instantiation. +//! the [`SyncState`] will fail at instantiation. #![deny(unused_crate_dependencies)] @@ -125,21 +125,21 @@ pub struct LightSyncState { /// An api for sync state RPC calls. #[rpc(client, server)] -pub trait SyncStateRpcApi { +pub trait SyncStateApi { /// Returns the JSON serialized chainspec running the node, with a sync state. #[method(name = "sync_state_genSyncSpec")] fn system_gen_sync_spec(&self, raw: bool) -> RpcResult; } /// An api for sync state RPC calls. -pub struct SyncStateRpc { +pub struct SyncState { chain_spec: Box, client: Arc, shared_authority_set: SharedAuthoritySet, shared_epoch_changes: SharedEpochChanges, } -impl SyncStateRpc +impl SyncState where Block: BlockT, Client: HeaderBackend + sc_client_api::AuxStore + 'static, @@ -180,7 +180,7 @@ where } } -impl SyncStateRpcApiServer for SyncStateRpc +impl SyncStateApiServer for SyncState where Block: BlockT, Backend: HeaderBackend + sc_client_api::AuxStore + 'static, diff --git a/frame/contracts/rpc/src/lib.rs b/frame/contracts/rpc/src/lib.rs index 599e80676cb19..77ae3f3ed35e3 100644 --- a/frame/contracts/rpc/src/lib.rs +++ b/frame/contracts/rpc/src/lib.rs @@ -173,12 +173,12 @@ where } /// Contracts RPC methods. -pub struct ContractsRpc { +pub struct Contracts { client: Arc, _marker: PhantomData, } -impl ContractsRpc { +impl Contracts { /// Create new `Contracts` with the given reference to the client. pub fn new(client: Arc) -> Self { Self { client, _marker: Default::default() } @@ -193,7 +193,7 @@ impl AccountId, Balance, Hash, - > for ContractsRpc + > for Contracts where Block: BlockT, Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, diff --git a/frame/merkle-mountain-range/rpc/src/lib.rs b/frame/merkle-mountain-range/rpc/src/lib.rs index 12e4e11f88256..75032d40f492a 100644 --- a/frame/merkle-mountain-range/rpc/src/lib.rs +++ b/frame/merkle-mountain-range/rpc/src/lib.rs @@ -131,12 +131,12 @@ pub trait MmrApi { } /// MMR RPC methods. -pub struct MmrRpc { +pub struct Mmr { client: Arc, _marker: PhantomData, } -impl MmrRpc { +impl Mmr { /// Create new `Mmr` with the given reference to the client. pub fn new(client: Arc) -> Self { Self { client, _marker: Default::default() } @@ -144,8 +144,7 @@ impl MmrRpc { } #[async_trait] -impl MmrApiServer<::Hash> - for MmrRpc +impl MmrApiServer<::Hash> for Mmr where Block: BlockT, Client: Send + Sync + 'static + ProvideRuntimeApi + HeaderBackend, diff --git a/frame/transaction-payment/rpc/src/lib.rs b/frame/transaction-payment/rpc/src/lib.rs index b0be19fdb22a9..75ec42321ef5e 100644 --- a/frame/transaction-payment/rpc/src/lib.rs +++ b/frame/transaction-payment/rpc/src/lib.rs @@ -51,14 +51,14 @@ pub trait TransactionPaymentApi { } /// Provides RPC methods to query a dispatchable's class, weight and fee. -pub struct TransactionPaymentRpc { +pub struct TransactionPayment { /// Shared reference to the client. client: Arc, _marker: std::marker::PhantomData

, } -impl TransactionPaymentRpc { - /// Creates a new instance of the TransactionPaymentRpc helper. +impl TransactionPayment { + /// Creates a new instance of the TransactionPayment Rpc helper. pub fn new(client: Arc) -> Self { Self { client, _marker: Default::default() } } @@ -84,7 +84,7 @@ impl From for i32 { #[async_trait] impl TransactionPaymentApiServer<::Hash, RuntimeDispatchInfo> - for TransactionPaymentRpc + for TransactionPayment where Block: BlockT, C: ProvideRuntimeApi + HeaderBackend + Send + Sync + 'static, diff --git a/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs b/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs index 531bf463f6523..b6d403ff2fcfd 100644 --- a/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs +++ b/utils/frame/rpc/state-trie-migration-rpc/src/lib.rs @@ -122,21 +122,21 @@ pub trait StateMigrationApi { } /// An implementation of state migration specific RPC methods. -pub struct MigrationRpc { +pub struct StateMigration { client: Arc, backend: Arc, deny_unsafe: DenyUnsafe, _marker: std::marker::PhantomData<(B, BA)>, } -impl MigrationRpc { +impl StateMigration { /// Create new state migration rpc for the given reference to the client. pub fn new(client: Arc, backend: Arc, deny_unsafe: DenyUnsafe) -> Self { - MigrationRpc { client, backend, deny_unsafe, _marker: Default::default() } + StateMigration { client, backend, deny_unsafe, _marker: Default::default() } } } -impl StateMigrationApiServer<::Hash> for MigrationRpc +impl StateMigrationApiServer<::Hash> for StateMigration where B: BlockT, C: Send + Sync + 'static + sc_client_api::HeaderBackend, diff --git a/utils/frame/rpc/system/src/lib.rs b/utils/frame/rpc/system/src/lib.rs index b044035c8120e..72ad99e435f72 100644 --- a/utils/frame/rpc/system/src/lib.rs +++ b/utils/frame/rpc/system/src/lib.rs @@ -70,14 +70,14 @@ impl From for i32 { } /// An implementation of System-specific RPC methods on full client. -pub struct SystemRpc { +pub struct System { client: Arc, pool: Arc

, deny_unsafe: DenyUnsafe, _marker: std::marker::PhantomData, } -impl SystemRpc { +impl System { /// Create new `FullSystem` given client and transaction pool. pub fn new(client: Arc, pool: Arc

, deny_unsafe: DenyUnsafe) -> Self { Self { client, pool, deny_unsafe, _marker: Default::default() } @@ -86,7 +86,7 @@ impl SystemRpc { #[async_trait] impl - SystemApiServer<::Hash, AccountId, Index> for SystemRpc + SystemApiServer<::Hash, AccountId, Index> for System where C: sp_api::ProvideRuntimeApi, C: HeaderBackend, @@ -251,7 +251,7 @@ mod tests { let ext1 = new_transaction(1); block_on(pool.submit_one(&BlockId::number(0), source, ext1)).unwrap(); - let accounts = SystemRpc::new(client, pool, DenyUnsafe::Yes); + let accounts = System::new(client, pool, DenyUnsafe::Yes); // when let nonce = accounts.nonce(AccountKeyring::Alice.into()).await; @@ -270,7 +270,7 @@ mod tests { let pool = BasicPool::new_full(Default::default(), true.into(), None, spawner, client.clone()); - let accounts = SystemRpc::new(client, pool, DenyUnsafe::Yes); + let accounts = System::new(client, pool, DenyUnsafe::Yes); // when let res = accounts.dry_run(vec![].into(), None).await; @@ -289,7 +289,7 @@ mod tests { let pool = BasicPool::new_full(Default::default(), true.into(), None, spawner, client.clone()); - let accounts = SystemRpc::new(client, pool, DenyUnsafe::No); + let accounts = System::new(client, pool, DenyUnsafe::No); let tx = Transfer { from: AccountKeyring::Alice.into(), @@ -317,7 +317,7 @@ mod tests { let pool = BasicPool::new_full(Default::default(), true.into(), None, spawner, client.clone()); - let accounts = SystemRpc::new(client, pool, DenyUnsafe::No); + let accounts = System::new(client, pool, DenyUnsafe::No); let tx = Transfer { from: AccountKeyring::Alice.into(),