Skip to content

Commit

Permalink
Add missing RPC APIs to rialto parachain node (paritytech#1250)
Browse files Browse the repository at this point in the history
* add missing RPC APIs to rialto parachain node

* spellcheck
  • Loading branch information
svyatonik authored and serban300 committed Apr 10, 2024
1 parent d198755 commit 4f0880e
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions bridges/bin/rialto-parachain/node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.

//! 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;

Expand Down Expand Up @@ -212,7 +219,14 @@ where
sc_client_api::StateBackendFor<TFullBackend<Block>, Block>: sp_api::StateBackend<BlakeTwo256>,
Executor: NativeExecutionDispatch + 'static,
RB: Fn(
sc_rpc_api::DenyUnsafe,
Arc<TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>>,
Arc<
sc_transaction_pool::FullPool<
Block,
TFullClient<Block, RuntimeApi, NativeElseWasmExecutor<Executor>>,
>,
>,
) -> jsonrpc_core::IoHandler<sc_rpc::Metadata>
+ Send
+ 'static,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 4f0880e

Please sign in to comment.