diff --git a/Cargo.lock b/Cargo.lock index d5cc868..30500df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5693,7 +5693,7 @@ dependencies = [ [[package]] name = "neuroweb-node" -version = "1.1.1" +version = "1.3.0" dependencies = [ "clap", "cumulus-client-cli", @@ -5759,7 +5759,7 @@ dependencies = [ [[package]] name = "neuroweb-runtime" -version = "1.2.1" +version = "1.3.0" dependencies = [ "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", @@ -5797,7 +5797,9 @@ dependencies = [ "pallet-evm-precompile-sha3fips", "pallet-evm-precompile-simple", "pallet-identity", + "pallet-multisig", "pallet-preimage", + "pallet-proxy", "pallet-scheduler", "pallet-session", "pallet-timestamp", diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index fc6afd9..5875d5a 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -38,6 +38,7 @@ pallet-aura = { git = "https://github.com/paritytech/substrate", default-feature pallet-authorship = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } +pallet-proxy = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-scheduler = { git = "https://github.com/paritytech/substrate.git", default-features = false, branch = "polkadot-v0.9.40" } pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.40" } @@ -134,6 +135,7 @@ std = [ "pallet-ethereum/std", "pallet-identity/std", "pallet-preimage/std", + "pallet-proxy/std", "pallet-multisig/std", "pallet-scheduler/std", "pallet-session/std", @@ -179,6 +181,7 @@ runtime-benchmarks = [ "pallet-ethereum/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-preimage/runtime-benchmarks", + "pallet-proxy/runtime-benchmarks", "pallet-scheduler/runtime-benchmarks", "pallet-timestamp/runtime-benchmarks", "pallet-treasury/runtime-benchmarks", @@ -209,6 +212,7 @@ try-runtime = [ "pallet-democracy/runtime-benchmarks", "pallet-identity/runtime-benchmarks", "pallet-preimage/try-runtime", + "pallet-proxy/try-runtime", "pallet-scheduler/try-runtime", "pallet-session/try-runtime", "pallet-utility/try-runtime", diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index d3ca350..c5941fe 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -23,7 +23,7 @@ use sp_runtime::{ transaction_validity::{ TransactionSource, TransactionValidity, TransactionValidityError }, - ApplyExtrinsicResult, MultiSignature, + ApplyExtrinsicResult, MultiSignature, RuntimeDebug, }; use sp_std::prelude::*; @@ -31,14 +31,13 @@ use sp_std::prelude::*; use sp_version::NativeVersion; use sp_version::RuntimeVersion; -use codec::{Encode}; -pub use frame_support::traits::EqualPrivilegeOnly; +use codec::{Encode, Decode, MaxEncodedLen}; use frame_support::{ construct_runtime, parameter_types, transactional, traits::{ - AsEnsureOriginWithArg, Currency as PalletCurrency, EitherOfDiverse, Everything, FindAuthor, - ReservableCurrency, Imbalance, OnUnbalanced, ConstU128, ConstU32, ConstU64, ConstU8, - WithdrawReasons + AsEnsureOriginWithArg, Currency as PalletCurrency, EqualPrivilegeOnly, EitherOfDiverse, + Everything, FindAuthor, ReservableCurrency, Imbalance, InstanceFilter, OnUnbalanced, + ConstU128, ConstU32, ConstU64, ConstU8, WithdrawReasons, }, dispatch::DispatchClass, weights::{ @@ -1052,6 +1051,83 @@ impl pallet_identity::Config for Runtime { type WeightInfo = pallet_identity::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 AnnouncementDepositBase: Balance = deposit(1, 8); + pub const AnnouncementDepositFactor: Balance = deposit(0, 66); +} + +/// The type used to represent the kinds of proxying allowed. +#[derive( + Copy, + Clone, + Eq, + PartialEq, + Ord, + PartialOrd, + Encode, + Decode, + RuntimeDebug, + MaxEncodedLen, + scale_info::TypeInfo, +)] +pub enum ProxyType { + Any, + NonTransfer, + Governance, +} +impl Default for ProxyType { + fn default() -> Self { + Self::Any + } +} +impl InstanceFilter for ProxyType { + fn filter(&self, c: &RuntimeCall) -> bool { + match self { + ProxyType::Any => true, + ProxyType::NonTransfer => !matches!( + c, + RuntimeCall::Balances(..) | + RuntimeCall::Assets(..) | + RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) + ), + ProxyType::Governance => matches!( + c, + RuntimeCall::Democracy(..) | + RuntimeCall::Council(..) | + RuntimeCall::Treasury(..) + ), + } + } + 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 RuntimeEvent = RuntimeEvent; + type RuntimeCall = RuntimeCall; + type Currency = Balances; + type ProxyType = ProxyType; + type ProxyDepositBase = ProxyDepositBase; + type ProxyDepositFactor = ProxyDepositFactor; + type MaxProxies = ConstU32<32>; + type WeightInfo = pallet_proxy::weights::SubstrateWeight; + type MaxPending = ConstU32<32>; + type CallHasher = BlakeTwo256; + type AnnouncementDepositBase = AnnouncementDepositBase; + type AnnouncementDepositFactor = AnnouncementDepositFactor; +} + // Create the runtime by composing the FRAME pallets that were previously configured. construct_runtime!( pub enum Runtime where @@ -1068,6 +1144,7 @@ construct_runtime!( ParachainInfo: parachain_info::{Pallet, Storage, Config} = 3, Utility: pallet_utility = 4, Multisig: pallet_multisig = 5, + Proxy: pallet_proxy = 6, // Monetary stuff. Balances: pallet_balances::{Pallet, Call, Storage, Config, Event} = 10, @@ -1118,6 +1195,7 @@ mod benches { [pallet_democracy, Democracy] [pallet_identity, Identity] [pallet_preimage, Preimage] + [pallet_proxy, Proxy] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp] [pallet_collator_selection, CollatorSelection]