Allow to set the max supply for collection (#11441)

* Allow to set the max supply for collection

* Update error

* Add weights info

* 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

* Update frame/uniques/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

Co-authored-by: Parity Bot <admin@parity.io>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Jegor Sidorenko
2022-05-18 13:23:44 +02:00
committed by GitHub
parent ce77cb1735
commit 236cc98be2
5 changed files with 199 additions and 63 deletions
+4
View File
@@ -142,6 +142,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
with_details(collection_details)?;
if let Ok(max_supply) = CollectionMaxSupply::<T, I>::try_get(&collection) {
ensure!(collection_details.items < max_supply, Error::<T, I>::MaxSupplyReached);
}
let items =
collection_details.items.checked_add(1).ok_or(ArithmeticError::Overflow)?;
collection_details.items = items;