-
Notifications
You must be signed in to change notification settings - Fork 47
feat: proxy type for disableling deposit claiming #341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
66449a8
a272df8
1aa8653
daeed42
3b59dd2
a75901f
8e7a2a8
5b5ae0a
8bd1b00
1496925
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -753,11 +753,19 @@ impl pallet_randomness_collective_flip::Config for Runtime {} | |
| Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, scale_info::TypeInfo, | ||
| )] | ||
| pub enum ProxyType { | ||
| /// Allow for any call. | ||
| Any, | ||
| /// Allow for calls that do not move tokens out of the caller's account. | ||
| NonTransfer, | ||
| /// Allow for governance-related calls. | ||
| Governance, | ||
| /// Allow for staking-related calls. | ||
| ParachainStaking, | ||
| /// Allow for calls that cancel proxy information. | ||
| CancelProxy, | ||
| /// Allow for calls that do not result in a deposit being claimed (e.g., for | ||
| /// attestations, delegations, or DIDs). | ||
| NonDepositClaiming, | ||
| } | ||
|
|
||
| impl Default for ProxyType { | ||
|
|
@@ -772,47 +780,132 @@ impl InstanceFilter<Call> for ProxyType { | |
| ProxyType::Any => true, | ||
| ProxyType::NonTransfer => matches!( | ||
| c, | ||
| Call::System(..) | | ||
| Call::Scheduler(..) | | ||
| Call::Timestamp(..) | | ||
| Call::Indices(pallet_indices::Call::claim{..}) | | ||
| Call::Indices(pallet_indices::Call::free{..}) | | ||
| Call::Indices(pallet_indices::Call::freeze{..}) | | ||
| // Specifically omitting Indices `transfer`, `force_transfer` | ||
| // Specifically omitting the entire Balances pallet | ||
| Call::Authorship(..) | | ||
| Call::Session(..) | | ||
| Call::Democracy(..) | | ||
| Call::Council(..) | | ||
| Call::TechnicalCommittee(..) | | ||
| Call::TechnicalMembership(..) | | ||
| Call::Treasury(..) | | ||
| Call::Vesting(pallet_vesting::Call::vest{..}) | | ||
| Call::Vesting(pallet_vesting::Call::vest_other{..}) | | ||
| // Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer` | ||
| Call::Utility(..) | | ||
| Call::ParachainStaking(..) | ||
| Call::Attestation(..) | ||
| | Call::Authorship(..) | ||
| // Excludes `Balances` | ||
| | Call::Council(..) | Call::Ctype(..) | ||
| | Call::Delegation(..) | ||
| | Call::Democracy(..) | ||
| | Call::Did(..) | ||
| | Call::DidLookup(..) | ||
| | Call::Indices( | ||
| // Excludes `force_transfer`, and `transfer` | ||
| pallet_indices::Call::claim { .. } | ||
| | pallet_indices::Call::free { .. } | ||
| | pallet_indices::Call::freeze { .. } | ||
| ) | ||
| // Excludes `KiltLaunch` | ||
| | Call::ParachainStaking(..) | ||
| // Excludes `ParachainSystem` | ||
| | Call::Preimage(..) | ||
| | Call::Proxy(..) | ||
| | Call::Scheduler(..) | ||
| | Call::Session(..) | ||
| // Excludes `Sudo` | ||
| | Call::System(..) | ||
| | Call::TechnicalCommittee(..) | ||
| | Call::TechnicalMembership(..) | ||
| | Call::Timestamp(..) | ||
| | Call::Treasury(..) | ||
| | Call::Utility(..) | ||
| | Call::Vesting( | ||
| // Excludes `force_vested_transfer`, `merge_schedules`, and `vested_transfer` | ||
| pallet_vesting::Call::vest { .. } | ||
| | pallet_vesting::Call::vest_other { .. } | ||
| ) | ||
| | Call::Web3Names(..), | ||
| ), | ||
| ProxyType::NonDepositClaiming => matches!( | ||
| c, | ||
| Call::Attestation( | ||
| // Excludes `reclaim_deposit` | ||
| attestation::Call::add { .. } | ||
| | attestation::Call::remove { .. } | ||
| | attestation::Call::revoke { .. } | ||
| ) | ||
| | Call::Authorship(..) | ||
| // Excludes `Balances` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really want to exclude Balances here?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is true that most calls require sudo origin, but technically by calling the balances pallet you could interact with deposits, no? Should we allow some balance calls in this proxy? Or the whole thing? What do you think?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would say we should not exclude balance transfers here. All calls should be allowed. |
||
| | Call::Council(..) | Call::Ctype(..) | ||
| | Call::Delegation( | ||
| // Excludes `reclaim_deposit` | ||
| delegation::Call::add_delegation { .. } | ||
| | delegation::Call::create_hierarchy { .. } | ||
| | delegation::Call::remove_delegation { .. } | ||
| | delegation::Call::revoke_delegation { .. } | ||
| ) | ||
| | Call::Democracy(..) | ||
| | Call::Did( | ||
| // Excludes `reclaim_deposit` | ||
| did::Call::add_key_agreement_key { .. } | ||
| | did::Call::add_service_endpoint { .. } | ||
| | did::Call::create { .. } | ||
| | did::Call::delete { .. } | ||
| | did::Call::remove_attestation_key { .. } | ||
| | did::Call::remove_delegation_key { .. } | ||
| | did::Call::remove_key_agreement_key { .. } | ||
| | did::Call::remove_service_endpoint { .. } | ||
| | did::Call::set_attestation_key { .. } | ||
| | did::Call::set_authentication_key { .. } | ||
| | did::Call::set_delegation_key { .. } | ||
| | did::Call::submit_did_call { .. } | ||
| ) | ||
| | Call::DidLookup( | ||
| // Excludes `reclaim_deposit` | ||
| pallet_did_lookup::Call::associate_account { .. } | ||
| | pallet_did_lookup::Call::associate_sender { .. } | ||
| | pallet_did_lookup::Call::remove_account_association { .. } | ||
| | pallet_did_lookup::Call::remove_sender_association { .. } | ||
| ) | ||
| | Call::Indices(..) | ||
| // Excludes `KiltLaunch` | ||
| | Call::ParachainStaking(..) | ||
| // Excludes `ParachainSystem` | ||
| | Call::Preimage(..) | ||
| | Call::Proxy(..) | ||
| | Call::Scheduler(..) | ||
| | Call::Session(..) | ||
| // Excludes `Sudo` | ||
| | Call::System(..) | ||
| | Call::TechnicalCommittee(..) | ||
| | Call::TechnicalMembership(..) | ||
| | Call::Timestamp(..) | ||
| | Call::Treasury(..) | ||
| | Call::Utility(..) | ||
| | Call::Vesting(..) | ||
| | Call::Web3Names( | ||
| // Excludes `ban`, and `reclaim_deposit` | ||
| pallet_web3_names::Call::claim { .. } | ||
| | pallet_web3_names::Call::release_by_owner { .. } | ||
| | pallet_web3_names::Call::unban { .. } | ||
| ), | ||
| ), | ||
| ProxyType::Governance => matches!( | ||
| c, | ||
| Call::Democracy(..) | ||
| | Call::Council(..) | Call::TechnicalCommittee(..) | ||
| | Call::Treasury(..) | Call::Utility(..) | ||
| Call::Council(..) | ||
| | Call::Democracy(..) | ||
| | Call::TechnicalCommittee(..) | ||
| | Call::TechnicalMembership(..) | ||
| | Call::Treasury(..) | Call::Utility(..) | ||
| ), | ||
| ProxyType::ParachainStaking => { | ||
| matches!(c, Call::ParachainStaking(..) | Call::Session(..) | Call::Utility(..)) | ||
| } | ||
| ProxyType::CancelProxy => { | ||
| matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })) | ||
| } | ||
| ProxyType::CancelProxy => matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. })), | ||
| } | ||
| } | ||
| fn is_superset(&self, o: &Self) -> bool { | ||
| match (self, o) { | ||
| (x, y) if x == y => true, | ||
| // "anything" always contains any subset | ||
| (ProxyType::Any, _) => true, | ||
| (_, ProxyType::Any) => false, | ||
| // reclaiming deposits is part of NonTransfer but not in NonDepositClaiming | ||
| (ProxyType::NonDepositClaiming, ProxyType::NonTransfer) => false, | ||
| // everything except NonTransfer and Any is part of NonDepositClaiming | ||
| (ProxyType::NonDepositClaiming, _) => true, | ||
| // Transfers are part of NonDepositClaiming but not in NonTransfer | ||
| (ProxyType::NonTransfer, ProxyType::NonDepositClaiming) => false, | ||
| // everything except NonDepositClaiming and Any is part of NonTransfer | ||
| (ProxyType::NonTransfer, _) => true, | ||
| _ => false, | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.