From 01ac3cf083d6ba7bf34a87f7465b6ed56b9bdae2 Mon Sep 17 00:00:00 2001 From: b-yap <2826165+b-yap@users.noreply.github.com> Date: Mon, 6 Nov 2023 22:30:01 +0800 Subject: [PATCH] https://github.com/pendulum-chain/pendulum/pull/325#discussion_r1374834036, https://github.com/pendulum-chain/pendulum/pull/325#discussion_r1374835562, --- runtime/amplitude/src/lib.rs | 9 +++-- runtime/common/src/proxy_type.rs | 11 ------ runtime/foucoco/src/lib.rs | 59 +++++--------------------------- runtime/pendulum/src/lib.rs | 9 +++-- 4 files changed, 22 insertions(+), 66 deletions(-) diff --git a/runtime/amplitude/src/lib.rs b/runtime/amplitude/src/lib.rs index bd8c4ca8ec..157ddfa37e 100644 --- a/runtime/amplitude/src/lib.rs +++ b/runtime/amplitude/src/lib.rs @@ -1230,8 +1230,13 @@ impl InstanceFilter for ProxyType { } // Determines whether self matches at least everything that o does. - fn is_superset(&self, _o: &Self) -> bool { - true + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + _ => false, + } } } diff --git a/runtime/common/src/proxy_type.rs b/runtime/common/src/proxy_type.rs index ae4d8607f4..f7beeea23a 100644 --- a/runtime/common/src/proxy_type.rs +++ b/runtime/common/src/proxy_type.rs @@ -17,17 +17,6 @@ use sp_runtime::RuntimeDebug; pub enum ProxyType { /// Allows all runtime calls for proxy account Any, - // /// Allows only NonTransfer runtime calls for proxy account - // /// To know exact calls check InstanceFilter inmplementation for ProxyTypes - // NonTransfer, - // /// All Runtime calls from Pallet Balances allowed for proxy account - // Balances, - // /// Only provide_judgement call from pallet identity allowed for proxy account - // IdentityJudgement, - // /// Only reject_announcement call from pallet proxy allowed for proxy account - // CancelProxy, - // /// Only claim_reward call from pallet staking is allowed for proxy account - // StakerRewardClaim, } impl Default for ProxyType { diff --git a/runtime/foucoco/src/lib.rs b/runtime/foucoco/src/lib.rs index 3af23e7c91..c128a75825 100644 --- a/runtime/foucoco/src/lib.rs +++ b/runtime/foucoco/src/lib.rs @@ -1519,61 +1519,18 @@ impl InstanceFilter for ProxyType { // Always allowed RuntimeCall::Utility no matter type. // Only transactions allowed by Proxy.filter can be executed _ if matches!(c, RuntimeCall::Utility(..)) => true, - ProxyType::Any => true, - // ProxyType::NonTransfer => { - // matches!( - // c, - // RuntimeCall::System(..) - // | RuntimeCall::Identity(..) - // | RuntimeCall::Timestamp(..) - // | RuntimeCall::Multisig(..) - // | RuntimeCall::Proxy(..) - // | RuntimeCall::ParachainSystem(..) - // | RuntimeCall::ParachainInfo(..) - // // Skip entire Balances pallet - // | RuntimeCall::Vesting(pallet_vesting::Call::vest{..}) - // | RuntimeCall::Vesting(pallet_vesting::Call::vest_other{..}) - // // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` - // | RuntimeCall::Session(..) - // | RuntimeCall::XcmpQueue(..) - // | RuntimeCall::PolkadotXcm(..) - // | RuntimeCall::DmpQueue(..) - // ) - // } - // ProxyType::Balances => { - // matches!(c, RuntimeCall::Balances(..)) - // } - // ProxyType::IdentityJudgement => { - // matches!( - // c, - // RuntimeCall::Identity(pallet_identity::Call::provide_judgement { .. }) - // ) - // } - // ProxyType::CancelProxy => { - // matches!( - // c, - // RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) - // ) - // } - // ProxyType::StakerRewardClaim => { - // matches!( - // c, - // RuntimeCall::DappsStaking(parachain_staking::Call::claim_rewards { .. }) - // ) - // } + ProxyType::Any => true } } // Determines whether self matches at least everything that o does. - fn is_superset(&self, _o: &Self) -> bool { - true - // match (self, o) { - // (x, y) if x == y => true, - // (ProxyType::Any, _) => true, - // (_, ProxyType::Any) => false, - // (_, ProxyType::StakerRewardClaim) => true, - // _ => false, - // } + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + _ => false, + } } } diff --git a/runtime/pendulum/src/lib.rs b/runtime/pendulum/src/lib.rs index fd68555ea6..d8db73a48e 100644 --- a/runtime/pendulum/src/lib.rs +++ b/runtime/pendulum/src/lib.rs @@ -965,8 +965,13 @@ impl InstanceFilter for ProxyType { } // Determines whether self matches at least everything that o does. - fn is_superset(&self, _o: &Self) -> bool { - true + fn is_superset(&self, o: &Self) -> bool { + match (self, o) { + (x, y) if x == y => true, + (ProxyType::Any, _) => true, + (_, ProxyType::Any) => false, + _ => false, + } } }