Refactor sr-api to not depend on client anymore (#4086)

* Refactor sr-api to not depend on client anymore

* Fix benches

* Apply suggestions from code review

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Apply suggestions from code review
This commit is contained in:
Bastian Köcher
2019-11-11 16:26:49 +01:00
committed by Benjamin Kampmann
parent e26d1a0b3e
commit 2ecffa1cd0
140 changed files with 1514 additions and 984 deletions
+8 -2
View File
@@ -22,7 +22,10 @@ sr-primitives = { path = "../../core/sr-primitives", default-features = false }
sr-staking-primitives = { path = "../../core/sr-staking-primitives", default-features = false }
# core dependencies
client = { package = "substrate-client", path = "../../core/client", default-features = false }
sr-api = { path = "../../core/sr-api", default-features = false }
inherents = { package = "substrate-inherents", path = "../../core/inherents", default-features = false }
block-builder-api = { package = "substrate-block-builder-runtime-api", path = "../../core/block-builder/runtime-api", default-features = false }
tx-pool-api = { package = "substrate-transaction-pool-runtime-api", path = "../../core/transaction-pool/runtime-api", default-features = false }
rstd = { package = "sr-std", path = "../../core/sr-std", default-features = false }
version = { package = "sr-version", path = "../../core/sr-version", default-features = false }
substrate-session = { path = "../../core/session", default-features = false }
@@ -72,7 +75,7 @@ std = [
"babe-primitives/std",
"babe/std",
"balances/std",
"client/std",
"sr-api/std",
"codec/std",
"collective/std",
"contracts/std",
@@ -111,4 +114,7 @@ std = [
"transaction-payment/std",
"transaction-payment-rpc-runtime-api/std",
"version/std",
"block-builder-api/std",
"tx-pool-api/std",
"inherents/std",
]
+6 -11
View File
@@ -25,14 +25,8 @@ use support::{
construct_runtime, parameter_types, traits::{SplitTwoWays, Currency, Randomness}
};
use primitives::u32_trait::{_1, _2, _3, _4};
use node_primitives::{
AccountId, AccountIndex, Balance, BlockNumber, Hash, Index,
Moment, Signature,
};
use client::{
block_builder::api::{self as block_builder_api, InherentData, CheckInherentsResult},
runtime_api as client_api, impl_runtime_apis
};
use node_primitives::{AccountId, AccountIndex, Balance, BlockNumber, Hash, Index, Moment, Signature};
use sr_api::impl_runtime_apis;
use sr_primitives::{Permill, Perbill, ApplyResult, impl_opaque_keys, generic, create_runtime_str};
use sr_primitives::curve::PiecewiseLinear;
use sr_primitives::transaction_validity::TransactionValidity;
@@ -51,6 +45,7 @@ use im_online::sr25519::{AuthorityId as ImOnlineId};
use transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use contracts_rpc_runtime_api::ContractExecResult;
use system::offchain::TransactionSubmitter;
use inherents::{InherentData, CheckInherentsResult};
#[cfg(any(feature = "std", test))]
pub use sr_primitives::BuildStorage;
@@ -562,7 +557,7 @@ pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExt
pub type Executive = executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;
impl_runtime_apis! {
impl client_api::Core<Block> for Runtime {
impl sr_api::Core<Block> for Runtime {
fn version() -> RuntimeVersion {
VERSION
}
@@ -576,7 +571,7 @@ impl_runtime_apis! {
}
}
impl client_api::Metadata<Block> for Runtime {
impl sr_api::Metadata<Block> for Runtime {
fn metadata() -> OpaqueMetadata {
Runtime::metadata().into()
}
@@ -604,7 +599,7 @@ impl_runtime_apis! {
}
}
impl client_api::TaggedTransactionQueue<Block> for Runtime {
impl tx_pool_api::TaggedTransactionQueue<Block> for Runtime {
fn validate_transaction(tx: <Block as BlockT>::Extrinsic) -> TransactionValidity {
Executive::validate_transaction(tx)
}