difftreelog
feat custom collection creation price
in: master
3 files changed
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -434,6 +434,8 @@
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
+
+ type CollectionCreationPrice: Get<BalanceOf<Self>>;
}
#[cfg(feature = "runtime-benchmarks")]
@@ -2535,14 +2537,10 @@
> {
let tip = self.0;
- // Set fee based on call type. Creating collection costs 1 Unique.
- // All other transactions have traditional fees so far
- // let fee = match call.is_sub_type() {
- // Some(Call::create_collection(..)) => <BalanceOf<T>>::from(1_000_000_000),
- // _ => Self::traditional_fee(len, info, tip), // Flat fee model, use only for testing purposes
- // // _ => <BalanceOf<T>>::from(100)
- // };
- let fee = Self::traditional_fee(len, info, tip);
+ let fee = match call.is_sub_type() {
+ Some(Call::create_collection(..)) => T::CollectionCreationPrice::get(),
+ _ => Self::traditional_fee(len, info, tip),
+ };
// Only mess with balances if fee is not zero.
if fee.is_zero() {
pallets/nft/src/mock.rsdiffbeforeafterboth--- a/pallets/nft/src/mock.rs
+++ b/pallets/nft/src/mock.rs
@@ -133,9 +133,14 @@
type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
}
+parameter_types! {
+ pub const CollectionCreationPrice: u64 = 1_000_000_000_000;
+}
+
impl pallet_template::Config for Test {
type Event = ();
type WeightInfo = ();
+ type CollectionCreationPrice = CollectionCreationPrice;
}
// Build genesis storage according to the mock runtime.
runtime/src/lib.rsdiffbeforeafterboth510510511parameter_types! {511parameter_types! {512 pub const MinVestedTransfer: Balance = 10 * UNIQUE;512 pub const MinVestedTransfer: Balance = 10 * UNIQUE;513 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;513}514}514515515impl pallet_vesting::Config for Runtime {516impl pallet_vesting::Config for Runtime {524impl pallet_nft::Config for Runtime {525impl pallet_nft::Config for Runtime {525 type Event = Event;526 type Event = Event;526 type WeightInfo = nft_weights::WeightInfo;527 type WeightInfo = nft_weights::WeightInfo;528 type CollectionCreationPrice = CollectionCreationPrice;527}529}528530529construct_runtime!(531construct_runtime!(