Skip to content

Commit ec9bb99

Browse files
bkchrark0f
authored andcommitted
pallet-assets: Rename total_supply to amount (paritytech#13229)
* pallet-assets: Rename `total_supply` to `amount` We are actually passing the `amount` on assets being minted and not the total supply. Closes: paritytech#13210 * ".git/.scripts/commands/fmt/fmt.sh" * Fix compilation * FMT Co-authored-by: command-bot <>
1 parent 9ce7977 commit ec9bb99

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

frame/assets/src/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ benchmarks_instance_pallet! {
220220
let amount = T::Balance::from(100u32);
221221
}: _(SystemOrigin::Signed(caller.clone()), asset_id, caller_lookup, amount)
222222
verify {
223-
assert_last_event::<T, I>(Event::Issued { asset_id: asset_id.into(), owner: caller, total_supply: amount }.into());
223+
assert_last_event::<T, I>(Event::Issued { asset_id: asset_id.into(), owner: caller, amount }.into());
224224
}
225225

226226
burn {

frame/assets/src/functions.rs

+6-9
Original file line numberDiff line numberDiff line change
@@ -354,18 +354,15 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
354354
if let Some(check_issuer) = maybe_check_issuer {
355355
ensure!(check_issuer == details.issuer, Error::<T, I>::NoPermission);
356356
}
357-
debug_assert!(
358-
T::Balance::max_value() - details.supply >= amount,
359-
"checked in prep; qed"
360-
);
357+
debug_assert!(details.supply.checked_add(&amount).is_some(), "checked in prep; qed");
358+
361359
details.supply = details.supply.saturating_add(amount);
360+
362361
Ok(())
363362
})?;
364-
Self::deposit_event(Event::Issued {
365-
asset_id: id,
366-
owner: beneficiary.clone(),
367-
total_supply: amount,
368-
});
363+
364+
Self::deposit_event(Event::Issued { asset_id: id, owner: beneficiary.clone(), amount });
365+
369366
Ok(())
370367
}
371368

frame/assets/src/lib.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,7 @@ pub use types::*;
151151

152152
use scale_info::TypeInfo;
153153
use sp_runtime::{
154-
traits::{
155-
AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero,
156-
},
154+
traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero},
157155
ArithmeticError, TokenError,
158156
};
159157
use sp_std::{borrow::Borrow, prelude::*};
@@ -427,7 +425,7 @@ pub mod pallet {
427425
*amount,
428426
|details| -> DispatchResult {
429427
debug_assert!(
430-
T::Balance::max_value() - details.supply >= *amount,
428+
details.supply.checked_add(&amount).is_some(),
431429
"checked in prep; qed"
432430
);
433431
details.supply = details.supply.saturating_add(*amount);
@@ -445,7 +443,7 @@ pub mod pallet {
445443
/// Some asset class was created.
446444
Created { asset_id: T::AssetId, creator: T::AccountId, owner: T::AccountId },
447445
/// Some assets were issued.
448-
Issued { asset_id: T::AssetId, owner: T::AccountId, total_supply: T::Balance },
446+
Issued { asset_id: T::AssetId, owner: T::AccountId, amount: T::Balance },
449447
/// Some assets were transferred.
450448
Transferred {
451449
asset_id: T::AssetId,

0 commit comments

Comments
 (0)