Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
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
fix
  • Loading branch information
Szegoo committed Mar 2, 2023
commit 6d6af0b28a276a520baca4e54f0943f5db2d8f61
10 changes: 5 additions & 5 deletions frame/assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1541,14 +1541,14 @@ pub mod pallet {

let old_min_balance = details.min_balance;
let is_sufficient = details.is_sufficient;
// If the asset is marked as sufficient it won't be allowed to
// change the min_balance.
ensure!(!is_sufficient, Error::<T, I>::NoPermission);

// Ensure that either the new min_balance is less than old
// min_balance or there aren't any accounts holding the asset.
//
// If the asset is marked as sufficient we will only allow the owner
// to set the min_balance if the count of accounts holding the assets
// is zero.
ensure!(
(!is_sufficient && min_balance < old_min_balance) || details.accounts == 0,
min_balance < old_min_balance || details.accounts == 0,
Error::<T, I>::NoPermission
);

Expand Down
9 changes: 0 additions & 9 deletions frame/assets/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,12 +1125,6 @@ fn set_min_balance_should_work() {
Error::<Test>::NoPermission
);

assert_ok!(Assets::burn(RuntimeOrigin::signed(1), id, 1, 100));

// Works because there are no asset holders.
assert_ok!(Assets::set_min_balance(RuntimeOrigin::signed(1), id, 60));
assert_eq!(Asset::<Test>::get(id).unwrap().min_balance, 60);

// Make the asset not sufficient.
assert_ok!(Assets::force_asset_status(
RuntimeOrigin::root(),
Expand All @@ -1144,9 +1138,6 @@ fn set_min_balance_should_work() {
false
));

// We mint the asset again.
assert_ok!(Assets::mint(RuntimeOrigin::signed(1), id, 1, 100));

// Will execute because the new value of min_balance is less than the
// old value. 10 < 30
assert_ok!(Assets::set_min_balance(RuntimeOrigin::signed(1), id, 10));
Expand Down