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

Commit 76522d7

Browse files
chevdorjsidorenkoParity Bot
authored
Remove a max supply record on collection's destruction (#11593) (#11635)
* 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]> Co-authored-by: Jegor Sidorenko <[email protected]> Co-authored-by: Parity Bot <[email protected]>
1 parent 6cbe177 commit 76522d7

File tree

4 files changed

+117
-88
lines changed

4 files changed

+117
-88
lines changed

frame/uniques/src/functions.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
115115
Attribute::<T, I>::remove_prefix((&collection,), None);
116116
CollectionAccount::<T, I>::remove(&collection_details.owner, &collection);
117117
T::Currency::unreserve(&collection_details.owner, collection_details.total_deposit);
118+
CollectionMaxSupply::<T, I>::remove(&collection);
118119

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

frame/uniques/src/tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,5 +684,13 @@ fn max_supply_should_work() {
684684
Uniques::mint(Origin::signed(user_id), collection_id, 2, user_id),
685685
Error::<Test>::MaxSupplyReached
686686
);
687+
688+
// validate we remove the CollectionMaxSupply record when we destroy the collection
689+
assert_ok!(Uniques::destroy(
690+
Origin::signed(user_id),
691+
collection_id,
692+
Collection::<Test>::get(collection_id).unwrap().destroy_witness()
693+
));
694+
assert!(!CollectionMaxSupply::<Test>::contains_key(collection_id));
687695
});
688696
}

0 commit comments

Comments
 (0)