mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Refactor sr_primitives. (#3214)
* refactor sr_primitives. * Fix try build error. * Line-width * Ui test. * Final fixes. * Fix build again. * bring back ui test. * Fix unsigned import. * Another ui fix. * Also refactor substrate-primitives * Fix benchmarks. * Fix doc test. * fix doc tests
This commit is contained in:
committed by
Bastian Köcher
parent
cf80af9255
commit
79feb23a22
@@ -17,7 +17,7 @@ aura-primitives = { package = "substrate-consensus-aura-primitives", path = "../
|
||||
babe-primitives = { package = "substrate-consensus-babe-primitives", path = "../consensus/babe/primitives", default-features = false }
|
||||
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
|
||||
runtime_io = { package = "sr-io", path = "../sr-io", default-features = false }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../sr-primitives", default-features = false }
|
||||
sr-primitives = { path = "../sr-primitives", default-features = false }
|
||||
runtime_version = { package = "sr-version", path = "../sr-version", default-features = false }
|
||||
runtime_support = { package = "srml-support", path = "../../srml/support", default-features = false }
|
||||
substrate-trie = { path = "../trie", default-features = false }
|
||||
@@ -53,7 +53,7 @@ std = [
|
||||
"runtime_support/std",
|
||||
"primitives/std",
|
||||
"inherents/std",
|
||||
"runtime_primitives/std",
|
||||
"sr-primitives/std",
|
||||
"runtime_version/std",
|
||||
"aura-primitives/std",
|
||||
"babe-primitives/std",
|
||||
|
||||
@@ -8,7 +8,7 @@ edition = "2018"
|
||||
generic-test-client = { package = "substrate-test-client", path = "../../test-client" }
|
||||
primitives = { package = "substrate-primitives", path = "../../primitives" }
|
||||
runtime = { package = "substrate-test-runtime", path = "../../test-runtime", default-features = false }
|
||||
runtime_primitives = { package = "sr-primitives", path = "../../sr-primitives" }
|
||||
sr-primitives = { path = "../../sr-primitives" }
|
||||
|
||||
[features]
|
||||
default = [
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Block Builder extensions for tests.
|
||||
|
||||
use runtime;
|
||||
use runtime_primitives::traits::ProvideRuntimeApi;
|
||||
use sr_primitives::traits::ProvideRuntimeApi;
|
||||
use generic_test_client::client;
|
||||
use generic_test_client::client::block_builder::api::BlockBuilder;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ pub use generic_test_client::*;
|
||||
pub use runtime;
|
||||
|
||||
use runtime::genesismap::{GenesisConfig, additional_storage_with_genesis};
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT};
|
||||
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Hash as HashT};
|
||||
|
||||
/// A prelude to import in tests.
|
||||
pub mod prelude {
|
||||
|
||||
@@ -28,8 +28,8 @@ use crate::{AccountKeyring, ClientExt, TestClientBuilder, TestClientBuilderExt};
|
||||
use generic_test_client::consensus::BlockOrigin;
|
||||
use primitives::Blake2Hasher;
|
||||
use runtime::{self, Transfer};
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::traits::Block as BlockT;
|
||||
use sr_primitives::generic::BlockId;
|
||||
use sr_primitives::traits::Block as BlockT;
|
||||
|
||||
/// helper to test the `leaves` implementation for various backends
|
||||
pub fn test_leaves_for_backend<B: 'static>(backend: Arc<B>) where
|
||||
|
||||
@@ -21,7 +21,7 @@ use runtime_io::{blake2_256, twox_128};
|
||||
use super::{AuthorityId, AccountId, WASM_BINARY};
|
||||
use parity_codec::{Encode, KeyedVec, Joiner};
|
||||
use primitives::{ChangesTrieConfiguration, map, storage::well_known_keys};
|
||||
use runtime_primitives::traits::Block;
|
||||
use sr_primitives::traits::Block;
|
||||
|
||||
/// Configuration of a general Substrate test genesis block.
|
||||
pub struct GenesisConfig {
|
||||
|
||||
@@ -33,7 +33,7 @@ use substrate_client::{
|
||||
runtime_api as client_api, block_builder::api as block_builder_api, decl_runtime_apis,
|
||||
impl_runtime_apis,
|
||||
};
|
||||
use runtime_primitives::{
|
||||
use sr_primitives::{
|
||||
ApplyResult, create_runtime_str, Perbill,
|
||||
transaction_validity::{TransactionValidity, ValidTransaction},
|
||||
traits::{
|
||||
@@ -125,13 +125,13 @@ impl BlindCheckable for Extrinsic {
|
||||
match self {
|
||||
Extrinsic::AuthoritiesChange(new_auth) => Ok(Extrinsic::AuthoritiesChange(new_auth)),
|
||||
Extrinsic::Transfer(transfer, signature) => {
|
||||
if runtime_primitives::verify_encoded_lazy(&signature, &transfer, &transfer.from) {
|
||||
if sr_primitives::verify_encoded_lazy(&signature, &transfer, &transfer.from) {
|
||||
Ok(Extrinsic::Transfer(transfer, signature))
|
||||
} else {
|
||||
Err(runtime_primitives::BAD_SIGNATURE)
|
||||
Err(sr_primitives::BAD_SIGNATURE)
|
||||
}
|
||||
},
|
||||
Extrinsic::IncludeData(_) => Err(runtime_primitives::BAD_SIGNATURE),
|
||||
Extrinsic::IncludeData(_) => Err(sr_primitives::BAD_SIGNATURE),
|
||||
Extrinsic::StorageChange(key, value) => Ok(Extrinsic::StorageChange(key, value)),
|
||||
}
|
||||
}
|
||||
@@ -173,13 +173,13 @@ pub type BlockNumber = u64;
|
||||
/// Index of a transaction.
|
||||
pub type Index = u64;
|
||||
/// The item of a block digest.
|
||||
pub type DigestItem = runtime_primitives::generic::DigestItem<H256>;
|
||||
pub type DigestItem = sr_primitives::generic::DigestItem<H256>;
|
||||
/// The digest of a block.
|
||||
pub type Digest = runtime_primitives::generic::Digest<H256>;
|
||||
pub type Digest = sr_primitives::generic::Digest<H256>;
|
||||
/// A test block.
|
||||
pub type Block = runtime_primitives::generic::Block<Header, Extrinsic>;
|
||||
pub type Block = sr_primitives::generic::Block<Header, Extrinsic>;
|
||||
/// A test block's header.
|
||||
pub type Header = runtime_primitives::generic::Header<BlockNumber, BlakeTwo256>;
|
||||
pub type Header = sr_primitives::generic::Header<BlockNumber, BlakeTwo256>;
|
||||
|
||||
/// Run whatever tests we have.
|
||||
pub fn run_tests(mut input: &[u8]) -> Vec<u8> {
|
||||
@@ -775,7 +775,7 @@ mod tests {
|
||||
DefaultTestClientBuilderExt, TestClientBuilder,
|
||||
runtime::TestAPI,
|
||||
};
|
||||
use runtime_primitives::{
|
||||
use sr_primitives::{
|
||||
generic::BlockId,
|
||||
traits::ProvideRuntimeApi,
|
||||
};
|
||||
|
||||
@@ -21,10 +21,10 @@ use rstd::prelude::*;
|
||||
use runtime_io::{storage_root, enumerated_trie_root, storage_changes_root, twox_128, blake2_256};
|
||||
use runtime_support::storage::{self, StorageValue, StorageMap};
|
||||
use runtime_support::storage_items;
|
||||
use runtime_primitives::traits::{Hash as HashT, BlakeTwo256, Header as _};
|
||||
use runtime_primitives::generic;
|
||||
use runtime_primitives::{ApplyError, ApplyOutcome, ApplyResult};
|
||||
use runtime_primitives::transaction_validity::{TransactionValidity, ValidTransaction};
|
||||
use sr_primitives::traits::{Hash as HashT, BlakeTwo256, Header as _};
|
||||
use sr_primitives::generic;
|
||||
use sr_primitives::{ApplyError, ApplyOutcome, ApplyResult};
|
||||
use sr_primitives::transaction_validity::{TransactionValidity, ValidTransaction};
|
||||
use parity_codec::{KeyedVec, Encode};
|
||||
use super::{
|
||||
AccountId, BlockNumber, Extrinsic, Transfer, H256 as Hash, Block, Header, Digest, AuthorityId
|
||||
@@ -232,7 +232,7 @@ pub fn finalize_block() -> Header {
|
||||
|
||||
#[inline(always)]
|
||||
fn check_signature(utx: &Extrinsic) -> Result<(), ApplyError> {
|
||||
use runtime_primitives::traits::BlindCheckable;
|
||||
use sr_primitives::traits::BlindCheckable;
|
||||
utx.clone().check().map_err(|_| ApplyError::BadSignature)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user