Skip to content

Commit

Permalink
feat: add mutisig pallet (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
ytqaljn authored Nov 13, 2023
1 parent 5eefce8 commit efb26aa
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 3 deletions.
33 changes: 33 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ pallet-indices = { version = "4.0.0-dev", default-features = false, git = "http
pallet-membership = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
# pallet-message-queue
pallet-mmr = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
# pallet-multisig
pallet-multisig = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
# pallet-nomination-pools
# pallet-nomination-pools-benchmarking
# pallet-nomination-pools-runtime-api
pallet-offences = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
# pallet-offences-benchmarking
pallet-preimage = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
# pallet-proxy
pallet-proxy = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
pallet-insecure-randomness-collective-flip = { version = "4.0.0-dev", default-features = false, git = "https://github.com/CESSProject/substrate", branch = "cess-polkadot-v0.9.42" }
# pallet-ranked-collective
# pallet-recovery
Expand Down Expand Up @@ -156,6 +156,7 @@ std = [
"frame-system-benchmarking?/std",
"pallet-im-online/std",
"pallet-membership/std",
"pallet-multisig/std",
"pallet-offences/std",
"pallet-scheduler/std",
"pallet-session/std",
Expand All @@ -169,6 +170,7 @@ std = [
"pallet-cacher/std",
"pallet-cess-treasury/std",
"pallet-preimage/std",
"pallet-proxy/std",
"pallet-assets/std",
"pallet-child-bounties/std",
"pallet-mmr/std",
Expand Down Expand Up @@ -269,8 +271,10 @@ try-runtime = [
"pallet-indices/try-runtime",
"pallet-membership/try-runtime",
"pallet-mmr/try-runtime",
"pallet-multisig/try-runtime",
"pallet-offences/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
"pallet-insecure-randomness-collective-flip/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-session/try-runtime",
Expand Down
90 changes: 89 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub use frame_support::{
},
ConstantMultiplier, IdentityFee, Weight,
},
PalletId, StorageValue,
PalletId, StorageValue, RuntimeDebug,
};

use frame_system::{
Expand Down Expand Up @@ -933,6 +933,92 @@ impl pallet_sudo::Config for Runtime {

impl pallet_evm_chain_id::Config for Runtime {}

parameter_types! {
// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
pub const DepositBase: Balance = deposit(1, 88);
// Additional storage item size of 32 bytes.
pub const DepositFactor: Balance = deposit(0, 32);
}

impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU32<100>;
type WeightInfo = pallet_multisig::weights::SubstrateWeight<Runtime>;
}

/// 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,
Staking,
}
impl Default for ProxyType {
fn default() -> Self {
Self::Any
}
}
impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer => !matches!(
c,
RuntimeCall::Balances(..) |
RuntimeCall::Assets(..) |
RuntimeCall::Indices(pallet_indices::Call::transfer { .. })
),
ProxyType::Governance => matches!(
c,
RuntimeCall::Council(..) |
RuntimeCall::TechnicalCommittee(..) |
RuntimeCall::Treasury(..)
),
ProxyType::Staking => matches!(c, RuntimeCall::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 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<Runtime>;
type MaxPending = ConstU32<32>;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

/***
* Add This Block
*/
Expand Down Expand Up @@ -1520,6 +1606,7 @@ construct_runtime!(

// Account lookup
Indices: pallet_indices = 7,
Proxy: pallet_proxy = 8,

// Tokens & Fees
Balances: pallet_balances = 10,
Expand Down Expand Up @@ -1547,6 +1634,7 @@ construct_runtime!(
Treasury: pallet_treasury = 43,
Bounties: pallet_bounties = 44,
ChildBounties: pallet_child_bounties = 45,
Multisig: pallet_multisig = 46,

// Smart contracts
Contracts: pallet_contracts = 50,
Expand Down

0 comments on commit efb26aa

Please sign in to comment.