Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: token terminology #215

Merged
merged 16 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading