mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 15:11:03 +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
@@ -107,13 +107,13 @@
|
||||
//! The Contract module uses the `Currency` trait to handle gas payment, and its types inherit from `Currency`:
|
||||
//!
|
||||
//! ```
|
||||
//! use support::traits::Currency;
|
||||
//! # pub trait Trait: system::Trait {
|
||||
//! use frame_support::traits::Currency;
|
||||
//! # pub trait Trait: frame_system::Trait {
|
||||
//! # type Currency: Currency<Self::AccountId>;
|
||||
//! # }
|
||||
//!
|
||||
//! pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
//! pub type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||
//! pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
//! pub type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
//!
|
||||
//! # fn main() {}
|
||||
//! ```
|
||||
@@ -121,14 +121,14 @@
|
||||
//! The Staking module uses the `LockableCurrency` trait to lock a stash account's funds:
|
||||
//!
|
||||
//! ```
|
||||
//! use support::traits::{WithdrawReasons, LockableCurrency};
|
||||
//! use frame_support::traits::{WithdrawReasons, LockableCurrency};
|
||||
//! use sp_runtime::traits::Bounded;
|
||||
//! pub trait Trait: system::Trait {
|
||||
//! pub trait Trait: frame_system::Trait {
|
||||
//! type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
|
||||
//! }
|
||||
//! # struct StakingLedger<T: Trait> {
|
||||
//! # stash: <T as system::Trait>::AccountId,
|
||||
//! # total: <<T as Trait>::Currency as support::traits::Currency<<T as system::Trait>::AccountId>>::Balance,
|
||||
//! # stash: <T as frame_system::Trait>::AccountId,
|
||||
//! # total: <<T as Trait>::Currency as frame_support::traits::Currency<<T as frame_system::Trait>::AccountId>>::Balance,
|
||||
//! # phantom: std::marker::PhantomData<T>,
|
||||
//! # }
|
||||
//! # const STAKING_ID: [u8; 8] = *b"staking ";
|
||||
@@ -162,7 +162,7 @@
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::{cmp, result, mem, fmt::Debug};
|
||||
use codec::{Codec, Encode, Decode};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
StorageValue, Parameter, decl_event, decl_storage, decl_module,
|
||||
traits::{
|
||||
UpdateBalanceOutcome, Currency, OnFreeBalanceZero, OnUnbalanced, TryDrop,
|
||||
@@ -179,7 +179,7 @@ use sp_runtime::{
|
||||
Saturating, Bounded,
|
||||
},
|
||||
};
|
||||
use system::{IsDeadAccount, OnNewAccount, ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, IsDeadAccount, OnNewAccount, ensure_signed, ensure_root};
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
@@ -188,7 +188,7 @@ mod tests;
|
||||
|
||||
pub use self::imbalances::{PositiveImbalance, NegativeImbalance};
|
||||
|
||||
pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
|
||||
pub trait Subtrait<I: Instance = DefaultInstance>: frame_system::Trait {
|
||||
/// The balance of an account.
|
||||
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy +
|
||||
MaybeSerializeDeserialize + Debug + From<Self::BlockNumber>;
|
||||
@@ -212,7 +212,7 @@ pub trait Subtrait<I: Instance = DefaultInstance>: system::Trait {
|
||||
type CreationFee: Get<Self::Balance>;
|
||||
}
|
||||
|
||||
pub trait Trait<I: Instance = DefaultInstance>: system::Trait {
|
||||
pub trait Trait<I: Instance = DefaultInstance>: frame_system::Trait {
|
||||
/// The balance of an account.
|
||||
type Balance: Parameter + Member + SimpleArithmetic + Codec + Default + Copy +
|
||||
MaybeSerializeDeserialize + Debug + From<Self::BlockNumber>;
|
||||
@@ -234,7 +234,7 @@ pub trait Trait<I: Instance = DefaultInstance>: system::Trait {
|
||||
type DustRemoval: OnUnbalanced<NegativeImbalance<Self, I>>;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self, I>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self, I>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// The minimum amount required to keep an account open.
|
||||
type ExistentialDeposit: Get<Self::Balance>;
|
||||
@@ -257,7 +257,7 @@ impl<T: Trait<I>, I: Instance> Subtrait<I> for T {
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I: Instance = DefaultInstance> where
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as Trait<I>>::Balance
|
||||
{
|
||||
/// A new account was created.
|
||||
@@ -348,7 +348,7 @@ decl_storage! {
|
||||
/// is invoked, giving a chance to external modules to clean up data associated with
|
||||
/// the deleted account.
|
||||
///
|
||||
/// `system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
|
||||
/// `frame_system::AccountNonce` is also deleted if `ReservedBalance` is also zero (it also gets
|
||||
/// collapsed to zero if it ever becomes less than `ExistentialDeposit`.
|
||||
pub FreeBalance get(fn free_balance)
|
||||
build(|config: &GenesisConfig<T, I>| config.balances.clone()):
|
||||
@@ -363,7 +363,7 @@ decl_storage! {
|
||||
/// When this balance falls below the value of `ExistentialDeposit`, then this 'reserve account'
|
||||
/// is deleted: specifically, `ReservedBalance`.
|
||||
///
|
||||
/// `system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
|
||||
/// `frame_system::AccountNonce` is also deleted if `FreeBalance` is also zero (it also gets
|
||||
/// collapsed to zero if it ever becomes less than `ExistentialDeposit`.)
|
||||
pub ReservedBalance get(fn reserved_balance): map T::AccountId => T::Balance;
|
||||
|
||||
@@ -439,7 +439,7 @@ decl_module! {
|
||||
/// This will alter `FreeBalance` and `ReservedBalance` in storage. it will
|
||||
/// also decrease the total issuance of the system (`TotalIssuance`).
|
||||
/// If the new free or reserved balance is below the existential deposit,
|
||||
/// it will reset the account nonce (`system::AccountNonce`).
|
||||
/// it will reset the account nonce (`frame_system::AccountNonce`).
|
||||
///
|
||||
/// The dispatch origin for this call is `root`.
|
||||
///
|
||||
@@ -565,7 +565,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
|
||||
///
|
||||
/// This just removes the nonce and leaves an event.
|
||||
fn reap_account(who: &T::AccountId) {
|
||||
<system::AccountNonce<T>>::remove(who);
|
||||
<frame_system::AccountNonce<T>>::remove(who);
|
||||
Self::deposit_event(RawEvent::ReapedAccount(who.clone()));
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ impl<T: Subtrait<I>, I: Instance> PartialEq for ElevatedTrait<T, I> {
|
||||
fn eq(&self, _: &Self) -> bool { unimplemented!() }
|
||||
}
|
||||
impl<T: Subtrait<I>, I: Instance> Eq for ElevatedTrait<T, I> {}
|
||||
impl<T: Subtrait<I>, I: Instance> system::Trait for ElevatedTrait<T, I> {
|
||||
impl<T: Subtrait<I>, I: Instance> frame_system::Trait for ElevatedTrait<T, I> {
|
||||
type Origin = T::Origin;
|
||||
type Call = T::Call;
|
||||
type Index = T::Index;
|
||||
@@ -878,7 +878,7 @@ where
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
if locks.into_iter()
|
||||
.all(|l|
|
||||
now >= l.until
|
||||
@@ -1140,7 +1140,7 @@ where
|
||||
until: T::BlockNumber,
|
||||
reasons: WithdrawReasons,
|
||||
) {
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
let mut new_lock = Some(BalanceLock { id, amount, until, reasons });
|
||||
let mut locks = Self::locks(who).into_iter().filter_map(|l|
|
||||
if l.id == id {
|
||||
@@ -1163,7 +1163,7 @@ where
|
||||
until: T::BlockNumber,
|
||||
reasons: WithdrawReasons,
|
||||
) {
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
let mut new_lock = Some(BalanceLock { id, amount, until, reasons });
|
||||
let mut locks = Self::locks(who).into_iter().filter_map(|l|
|
||||
if l.id == id {
|
||||
@@ -1190,7 +1190,7 @@ where
|
||||
id: LockIdentifier,
|
||||
who: &T::AccountId,
|
||||
) {
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
let locks = Self::locks(who).into_iter().filter_map(|l|
|
||||
if l.until > now && l.id != id {
|
||||
Some(l)
|
||||
@@ -1211,7 +1211,7 @@ where
|
||||
fn vesting_balance(who: &T::AccountId) -> T::Balance {
|
||||
if let Some(v) = Self::vesting(who) {
|
||||
Self::free_balance(who)
|
||||
.min(v.locked_at(<system::Module<T>>::block_number()))
|
||||
.min(v.locked_at(<frame_system::Module<T>>::block_number()))
|
||||
} else {
|
||||
Zero::zero()
|
||||
}
|
||||
|
||||
@@ -17,14 +17,15 @@
|
||||
//! Test utilities
|
||||
|
||||
use sp_runtime::{Perbill, traits::{ConvertInto, IdentityLookup}, testing::Header};
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_io;
|
||||
use support::{impl_outer_origin, parameter_types};
|
||||
use support::traits::Get;
|
||||
use support::weights::{Weight, DispatchInfo};
|
||||
use frame_support::{impl_outer_origin, parameter_types};
|
||||
use frame_support::traits::Get;
|
||||
use frame_support::weights::{Weight, DispatchInfo};
|
||||
use std::cell::RefCell;
|
||||
use crate::{GenesisConfig, Module, Trait};
|
||||
|
||||
use frame_system as system;
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Runtime {}
|
||||
}
|
||||
@@ -59,7 +60,7 @@ parameter_types! {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||
}
|
||||
impl system::Trait for Runtime {
|
||||
impl frame_system::Trait for Runtime {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -80,7 +81,7 @@ parameter_types! {
|
||||
pub const TransactionBaseFee: u64 = 0;
|
||||
pub const TransactionByteFee: u64 = 1;
|
||||
}
|
||||
impl transaction_payment::Trait for Runtime {
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
type Currency = Module<Runtime>;
|
||||
type OnTransactionPayment = ();
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
@@ -150,7 +151,7 @@ impl ExtBuilder {
|
||||
}
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
self.set_associated_consts();
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
GenesisConfig::<Runtime> {
|
||||
balances: if self.monied {
|
||||
vec![
|
||||
@@ -177,10 +178,10 @@ impl ExtBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub type System = system::Module<Runtime>;
|
||||
pub type System = frame_system::Module<Runtime>;
|
||||
pub type Balances = Module<Runtime>;
|
||||
|
||||
pub const CALL: &<Runtime as system::Trait>::Call = &();
|
||||
pub const CALL: &<Runtime as frame_system::Trait>::Call = &();
|
||||
|
||||
/// create a transaction info struct from weight. Handy to avoid building the whole struct.
|
||||
pub fn info_from_weight(w: Weight) -> DispatchInfo {
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
use super::*;
|
||||
use mock::{Balances, ExtBuilder, Runtime, System, info_from_weight, CALL};
|
||||
use sp_runtime::traits::SignedExtension;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
assert_noop, assert_ok, assert_err,
|
||||
traits::{LockableCurrency, LockIdentifier, WithdrawReason, WithdrawReasons,
|
||||
Currency, ReservableCurrency, ExistenceRequirement::AllowDeath}
|
||||
};
|
||||
use transaction_payment::ChargeTransactionPayment;
|
||||
use system::RawOrigin;
|
||||
use pallet_transaction_payment::ChargeTransactionPayment;
|
||||
use frame_system::RawOrigin;
|
||||
|
||||
const ID_1: LockIdentifier = *b"1 ";
|
||||
const ID_2: LockIdentifier = *b"2 ";
|
||||
@@ -763,7 +763,7 @@ fn transfer_keep_alive_works() {
|
||||
#[should_panic="the balance of any account should always be more than existential deposit."]
|
||||
fn cannot_set_genesis_value_below_ed() {
|
||||
mock::EXISTENTIAL_DEPOSIT.with(|v| *v.borrow_mut() = 11);
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
let _ = GenesisConfig::<Runtime> {
|
||||
balances: vec![(1, 10)],
|
||||
vesting: vec![],
|
||||
|
||||
Reference in New Issue
Block a user