Skip to content

Commit

Permalink
pallet-assets: Rename total_supply to amount (paritytech#13229)
Browse files Browse the repository at this point in the history
* 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 <>
  • Loading branch information
bkchr authored and ltfschoen committed Feb 22, 2023
1 parent 906c188 commit 1da4c06
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
2 changes: 1 addition & 1 deletion frame/assets/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ benchmarks_instance_pallet! {
let amount = T::Balance::from(100u32);
}: _(SystemOrigin::Signed(caller.clone()), asset_id, caller_lookup, amount)
verify {
assert_last_event::<T, I>(Event::Issued { asset_id: asset_id.into(), owner: caller, total_supply: amount }.into());
assert_last_event::<T, I>(Event::Issued { asset_id: asset_id.into(), owner: caller, amount }.into());
}

burn {
Expand Down
15 changes: 6 additions & 9 deletions frame/assets/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,15 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
if let Some(check_issuer) = maybe_check_issuer {
ensure!(check_issuer == details.issuer, Error::<T, I>::NoPermission);
}
debug_assert!(
T::Balance::max_value() - details.supply >= amount,
"checked in prep; qed"
);
debug_assert!(details.supply.checked_add(&amount).is_some(), "checked in prep; qed");

details.supply = details.supply.saturating_add(amount);

Ok(())
})?;
Self::deposit_event(Event::Issued {
asset_id: id,
owner: beneficiary.clone(),
total_supply: amount,
});

Self::deposit_event(Event::Issued { asset_id: id, owner: beneficiary.clone(), amount });

Ok(())
}

Expand Down
8 changes: 3 additions & 5 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,7 @@ pub use types::*;

use scale_info::TypeInfo;
use sp_runtime::{
traits::{
AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero,
},
traits::{AtLeast32BitUnsigned, CheckedAdd, CheckedSub, Saturating, StaticLookup, Zero},
ArithmeticError, TokenError,
};
use sp_std::{borrow::Borrow, prelude::*};
Expand Down Expand Up @@ -427,7 +425,7 @@ pub mod pallet {
*amount,
|details| -> DispatchResult {
debug_assert!(
T::Balance::max_value() - details.supply >= *amount,
details.supply.checked_add(&amount).is_some(),
"checked in prep; qed"
);
details.supply = details.supply.saturating_add(*amount);
Expand All @@ -445,7 +443,7 @@ pub mod pallet {
/// Some asset class was created.
Created { asset_id: T::AssetId, creator: T::AccountId, owner: T::AccountId },
/// Some assets were issued.
Issued { asset_id: T::AssetId, owner: T::AccountId, total_supply: T::Balance },
Issued { asset_id: T::AssetId, owner: T::AccountId, amount: T::Balance },
/// Some assets were transferred.
Transferred {
asset_id: T::AssetId,
Expand Down

0 comments on commit 1da4c06

Please sign in to comment.