mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-29 07:58:00 +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
@@ -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