Replace T::AccountId with <T::Lookup as StaticLookup>::Source (#11670)

* initial

* update

* update

* update

* cargo fmt

* update

* update benchmarks

* AccountIdLookupOf<T>

* cargo fmt

* fix conflits

* cargo fmt

* update

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Doordashcon
2022-08-18 10:30:46 +01:00
committed by GitHub
parent 511e5c9651
commit d46f6f0d34
50 changed files with 465 additions and 309 deletions
+3 -3
View File
@@ -662,7 +662,7 @@ benchmarks_instance_pallet! {
assert!(!Alliance::<T, I>::is_member(&outsider));
assert_eq!(DepositOf::<T, I>::get(&outsider), None);
let outsider_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(outsider.clone());
let outsider_lookup = T::Lookup::unlookup(outsider.clone());
}: _(SystemOrigin::Signed(founder1.clone()), outsider_lookup)
verify {
assert!(Alliance::<T, I>::is_member_of(&outsider, MemberRole::Ally)); // outsider is now an ally
@@ -681,7 +681,7 @@ benchmarks_instance_pallet! {
let ally1 = ally::<T, I>(1);
assert!(Alliance::<T, I>::is_ally(&ally1));
let ally1_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(ally1.clone());
let ally1_lookup = T::Lookup::unlookup(ally1.clone());
let call = Call::<T, I>::elevate_ally { ally: ally1_lookup };
let origin = T::MembershipManager::successful_origin();
}: { call.dispatch_bypass_filter(origin)? }
@@ -720,7 +720,7 @@ benchmarks_instance_pallet! {
assert_eq!(DepositOf::<T, I>::get(&fellow2), Some(T::AllyDeposit::get()));
let fellow2_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(fellow2.clone());
let fellow2_lookup = T::Lookup::unlookup(fellow2.clone());
let call = Call::<T, I>::kick_member { who: fellow2_lookup };
let origin = T::MembershipManager::successful_origin();
}: { call.dispatch_bypass_filter(origin)? }
+5 -12
View File
@@ -210,6 +210,8 @@ pub enum UnscrupulousItem<AccountId, Url> {
type UnscrupulousItemOf<T, I> =
UnscrupulousItem<<T as frame_system::Config>::AccountId, UrlOf<T, I>>;
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
#[frame_support::pallet]
pub mod pallet {
use super::*;
@@ -744,10 +746,7 @@ pub mod pallet {
/// A founder or fellow can nominate someone to join the alliance as an Ally.
/// There is no deposit required to the nominator or nominee.
#[pallet::weight(T::WeightInfo::nominate_ally())]
pub fn nominate_ally(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
) -> DispatchResult {
pub fn nominate_ally(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
let nominator = ensure_signed(origin)?;
ensure!(Self::has_voting_rights(&nominator), Error::<T, I>::NoVotingRights);
let who = T::Lookup::lookup(who)?;
@@ -771,10 +770,7 @@ pub mod pallet {
/// Elevate an ally to fellow.
#[pallet::weight(T::WeightInfo::elevate_ally())]
pub fn elevate_ally(
origin: OriginFor<T>,
ally: <T::Lookup as StaticLookup>::Source,
) -> DispatchResult {
pub fn elevate_ally(origin: OriginFor<T>, ally: AccountIdLookupOf<T>) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
let ally = T::Lookup::lookup(ally)?;
ensure!(Self::is_ally(&ally), Error::<T, I>::NotAlly);
@@ -807,10 +803,7 @@ pub mod pallet {
/// Kick a member from the alliance and slash its deposit.
#[pallet::weight(T::WeightInfo::kick_member())]
pub fn kick_member(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
) -> DispatchResult {
pub fn kick_member(origin: OriginFor<T>, who: AccountIdLookupOf<T>) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
let member = T::Lookup::lookup(who)?;