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
--- 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() {
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
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -510,6 +510,7 @@
 
 parameter_types! {
 	pub const MinVestedTransfer: Balance = 10 * UNIQUE;
+	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
 }
 
 impl pallet_vesting::Config for Runtime {
@@ -524,6 +525,7 @@
 impl pallet_nft::Config for Runtime {
     type Event = Event;
     type WeightInfo = nft_weights::WeightInfo;
+	type CollectionCreationPrice = CollectionCreationPrice;
 }
 
 construct_runtime!(