mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 20:11:03 +00:00
Add ProxyRemoved event (#11085)
This commit is contained in:
@@ -570,6 +570,13 @@ pub mod pallet {
|
|||||||
proxy_type: T::ProxyType,
|
proxy_type: T::ProxyType,
|
||||||
delay: T::BlockNumber,
|
delay: T::BlockNumber,
|
||||||
},
|
},
|
||||||
|
/// A proxy was removed.
|
||||||
|
ProxyRemoved {
|
||||||
|
delegator: T::AccountId,
|
||||||
|
delegatee: T::AccountId,
|
||||||
|
proxy_type: T::ProxyType,
|
||||||
|
delay: T::BlockNumber,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Old name generated by `decl_event`.
|
/// Old name generated by `decl_event`.
|
||||||
@@ -712,7 +719,11 @@ impl<T: Config> Pallet<T> {
|
|||||||
) -> DispatchResult {
|
) -> DispatchResult {
|
||||||
Proxies::<T>::try_mutate_exists(delegator, |x| {
|
Proxies::<T>::try_mutate_exists(delegator, |x| {
|
||||||
let (mut proxies, old_deposit) = x.take().ok_or(Error::<T>::NotFound)?;
|
let (mut proxies, old_deposit) = x.take().ok_or(Error::<T>::NotFound)?;
|
||||||
let proxy_def = ProxyDefinition { delegate: delegatee, proxy_type, delay };
|
let proxy_def = ProxyDefinition {
|
||||||
|
delegate: delegatee.clone(),
|
||||||
|
proxy_type: proxy_type.clone(),
|
||||||
|
delay,
|
||||||
|
};
|
||||||
let i = proxies.binary_search(&proxy_def).ok().ok_or(Error::<T>::NotFound)?;
|
let i = proxies.binary_search(&proxy_def).ok().ok_or(Error::<T>::NotFound)?;
|
||||||
proxies.remove(i);
|
proxies.remove(i);
|
||||||
let new_deposit = Self::deposit(proxies.len() as u32);
|
let new_deposit = Self::deposit(proxies.len() as u32);
|
||||||
@@ -724,6 +735,12 @@ impl<T: Config> Pallet<T> {
|
|||||||
if !proxies.is_empty() {
|
if !proxies.is_empty() {
|
||||||
*x = Some((proxies, new_deposit))
|
*x = Some((proxies, new_deposit))
|
||||||
}
|
}
|
||||||
|
Self::deposit_event(Event::<T>::ProxyRemoved {
|
||||||
|
delegator: delegator.clone(),
|
||||||
|
delegatee,
|
||||||
|
proxy_type,
|
||||||
|
delay,
|
||||||
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -436,13 +436,49 @@ fn add_remove_proxies_works() {
|
|||||||
Error::<Test>::NotFound
|
Error::<Test>::NotFound
|
||||||
);
|
);
|
||||||
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 4, ProxyType::JustUtility, 0));
|
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 4, ProxyType::JustUtility, 0));
|
||||||
|
System::assert_last_event(
|
||||||
|
ProxyEvent::ProxyRemoved {
|
||||||
|
delegator: 1,
|
||||||
|
delegatee: 4,
|
||||||
|
proxy_type: ProxyType::JustUtility,
|
||||||
|
delay: 0,
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
assert_eq!(Balances::reserved_balance(1), 4);
|
assert_eq!(Balances::reserved_balance(1), 4);
|
||||||
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 3, ProxyType::Any, 0));
|
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 3, ProxyType::Any, 0));
|
||||||
assert_eq!(Balances::reserved_balance(1), 3);
|
assert_eq!(Balances::reserved_balance(1), 3);
|
||||||
|
System::assert_last_event(
|
||||||
|
ProxyEvent::ProxyRemoved {
|
||||||
|
delegator: 1,
|
||||||
|
delegatee: 3,
|
||||||
|
proxy_type: ProxyType::Any,
|
||||||
|
delay: 0,
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 2, ProxyType::Any, 0));
|
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 2, ProxyType::Any, 0));
|
||||||
assert_eq!(Balances::reserved_balance(1), 2);
|
assert_eq!(Balances::reserved_balance(1), 2);
|
||||||
|
System::assert_last_event(
|
||||||
|
ProxyEvent::ProxyRemoved {
|
||||||
|
delegator: 1,
|
||||||
|
delegatee: 2,
|
||||||
|
proxy_type: ProxyType::Any,
|
||||||
|
delay: 0,
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 2, ProxyType::JustTransfer, 0));
|
assert_ok!(Proxy::remove_proxy(Origin::signed(1), 2, ProxyType::JustTransfer, 0));
|
||||||
assert_eq!(Balances::reserved_balance(1), 0);
|
assert_eq!(Balances::reserved_balance(1), 0);
|
||||||
|
System::assert_last_event(
|
||||||
|
ProxyEvent::ProxyRemoved {
|
||||||
|
delegator: 1,
|
||||||
|
delegatee: 2,
|
||||||
|
proxy_type: ProxyType::JustTransfer,
|
||||||
|
delay: 0,
|
||||||
|
}
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
assert_noop!(
|
assert_noop!(
|
||||||
Proxy::add_proxy(Origin::signed(1), 1, ProxyType::Any, 0),
|
Proxy::add_proxy(Origin::signed(1), 1, ProxyType::Any, 0),
|
||||||
Error::<Test>::NoSelfProxy
|
Error::<Test>::NoSelfProxy
|
||||||
|
|||||||
Reference in New Issue
Block a user