Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add remove_proxies API for pallet-proxies #7557 #12714

Merged
merged 18 commits into from
May 26, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions frame/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ use frame_support::{
traits::{Currency, Get, InstanceFilter, IsSubType, IsType, OriginTrait, ReservableCurrency},
RuntimeDebug,
};
use frame_system::{self as system};
use frame_system::{self as system, ensure_signed};
pub use pallet::*;
use scale_info::TypeInfo;
use sp_io::hashing::blake2_256;
use sp_runtime::{
Expand All @@ -50,8 +51,6 @@ use sp_runtime::{
use sp_std::prelude::*;
pub use weights::WeightInfo;

pub use pallet::*;

type CallHashOf<T> = <<T as Config>::CallHasher as Hash>::Output;

type BalanceOf<T> =
Expand Down Expand Up @@ -252,7 +251,7 @@ pub mod pallet {
) -> DispatchResult {
let who = ensure_signed(origin)?;
let delegate = T::Lookup::lookup(delegate)?;
Self::remove_proxy_delegate(&who, delegate, proxy_type, delay)
Self::remove_all_proxy_delegates(&who, delegate, proxy_type, delay)
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
}

/// Unregister all proxy accounts for the sender.
Expand Down Expand Up @@ -792,4 +791,14 @@ impl<T: Config> Pallet<T> {
let e = call.dispatch(origin);
Self::deposit_event(Event::ProxyExecuted { result: e.map(|_| ()).map_err(|e| e.error) });
}

pub fn remove_all_proxy_delegates(
delegator: &T::AccountId,
delegatee: T::AccountId,
proxy_type: T::ProxyType,
delay: T::BlockNumber,
) -> DispatchResult {
ensure!(delegator != &delegatee, Error::<T>::NoSelfProxy);
Self::remove_proxy_delegate(delegator, delegatee, proxy_type, delay)
}
}