mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-21 15:35:42 +00:00
Fix missing contracts RPC on a full node. (#3622)
* Add contracts RPC to full node. * Instantiate both RPC extensions for light & full.
This commit is contained in:
committed by
Sergei Pepyakin
parent
96c781834d
commit
c4af4fa522
@@ -44,6 +44,7 @@ construct_simple_protocol! {
|
|||||||
/// be able to perform chain operations.
|
/// be able to perform chain operations.
|
||||||
macro_rules! new_full_start {
|
macro_rules! new_full_start {
|
||||||
($config:expr) => {{
|
($config:expr) => {{
|
||||||
|
type RpcExtension = jsonrpc_core::IoHandler<substrate_rpc::Metadata>;
|
||||||
let mut import_setup = None;
|
let mut import_setup = None;
|
||||||
let inherent_data_providers = inherents::InherentDataProviders::new();
|
let inherent_data_providers = inherents::InherentDataProviders::new();
|
||||||
let mut tasks_to_spawn = Vec::new();
|
let mut tasks_to_spawn = Vec::new();
|
||||||
@@ -82,14 +83,8 @@ macro_rules! new_full_start {
|
|||||||
|
|
||||||
Ok(import_queue)
|
Ok(import_queue)
|
||||||
})?
|
})?
|
||||||
.with_rpc_extensions(|client, pool| {
|
.with_rpc_extensions(|client, pool| -> RpcExtension {
|
||||||
use node_rpc::accounts::{Accounts, AccountsApi};
|
node_rpc::create(client, pool)
|
||||||
|
|
||||||
let mut io = jsonrpc_core::IoHandler::<substrate_service::RpcMetadata>::default();
|
|
||||||
io.extend_with(
|
|
||||||
AccountsApi::to_delegate(Accounts::new(client, pool))
|
|
||||||
);
|
|
||||||
io
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
(builder, import_setup, inherent_data_providers, tasks_to_spawn)
|
(builder, import_setup, inherent_data_providers, tasks_to_spawn)
|
||||||
@@ -227,6 +222,7 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
|
|||||||
-> Result<impl AbstractService, ServiceError> {
|
-> Result<impl AbstractService, ServiceError> {
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
|
|
||||||
|
type RpcExtension = jsonrpc_core::IoHandler<substrate_rpc::Metadata>;
|
||||||
let inherent_data_providers = InherentDataProviders::new();
|
let inherent_data_providers = InherentDataProviders::new();
|
||||||
let mut tasks_to_spawn = Vec::new();
|
let mut tasks_to_spawn = Vec::new();
|
||||||
|
|
||||||
@@ -268,20 +264,8 @@ pub fn new_light<C: Send + Default + 'static>(config: Configuration<C, GenesisCo
|
|||||||
.with_finality_proof_provider(|client, backend|
|
.with_finality_proof_provider(|client, backend|
|
||||||
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
Ok(Arc::new(GrandpaFinalityProofProvider::new(backend, client)) as _)
|
||||||
)?
|
)?
|
||||||
.with_rpc_extensions(|client, pool| {
|
.with_rpc_extensions(|client, pool| -> RpcExtension {
|
||||||
use node_rpc::{
|
node_rpc::create(client, pool)
|
||||||
accounts::{Accounts, AccountsApi},
|
|
||||||
contracts::{Contracts, ContractsApi},
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut io = jsonrpc_core::IoHandler::default();
|
|
||||||
io.extend_with(
|
|
||||||
AccountsApi::to_delegate(Accounts::new(client.clone(), pool))
|
|
||||||
);
|
|
||||||
io.extend_with(
|
|
||||||
ContractsApi::to_delegate(Contracts::new(client))
|
|
||||||
);
|
|
||||||
io
|
|
||||||
})?
|
})?
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,12 @@
|
|||||||
|
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use node_primitives::{Block, AccountNonceApi, ContractsApi};
|
||||||
|
use sr_primitives::traits::ProvideRuntimeApi;
|
||||||
|
use transaction_pool::txpool::{ChainApi, Pool};
|
||||||
|
|
||||||
pub mod accounts;
|
pub mod accounts;
|
||||||
pub mod contracts;
|
pub mod contracts;
|
||||||
|
|
||||||
@@ -38,3 +44,27 @@ mod constants {
|
|||||||
/// This typically means that the runtime trapped.
|
/// This typically means that the runtime trapped.
|
||||||
pub const RUNTIME_ERROR: i64 = 1;
|
pub const RUNTIME_ERROR: i64 = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Instantiate all RPC extensions.
|
||||||
|
pub fn create<C, P, M>(client: Arc<C>, pool: Arc<Pool<P>>) -> jsonrpc_core::IoHandler<M> where
|
||||||
|
C: ProvideRuntimeApi,
|
||||||
|
C: client::blockchain::HeaderBackend<Block>,
|
||||||
|
C: Send + Sync + 'static,
|
||||||
|
C::Api: AccountNonceApi<Block> + ContractsApi<Block>,
|
||||||
|
P: ChainApi + Sync + Send + 'static,
|
||||||
|
M: jsonrpc_core::Metadata + Default,
|
||||||
|
{
|
||||||
|
use self::{
|
||||||
|
accounts::{Accounts, AccountsApi},
|
||||||
|
contracts::{Contracts, ContractsApi},
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut io = jsonrpc_core::IoHandler::default();
|
||||||
|
io.extend_with(
|
||||||
|
AccountsApi::to_delegate(Accounts::new(client.clone(), pool))
|
||||||
|
);
|
||||||
|
io.extend_with(
|
||||||
|
ContractsApi::to_delegate(Contracts::new(client))
|
||||||
|
);
|
||||||
|
io
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user