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:
Tomasz Drwięga
2019-09-17 13:06:36 +02:00
committed by Sergei Pepyakin
parent 96c781834d
commit c4af4fa522
2 changed files with 36 additions and 22 deletions
+30
View File
@@ -29,6 +29,12 @@
#![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 contracts;
@@ -38,3 +44,27 @@ mod constants {
/// This typically means that the runtime trapped.
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
}