Move srml RPC extensions to separate crates (#3791)

* Move srml-system RPC out.

* Fix tests for system-rpc module.

* Contracts RPC moved.

* Fix rpc test.

* Clean up.

* Update lockfile.

* Bump runtime version.

* Update srml/contracts/rpc/runtime-api/src/lib.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Bump impl version.
This commit is contained in:
Tomasz Drwięga
2019-10-16 12:40:35 +02:00
committed by Gavin Wood
parent 642c8504c4
commit dc92631180
20 changed files with 344 additions and 182 deletions
+7 -18
View File
@@ -25,43 +25,32 @@
//! The RPCs available in this crate however can make some assumptions
//! about how the runtime is constructed and what `SRML` modules
//! are part of it. Therefore all node-runtime-specific RPCs can
//! be placed here.
//! be placed here or imported from corresponding `SRML` RPC definitions.
#![warn(missing_docs)]
use std::sync::Arc;
use node_primitives::{Block, AccountNonceApi, ContractsApi};
use node_primitives::{Block, AccountId, Index, Balance};
use sr_primitives::traits::ProvideRuntimeApi;
use transaction_pool::txpool::{ChainApi, Pool};
pub mod accounts;
pub mod contracts;
mod constants {
/// A status code indicating an error happened while trying to call into the runtime.
///
/// 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>,
C::Api: srml_system_rpc::AccountNonceApi<Block, AccountId, Index>,
C::Api: srml_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance>,
P: ChainApi + Sync + Send + 'static,
M: jsonrpc_core::Metadata + Default,
{
use self::{
accounts::{Accounts, AccountsApi},
contracts::{Contracts, ContractsApi},
};
use srml_system_rpc::{System, SystemApi};
use srml_contracts_rpc::{Contracts, ContractsApi};
let mut io = jsonrpc_core::IoHandler::default();
io.extend_with(
AccountsApi::to_delegate(Accounts::new(client.clone(), pool))
SystemApi::to_delegate(System::new(client.clone(), pool))
);
io.extend_with(
ContractsApi::to_delegate(Contracts::new(client))