referrerpolicy=no-referrer-when-downgrade

revive_dev_node/
rpc.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! A collection of node-specific RPC methods.
19//! Substrate provides the `sc-rpc` crate, which defines the core RPC layer
20//! used by Substrate nodes. This file extends those RPC definitions with
21//! capabilities that are specific to this project's runtime configuration.
22
23#![warn(missing_docs)]
24
25use jsonrpsee::RpcModule;
26use polkadot_sdk::{
27	sc_transaction_pool_api::TransactionPool,
28	sp_blockchain::{Error as BlockChainError, HeaderBackend, HeaderMetadata},
29	*,
30};
31use revive_dev_runtime::{AccountId, Nonce, OpaqueBlock};
32use std::sync::Arc;
33
34/// Full client dependencies.
35pub struct FullDeps<C, P> {
36	/// The client instance to use.
37	pub client: Arc<C>,
38	/// Transaction pool instance.
39	pub pool: Arc<P>,
40}
41
42#[docify::export]
43/// Instantiate all full RPC extensions.
44pub fn create_full<C, P>(
45	deps: FullDeps<C, P>,
46) -> Result<RpcModule<()>, Box<dyn std::error::Error + Send + Sync>>
47where
48	C: Send
49		+ Sync
50		+ 'static
51		+ sp_api::ProvideRuntimeApi<OpaqueBlock>
52		+ HeaderBackend<OpaqueBlock>
53		+ HeaderMetadata<OpaqueBlock, Error = BlockChainError>
54		+ 'static,
55	C::Api: sp_block_builder::BlockBuilder<OpaqueBlock>,
56	C::Api: substrate_frame_rpc_system::AccountNonceApi<OpaqueBlock, AccountId, Nonce>,
57	P: TransactionPool + 'static,
58{
59	use polkadot_sdk::substrate_frame_rpc_system::{System, SystemApiServer};
60	let mut module = RpcModule::new(());
61	let FullDeps { client, pool } = deps;
62
63	module.merge(System::new(client.clone(), pool.clone()).into_rpc())?;
64
65	Ok(module)
66}