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
+10 -5
View File
@@ -281,6 +281,7 @@ type BalanceOf<T, I> =
type NegativeImbalanceOf<T, I> = <<T as Config<I>>::Currency as Currency<
<T as frame_system::Config>::AccountId,
>>::NegativeImbalance;
type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;
/// A vote by a member on a candidate application.
#[derive(Encode, Decode, Copy, Clone, PartialEq, Eq, RuntimeDebug, TypeInfo)]
@@ -823,11 +824,12 @@ pub mod pallet {
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
pub fn vouch(
origin: OriginFor<T>,
who: T::AccountId,
who: AccountIdLookupOf<T>,
value: BalanceOf<T, I>,
tip: BalanceOf<T, I>,
) -> DispatchResult {
let voucher = ensure_signed(origin)?;
let who = T::Lookup::lookup(who)?;
// Check user is not suspended.
ensure!(!<SuspendedCandidates<T, I>>::contains_key(&who), Error::<T, I>::Suspended);
ensure!(!<SuspendedMembers<T, I>>::contains_key(&who), Error::<T, I>::Suspended);
@@ -914,7 +916,7 @@ pub mod pallet {
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
pub fn vote(
origin: OriginFor<T>,
candidate: <T::Lookup as StaticLookup>::Source,
candidate: AccountIdLookupOf<T>,
approve: bool,
) -> DispatchResult {
let voter = ensure_signed(origin)?;
@@ -1026,11 +1028,12 @@ pub mod pallet {
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
pub fn found(
origin: OriginFor<T>,
founder: T::AccountId,
founder: AccountIdLookupOf<T>,
max_members: u32,
rules: Vec<u8>,
) -> DispatchResult {
T::FounderSetOrigin::ensure_origin(origin)?;
let founder = T::Lookup::lookup(founder)?;
ensure!(!<Head<T, I>>::exists(), Error::<T, I>::AlreadyFounded);
ensure!(max_members > 1, Error::<T, I>::MaxMembers);
// This should never fail in the context of this function...
@@ -1104,10 +1107,11 @@ pub mod pallet {
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
pub fn judge_suspended_member(
origin: OriginFor<T>,
who: T::AccountId,
who: AccountIdLookupOf<T>,
forgive: bool,
) -> DispatchResult {
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
let who = T::Lookup::lookup(who)?;
ensure!(<SuspendedMembers<T, I>>::contains_key(&who), Error::<T, I>::NotSuspended);
if forgive {
@@ -1180,10 +1184,11 @@ pub mod pallet {
#[pallet::weight(T::BlockWeights::get().max_block / 10)]
pub fn judge_suspended_candidate(
origin: OriginFor<T>,
who: T::AccountId,
who: AccountIdLookupOf<T>,
judgement: Judgement,
) -> DispatchResult {
T::SuspensionJudgementOrigin::ensure_origin(origin)?;
let who = T::Lookup::lookup(who)?;
if let Some((value, kind)) = <SuspendedCandidates<T, I>>::get(&who) {
match judgement {
Judgement::Approve => {