mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 22:11:06 +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
@@ -10,12 +10,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features =
|
||||
# Needed for various traits. In our case, `OnFinalize`.
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
# Needed for type-safe access to storage DB.
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
# `system` module provides us with all sorts of useful stuff and macros depend on it being around.
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sp-std = { path = "../../primitives/std" }
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
|
||||
@@ -25,6 +25,6 @@ std = [
|
||||
"serde",
|
||||
"codec/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -84,8 +84,8 @@
|
||||
//! ### Simple Code Snippet
|
||||
//!
|
||||
//! ```rust,ignore
|
||||
//! use support::{decl_module, dispatch};
|
||||
//! use system::ensure_signed;
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//!
|
||||
//! pub trait Trait: assets::Trait { }
|
||||
//!
|
||||
@@ -130,15 +130,15 @@
|
||||
// Ensure we're `no_std` when compiling for Wasm.
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use support::{Parameter, decl_module, decl_event, decl_storage, ensure};
|
||||
use frame_support::{Parameter, decl_module, decl_event, decl_storage, ensure};
|
||||
use sp_runtime::traits::{Member, SimpleArithmetic, Zero, StaticLookup};
|
||||
use system::ensure_signed;
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
use sp_runtime::traits::One;
|
||||
|
||||
/// The module configuration trait.
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// The units in which we record balances.
|
||||
type Balance: Member + Parameter + SimpleArithmetic + Default + Copy;
|
||||
@@ -197,7 +197,7 @@ decl_module! {
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as Trait>::Balance,
|
||||
<T as Trait>::AssetId,
|
||||
{
|
||||
@@ -240,14 +240,14 @@ impl<T: Trait> Module<T> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use support::{impl_outer_origin, assert_ok, assert_noop, parameter_types, weights::Weight};
|
||||
use primitives::H256;
|
||||
use frame_support::{impl_outer_origin, assert_ok, assert_noop, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||
use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
@@ -261,7 +261,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
pub const AvailableBlockRatio: Perbill = Perbill::one();
|
||||
}
|
||||
impl system::Trait for Test {
|
||||
impl frame_system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type Call = ();
|
||||
@@ -288,7 +288,7 @@ mod tests {
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
|
||||
frame_system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -5,20 +5,20 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
|
||||
sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-inherents = { path = "../../primitives/inherents", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
session = { package = "pallet-session", path = "../session", default-features = false }
|
||||
pallet-session = { path = "../session", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-io ={ path = "../../primitives/io", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
sp-consensus-aura = { path = "../../primitives/consensus/aura", default-features = false}
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
sp-timestamp = { package = "sp-timestamp", path = "../../primitives/timestamp", default-features = false }
|
||||
pallet-timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
sp-timestamp = { path = "../../primitives/timestamp", default-features = false }
|
||||
pallet-timestamp = { path = "../timestamp", default-features = false }
|
||||
|
||||
|
||||
[dev-dependencies]
|
||||
@@ -28,17 +28,17 @@ parking_lot = "0.9.0"
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"sp-application-crypto/std",
|
||||
"codec/std",
|
||||
"inherents/std",
|
||||
"sp-inherents/std",
|
||||
"sp-io/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"serde",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-consensus-aura/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
"sp-timestamp/std",
|
||||
"pallet-timestamp/std",
|
||||
]
|
||||
|
||||
@@ -49,7 +49,7 @@ use pallet_timestamp;
|
||||
|
||||
use sp_std::{result, prelude::*};
|
||||
use codec::{Encode, Decode};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_storage, decl_module, Parameter, traits::{Get, FindAuthor},
|
||||
ConsensusEngineId,
|
||||
};
|
||||
@@ -58,7 +58,7 @@ use sp_runtime::{
|
||||
traits::{SaturatedConversion, Saturating, Zero, Member, IsMember}, generic::DigestItem,
|
||||
};
|
||||
use sp_timestamp::OnTimestampSet;
|
||||
use inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError};
|
||||
use sp_inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError};
|
||||
use sp_consensus_aura::{
|
||||
AURA_ENGINE_ID, ConsensusLog, AuthorityIndex,
|
||||
inherents::{INHERENT_IDENTIFIER, AuraInherentData},
|
||||
@@ -98,7 +98,7 @@ impl<T: Trait> Module<T> {
|
||||
AURA_ENGINE_ID,
|
||||
ConsensusLog::AuthoritiesChange(new).encode()
|
||||
);
|
||||
<system::Module<T>>::deposit_log(log.into());
|
||||
<frame_system::Module<T>>::deposit_log(log.into());
|
||||
}
|
||||
|
||||
fn initialize_authorities(authorities: &[T::AuthorityId]) {
|
||||
@@ -113,7 +113,7 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
|
||||
type Public = T::AuthorityId;
|
||||
}
|
||||
|
||||
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
type Key = T::AuthorityId;
|
||||
|
||||
fn on_genesis_session<'a, I: 'a>(validators: I)
|
||||
@@ -142,7 +142,7 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
ConsensusLog::<T::AuthorityId>::OnDisabled(i as AuthorityIndex).encode(),
|
||||
);
|
||||
|
||||
<system::Module<T>>::deposit_log(log.into());
|
||||
<frame_system::Module<T>>::deposit_log(log.into());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ impl<T: Trait> OnTimestampSet<T::Moment> for Module<T> {
|
||||
|
||||
impl<T: Trait> ProvideInherent for Module<T> {
|
||||
type Call = pallet_timestamp::Call<T>;
|
||||
type Error = MakeFatalError<inherents::Error>;
|
||||
type Error = MakeFatalError<sp_inherents::Error>;
|
||||
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
|
||||
|
||||
fn create_inherent(_: &InherentData) -> Option<Self::Call> {
|
||||
@@ -227,7 +227,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
|
||||
if timestamp_based_slot == seal_slot {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(inherents::Error::from("timestamp set in block doesn't match slot in seal").into())
|
||||
Err(sp_inherents::Error::from("timestamp set in block doesn't match slot in seal").into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,12 +24,12 @@ use sp_runtime::{
|
||||
traits::IdentityLookup, Perbill,
|
||||
testing::{Header, UintAuthorityId},
|
||||
};
|
||||
use support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_io;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
|
||||
@@ -44,7 +44,7 @@ parameter_types! {
|
||||
pub const MinimumPeriod: u64 = 1;
|
||||
}
|
||||
|
||||
impl system::Trait for Test {
|
||||
impl frame_system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -73,7 +73,7 @@ impl Trait for Test {
|
||||
}
|
||||
|
||||
pub fn new_test_ext(authorities: Vec<u64>) -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
GenesisConfig::<Test>{
|
||||
authorities: authorities.into_iter().map(|a| UintAuthorityId(a).to_public_key()).collect(),
|
||||
}.assimilate_storage(&mut t).unwrap();
|
||||
|
||||
@@ -5,17 +5,17 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
authority-discovery-primitives = { package = "sp-authority-discovery", path = "../../primitives/authority-discovery", default-features = false }
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
|
||||
sp-authority-discovery = { path = "../../primitives/authority-discovery", default-features = false }
|
||||
sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical" ] }
|
||||
pallet-session = { path = "../session", default-features = false, features = ["historical" ] }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
@@ -23,15 +23,15 @@ sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"authority-discovery-primitives/std",
|
||||
"sp-application-crypto/std",
|
||||
"sp-authority-discovery/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-io/std",
|
||||
"sp-std/std",
|
||||
"serde",
|
||||
"session/std",
|
||||
"pallet-session/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use support::{decl_module, decl_storage};
|
||||
use authority_discovery_primitives::AuthorityId;
|
||||
use frame_support::{decl_module, decl_storage};
|
||||
use sp_authority_discovery::AuthorityId;
|
||||
|
||||
/// The module's config trait.
|
||||
pub trait Trait: system::Trait + session::Trait {}
|
||||
pub trait Trait: frame_system::Trait + pallet_session::Trait {}
|
||||
|
||||
decl_storage! {
|
||||
trait Store for Module<T: Trait> as AuthorityDiscovery {
|
||||
@@ -63,7 +63,7 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
|
||||
type Public = AuthorityId;
|
||||
}
|
||||
|
||||
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
type Key = AuthorityId;
|
||||
|
||||
fn on_genesis_session<'a, I: 'a>(authorities: I)
|
||||
@@ -92,15 +92,15 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use authority_discovery_primitives::{AuthorityPair};
|
||||
use app_crypto::Pair;
|
||||
use primitives::{crypto::key_types, H256};
|
||||
use sp_authority_discovery::{AuthorityPair};
|
||||
use sp_application_crypto::Pair;
|
||||
use sp_core::{crypto::key_types, H256};
|
||||
use sp_io::TestExternalities;
|
||||
use sp_runtime::{
|
||||
testing::{Header, UintAuthorityId}, traits::{ConvertInto, IdentityLookup, OpaqueKeys},
|
||||
Perbill, KeyTypeId,
|
||||
};
|
||||
use support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
|
||||
type AuthorityDiscovery = Module<Test>;
|
||||
type SessionIndex = u32;
|
||||
@@ -110,7 +110,7 @@ mod tests {
|
||||
impl Trait for Test {}
|
||||
|
||||
pub struct TestOnSessionEnding;
|
||||
impl session::OnSessionEnding<AuthorityId> for TestOnSessionEnding {
|
||||
impl pallet_session::OnSessionEnding<AuthorityId> for TestOnSessionEnding {
|
||||
fn on_session_ending(_: SessionIndex, _: SessionIndex) -> Option<Vec<AuthorityId>> {
|
||||
None
|
||||
}
|
||||
@@ -120,10 +120,10 @@ mod tests {
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33);
|
||||
}
|
||||
|
||||
impl session::Trait for Test {
|
||||
impl pallet_session::Trait for Test {
|
||||
type OnSessionEnding = TestOnSessionEnding;
|
||||
type Keys = UintAuthorityId;
|
||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type SessionHandler = TestSessionHandler;
|
||||
type Event = ();
|
||||
type ValidatorId = AuthorityId;
|
||||
@@ -132,7 +132,7 @@ mod tests {
|
||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||
}
|
||||
|
||||
impl session::historical::Trait for Test {
|
||||
impl pallet_session::historical::Trait for Test {
|
||||
type FullIdentification = ();
|
||||
type FullIdentificationOf = ();
|
||||
}
|
||||
@@ -149,7 +149,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 = BlockNumber;
|
||||
@@ -168,11 +168,11 @@ mod tests {
|
||||
}
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
pub struct TestSessionHandler;
|
||||
impl session::SessionHandler<AuthorityId> for TestSessionHandler {
|
||||
impl pallet_session::SessionHandler<AuthorityId> for TestSessionHandler {
|
||||
const KEY_TYPE_IDS: &'static [KeyTypeId] = &[key_types::DUMMY];
|
||||
|
||||
fn on_new_session<Ks: OpaqueKeys>(
|
||||
@@ -190,7 +190,7 @@ mod tests {
|
||||
#[test]
|
||||
fn authorities_returns_current_authority_set() {
|
||||
// The whole authority discovery module ignores account ids, but we still need it for
|
||||
// `session::OneSessionHandler::on_new_session`, thus its safe to use the same value everywhere.
|
||||
// `pallet_session::OneSessionHandler::on_new_session`, thus its safe to use the same value everywhere.
|
||||
let account_id = AuthorityPair::from_seed_slice(vec![10; 32].as_ref()).unwrap().public();
|
||||
|
||||
let first_authorities: Vec<AuthorityId> = vec![0, 1].into_iter()
|
||||
@@ -203,14 +203,14 @@ mod tests {
|
||||
.map(AuthorityId::from)
|
||||
.collect();
|
||||
|
||||
// Needed for `session::OneSessionHandler::on_new_session`.
|
||||
// Needed for `pallet_session::OneSessionHandler::on_new_session`.
|
||||
let second_authorities_and_account_ids: Vec<(&AuthorityId, AuthorityId)> = second_authorities.clone()
|
||||
.into_iter()
|
||||
.map(|id| (&account_id, id))
|
||||
.collect();
|
||||
|
||||
// Build genesis.
|
||||
let mut t = system::GenesisConfig::default()
|
||||
let mut t = frame_system::GenesisConfig::default()
|
||||
.build_storage::<Test>()
|
||||
.unwrap();
|
||||
|
||||
@@ -224,7 +224,7 @@ mod tests {
|
||||
let mut externalities = TestExternalities::new(t);
|
||||
|
||||
externalities.execute_with(|| {
|
||||
use session::OneSessionHandler;
|
||||
use pallet_session::OneSessionHandler;
|
||||
|
||||
AuthorityDiscovery::on_genesis_session(
|
||||
first_authorities.iter().map(|id| (id, id.clone()))
|
||||
|
||||
@@ -6,14 +6,14 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
|
||||
sp-inherents = { path = "../../primitives/inherents", default-features = false }
|
||||
sp-authorship = { path = "../../primitives/authorship", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
sp-io ={ path = "../../primitives/io", default-features = false }
|
||||
impl-trait-for-tuples = "0.1.3"
|
||||
|
||||
@@ -21,12 +21,12 @@ impl-trait-for-tuples = "0.1.3"
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"inherents/std",
|
||||
"sp-core/std",
|
||||
"sp-inherents/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"sp-io/std",
|
||||
"sp-authorship/std",
|
||||
]
|
||||
|
||||
@@ -22,18 +22,18 @@
|
||||
|
||||
use sp_std::{result, prelude::*};
|
||||
use sp_std::collections::btree_set::BTreeSet;
|
||||
use support::{decl_module, decl_storage, dispatch, ensure};
|
||||
use support::traits::{FindAuthor, VerifySeal, Get};
|
||||
use frame_support::{decl_module, decl_storage, dispatch, ensure};
|
||||
use frame_support::traits::{FindAuthor, VerifySeal, Get};
|
||||
use codec::{Encode, Decode};
|
||||
use system::ensure_none;
|
||||
use frame_system::ensure_none;
|
||||
use sp_runtime::traits::{Header as HeaderT, One, Zero};
|
||||
use support::weights::SimpleDispatchInfo;
|
||||
use inherents::{InherentIdentifier, ProvideInherent, InherentData};
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
use sp_inherents::{InherentIdentifier, ProvideInherent, InherentData};
|
||||
use sp_authorship::{INHERENT_IDENTIFIER, UnclesInherentData, InherentError};
|
||||
|
||||
const MAX_UNCLES: usize = 10;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// Find the author of a block.
|
||||
type FindAuthor: FindAuthor<Self::AccountId>;
|
||||
/// The number of blocks back we should accept uncles.
|
||||
@@ -209,7 +209,7 @@ impl<T: Trait> Module<T> {
|
||||
return author;
|
||||
}
|
||||
|
||||
let digest = <system::Module<T>>::digest();
|
||||
let digest = <frame_system::Module<T>>::digest();
|
||||
let pre_runtime_digests = digest.logs.iter().filter_map(|d| d.as_pre_runtime());
|
||||
if let Some(author) = T::FindAuthor::find_author(pre_runtime_digests) {
|
||||
<Self as Store>::Author::put(&author);
|
||||
@@ -220,7 +220,7 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
fn verify_and_import_uncles(new_uncles: Vec<T::Header>) -> dispatch::Result {
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
|
||||
let mut uncles = <Self as Store>::Uncles::get();
|
||||
uncles.push(UncleEntryItem::InclusionHeight(now));
|
||||
@@ -253,7 +253,7 @@ impl<T: Trait> Module<T> {
|
||||
accumulator: &mut <T::FilterUncle as FilterUncle<T::Header, T::AccountId>>::Accumulator,
|
||||
) -> Result<Option<T::AccountId>, &'static str>
|
||||
{
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
|
||||
let (minimum_height, maximum_height) = {
|
||||
let uncle_generations = T::UncleGenerations::get();
|
||||
@@ -278,7 +278,7 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
{
|
||||
let parent_number = uncle.number().clone() - One::one();
|
||||
let parent_hash = <system::Module<T>>::block_hash(&parent_number);
|
||||
let parent_hash = <frame_system::Module<T>>::block_hash(&parent_number);
|
||||
if &parent_hash != uncle.parent_hash() {
|
||||
return Err("uncle parent not in chain");
|
||||
}
|
||||
@@ -289,7 +289,7 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
let duplicate = existing_uncles.into_iter().find(|h| **h == hash).is_some();
|
||||
let in_chain = <system::Module<T>>::block_hash(uncle.number()) == hash;
|
||||
let in_chain = <frame_system::Module<T>>::block_hash(uncle.number()) == hash;
|
||||
|
||||
if duplicate || in_chain {
|
||||
return Err("uncle already included")
|
||||
@@ -372,14 +372,14 @@ impl<T: Trait> ProvideInherent for Module<T> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
traits::{BlakeTwo256, IdentityLookup}, testing::Header, generic::DigestItem, Perbill,
|
||||
};
|
||||
use support::{parameter_types, impl_outer_origin, ConsensusEngineId, weights::Weight};
|
||||
use frame_support::{parameter_types, impl_outer_origin, ConsensusEngineId, weights::Weight};
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
#[derive(Clone, Eq, PartialEq)]
|
||||
@@ -392,7 +392,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;
|
||||
@@ -421,7 +421,7 @@ mod tests {
|
||||
type EventHandler = ();
|
||||
}
|
||||
|
||||
type System = system::Module<Test>;
|
||||
type System = frame_system::Module<Test>;
|
||||
type Authorship = Module<Test>;
|
||||
|
||||
const TEST_ID: ConsensusEngineId = [1, 2, 3, 4];
|
||||
@@ -493,7 +493,7 @@ mod tests {
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
@@ -8,24 +8,24 @@ edition = "2018"
|
||||
hex-literal = "0.2.1"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
|
||||
sp-inherents = { path = "../../primitives/inherents", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
pallet-timestamp = { path = "../timestamp", default-features = false }
|
||||
sp-timestamp = { path = "../../primitives/timestamp", default-features = false }
|
||||
session = { package = "pallet-session", path = "../session", default-features = false }
|
||||
babe-primitives = { package = "sp-consensus-babe", path = "../../primitives/consensus/babe", default-features = false }
|
||||
pallet-session = { path = "../session", default-features = false }
|
||||
sp-consensus-babe = { path = "../../primitives/consensus/babe", default-features = false }
|
||||
sp-io ={ path = "../../primitives/io", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
lazy_static = "1.4.0"
|
||||
parking_lot = "0.9.0"
|
||||
sp-version = { path = "../../primitives/version", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
test-runtime = { package = "substrate-test-runtime", path = "../../test-utils/runtime" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
substrate-test-runtime = { path = "../../test-utils/runtime" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -33,14 +33,14 @@ std = [
|
||||
"serde",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"system/std",
|
||||
"timestamp/std",
|
||||
"frame-system/std",
|
||||
"pallet-timestamp/std",
|
||||
"sp-timestamp/std",
|
||||
"inherents/std",
|
||||
"babe-primitives/std",
|
||||
"session/std",
|
||||
"sp-inherents/std",
|
||||
"sp-consensus-babe/std",
|
||||
"pallet-session/std",
|
||||
"sp-io/std",
|
||||
]
|
||||
|
||||
@@ -20,11 +20,10 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![forbid(unused_must_use, unsafe_code, unused_variables, unused_must_use)]
|
||||
#![deny(unused_imports)]
|
||||
pub use timestamp;
|
||||
use sp_timestamp;
|
||||
pub use pallet_timestamp;
|
||||
|
||||
use sp_std::{result, prelude::*};
|
||||
use support::{decl_storage, decl_module, traits::FindAuthor, traits::Get};
|
||||
use frame_support::{decl_storage, decl_module, traits::FindAuthor, traits::Get};
|
||||
use sp_timestamp::OnTimestampSet;
|
||||
use sp_runtime::{generic::DigestItem, ConsensusEngineId, Perbill};
|
||||
use sp_runtime::traits::{IsMember, SaturatedConversion, Saturating, RandomnessBeacon};
|
||||
@@ -34,12 +33,12 @@ use sp_staking::{
|
||||
};
|
||||
|
||||
use codec::{Encode, Decode};
|
||||
use inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError};
|
||||
use babe_primitives::{
|
||||
use sp_inherents::{InherentIdentifier, InherentData, ProvideInherent, MakeFatalError};
|
||||
use sp_consensus_babe::{
|
||||
BABE_ENGINE_ID, ConsensusLog, BabeAuthorityWeight, NextEpochDescriptor, RawBabePreDigest,
|
||||
SlotNumber, inherents::{INHERENT_IDENTIFIER, BabeInherentData}
|
||||
};
|
||||
pub use babe_primitives::{AuthorityId, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH};
|
||||
pub use sp_consensus_babe::{AuthorityId, VRF_OUTPUT_LENGTH, PUBLIC_KEY_LENGTH};
|
||||
|
||||
#[cfg(all(feature = "std", test))]
|
||||
mod tests;
|
||||
@@ -47,7 +46,7 @@ mod tests;
|
||||
#[cfg(all(feature = "std", test))]
|
||||
mod mock;
|
||||
|
||||
pub trait Trait: timestamp::Trait {
|
||||
pub trait Trait: pallet_timestamp::Trait {
|
||||
/// The amount of time, in slots, that each epoch should last.
|
||||
type EpochDuration: Get<SlotNumber>;
|
||||
|
||||
@@ -228,11 +227,11 @@ impl<T: Trait> IsMember<AuthorityId> for Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> session::ShouldEndSession<T::BlockNumber> for Module<T> {
|
||||
impl<T: Trait> pallet_session::ShouldEndSession<T::BlockNumber> for Module<T> {
|
||||
fn should_end_session(now: T::BlockNumber) -> bool {
|
||||
// it might be (and it is in current implementation) that session module is calling
|
||||
// should_end_session() from it's own on_initialize() handler
|
||||
// => because session on_initialize() is called earlier than ours, let's ensure
|
||||
// => because pallet_session on_initialize() is called earlier than ours, let's ensure
|
||||
// that we have synced with digest before checking if session should be ended.
|
||||
Self::do_initialize(now);
|
||||
|
||||
@@ -292,7 +291,7 @@ impl<T: Trait> Module<T> {
|
||||
pub fn slot_duration() -> T::Moment {
|
||||
// we double the minimum block-period so each author can always propose within
|
||||
// the majority of their slot.
|
||||
<T as timestamp::Trait>::MinimumPeriod::get().saturating_mul(2.into())
|
||||
<T as pallet_timestamp::Trait>::MinimumPeriod::get().saturating_mul(2.into())
|
||||
}
|
||||
|
||||
/// Determine whether an epoch change should take place at this block.
|
||||
@@ -367,7 +366,7 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
fn deposit_consensus<U: Encode>(new: U) {
|
||||
let log: DigestItem<T::Hash> = DigestItem::Consensus(BABE_ENGINE_ID, new.encode());
|
||||
<system::Module<T>>::deposit_log(log.into())
|
||||
<frame_system::Module<T>>::deposit_log(log.into())
|
||||
}
|
||||
|
||||
fn deposit_vrf_output(vrf_output: &[u8; VRF_OUTPUT_LENGTH]) {
|
||||
@@ -393,7 +392,7 @@ impl<T: Trait> Module<T> {
|
||||
return;
|
||||
}
|
||||
|
||||
let maybe_pre_digest = <system::Module<T>>::digest()
|
||||
let maybe_pre_digest = <frame_system::Module<T>>::digest()
|
||||
.logs
|
||||
.iter()
|
||||
.filter_map(|s| s.as_pre_runtime())
|
||||
@@ -476,7 +475,7 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
|
||||
type Public = AuthorityId;
|
||||
}
|
||||
|
||||
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
type Key = AuthorityId;
|
||||
|
||||
fn on_genesis_session<'a, I: 'a>(validators: I)
|
||||
@@ -527,8 +526,8 @@ fn compute_randomness(
|
||||
}
|
||||
|
||||
impl<T: Trait> ProvideInherent for Module<T> {
|
||||
type Call = timestamp::Call<T>;
|
||||
type Error = MakeFatalError<inherents::Error>;
|
||||
type Call = pallet_timestamp::Call<T>;
|
||||
type Error = MakeFatalError<sp_inherents::Error>;
|
||||
const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
|
||||
|
||||
fn create_inherent(_: &InherentData) -> Option<Self::Call> {
|
||||
@@ -537,7 +536,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
|
||||
|
||||
fn check_inherent(call: &Self::Call, data: &InherentData) -> result::Result<(), Self::Error> {
|
||||
let timestamp = match call {
|
||||
timestamp::Call::set(ref timestamp) => timestamp.clone(),
|
||||
pallet_timestamp::Call::set(ref timestamp) => timestamp.clone(),
|
||||
_ => return Ok(()),
|
||||
};
|
||||
|
||||
@@ -547,7 +546,7 @@ impl<T: Trait> ProvideInherent for Module<T> {
|
||||
if timestamp_based_slot == seal_slot {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(inherents::Error::from("timestamp set in block doesn't match slot in seal").into())
|
||||
Err(sp_inherents::Error::from("timestamp set in block doesn't match slot in seal").into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,17 +18,17 @@
|
||||
#![allow(dead_code, unused_imports)]
|
||||
|
||||
use super::{Trait, Module, GenesisConfig};
|
||||
use babe_primitives::AuthorityId;
|
||||
use sp_consensus_babe::AuthorityId;
|
||||
use sp_runtime::{
|
||||
traits::IdentityLookup, Perbill, testing::{Header, UintAuthorityId}, impl_opaque_keys,
|
||||
};
|
||||
use sp_version::RuntimeVersion;
|
||||
use support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_io;
|
||||
use primitives::{H256, Blake2Hasher};
|
||||
use sp_core::{H256, Blake2Hasher};
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
type DummyValidatorId = u64;
|
||||
@@ -45,11 +45,11 @@ parameter_types! {
|
||||
pub const MinimumPeriod: u64 = 1;
|
||||
pub const EpochDuration: u64 = 3;
|
||||
pub const ExpectedBlockTime: u64 = 1;
|
||||
pub const Version: RuntimeVersion = test_runtime::VERSION;
|
||||
pub const Version: RuntimeVersion = substrate_test_runtime::VERSION;
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(16);
|
||||
}
|
||||
|
||||
impl system::Trait for Test {
|
||||
impl frame_system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -73,9 +73,9 @@ impl_opaque_keys! {
|
||||
}
|
||||
}
|
||||
|
||||
impl session::Trait for Test {
|
||||
impl pallet_session::Trait for Test {
|
||||
type Event = ();
|
||||
type ValidatorId = <Self as system::Trait>::AccountId;
|
||||
type ValidatorId = <Self as frame_system::Trait>::AccountId;
|
||||
type ShouldEndSession = Babe;
|
||||
type SessionHandler = (Babe,Babe,);
|
||||
type OnSessionEnding = ();
|
||||
@@ -85,7 +85,7 @@ impl session::Trait for Test {
|
||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Test {
|
||||
impl pallet_timestamp::Trait for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = Babe;
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
@@ -98,12 +98,12 @@ impl Trait for Test {
|
||||
}
|
||||
|
||||
pub fn new_test_ext(authorities: Vec<DummyValidatorId>) -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
GenesisConfig {
|
||||
authorities: authorities.into_iter().map(|a| (UintAuthorityId(a).to_public_key(), 1)).collect(),
|
||||
}.assimilate_storage::<Test>(&mut t).unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
pub type System = system::Module<Test>;
|
||||
pub type System = frame_system::Module<Test>;
|
||||
pub type Babe = Module<Test>;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use super::*;
|
||||
use mock::{new_test_ext, Babe, Test};
|
||||
use sp_runtime::{traits::OnFinalize, testing::{Digest, DigestItem}};
|
||||
use session::ShouldEndSession;
|
||||
use pallet_session::ShouldEndSession;
|
||||
|
||||
const EMPTY_RANDOMNESS: [u8; 32] = [
|
||||
74, 25, 49, 128, 53, 97, 244, 49,
|
||||
@@ -29,18 +29,18 @@ const EMPTY_RANDOMNESS: [u8; 32] = [
|
||||
];
|
||||
|
||||
fn make_pre_digest(
|
||||
authority_index: babe_primitives::AuthorityIndex,
|
||||
slot_number: babe_primitives::SlotNumber,
|
||||
vrf_output: [u8; babe_primitives::VRF_OUTPUT_LENGTH],
|
||||
vrf_proof: [u8; babe_primitives::VRF_PROOF_LENGTH],
|
||||
authority_index: sp_consensus_babe::AuthorityIndex,
|
||||
slot_number: sp_consensus_babe::SlotNumber,
|
||||
vrf_output: [u8; sp_consensus_babe::VRF_OUTPUT_LENGTH],
|
||||
vrf_proof: [u8; sp_consensus_babe::VRF_PROOF_LENGTH],
|
||||
) -> Digest {
|
||||
let digest_data = babe_primitives::RawBabePreDigest::Primary {
|
||||
let digest_data = sp_consensus_babe::RawBabePreDigest::Primary {
|
||||
authority_index,
|
||||
slot_number,
|
||||
vrf_output,
|
||||
vrf_proof,
|
||||
};
|
||||
let log = DigestItem::PreRuntime(babe_primitives::BABE_ENGINE_ID, digest_data.encode());
|
||||
let log = DigestItem::PreRuntime(sp_consensus_babe::BABE_ENGINE_ID, digest_data.encode());
|
||||
Digest { logs: vec![log] }
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ fn check_module() {
|
||||
})
|
||||
}
|
||||
|
||||
type System = system::Module<Test>;
|
||||
type System = frame_system::Module<Test>;
|
||||
|
||||
#[test]
|
||||
fn first_block_epoch_zero_start() {
|
||||
@@ -103,8 +103,8 @@ fn first_block_epoch_zero_start() {
|
||||
assert_eq!(header.digest.logs[0], pre_digest.logs[0]);
|
||||
|
||||
let authorities = Babe::authorities();
|
||||
let consensus_log = babe_primitives::ConsensusLog::NextEpochData(
|
||||
babe_primitives::NextEpochDescriptor {
|
||||
let consensus_log = sp_consensus_babe::ConsensusLog::NextEpochData(
|
||||
sp_consensus_babe::NextEpochDescriptor {
|
||||
authorities,
|
||||
randomness: Babe::randomness(),
|
||||
}
|
||||
|
||||
@@ -10,13 +10,13 @@ safe-mix = { version = "1.0.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../transaction-payment" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
pallet-transaction-payment = { path = "../transaction-payment" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -25,7 +25,7 @@ std = [
|
||||
"safe-mix/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -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![],
|
||||
|
||||
@@ -8,27 +8,27 @@ edition = "2018"
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
safe-mix = { version = "1.0.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.2.1"
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"safe-mix/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"serde",
|
||||
"sp-io/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
#![recursion_limit="128"]
|
||||
|
||||
use sp_std::{prelude::*, result};
|
||||
use primitives::u32_trait::Value as U32;
|
||||
use sp_core::u32_trait::Value as U32;
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_runtime::traits::{Hash, EnsureOrigin};
|
||||
use support::weights::SimpleDispatchInfo;
|
||||
use support::{
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
use frame_support::{
|
||||
dispatch::{Dispatchable, Parameter}, codec::{Encode, Decode},
|
||||
traits::{ChangeMembers, InitializeMembers}, decl_module, decl_event,
|
||||
decl_storage, ensure,
|
||||
};
|
||||
use system::{self, ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
/// Simple index type for proposal counting.
|
||||
pub type ProposalIndex = u32;
|
||||
@@ -44,7 +44,7 @@ pub type ProposalIndex = u32;
|
||||
/// vote exactly once, therefore also the number of votes for any given motion.
|
||||
pub type MemberCount = u32;
|
||||
|
||||
pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
pub trait Trait<I=DefaultInstance>: frame_system::Trait {
|
||||
/// The outer origin type.
|
||||
type Origin: From<RawOrigin<Self::AccountId, I>>;
|
||||
|
||||
@@ -52,7 +52,7 @@ pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
type Proposal: Parameter + Dispatchable<Origin=<Self as Trait<I>>::Origin>;
|
||||
|
||||
/// The outer 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>;
|
||||
}
|
||||
|
||||
/// Origin for the collective module.
|
||||
@@ -67,7 +67,7 @@ pub enum RawOrigin<AccountId, I> {
|
||||
}
|
||||
|
||||
/// Origin for the collective module.
|
||||
pub type Origin<T, I=DefaultInstance> = RawOrigin<<T as system::Trait>::AccountId, I>;
|
||||
pub type Origin<T, I=DefaultInstance> = RawOrigin<<T as frame_system::Trait>::AccountId, I>;
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
/// Info for keeping track of a motion being voted on.
|
||||
@@ -104,8 +104,8 @@ decl_storage! {
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I=DefaultInstance> where
|
||||
<T as system::Trait>::Hash,
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::Hash,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
{
|
||||
/// A motion (given hash) has been proposed (by given account) with a threshold (given
|
||||
/// `MemberCount`).
|
||||
@@ -128,7 +128,7 @@ decl_event!(
|
||||
// executed logic with other democracy function. Note that councillor operations are assigned to the
|
||||
// operational class.
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait<I>, I: Instance=DefaultInstance> for enum Call where origin: <T as system::Trait>::Origin {
|
||||
pub struct Module<T: Trait<I>, I: Instance=DefaultInstance> for enum Call where origin: <T as frame_system::Trait>::Origin {
|
||||
fn deposit_event() = default;
|
||||
|
||||
/// Set the collective's membership manually to `new_members`. Be nice to the chain and
|
||||
@@ -379,10 +379,10 @@ impl<
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use support::{Hashable, assert_ok, assert_noop, parameter_types, weights::Weight};
|
||||
use system::{EventRecord, Phase};
|
||||
use frame_support::{Hashable, assert_ok, assert_noop, parameter_types, weights::Weight};
|
||||
use frame_system::{self as system, EventRecord, Phase};
|
||||
use hex_literal::hex;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill, traits::{BlakeTwo256, IdentityLookup, Block as BlockT}, testing::Header,
|
||||
BuildStorage,
|
||||
@@ -395,7 +395,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -426,7 +426,7 @@ mod tests {
|
||||
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, u64, Call, ()>;
|
||||
|
||||
support::construct_runtime!(
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
@@ -458,7 +458,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn make_proposal(value: u64) -> Call {
|
||||
Call::System(system::Call::remark(value.encode()))
|
||||
Call::System(frame_system::Call::remark(value.encode()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -10,34 +10,34 @@ pwasm-utils = { version = "0.12.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
parity-wasm = { version = "0.41.0", default-features = false }
|
||||
wasmi-validation = { version = "0.3.0", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sandbox = { package = "sp-sandbox", path = "../../primitives/sandbox", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
sp-sandbox = { path = "../../primitives/sandbox", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.9.2"
|
||||
assert_matches = "1.3.0"
|
||||
hex-literal = "0.2.1"
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
timestamp = { package = "pallet-timestamp", path = "../timestamp" }
|
||||
randomness-collective-flip = { package = "pallet-randomness-collective-flip", path = "../randomness-collective-flip" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
pallet-timestamp = { path = "../timestamp" }
|
||||
pallet-randomness-collective-flip = { path = "../randomness-collective-flip" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-io/std",
|
||||
"sp-std/std",
|
||||
"sandbox/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"sp-sandbox/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"parity-wasm/std",
|
||||
"pwasm-utils/std",
|
||||
"wasmi-validation/std",
|
||||
|
||||
@@ -10,8 +10,8 @@ jsonrpc-core = "14.0.3"
|
||||
jsonrpc-core-client = "14.0.3"
|
||||
jsonrpc-derive = "14.0.3"
|
||||
sp-blockchain = { path = "../../../primitives/blockchain" }
|
||||
primitives = { package = "sp-core", path = "../../../primitives/core" }
|
||||
rpc-primitives = { package = "sp-rpc", path = "../../../primitives/rpc" }
|
||||
sp-core = { path = "../../../primitives/core" }
|
||||
sp-rpc = { path = "../../../primitives/rpc" }
|
||||
serde = { version = "1.0.101", features = ["derive"] }
|
||||
sp-runtime = { path = "../../../primitives/runtime" }
|
||||
pallet-contracts-rpc-runtime-api = { path = "./runtime-api" }
|
||||
|
||||
@@ -22,8 +22,8 @@ use sp_blockchain::HeaderBackend;
|
||||
use codec::Codec;
|
||||
use jsonrpc_core::{Error, ErrorCode, Result};
|
||||
use jsonrpc_derive::rpc;
|
||||
use primitives::{H256, Bytes};
|
||||
use rpc_primitives::number;
|
||||
use sp_core::{H256, Bytes};
|
||||
use sp_rpc::number;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_runtime::{
|
||||
generic::BlockId,
|
||||
|
||||
@@ -26,9 +26,9 @@ use sp_std::collections::btree_map::{BTreeMap, Entry};
|
||||
use sp_std::prelude::*;
|
||||
use sp_io::hashing::blake2_256;
|
||||
use sp_runtime::traits::{Bounded, Zero};
|
||||
use support::traits::{Currency, Get, Imbalance, SignedImbalance, UpdateBalanceOutcome};
|
||||
use support::{storage::child, StorageMap};
|
||||
use system;
|
||||
use frame_support::traits::{Currency, Get, Imbalance, SignedImbalance, UpdateBalanceOutcome};
|
||||
use frame_support::{storage::child, StorageMap};
|
||||
use frame_system;
|
||||
|
||||
// Note: we don't provide Option<Contract> because we can't create
|
||||
// the trie_id in the overlay, thus we provide an overlay on the fields
|
||||
@@ -100,7 +100,7 @@ impl<T: Trait> Default for ChangeEntry<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub type ChangeSet<T> = BTreeMap<<T as system::Trait>::AccountId, ChangeEntry<T>>;
|
||||
pub type ChangeSet<T> = BTreeMap<<T as frame_system::Trait>::AccountId, ChangeEntry<T>>;
|
||||
|
||||
pub trait AccountDb<T: Trait> {
|
||||
/// Account is used when overlayed otherwise trie_id must be provided.
|
||||
@@ -184,7 +184,7 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
code_hash,
|
||||
storage_size: T::StorageSizeOffset::get(),
|
||||
trie_id: <T as Trait>::TrieIdGenerator::trie_id(&address),
|
||||
deduct_block: <system::Module<T>>::block_number(),
|
||||
deduct_block: <frame_system::Module<T>>::block_number(),
|
||||
rent_allowance: <BalanceOf<T>>::max_value(),
|
||||
last_write: None,
|
||||
}
|
||||
@@ -195,7 +195,7 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
code_hash,
|
||||
storage_size: T::StorageSizeOffset::get(),
|
||||
trie_id: <T as Trait>::TrieIdGenerator::trie_id(&address),
|
||||
deduct_block: <system::Module<T>>::block_number(),
|
||||
deduct_block: <frame_system::Module<T>>::block_number(),
|
||||
rent_allowance: <BalanceOf<T>>::max_value(),
|
||||
last_write: None,
|
||||
}
|
||||
@@ -213,7 +213,7 @@ impl<T: Trait> AccountDb<T> for DirectAccountDb {
|
||||
}
|
||||
|
||||
if !changed.storage.is_empty() {
|
||||
new_info.last_write = Some(<system::Module<T>>::block_number());
|
||||
new_info.last_write = Some(<frame_system::Module<T>>::block_number());
|
||||
}
|
||||
|
||||
for (k, v) in changed.storage.into_iter() {
|
||||
|
||||
@@ -22,20 +22,20 @@ use crate::rent;
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_runtime::traits::{Bounded, CheckedAdd, CheckedSub, Zero};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
storage::unhashed,
|
||||
traits::{WithdrawReason, Currency, Time, Randomness},
|
||||
};
|
||||
|
||||
pub type AccountIdOf<T> = <T as system::Trait>::AccountId;
|
||||
pub type AccountIdOf<T> = <T as frame_system::Trait>::AccountId;
|
||||
pub type CallOf<T> = <T as Trait>::Call;
|
||||
pub type MomentOf<T> = <<T as Trait>::Time as Time>::Moment;
|
||||
pub type SeedOf<T> = <T as system::Trait>::Hash;
|
||||
pub type BlockNumberOf<T> = <T as system::Trait>::BlockNumber;
|
||||
pub type SeedOf<T> = <T as frame_system::Trait>::Hash;
|
||||
pub type BlockNumberOf<T> = <T as frame_system::Trait>::BlockNumber;
|
||||
pub type StorageKey = [u8; 32];
|
||||
|
||||
/// A type that represents a topic of an event. At the moment a hash is used.
|
||||
pub type TopicOf<T> = <T as system::Trait>::Hash;
|
||||
pub type TopicOf<T> = <T as frame_system::Trait>::Hash;
|
||||
|
||||
/// A status code return to the source of a contract call or instantiation indicating success or
|
||||
/// failure. A code of 0 indicates success and that changes are applied. All other codes indicate
|
||||
@@ -304,7 +304,7 @@ where
|
||||
vm: &vm,
|
||||
loader: &loader,
|
||||
timestamp: T::Time::now(),
|
||||
block_number: <system::Module<T>>::block_number(),
|
||||
block_number: <frame_system::Module<T>>::block_number(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -871,7 +871,7 @@ mod tests {
|
||||
|
||||
fn insert(&mut self, f: impl Fn(MockCtx) -> ExecResult + 'a) -> CodeHash<Test> {
|
||||
// Generate code hashes as monotonically increasing values.
|
||||
let code_hash = <Test as system::Trait>::Hash::from_low_u64_be(self.counter);
|
||||
let code_hash = <Test as frame_system::Trait>::Hash::from_low_u64_be(self.counter);
|
||||
|
||||
self.counter += 1;
|
||||
self.map.insert(code_hash, MockExecutable::new(f));
|
||||
|
||||
@@ -19,7 +19,7 @@ use sp_std::convert::TryFrom;
|
||||
use sp_runtime::traits::{
|
||||
CheckedMul, Zero, SaturatedConversion, SimpleArithmetic, UniqueSaturatedInto,
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
traits::{Currency, ExistenceRequirement, Imbalance, OnUnbalanced, WithdrawReason}, StorageValue,
|
||||
};
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ pub use crate::exec::{ExecResult, ExecReturnValue, ExecError, StatusCode};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
use primitives::crypto::UncheckedFrom;
|
||||
use sp_core::crypto::UncheckedFrom;
|
||||
use sp_std::{prelude::*, marker::PhantomData, fmt::Debug};
|
||||
use codec::{Codec, Encode, Decode};
|
||||
use sp_io::hashing::blake2_256;
|
||||
@@ -119,17 +119,17 @@ use sp_runtime::{
|
||||
},
|
||||
RuntimeDebug,
|
||||
};
|
||||
use support::dispatch::{Result, Dispatchable};
|
||||
use support::{
|
||||
use frame_support::dispatch::{Result, Dispatchable};
|
||||
use frame_support::{
|
||||
Parameter, decl_module, decl_event, decl_storage, storage::child,
|
||||
parameter_types, IsSubType,
|
||||
weights::DispatchInfo,
|
||||
};
|
||||
use support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get, Time, Randomness};
|
||||
use system::{ensure_signed, RawOrigin, ensure_root};
|
||||
use primitives::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX;
|
||||
use frame_support::traits::{OnFreeBalanceZero, OnUnbalanced, Currency, Get, Time, Randomness};
|
||||
use frame_system::{self as system, ensure_signed, RawOrigin, ensure_root};
|
||||
use sp_core::storage::well_known_keys::CHILD_STORAGE_KEY_PREFIX;
|
||||
|
||||
pub type CodeHash<T> = <T as system::Trait>::Hash;
|
||||
pub type CodeHash<T> = <T as frame_system::Trait>::Hash;
|
||||
pub type TrieId = Vec<u8>;
|
||||
|
||||
/// A function that generates an `AccountId` for a contract upon instantiation.
|
||||
@@ -203,7 +203,7 @@ impl<T: Trait> ContractInfo<T> {
|
||||
}
|
||||
|
||||
pub type AliveContractInfo<T> =
|
||||
RawAliveContractInfo<CodeHash<T>, BalanceOf<T>, <T as system::Trait>::BlockNumber>;
|
||||
RawAliveContractInfo<CodeHash<T>, BalanceOf<T>, <T as frame_system::Trait>::BlockNumber>;
|
||||
|
||||
/// Information for managing an account and its sub trie abstraction.
|
||||
/// This is the required info to cache for an account.
|
||||
@@ -237,7 +237,7 @@ pub(crate) fn trie_unique_id(trie_id: &[u8]) -> child::ChildInfo {
|
||||
}
|
||||
|
||||
pub type TombstoneContractInfo<T> =
|
||||
RawTombstoneContractInfo<<T as system::Trait>::Hash, <T as system::Trait>::Hashing>;
|
||||
RawTombstoneContractInfo<<T as frame_system::Trait>::Hash, <T as frame_system::Trait>::Hashing>;
|
||||
|
||||
#[derive(Encode, Decode, PartialEq, Eq, RuntimeDebug)]
|
||||
pub struct RawTombstoneContractInfo<H, Hasher>(H, PhantomData<Hasher>);
|
||||
@@ -303,9 +303,9 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
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 system::Trait>::AccountId>>::NegativeImbalance;
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
|
||||
parameter_types! {
|
||||
/// A reasonable default value for [`Trait::SignedClaimedHandicap`].
|
||||
@@ -342,16 +342,16 @@ parameter_types! {
|
||||
pub const DefaultBlockGasLimit: u32 = 10_000_000;
|
||||
}
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
type Currency: Currency<Self::AccountId>;
|
||||
type Time: Time;
|
||||
type Randomness: Randomness<Self::Hash>;
|
||||
|
||||
/// The outer call dispatch type.
|
||||
type Call: Parameter + Dispatchable<Origin=<Self as system::Trait>::Origin> + IsSubType<Module<Self>, Self>;
|
||||
type Call: Parameter + Dispatchable<Origin=<Self as frame_system::Trait>::Origin> + IsSubType<Module<Self>, Self>;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// A function type to get the contract address given the instantiator.
|
||||
type DetermineContractAddress: ContractAddressFor<CodeHash<Self>, Self::AccountId>;
|
||||
@@ -469,7 +469,7 @@ impl<T: Trait> ComputeDispatchFee<<T as Trait>::Call, BalanceOf<T>> for DefaultD
|
||||
|
||||
decl_module! {
|
||||
/// Contracts module.
|
||||
pub struct Module<T: Trait> for enum Call where origin: <T as system::Trait>::Origin {
|
||||
pub struct Module<T: Trait> for enum Call where origin: <T as frame_system::Trait>::Origin {
|
||||
/// Number of block delay an extrinsic claim surcharge has.
|
||||
///
|
||||
/// When claim surcharge is called by an extrinsic the rent is checked
|
||||
@@ -630,10 +630,10 @@ decl_module! {
|
||||
fn claim_surcharge(origin, dest: T::AccountId, aux_sender: Option<T::AccountId>) {
|
||||
let origin = origin.into();
|
||||
let (signed, rewarded) = match (origin, aux_sender) {
|
||||
(Ok(system::RawOrigin::Signed(account)), None) => {
|
||||
(Ok(frame_system::RawOrigin::Signed(account)), None) => {
|
||||
(true, account)
|
||||
},
|
||||
(Ok(system::RawOrigin::None), Some(aux_sender)) => {
|
||||
(Ok(frame_system::RawOrigin::None), Some(aux_sender)) => {
|
||||
(false, aux_sender)
|
||||
},
|
||||
_ => return Err(
|
||||
@@ -751,7 +751,7 @@ impl<T: Trait> Module<T> {
|
||||
DepositEvent {
|
||||
topics,
|
||||
event,
|
||||
} => <system::Module<T>>::deposit_event_indexed(
|
||||
} => <frame_system::Module<T>>::deposit_event_indexed(
|
||||
&*topics,
|
||||
<T as Trait>::Event::from(event).into(),
|
||||
),
|
||||
@@ -788,7 +788,7 @@ impl<T: Trait> Module<T> {
|
||||
.and_then(|c| c.get_alive())
|
||||
.ok_or("Cannot restore from inexisting or tombstone contract")?;
|
||||
|
||||
let current_block = <system::Module<T>>::block_number();
|
||||
let current_block = <frame_system::Module<T>>::block_number();
|
||||
|
||||
if origin_contract.last_write == Some(current_block) {
|
||||
return Err("Origin TrieId written in the current block");
|
||||
@@ -870,8 +870,8 @@ decl_event! {
|
||||
pub enum Event<T>
|
||||
where
|
||||
Balance = BalanceOf<T>,
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as system::Trait>::Hash
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::Hash
|
||||
{
|
||||
/// Transfer happened `from` to `to` with given `value` as part of a `call` or `instantiate`.
|
||||
Transfer(AccountId, AccountId, Balance),
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
use crate::{BalanceOf, ContractInfo, ContractInfoOf, TombstoneContractInfo, Trait, AliveContractInfo};
|
||||
use sp_runtime::traits::{Bounded, CheckedDiv, CheckedMul, Saturating, Zero,
|
||||
SaturatedConversion};
|
||||
use support::traits::{Currency, ExistenceRequirement, Get, WithdrawReason, OnUnbalanced};
|
||||
use support::StorageMap;
|
||||
use support::storage::child;
|
||||
use frame_support::traits::{Currency, ExistenceRequirement, Get, WithdrawReason, OnUnbalanced};
|
||||
use frame_support::StorageMap;
|
||||
use frame_support::storage::child;
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
#[must_use]
|
||||
@@ -58,7 +58,7 @@ fn try_evict_or_and_pay_rent<T: Trait>(
|
||||
Some(ContractInfo::Alive(contract)) => contract,
|
||||
};
|
||||
|
||||
let current_block_number = <system::Module<T>>::block_number();
|
||||
let current_block_number = <frame_system::Module<T>>::block_number();
|
||||
|
||||
// How much block has passed since the last deduction for the contract.
|
||||
let blocks_passed = {
|
||||
|
||||
@@ -32,29 +32,32 @@ use sp_runtime::{
|
||||
traits::{BlakeTwo256, Hash, IdentityLookup, SignedExtension},
|
||||
testing::{Digest, DigestItem, Header, UintAuthorityId, H256},
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
assert_ok, assert_err, impl_outer_dispatch, impl_outer_event, impl_outer_origin, parameter_types,
|
||||
storage::child, StorageMap, StorageValue, traits::{Currency, Get},
|
||||
weights::{DispatchInfo, DispatchClass, Weight},
|
||||
};
|
||||
use std::{cell::RefCell, sync::atomic::{AtomicUsize, Ordering}};
|
||||
use primitives::storage::well_known_keys;
|
||||
use system::{self, EventRecord, Phase};
|
||||
use sp_core::storage::well_known_keys;
|
||||
use frame_system::{self as system, EventRecord, Phase};
|
||||
|
||||
mod contract {
|
||||
// Re-export contents of the root. This basically
|
||||
// needs to give a name for the current crate.
|
||||
// This hack is required for `impl_outer_event!`.
|
||||
pub use super::super::*;
|
||||
use support::impl_outer_event;
|
||||
use frame_support::impl_outer_event;
|
||||
}
|
||||
|
||||
use pallet_balances as balances;
|
||||
|
||||
impl_outer_event! {
|
||||
pub enum MetaEvent for Test {
|
||||
balances<T>, contract<T>,
|
||||
}
|
||||
}
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test { }
|
||||
pub enum Origin for Test where system = frame_system { }
|
||||
}
|
||||
impl_outer_dispatch! {
|
||||
pub enum Call for Test where origin: Origin {
|
||||
@@ -98,7 +101,7 @@ parameter_types! {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -115,7 +118,7 @@ impl system::Trait for Test {
|
||||
type MaximumBlockLength = MaximumBlockLength;
|
||||
type Version = ();
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = Contract;
|
||||
type OnNewAccount = ();
|
||||
@@ -129,7 +132,7 @@ impl balances::Trait for Test {
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: u64 = 1;
|
||||
}
|
||||
impl timestamp::Trait for Test {
|
||||
impl pallet_timestamp::Trait for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
@@ -178,11 +181,11 @@ impl Trait for Test {
|
||||
type BlockGasLimit = BlockGasLimit;
|
||||
}
|
||||
|
||||
type Balances = balances::Module<Test>;
|
||||
type Timestamp = timestamp::Module<Test>;
|
||||
type Balances = pallet_balances::Module<Test>;
|
||||
type Timestamp = pallet_timestamp::Module<Test>;
|
||||
type Contract = Module<Test>;
|
||||
type System = system::Module<Test>;
|
||||
type Randomness = randomness_collective_flip::Module<Test>;
|
||||
type System = frame_system::Module<Test>;
|
||||
type Randomness = pallet_randomness_collective_flip::Module<Test>;
|
||||
|
||||
pub struct DummyContractAddressFor;
|
||||
impl ContractAddressFor<H256, u64> for DummyContractAddressFor {
|
||||
@@ -194,7 +197,7 @@ impl ContractAddressFor<H256, u64> for DummyContractAddressFor {
|
||||
pub struct DummyTrieIdGenerator;
|
||||
impl TrieIdGenerator<u64> for DummyTrieIdGenerator {
|
||||
fn trie_id(account_id: &u64) -> TrieId {
|
||||
use primitives::storage::well_known_keys;
|
||||
use sp_core::storage::well_known_keys;
|
||||
|
||||
let new_seed = super::AccountCounter::mutate(|v| {
|
||||
*v = v.wrapping_add(1);
|
||||
@@ -270,8 +273,8 @@ impl ExtBuilder {
|
||||
}
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
self.set_associated_consts();
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
balances::GenesisConfig::<Test> {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![],
|
||||
vesting: vec![],
|
||||
}.assimilate_storage(&mut t).unwrap();
|
||||
@@ -289,7 +292,7 @@ impl ExtBuilder {
|
||||
/// Generate Wasm binary and code hash from wabt source.
|
||||
fn compile_module<T>(wabt_module: &str)
|
||||
-> Result<(Vec<u8>, <T::Hashing as Hash>::Output), wabt::Error>
|
||||
where T: system::Trait
|
||||
where T: frame_system::Trait
|
||||
{
|
||||
let wasm = wabt::wat2wasm(wabt_module)?;
|
||||
let code_hash = T::Hashing::hash(&wasm);
|
||||
@@ -426,7 +429,7 @@ fn instantiate_and_call_and_deposit_event() {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
@@ -437,7 +440,7 @@ fn instantiate_and_call_and_deposit_event() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(
|
||||
balances::RawEvent::NewAccount(BOB, 100)
|
||||
pallet_balances::RawEvent::NewAccount(BOB, 100)
|
||||
),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -484,7 +487,7 @@ const CODE_DISPATCH_CALL: &str = r#"
|
||||
fn dispatch_call() {
|
||||
// This test can fail due to the encoding changes. In case it becomes too annoying
|
||||
// let's rewrite so as we use this module controlled call or we serialize it in runtime.
|
||||
let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50)));
|
||||
let encoded = Encode::encode(&Call::Balances(pallet_balances::Call::transfer(CHARLIE, 50)));
|
||||
assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]);
|
||||
|
||||
let (wasm, code_hash) = compile_module::<Test>(CODE_DISPATCH_CALL).unwrap();
|
||||
@@ -499,7 +502,7 @@ fn dispatch_call() {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
@@ -528,7 +531,7 @@ fn dispatch_call() {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
@@ -539,7 +542,7 @@ fn dispatch_call() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(
|
||||
balances::RawEvent::NewAccount(BOB, 100)
|
||||
pallet_balances::RawEvent::NewAccount(BOB, 100)
|
||||
),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -558,14 +561,14 @@ fn dispatch_call() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(
|
||||
balances::RawEvent::NewAccount(CHARLIE, 50)
|
||||
pallet_balances::RawEvent::NewAccount(CHARLIE, 50)
|
||||
),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(
|
||||
balances::RawEvent::Transfer(BOB, CHARLIE, 50, 0)
|
||||
pallet_balances::RawEvent::Transfer(BOB, CHARLIE, 50, 0)
|
||||
),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -602,7 +605,7 @@ const CODE_DISPATCH_CALL_THEN_TRAP: &str = r#"
|
||||
fn dispatch_call_not_dispatched_after_top_level_transaction_failure() {
|
||||
// This test can fail due to the encoding changes. In case it becomes too annoying
|
||||
// let's rewrite so as we use this module controlled call or we serialize it in runtime.
|
||||
let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50)));
|
||||
let encoded = Encode::encode(&Call::Balances(pallet_balances::Call::transfer(CHARLIE, 50)));
|
||||
assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]);
|
||||
|
||||
let (wasm, code_hash) = compile_module::<Test>(CODE_DISPATCH_CALL_THEN_TRAP).unwrap();
|
||||
@@ -617,7 +620,7 @@ fn dispatch_call_not_dispatched_after_top_level_transaction_failure() {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
@@ -650,7 +653,7 @@ fn dispatch_call_not_dispatched_after_top_level_transaction_failure() {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
@@ -661,7 +664,7 @@ fn dispatch_call_not_dispatched_after_top_level_transaction_failure() {
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(
|
||||
balances::RawEvent::NewAccount(BOB, 100)
|
||||
pallet_balances::RawEvent::NewAccount(BOB, 100)
|
||||
),
|
||||
topics: vec![],
|
||||
},
|
||||
@@ -802,7 +805,7 @@ mod call {
|
||||
fn test_set_rent_code_and_hash() {
|
||||
// This test can fail due to the encoding changes. In case it becomes too annoying
|
||||
// let's rewrite so as we use this module controlled call or we serialize it in runtime.
|
||||
let encoded = Encode::encode(&Call::Balances(balances::Call::transfer(CHARLIE, 50)));
|
||||
let encoded = Encode::encode(&Call::Balances(pallet_balances::Call::transfer(CHARLIE, 50)));
|
||||
assert_eq!(&encoded[..], &hex!("00000300000000000000C8")[..]);
|
||||
|
||||
let (wasm, code_hash) = compile_module::<Test>(CODE_SET_RENT).unwrap();
|
||||
@@ -816,7 +819,7 @@ fn test_set_rent_code_and_hash() {
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
@@ -841,7 +844,7 @@ fn storage_size() {
|
||||
Origin::signed(ALICE),
|
||||
30_000,
|
||||
100_000, code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
<Test as pallet_balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
));
|
||||
let bob_contract = ContractInfoOf::<Test>::get(BOB).unwrap().get_alive().unwrap();
|
||||
assert_eq!(bob_contract.storage_size, <Test as Trait>::StorageSizeOffset::get() + 4);
|
||||
@@ -868,7 +871,7 @@ fn deduct_blocks() {
|
||||
Origin::signed(ALICE),
|
||||
30_000,
|
||||
100_000, code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
<Test as pallet_balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
));
|
||||
|
||||
// Check creation
|
||||
@@ -962,7 +965,7 @@ fn claim_surcharge(blocks: u64, trigger_call: impl Fn() -> bool, removes: bool)
|
||||
Origin::signed(ALICE),
|
||||
100,
|
||||
100_000, code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
<Test as pallet_balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
));
|
||||
|
||||
// Advance blocks
|
||||
@@ -995,7 +998,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
Origin::signed(ALICE),
|
||||
100,
|
||||
100_000, code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
<Test as pallet_balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
));
|
||||
|
||||
let subsistence_threshold = 50 /*existential_deposit*/ + 16 /*tombstone_deposit*/;
|
||||
@@ -1031,7 +1034,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
Origin::signed(ALICE),
|
||||
1_000,
|
||||
100_000, code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(100u32).encode() // rent allowance
|
||||
<Test as pallet_balances::Trait>::Balance::from(100u32).encode() // rent allowance
|
||||
));
|
||||
|
||||
// Trigger rent must have no effect
|
||||
@@ -1066,7 +1069,7 @@ fn removals(trigger_call: impl Fn() -> bool) {
|
||||
Origin::signed(ALICE),
|
||||
50+Balances::minimum_balance(),
|
||||
100_000, code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
<Test as pallet_balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
));
|
||||
|
||||
// Trigger rent must have no effect
|
||||
@@ -1110,7 +1113,7 @@ fn call_removed_contract() {
|
||||
Origin::signed(ALICE),
|
||||
100,
|
||||
100_000, code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
<Test as pallet_balances::Trait>::Balance::from(1_000u32).encode() // rent allowance
|
||||
));
|
||||
|
||||
// Calling contract should succeed.
|
||||
@@ -1311,7 +1314,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
|
||||
assert_eq!(System::events(), vec![
|
||||
EventRecord {
|
||||
phase: Phase::ApplyExtrinsic(0),
|
||||
event: MetaEvent::balances(balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
event: MetaEvent::balances(pallet_balances::RawEvent::NewAccount(1, 1_000_000)),
|
||||
topics: vec![],
|
||||
},
|
||||
EventRecord {
|
||||
@@ -1333,7 +1336,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
|
||||
30_000,
|
||||
100_000,
|
||||
set_rent_code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(0u32).encode()
|
||||
<Test as pallet_balances::Trait>::Balance::from(0u32).encode()
|
||||
));
|
||||
|
||||
// Check if `BOB` was created successfully and that the rent allowance is
|
||||
@@ -1370,7 +1373,7 @@ fn restoration(test_different_storage: bool, test_restore_to_with_dirty_storage:
|
||||
30_000,
|
||||
100_000,
|
||||
restoration_code_hash.into(),
|
||||
<Test as balances::Trait>::Balance::from(0u32).encode()
|
||||
<Test as pallet_balances::Trait>::Balance::from(0u32).encode()
|
||||
));
|
||||
|
||||
// Before performing a call to `DJANGO` save its original trie id.
|
||||
@@ -2425,7 +2428,7 @@ fn get_runtime_storage() {
|
||||
ExtBuilder::default().existential_deposit(50).build().execute_with(|| {
|
||||
Balances::deposit_creating(&ALICE, 1_000_000);
|
||||
|
||||
support::storage::unhashed::put_raw(
|
||||
frame_support::storage::unhashed::put_raw(
|
||||
&[1, 2, 3, 4],
|
||||
0x14144020u32.to_le_bytes().to_vec().as_ref()
|
||||
);
|
||||
|
||||
@@ -31,7 +31,7 @@ use crate::wasm::{prepare, runtime::Env, PrefabWasmModule};
|
||||
use crate::{CodeHash, CodeStorage, PristineCode, Schedule, Trait};
|
||||
use sp_std::prelude::*;
|
||||
use sp_runtime::traits::{Hash, Bounded};
|
||||
use support::StorageMap;
|
||||
use frame_support::StorageMap;
|
||||
|
||||
/// Gas metering token that used for charging storing code into the code storage.
|
||||
///
|
||||
|
||||
@@ -96,7 +96,7 @@ macro_rules! unmarshall_then_body {
|
||||
#[inline(always)]
|
||||
pub fn constrain_closure<R, F>(f: F) -> F
|
||||
where
|
||||
F: FnOnce() -> Result<R, sandbox::HostError>,
|
||||
F: FnOnce() -> Result<R, sp_sandbox::HostError>,
|
||||
{
|
||||
f
|
||||
}
|
||||
@@ -110,14 +110,14 @@ macro_rules! unmarshall_then_body_then_marshall {
|
||||
unmarshall_then_body!($body, $ctx, $args_iter, $( $names : $params ),*)
|
||||
});
|
||||
let r = body()?;
|
||||
return Ok(sandbox::ReturnValue::Value({ use $crate::wasm::env_def::ConvertibleToWasm; r.to_typed_value() }))
|
||||
return Ok(sp_sandbox::ReturnValue::Value({ use $crate::wasm::env_def::ConvertibleToWasm; r.to_typed_value() }))
|
||||
});
|
||||
( $args_iter:ident, $ctx:ident, ( $( $names:ident : $params:ty ),* ) => $body:tt ) => ({
|
||||
let body = $crate::wasm::env_def::macros::constrain_closure::<(), _>(|| {
|
||||
unmarshall_then_body!($body, $ctx, $args_iter, $( $names : $params ),*)
|
||||
});
|
||||
body()?;
|
||||
return Ok(sandbox::ReturnValue::Unit)
|
||||
return Ok(sp_sandbox::ReturnValue::Unit)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -126,8 +126,8 @@ macro_rules! define_func {
|
||||
( < E: $ext_ty:tt > $name:ident ( $ctx: ident $(, $names:ident : $params:ty)*) $(-> $returns:ty)* => $body:tt ) => {
|
||||
fn $name< E: $ext_ty >(
|
||||
$ctx: &mut $crate::wasm::Runtime<E>,
|
||||
args: &[sandbox::TypedValue],
|
||||
) -> Result<sandbox::ReturnValue, sandbox::HostError> {
|
||||
args: &[sp_sandbox::TypedValue],
|
||||
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> {
|
||||
#[allow(unused)]
|
||||
let mut args = args.iter();
|
||||
|
||||
@@ -196,7 +196,7 @@ mod tests {
|
||||
use parity_wasm::elements::FunctionType;
|
||||
use parity_wasm::elements::ValueType;
|
||||
use sp_runtime::traits::Zero;
|
||||
use sandbox::{self, ReturnValue, TypedValue};
|
||||
use sp_sandbox::{self, ReturnValue, TypedValue};
|
||||
use crate::wasm::tests::MockExt;
|
||||
use crate::wasm::Runtime;
|
||||
use crate::exec::Ext;
|
||||
@@ -206,15 +206,15 @@ mod tests {
|
||||
fn macro_unmarshall_then_body_then_marshall_value_or_trap() {
|
||||
fn test_value(
|
||||
_ctx: &mut u32,
|
||||
args: &[sandbox::TypedValue],
|
||||
) -> Result<ReturnValue, sandbox::HostError> {
|
||||
args: &[sp_sandbox::TypedValue],
|
||||
) -> Result<ReturnValue, sp_sandbox::HostError> {
|
||||
let mut args = args.iter();
|
||||
unmarshall_then_body_then_marshall!(
|
||||
args,
|
||||
_ctx,
|
||||
(a: u32, b: u32) -> u32 => {
|
||||
if b == 0 {
|
||||
Err(sandbox::HostError)
|
||||
Err(sp_sandbox::HostError)
|
||||
} else {
|
||||
Ok(a / b)
|
||||
}
|
||||
@@ -234,8 +234,8 @@ mod tests {
|
||||
fn macro_unmarshall_then_body_then_marshall_unit() {
|
||||
fn test_unit(
|
||||
ctx: &mut u32,
|
||||
args: &[sandbox::TypedValue],
|
||||
) -> Result<ReturnValue, sandbox::HostError> {
|
||||
args: &[sp_sandbox::TypedValue],
|
||||
) -> Result<ReturnValue, sp_sandbox::HostError> {
|
||||
let mut args = args.iter();
|
||||
unmarshall_then_body_then_marshall!(
|
||||
args,
|
||||
@@ -260,11 +260,11 @@ mod tests {
|
||||
if !amount.is_zero() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(sandbox::HostError)
|
||||
Err(sp_sandbox::HostError)
|
||||
}
|
||||
});
|
||||
let _f: fn(&mut Runtime<MockExt>, &[sandbox::TypedValue])
|
||||
-> Result<sandbox::ReturnValue, sandbox::HostError> = ext_gas::<MockExt>;
|
||||
let _f: fn(&mut Runtime<MockExt>, &[sp_sandbox::TypedValue])
|
||||
-> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError> = ext_gas::<MockExt>;
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -312,7 +312,7 @@ mod tests {
|
||||
if !amount.is_zero() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(sandbox::HostError)
|
||||
Err(sp_sandbox::HostError)
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use super::Runtime;
|
||||
use crate::exec::Ext;
|
||||
|
||||
use sandbox::{self, TypedValue};
|
||||
use sp_sandbox::{self, TypedValue};
|
||||
use parity_wasm::elements::{FunctionType, ValueType};
|
||||
|
||||
#[macro_use]
|
||||
@@ -69,8 +69,8 @@ impl ConvertibleToWasm for u64 {
|
||||
pub(crate) type HostFunc<E> =
|
||||
fn(
|
||||
&mut Runtime<E>,
|
||||
&[sandbox::TypedValue]
|
||||
) -> Result<sandbox::ReturnValue, sandbox::HostError>;
|
||||
&[sp_sandbox::TypedValue]
|
||||
) -> Result<sp_sandbox::ReturnValue, sp_sandbox::HostError>;
|
||||
|
||||
pub(crate) trait FunctionImplProvider<E: Ext> {
|
||||
fn impls<F: FnMut(&[u8], HostFunc<E>)>(f: &mut F);
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::gas::GasMeter;
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use sandbox;
|
||||
use sp_sandbox;
|
||||
|
||||
#[macro_use]
|
||||
mod env_def;
|
||||
@@ -114,7 +114,7 @@ impl<'a, T: Trait> crate::exec::Vm<T> for WasmVm<'a> {
|
||||
gas_meter: &mut GasMeter<E::T>,
|
||||
) -> ExecResult {
|
||||
let memory =
|
||||
sandbox::Memory::new(exec.prefab_module.initial, Some(exec.prefab_module.maximum))
|
||||
sp_sandbox::Memory::new(exec.prefab_module.initial, Some(exec.prefab_module.maximum))
|
||||
.unwrap_or_else(|_| {
|
||||
// unlike `.expect`, explicit panic preserves the source location.
|
||||
// Needed as we can't use `RUST_BACKTRACE` in here.
|
||||
@@ -125,7 +125,7 @@ impl<'a, T: Trait> crate::exec::Vm<T> for WasmVm<'a> {
|
||||
)
|
||||
});
|
||||
|
||||
let mut imports = sandbox::EnvironmentDefinitionBuilder::new();
|
||||
let mut imports = sp_sandbox::EnvironmentDefinitionBuilder::new();
|
||||
imports.add_memory("env", "memory", memory.clone());
|
||||
runtime::Env::impls(&mut |name, func_ptr| {
|
||||
imports.add_host_func("env", name, func_ptr);
|
||||
@@ -141,7 +141,7 @@ impl<'a, T: Trait> crate::exec::Vm<T> for WasmVm<'a> {
|
||||
|
||||
// Instantiate the instance from the instrumented module code and invoke the contract
|
||||
// entrypoint.
|
||||
let result = sandbox::Instance::new(&exec.prefab_module.code, &imports, &mut runtime)
|
||||
let result = sp_sandbox::Instance::new(&exec.prefab_module.code, &imports, &mut runtime)
|
||||
.and_then(|mut instance| instance.invoke(exec.entrypoint_name, &[], &mut runtime));
|
||||
to_execution_result(runtime, result)
|
||||
}
|
||||
@@ -152,7 +152,7 @@ mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashMap;
|
||||
use std::cell::RefCell;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use crate::exec::{Ext, StorageKey, ExecError, ExecReturnValue, STATUS_SUCCESS};
|
||||
use crate::gas::{Gas, GasMeter};
|
||||
use crate::tests::{Test, Call};
|
||||
@@ -1111,7 +1111,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
&mock_ext.dispatches,
|
||||
&[DispatchEntry(
|
||||
Call::Balances(balances::Call::set_balance(42, 1337, 0)),
|
||||
Call::Balances(pallet_balances::Call::set_balance(42, 1337, 0)),
|
||||
)]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@ use crate::exec::{
|
||||
Ext, ExecResult, ExecError, ExecReturnValue, StorageKey, TopicOf, STATUS_SUCCESS,
|
||||
};
|
||||
use crate::gas::{Gas, GasMeter, Token, GasMeterResult, approx_gas_for_balance};
|
||||
use sandbox;
|
||||
use system;
|
||||
use sp_sandbox;
|
||||
use frame_system;
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::convert::TryInto;
|
||||
use sp_std::mem;
|
||||
@@ -48,7 +48,7 @@ pub(crate) struct Runtime<'a, E: Ext + 'a> {
|
||||
ext: &'a mut E,
|
||||
scratch_buf: Vec<u8>,
|
||||
schedule: &'a Schedule,
|
||||
memory: sandbox::Memory,
|
||||
memory: sp_sandbox::Memory,
|
||||
gas_meter: &'a mut GasMeter<E::T>,
|
||||
special_trap: Option<SpecialTrap>,
|
||||
}
|
||||
@@ -57,7 +57,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> {
|
||||
ext: &'a mut E,
|
||||
input_data: Vec<u8>,
|
||||
schedule: &'a Schedule,
|
||||
memory: sandbox::Memory,
|
||||
memory: sp_sandbox::Memory,
|
||||
gas_meter: &'a mut GasMeter<E::T>,
|
||||
) -> Self {
|
||||
Runtime {
|
||||
@@ -74,7 +74,7 @@ impl<'a, E: Ext + 'a> Runtime<'a, E> {
|
||||
|
||||
pub(crate) fn to_execution_result<E: Ext>(
|
||||
runtime: Runtime<E>,
|
||||
sandbox_result: Result<sandbox::ReturnValue, sandbox::Error>,
|
||||
sandbox_result: Result<sp_sandbox::ReturnValue, sp_sandbox::Error>,
|
||||
) -> ExecResult {
|
||||
// Special case. The trap was the result of the execution `return` host function.
|
||||
if let Some(SpecialTrap::Return(data)) = runtime.special_trap {
|
||||
@@ -84,12 +84,12 @@ pub(crate) fn to_execution_result<E: Ext>(
|
||||
// Check the exact type of the error.
|
||||
match sandbox_result {
|
||||
// No traps were generated. Proceed normally.
|
||||
Ok(sandbox::ReturnValue::Unit) => {
|
||||
Ok(sp_sandbox::ReturnValue::Unit) => {
|
||||
let mut buffer = runtime.scratch_buf;
|
||||
buffer.clear();
|
||||
Ok(ExecReturnValue { status: STATUS_SUCCESS, data: buffer })
|
||||
}
|
||||
Ok(sandbox::ReturnValue::Value(sandbox::TypedValue::I32(exit_code))) => {
|
||||
Ok(sp_sandbox::ReturnValue::Value(sp_sandbox::TypedValue::I32(exit_code))) => {
|
||||
let status = (exit_code & 0xFF).try_into()
|
||||
.expect("exit_code is masked into the range of a u8; qed");
|
||||
Ok(ExecReturnValue { status, data: runtime.scratch_buf })
|
||||
@@ -105,10 +105,10 @@ pub(crate) fn to_execution_result<E: Ext>(
|
||||
//
|
||||
// Because panics are really undesirable in the runtime code, we treat this as
|
||||
// a trap for now. Eventually, we might want to revisit this.
|
||||
Err(sandbox::Error::Module) =>
|
||||
Err(sp_sandbox::Error::Module) =>
|
||||
Err(ExecError { reason: "validation error", buffer: runtime.scratch_buf }),
|
||||
// Any other kind of a trap should result in a failure.
|
||||
Err(sandbox::Error::Execution) | Err(sandbox::Error::OutOfBounds) =>
|
||||
Err(sp_sandbox::Error::Execution) | Err(sp_sandbox::Error::OutOfBounds) =>
|
||||
Err(ExecError { reason: "during execution", buffer: runtime.scratch_buf }),
|
||||
}
|
||||
}
|
||||
@@ -182,10 +182,10 @@ fn charge_gas<T: Trait, Tok: Token<T>>(
|
||||
gas_meter: &mut GasMeter<T>,
|
||||
metadata: &Tok::Metadata,
|
||||
token: Tok,
|
||||
) -> Result<(), sandbox::HostError> {
|
||||
) -> Result<(), sp_sandbox::HostError> {
|
||||
match gas_meter.charge(metadata, token) {
|
||||
GasMeterResult::Proceed => Ok(()),
|
||||
GasMeterResult::OutOfGas => Err(sandbox::HostError),
|
||||
GasMeterResult::OutOfGas => Err(sp_sandbox::HostError),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,11 +201,11 @@ fn read_sandbox_memory<E: Ext>(
|
||||
ctx: &mut Runtime<E>,
|
||||
ptr: u32,
|
||||
len: u32,
|
||||
) -> Result<Vec<u8>, sandbox::HostError> {
|
||||
) -> Result<Vec<u8>, sp_sandbox::HostError> {
|
||||
charge_gas(ctx.gas_meter, ctx.schedule, RuntimeToken::ReadMemory(len))?;
|
||||
|
||||
let mut buf = vec![0u8; len as usize];
|
||||
ctx.memory.get(ptr, buf.as_mut_slice()).map_err(|_| sandbox::HostError)?;
|
||||
ctx.memory.get(ptr, buf.as_mut_slice()).map_err(|_| sp_sandbox::HostError)?;
|
||||
Ok(buf)
|
||||
}
|
||||
|
||||
@@ -221,11 +221,11 @@ fn read_sandbox_memory_into_scratch<E: Ext>(
|
||||
ctx: &mut Runtime<E>,
|
||||
ptr: u32,
|
||||
len: u32,
|
||||
) -> Result<(), sandbox::HostError> {
|
||||
) -> Result<(), sp_sandbox::HostError> {
|
||||
charge_gas(ctx.gas_meter, ctx.schedule, RuntimeToken::ReadMemory(len))?;
|
||||
|
||||
ctx.scratch_buf.resize(len as usize, 0);
|
||||
ctx.memory.get(ptr, ctx.scratch_buf.as_mut_slice()).map_err(|_| sandbox::HostError)?;
|
||||
ctx.memory.get(ptr, ctx.scratch_buf.as_mut_slice()).map_err(|_| sp_sandbox::HostError)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ fn read_sandbox_memory_into_buf<E: Ext>(
|
||||
ctx: &mut Runtime<E>,
|
||||
ptr: u32,
|
||||
buf: &mut [u8],
|
||||
) -> Result<(), sandbox::HostError> {
|
||||
) -> Result<(), sp_sandbox::HostError> {
|
||||
charge_gas(ctx.gas_meter, ctx.schedule, RuntimeToken::ReadMemory(buf.len() as u32))?;
|
||||
|
||||
ctx.memory.get(ptr, buf).map_err(Into::into)
|
||||
@@ -260,9 +260,9 @@ fn read_sandbox_memory_as<E: Ext, D: Decode>(
|
||||
ctx: &mut Runtime<E>,
|
||||
ptr: u32,
|
||||
len: u32,
|
||||
) -> Result<D, sandbox::HostError> {
|
||||
) -> Result<D, sp_sandbox::HostError> {
|
||||
let buf = read_sandbox_memory(ctx, ptr, len)?;
|
||||
D::decode(&mut &buf[..]).map_err(|_| sandbox::HostError)
|
||||
D::decode(&mut &buf[..]).map_err(|_| sp_sandbox::HostError)
|
||||
}
|
||||
|
||||
/// Write the given buffer to the designated location in the sandbox memory, consuming
|
||||
@@ -276,10 +276,10 @@ fn read_sandbox_memory_as<E: Ext, D: Decode>(
|
||||
fn write_sandbox_memory<T: Trait>(
|
||||
schedule: &Schedule,
|
||||
gas_meter: &mut GasMeter<T>,
|
||||
memory: &sandbox::Memory,
|
||||
memory: &sp_sandbox::Memory,
|
||||
ptr: u32,
|
||||
buf: &[u8],
|
||||
) -> Result<(), sandbox::HostError> {
|
||||
) -> Result<(), sp_sandbox::HostError> {
|
||||
charge_gas(gas_meter, schedule, RuntimeToken::WriteMemory(buf.len() as u32))?;
|
||||
|
||||
memory.set(ptr, buf)?;
|
||||
@@ -318,7 +318,7 @@ define_env!(Env, <E: Ext>,
|
||||
// - value_len: the length of the value. If `value_non_null` is set to 0, then this parameter is ignored.
|
||||
ext_set_storage(ctx, key_ptr: u32, value_non_null: u32, value_ptr: u32, value_len: u32) => {
|
||||
if value_non_null != 0 && ctx.ext.max_value_size() < value_len {
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
let mut key: StorageKey = [0; 32];
|
||||
read_sandbox_memory_into_buf(ctx, key_ptr, &mut key)?;
|
||||
@@ -328,7 +328,7 @@ define_env!(Env, <E: Ext>,
|
||||
} else {
|
||||
None
|
||||
};
|
||||
ctx.ext.set_storage(key, value).map_err(|_| sandbox::HostError)?;
|
||||
ctx.ext.set_storage(key, value).map_err(|_| sp_sandbox::HostError)?;
|
||||
|
||||
Ok(())
|
||||
},
|
||||
@@ -382,7 +382,7 @@ define_env!(Env, <E: Ext>,
|
||||
input_data_ptr: u32,
|
||||
input_data_len: u32
|
||||
) -> u32 => {
|
||||
let callee: <<E as Ext>::T as system::Trait>::AccountId =
|
||||
let callee: <<E as Ext>::T as frame_system::Trait>::AccountId =
|
||||
read_sandbox_memory_as(ctx, callee_ptr, callee_len)?;
|
||||
let value: BalanceOf<<E as Ext>::T> =
|
||||
read_sandbox_memory_as(ctx, value_ptr, value_len)?;
|
||||
@@ -532,7 +532,7 @@ define_env!(Env, <E: Ext>,
|
||||
// The trap mechanism is used to immediately terminate the execution.
|
||||
// This trap should be handled appropriately before returning the result
|
||||
// to the user of this crate.
|
||||
Err(sandbox::HostError)
|
||||
Err(sp_sandbox::HostError)
|
||||
},
|
||||
|
||||
// Stores the address of the caller into the scratch buffer.
|
||||
@@ -597,7 +597,7 @@ define_env!(Env, <E: Ext>,
|
||||
ext_random(ctx, subject_ptr: u32, subject_len: u32) => {
|
||||
// The length of a subject can't exceed `max_subject_len`.
|
||||
if subject_len > ctx.schedule.max_subject_len {
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
|
||||
let subject_buf = read_sandbox_memory(ctx, subject_ptr, subject_len)?;
|
||||
@@ -675,7 +675,7 @@ define_env!(Env, <E: Ext>,
|
||||
delta_ptr: u32,
|
||||
delta_count: u32
|
||||
) => {
|
||||
let dest: <<E as Ext>::T as system::Trait>::AccountId =
|
||||
let dest: <<E as Ext>::T as frame_system::Trait>::AccountId =
|
||||
read_sandbox_memory_as(ctx, dest_ptr, dest_len)?;
|
||||
let code_hash: CodeHash<<E as Ext>::T> =
|
||||
read_sandbox_memory_as(ctx, code_hash_ptr, code_hash_len)?;
|
||||
@@ -696,7 +696,7 @@ define_env!(Env, <E: Ext>,
|
||||
delta.push(delta_key);
|
||||
|
||||
// Offset key_ptr to the next element.
|
||||
key_ptr = key_ptr.checked_add(KEY_SIZE as u32).ok_or_else(|| sandbox::HostError)?;
|
||||
key_ptr = key_ptr.checked_add(KEY_SIZE as u32).ok_or_else(|| sp_sandbox::HostError)?;
|
||||
}
|
||||
|
||||
delta
|
||||
@@ -729,13 +729,13 @@ define_env!(Env, <E: Ext>,
|
||||
let offset = offset as usize;
|
||||
if offset > ctx.scratch_buf.len() {
|
||||
// Offset can't be larger than scratch buffer length.
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
|
||||
// This can't panic since `offset <= ctx.scratch_buf.len()`.
|
||||
let src = &ctx.scratch_buf[offset..];
|
||||
if src.len() != len as usize {
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
|
||||
// Finally, perform the write.
|
||||
@@ -775,12 +775,12 @@ define_env!(Env, <E: Ext>,
|
||||
|
||||
// If there are more than `max_event_topics`, then trap.
|
||||
if topics.len() > ctx.schedule.max_event_topics as usize {
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
|
||||
// Check for duplicate topics. If there are any, then trap.
|
||||
if has_duplicates(&mut topics) {
|
||||
return Err(sandbox::HostError);
|
||||
return Err(sp_sandbox::HostError);
|
||||
}
|
||||
|
||||
let event_data = read_sandbox_memory(ctx, data_ptr, data_len)?;
|
||||
|
||||
@@ -11,12 +11,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features =
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -26,7 +26,7 @@ std = [
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ use sp_runtime::{
|
||||
traits::{Zero, Bounded, CheckedMul, CheckedDiv, EnsureOrigin, Hash, Dispatchable, Saturating},
|
||||
};
|
||||
use codec::{Ref, Encode, Decode, Input, Output, Error};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, decl_event, ensure,
|
||||
dispatch,
|
||||
Parameter,
|
||||
@@ -35,7 +35,7 @@ use support::{
|
||||
OnFreeBalanceZero, OnUnbalanced
|
||||
}
|
||||
};
|
||||
use system::{ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
mod vote_threshold;
|
||||
pub use vote_threshold::{Approved, VoteThreshold};
|
||||
@@ -173,13 +173,13 @@ impl Decode for Vote {
|
||||
}
|
||||
}
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
|
||||
pub trait Trait: system::Trait + Sized {
|
||||
pub trait Trait: frame_system::Trait + Sized {
|
||||
type Proposal: Parameter + Dispatchable<Origin=Self::Origin>;
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// Currency type for this module.
|
||||
type Currency: ReservableCurrency<Self::AccountId>
|
||||
@@ -281,7 +281,7 @@ decl_storage! {
|
||||
pub LowestUnbaked get(fn lowest_unbaked) build(|_| 0 as ReferendumIndex): ReferendumIndex;
|
||||
/// Information concerning any given referendum.
|
||||
pub ReferendumInfoOf get(fn referendum_info):
|
||||
map ReferendumIndex => Option<(ReferendumInfo<T::BlockNumber, T::Hash>)>;
|
||||
map ReferendumIndex => Option<ReferendumInfo<T::BlockNumber, T::Hash>>;
|
||||
/// Queue of successful referenda to be dispatched. Stored ordered by block number.
|
||||
pub DispatchQueue get(fn dispatch_queue): Vec<(T::BlockNumber, T::Hash, ReferendumIndex)>;
|
||||
|
||||
@@ -323,9 +323,9 @@ decl_storage! {
|
||||
decl_event!(
|
||||
pub enum Event<T> where
|
||||
Balance = BalanceOf<T>,
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as system::Trait>::Hash,
|
||||
<T as system::Trait>::BlockNumber,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::Hash,
|
||||
<T as frame_system::Trait>::BlockNumber,
|
||||
{
|
||||
/// A motion has been proposed by a public account.
|
||||
Proposed(PropIndex, Balance),
|
||||
@@ -487,7 +487,7 @@ decl_module! {
|
||||
T::ExternalOrigin::ensure_origin(origin)?;
|
||||
ensure!(!<NextExternal<T>>::exists(), "proposal already made");
|
||||
if let Some((until, _)) = <Blacklist<T>>::get(proposal_hash) {
|
||||
ensure!(<system::Module<T>>::block_number() >= until, "proposal still blacklisted");
|
||||
ensure!(<frame_system::Module<T>>::block_number() >= until, "proposal still blacklisted");
|
||||
}
|
||||
<NextExternal<T>>::put((proposal_hash, VoteThreshold::SuperMajorityApprove));
|
||||
}
|
||||
@@ -538,7 +538,7 @@ decl_module! {
|
||||
ensure!(proposal_hash == e_proposal_hash, "invalid hash");
|
||||
|
||||
<NextExternal<T>>::kill();
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
// We don't consider it an error if `vote_period` is too low, like `emergency_propose`.
|
||||
let period = voting_period.max(T::EmergencyVotingPeriod::get());
|
||||
Self::inject_referendum(now + period, proposal_hash, threshold, delay);
|
||||
@@ -562,7 +562,7 @@ decl_module! {
|
||||
.err().ok_or("identity may not veto a proposal twice")?;
|
||||
|
||||
existing_vetoers.insert(insert_position, who.clone());
|
||||
let until = <system::Module<T>>::block_number() + T::CooloffPeriod::get();
|
||||
let until = <frame_system::Module<T>>::block_number() + T::CooloffPeriod::get();
|
||||
<Blacklist<T>>::insert(&proposal_hash, (until, existing_vetoers));
|
||||
|
||||
Self::deposit_event(RawEvent::Vetoed(who, proposal_hash, until));
|
||||
@@ -659,7 +659,7 @@ decl_module! {
|
||||
ensure!(<Delegations<T>>::exists(&who), "not delegated");
|
||||
let (_, conviction) = <Delegations<T>>::take(&who);
|
||||
// Indefinite lock is reduced to the maximum voting lock that could be possible.
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
let locked_until = now + T::EnactmentPeriod::get() * conviction.lock_periods().into();
|
||||
T::Currency::set_lock(
|
||||
DEMOCRACY_ID,
|
||||
@@ -691,7 +691,7 @@ decl_module! {
|
||||
.saturating_mul(T::PreimageByteDeposit::get());
|
||||
T::Currency::reserve(&who, deposit)?;
|
||||
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
<Preimages<T>>::insert(proposal_hash, (encoded_proposal, who.clone(), deposit, now));
|
||||
|
||||
Self::deposit_event(RawEvent::PreimageNoted(proposal_hash, who, deposit));
|
||||
@@ -707,7 +707,7 @@ decl_module! {
|
||||
let queue = <DispatchQueue<T>>::get();
|
||||
ensure!(queue.iter().any(|item| &item.1 == &proposal_hash), "not imminent");
|
||||
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
let free = <BalanceOf<T>>::zero();
|
||||
<Preimages<T>>::insert(proposal_hash, (encoded_proposal, who.clone(), free, now));
|
||||
|
||||
@@ -724,7 +724,7 @@ decl_module! {
|
||||
let who = ensure_signed(origin)?;
|
||||
|
||||
let (_, old, deposit, then) = <Preimages<T>>::get(&proposal_hash).ok_or("not found")?;
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
let (voting, enactment) = (T::VotingPeriod::get(), T::EnactmentPeriod::get());
|
||||
let additional = if who == old { Zero::zero() } else { enactment };
|
||||
ensure!(now >= then + voting + additional, "too early");
|
||||
@@ -863,7 +863,7 @@ impl<T: Trait> Module<T> {
|
||||
delay: T::BlockNumber
|
||||
) -> ReferendumIndex {
|
||||
<Module<T>>::inject_referendum(
|
||||
<system::Module<T>>::block_number() + T::VotingPeriod::get(),
|
||||
<frame_system::Module<T>>::block_number() + T::VotingPeriod::get(),
|
||||
proposal_hash,
|
||||
threshold,
|
||||
delay
|
||||
@@ -927,7 +927,7 @@ impl<T: Trait> Module<T> {
|
||||
let _ = T::Currency::unreserve(&who, amount);
|
||||
Self::deposit_event(RawEvent::PreimageUsed(proposal_hash, who, amount));
|
||||
|
||||
let ok = proposal.dispatch(system::RawOrigin::Root.into()).is_ok();
|
||||
let ok = proposal.dispatch(frame_system::RawOrigin::Root.into()).is_ok();
|
||||
Self::deposit_event(RawEvent::Executed(index, ok));
|
||||
|
||||
Ok(())
|
||||
@@ -1088,15 +1088,15 @@ impl<T: Trait> OnFreeBalanceZero<T::AccountId> for Module<T> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::cell::RefCell;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_dispatch, assert_noop, assert_ok, parameter_types,
|
||||
traits::Contains,
|
||||
weights::Weight,
|
||||
};
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{traits::{BlakeTwo256, IdentityLookup, Bounded}, testing::Header, Perbill};
|
||||
use balances::BalanceLock;
|
||||
use system::EnsureSignedBy;
|
||||
use pallet_balances::BalanceLock;
|
||||
use frame_system::EnsureSignedBy;
|
||||
|
||||
const AYE: Vote = Vote{ aye: true, conviction: Conviction::None };
|
||||
const NAY: Vote = Vote{ aye: false, conviction: Conviction::None };
|
||||
@@ -1104,12 +1104,12 @@ mod tests {
|
||||
const BIG_NAY: Vote = Vote{ aye: false, conviction: Conviction::Locked1x };
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
impl_outer_dispatch! {
|
||||
pub enum Call for Test where origin: Origin {
|
||||
balances::Balances,
|
||||
pallet_balances::Balances,
|
||||
democracy::Democracy,
|
||||
}
|
||||
}
|
||||
@@ -1123,7 +1123,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -1145,7 +1145,7 @@ mod tests {
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
@@ -1185,7 +1185,7 @@ mod tests {
|
||||
impl super::Trait for Test {
|
||||
type Proposal = Call;
|
||||
type Event = ();
|
||||
type Currency = balances::Module<Self>;
|
||||
type Currency = pallet_balances::Module<Self>;
|
||||
type EnactmentPeriod = EnactmentPeriod;
|
||||
type LaunchPeriod = LaunchPeriod;
|
||||
type VotingPeriod = VotingPeriod;
|
||||
@@ -1203,8 +1203,8 @@ mod tests {
|
||||
}
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
balances::GenesisConfig::<Test>{
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
pallet_balances::GenesisConfig::<Test>{
|
||||
balances: vec![(1, 10), (2, 20), (3, 30), (4, 40), (5, 50), (6, 60)],
|
||||
vesting: vec![],
|
||||
}.assimilate_storage(&mut t).unwrap();
|
||||
@@ -1212,8 +1212,8 @@ mod tests {
|
||||
sp_io::TestExternalities::new(t)
|
||||
}
|
||||
|
||||
type System = system::Module<Test>;
|
||||
type Balances = balances::Module<Test>;
|
||||
type System = frame_system::Module<Test>;
|
||||
type Balances = pallet_balances::Module<Test>;
|
||||
type Democracy = Module<Test>;
|
||||
|
||||
#[test]
|
||||
@@ -1226,7 +1226,7 @@ mod tests {
|
||||
}
|
||||
|
||||
fn set_balance_proposal(value: u64) -> Vec<u8> {
|
||||
Call::Balances(balances::Call::set_balance(42, value, 0)).encode()
|
||||
Call::Balances(pallet_balances::Call::set_balance(42, value, 0)).encode()
|
||||
}
|
||||
|
||||
fn set_balance_proposal_hash(value: u64) -> H256 {
|
||||
|
||||
@@ -7,16 +7,16 @@ edition = "2018"
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
sp-phragmen = { path = "../../primitives/phragmen", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
hex-literal = "0.2.1"
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
substrate-test-utils = { path = "../../test-utils" }
|
||||
serde = { version = "1.0.101" }
|
||||
|
||||
@@ -24,9 +24,9 @@ serde = { version = "1.0.101" }
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"phragmen/std",
|
||||
"system/std",
|
||||
"sp-phragmen/std",
|
||||
"frame-system/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
//!
|
||||
//! ### Module Information
|
||||
//!
|
||||
//! - [`election_phragmen::Trait`](./trait.Trait.html)
|
||||
//! - [`election_sp_phragmen::Trait`](./trait.Trait.html)
|
||||
//! - [`Call`](./enum.Call.html)
|
||||
//! - [`Module`](./struct.Module.html)
|
||||
|
||||
@@ -84,28 +84,28 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_runtime::{print, traits::{Zero, StaticLookup, Bounded, Convert}};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_storage, decl_event, ensure, decl_module, dispatch, weights::SimpleDispatchInfo,
|
||||
traits::{
|
||||
Currency, Get, LockableCurrency, LockIdentifier, ReservableCurrency, WithdrawReasons,
|
||||
ChangeMembers, OnUnbalanced, WithdrawReason
|
||||
}
|
||||
};
|
||||
use phragmen::ExtendedBalance;
|
||||
use system::{self, ensure_signed, ensure_root};
|
||||
use sp_phragmen::ExtendedBalance;
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
const MODULE_ID: LockIdentifier = *b"phrelect";
|
||||
|
||||
/// The maximum votes allowed per voter.
|
||||
pub const MAXIMUM_VOTE: usize = 16;
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The overarching event type.c
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// The currency that people are electing with.
|
||||
type Currency:
|
||||
@@ -418,7 +418,7 @@ decl_module! {
|
||||
decl_event!(
|
||||
pub enum Event<T> where
|
||||
Balance = BalanceOf<T>,
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
{
|
||||
/// A new term with new members. This indicates that enough candidates existed, not that
|
||||
/// enough have has been elected. The inner value must be examined for this purpose.
|
||||
@@ -602,7 +602,7 @@ impl<T: Trait> Module<T> {
|
||||
let voters_and_votes = <VotesOf<T>>::enumerate()
|
||||
.map(|(v, i)| (v, i))
|
||||
.collect::<Vec<(T::AccountId, Vec<T::AccountId>)>>();
|
||||
let maybe_phragmen_result = phragmen::elect::<_, _, _, T::CurrencyToVote>(
|
||||
let maybe_phragmen_result = sp_phragmen::elect::<_, _, _, T::CurrencyToVote>(
|
||||
num_to_elect,
|
||||
0,
|
||||
candidates,
|
||||
@@ -629,7 +629,7 @@ impl<T: Trait> Module<T> {
|
||||
.filter_map(|(m, a)| if a.is_zero() { None } else { Some(m) } )
|
||||
.collect::<Vec<T::AccountId>>();
|
||||
|
||||
let support_map = phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
|
||||
let support_map = sp_phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
|
||||
&new_set,
|
||||
&phragmen_result.assignments,
|
||||
Self::locked_stake_of,
|
||||
@@ -735,14 +735,15 @@ impl<T: Trait> Module<T> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::cell::RefCell;
|
||||
use support::{assert_ok, assert_noop, parameter_types, weights::Weight};
|
||||
use frame_support::{assert_ok, assert_noop, parameter_types, weights::Weight};
|
||||
use substrate_test_utils::assert_eq_uvec;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill, testing::Header, BuildStorage,
|
||||
traits::{BlakeTwo256, IdentityLookup, Block as BlockT},
|
||||
};
|
||||
use crate as elections;
|
||||
use frame_system as system;
|
||||
|
||||
parameter_types! {
|
||||
pub const BlockHashCount: u64 = 250;
|
||||
@@ -751,7 +752,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;
|
||||
@@ -775,7 +776,7 @@ mod tests {
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnNewAccount = ();
|
||||
type OnFreeBalanceZero = ();
|
||||
@@ -886,14 +887,14 @@ mod tests {
|
||||
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, u64, Call, ()>;
|
||||
|
||||
support::construct_runtime!(
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system::{Module, Call, Event},
|
||||
Balances: balances::{Module, Call, Event<T>, Config<T>},
|
||||
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>},
|
||||
Elections: elections::{Module, Call, Event<T>},
|
||||
}
|
||||
);
|
||||
@@ -934,7 +935,7 @@ mod tests {
|
||||
TERM_DURATION.with(|v| *v.borrow_mut() = self.term_duration);
|
||||
DESIRED_RUNNERS_UP.with(|v| *v.borrow_mut() = self.desired_runners_up);
|
||||
GenesisConfig {
|
||||
balances: Some(balances::GenesisConfig::<Test>{
|
||||
pallet_balances: Some(pallet_balances::GenesisConfig::<Test>{
|
||||
balances: vec![
|
||||
(1, 10 * self.balance_factor),
|
||||
(2, 20 * self.balance_factor),
|
||||
|
||||
@@ -8,27 +8,27 @@ edition = "2018"
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
safe-mix = { version = "1.0.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.2.1"
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"safe-mix/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"serde",
|
||||
"sp-io/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -29,7 +29,7 @@ use sp_runtime::{
|
||||
print,
|
||||
traits::{Zero, One, StaticLookup, Bounded, Saturating},
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
dispatch::Result, decl_storage, decl_event, ensure, decl_module,
|
||||
weights::SimpleDispatchInfo,
|
||||
traits::{
|
||||
@@ -38,7 +38,7 @@ use support::{
|
||||
}
|
||||
};
|
||||
use codec::{Encode, Decode};
|
||||
use system::{self, ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
mod mock;
|
||||
mod tests;
|
||||
@@ -134,9 +134,9 @@ pub const VOTER_SET_SIZE: usize = 64;
|
||||
/// NUmber of approvals grouped in one chunk.
|
||||
pub const APPROVAL_SET_SIZE: usize = 8;
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
|
||||
/// Index used to access chunks.
|
||||
type SetIndex = u32;
|
||||
@@ -147,8 +147,8 @@ type ApprovalFlag = u32;
|
||||
/// Number of approval flags that can fit into [`ApprovalFlag`] type.
|
||||
const APPROVAL_FLAG_LEN: usize = 32;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
pub trait Trait: frame_system::Trait {
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// The currency that people are electing with.
|
||||
type Currency:
|
||||
@@ -643,7 +643,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where <T as system::Trait>::AccountId {
|
||||
pub enum Event<T> where <T as frame_system::Trait>::AccountId {
|
||||
/// reaped voter, reaper
|
||||
VoterReaped(AccountId, AccountId),
|
||||
/// slashed reaper
|
||||
@@ -695,7 +695,7 @@ impl<T: Trait> Module<T> {
|
||||
// if there's a tally in progress, then next tally can begin immediately afterwards
|
||||
(tally_end, c.len() - leavers.len() + comers as usize, comers)
|
||||
} else {
|
||||
(<system::Module<T>>::block_number(), c.len(), 0)
|
||||
(<frame_system::Module<T>>::block_number(), c.len(), 0)
|
||||
};
|
||||
if count < desired_seats as usize {
|
||||
Some(next_possible)
|
||||
@@ -851,7 +851,7 @@ impl<T: Trait> Module<T> {
|
||||
fn start_tally() {
|
||||
let members = Self::members();
|
||||
let desired_seats = Self::desired_seats() as usize;
|
||||
let number = <system::Module<T>>::block_number();
|
||||
let number = <frame_system::Module<T>>::block_number();
|
||||
let expiring =
|
||||
members.iter().take_while(|i| i.1 <= number).map(|i| i.0.clone()).collect::<Vec<_>>();
|
||||
let retaining_seats = members.len() - expiring.len();
|
||||
@@ -879,7 +879,7 @@ impl<T: Trait> Module<T> {
|
||||
.ok_or("finalize can only be called after a tally is started.")?;
|
||||
let leaderboard: Vec<(BalanceOf<T>, T::AccountId)> = <Leaderboard<T>>::take()
|
||||
.unwrap_or_default();
|
||||
let new_expiry = <system::Module<T>>::block_number() + Self::term_duration();
|
||||
let new_expiry = <frame_system::Module<T>>::block_number() + Self::term_duration();
|
||||
|
||||
// return bond to winners.
|
||||
let candidacy_bond = T::CandidacyBond::get();
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
#![cfg(test)]
|
||||
|
||||
use std::cell::RefCell;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
StorageValue, StorageMap, parameter_types, assert_ok,
|
||||
traits::{Get, ChangeMembers, Currency},
|
||||
weights::Weight,
|
||||
};
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
Perbill, BuildStorage, testing::Header, traits::{BlakeTwo256, IdentityLookup, Block as BlockT},
|
||||
};
|
||||
@@ -37,7 +37,7 @@ parameter_types! {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -60,7 +60,7 @@ parameter_types! {
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnNewAccount = ();
|
||||
type OnFreeBalanceZero = ();
|
||||
@@ -145,14 +145,15 @@ impl elections::Trait for Test {
|
||||
pub type Block = sp_runtime::generic::Block<Header, UncheckedExtrinsic>;
|
||||
pub type UncheckedExtrinsic = sp_runtime::generic::UncheckedExtrinsic<u32, u64, Call, ()>;
|
||||
|
||||
support::construct_runtime!(
|
||||
use frame_system as system;
|
||||
frame_support::construct_runtime!(
|
||||
pub enum Test where
|
||||
Block = Block,
|
||||
NodeBlock = Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
System: system::{Module, Call, Event},
|
||||
Balances: balances::{Module, Call, Event<T>, Config<T>, Error},
|
||||
Balances: pallet_balances::{Module, Call, Event<T>, Config<T>, Error},
|
||||
Elections: elections::{Module, Call, Event<T>, Config<T>},
|
||||
}
|
||||
);
|
||||
@@ -210,7 +211,7 @@ impl ExtBuilder {
|
||||
PRESENT_SLASH_PER_VOTER.with(|v| *v.borrow_mut() = self.bad_presentation_punishment);
|
||||
DECAY_RATIO.with(|v| *v.borrow_mut() = self.decay_ratio);
|
||||
GenesisConfig {
|
||||
balances: Some(balances::GenesisConfig::<Test>{
|
||||
pallet_balances: Some(pallet_balances::GenesisConfig::<Test>{
|
||||
balances: vec![
|
||||
(1, 10 * self.balance_factor),
|
||||
(2, 20 * self.balance_factor),
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use crate::mock::*;
|
||||
use crate::*;
|
||||
|
||||
use support::{assert_ok, assert_err, assert_noop};
|
||||
use frame_support::{assert_ok, assert_err, assert_noop};
|
||||
|
||||
#[test]
|
||||
fn params_should_work() {
|
||||
|
||||
@@ -7,11 +7,11 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false }
|
||||
balances = { package = "pallet-balances", path = "../balances", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
pallet-timestamp = { path = "../timestamp", default-features = false }
|
||||
pallet-balances = { path = "../balances", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
@@ -25,16 +25,16 @@ default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"balances/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"pallet-balances/std",
|
||||
"sp-io/std",
|
||||
"sp-std/std",
|
||||
"sha3/std",
|
||||
"rlp/std",
|
||||
"primitive-types/std",
|
||||
"evm/std",
|
||||
"timestamp/std",
|
||||
"pallet-timestamp/std",
|
||||
]
|
||||
|
||||
@@ -3,9 +3,9 @@ use sp_std::vec::Vec;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Serialize, Deserialize};
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::{U256, H256, H160};
|
||||
use sp_core::{U256, H256, H160};
|
||||
use sp_runtime::traits::UniqueSaturatedInto;
|
||||
use support::storage::{StorageMap, StorageDoubleMap};
|
||||
use frame_support::storage::{StorageMap, StorageDoubleMap};
|
||||
use sha3::{Keccak256, Digest};
|
||||
use evm::Config;
|
||||
use evm::backend::{Backend as BackendT, ApplyBackend, Apply};
|
||||
@@ -69,12 +69,12 @@ impl<'vicinity, T: Trait> BackendT for Backend<'vicinity, T> {
|
||||
H256::default()
|
||||
} else {
|
||||
let number = T::BlockNumber::from(number.as_u32());
|
||||
H256::from_slice(system::Module::<T>::block_hash(number).as_ref())
|
||||
H256::from_slice(frame_system::Module::<T>::block_hash(number).as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
fn block_number(&self) -> U256 {
|
||||
let number: u128 = system::Module::<T>::block_number().unique_saturated_into();
|
||||
let number: u128 = frame_system::Module::<T>::block_number().unique_saturated_into();
|
||||
U256::from(number)
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ impl<'vicinity, T: Trait> BackendT for Backend<'vicinity, T> {
|
||||
}
|
||||
|
||||
fn block_timestamp(&self) -> U256 {
|
||||
let now: u128 = timestamp::Module::<T>::get().unique_saturated_into();
|
||||
let now: u128 = pallet_timestamp::Module::<T>::get().unique_saturated_into();
|
||||
U256::from(now)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,14 +24,14 @@ mod backend;
|
||||
pub use crate::backend::{Account, Log, Vicinity, Backend};
|
||||
|
||||
use sp_std::{vec::Vec, marker::PhantomData};
|
||||
use support::{dispatch, decl_module, decl_storage, decl_event};
|
||||
use support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee};
|
||||
use support::traits::{Currency, WithdrawReason, ExistenceRequirement};
|
||||
use system::ensure_signed;
|
||||
use frame_support::{dispatch, decl_module, decl_storage, decl_event};
|
||||
use frame_support::weights::{Weight, WeighData, ClassifyDispatch, DispatchClass, PaysFee};
|
||||
use frame_support::traits::{Currency, WithdrawReason, ExistenceRequirement};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
use sp_runtime::ModuleId;
|
||||
use support::weights::SimpleDispatchInfo;
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
use sp_runtime::traits::{UniqueSaturatedInto, AccountIdConversion, SaturatedConversion};
|
||||
use primitives::{U256, H256, H160};
|
||||
use sp_core::{U256, H256, H160};
|
||||
use evm::{ExitReason, ExitSucceed, ExitError};
|
||||
use evm::executor::StackExecutor;
|
||||
use evm::backend::ApplyBackend;
|
||||
@@ -39,7 +39,7 @@ use evm::backend::ApplyBackend;
|
||||
const MODULE_ID: ModuleId = ModuleId(*b"py/ethvm");
|
||||
|
||||
/// Type alias for currency balance.
|
||||
pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
pub type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
|
||||
/// Trait that outputs the current transaction gas price.
|
||||
pub trait FeeCalculator {
|
||||
@@ -116,7 +116,7 @@ impl<F: FeeCalculator> PaysFee for WeightForCallCreate<F> {
|
||||
}
|
||||
|
||||
/// EVM module trait
|
||||
pub trait Trait: system::Trait + timestamp::Trait {
|
||||
pub trait Trait: frame_system::Trait + pallet_timestamp::Trait {
|
||||
/// Calculator for current gas price.
|
||||
type FeeCalculator: FeeCalculator;
|
||||
/// Convert account ID to H160;
|
||||
@@ -124,7 +124,7 @@ pub trait Trait: system::Trait + timestamp::Trait {
|
||||
/// Currency type for deposit and withdraw.
|
||||
type Currency: Currency<Self::AccountId>;
|
||||
/// The overarching event type.
|
||||
type Event: From<Event> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
|
||||
/// Precompiles associated with this EVM engine.
|
||||
type Precompiles: Precompiles;
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
balances = { package = "pallet-balances", path = "../balances", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
pallet-balances = { path = "../balances", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -23,9 +23,9 @@ std = [
|
||||
"serde",
|
||||
"codec/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"balances/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"pallet-balances/std",
|
||||
"sp-io/std",
|
||||
"sp-std/std"
|
||||
]
|
||||
|
||||
@@ -254,11 +254,11 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use sp_std::marker::PhantomData;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
dispatch::Result, decl_module, decl_storage, decl_event,
|
||||
weights::{SimpleDispatchInfo, DispatchInfo, DispatchClass, ClassifyDispatch, WeighData, Weight, PaysFee},
|
||||
};
|
||||
use system::{ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::{
|
||||
traits::{SignedExtension, Bounded, SaturatedConversion},
|
||||
@@ -281,9 +281,9 @@ use sp_runtime::{
|
||||
// - The final weight of each dispatch is calculated as the argument of the call multiplied by the
|
||||
// parameter given to the `WeightForSetDummy`'s constructor.
|
||||
// - assigns a dispatch class `operational` if the argument of the call is more than 1000.
|
||||
struct WeightForSetDummy<T: balances::Trait>(BalanceOf<T>);
|
||||
struct WeightForSetDummy<T: pallet_balances::Trait>(BalanceOf<T>);
|
||||
|
||||
impl<T: balances::Trait> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T>
|
||||
impl<T: pallet_balances::Trait> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T>
|
||||
{
|
||||
fn weigh_data(&self, target: (&BalanceOf<T>,)) -> Weight {
|
||||
let multiplier = self.0;
|
||||
@@ -291,7 +291,7 @@ impl<T: balances::Trait> WeighData<(&BalanceOf<T>,)> for WeightForSetDummy<T>
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: balances::Trait> ClassifyDispatch<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
|
||||
impl<T: pallet_balances::Trait> ClassifyDispatch<(&BalanceOf<T>,)> for WeightForSetDummy<T> {
|
||||
fn classify_dispatch(&self, target: (&BalanceOf<T>,)) -> DispatchClass {
|
||||
if *target.0 > <BalanceOf<T>>::from(1000u32) {
|
||||
DispatchClass::Operational
|
||||
@@ -301,23 +301,23 @@ impl<T: balances::Trait> ClassifyDispatch<(&BalanceOf<T>,)> for WeightForSetDumm
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: balances::Trait> PaysFee for WeightForSetDummy<T> {
|
||||
impl<T: pallet_balances::Trait> PaysFee for WeightForSetDummy<T> {
|
||||
fn pays_fee(&self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// A type alias for the balance type from this module's point of view.
|
||||
type BalanceOf<T> = <T as balances::Trait>::Balance;
|
||||
type BalanceOf<T> = <T as pallet_balances::Trait>::Balance;
|
||||
|
||||
/// Our module's configuration trait. All our types and constants go in here. If the
|
||||
/// module is dependent on specific other modules, then their configuration traits
|
||||
/// should be added to our implied traits list.
|
||||
///
|
||||
/// `system::Trait` should always be included in our implied traits.
|
||||
pub trait Trait: balances::Trait {
|
||||
/// `frame_system::Trait` should always be included in our implied traits.
|
||||
pub trait Trait: pallet_balances::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
}
|
||||
|
||||
decl_storage! {
|
||||
@@ -342,8 +342,8 @@ decl_storage! {
|
||||
// e.g. pub Bar get(fn bar): map T::AccountId => Vec<(T::Balance, u64)>;
|
||||
//
|
||||
// For basic value items, you'll get a type which implements
|
||||
// `support::StorageValue`. For map items, you'll get a type which
|
||||
// implements `support::StorageMap`.
|
||||
// `frame_support::StorageValue`. For map items, you'll get a type which
|
||||
// implements `frame_support::StorageMap`.
|
||||
//
|
||||
// If they have a getter (`get(getter_name)`), then your module will come
|
||||
// equipped with `fn getter_name() -> Type` for basic value items or
|
||||
@@ -362,7 +362,7 @@ decl_event!(
|
||||
/// Events are a simple means of reporting specific conditions and
|
||||
/// circumstances that have happened that users, Dapps and/or chain explorers would find
|
||||
/// interesting and otherwise difficult to detect.
|
||||
pub enum Event<T> where B = <T as balances::Trait>::Balance {
|
||||
pub enum Event<T> where B = <T as pallet_balances::Trait>::Balance {
|
||||
// Just a normal `enum`, here's a dummy event to ensure it compiles.
|
||||
/// Dummy event, just here so there's a generic type that's used.
|
||||
Dummy(B),
|
||||
@@ -398,7 +398,7 @@ decl_event!(
|
||||
//
|
||||
// `fn foo(origin: T::Origin, bar: Bar, baz: Baz) { ... }`
|
||||
//
|
||||
// There are three entries in the `system::Origin` enum that correspond
|
||||
// There are three entries in the `frame_system::Origin` enum that correspond
|
||||
// to the above bullets: `::Signed(AccountId)`, `::Root` and `::None`. You should always match
|
||||
// against them as the first thing you do in your function. There are three convenience calls
|
||||
// in system that do the matching for you and return a convenient result: `ensure_signed`,
|
||||
@@ -605,7 +605,7 @@ impl<T: Trait + Send + Sync> sp_std::fmt::Debug for WatchDummy<T> {
|
||||
impl<T: Trait + Send + Sync> SignedExtension for WatchDummy<T> {
|
||||
type AccountId = T::AccountId;
|
||||
// Note that this could also be assigned to the top-level call enum. It is passed into the
|
||||
// balances module directly and since `Trait: balances::Trait`, you could also use `T::Call`.
|
||||
// balances module directly and since `Trait: pallet_balances::Trait`, you could also use `T::Call`.
|
||||
// In that case, you would have had access to all call variants and could match on variants from
|
||||
// other modules.
|
||||
type Call = Call<T>;
|
||||
@@ -645,8 +645,8 @@ impl<T: Trait + Send + Sync> SignedExtension for WatchDummy<T> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use support::{assert_ok, impl_outer_origin, parameter_types, weights::GetDispatchInfo};
|
||||
use primitives::H256;
|
||||
use frame_support::{assert_ok, impl_outer_origin, parameter_types, weights::GetDispatchInfo};
|
||||
use sp_core::H256;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||
use sp_runtime::{
|
||||
@@ -655,7 +655,7 @@ mod tests {
|
||||
};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
@@ -669,7 +669,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -691,7 +691,7 @@ mod tests {
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
@@ -710,9 +710,9 @@ mod tests {
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
balances::GenesisConfig::<Test>::default().assimilate_storage(&mut t).unwrap();
|
||||
pallet_balances::GenesisConfig::<Test>::default().assimilate_storage(&mut t).unwrap();
|
||||
GenesisConfig::<Test>{
|
||||
dummy: 42,
|
||||
// we configure the map with (key, value) pairs.
|
||||
|
||||
@@ -10,24 +10,24 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features =
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io ={ path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
hex-literal = "0.2.1"
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
pallet-indices = { path = "../indices" }
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
transaction-payment = { package = "pallet-transaction-payment", path = "../transaction-payment" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
pallet-transaction-payment = { path = "../transaction-payment" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"serde",
|
||||
"codec/std",
|
||||
"sp-runtime/std",
|
||||
"sp-io/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
//! # use frame_executive as executive;
|
||||
//! # pub struct UncheckedExtrinsic {};
|
||||
//! # pub struct Header {};
|
||||
//! # type Context = system::ChainContext<Runtime>;
|
||||
//! # type Context = frame_system::ChainContext<Runtime>;
|
||||
//! # pub type Block = generic::Block<Header, UncheckedExtrinsic>;
|
||||
//! # pub type Balances = u64;
|
||||
//! # pub type AllModules = u64;
|
||||
@@ -77,7 +77,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use sp_std::{prelude::*, marker::PhantomData};
|
||||
use support::weights::{GetDispatchInfo, WeighBlock, DispatchInfo};
|
||||
use frame_support::weights::{GetDispatchInfo, WeighBlock, DispatchInfo};
|
||||
use sp_runtime::{
|
||||
generic::Digest, ApplyExtrinsicResult,
|
||||
traits::{
|
||||
@@ -89,7 +89,7 @@ use sp_runtime::{
|
||||
#[allow(deprecated)]
|
||||
use sp_runtime::traits::ValidateUnsigned;
|
||||
use codec::{Codec, Encode};
|
||||
use system::{extrinsics_root, DigestOf};
|
||||
use frame_system::{extrinsics_root, DigestOf};
|
||||
|
||||
/// Trait that can be used to execute a block.
|
||||
pub trait ExecuteBlock<Block: BlockT> {
|
||||
@@ -107,7 +107,7 @@ pub struct Executive<System, Block, Context, UnsignedValidator, AllModules>(
|
||||
|
||||
#[allow(deprecated)] // Allow ValidateUnsigned, remove the attribute when the trait is removed.
|
||||
impl<
|
||||
System: system::Trait,
|
||||
System: frame_system::Trait,
|
||||
Block: traits::Block<Header=System::Header, Hash=System::Hash>,
|
||||
Context: Default,
|
||||
UnsignedValidator,
|
||||
@@ -133,7 +133,7 @@ where
|
||||
|
||||
#[allow(deprecated)] // Allow ValidateUnsigned, remove the attribute when the trait is removed.
|
||||
impl<
|
||||
System: system::Trait,
|
||||
System: frame_system::Trait,
|
||||
Block: traits::Block<Header=System::Header, Hash=System::Hash>,
|
||||
Context: Default,
|
||||
UnsignedValidator,
|
||||
@@ -165,12 +165,12 @@ where
|
||||
extrinsics_root: &System::Hash,
|
||||
digest: &Digest<System::Hash>,
|
||||
) {
|
||||
<system::Module<System>>::initialize(block_number, parent_hash, extrinsics_root, digest);
|
||||
<frame_system::Module<System>>::initialize(block_number, parent_hash, extrinsics_root, digest);
|
||||
<AllModules as OnInitialize<System::BlockNumber>>::on_initialize(*block_number);
|
||||
<system::Module<System>>::register_extra_weight_unchecked(
|
||||
<frame_system::Module<System>>::register_extra_weight_unchecked(
|
||||
<AllModules as WeighBlock<System::BlockNumber>>::on_initialize(*block_number)
|
||||
);
|
||||
<system::Module<System>>::register_extra_weight_unchecked(
|
||||
<frame_system::Module<System>>::register_extra_weight_unchecked(
|
||||
<AllModules as WeighBlock<System::BlockNumber>>::on_finalize(*block_number)
|
||||
);
|
||||
}
|
||||
@@ -182,7 +182,7 @@ where
|
||||
let n = header.number().clone();
|
||||
assert!(
|
||||
n > System::BlockNumber::zero()
|
||||
&& <system::Module<System>>::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(),
|
||||
&& <frame_system::Module<System>>::block_hash(n - System::BlockNumber::one()) == *header.parent_hash(),
|
||||
"Parent hash should be valid."
|
||||
);
|
||||
|
||||
@@ -213,19 +213,19 @@ where
|
||||
extrinsics.into_iter().for_each(Self::apply_extrinsic_no_note);
|
||||
|
||||
// post-extrinsics book-keeping
|
||||
<system::Module<System>>::note_finished_extrinsics();
|
||||
<frame_system::Module<System>>::note_finished_extrinsics();
|
||||
<AllModules as OnFinalize<System::BlockNumber>>::on_finalize(block_number);
|
||||
}
|
||||
|
||||
/// Finalize the block - it is up the caller to ensure that all header fields are valid
|
||||
/// except state-root.
|
||||
pub fn finalize_block() -> System::Header {
|
||||
<system::Module<System>>::note_finished_extrinsics();
|
||||
<AllModules as OnFinalize<System::BlockNumber>>::on_finalize(<system::Module<System>>::block_number());
|
||||
<frame_system::Module<System>>::note_finished_extrinsics();
|
||||
<AllModules as OnFinalize<System::BlockNumber>>::on_finalize(<frame_system::Module<System>>::block_number());
|
||||
|
||||
// set up extrinsics
|
||||
<system::Module<System>>::derive_extrinsics();
|
||||
<system::Module<System>>::finalize()
|
||||
<frame_system::Module<System>>::derive_extrinsics();
|
||||
<frame_system::Module<System>>::finalize()
|
||||
}
|
||||
|
||||
/// Apply extrinsic outside of the block execution function.
|
||||
@@ -261,7 +261,7 @@ where
|
||||
// executed to prevent it from leaking in storage since at this point, it will either
|
||||
// execute or panic (and revert storage changes).
|
||||
if let Some(encoded) = to_note {
|
||||
<system::Module<System>>::note_extrinsic(encoded);
|
||||
<frame_system::Module<System>>::note_extrinsic(encoded);
|
||||
}
|
||||
|
||||
// AUDIT: Under no circumstances may this function panic from here onwards.
|
||||
@@ -270,14 +270,14 @@ where
|
||||
let dispatch_info = xt.get_dispatch_info();
|
||||
let r = Applyable::apply::<UnsignedValidator>(xt, dispatch_info, encoded_len)?;
|
||||
|
||||
<system::Module<System>>::note_applied_extrinsic(&r, encoded_len as u32, dispatch_info);
|
||||
<frame_system::Module<System>>::note_applied_extrinsic(&r, encoded_len as u32, dispatch_info);
|
||||
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
fn final_checks(header: &System::Header) {
|
||||
// remove temporaries
|
||||
let new_header = <system::Module<System>>::finalize();
|
||||
let new_header = <frame_system::Module<System>>::finalize();
|
||||
|
||||
// check digest
|
||||
assert_eq!(
|
||||
@@ -319,40 +319,40 @@ where
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
generic::Era, Perbill, DispatchError, testing::{Digest, Header, Block},
|
||||
traits::{Bounded, Header as HeaderT, BlakeTwo256, IdentityLookup, ConvertInto},
|
||||
transaction_validity::{InvalidTransaction, UnknownTransaction, TransactionValidityError},
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
impl_outer_event, impl_outer_origin, parameter_types, impl_outer_dispatch,
|
||||
weights::Weight,
|
||||
traits::{Currency, LockIdentifier, LockableCurrency, WithdrawReasons, WithdrawReason},
|
||||
};
|
||||
use system::{Call as SystemCall, ChainContext};
|
||||
use balances::Call as BalancesCall;
|
||||
use frame_system::{self as system, Call as SystemCall, ChainContext};
|
||||
use pallet_balances::Call as BalancesCall;
|
||||
use hex_literal::hex;
|
||||
|
||||
mod custom {
|
||||
use support::weights::SimpleDispatchInfo;
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
|
||||
pub trait Trait: system::Trait {}
|
||||
pub trait Trait: frame_system::Trait {}
|
||||
|
||||
support::decl_module! {
|
||||
frame_support::decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(100)]
|
||||
fn some_function(origin) {
|
||||
// NOTE: does not make any different.
|
||||
let _ = system::ensure_signed(origin);
|
||||
let _ = frame_system::ensure_signed(origin);
|
||||
}
|
||||
#[weight = SimpleDispatchInfo::FixedOperational(200)]
|
||||
fn some_root_operation(origin) {
|
||||
let _ = system::ensure_root(origin);
|
||||
let _ = frame_system::ensure_root(origin);
|
||||
}
|
||||
#[weight = SimpleDispatchInfo::FreeNormal]
|
||||
fn some_unsigned_message(origin) {
|
||||
let _ = system::ensure_none(origin);
|
||||
let _ = frame_system::ensure_none(origin);
|
||||
}
|
||||
|
||||
// module hooks.
|
||||
@@ -369,10 +369,12 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
type System = system::Module<Runtime>;
|
||||
type Balances = balances::Module<Runtime>;
|
||||
type System = frame_system::Module<Runtime>;
|
||||
type Balances = pallet_balances::Module<Runtime>;
|
||||
type Custom = custom::Module<Runtime>;
|
||||
|
||||
use pallet_balances as balances;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Runtime { }
|
||||
}
|
||||
@@ -384,8 +386,8 @@ mod tests {
|
||||
}
|
||||
impl_outer_dispatch! {
|
||||
pub enum Call for Runtime where origin: Origin {
|
||||
system::System,
|
||||
balances::Balances,
|
||||
frame_system::System,
|
||||
pallet_balances::Balances,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,12 +399,12 @@ mod tests {
|
||||
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 Call = Call;
|
||||
type BlockNumber = u64;
|
||||
type Hash = primitives::H256;
|
||||
type Hash = sp_core::H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = u64;
|
||||
type Lookup = IdentityLookup<u64>;
|
||||
@@ -419,7 +421,7 @@ mod tests {
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
impl balances::Trait for Runtime {
|
||||
impl pallet_balances::Trait for Runtime {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
@@ -435,7 +437,7 @@ mod tests {
|
||||
pub const TransactionBaseFee: u64 = 10;
|
||||
pub const TransactionByteFee: u64 = 0;
|
||||
}
|
||||
impl transaction_payment::Trait for Runtime {
|
||||
impl pallet_transaction_payment::Trait for Runtime {
|
||||
type Currency = Balances;
|
||||
type OnTransactionPayment = ();
|
||||
type TransactionBaseFee = TransactionBaseFee;
|
||||
@@ -462,10 +464,10 @@ mod tests {
|
||||
}
|
||||
|
||||
type SignedExtra = (
|
||||
system::CheckEra<Runtime>,
|
||||
system::CheckNonce<Runtime>,
|
||||
system::CheckWeight<Runtime>,
|
||||
transaction_payment::ChargeTransactionPayment<Runtime>
|
||||
frame_system::CheckEra<Runtime>,
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>
|
||||
);
|
||||
type AllModules = (System, Balances, Custom);
|
||||
type TestXt = sp_runtime::testing::TestXt<Call, SignedExtra>;
|
||||
@@ -473,10 +475,10 @@ mod tests {
|
||||
|
||||
fn extra(nonce: u64, fee: u64) -> SignedExtra {
|
||||
(
|
||||
system::CheckEra::from(Era::Immortal),
|
||||
system::CheckNonce::from(nonce),
|
||||
system::CheckWeight::new(),
|
||||
transaction_payment::ChargeTransactionPayment::from(fee)
|
||||
frame_system::CheckEra::from(Era::Immortal),
|
||||
frame_system::CheckNonce::from(nonce),
|
||||
frame_system::CheckWeight::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::from(fee)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -486,8 +488,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn balance_transfer_dispatch_works() {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
balances::GenesisConfig::<Runtime> {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
pallet_balances::GenesisConfig::<Runtime> {
|
||||
balances: vec![(1, 211)],
|
||||
vesting: vec![],
|
||||
}.assimilate_storage(&mut t).unwrap();
|
||||
@@ -504,14 +506,14 @@ mod tests {
|
||||
));
|
||||
let r = Executive::apply_extrinsic(xt);
|
||||
assert!(r.is_ok());
|
||||
assert_eq!(<balances::Module<Runtime>>::total_balance(&1), 142 - 10 - weight);
|
||||
assert_eq!(<balances::Module<Runtime>>::total_balance(&2), 69);
|
||||
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 142 - 10 - weight);
|
||||
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&2), 69);
|
||||
});
|
||||
}
|
||||
|
||||
fn new_test_ext(balance_factor: u64) -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
balances::GenesisConfig::<Runtime> {
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
pallet_balances::GenesisConfig::<Runtime> {
|
||||
balances: vec![(1, 111 * balance_factor)],
|
||||
vesting: vec![],
|
||||
}.assimilate_storage(&mut t).unwrap();
|
||||
@@ -582,7 +584,7 @@ mod tests {
|
||||
Digest::default(),
|
||||
));
|
||||
assert!(Executive::apply_extrinsic(xt).is_err());
|
||||
assert_eq!(<system::Module<Runtime>>::extrinsic_index(), Some(0));
|
||||
assert_eq!(<frame_system::Module<Runtime>>::extrinsic_index(), Some(0));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -604,7 +606,7 @@ mod tests {
|
||||
Digest::default(),
|
||||
));
|
||||
// Initial block weight form the custom module.
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_weight(), 175);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_weight(), 175);
|
||||
|
||||
for nonce in 0..=num_to_exhaust_block {
|
||||
let xt = sp_runtime::testing::TestXt(
|
||||
@@ -614,10 +616,10 @@ mod tests {
|
||||
if nonce != num_to_exhaust_block {
|
||||
assert!(res.is_ok());
|
||||
assert_eq!(
|
||||
<system::Module<Runtime>>::all_extrinsics_weight(),
|
||||
<frame_system::Module<Runtime>>::all_extrinsics_weight(),
|
||||
encoded_len * (nonce + 1) + 175,
|
||||
);
|
||||
assert_eq!(<system::Module<Runtime>>::extrinsic_index(), Some(nonce as u32 + 1));
|
||||
assert_eq!(<frame_system::Module<Runtime>>::extrinsic_index(), Some(nonce as u32 + 1));
|
||||
} else {
|
||||
assert_eq!(res, Err(InvalidTransaction::ExhaustsResources.into()));
|
||||
}
|
||||
@@ -633,21 +635,21 @@ mod tests {
|
||||
let len = xt.clone().encode().len() as u32;
|
||||
let mut t = new_test_ext(1);
|
||||
t.execute_with(|| {
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
|
||||
assert!(Executive::apply_extrinsic(xt.clone()).unwrap().is_ok());
|
||||
assert!(Executive::apply_extrinsic(x1.clone()).unwrap().is_ok());
|
||||
assert!(Executive::apply_extrinsic(x2.clone()).unwrap().is_ok());
|
||||
|
||||
// default weight for `TestXt` == encoded length.
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_weight(), (3 * len) as Weight);
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_len(), 3 * len);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_weight(), (3 * len) as Weight);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_len(), 3 * len);
|
||||
|
||||
let _ = <system::Module<Runtime>>::finalize();
|
||||
let _ = <frame_system::Module<Runtime>>::finalize();
|
||||
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_weight(), 0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -675,7 +677,7 @@ mod tests {
|
||||
let execute_with_lock = |lock: WithdrawReasons| {
|
||||
let mut t = new_test_ext(1);
|
||||
t.execute_with(|| {
|
||||
<balances::Module<Runtime> as LockableCurrency<u64>>::set_lock(
|
||||
<pallet_balances::Module<Runtime> as LockableCurrency<u64>>::set_lock(
|
||||
id,
|
||||
&1,
|
||||
110,
|
||||
@@ -698,13 +700,13 @@ mod tests {
|
||||
if lock == WithdrawReasons::except(WithdrawReason::TransactionPayment) {
|
||||
assert!(Executive::apply_extrinsic(xt).unwrap().is_ok());
|
||||
// tx fee has been deducted.
|
||||
assert_eq!(<balances::Module<Runtime>>::total_balance(&1), 111 - 10 - weight);
|
||||
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 111 - 10 - weight);
|
||||
} else {
|
||||
assert_eq!(
|
||||
Executive::apply_extrinsic(xt),
|
||||
Err(InvalidTransaction::Payment.into()),
|
||||
);
|
||||
assert_eq!(<balances::Module<Runtime>>::total_balance(&1), 111);
|
||||
assert_eq!(<pallet_balances::Module<Runtime>>::total_balance(&1), 111);
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -720,7 +722,7 @@ mod tests {
|
||||
Executive::initialize_block(&Header::new_from_number(1));
|
||||
// NOTE: might need updates over time if system and balance introduce new weights. For
|
||||
// now only accounts for the custom module.
|
||||
assert_eq!(<system::Module<Runtime>>::all_extrinsics_weight(), 150 + 25);
|
||||
assert_eq!(<frame_system::Module<Runtime>>::all_extrinsics_weight(), 150 + 25);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,16 +7,16 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
|
||||
sp-inherents = { path = "../../primitives/inherents", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-finality-tracker = { path = "../../primitives/finality-tracker", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
impl-trait-for-tuples = "0.1.3"
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
|
||||
[features]
|
||||
@@ -25,9 +25,9 @@ std = [
|
||||
"serde/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"frame-system/std",
|
||||
"sp-finality-tracker/std",
|
||||
"inherents/std",
|
||||
"sp-inherents/std",
|
||||
]
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError};
|
||||
use sp_inherents::{InherentIdentifier, ProvideInherent, InherentData, MakeFatalError};
|
||||
use sp_runtime::traits::{One, Zero, SaturatedConversion};
|
||||
use sp_std::{prelude::*, result, cmp, vec};
|
||||
use support::{decl_module, decl_storage};
|
||||
use support::traits::Get;
|
||||
use frame_support::{decl_module, decl_storage};
|
||||
use frame_support::traits::Get;
|
||||
use frame_system::{ensure_none, Trait as SystemTrait};
|
||||
use sp_finality_tracker::{INHERENT_IDENTIFIER, FinalizedInherentData};
|
||||
|
||||
@@ -194,12 +194,12 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use sp_io::TestExternalities;
|
||||
use primitives::H256;
|
||||
use sp_core::H256;
|
||||
use sp_runtime::{
|
||||
testing::Header, Perbill,
|
||||
traits::{BlakeTwo256, IdentityLookup, OnFinalize, Header as HeaderT},
|
||||
};
|
||||
use support::{assert_ok, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use frame_support::{assert_ok, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use frame_system as system;
|
||||
use std::cell::RefCell;
|
||||
|
||||
@@ -213,7 +213,7 @@ mod tests {
|
||||
pub struct Test;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
|
||||
@@ -9,12 +9,12 @@ serde = { version = "1.0.101", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-io ={ path = "../../primitives/io" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -23,6 +23,6 @@ std =[
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -114,14 +114,14 @@
|
||||
//! The Fees module uses the `Currency` trait to handle fee charge/refund, and its types inherit from `Currency`:
|
||||
//!
|
||||
//! ```
|
||||
//! use support::{
|
||||
//! use frame_support::{
|
||||
//! dispatch,
|
||||
//! traits::{Currency, ExistenceRequirement, WithdrawReason},
|
||||
//! };
|
||||
//! # pub trait Trait: system::Trait {
|
||||
//! # pub trait Trait: frame_system::Trait {
|
||||
//! # type Currency: Currency<Self::AccountId>;
|
||||
//! # }
|
||||
//! type AssetOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
//! type AssetOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
//!
|
||||
//! fn charge_fee<T: Trait>(transactor: &T::AccountId, amount: AssetOf<T>) -> dispatch::Result {
|
||||
//! // ...
|
||||
@@ -161,7 +161,7 @@ use sp_runtime::traits::{
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::{cmp, result, fmt::Debug};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_event, decl_module, decl_storage, ensure, dispatch,
|
||||
traits::{
|
||||
Currency, ExistenceRequirement, Imbalance, LockIdentifier, LockableCurrency, ReservableCurrency,
|
||||
@@ -169,14 +169,14 @@ use support::{
|
||||
},
|
||||
Parameter, StorageMap,
|
||||
};
|
||||
use system::{ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
mod mock;
|
||||
mod tests;
|
||||
|
||||
pub use self::imbalances::{NegativeImbalance, PositiveImbalance};
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
type Balance: Parameter
|
||||
+ Member
|
||||
+ SimpleArithmetic
|
||||
@@ -185,10 +185,10 @@ pub trait Trait: system::Trait {
|
||||
+ MaybeSerializeDeserialize
|
||||
+ Debug;
|
||||
type AssetId: Parameter + Member + SimpleArithmetic + Default + Copy;
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
}
|
||||
|
||||
pub trait Subtrait: system::Trait {
|
||||
pub trait Subtrait: frame_system::Trait {
|
||||
type Balance: Parameter
|
||||
+ Member
|
||||
+ SimpleArithmetic
|
||||
@@ -495,10 +495,10 @@ decl_storage! {
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as Trait>::Balance,
|
||||
<T as Trait>::AssetId,
|
||||
AssetOptions = AssetOptions<<T as Trait>::Balance, <T as system::Trait>::AccountId>
|
||||
AssetOptions = AssetOptions<<T as Trait>::Balance, <T as frame_system::Trait>::AccountId>
|
||||
{
|
||||
/// Asset created (asset_id, creator, asset_options).
|
||||
Created(AssetId, AccountId, AssetOptions),
|
||||
@@ -760,7 +760,7 @@ impl<T: Trait> Module<T> {
|
||||
if locks.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
if Self::locks(who)
|
||||
.into_iter()
|
||||
.all(|l| now >= l.until || new_balance >= l.amount || !l.reasons.intersects(reasons))
|
||||
@@ -792,7 +792,7 @@ impl<T: Trait> Module<T> {
|
||||
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,
|
||||
@@ -824,7 +824,7 @@ impl<T: Trait> Module<T> {
|
||||
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,
|
||||
@@ -855,7 +855,7 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
fn remove_lock(id: LockIdentifier, who: &T::AccountId) {
|
||||
let now = <system::Module<T>>::block_number();
|
||||
let now = <frame_system::Module<T>>::block_number();
|
||||
let locks = <Module<T>>::locks(who)
|
||||
.into_iter()
|
||||
.filter_map(|l| if l.until > now && l.id != id { Some(l) } else { None })
|
||||
@@ -1076,7 +1076,7 @@ impl<T: Subtrait> PartialEq for ElevatedTrait<T> {
|
||||
}
|
||||
}
|
||||
impl<T: Subtrait> Eq for ElevatedTrait<T> {}
|
||||
impl<T: Subtrait> system::Trait for ElevatedTrait<T> {
|
||||
impl<T: Subtrait> frame_system::Trait for ElevatedTrait<T> {
|
||||
type Origin = T::Origin;
|
||||
type Call = T::Call;
|
||||
type Index = T::Index;
|
||||
|
||||
@@ -25,13 +25,13 @@ use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
};
|
||||
use primitives::H256;
|
||||
use support::{parameter_types, impl_outer_event, impl_outer_origin, weights::Weight};
|
||||
use sp_core::H256;
|
||||
use frame_support::{parameter_types, impl_outer_event, impl_outer_origin, weights::Weight};
|
||||
|
||||
use super::*;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
@@ -45,7 +45,7 @@ parameter_types! {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -73,6 +73,7 @@ mod generic_asset {
|
||||
pub use crate::Event;
|
||||
}
|
||||
|
||||
use frame_system as system;
|
||||
impl_outer_event! {
|
||||
pub enum TestEvent for Test {
|
||||
generic_asset<T>,
|
||||
@@ -81,7 +82,7 @@ impl_outer_event! {
|
||||
|
||||
pub type GenericAsset = Module<Test>;
|
||||
|
||||
pub type System = system::Module<Test>;
|
||||
pub type System = frame_system::Module<Test>;
|
||||
|
||||
pub struct ExtBuilder {
|
||||
asset_id: u32,
|
||||
@@ -118,7 +119,7 @@ impl ExtBuilder {
|
||||
|
||||
// builds genesis config
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
|
||||
GenesisConfig::<Test> {
|
||||
assets: vec![self.asset_id],
|
||||
@@ -137,7 +138,7 @@ impl ExtBuilder {
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
system::GenesisConfig::default()
|
||||
frame_system::GenesisConfig::default()
|
||||
.build_storage::<Test>()
|
||||
.unwrap()
|
||||
.into()
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
use super::*;
|
||||
use crate::mock::{new_test_ext, ExtBuilder, GenericAsset, Origin, System, Test, TestEvent};
|
||||
use support::{assert_noop, assert_ok};
|
||||
use frame_support::{assert_noop, assert_ok};
|
||||
|
||||
#[test]
|
||||
fn issuing_asset_units_to_issuer_should_work() {
|
||||
@@ -906,7 +906,7 @@ fn update_permission_should_throw_error_when_lack_of_permissions() {
|
||||
fn create_asset_works_with_given_asset_id_and_from_account() {
|
||||
ExtBuilder::default().next_asset_id(10).build().execute_with(|| {
|
||||
let origin = 1;
|
||||
let from_account: Option<<Test as system::Trait>::AccountId> = Some(1);
|
||||
let from_account: Option<<Test as frame_system::Trait>::AccountId> = Some(1);
|
||||
|
||||
let default_permission = PermissionLatest {
|
||||
update: Owner::Address(origin),
|
||||
@@ -943,7 +943,7 @@ fn create_asset_works_with_given_asset_id_and_from_account() {
|
||||
fn create_asset_with_non_reserved_asset_id_should_not_work() {
|
||||
ExtBuilder::default().next_asset_id(10).build().execute_with(|| {
|
||||
let origin = 1;
|
||||
let from_account: Option<<Test as system::Trait>::AccountId> = Some(1);
|
||||
let from_account: Option<<Test as frame_system::Trait>::AccountId> = Some(1);
|
||||
|
||||
let default_permission = PermissionLatest {
|
||||
update: Owner::Address(origin),
|
||||
@@ -977,7 +977,7 @@ fn create_asset_with_non_reserved_asset_id_should_not_work() {
|
||||
fn create_asset_with_a_taken_asset_id_should_not_work() {
|
||||
ExtBuilder::default().next_asset_id(10).build().execute_with(|| {
|
||||
let origin = 1;
|
||||
let from_account: Option<<Test as system::Trait>::AccountId> = Some(1);
|
||||
let from_account: Option<<Test as frame_system::Trait>::AccountId> = Some(1);
|
||||
|
||||
let default_permission = PermissionLatest {
|
||||
update: Owner::Address(origin),
|
||||
@@ -1022,7 +1022,7 @@ fn create_asset_with_a_taken_asset_id_should_not_work() {
|
||||
fn create_asset_should_create_a_reserved_asset_when_from_account_is_none() {
|
||||
ExtBuilder::default().next_asset_id(10).build().execute_with(|| {
|
||||
let origin = 1;
|
||||
let from_account: Option<<Test as system::Trait>::AccountId> = None;
|
||||
let from_account: Option<<Test as frame_system::Trait>::AccountId> = None;
|
||||
|
||||
let default_permission = PermissionLatest {
|
||||
update: Owner::Address(origin),
|
||||
@@ -1065,7 +1065,7 @@ fn create_asset_should_create_a_reserved_asset_when_from_account_is_none() {
|
||||
fn create_asset_should_create_a_user_asset() {
|
||||
ExtBuilder::default().next_asset_id(10).build().execute_with(|| {
|
||||
let origin = 1;
|
||||
let from_account: Option<<Test as system::Trait>::AccountId> = None;
|
||||
let from_account: Option<<Test as frame_system::Trait>::AccountId> = None;
|
||||
|
||||
let default_permission = PermissionLatest {
|
||||
update: Owner::Address(origin),
|
||||
|
||||
@@ -7,15 +7,15 @@ edition = "2018"
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-finality-grandpa = { path = "../../primitives/finality-grandpa", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
session = { package = "pallet-session", path = "../session", default-features = false }
|
||||
finality-tracker = { package = "pallet-finality-tracker", path = "../finality-tracker", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
pallet-session = { path = "../session", default-features = false }
|
||||
pallet-finality-tracker = { path = "../finality-tracker", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-io ={ path = "../../primitives/io" }
|
||||
@@ -25,14 +25,14 @@ default = ["std"]
|
||||
std = [
|
||||
"serde",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-finality-grandpa/std",
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"system/std",
|
||||
"session/std",
|
||||
"finality-tracker/std",
|
||||
"frame-system/std",
|
||||
"pallet-session/std",
|
||||
"pallet-finality-tracker/std",
|
||||
]
|
||||
migrate-authorities = []
|
||||
|
||||
@@ -32,7 +32,7 @@ pub use sp_finality_grandpa as fg_primitives;
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use codec::{self as codec, Encode, Decode, Error};
|
||||
use support::{decl_event, decl_storage, decl_module, dispatch, storage};
|
||||
use frame_support::{decl_event, decl_storage, decl_module, dispatch, storage};
|
||||
use sp_runtime::{
|
||||
generic::{DigestItem, OpaqueDigestItemId}, traits::Zero, Perbill,
|
||||
};
|
||||
@@ -44,14 +44,14 @@ use fg_primitives::{
|
||||
GRANDPA_AUTHORITIES_KEY, GRANDPA_ENGINE_ID, ScheduledChange, ConsensusLog, SetId, RoundNumber,
|
||||
};
|
||||
pub use fg_primitives::{AuthorityId, AuthorityList, AuthorityWeight, VersionedAuthorityList};
|
||||
use system::{ensure_signed, DigestOf};
|
||||
use frame_system::{self as system, ensure_signed, DigestOf};
|
||||
|
||||
mod mock;
|
||||
mod tests;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The event type of this module.
|
||||
type Event: From<Event> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
|
||||
}
|
||||
|
||||
/// A stored pending change, old format.
|
||||
@@ -266,7 +266,7 @@ impl<T: Trait> Module<T> {
|
||||
/// Cannot be done when already paused.
|
||||
pub fn schedule_pause(in_blocks: T::BlockNumber) -> dispatch::Result {
|
||||
if let StoredState::Live = <State<T>>::get() {
|
||||
let scheduled_at = <system::Module<T>>::block_number();
|
||||
let scheduled_at = <frame_system::Module<T>>::block_number();
|
||||
<State<T>>::put(StoredState::PendingPause {
|
||||
delay: in_blocks,
|
||||
scheduled_at,
|
||||
@@ -282,7 +282,7 @@ impl<T: Trait> Module<T> {
|
||||
/// Schedule a resume of GRANDPA after pausing.
|
||||
pub fn schedule_resume(in_blocks: T::BlockNumber) -> dispatch::Result {
|
||||
if let StoredState::Paused = <State<T>>::get() {
|
||||
let scheduled_at = <system::Module<T>>::block_number();
|
||||
let scheduled_at = <frame_system::Module<T>>::block_number();
|
||||
<State<T>>::put(StoredState::PendingResume {
|
||||
delay: in_blocks,
|
||||
scheduled_at,
|
||||
@@ -315,7 +315,7 @@ impl<T: Trait> Module<T> {
|
||||
forced: Option<T::BlockNumber>,
|
||||
) -> dispatch::Result {
|
||||
if !<PendingChange<T>>::exists() {
|
||||
let scheduled_at = <system::Module<T>>::block_number();
|
||||
let scheduled_at = <frame_system::Module<T>>::block_number();
|
||||
|
||||
if let Some(_) = forced {
|
||||
if Self::next_forced().map_or(false, |next| next > scheduled_at) {
|
||||
@@ -343,7 +343,7 @@ impl<T: Trait> Module<T> {
|
||||
/// Deposit one of this module's logs.
|
||||
fn deposit_log(log: ConsensusLog<T::BlockNumber>) {
|
||||
let log: DigestItem<T::Hash> = DigestItem::Consensus(GRANDPA_ENGINE_ID, log.encode());
|
||||
<system::Module<T>>::deposit_log(log.into());
|
||||
<frame_system::Module<T>>::deposit_log(log.into());
|
||||
}
|
||||
|
||||
fn initialize_authorities(authorities: &AuthorityList) {
|
||||
@@ -404,8 +404,8 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
|
||||
type Public = AuthorityId;
|
||||
}
|
||||
|
||||
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T>
|
||||
where T: session::Trait
|
||||
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T>
|
||||
where T: pallet_session::Trait
|
||||
{
|
||||
type Key = AuthorityId;
|
||||
|
||||
@@ -438,7 +438,7 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T>
|
||||
|
||||
// if we didn't issue a change, we update the mapping to note that the current
|
||||
// set corresponds to the latest equivalent session (i.e. now).
|
||||
let session_index = <session::Module<T>>::current_index();
|
||||
let session_index = <pallet_session::Module<T>>::current_index();
|
||||
SetIdSession::insert(current_set_id, &session_index);
|
||||
}
|
||||
|
||||
@@ -447,9 +447,9 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T>
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> finality_tracker::OnFinalizationStalled<T::BlockNumber> for Module<T> {
|
||||
impl<T: Trait> pallet_finality_tracker::OnFinalizationStalled<T::BlockNumber> for Module<T> {
|
||||
fn on_stalled(further_wait: T::BlockNumber, median: T::BlockNumber) {
|
||||
// when we record old authority sets, we can use `finality_tracker::median`
|
||||
// when we record old authority sets, we can use `pallet_finality_tracker::median`
|
||||
// to figure out _who_ failed. until then, we can't meaningfully guard
|
||||
// against `next == last` the way that normal session changes do.
|
||||
<Stalled<T>>::put((further_wait, median));
|
||||
|
||||
@@ -20,14 +20,15 @@
|
||||
|
||||
use sp_runtime::{Perbill, DigestItem, traits::IdentityLookup, testing::{Header, UintAuthorityId}};
|
||||
use sp_io;
|
||||
use support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight};
|
||||
use primitives::H256;
|
||||
use frame_support::{impl_outer_origin, impl_outer_event, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
use codec::{Encode, Decode};
|
||||
use crate::{AuthorityId, AuthorityList, GenesisConfig, Trait, Module, ConsensusLog};
|
||||
use sp_finality_grandpa::GRANDPA_ENGINE_ID;
|
||||
|
||||
use frame_system as system;
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
pub fn grandpa_log(log: ConsensusLog<u64>) -> DigestItem<H256> {
|
||||
@@ -47,7 +48,7 @@ parameter_types! {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -82,12 +83,12 @@ pub fn to_authorities(vec: Vec<(u64, u64)>) -> AuthorityList {
|
||||
}
|
||||
|
||||
pub fn new_test_ext(authorities: Vec<(u64, u64)>) -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
GenesisConfig {
|
||||
authorities: to_authorities(authorities),
|
||||
}.assimilate_storage::<Test>(&mut t).unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
pub type System = system::Module<Test>;
|
||||
pub type System = frame_system::Module<Test>;
|
||||
pub type Grandpa = Module<Test>;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
use sp_runtime::{testing::Digest, traits::{Header, OnFinalize}};
|
||||
use crate::mock::*;
|
||||
use system::{EventRecord, Phase};
|
||||
use frame_system::{EventRecord, Phase};
|
||||
use codec::{Decode, Encode};
|
||||
use fg_primitives::ScheduledChange;
|
||||
use super::*;
|
||||
|
||||
@@ -11,12 +11,12 @@ enumflags2 = { version = "0.6.2" }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -26,6 +26,6 @@ std = [
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -70,19 +70,19 @@ use sp_std::{fmt::Debug, ops::Add, iter::once};
|
||||
use enumflags2::BitFlags;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::{traits::{StaticLookup, EnsureOrigin, Zero}, RuntimeDebug};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, ensure, dispatch::Result,
|
||||
traits::{Currency, ReservableCurrency, OnUnbalanced, Get},
|
||||
weights::SimpleDispatchInfo,
|
||||
};
|
||||
use system::{ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// The currency trait.
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
@@ -383,7 +383,7 @@ decl_storage! {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where AccountId = <T as system::Trait>::AccountId, Balance = BalanceOf<T> {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId, Balance = BalanceOf<T> {
|
||||
/// A name was set or reset (which will remove all judgements).
|
||||
IdentitySet(AccountId),
|
||||
/// A name was cleared, and the given balance returned.
|
||||
@@ -822,9 +822,9 @@ decl_module! {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use primitives::H256;
|
||||
use system::EnsureSignedBy;
|
||||
use frame_support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
use frame_system::EnsureSignedBy;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||
use sp_runtime::{
|
||||
@@ -832,7 +832,7 @@ mod tests {
|
||||
};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
@@ -846,7 +846,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -868,7 +868,7 @@ mod tests {
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
@@ -898,15 +898,15 @@ mod tests {
|
||||
type RegistrarOrigin = EnsureSignedBy<One, u64>;
|
||||
type ForceOrigin = EnsureSignedBy<Two, u64>;
|
||||
}
|
||||
type Balances = balances::Module<Test>;
|
||||
type Balances = pallet_balances::Module<Test>;
|
||||
type Identity = Module<Test>;
|
||||
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
balances::GenesisConfig::<Test> {
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![
|
||||
(1, 10),
|
||||
(2, 10),
|
||||
|
||||
@@ -5,32 +5,32 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto", default-features = false }
|
||||
authorship = { package = "pallet-authorship", path = "../authorship", default-features = false }
|
||||
sp-application-crypto = { path = "../../primitives/application-crypto", default-features = false }
|
||||
pallet-authorship = { path = "../authorship", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
primitives = { package="sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
session = { package = "pallet-session", path = "../session", default-features = false }
|
||||
pallet-session = { path = "../session", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std", "session/historical"]
|
||||
default = ["std", "pallet-session/historical"]
|
||||
std = [
|
||||
"app-crypto/std",
|
||||
"authorship/std",
|
||||
"sp-application-crypto/std",
|
||||
"pallet-authorship/std",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"serde",
|
||||
"session/std",
|
||||
"pallet-session/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -42,8 +42,8 @@
|
||||
//! ## Usage
|
||||
//!
|
||||
//! ```
|
||||
//! use support::{decl_module, dispatch};
|
||||
//! use system::ensure_signed;
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//! use pallet_im_online::{self as im_online};
|
||||
//!
|
||||
//! pub trait Trait: im_online::Trait {}
|
||||
@@ -70,12 +70,12 @@
|
||||
mod mock;
|
||||
mod tests;
|
||||
|
||||
use app_crypto::RuntimeAppPublic;
|
||||
use sp_application_crypto::RuntimeAppPublic;
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::offchain::{OpaqueNetworkState, StorageKind};
|
||||
use sp_core::offchain::{OpaqueNetworkState, StorageKind};
|
||||
use sp_std::prelude::*;
|
||||
use sp_std::convert::TryInto;
|
||||
use session::historical::IdentificationTuple;
|
||||
use pallet_session::historical::IdentificationTuple;
|
||||
use sp_runtime::{
|
||||
RuntimeDebug,
|
||||
traits::{Convert, Member, Printable, Saturating}, Perbill,
|
||||
@@ -88,16 +88,16 @@ use sp_staking::{
|
||||
SessionIndex,
|
||||
offence::{ReportOffence, Offence, Kind},
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, print, Parameter, debug,
|
||||
traits::Get,
|
||||
};
|
||||
use system::ensure_none;
|
||||
use system::offchain::SubmitUnsignedTransaction;
|
||||
use frame_system::{self as system, ensure_none};
|
||||
use frame_system::offchain::SubmitUnsignedTransaction;
|
||||
|
||||
pub mod sr25519 {
|
||||
mod app_sr25519 {
|
||||
use app_crypto::{app_crypto, key_types::IM_ONLINE, sr25519};
|
||||
use sp_application_crypto::{app_crypto, key_types::IM_ONLINE, sr25519};
|
||||
app_crypto!(sr25519, IM_ONLINE);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ pub mod sr25519 {
|
||||
|
||||
pub mod ed25519 {
|
||||
mod app_ed25519 {
|
||||
use app_crypto::{app_crypto, key_types::IM_ONLINE, ed25519};
|
||||
use sp_application_crypto::{app_crypto, key_types::IM_ONLINE, ed25519};
|
||||
app_crypto!(ed25519, IM_ONLINE);
|
||||
}
|
||||
|
||||
@@ -177,12 +177,12 @@ pub struct Heartbeat<BlockNumber>
|
||||
authority_index: AuthIndex,
|
||||
}
|
||||
|
||||
pub trait Trait: system::Trait + session::historical::Trait {
|
||||
pub trait Trait: frame_system::Trait + pallet_session::historical::Trait {
|
||||
/// The identifier type for an authority.
|
||||
type AuthorityId: Member + Parameter + RuntimeAppPublic + Default + Ord;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// A dispatchable call type.
|
||||
type Call: From<Call<Self>>;
|
||||
@@ -257,7 +257,7 @@ decl_module! {
|
||||
) {
|
||||
ensure_none(origin)?;
|
||||
|
||||
let current_session = <session::Module<T>>::current_index();
|
||||
let current_session = <pallet_session::Module<T>>::current_index();
|
||||
let exists = <ReceivedHeartbeats>::exists(
|
||||
¤t_session,
|
||||
&heartbeat.authority_index
|
||||
@@ -294,7 +294,7 @@ decl_module! {
|
||||
|
||||
/// Keep track of number of authored blocks per authority, uncles are counted as
|
||||
/// well since they're a valid proof of onlineness.
|
||||
impl<T: Trait + authorship::Trait> authorship::EventHandler<T::ValidatorId, T::BlockNumber> for Module<T> {
|
||||
impl<T: Trait + pallet_authorship::Trait> pallet_authorship::EventHandler<T::ValidatorId, T::BlockNumber> for Module<T> {
|
||||
fn note_author(author: T::ValidatorId) {
|
||||
Self::note_authorship(author);
|
||||
}
|
||||
@@ -310,7 +310,7 @@ impl<T: Trait> Module<T> {
|
||||
/// authored at least one block, during the current session. Otherwise
|
||||
/// `false`.
|
||||
pub fn is_online(authority_index: AuthIndex) -> bool {
|
||||
let current_validators = <session::Module<T>>::validators();
|
||||
let current_validators = <pallet_session::Module<T>>::validators();
|
||||
|
||||
if authority_index >= current_validators.len() as u32 {
|
||||
return false;
|
||||
@@ -322,7 +322,7 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
|
||||
fn is_online_aux(authority_index: AuthIndex, authority: &T::ValidatorId) -> bool {
|
||||
let current_session = <session::Module<T>>::current_index();
|
||||
let current_session = <pallet_session::Module<T>>::current_index();
|
||||
|
||||
<ReceivedHeartbeats>::exists(¤t_session, &authority_index) ||
|
||||
<AuthoredBlocks<T>>::get(
|
||||
@@ -334,13 +334,13 @@ impl<T: Trait> Module<T> {
|
||||
/// Returns `true` if a heartbeat has been received for the authority at `authority_index` in
|
||||
/// the authorities series, during the current session. Otherwise `false`.
|
||||
pub fn received_heartbeat_in_current_session(authority_index: AuthIndex) -> bool {
|
||||
let current_session = <session::Module<T>>::current_index();
|
||||
let current_session = <pallet_session::Module<T>>::current_index();
|
||||
<ReceivedHeartbeats>::exists(¤t_session, &authority_index)
|
||||
}
|
||||
|
||||
/// Note that the given authority has authored a block in the current session.
|
||||
fn note_authorship(author: T::ValidatorId) {
|
||||
let current_session = <session::Module<T>>::current_index();
|
||||
let current_session = <pallet_session::Module<T>>::current_index();
|
||||
|
||||
<AuthoredBlocks<T>>::mutate(
|
||||
¤t_session,
|
||||
@@ -413,7 +413,7 @@ impl<T: Trait> Module<T> {
|
||||
let heartbeat_data = Heartbeat {
|
||||
block_number,
|
||||
network_state,
|
||||
session_index: <session::Module<T>>::current_index(),
|
||||
session_index: <pallet_session::Module<T>>::current_index(),
|
||||
authority_index,
|
||||
};
|
||||
|
||||
@@ -513,7 +513,7 @@ impl<T: Trait> sp_runtime::BoundToRuntimeAppPublic for Module<T> {
|
||||
type Public = T::AuthorityId;
|
||||
}
|
||||
|
||||
impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
impl<T: Trait> pallet_session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
type Key = T::AuthorityId;
|
||||
|
||||
fn on_genesis_session<'a, I: 'a>(validators: I)
|
||||
@@ -529,7 +529,7 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
// Tell the offchain worker to start making the next session's heartbeats.
|
||||
// Since we consider producing blocks as being online,
|
||||
// the hearbeat is defered a bit to prevent spaming.
|
||||
let block_number = <system::Module<T>>::block_number();
|
||||
let block_number = <frame_system::Module<T>>::block_number();
|
||||
let half_session = T::SessionDuration::get() / 2.into();
|
||||
<GossipAt<T>>::put(block_number + half_session);
|
||||
|
||||
@@ -538,9 +538,9 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
}
|
||||
|
||||
fn on_before_session_ending() {
|
||||
let session_index = <session::Module<T>>::current_index();
|
||||
let session_index = <pallet_session::Module<T>>::current_index();
|
||||
let keys = Keys::<T>::get();
|
||||
let current_validators = <session::Module<T>>::validators();
|
||||
let current_validators = <pallet_session::Module<T>>::validators();
|
||||
|
||||
let offenders = current_validators.into_iter().enumerate()
|
||||
.filter(|(index, id)|
|
||||
@@ -552,8 +552,8 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
// Remove all received heartbeats and number of authored blocks from the
|
||||
// current session, they have already been processed and won't be needed
|
||||
// anymore.
|
||||
<ReceivedHeartbeats>::remove_prefix(&<session::Module<T>>::current_index());
|
||||
<AuthoredBlocks<T>>::remove_prefix(&<session::Module<T>>::current_index());
|
||||
<ReceivedHeartbeats>::remove_prefix(&<pallet_session::Module<T>>::current_index());
|
||||
<AuthoredBlocks<T>>::remove_prefix(&<pallet_session::Module<T>>::current_index());
|
||||
|
||||
if offenders.is_empty() {
|
||||
Self::deposit_event(RawEvent::AllGood);
|
||||
@@ -572,7 +572,7 @@ impl<T: Trait> session::OneSessionHandler<T::AccountId> for Module<T> {
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<T: Trait> support::unsigned::ValidateUnsigned for Module<T> {
|
||||
impl<T: Trait> frame_support::unsigned::ValidateUnsigned for Module<T> {
|
||||
type Call = Call<T>;
|
||||
|
||||
fn validate_unsigned(call: &Self::Call) -> TransactionValidity {
|
||||
@@ -583,7 +583,7 @@ impl<T: Trait> support::unsigned::ValidateUnsigned for Module<T> {
|
||||
}
|
||||
|
||||
// check if session index from heartbeat is recent
|
||||
let current_session = <session::Module<T>>::current_index();
|
||||
let current_session = <pallet_session::Module<T>>::current_index();
|
||||
if heartbeat.session_index != current_session {
|
||||
return InvalidTransaction::Stale.into();
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ use sp_runtime::Perbill;
|
||||
use sp_staking::{SessionIndex, offence::ReportOffence};
|
||||
use sp_runtime::testing::{Header, UintAuthorityId, TestXt};
|
||||
use sp_runtime::traits::{IdentityLookup, BlakeTwo256, ConvertInto};
|
||||
use primitives::H256;
|
||||
use support::{impl_outer_origin, impl_outer_dispatch, parameter_types, weights::Weight};
|
||||
use {sp_io, system};
|
||||
use sp_core::H256;
|
||||
use frame_support::{impl_outer_origin, impl_outer_dispatch, parameter_types, weights::Weight};
|
||||
|
||||
use frame_system as system;
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Runtime {}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ thread_local! {
|
||||
}
|
||||
|
||||
pub struct TestOnSessionEnding;
|
||||
impl session::OnSessionEnding<u64> for TestOnSessionEnding {
|
||||
impl pallet_session::OnSessionEnding<u64> for TestOnSessionEnding {
|
||||
fn on_session_ending(_ending_index: SessionIndex, _will_apply_at: SessionIndex)
|
||||
-> Option<Vec<u64>>
|
||||
{
|
||||
@@ -52,7 +52,7 @@ impl session::OnSessionEnding<u64> for TestOnSessionEnding {
|
||||
}
|
||||
}
|
||||
|
||||
impl session::historical::OnSessionEnding<u64, u64> for TestOnSessionEnding {
|
||||
impl pallet_session::historical::OnSessionEnding<u64, u64> for TestOnSessionEnding {
|
||||
fn on_session_ending(_ending_index: SessionIndex, _will_apply_at: SessionIndex)
|
||||
-> Option<(Vec<u64>, Vec<(u64, u64)>)>
|
||||
{
|
||||
@@ -69,7 +69,7 @@ impl session::historical::OnSessionEnding<u64, u64> for TestOnSessionEnding {
|
||||
|
||||
/// An extrinsic type used for tests.
|
||||
pub type Extrinsic = TestXt<Call, ()>;
|
||||
type SubmitTransaction = system::offchain::TransactionSubmitter<(), Call, Extrinsic>;
|
||||
type SubmitTransaction = frame_system::offchain::TransactionSubmitter<(), Call, Extrinsic>;
|
||||
type IdentificationTuple = (u64, u64);
|
||||
type Offence = crate::UnresponsivenessOffence<IdentificationTuple>;
|
||||
|
||||
@@ -86,7 +86,7 @@ impl ReportOffence<u64, IdentificationTuple, Offence> for OffenceHandler {
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
let t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ parameter_types! {
|
||||
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;
|
||||
@@ -128,9 +128,9 @@ parameter_types! {
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(33);
|
||||
}
|
||||
|
||||
impl session::Trait for Runtime {
|
||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||
type OnSessionEnding = session::historical::NoteHistoricalRoot<Runtime, TestOnSessionEnding>;
|
||||
impl pallet_session::Trait for Runtime {
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type OnSessionEnding = pallet_session::historical::NoteHistoricalRoot<Runtime, TestOnSessionEnding>;
|
||||
type SessionHandler = (ImOnline, );
|
||||
type ValidatorId = u64;
|
||||
type ValidatorIdOf = ConvertInto;
|
||||
@@ -140,7 +140,7 @@ impl session::Trait for Runtime {
|
||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||
}
|
||||
|
||||
impl session::historical::Trait for Runtime {
|
||||
impl pallet_session::historical::Trait for Runtime {
|
||||
type FullIdentification = u64;
|
||||
type FullIdentificationOf = ConvertInto;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ parameter_types! {
|
||||
pub const UncleGenerations: u32 = 5;
|
||||
}
|
||||
|
||||
impl authorship::Trait for Runtime {
|
||||
impl pallet_authorship::Trait for Runtime {
|
||||
type FindAuthor = ();
|
||||
type UncleGenerations = UncleGenerations;
|
||||
type FilterUncle = ();
|
||||
@@ -167,8 +167,8 @@ impl Trait for Runtime {
|
||||
|
||||
/// Im Online module.
|
||||
pub type ImOnline = Module<Runtime>;
|
||||
pub type System = system::Module<Runtime>;
|
||||
pub type Session = session::Module<Runtime>;
|
||||
pub type System = frame_system::Module<Runtime>;
|
||||
pub type Session = pallet_session::Module<Runtime>;
|
||||
|
||||
pub fn advance_session() {
|
||||
let now = System::block_number();
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
|
||||
use super::*;
|
||||
use crate::mock::*;
|
||||
use primitives::offchain::{
|
||||
use sp_core::offchain::{
|
||||
OpaquePeerId,
|
||||
OffchainExt,
|
||||
TransactionPoolExt,
|
||||
testing::{TestOffchainExt, TestTransactionPoolExt},
|
||||
};
|
||||
use support::{dispatch, assert_noop};
|
||||
use frame_support::{dispatch, assert_noop};
|
||||
use sp_runtime::testing::UintAuthorityId;
|
||||
|
||||
#[test]
|
||||
@@ -113,7 +113,7 @@ fn heartbeat(
|
||||
id: UintAuthorityId,
|
||||
) -> dispatch::Result {
|
||||
#[allow(deprecated)]
|
||||
use support::unsigned::ValidateUnsigned;
|
||||
use frame_support::unsigned::ValidateUnsigned;
|
||||
|
||||
let heartbeat = Heartbeat {
|
||||
block_number,
|
||||
@@ -129,7 +129,7 @@ fn heartbeat(
|
||||
#[allow(deprecated)] // Allow ValidateUnsigned
|
||||
ImOnline::pre_dispatch(&crate::Call::heartbeat(heartbeat.clone(), signature.clone()))?;
|
||||
ImOnline::heartbeat(
|
||||
Origin::system(system::RawOrigin::None),
|
||||
Origin::system(frame_system::RawOrigin::None),
|
||||
heartbeat,
|
||||
signature
|
||||
)
|
||||
@@ -262,7 +262,7 @@ fn should_cleanup_received_heartbeats_on_session_end() {
|
||||
|
||||
#[test]
|
||||
fn should_mark_online_validator_when_block_is_authored() {
|
||||
use authorship::EventHandler;
|
||||
use pallet_authorship::EventHandler;
|
||||
|
||||
new_test_ext().execute_with(|| {
|
||||
advance_session();
|
||||
@@ -292,7 +292,7 @@ fn should_mark_online_validator_when_block_is_authored() {
|
||||
|
||||
#[test]
|
||||
fn should_not_send_a_report_if_already_online() {
|
||||
use authorship::EventHandler;
|
||||
use pallet_authorship::EventHandler;
|
||||
|
||||
let mut ext = new_test_ext();
|
||||
let (offchain, _state) = TestOffchainExt::new();
|
||||
@@ -313,7 +313,7 @@ fn should_not_send_a_report_if_already_online() {
|
||||
ImOnline::note_uncle(3, 0);
|
||||
|
||||
// when
|
||||
UintAuthorityId::set_all_keys(vec![0]); // all authorities use session key 0
|
||||
UintAuthorityId::set_all_keys(vec![0]); // all authorities use pallet_session key 0
|
||||
ImOnline::offchain(4);
|
||||
|
||||
// then
|
||||
|
||||
@@ -12,9 +12,9 @@ sp-keyring = { path = "../../primitives/keyring", optional = true }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
ref_thread_local = "0.0.0"
|
||||
@@ -26,10 +26,10 @@ std = [
|
||||
"safe-mix/std",
|
||||
"sp-keyring",
|
||||
"codec/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
|
||||
use sp_std::{prelude::*, marker::PhantomData, convert::TryInto};
|
||||
use codec::{Encode, Codec};
|
||||
use support::{Parameter, decl_module, decl_event, decl_storage};
|
||||
use frame_support::{Parameter, decl_module, decl_event, decl_storage};
|
||||
use sp_runtime::traits::{One, SimpleArithmetic, StaticLookup, Member, LookupError};
|
||||
use system::{IsDeadAccount, OnNewAccount};
|
||||
use frame_system::{IsDeadAccount, OnNewAccount};
|
||||
|
||||
use self::address::Address as RawAddress;
|
||||
|
||||
@@ -35,7 +35,7 @@ mod tests;
|
||||
/// Number of account IDs stored per enum set.
|
||||
const ENUM_SET_SIZE: u32 = 64;
|
||||
|
||||
pub type Address<T> = RawAddress<<T as system::Trait>::AccountId, <T as Trait>::AccountIndex>;
|
||||
pub type Address<T> = RawAddress<<T as frame_system::Trait>::AccountId, <T as Trait>::AccountIndex>;
|
||||
|
||||
/// Turn an Id into an Index, or None for the purpose of getting
|
||||
/// a hint at a possibly desired index.
|
||||
@@ -56,7 +56,7 @@ impl<AccountId: Encode, AccountIndex: From<u32>>
|
||||
}
|
||||
|
||||
/// The module's config trait.
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// Type used for storing an account's index; implies the maximum number of accounts the system
|
||||
/// can hold.
|
||||
type AccountIndex: Parameter + Member + Codec + Default + SimpleArithmetic + Copy;
|
||||
@@ -68,18 +68,18 @@ pub trait Trait: system::Trait {
|
||||
type ResolveHint: ResolveHint<Self::AccountId, Self::AccountIndex>;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
}
|
||||
|
||||
decl_module! {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
|
||||
pub struct Module<T: Trait> for enum Call where origin: T::Origin, system = frame_system {
|
||||
fn deposit_event() = default;
|
||||
}
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as Trait>::AccountIndex
|
||||
{
|
||||
/// A new account index was assigned.
|
||||
|
||||
@@ -22,13 +22,12 @@ use std::collections::HashSet;
|
||||
use ref_thread_local::{ref_thread_local, RefThreadLocal};
|
||||
use sp_runtime::testing::Header;
|
||||
use sp_runtime::Perbill;
|
||||
use primitives::H256;
|
||||
use support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use {sp_io, system};
|
||||
use sp_core::H256;
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use crate::{GenesisConfig, Module, Trait, IsDeadAccount, OnNewAccount, ResolveHint};
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Runtime {}
|
||||
pub enum Origin for Runtime where system = frame_system {}
|
||||
}
|
||||
|
||||
ref_thread_local! {
|
||||
@@ -71,7 +70,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;
|
||||
@@ -102,7 +101,7 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
for i in 1..5 { h.insert(i); }
|
||||
}
|
||||
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
GenesisConfig::<Runtime> {
|
||||
ids: vec![1, 2, 3, 4]
|
||||
}.assimilate_storage(&mut t).unwrap();
|
||||
|
||||
@@ -9,12 +9,12 @@ serde = { version = "1.0.101", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -24,6 +24,6 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -23,17 +23,17 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, decl_event,
|
||||
traits::{ChangeMembers, InitializeMembers},
|
||||
weights::SimpleDispatchInfo,
|
||||
};
|
||||
use system::{ensure_root, ensure_signed};
|
||||
use frame_system::{self as system, ensure_root, ensure_signed};
|
||||
use sp_runtime::traits::EnsureOrigin;
|
||||
|
||||
pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
pub trait Trait<I=DefaultInstance>: frame_system::Trait {
|
||||
/// 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>;
|
||||
|
||||
/// Required origin for adding a member (though can always be Root).
|
||||
type AddOrigin: EnsureOrigin<Self::Origin>;
|
||||
@@ -75,7 +75,7 @@ decl_storage! {
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I=DefaultInstance> where
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
<T as Trait<I>>::Event,
|
||||
{
|
||||
/// The given member was added; see the transaction for who.
|
||||
@@ -221,15 +221,15 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use primitives::H256;
|
||||
use frame_support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
|
||||
use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header};
|
||||
use system::EnsureSignedBy;
|
||||
use frame_system::EnsureSignedBy;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
@@ -243,7 +243,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -307,7 +307,7 @@ mod tests {
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
GenesisConfig::<Test>{
|
||||
members: vec![10, 20, 30],
|
||||
|
||||
@@ -8,13 +8,13 @@ edition = "2018"
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"primitives/std",
|
||||
"sp-core/std",
|
||||
"serde",
|
||||
]
|
||||
|
||||
@@ -28,7 +28,7 @@ use serde::Serialize;
|
||||
use codec::{Decode, Input, Error};
|
||||
use codec::{Encode, Output};
|
||||
use sp_std::vec::Vec;
|
||||
use primitives::RuntimeDebug;
|
||||
use sp_core::RuntimeDebug;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
type StringBuf = String;
|
||||
@@ -391,9 +391,9 @@ pub struct ModuleMetadata {
|
||||
type ODFnA<T> = Option<DFnA<T>>;
|
||||
type DFnA<T> = DecodeDifferent<FnEncode<&'static [T]>, Vec<T>>;
|
||||
|
||||
impl Into<primitives::OpaqueMetadata> for RuntimeMetadataPrefixed {
|
||||
fn into(self) -> primitives::OpaqueMetadata {
|
||||
primitives::OpaqueMetadata::new(self.encode())
|
||||
impl Into<sp_core::OpaqueMetadata> for RuntimeMetadataPrefixed {
|
||||
fn into(self) -> sp_core::OpaqueMetadata {
|
||||
sp_core::OpaqueMetadata::new(self.encode())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features =
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -25,6 +25,6 @@ std = [
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -42,19 +42,19 @@ use sp_std::prelude::*;
|
||||
use sp_runtime::{
|
||||
traits::{StaticLookup, EnsureOrigin, Zero}
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, ensure,
|
||||
traits::{Currency, ReservableCurrency, OnUnbalanced, Get},
|
||||
weights::SimpleDispatchInfo,
|
||||
};
|
||||
use system::{ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||
type BalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type NegativeImbalanceOf<T> = <<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// The currency trait.
|
||||
type Currency: ReservableCurrency<Self::AccountId>;
|
||||
@@ -83,7 +83,7 @@ decl_storage! {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where AccountId = <T as system::Trait>::AccountId, Balance = BalanceOf<T> {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId, Balance = BalanceOf<T> {
|
||||
/// A name was set.
|
||||
NameSet(AccountId),
|
||||
/// A name was forcibly set.
|
||||
@@ -229,9 +229,9 @@ decl_module! {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use primitives::H256;
|
||||
use system::EnsureSignedBy;
|
||||
use frame_support::{assert_ok, assert_noop, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
use frame_system::EnsureSignedBy;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are required.
|
||||
use sp_runtime::{
|
||||
@@ -239,7 +239,7 @@ mod tests {
|
||||
};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
@@ -253,7 +253,7 @@ mod tests {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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;
|
||||
@@ -275,7 +275,7 @@ mod tests {
|
||||
pub const TransferFee: u64 = 0;
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
@@ -301,15 +301,15 @@ mod tests {
|
||||
type MinLength = MinLength;
|
||||
type MaxLength = MaxLength;
|
||||
}
|
||||
type Balances = balances::Module<Test>;
|
||||
type Balances = pallet_balances::Module<Test>;
|
||||
type Nicks = Module<Test>;
|
||||
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
balances::GenesisConfig::<Test> {
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![
|
||||
(1, 10),
|
||||
(2, 10),
|
||||
|
||||
@@ -5,14 +5,14 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
balances = { package = "pallet-balances", path = "../balances", default-features = false }
|
||||
pallet-balances = { path = "../balances", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
@@ -21,12 +21,12 @@ sp-core = { path = "../../primitives/core" }
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"balances/std",
|
||||
"pallet-balances/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"serde",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -25,7 +25,7 @@ mod mock;
|
||||
mod tests;
|
||||
|
||||
use sp_std::vec::Vec;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, Parameter,
|
||||
};
|
||||
use sp_runtime::traits::Hash;
|
||||
@@ -33,17 +33,18 @@ use sp_staking::{
|
||||
offence::{Offence, ReportOffence, Kind, OnOffenceHandler, OffenceDetails},
|
||||
};
|
||||
use codec::{Encode, Decode};
|
||||
use frame_system as system;
|
||||
|
||||
/// A binary blob which represents a SCALE codec-encoded `O::TimeSlot`.
|
||||
type OpaqueTimeSlot = Vec<u8>;
|
||||
|
||||
/// A type alias for a report identifier.
|
||||
type ReportIdOf<T> = <T as system::Trait>::Hash;
|
||||
type ReportIdOf<T> = <T as frame_system::Trait>::Hash;
|
||||
|
||||
/// Offences trait
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
|
||||
/// Full identification of the validator.
|
||||
type IdentificationTuple: Parameter + Ord;
|
||||
/// A handler called for every offence report.
|
||||
|
||||
@@ -29,11 +29,11 @@ use sp_staking::{
|
||||
use sp_runtime::testing::Header;
|
||||
use sp_runtime::traits::{IdentityLookup, BlakeTwo256};
|
||||
use sp_core::H256;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
impl_outer_origin, impl_outer_event, parameter_types, StorageMap, StorageDoubleMap,
|
||||
weights::Weight,
|
||||
};
|
||||
use {sp_io, system};
|
||||
use frame_system as system;
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Runtime {}
|
||||
@@ -72,7 +72,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;
|
||||
@@ -107,13 +107,13 @@ impl_outer_event! {
|
||||
}
|
||||
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let t = system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
let t = frame_system::GenesisConfig::default().build_storage::<Runtime>().unwrap();
|
||||
t.into()
|
||||
}
|
||||
|
||||
/// Offences module.
|
||||
pub type Offences = Module<Runtime>;
|
||||
pub type System = system::Module<Runtime>;
|
||||
pub type System = frame_system::Module<Runtime>;
|
||||
|
||||
pub const KIND: [u8; 16] = *b"test_report_1234";
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ use crate::mock::{
|
||||
offence_reports,
|
||||
};
|
||||
use sp_runtime::Perbill;
|
||||
use system::{EventRecord, Phase};
|
||||
use frame_system::{EventRecord, Phase};
|
||||
|
||||
#[test]
|
||||
fn should_report_an_authority_and_trigger_on_offence() {
|
||||
|
||||
@@ -8,21 +8,21 @@ edition = "2018"
|
||||
safe-mix = { version = "1.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sp-io = { path = "../../primitives/io" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"safe-mix/std",
|
||||
"system/std",
|
||||
"frame-system/std",
|
||||
"codec/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
@@ -10,12 +10,12 @@ serde = { version = "1.0.101", optional = true }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -25,6 +25,6 @@ std = [
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -53,8 +53,8 @@
|
||||
//! ## Usage
|
||||
//!
|
||||
//! ```
|
||||
//! use support::{decl_module, dispatch};
|
||||
//! use system::ensure_signed;
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//! use pallet_scored_pool::{self as scored_pool};
|
||||
//!
|
||||
//! pub trait Trait: scored_pool::Trait {}
|
||||
@@ -93,17 +93,17 @@ use sp_std::{
|
||||
fmt::Debug,
|
||||
prelude::*,
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_storage, decl_event, ensure,
|
||||
traits::{ChangeMembers, InitializeMembers, Currency, Get, ReservableCurrency},
|
||||
};
|
||||
use system::{self, ensure_root, ensure_signed};
|
||||
use frame_system::{self as system, ensure_root, ensure_signed};
|
||||
use sp_runtime::{
|
||||
traits::{EnsureOrigin, SimpleArithmetic, MaybeSerializeDeserialize, Zero, StaticLookup},
|
||||
};
|
||||
|
||||
type BalanceOf<T, I> = <<T as Trait<I>>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
type PoolT<T, I> = Vec<(<T as system::Trait>::AccountId, Option<<T as Trait<I>>::Score>)>;
|
||||
type BalanceOf<T, I> = <<T as Trait<I>>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type PoolT<T, I> = Vec<(<T as frame_system::Trait>::AccountId, Option<<T as Trait<I>>::Score>)>;
|
||||
|
||||
/// The enum is supplied when refreshing the members set.
|
||||
/// Depending on the enum variant the corresponding associated
|
||||
@@ -115,7 +115,7 @@ enum ChangeReceiver {
|
||||
MembershipChanged,
|
||||
}
|
||||
|
||||
pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
pub trait Trait<I=DefaultInstance>: frame_system::Trait {
|
||||
/// The currency used for deposits.
|
||||
type Currency: Currency<Self::AccountId> + ReservableCurrency<Self::AccountId>;
|
||||
|
||||
@@ -124,7 +124,7 @@ pub trait Trait<I=DefaultInstance>: system::Trait {
|
||||
SimpleArithmetic + Clone + Copy + Default + FullCodec + MaybeSerializeDeserialize + Debug;
|
||||
|
||||
/// 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 deposit which is reserved from candidates if they want to
|
||||
// start a candidacy. The deposit gets returned when the candidacy is
|
||||
@@ -203,7 +203,7 @@ decl_storage! {
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T, I=DefaultInstance> where
|
||||
<T as system::Trait>::AccountId,
|
||||
<T as frame_system::Trait>::AccountId,
|
||||
{
|
||||
/// The given member was removed. See the transaction for who.
|
||||
MemberRemoved,
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
use super::*;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use primitives::H256;
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
// The testing primitives are very useful for avoiding having to work with signatures
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
|
||||
use sp_runtime::{
|
||||
Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header,
|
||||
};
|
||||
use system::EnsureSignedBy;
|
||||
use frame_system::EnsureSignedBy;
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
// For testing the module, we construct most of a mock runtime. This means
|
||||
@@ -54,7 +54,7 @@ parameter_types! {
|
||||
pub const CreationFee: u64 = 0;
|
||||
}
|
||||
|
||||
impl system::Trait for Test {
|
||||
impl frame_system::Trait for Test {
|
||||
type Origin = Origin;
|
||||
type Index = u64;
|
||||
type BlockNumber = u64;
|
||||
@@ -72,7 +72,7 @@ impl system::Trait for Test {
|
||||
type Version = ();
|
||||
}
|
||||
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = u64;
|
||||
type OnFreeBalanceZero = ();
|
||||
type OnNewAccount = ();
|
||||
@@ -116,7 +116,7 @@ impl Trait for Test {
|
||||
type KickOrigin = EnsureSignedBy<KickOrigin, u64>;
|
||||
type MembershipInitialized = TestChangeMembers;
|
||||
type MembershipChanged = TestChangeMembers;
|
||||
type Currency = balances::Module<Self>;
|
||||
type Currency = pallet_balances::Module<Self>;
|
||||
type CandidateDeposit = CandidateDeposit;
|
||||
type Period = Period;
|
||||
type Score = u64;
|
||||
@@ -126,9 +126,9 @@ impl Trait for Test {
|
||||
// This function basically just builds a genesis storage key/value store according to
|
||||
// our desired mockup.
|
||||
pub fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
// We use default for brevity, but you can configure as desired if needed.
|
||||
balances::GenesisConfig::<Test> {
|
||||
pallet_balances::GenesisConfig::<Test> {
|
||||
balances: vec![
|
||||
(5, 500_000),
|
||||
(10, 500_000),
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
use super::*;
|
||||
use mock::*;
|
||||
|
||||
use support::{assert_ok, assert_noop};
|
||||
use frame_support::{assert_ok, assert_noop};
|
||||
use sp_runtime::traits::OnInitialize;
|
||||
|
||||
type ScoredPool = Module<Test>;
|
||||
type System = system::Module<Test>;
|
||||
type Balances = balances::Module<Test>;
|
||||
type System = frame_system::Module<Test>;
|
||||
type Balances = pallet_balances::Module<Test>;
|
||||
|
||||
const OOB_ERR: &str = "index out of bounds";
|
||||
const INDEX_ERR: &str = "index does not match requested account";
|
||||
|
||||
@@ -11,16 +11,16 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features =
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
timestamp = { package = "pallet-timestamp", path = "../timestamp", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
pallet-timestamp = { path = "../timestamp", default-features = false }
|
||||
sp-trie = { path = "../../primitives/trie", default-features = false, optional = true }
|
||||
sp-io ={ path = "../../primitives/io", default-features = false }
|
||||
impl-trait-for-tuples = "0.1.3"
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
app-crypto = { package = "sp-application-crypto", path = "../../primitives/application-crypto" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
sp-application-crypto = { path = "../../primitives/application-crypto" }
|
||||
lazy_static = "1.4.0"
|
||||
|
||||
[features]
|
||||
@@ -31,10 +31,10 @@ std = [
|
||||
"safe-mix/std",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"timestamp/std",
|
||||
"pallet-timestamp/std",
|
||||
"sp-trie/std",
|
||||
"sp-io/std",
|
||||
]
|
||||
|
||||
@@ -29,8 +29,8 @@ use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_runtime::KeyTypeId;
|
||||
use sp_runtime::traits::{Convert, OpaqueKeys, Hash as HashT};
|
||||
use support::{decl_module, decl_storage};
|
||||
use support::{Parameter, print};
|
||||
use frame_support::{decl_module, decl_storage};
|
||||
use frame_support::{Parameter, print};
|
||||
use sp_trie::{MemoryDB, Trie, TrieMut, Recorder, EMPTY_PREFIX};
|
||||
use sp_trie::trie_types::{TrieDBMut, TrieDB};
|
||||
use super::{SessionIndex, Module as SessionModule};
|
||||
@@ -146,7 +146,7 @@ impl<T: Trait, I> crate::OnSessionEnding<T::ValidatorId> for NoteHistoricalRoot<
|
||||
}
|
||||
}
|
||||
|
||||
type HasherOf<T> = <<T as system::Trait>::Hashing as HashT>::Hasher;
|
||||
type HasherOf<T> = <<T as frame_system::Trait>::Hashing as HashT>::Hasher;
|
||||
|
||||
/// A tuple of the validator's ID and their full identification.
|
||||
pub type IdentificationTuple<T> = (<T as crate::Trait>::ValidatorId, <T as Trait>::FullIdentification);
|
||||
@@ -273,7 +273,7 @@ pub struct Proof {
|
||||
trie_nodes: Vec<Vec<u8>>,
|
||||
}
|
||||
|
||||
impl<T: Trait, D: AsRef<[u8]>> support::traits::KeyOwnerProofSystem<(KeyTypeId, D)>
|
||||
impl<T: Trait, D: AsRef<[u8]>> frame_support::traits::KeyOwnerProofSystem<(KeyTypeId, D)>
|
||||
for Module<T>
|
||||
{
|
||||
type Proof = Proof;
|
||||
@@ -310,18 +310,18 @@ impl<T: Trait, D: AsRef<[u8]>> support::traits::KeyOwnerProofSystem<(KeyTypeId,
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use primitives::crypto::key_types::DUMMY;
|
||||
use sp_core::crypto::key_types::DUMMY;
|
||||
use sp_runtime::{traits::OnInitialize, testing::UintAuthorityId};
|
||||
use crate::mock::{
|
||||
NEXT_VALIDATORS, force_new_session,
|
||||
set_next_validators, Test, System, Session,
|
||||
};
|
||||
use support::traits::KeyOwnerProofSystem;
|
||||
use frame_support::traits::KeyOwnerProofSystem;
|
||||
|
||||
type Historical = Module<Test>;
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
crate::GenesisConfig::<Test> {
|
||||
keys: NEXT_VALIDATORS.with(|l|
|
||||
l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i).into())).collect()
|
||||
|
||||
@@ -122,12 +122,12 @@
|
||||
use sp_std::{prelude::*, marker::PhantomData, ops::{Sub, Rem}};
|
||||
use codec::Decode;
|
||||
use sp_runtime::{KeyTypeId, Perbill, RuntimeAppPublic, BoundToRuntimeAppPublic};
|
||||
use support::weights::SimpleDispatchInfo;
|
||||
use frame_support::weights::SimpleDispatchInfo;
|
||||
use sp_runtime::traits::{Convert, Zero, Member, OpaqueKeys};
|
||||
use sp_staking::SessionIndex;
|
||||
use support::{dispatch, ConsensusEngineId, decl_module, decl_event, decl_storage};
|
||||
use support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor, ValidatorRegistration}, Parameter};
|
||||
use system::{self, ensure_signed};
|
||||
use frame_support::{dispatch, ConsensusEngineId, decl_module, decl_event, decl_storage};
|
||||
use frame_support::{ensure, traits::{OnFreeBalanceZero, Get, FindAuthor, ValidatorRegistration}, Parameter};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
|
||||
#[cfg(test)]
|
||||
mod mock;
|
||||
@@ -339,9 +339,9 @@ impl<T: Trait> ValidatorRegistration<T::ValidatorId> for Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// A stable ID for a validator.
|
||||
type ValidatorId: Member + Parameter;
|
||||
@@ -720,8 +720,8 @@ impl<T: Trait, Inner: FindAuthor<u32>> FindAuthor<T::ValidatorId>
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use support::assert_ok;
|
||||
use primitives::crypto::key_types::DUMMY;
|
||||
use frame_support::assert_ok;
|
||||
use sp_core::crypto::key_types::DUMMY;
|
||||
use sp_runtime::{traits::OnInitialize, testing::UintAuthorityId};
|
||||
use mock::{
|
||||
NEXT_VALIDATORS, SESSION_CHANGED, TEST_SESSION_CHANGED, authorities, force_new_session,
|
||||
@@ -730,7 +730,7 @@ mod tests {
|
||||
};
|
||||
|
||||
fn new_test_ext() -> sp_io::TestExternalities {
|
||||
let mut t = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut t = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
GenesisConfig::<Test> {
|
||||
keys: NEXT_VALIDATORS.with(|l|
|
||||
l.borrow().iter().cloned().map(|i| (i, UintAuthorityId(i).into())).collect()
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
use super::*;
|
||||
use std::cell::RefCell;
|
||||
use support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use primitives::{crypto::key_types::DUMMY, H256};
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_core::{crypto::key_types::DUMMY, H256};
|
||||
use sp_runtime::{
|
||||
Perbill, impl_opaque_keys, traits::{BlakeTwo256, IdentityLookup, ConvertInto},
|
||||
testing::{Header, UintAuthorityId}
|
||||
@@ -39,7 +39,7 @@ impl From<UintAuthorityId> for MockSessionKeys {
|
||||
}
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
thread_local! {
|
||||
@@ -158,7 +158,7 @@ parameter_types! {
|
||||
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;
|
||||
@@ -176,7 +176,7 @@ impl system::Trait for Test {
|
||||
type Version = ();
|
||||
}
|
||||
|
||||
impl timestamp::Trait for Test {
|
||||
impl pallet_timestamp::Trait for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
@@ -207,5 +207,5 @@ impl crate::historical::Trait for Test {
|
||||
type FullIdentificationOf = sp_runtime::traits::ConvertInto;
|
||||
}
|
||||
|
||||
pub type System = system::Module<Test>;
|
||||
pub type System = frame_system::Module<Test>;
|
||||
pub type Session = Module<Test>;
|
||||
|
||||
@@ -10,19 +10,19 @@ safe-mix = { version = "1.0.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
|
||||
sp-keyring = { path = "../../primitives/keyring", optional = true }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
phragmen = { package = "sp-phragmen", path = "../../primitives/phragmen", default-features = false }
|
||||
sp-phragmen = { path = "../../primitives/phragmen", default-features = false }
|
||||
sp-io ={ path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
sp-staking = { path = "../../primitives/staking", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
session = { package = "pallet-session", path = "../session", default-features = false, features = ["historical"] }
|
||||
authorship = { package = "pallet-authorship", path = "../authorship", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
pallet-session = { path = "../session", default-features = false, features = ["historical"] }
|
||||
pallet-authorship = { path = "../authorship", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
balances = { package = "pallet-balances", path = "../balances" }
|
||||
timestamp = { package = "pallet-timestamp", path = "../timestamp" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
pallet-balances = { path = "../balances" }
|
||||
pallet-timestamp = { path = "../timestamp" }
|
||||
pallet-staking-reward-curve = { path = "../staking/reward-curve"}
|
||||
substrate-test-utils = { path = "../../test-utils" }
|
||||
|
||||
@@ -36,12 +36,12 @@ std = [
|
||||
"sp-keyring",
|
||||
"codec/std",
|
||||
"sp-std/std",
|
||||
"phragmen/std",
|
||||
"sp-phragmen/std",
|
||||
"sp-io/std",
|
||||
"support/std",
|
||||
"frame-support/std",
|
||||
"sp-runtime/std",
|
||||
"sp-staking/std",
|
||||
"session/std",
|
||||
"system/std",
|
||||
"authorship/std",
|
||||
"pallet-session/std",
|
||||
"frame-system/std",
|
||||
"pallet-authorship/std",
|
||||
]
|
||||
|
||||
@@ -138,8 +138,8 @@
|
||||
//! ### Example: Rewarding a validator by id.
|
||||
//!
|
||||
//! ```
|
||||
//! use support::{decl_module, dispatch};
|
||||
//! use system::ensure_signed;
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_system::{self as system, ensure_signed};
|
||||
//! use pallet_staking::{self as staking};
|
||||
//!
|
||||
//! pub trait Trait: staking::Trait {}
|
||||
@@ -181,7 +181,7 @@
|
||||
//! [`reward_by_indices`](./enum.Call.html#variant.reward_by_indices).
|
||||
//!
|
||||
//! [`Module`](./struct.Module.html) implements
|
||||
//! [`authorship::EventHandler`](../pallet_authorship/trait.EventHandler.html) to add reward points
|
||||
//! [`pallet_authorship::EventHandler`](../pallet_authorship/trait.EventHandler.html) to add reward points
|
||||
//! to block producer and block producer of referenced uncles.
|
||||
//!
|
||||
//! The validator and its nominator split their reward as following:
|
||||
@@ -257,7 +257,7 @@ pub mod inflation;
|
||||
|
||||
use sp_std::{prelude::*, result};
|
||||
use codec::{HasCompact, Encode, Decode};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
decl_module, decl_event, decl_storage, ensure,
|
||||
weights::SimpleDispatchInfo,
|
||||
traits::{
|
||||
@@ -265,7 +265,7 @@ use support::{
|
||||
WithdrawReasons, OnUnbalanced, Imbalance, Get, Time
|
||||
}
|
||||
};
|
||||
use session::{historical::OnSessionEnding, SelectInitialValidators};
|
||||
use pallet_session::{historical::OnSessionEnding, SelectInitialValidators};
|
||||
use sp_runtime::{
|
||||
Perbill,
|
||||
RuntimeDebug,
|
||||
@@ -281,9 +281,9 @@ use sp_staking::{
|
||||
};
|
||||
#[cfg(feature = "std")]
|
||||
use sp_runtime::{Serialize, Deserialize};
|
||||
use system::{ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
|
||||
use phragmen::{ExtendedBalance, PhragmenStakedAssignment};
|
||||
use sp_phragmen::{ExtendedBalance, PhragmenStakedAssignment};
|
||||
|
||||
const DEFAULT_MINIMUM_VALIDATOR_COUNT: u32 = 4;
|
||||
const MAX_NOMINATIONS: usize = 16;
|
||||
@@ -521,17 +521,17 @@ pub struct UnappliedSlash<AccountId, Balance: HasCompact> {
|
||||
}
|
||||
|
||||
pub type BalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::Balance;
|
||||
type PositiveImbalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::PositiveImbalance;
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::PositiveImbalance;
|
||||
type NegativeImbalanceOf<T> =
|
||||
<<T as Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::NegativeImbalance;
|
||||
<<T as Trait>::Currency as Currency<<T as frame_system::Trait>::AccountId>>::NegativeImbalance;
|
||||
type MomentOf<T> = <<T as Trait>::Time as Time>::Moment;
|
||||
|
||||
/// Means for interacting with a specialized version of the `session` trait.
|
||||
///
|
||||
/// This is needed because `Staking` sets the `ValidatorIdOf` of the `session::Trait`
|
||||
pub trait SessionInterface<AccountId>: system::Trait {
|
||||
/// This is needed because `Staking` sets the `ValidatorIdOf` of the `pallet_session::Trait`
|
||||
pub trait SessionInterface<AccountId>: frame_system::Trait {
|
||||
/// Disable a given validator by stash ID.
|
||||
///
|
||||
/// Returns `true` if new era should be forced at the end of this session.
|
||||
@@ -544,31 +544,31 @@ pub trait SessionInterface<AccountId>: system::Trait {
|
||||
fn prune_historical_up_to(up_to: SessionIndex);
|
||||
}
|
||||
|
||||
impl<T: Trait> SessionInterface<<T as system::Trait>::AccountId> for T where
|
||||
T: session::Trait<ValidatorId = <T as system::Trait>::AccountId>,
|
||||
T: session::historical::Trait<
|
||||
FullIdentification = Exposure<<T as system::Trait>::AccountId, BalanceOf<T>>,
|
||||
impl<T: Trait> SessionInterface<<T as frame_system::Trait>::AccountId> for T where
|
||||
T: pallet_session::Trait<ValidatorId = <T as frame_system::Trait>::AccountId>,
|
||||
T: pallet_session::historical::Trait<
|
||||
FullIdentification = Exposure<<T as frame_system::Trait>::AccountId, BalanceOf<T>>,
|
||||
FullIdentificationOf = ExposureOf<T>,
|
||||
>,
|
||||
T::SessionHandler: session::SessionHandler<<T as system::Trait>::AccountId>,
|
||||
T::OnSessionEnding: session::OnSessionEnding<<T as system::Trait>::AccountId>,
|
||||
T::SelectInitialValidators: session::SelectInitialValidators<<T as system::Trait>::AccountId>,
|
||||
T::ValidatorIdOf: Convert<<T as system::Trait>::AccountId, Option<<T as system::Trait>::AccountId>>
|
||||
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Trait>::AccountId>,
|
||||
T::OnSessionEnding: pallet_session::OnSessionEnding<<T as frame_system::Trait>::AccountId>,
|
||||
T::SelectInitialValidators: pallet_session::SelectInitialValidators<<T as frame_system::Trait>::AccountId>,
|
||||
T::ValidatorIdOf: Convert<<T as frame_system::Trait>::AccountId, Option<<T as frame_system::Trait>::AccountId>>
|
||||
{
|
||||
fn disable_validator(validator: &<T as system::Trait>::AccountId) -> Result<bool, ()> {
|
||||
<session::Module<T>>::disable(validator)
|
||||
fn disable_validator(validator: &<T as frame_system::Trait>::AccountId) -> Result<bool, ()> {
|
||||
<pallet_session::Module<T>>::disable(validator)
|
||||
}
|
||||
|
||||
fn validators() -> Vec<<T as system::Trait>::AccountId> {
|
||||
<session::Module<T>>::validators()
|
||||
fn validators() -> Vec<<T as frame_system::Trait>::AccountId> {
|
||||
<pallet_session::Module<T>>::validators()
|
||||
}
|
||||
|
||||
fn prune_historical_up_to(up_to: SessionIndex) {
|
||||
<session::historical::Module<T>>::prune_up_to(up_to);
|
||||
<pallet_session::historical::Module<T>>::prune_up_to(up_to);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The staking balance.
|
||||
type Currency: LockableCurrency<Self::AccountId, Moment=Self::BlockNumber>;
|
||||
|
||||
@@ -586,7 +586,7 @@ pub trait Trait: system::Trait {
|
||||
type RewardRemainder: OnUnbalanced<NegativeImbalanceOf<Self>>;
|
||||
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// Handler for the unbalanced reduction when slashing a staker.
|
||||
type Slash: OnUnbalanced<NegativeImbalanceOf<Self>>;
|
||||
@@ -771,7 +771,7 @@ decl_storage! {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where Balance = BalanceOf<T>, <T as system::Trait>::AccountId {
|
||||
pub enum Event<T> where Balance = BalanceOf<T>, <T as frame_system::Trait>::AccountId {
|
||||
/// All validators have been rewarded by the first balance; the second is the remainder
|
||||
/// from the maximum amount of reward.
|
||||
Reward(Balance, Balance),
|
||||
@@ -1423,7 +1423,7 @@ impl<T: Trait> Module<T> {
|
||||
});
|
||||
all_nominators.extend(nominator_votes);
|
||||
|
||||
let maybe_phragmen_result = phragmen::elect::<_, _, _, T::CurrencyToVote>(
|
||||
let maybe_phragmen_result = sp_phragmen::elect::<_, _, _, T::CurrencyToVote>(
|
||||
Self::validator_count() as usize,
|
||||
Self::minimum_validator_count().max(1) as usize,
|
||||
all_validators,
|
||||
@@ -1442,7 +1442,7 @@ impl<T: Trait> Module<T> {
|
||||
let to_balance = |e: ExtendedBalance|
|
||||
<T::CurrencyToVote as Convert<ExtendedBalance, BalanceOf<T>>>::convert(e);
|
||||
|
||||
let mut supports = phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
|
||||
let mut supports = sp_phragmen::build_support_map::<_, _, _, T::CurrencyToVote>(
|
||||
&elected_stashes,
|
||||
&assignments,
|
||||
Self::slashable_balance_of,
|
||||
@@ -1473,7 +1473,7 @@ impl<T: Trait> Module<T> {
|
||||
|
||||
let tolerance = 0_u128;
|
||||
let iterations = 2_usize;
|
||||
phragmen::equalize::<_, _, T::CurrencyToVote, _>(
|
||||
sp_phragmen::equalize::<_, _, T::CurrencyToVote, _>(
|
||||
staked_assignments,
|
||||
&mut supports,
|
||||
tolerance,
|
||||
@@ -1600,7 +1600,7 @@ impl<T: Trait> Module<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Trait> session::OnSessionEnding<T::AccountId> for Module<T> {
|
||||
impl<T: Trait> pallet_session::OnSessionEnding<T::AccountId> for Module<T> {
|
||||
fn on_session_ending(_ending: SessionIndex, start_session: SessionIndex) -> Option<Vec<T::AccountId>> {
|
||||
Self::ensure_storage_upgraded();
|
||||
Self::new_session(start_session - 1).map(|(new, _old)| new)
|
||||
@@ -1627,13 +1627,13 @@ impl<T: Trait> OnFreeBalanceZero<T::AccountId> for Module<T> {
|
||||
/// * 20 points to the block producer for producing a (non-uncle) block in the relay chain,
|
||||
/// * 2 points to the block producer for each reference to a previously unreferenced uncle, and
|
||||
/// * 1 point to the producer of each referenced uncle block.
|
||||
impl<T: Trait + authorship::Trait> authorship::EventHandler<T::AccountId, T::BlockNumber> for Module<T> {
|
||||
impl<T: Trait + pallet_authorship::Trait> pallet_authorship::EventHandler<T::AccountId, T::BlockNumber> for Module<T> {
|
||||
fn note_author(author: T::AccountId) {
|
||||
Self::reward_by_ids(vec![(author, 20)]);
|
||||
}
|
||||
fn note_uncle(author: T::AccountId, _age: T::BlockNumber) {
|
||||
Self::reward_by_ids(vec![
|
||||
(<authorship::Module<T>>::author(), 2),
|
||||
(<pallet_authorship::Module<T>>::author(), 2),
|
||||
(author, 1)
|
||||
])
|
||||
}
|
||||
@@ -1668,19 +1668,19 @@ impl<T: Trait> SelectInitialValidators<T::AccountId> for Module<T> {
|
||||
}
|
||||
|
||||
/// This is intended to be used with `FilterHistoricalOffences`.
|
||||
impl <T: Trait> OnOffenceHandler<T::AccountId, session::historical::IdentificationTuple<T>> for Module<T> where
|
||||
T: session::Trait<ValidatorId = <T as system::Trait>::AccountId>,
|
||||
T: session::historical::Trait<
|
||||
FullIdentification = Exposure<<T as system::Trait>::AccountId, BalanceOf<T>>,
|
||||
impl <T: Trait> OnOffenceHandler<T::AccountId, pallet_session::historical::IdentificationTuple<T>> for Module<T> where
|
||||
T: pallet_session::Trait<ValidatorId = <T as frame_system::Trait>::AccountId>,
|
||||
T: pallet_session::historical::Trait<
|
||||
FullIdentification = Exposure<<T as frame_system::Trait>::AccountId, BalanceOf<T>>,
|
||||
FullIdentificationOf = ExposureOf<T>,
|
||||
>,
|
||||
T::SessionHandler: session::SessionHandler<<T as system::Trait>::AccountId>,
|
||||
T::OnSessionEnding: session::OnSessionEnding<<T as system::Trait>::AccountId>,
|
||||
T::SelectInitialValidators: session::SelectInitialValidators<<T as system::Trait>::AccountId>,
|
||||
T::ValidatorIdOf: Convert<<T as system::Trait>::AccountId, Option<<T as system::Trait>::AccountId>>
|
||||
T::SessionHandler: pallet_session::SessionHandler<<T as frame_system::Trait>::AccountId>,
|
||||
T::OnSessionEnding: pallet_session::OnSessionEnding<<T as frame_system::Trait>::AccountId>,
|
||||
T::SelectInitialValidators: pallet_session::SelectInitialValidators<<T as frame_system::Trait>::AccountId>,
|
||||
T::ValidatorIdOf: Convert<<T as frame_system::Trait>::AccountId, Option<<T as frame_system::Trait>::AccountId>>
|
||||
{
|
||||
fn on_offence(
|
||||
offenders: &[OffenceDetails<T::AccountId, session::historical::IdentificationTuple<T>>],
|
||||
offenders: &[OffenceDetails<T::AccountId, pallet_session::historical::IdentificationTuple<T>>],
|
||||
slash_fraction: &[Perbill],
|
||||
slash_session: SessionIndex,
|
||||
) {
|
||||
|
||||
@@ -25,7 +25,7 @@ pub const CURRENT_VERSION: VersionNumber = 1;
|
||||
#[cfg(any(test, feature = "migrate"))]
|
||||
mod inner {
|
||||
use crate::{Store, Module, Trait};
|
||||
use support::{StorageLinkedMap, StorageValue};
|
||||
use frame_support::{StorageLinkedMap, StorageValue};
|
||||
use sp_std::vec::Vec;
|
||||
use super::{CURRENT_VERSION, VersionNumber};
|
||||
|
||||
@@ -51,21 +51,21 @@ mod inner {
|
||||
);
|
||||
|
||||
if let Err(e) = res {
|
||||
support::print("Encountered error in migration of Staking::Nominators map.");
|
||||
frame_support::print("Encountered error in migration of Staking::Nominators map.");
|
||||
if e.is_none() {
|
||||
support::print("Staking::Nominators map reinitialized");
|
||||
frame_support::print("Staking::Nominators map reinitialized");
|
||||
}
|
||||
}
|
||||
|
||||
support::print("Finished migrating Staking storage to v1.");
|
||||
frame_support::print("Finished migrating Staking storage to v1.");
|
||||
}
|
||||
|
||||
pub(super) fn perform_migrations<T: Trait>() {
|
||||
<Module<T> as Store>::StorageVersion::mutate(|version| {
|
||||
if *version < MIN_SUPPORTED_VERSION {
|
||||
support::print("Cannot migrate staking storage because version is less than\
|
||||
frame_support::print("Cannot migrate staking storage because version is less than\
|
||||
minimum.");
|
||||
support::print(*version);
|
||||
frame_support::print(*version);
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ use sp_runtime::curve::PiecewiseLinear;
|
||||
use sp_runtime::traits::{IdentityLookup, Convert, OpaqueKeys, OnInitialize, SaturatedConversion};
|
||||
use sp_runtime::testing::{Header, UintAuthorityId};
|
||||
use sp_staking::{SessionIndex, offence::{OffenceDetails, OnOffenceHandler}};
|
||||
use primitives::{H256, crypto::key_types};
|
||||
use sp_core::{H256, crypto::key_types};
|
||||
use sp_io;
|
||||
use support::{
|
||||
use frame_support::{
|
||||
assert_ok, impl_outer_origin, parameter_types, StorageLinkedMap, StorageValue,
|
||||
traits::{Currency, Get, FindAuthor},
|
||||
weights::Weight,
|
||||
@@ -55,7 +55,7 @@ thread_local! {
|
||||
}
|
||||
|
||||
pub struct TestSessionHandler;
|
||||
impl session::SessionHandler<AccountId> for TestSessionHandler {
|
||||
impl pallet_session::SessionHandler<AccountId> for TestSessionHandler {
|
||||
const KEY_TYPE_IDS: &'static [KeyTypeId] = &[key_types::DUMMY];
|
||||
|
||||
fn on_genesis_session<Ks: OpaqueKeys>(_validators: &[(AccountId, Ks)]) {}
|
||||
@@ -99,14 +99,14 @@ impl Get<EraIndex> for SlashDeferDuration {
|
||||
}
|
||||
|
||||
impl_outer_origin!{
|
||||
pub enum Origin for Test {}
|
||||
pub enum Origin for Test where system = frame_system {}
|
||||
}
|
||||
|
||||
/// Author of block is always 11
|
||||
pub struct Author11;
|
||||
impl FindAuthor<u64> for Author11 {
|
||||
fn find_author<'a, I>(_digests: I) -> Option<u64>
|
||||
where I: 'a + IntoIterator<Item=(support::ConsensusEngineId, &'a [u8])>
|
||||
where I: 'a + IntoIterator<Item=(frame_support::ConsensusEngineId, &'a [u8])>
|
||||
{
|
||||
Some(11)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ parameter_types! {
|
||||
pub const MaximumBlockLength: u32 = 2 * 1024;
|
||||
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 = BlockNumber;
|
||||
@@ -142,7 +142,7 @@ parameter_types! {
|
||||
pub const TransferFee: Balance = 0;
|
||||
pub const CreationFee: Balance = 0;
|
||||
}
|
||||
impl balances::Trait for Test {
|
||||
impl pallet_balances::Trait for Test {
|
||||
type Balance = Balance;
|
||||
type OnFreeBalanceZero = Staking;
|
||||
type OnNewAccount = ();
|
||||
@@ -159,10 +159,10 @@ parameter_types! {
|
||||
pub const UncleGenerations: u64 = 0;
|
||||
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(25);
|
||||
}
|
||||
impl session::Trait for Test {
|
||||
type OnSessionEnding = session::historical::NoteHistoricalRoot<Test, Staking>;
|
||||
impl pallet_session::Trait for Test {
|
||||
type OnSessionEnding = pallet_session::historical::NoteHistoricalRoot<Test, Staking>;
|
||||
type Keys = UintAuthorityId;
|
||||
type ShouldEndSession = session::PeriodicSessions<Period, Offset>;
|
||||
type ShouldEndSession = pallet_session::PeriodicSessions<Period, Offset>;
|
||||
type SessionHandler = TestSessionHandler;
|
||||
type Event = ();
|
||||
type ValidatorId = AccountId;
|
||||
@@ -171,11 +171,11 @@ impl session::Trait for Test {
|
||||
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
|
||||
}
|
||||
|
||||
impl session::historical::Trait for Test {
|
||||
impl pallet_session::historical::Trait for Test {
|
||||
type FullIdentification = crate::Exposure<AccountId, Balance>;
|
||||
type FullIdentificationOf = crate::ExposureOf<Test>;
|
||||
}
|
||||
impl authorship::Trait for Test {
|
||||
impl pallet_authorship::Trait for Test {
|
||||
type FindAuthor = Author11;
|
||||
type UncleGenerations = UncleGenerations;
|
||||
type FilterUncle = ();
|
||||
@@ -184,7 +184,7 @@ impl authorship::Trait for Test {
|
||||
parameter_types! {
|
||||
pub const MinimumPeriod: u64 = 5;
|
||||
}
|
||||
impl timestamp::Trait for Test {
|
||||
impl pallet_timestamp::Trait for Test {
|
||||
type Moment = u64;
|
||||
type OnTimestampSet = ();
|
||||
type MinimumPeriod = MinimumPeriod;
|
||||
@@ -205,8 +205,8 @@ parameter_types! {
|
||||
pub const RewardCurve: &'static PiecewiseLinear<'static> = &I_NPOS;
|
||||
}
|
||||
impl Trait for Test {
|
||||
type Currency = balances::Module<Self>;
|
||||
type Time = timestamp::Module<Self>;
|
||||
type Currency = pallet_balances::Module<Self>;
|
||||
type Time = pallet_timestamp::Module<Self>;
|
||||
type CurrencyToVote = CurrencyToVoteHandler;
|
||||
type RewardRemainder = ();
|
||||
type Event = ();
|
||||
@@ -214,7 +214,7 @@ impl Trait for Test {
|
||||
type Reward = ();
|
||||
type SessionsPerEra = SessionsPerEra;
|
||||
type SlashDeferDuration = SlashDeferDuration;
|
||||
type SlashCancelOrigin = system::EnsureRoot<Self::AccountId>;
|
||||
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
|
||||
type BondingDuration = BondingDuration;
|
||||
type SessionInterface = Self;
|
||||
type RewardCurve = RewardCurve;
|
||||
@@ -291,7 +291,7 @@ impl ExtBuilder {
|
||||
}
|
||||
pub fn build(self) -> sp_io::TestExternalities {
|
||||
self.set_associated_consts();
|
||||
let mut storage = system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let mut storage = frame_system::GenesisConfig::default().build_storage::<Test>().unwrap();
|
||||
let balance_factor = if self.existential_deposit > 0 {
|
||||
256
|
||||
} else {
|
||||
@@ -303,7 +303,7 @@ impl ExtBuilder {
|
||||
.map(|x| ((x + 1) * 10 + 1) as u64)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let _ = balances::GenesisConfig::<Test>{
|
||||
let _ = pallet_balances::GenesisConfig::<Test>{
|
||||
balances: vec![
|
||||
(1, 10 * balance_factor),
|
||||
(2, 20 * balance_factor),
|
||||
@@ -351,7 +351,7 @@ impl ExtBuilder {
|
||||
..Default::default()
|
||||
}.assimilate_storage(&mut storage);
|
||||
|
||||
let _ = session::GenesisConfig::<Test> {
|
||||
let _ = pallet_session::GenesisConfig::<Test> {
|
||||
keys: validators.iter().map(|x| (*x, UintAuthorityId(*x))).collect(),
|
||||
}.assimilate_storage(&mut storage);
|
||||
|
||||
@@ -366,10 +366,10 @@ impl ExtBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
pub type System = system::Module<Test>;
|
||||
pub type Balances = balances::Module<Test>;
|
||||
pub type Session = session::Module<Test>;
|
||||
pub type Timestamp = timestamp::Module<Test>;
|
||||
pub type System = frame_system::Module<Test>;
|
||||
pub type Balances = pallet_balances::Module<Test>;
|
||||
pub type Session = pallet_session::Module<Test>;
|
||||
pub type Timestamp = pallet_timestamp::Module<Test>;
|
||||
pub type Staking = Module<Test>;
|
||||
|
||||
pub fn check_exposure_all() {
|
||||
@@ -481,7 +481,7 @@ pub fn validator_controllers() -> Vec<AccountId> {
|
||||
}
|
||||
|
||||
pub fn on_offence_in_era(
|
||||
offenders: &[OffenceDetails<AccountId, session::historical::IdentificationTuple<Test>>],
|
||||
offenders: &[OffenceDetails<AccountId, pallet_session::historical::IdentificationTuple<Test>>],
|
||||
slash_fraction: &[Perbill],
|
||||
era: EraIndex,
|
||||
) {
|
||||
@@ -503,7 +503,7 @@ pub fn on_offence_in_era(
|
||||
}
|
||||
|
||||
pub fn on_offence_now(
|
||||
offenders: &[OffenceDetails<AccountId, session::historical::IdentificationTuple<Test>>],
|
||||
offenders: &[OffenceDetails<AccountId, pallet_session::historical::IdentificationTuple<Test>>],
|
||||
slash_fraction: &[Perbill],
|
||||
) {
|
||||
let now = Staking::current_era();
|
||||
|
||||
@@ -53,7 +53,7 @@ use super::{
|
||||
NegativeImbalanceOf, UnappliedSlash,
|
||||
};
|
||||
use sp_runtime::traits::{Zero, Saturating};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
StorageMap, StorageDoubleMap,
|
||||
traits::{Currency, OnUnbalanced, Imbalance},
|
||||
};
|
||||
|
||||
@@ -20,7 +20,7 @@ use super::*;
|
||||
use mock::*;
|
||||
use sp_runtime::{assert_eq_error_rate, traits::OnInitialize};
|
||||
use sp_staking::offence::OffenceDetails;
|
||||
use support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}};
|
||||
use frame_support::{assert_ok, assert_noop, traits::{Currency, ReservableCurrency}};
|
||||
use substrate_test_utils::assert_eq_uvec;
|
||||
|
||||
#[test]
|
||||
@@ -1688,9 +1688,9 @@ fn reward_validator_slashing_validator_doesnt_overflow() {
|
||||
#[test]
|
||||
fn reward_from_authorship_event_handler_works() {
|
||||
ExtBuilder::default().build().execute_with(|| {
|
||||
use authorship::EventHandler;
|
||||
use pallet_authorship::EventHandler;
|
||||
|
||||
assert_eq!(<authorship::Module<Test>>::author(), 11);
|
||||
assert_eq!(<pallet_authorship::Module<Test>>::author(), 11);
|
||||
|
||||
<Module<Test>>::note_author(11);
|
||||
<Module<Test>>::note_uncle(21, 1);
|
||||
|
||||
@@ -10,11 +10,11 @@ codec = { package = "parity-scale-codec", version = "1.0.0", default-features =
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io = { path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
support = { package = "frame-support", path = "../support", default-features = false }
|
||||
system = { package = "frame-system", path = "../system", default-features = false }
|
||||
frame-support = { path = "../support", default-features = false }
|
||||
frame-system = { path = "../system", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
primitives = { package = "sp-core", path = "../../primitives/core" }
|
||||
sp-core = { path = "../../primitives/core" }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
@@ -24,6 +24,6 @@ std = [
|
||||
"sp-std/std",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
"support/std",
|
||||
"system/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
]
|
||||
|
||||
@@ -51,10 +51,10 @@
|
||||
//! This is an example of a module that exposes a privileged function:
|
||||
//!
|
||||
//! ```
|
||||
//! use support::{decl_module, dispatch};
|
||||
//! use system::ensure_root;
|
||||
//! use frame_support::{decl_module, dispatch};
|
||||
//! use frame_system::{self as system, ensure_root};
|
||||
//!
|
||||
//! 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 {
|
||||
@@ -90,15 +90,15 @@ use sp_std::prelude::*;
|
||||
use sp_runtime::{
|
||||
traits::{StaticLookup, Dispatchable}, DispatchError,
|
||||
};
|
||||
use support::{
|
||||
use frame_support::{
|
||||
Parameter, decl_module, decl_event, decl_storage, ensure,
|
||||
weights::SimpleDispatchInfo,
|
||||
};
|
||||
use system::ensure_signed;
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
|
||||
pub trait Trait: system::Trait {
|
||||
pub trait Trait: frame_system::Trait {
|
||||
/// The overarching event type.
|
||||
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
|
||||
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
|
||||
|
||||
/// A sudo-able call.
|
||||
type Proposal: Parameter + Dispatchable<Origin=Self::Origin>;
|
||||
@@ -125,7 +125,7 @@ decl_module! {
|
||||
let sender = ensure_signed(origin)?;
|
||||
ensure!(sender == Self::key(), "only the current sudo key can sudo");
|
||||
|
||||
let res = match proposal.dispatch(system::RawOrigin::Root.into()) {
|
||||
let res = match proposal.dispatch(frame_system::RawOrigin::Root.into()) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
let e: DispatchError = e.into();
|
||||
@@ -175,7 +175,7 @@ decl_module! {
|
||||
|
||||
let who = T::Lookup::lookup(who)?;
|
||||
|
||||
let res = match proposal.dispatch(system::RawOrigin::Signed(who).into()) {
|
||||
let res = match proposal.dispatch(frame_system::RawOrigin::Signed(who).into()) {
|
||||
Ok(_) => true,
|
||||
Err(e) => {
|
||||
let e: DispatchError = e.into();
|
||||
@@ -190,7 +190,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
decl_event!(
|
||||
pub enum Event<T> where AccountId = <T as system::Trait>::AccountId {
|
||||
pub enum Event<T> where AccountId = <T as frame_system::Trait>::AccountId {
|
||||
/// A sudo just took place.
|
||||
Sudid(bool),
|
||||
/// The sudoer just switched identity; the old key is supplied.
|
||||
|
||||
@@ -12,13 +12,13 @@ frame-metadata = { path = "../metadata", default-features = false }
|
||||
sp-std = { path = "../../primitives/std", default-features = false }
|
||||
sp-io ={ path = "../../primitives/io", default-features = false }
|
||||
sp-runtime = { path = "../../primitives/runtime", default-features = false }
|
||||
primitives = { package = "sp-core", path = "../../primitives/core", default-features = false }
|
||||
sp-core = { path = "../../primitives/core", default-features = false }
|
||||
sp-arithmetic = { path = "../../primitives/arithmetic", default-features = false }
|
||||
inherents = { package = "sp-inherents", path = "../../primitives/inherents", default-features = false }
|
||||
frame-support-procedural = { package = "frame-support-procedural", path = "./procedural" }
|
||||
sp-inherents = { path = "../../primitives/inherents", default-features = false }
|
||||
frame-support-procedural = { path = "./procedural" }
|
||||
paste = "0.1.6"
|
||||
once_cell = { version = "0.2.4", default-features = false, optional = true }
|
||||
state-machine = { package = "sp-state-machine", path = "../../primitives/state-machine", optional = true }
|
||||
sp-state-machine = { path = "../../primitives/state-machine", optional = true }
|
||||
bitmask = { version = "0.5.0", default-features = false }
|
||||
impl-trait-for-tuples = "0.1.3"
|
||||
tracing = { version = "0.1.10", optional = true }
|
||||
@@ -40,8 +40,8 @@ std = [
|
||||
"sp-runtime/std",
|
||||
"sp-arithmetic/std",
|
||||
"frame-metadata/std",
|
||||
"inherents/std",
|
||||
"state-machine",
|
||||
"sp-inherents/std",
|
||||
"sp-state-machine",
|
||||
]
|
||||
nightly = []
|
||||
strict = []
|
||||
|
||||
@@ -8,7 +8,7 @@ edition = "2018"
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
frame-support-procedural-tools = { package = "frame-support-procedural-tools", path = "./tools" }
|
||||
frame-support-procedural-tools = { path = "./tools" }
|
||||
|
||||
proc-macro2 = "1.0.6"
|
||||
quote = "1.0.2"
|
||||
|
||||
@@ -79,7 +79,7 @@ fn construct_runtime_parsed(definition: RuntimeDefinition) -> Result<TokenStream
|
||||
&scrate,
|
||||
DeclOuterKind::Origin,
|
||||
)?;
|
||||
let all_modules = decl_all_modules(&name, all_but_system_modules);
|
||||
let all_modules = decl_all_modules(&name, &system_module, all_but_system_modules);
|
||||
|
||||
let dispatch = decl_outer_dispatch(&name, modules.iter(), &scrate);
|
||||
let metadata = decl_runtime_metadata(&name, modules.iter(), &scrate);
|
||||
@@ -308,6 +308,7 @@ fn decl_outer_event_or_origin<'a>(
|
||||
|
||||
fn decl_all_modules<'a>(
|
||||
runtime: &'a Ident,
|
||||
system_name: &'a Ident,
|
||||
module_declarations: impl Iterator<Item = &'a ModuleDeclaration>,
|
||||
) -> TokenStream2 {
|
||||
let mut types = TokenStream2::new();
|
||||
@@ -335,7 +336,7 @@ fn decl_all_modules<'a>(
|
||||
);
|
||||
|
||||
quote!(
|
||||
pub type System = system::Module<#runtime>;
|
||||
pub type System = #system_name::Module<#runtime>;
|
||||
#types
|
||||
type AllModules = ( #all_modules );
|
||||
)
|
||||
|
||||
@@ -243,7 +243,7 @@ impl ModuleDeclaration {
|
||||
.collect();
|
||||
res.extend(
|
||||
["Event", "Config"]
|
||||
.into_iter()
|
||||
.iter()
|
||||
.map(|name| ModulePart::with_generics(name, span)),
|
||||
);
|
||||
res
|
||||
@@ -345,7 +345,7 @@ impl ModulePart {
|
||||
|
||||
pub fn is_included_in_default(&self) -> bool {
|
||||
["Module", "Call", "Storage", "Event", "Config"]
|
||||
.into_iter()
|
||||
.iter()
|
||||
.any(|name| self.name == name)
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
frame-support-procedural-tools-derive = { package = "frame-support-procedural-tools-derive", path = "./derive" }
|
||||
frame-support-procedural-tools-derive = { path = "./derive" }
|
||||
proc-macro2 = "1.0.6"
|
||||
quote = "1.0.2"
|
||||
syn = { version = "1.0.7", features = ["full", "visit"] }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user