Skip to content

Commit

Permalink
style: token terminology (#215)
Browse files Browse the repository at this point in the history
Co-authored-by: Tin Chung <[email protected]>
Co-authored-by: Frank Bell <[email protected]>
  • Loading branch information
3 people authored Sep 9, 2024
1 parent c0ea3ed commit 206757b
Show file tree
Hide file tree
Showing 15 changed files with 510 additions and 520 deletions.
18 changes: 9 additions & 9 deletions pallets/api/src/fungibles/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Benchmarking setup for pallet-api::fungibles
//! Benchmarking setup for pallet_api::fungibles

use frame_benchmarking::{account, v2::*};
use frame_support::{
Expand All @@ -14,7 +14,7 @@ use frame_support::{
use frame_system::RawOrigin;
use sp_runtime::traits::Zero;

use super::{AccountIdOf, AssetIdOf, AssetsInstanceOf, AssetsOf, BalanceOf, Call, Config, Pallet};
use super::{AccountIdOf, AssetsInstanceOf, AssetsOf, BalanceOf, Call, Config, Pallet, TokenIdOf};

const SEED: u32 = 1;

Expand All @@ -37,21 +37,21 @@ mod benchmarks {
// - 'c': whether `cancel_approval` is required.
#[benchmark]
fn approve(a: Linear<0, 1>, c: Linear<0, 1>) -> Result<(), BenchmarkError> {
let asset_id = AssetIdOf::<T>::zero();
let token_id = TokenIdOf::<T>::zero();
let min_balance = <BalanceOf<T>>::from(1u32);
let owner: AccountIdOf<T> = account("Alice", 0, SEED);
let spender: AccountIdOf<T> = account("Bob", 0, SEED);
let current_allowance = <BalanceOf<T>>::from(u32::MAX / 2);
T::Currency::make_free_balance_be(&owner, u32::MAX.into());
// Set the `current_allowance`.
assert_ok!(<AssetsOf<T> as Create<AccountIdOf<T>>>::create(
asset_id.clone(),
token_id.clone(),
owner.clone(),
true,
min_balance
));
assert_ok!(<AssetsOf<T> as Mutate<AccountIdOf<T>>>::approve(
asset_id.clone(),
token_id.clone(),
&owner,
&spender,
current_allowance,
Expand All @@ -69,13 +69,13 @@ mod benchmarks {
};

#[extrinsic_call]
_(RawOrigin::Signed(owner.clone()), asset_id.clone(), spender.clone(), approval_value);
_(RawOrigin::Signed(owner.clone()), token_id.clone(), spender.clone(), approval_value);

assert_eq!(AssetsOf::<T>::allowance(asset_id.clone(), &owner, &spender), approval_value);
assert_eq!(AssetsOf::<T>::allowance(token_id.clone(), &owner, &spender), approval_value);
if c == 1 {
assert_has_event::<T>(
pallet_assets::Event::ApprovalCancelled {
asset_id: asset_id.clone(),
asset_id: token_id.clone(),
owner: owner.clone(),
delegate: spender.clone(),
}
Expand All @@ -92,7 +92,7 @@ mod benchmarks {
};
assert_has_event::<T>(
pallet_assets::Event::ApprovedTransfer {
asset_id,
asset_id: token_id,
source: owner,
delegate: spender,
amount,
Expand Down
Loading

0 comments on commit 206757b

Please sign in to comment.