|
25 | 25 | //! The RPCs available in this crate however can make some assumptions |
26 | 26 | //! about how the runtime is constructed and what `SRML` modules |
27 | 27 | //! are part of it. Therefore all node-runtime-specific RPCs can |
28 | | -//! be placed here. |
| 28 | +//! be placed here or imported from corresponding `SRML` RPC definitions. |
29 | 29 |
|
30 | 30 | #![warn(missing_docs)] |
31 | 31 |
|
32 | 32 | use std::sync::Arc; |
33 | 33 |
|
34 | | -use node_primitives::{Block, AccountNonceApi, ContractsApi}; |
| 34 | +use node_primitives::{Block, AccountId, Index, Balance}; |
35 | 35 | use sr_primitives::traits::ProvideRuntimeApi; |
36 | 36 | use transaction_pool::txpool::{ChainApi, Pool}; |
37 | 37 |
|
38 | | -pub mod accounts; |
39 | | -pub mod contracts; |
40 | | - |
41 | | -mod constants { |
42 | | - /// A status code indicating an error happened while trying to call into the runtime. |
43 | | - /// |
44 | | - /// This typically means that the runtime trapped. |
45 | | - pub const RUNTIME_ERROR: i64 = 1; |
46 | | -} |
47 | | - |
48 | 38 | /// Instantiate all RPC extensions. |
49 | 39 | pub fn create<C, P, M>(client: Arc<C>, pool: Arc<Pool<P>>) -> jsonrpc_core::IoHandler<M> where |
50 | 40 | C: ProvideRuntimeApi, |
51 | 41 | C: client::blockchain::HeaderBackend<Block>, |
52 | 42 | C: Send + Sync + 'static, |
53 | | - C::Api: AccountNonceApi<Block> + ContractsApi<Block>, |
| 43 | + C::Api: srml_system_rpc::AccountNonceApi<Block, AccountId, Index>, |
| 44 | + C::Api: srml_contracts_rpc::ContractsRuntimeApi<Block, AccountId, Balance>, |
54 | 45 | P: ChainApi + Sync + Send + 'static, |
55 | 46 | M: jsonrpc_core::Metadata + Default, |
56 | 47 | { |
57 | | - use self::{ |
58 | | - accounts::{Accounts, AccountsApi}, |
59 | | - contracts::{Contracts, ContractsApi}, |
60 | | - }; |
| 48 | + use srml_system_rpc::{System, SystemApi}; |
| 49 | + use srml_contracts_rpc::{Contracts, ContractsApi}; |
61 | 50 |
|
62 | 51 | let mut io = jsonrpc_core::IoHandler::default(); |
63 | 52 | io.extend_with( |
64 | | - AccountsApi::to_delegate(Accounts::new(client.clone(), pool)) |
| 53 | + SystemApi::to_delegate(System::new(client.clone(), pool)) |
65 | 54 | ); |
66 | 55 | io.extend_with( |
67 | 56 | ContractsApi::to_delegate(Contracts::new(client)) |
|
0 commit comments