Skip to content

Commit

Permalink
Refactor proxy pallet to use Consideration trait
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kazlauskas committed Aug 19, 2024
1 parent 843c4db commit 912f663
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 168 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions prdoc/pr_5336.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Refactor proxy pallet to use Consideration trait

doc:
- audience: Runtime Dev
description: |
Before this pallet would reserve its storage value manually, `Consideration`
trait simplifies the implementation.

crates:
- name: pallet-proxy
bump: major
15 changes: 8 additions & 7 deletions substrate/frame/proxy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use super::*;
use crate::Pallet as Proxy;
use alloc::{boxed::Box, vec};
use frame_benchmarking::v1::{account, benchmarks, whitelisted_caller};
use frame_support::traits::Currency;
use frame_system::{pallet_prelude::BlockNumberFor, RawOrigin};
use sp_runtime::traits::Bounded;

Expand Down Expand Up @@ -136,7 +137,7 @@ benchmarks! {
add_announcements::<T>(a, Some(caller.clone()), None)?;
}: _(RawOrigin::Signed(caller.clone()), real_lookup, T::CallHasher::hash_of(&call))
verify {
let (announcements, _) = Announcements::<T>::get(&caller);
let (announcements, _) = Announcements::<T>::get(&caller).unwrap();
assert_eq!(announcements.len() as u32, a);
}

Expand All @@ -159,7 +160,7 @@ benchmarks! {
add_announcements::<T>(a, Some(caller.clone()), None)?;
}: _(RawOrigin::Signed(real), caller_lookup, T::CallHasher::hash_of(&call))
verify {
let (announcements, _) = Announcements::<T>::get(&caller);
let (announcements, _) = Announcements::<T>::get(&caller).unwrap();
assert_eq!(announcements.len() as u32, a);
}

Expand Down Expand Up @@ -191,7 +192,7 @@ benchmarks! {
BlockNumberFor::<T>::zero()
)
verify {
let (proxies, _) = Proxies::<T>::get(caller);
let (proxies, _) = Proxies::<T>::get(caller).unwrap();
assert_eq!(proxies.len() as u32, p + 1);
}

Expand All @@ -206,17 +207,17 @@ benchmarks! {
BlockNumberFor::<T>::zero()
)
verify {
let (proxies, _) = Proxies::<T>::get(caller);
assert_eq!(proxies.len() as u32, p - 1);
let len = Proxies::<T>::get(caller).map(|x| x.0.len()).unwrap_or(0);
assert_eq!(len as u32, p - 1);
}

remove_proxies {
let p in 1 .. (T::MaxProxies::get() - 1) => add_proxies::<T>(p, None)?;
let caller: T::AccountId = whitelisted_caller();
}: _(RawOrigin::Signed(caller.clone()))
verify {
let (proxies, _) = Proxies::<T>::get(caller);
assert_eq!(proxies.len() as u32, 0);
let len = Proxies::<T>::get(caller).map(|x| x.0.len()).unwrap_or(0);
assert_eq!(len as u32, 0);
}

create_pure {
Expand Down
Loading

0 comments on commit 912f663

Please sign in to comment.