Skip to content
Closed
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
inactive amount can't exceed supply
Signed-off-by: Matteo Muraca <[email protected]>
  • Loading branch information
muraca committed Mar 7, 2024
commit 91ac946b0faad348f7574e4bfc504d3267dad135
5 changes: 4 additions & 1 deletion substrate/frame/assets/src/impl_fungibles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ impl<T: Config<I>, I: 'static> fungibles::Unbalanced<T::AccountId> for Pallet<T,

fn deactivate(asset: Self::AssetId, amount: Self::Balance) {
Asset::<T, I>::mutate(&asset, |maybe_asset| match maybe_asset {
Some(ref mut asset) => asset.inactive.saturating_accrue(amount),
Some(ref mut asset) =>{
// Inactive amount can't exceed supply
asset.inactive = asset.inactive.saturating_add(amount).max(asset.supply);
Comment on lines +170 to +171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this be a defensive check if the runtime is trying to set the inactive amt > total supply, probably indicates a bug?

},
None => log::error!("Called deactivate for nonexistent asset {:?}", asset),
});
}
Expand Down