mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 23:21:02 +00:00
[big refactor] Remove crate aliasing. (#4395)
* Rename: Phase 1. * Unify codec. * Fixing: Phase 2 * Fixing: Phase 3. * Fixing: Phase 4. * Fixing: Phase 5. * Fixing: Phase 6. * Fixing: Phase 7. * Fixing: Phase 8. Tests * Fixing: Phase 9. Tests!!! * Fixing: Phase 10. Moar tests! * Finally done! * More fixes. * Rename primitives:: to sp_core:: * Apply renames in finality-grandpa. * Fix benches. * Fix benches 2. * Revert node-template. * Fix frame-system in our modules.
This commit is contained in:
committed by
Gavin Wood
parent
f14d98a439
commit
8778ca7dc8
@@ -35,9 +35,9 @@
|
||||
//! ### Example - Get random seed for the current block
|
||||
//!
|
||||
//! ```
|
||||
//! use support::{decl_module, dispatch, traits::Randomness};
|
||||
//! use frame_support::{decl_module, dispatch, traits::Randomness};
|
||||
//!
|
||||
//! pub trait Trait: system::Trait {}
|
||||
//! pub trait Trait: frame_system::Trait {}
|
||||
//!
|
||||
//! decl_module! {
|
||||
//! pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
@@ -54,10 +54,10 @@
|
||||
|
||||
use sp_std::{prelude::*, convert::TryInto};
|
||||
use sp_runtime::traits::Hash;
|
||||
use support::{decl_module, decl_storage, traits::Randomness};
|
||||
use frame_support::{decl_module, decl_storage, traits::Randomness};
|
||||
use safe_mix::TripletMix;
|
||||
use codec::Encode;
|
||||
use system::Trait;
|
||||
use frame_system::Trait;
|
||||
|
||||
const RANDOM_MATERIAL_LEN: u32 = 81;
|
||||
|
||||
@@ -70,7 +70,7 @@ fn block_number_to_index<T: Trait>(block_number: T::BlockNumber) -> usize {
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
fn on_initialize(block_number: T::BlockNumber) {
|
||||
let parent_hash = <system::Module<T>>::parent_hash();
|
||||
let parent_hash = <frame_system::Module<T>>::parent_hash();
|
||||
|
||||
<RandomMaterial<T>>::mutate(|ref mut values| if values.len() < RANDOM_MATERIAL_LEN as usize {
|
||||
values.push(parent_hash)
|
||||
@@ -130,7 +130,7 @@ impl<T: Trait> Randomness<T::Hash> for Module<T> {
|
||||
/// and mean that all bits of the resulting value are entirely manipulatable by the author of
|
||||
/// the parent block, who can determine the value of `parent_hash`.
|
||||
fn random(subject: &[u8]) -> T::Hash {
|
||||
let block_number = <system::Module<T>>::block_number();
|
||||
let block_number = <frame_system::Module<T>>::block_number();
|
||||
let index = block_number_to_index::<T>(block_number);
|
||||
|
||||
let hash_series = <RandomMaterial<T>>::get();
|
||||
@@ -152,17 +152,17 @@ impl<T: Trait> Randomness<T::Hash> for Module<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill, traits::{BlakeTwo256, OnInitialize, Header as _, IdentityLookup}, testing::Header,
|
||||
};
|
||||
use support::{impl_outer_origin, parameter_types, weights::Weight, traits::Randomness};
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight, traits::Randomness};
|
||||
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
pub struct Test;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
@@ -172,7 +172,7 @@ mod tests {
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||
}
|
||||
|
||||
impl system::Trait for Test {
|
||||
impl frame_system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -190,11 +190,11 @@ mod tests {
|
||||
type Version = ();
|
||||
}
|
||||
|
||||
type System = system::Module<Test>;
|
||||
type System = frame_system::Module<Test>;
|
||||
type CollectiveFlip = Module<Test>;
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user