Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
AccountIdLookupOf<T>
  • Loading branch information
Doordashcon committed Jul 12, 2022
commit e65e165a166f4b3acffab26367e34fd6846cda87
6 changes: 3 additions & 3 deletions frame/alliance/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: AccountIdLookupOf<T> = 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
Expand All @@ -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: AccountIdLookupOf<T> = 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)? }
Expand Down Expand Up @@ -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: AccountIdLookupOf<T> = 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)? }
Expand Down
8 changes: 5 additions & 3 deletions frame/alliance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -731,7 +733,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::nominate_ally())]
pub fn nominate_ally(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
who: AccountIdLookupOf<T>,
) -> DispatchResult {
let nominator = ensure_signed(origin)?;
ensure!(Self::has_voting_rights(&nominator), Error::<T, I>::NoVotingRights);
Expand All @@ -758,7 +760,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::elevate_ally())]
pub fn elevate_ally(
origin: OriginFor<T>,
ally: <T::Lookup as StaticLookup>::Source,
ally: AccountIdLookupOf<T>,
) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
let ally = T::Lookup::lookup(ally)?;
Expand Down Expand Up @@ -794,7 +796,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::kick_member())]
pub fn kick_member(
origin: OriginFor<T>,
who: <T::Lookup as StaticLookup>::Source,
who: AccountIdLookupOf<T>,
) -> DispatchResult {
T::MembershipManager::ensure_origin(origin)?;
let member = T::Lookup::lookup(who)?;
Expand Down
4 changes: 2 additions & 2 deletions frame/assets/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const SEED: u32 = 0;

fn create_default_asset<T: Config<I>, I: 'static>(
is_sufficient: bool,
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
) -> (T::AccountId, AccountIdLookupOf<T>) {
let caller: T::AccountId = whitelisted_caller();
let caller_lookup = T::Lookup::unlookup(caller.clone());
let root = SystemOrigin::Root.into();
Expand All @@ -55,7 +55,7 @@ fn create_default_asset<T: Config<I>, I: 'static>(
fn create_default_minted_asset<T: Config<I>, I: 'static>(
is_sufficient: bool,
amount: T::Balance,
) -> (T::AccountId, <T::Lookup as StaticLookup>::Source) {
) -> (T::AccountId, AccountIdLookupOf<T>) {
let (caller, caller_lookup) = create_default_asset::<T, I>(is_sufficient);
if !is_sufficient {
T::Currency::make_free_balance_be(&caller, T::Currency::minimum_balance());
Expand Down
50 changes: 26 additions & 24 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ use frame_system::Config as SystemConfig;
pub use pallet::*;
pub use weights::WeightInfo;

type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;

#[frame_support::pallet]
pub mod pallet {
use super::*;
Expand Down Expand Up @@ -501,7 +503,7 @@ pub mod pallet {
pub fn create(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
admin: <T::Lookup as StaticLookup>::Source,
admin: AccountIdLookupOf<T>,
min_balance: T::Balance,
) -> DispatchResult {
let owner = ensure_signed(origin)?;
Expand Down Expand Up @@ -557,7 +559,7 @@ pub mod pallet {
pub fn force_create(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
owner: <T::Lookup as StaticLookup>::Source,
owner: AccountIdLookupOf<T>,
is_sufficient: bool,
#[pallet::compact] min_balance: T::Balance,
) -> DispatchResult {
Expand Down Expand Up @@ -623,7 +625,7 @@ pub mod pallet {
pub fn mint(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
beneficiary: <T::Lookup as StaticLookup>::Source,
beneficiary: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
Expand Down Expand Up @@ -651,7 +653,7 @@ pub mod pallet {
pub fn burn(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
who: <T::Lookup as StaticLookup>::Source,
who: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
Expand Down Expand Up @@ -684,7 +686,7 @@ pub mod pallet {
pub fn transfer(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
target: <T::Lookup as StaticLookup>::Source,
target: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
Expand Down Expand Up @@ -716,7 +718,7 @@ pub mod pallet {
pub fn transfer_keep_alive(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
target: <T::Lookup as StaticLookup>::Source,
target: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
) -> DispatchResult {
let source = ensure_signed(origin)?;
Expand Down Expand Up @@ -749,8 +751,8 @@ pub mod pallet {
pub fn force_transfer(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
source: <T::Lookup as StaticLookup>::Source,
dest: <T::Lookup as StaticLookup>::Source,
source: AccountIdLookupOf<T>,
dest: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
Expand All @@ -775,7 +777,7 @@ pub mod pallet {
pub fn freeze(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
who: <T::Lookup as StaticLookup>::Source,
who: AccountIdLookupOf<T>,
) -> DispatchResult {
let origin = ensure_signed(origin)?;

Expand Down Expand Up @@ -806,7 +808,7 @@ pub mod pallet {
pub fn thaw(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
who: <T::Lookup as StaticLookup>::Source,
who: AccountIdLookupOf<T>,
) -> DispatchResult {
let origin = ensure_signed(origin)?;

Expand Down Expand Up @@ -891,7 +893,7 @@ pub mod pallet {
pub fn transfer_ownership(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
owner: <T::Lookup as StaticLookup>::Source,
owner: AccountIdLookupOf<T>,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
let owner = T::Lookup::lookup(owner)?;
Expand Down Expand Up @@ -932,9 +934,9 @@ pub mod pallet {
pub fn set_team(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
issuer: <T::Lookup as StaticLookup>::Source,
admin: <T::Lookup as StaticLookup>::Source,
freezer: <T::Lookup as StaticLookup>::Source,
issuer: AccountIdLookupOf<T>,
admin: AccountIdLookupOf<T>,
freezer: AccountIdLookupOf<T>,
) -> DispatchResult {
let origin = ensure_signed(origin)?;
let issuer = T::Lookup::lookup(issuer)?;
Expand Down Expand Up @@ -1117,10 +1119,10 @@ pub mod pallet {
pub fn force_asset_status(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
owner: <T::Lookup as StaticLookup>::Source,
issuer: <T::Lookup as StaticLookup>::Source,
admin: <T::Lookup as StaticLookup>::Source,
freezer: <T::Lookup as StaticLookup>::Source,
owner: AccountIdLookupOf<T>,
issuer: AccountIdLookupOf<T>,
admin: AccountIdLookupOf<T>,
freezer: AccountIdLookupOf<T>,
#[pallet::compact] min_balance: T::Balance,
is_sufficient: bool,
is_frozen: bool,
Expand Down Expand Up @@ -1167,7 +1169,7 @@ pub mod pallet {
pub fn approve_transfer(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
delegate: <T::Lookup as StaticLookup>::Source,
delegate: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
) -> DispatchResult {
let owner = ensure_signed(origin)?;
Expand All @@ -1192,7 +1194,7 @@ pub mod pallet {
pub fn cancel_approval(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
delegate: <T::Lookup as StaticLookup>::Source,
delegate: AccountIdLookupOf<T>,
) -> DispatchResult {
let owner = ensure_signed(origin)?;
let delegate = T::Lookup::lookup(delegate)?;
Expand Down Expand Up @@ -1225,8 +1227,8 @@ pub mod pallet {
pub fn force_cancel_approval(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
owner: <T::Lookup as StaticLookup>::Source,
delegate: <T::Lookup as StaticLookup>::Source,
owner: AccountIdLookupOf<T>,
delegate: AccountIdLookupOf<T>,
) -> DispatchResult {
let mut d = Asset::<T, I>::get(id).ok_or(Error::<T, I>::Unknown)?;
T::ForceOrigin::try_origin(origin)
Expand Down Expand Up @@ -1272,8 +1274,8 @@ pub mod pallet {
pub fn transfer_approved(
origin: OriginFor<T>,
#[pallet::compact] id: T::AssetId,
owner: <T::Lookup as StaticLookup>::Source,
destination: <T::Lookup as StaticLookup>::Source,
owner: AccountIdLookupOf<T>,
destination: AccountIdLookupOf<T>,
#[pallet::compact] amount: T::Balance,
) -> DispatchResult {
let delegate = ensure_signed(origin)?;
Expand Down
6 changes: 4 additions & 2 deletions frame/bags-list/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ macro_rules! log {
};
}

type AccountIdLookupOf<T> = <<T as frame_system::Config>::Lookup as StaticLookup>::Source;

#[frame_support::pallet]
pub mod pallet {
use super::*;
Expand Down Expand Up @@ -224,7 +226,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::rebag_non_terminal().max(T::WeightInfo::rebag_terminal()))]
pub fn rebag(
origin: OriginFor<T>,
dislocated: <T::Lookup as StaticLookup>::Source,
dislocated: AccountIdLookupOf<T>,
) -> DispatchResult {
ensure_signed(origin)?;
let dislocated = T::Lookup::lookup(dislocated)?;
Expand All @@ -245,7 +247,7 @@ pub mod pallet {
#[pallet::weight(T::WeightInfo::put_in_front_of())]
pub fn put_in_front_of(
origin: OriginFor<T>,
lighter: <T::Lookup as StaticLookup>::Source,
lighter: AccountIdLookupOf<T>,
) -> DispatchResult {
let heavier = ensure_signed(origin)?;
let lighter = T::Lookup::lookup(lighter)?;
Expand Down
20 changes: 10 additions & 10 deletions frame/balances/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ benchmarks_instance_pallet! {
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
// and reap this user.
let recipient: T::AccountId = account("recipient", 0, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
let recipient_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(recipient.clone());
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
}: transfer(RawOrigin::Signed(caller.clone()), recipient_lookup, transfer_amount)
verify {
Expand All @@ -60,7 +60,7 @@ benchmarks_instance_pallet! {
transfer_best_case {
let caller = whitelisted_caller();
let recipient: T::AccountId = account("recipient", 0, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
let recipient_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(recipient.clone());

// Give the sender account max funds for transfer (their account will never reasonably be killed).
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
Expand All @@ -80,7 +80,7 @@ benchmarks_instance_pallet! {
transfer_keep_alive {
let caller = whitelisted_caller();
let recipient: T::AccountId = account("recipient", 0, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
let recipient_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(recipient.clone());

// Give the sender account max funds, thus a transfer will not kill account.
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&caller, T::Balance::max_value());
Expand All @@ -95,7 +95,7 @@ benchmarks_instance_pallet! {
// Benchmark `set_balance` coming from ROOT account. This always creates an account.
set_balance_creating {
let user: T::AccountId = account("user", 0, SEED);
let user_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(user.clone());
let user_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(user.clone());

// Give the user some initial balance.
let existential_deposit = T::ExistentialDeposit::get();
Expand All @@ -110,7 +110,7 @@ benchmarks_instance_pallet! {
// Benchmark `set_balance` coming from ROOT account. This always kills an account.
set_balance_killing {
let user: T::AccountId = account("user", 0, SEED);
let user_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(user.clone());
let user_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(user.clone());

// Give the user some initial balance.
let existential_deposit = T::ExistentialDeposit::get();
Expand All @@ -127,15 +127,15 @@ benchmarks_instance_pallet! {
force_transfer {
let existential_deposit = T::ExistentialDeposit::get();
let source: T::AccountId = account("source", 0, SEED);
let source_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(source.clone());
let source_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(source.clone());

// Give some multiple of the existential deposit
let balance = existential_deposit.saturating_mul(ED_MULTIPLIER.into());
let _ = <Balances<T, I> as Currency<_>>::make_free_balance_be(&source, balance);

// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account, and reap this user.
let recipient: T::AccountId = account("recipient", 0, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
let recipient_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(recipient.clone());
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();
}: force_transfer(RawOrigin::Root, source_lookup, recipient_lookup, transfer_amount)
verify {
Expand All @@ -160,7 +160,7 @@ benchmarks_instance_pallet! {
// Transfer `e - 1` existential deposits + 1 unit, which guarantees to create one account,
// and reap this user.
let recipient: T::AccountId = account("recipient", 0, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
let recipient_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(recipient.clone());
let transfer_amount = existential_deposit.saturating_mul((ED_MULTIPLIER - 1).into()) + 1u32.into();

// Create a bunch of users in storage.
Expand All @@ -182,7 +182,7 @@ benchmarks_instance_pallet! {
transfer_all {
let caller = whitelisted_caller();
let recipient: T::AccountId = account("recipient", 0, SEED);
let recipient_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(recipient.clone());
let recipient_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(recipient.clone());

// Give some multiple of the existential deposit
let existential_deposit = T::ExistentialDeposit::get();
Expand All @@ -196,7 +196,7 @@ benchmarks_instance_pallet! {

force_unreserve {
let user: T::AccountId = account("user", 0, SEED);
let user_lookup: <T::Lookup as StaticLookup>::Source = T::Lookup::unlookup(user.clone());
let user_lookup: AccountIdLookupOf<T> = T::Lookup::unlookup(user.clone());

// Give some multiple of the existential deposit
let existential_deposit = T::ExistentialDeposit::get();
Expand Down
Loading