diff --git a/Cargo.lock b/Cargo.lock index 6a6661728..5ff2d88df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1171,7 +1171,7 @@ dependencies = [ [[package]] name = "datahighway" -version = "3.0.4" +version = "3.0.6" dependencies = [ "datahighway-runtime", "frame-benchmarking", @@ -1229,7 +1229,7 @@ dependencies = [ [[package]] name = "datahighway-runtime" -version = "3.0.4" +version = "3.0.6" dependencies = [ "chrono", "exchange-rate", @@ -1266,6 +1266,7 @@ dependencies = [ "pallet-membership", "pallet-multisig", "pallet-offences", + "pallet-proxy", "pallet-randomness-collective-flip", "pallet-scheduler", "pallet-session", @@ -3579,7 +3580,7 @@ dependencies = [ [[package]] name = "mining-eligibility-proxy" -version = "3.0.4" +version = "3.0.6" dependencies = [ "account-set", "chrono", @@ -3848,7 +3849,7 @@ dependencies = [ [[package]] name = "module-primitives" -version = "3.0.4" +version = "3.0.6" dependencies = [ "bitmask", "parity-scale-codec", @@ -4369,6 +4370,22 @@ dependencies = [ "sp-std", ] +[[package]] +name = "pallet-proxy" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b3aeaa4977795fce9a1b19d0bd0f0819602b18eb262fdaea1be620f0efe55c" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "serde", + "sp-core", + "sp-io", + "sp-runtime", + "sp-std", +] + [[package]] name = "pallet-randomness-collective-flip" version = "3.0.0" diff --git a/node/Cargo.toml b/node/Cargo.toml index eb3dc5f7f..a3c614854 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -3,7 +3,7 @@ authors = ['MXC Foundation gGmbH ', 'Luke Schoen ', 'MXC Foundation GmbH ', 'Luke Schoen'] edition = '2018' diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 5a6725ff0..6fe406299 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -2,7 +2,7 @@ authors = ['MXC Foundation gGmbH ', 'Luke Schoen ', 'Ilya Beregovskiy '] edition = '2018' name = 'datahighway-runtime' -version = '3.0.5' +version = '3.0.6' [package.metadata.docs.rs] targets = ['x86_64-unknown-linux-gnu'] @@ -30,6 +30,7 @@ pallet-membership = { version = '3.0.0', default-features = false } pallet-multisig = { version = '3.0.0', default-features = false } pallet-offences = { version = '3.0.0', default-features = false } pallet-randomness-collective-flip = { version = '3.0.0', default-features = false } +pallet-proxy = { version = '3.0.0', default-features = false } pallet-scheduler = { version = '3.0.0', default-features = false } pallet-session = { version = '3.0.0', default-features = false } pallet-staking = { version = '3.0.0', default-features = false } @@ -115,6 +116,7 @@ std = [ 'pallet-membership/std', 'pallet-multisig/std', 'pallet-offences/std', + 'pallet-proxy/std', 'pallet-tips/std', 'pallet-treasury/std', 'pallet-randomness-collective-flip/std', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 110637d9a..a5bc50833 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -73,9 +73,11 @@ pub use frame_support::{ construct_runtime, parameter_types, debug, + RuntimeDebug, traits::{ Currency, Imbalance, + InstanceFilter, Contains, ContainsLengthBound, OnUnbalanced, @@ -197,7 +199,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { spec_name: create_runtime_str!("datahighway"), impl_name: create_runtime_str!("datahighway"), authoring_version: 2, - spec_version: 8, + spec_version: 9, impl_version: 2, apis: RUNTIME_API_VERSIONS, transaction_version: 2, @@ -316,6 +318,74 @@ impl pallet_multisig::Config for Runtime { type WeightInfo = pallet_multisig::weights::SubstrateWeight; } +parameter_types! { + // One storage item; key size 32, value size 8; . + pub const ProxyDepositBase: Balance = deposit(1, 8); + // Additional storage item size of 33 bytes. + pub const ProxyDepositFactor: Balance = deposit(0, 33); + pub const MaxProxies: u16 = 32; + pub const AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); + pub const MaxPending: u16 = 32; +} + +/// The type used to represent the kinds of proxying allowed. +#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, + Staking, +} +impl Default for ProxyType { fn default() -> Self { Self::Any } } +impl InstanceFilter for ProxyType { + fn filter(&self, c: &Call) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => !matches!( + c, + Call::Balances(..) | + // Call::Vesting(pallet_vesting::Call::vested_transfer(..)) | + Call::Indices(pallet_indices::Call::transfer(..)) + ), + ProxyType::Governance => matches!( + c, + Call::Democracy(..) | + Call::Council(..) | + // Call::Society(..) | + Call::TechnicalCommittee(..) | + Call::Elections(..) | + Call::Treasury(..) + ), + ProxyType::Staking => matches!(c, Call::Staking(..)), + } + } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + (ProxyType::NonTransfer, _) => true, + _ => false, + } + } +} + +impl pallet_proxy::Config for Runtime { + type Event = Event; + type Call = Call; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = MaxProxies; + type WeightInfo = pallet_proxy::weights::SubstrateWeight; + type MaxPending = MaxPending; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; +} + parameter_types! { pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * RuntimeBlockWeights::get().max_block; @@ -1113,6 +1183,7 @@ construct_runtime!( RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Call, Storage}, Identity: pallet_identity::{Module, Call, Storage, Event}, Scheduler: pallet_scheduler::{Module, Call, Storage, Event}, + Proxy: pallet_proxy::{Module, Call, Storage, Event}, Multisig: pallet_multisig::{Module, Call, Storage, Event}, Bounties: pallet_bounties::{Module, Call, Storage, Event}, Tips: pallet_tips::{Module, Call, Storage, Event},