From 4a94de77754d85e5a8b85624980254fca103f62e Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 14 Dec 2021 13:47:32 +0300 Subject: [PATCH] Add missing RPC APIs to rialto parachain node (#1250) * add missing RPC APIs to rialto parachain node * spellcheck --- .../bin/rialto-parachain/node/src/service.rs | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/bridges/bin/rialto-parachain/node/src/service.rs b/bridges/bin/rialto-parachain/node/src/service.rs index bd3afca307449..54e626e0ead19 100644 --- a/bridges/bin/rialto-parachain/node/src/service.rs +++ b/bridges/bin/rialto-parachain/node/src/service.rs @@ -14,6 +14,13 @@ // You should have received a copy of the GNU General Public License // along with Parity Bridges Common. If not, see . +//! Rialto parachain node service. +//! +//! The code is mostly copy of `polkadot-parachains/src/service.rs` file from Cumulus +//! repository with some parts removed. We have added two RPC extensions to the original +//! service: `pallet_transaction_payment_rpc::TransactionPaymentApi` and +//! `substrate_frame_rpc_system::SystemApi`. + // std use std::sync::Arc; @@ -212,7 +219,14 @@ where sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, Executor: NativeExecutionDispatch + 'static, RB: Fn( + sc_rpc_api::DenyUnsafe, Arc>>, + Arc< + sc_transaction_pool::FullPool< + Block, + TFullClient>, + >, + >, ) -> jsonrpc_core::IoHandler + Send + 'static, @@ -288,7 +302,10 @@ where })?; let rpc_client = client.clone(); - let rpc_extensions_builder = Box::new(move |_, _| Ok(rpc_ext_builder(rpc_client.clone()))); + let rpc_transaction_pool = transaction_pool.clone(); + let rpc_extensions_builder = Box::new(move |deny_unsafe, _| { + Ok(rpc_ext_builder(deny_unsafe, rpc_client.clone(), rpc_transaction_pool.clone())) + }); sc_service::spawn_tasks(sc_service::SpawnTasksParams { rpc_extensions_builder, @@ -412,7 +429,19 @@ pub async fn start_node( parachain_config, polkadot_config, id, - |_| Default::default(), + |deny_unsafe, client, pool| { + use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi}; + use substrate_frame_rpc_system::{FullSystem, SystemApi}; + + let mut io = jsonrpc_core::IoHandler::default(); + io.extend_with(SystemApi::to_delegate(FullSystem::new( + client.clone(), + pool, + deny_unsafe, + ))); + io.extend_with(TransactionPaymentApi::to_delegate(TransactionPayment::new(client))); + io + }, parachain_build_import_queue, |client, prometheus_registry,