git.delta.rocks / unique-network / refs/commits / 5df49385ed2d

difftreelog

feat custom collection creation price

Yaroslav Bolyukin2021-03-12parent: #2d6d3d4.patch.diff
in: master

3 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
435 /// Weight information for extrinsics in this pallet.435 /// Weight information for extrinsics in this pallet.
436 type WeightInfo: WeightInfo;436 type WeightInfo: WeightInfo;
437
438 type CollectionCreationPrice: Get<BalanceOf<Self>>;
437}439}
438440
439#[cfg(feature = "runtime-benchmarks")]441#[cfg(feature = "runtime-benchmarks")]
2535 > {2537 > {
2536 let tip = self.0;2538 let tip = self.0;
25372539
2538 // Set fee based on call type. Creating collection costs 1 Unique.
2539 // All other transactions have traditional fees so far
2540 // let fee = match call.is_sub_type() {
2541 // Some(Call::create_collection(..)) => <BalanceOf<T>>::from(1_000_000_000),
2542 // _ => Self::traditional_fee(len, info, tip), // Flat fee model, use only for testing purposes
2543 // // _ => <BalanceOf<T>>::from(100)
2544 // };
2545 let fee = Self::traditional_fee(len, info, tip);2540 let fee = match call.is_sub_type() {
2541 Some(Call::create_collection(..)) => T::CollectionCreationPrice::get(),
2542 _ => Self::traditional_fee(len, info, tip),
2543 };
25462544
2547 // Only mess with balances if fee is not zero.2545 // Only mess with balances if fee is not zero.
2548 if fee.is_zero() {2546 if fee.is_zero() {
modifiedpallets/nft/src/mock.rsdiffbeforeafterboth
133 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;133 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;
134}134}
135
136parameter_types! {
137 pub const CollectionCreationPrice: u64 = 1_000_000_000_000;
138}
135139
136impl pallet_template::Config for Test {140impl pallet_template::Config for Test {
137 type Event = ();141 type Event = ();
138 type WeightInfo = ();142 type WeightInfo = ();
143 type CollectionCreationPrice = CollectionCreationPrice;
139}144}
140145
141// Build genesis storage according to the mock runtime.146// Build genesis storage according to the mock runtime.
modifiedruntime/src/lib.rsdiffbeforeafterboth
510510
511parameter_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}
514515
515impl 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}
528530
529construct_runtime!(531construct_runtime!(