Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Remove a max supply record on collection's destruction (#11593)
Browse files Browse the repository at this point in the history
* Remove a max supply record on collection's destruction

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_utility --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/utility/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_uniques --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/uniques/src/weights.rs --template=./.maintain/frame-weight-template.hbs

* cargo run --quiet --profile=production  --features=runtime-benchmarks --manifest-path=bin/node/cli/Cargo.toml -- benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=pallet_uniques --extrinsic=* --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=./frame/uniques/src/weights.rs --template=./.maintain/frame-weight-template.hbs

Co-authored-by: Parity Bot <[email protected]>
  • Loading branch information
jsidorenko and Parity Bot authored Jun 7, 2022
1 parent a0a40ad commit 3ca525d
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 88 deletions.
1 change: 1 addition & 0 deletions frame/uniques/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
Attribute::<T, I>::remove_prefix((&collection,), None);
CollectionAccount::<T, I>::remove(&collection_details.owner, &collection);
T::Currency::unreserve(&collection_details.owner, collection_details.total_deposit);
CollectionMaxSupply::<T, I>::remove(&collection);

Self::deposit_event(Event::Destroyed { collection });

Expand Down
8 changes: 8 additions & 0 deletions frame/uniques/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,5 +684,13 @@ fn max_supply_should_work() {
Uniques::mint(Origin::signed(user_id), collection_id, 2, user_id),
Error::<Test>::MaxSupplyReached
);

// validate we remove the CollectionMaxSupply record when we destroy the collection
assert_ok!(Uniques::destroy(
Origin::signed(user_id),
collection_id,
Collection::<Test>::get(collection_id).unwrap().destroy_witness()
));
assert!(!CollectionMaxSupply::<Test>::contains_key(collection_id));
});
}
Loading

0 comments on commit 3ca525d

Please sign in to comment.