Skip to content

add PureKilled event to proxy pallet #1772

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

Open
wants to merge 2 commits into
base: devnet-ready
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 18 additions & 0 deletions pallets/proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ pub mod pallet {
let (_, deposit) = Proxies::<T>::take(&who);
T::Currency::unreserve(&spawner, deposit);

Self::deposit_event(Event::PureKilled {
pure: who,
spawner,
proxy_type,
disambiguation_index: index,
});

Ok(())
}

Expand Down Expand Up @@ -566,6 +573,17 @@ pub mod pallet {
proxy_type: T::ProxyType,
delay: BlockNumberFor<T>,
},
/// A pure proxy was killed by its spawner.
PureKilled {
// The pure proxy account that was destroyed.
pure: T::AccountId,
// The account that created the pure proxy.
spawner: T::AccountId,
// The proxy type of the pure proxy that was destroyed.
proxy_type: T::ProxyType,
// The index originally passed to `create_pure` when this pure proxy was created.
disambiguation_index: u16,
},
}

#[pallet::error]
Expand Down
22 changes: 21 additions & 1 deletion pallets/proxy/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ fn pure_works() {
anon,
5
));
assert_eq!(Balances::free_balance(6), 0);
assert_ok!(Proxy::proxy(RuntimeOrigin::signed(1), anon, None, call));
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Ok(()) }.into());
assert_eq!(Balances::free_balance(6), 1);
Expand All @@ -943,7 +944,7 @@ fn pure_works() {
None,
call.clone()
));
let de = DispatchError::from(Error::<Test>::NoPermission).stripped();
let de: DispatchError = DispatchError::from(Error::<Test>::NoPermission).stripped();
System::assert_last_event(ProxyEvent::ProxyExecuted { result: Err(de) }.into());
assert_noop!(
Proxy::kill_pure(RuntimeOrigin::signed(1), 1, ProxyType::Any, 0, 1, 0),
Expand All @@ -961,5 +962,24 @@ fn pure_works() {
Proxy::proxy(RuntimeOrigin::signed(1), anon, None, call.clone()),
Error::<Test>::NotProxy
);

// Actually kill the pure proxy.
assert_ok!(Proxy::kill_pure(
RuntimeOrigin::signed(anon),
1,
ProxyType::Any,
0,
1,
0
));
System::assert_last_event(
ProxyEvent::PureKilled {
pure: anon,
spawner: 1,
proxy_type: ProxyType::Any,
disambiguation_index: 0,
}
.into(),
);
});
}
Loading