Don't allow self proxies (#7803)

This commit is contained in:
Shawn Tabrizi
2020-12-29 13:31:44 -04:00
committed by GitHub
parent 0b7ae4440c
commit 8c795accc8
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -168,6 +168,8 @@ decl_error! {
NoPermission,
/// Announcement, if made at all, was made too recently.
Unannounced,
/// Cannot add self as proxy.
NoSelfProxy,
}
}
@@ -567,6 +569,7 @@ impl<T: Config> Module<T> {
proxy_type: T::ProxyType,
delay: T::BlockNumber,
) -> DispatchResult {
ensure!(delegator != &delegatee, Error::<T>::NoSelfProxy);
Proxies::<T>::try_mutate(delegator, |(ref mut proxies, ref mut deposit)| {
ensure!(proxies.len() < T::MaxProxies::get() as usize, Error::<T>::TooMany);
let proxy_def = ProxyDefinition { delegate: delegatee, proxy_type, delay };