git.delta.rocks / unique-network / refs/commits / 6f9cded09d5c

difftreelog

feat explicit collection creation fee

Yaroslav Bolyukin2021-03-17parent: #5df4938.patch.diff
in: master

2 files changed

modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
20 ensure, fail, parameter_types,20 ensure, fail, parameter_types,
21 traits::{21 traits::{
22 Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,22 Currency, ExistenceRequirement, Get, Imbalance, KeyOwnerProofSystem, OnUnbalanced,
23 Randomness, IsSubType,23 Randomness, IsSubType, WithdrawReasons,
24 },24 },
25 weights::{25 weights::{
26 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},26 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},
435 /// Weight information for extrinsics in this pallet.435 /// Weight information for extrinsics in this pallet.
436 type WeightInfo: WeightInfo;436 type WeightInfo: WeightInfo;
437437
438 type Currency: Currency<Self::AccountId>;
438 type CollectionCreationPrice: Get<BalanceOf<Self>>;439 type CollectionCreationPrice: Get<<<Self as Config>::Currency as Currency<Self::AccountId>>::Balance>;
440 type TreasuryAccountId: Get<Self::AccountId>;
439}441}
440442
441#[cfg(feature = "runtime-benchmarks")]443#[cfg(feature = "runtime-benchmarks")]
663 // Anyone can create a collection665 // Anyone can create a collection
664 let who = ensure_signed(origin)?;666 let who = ensure_signed(origin)?;
667
668 let mut imbalance = <<<T as Config>::Currency as Currency<T::AccountId>>::PositiveImbalance>::zero();
669 imbalance.subsume(<<T as Config>::Currency as Currency<T::AccountId>>::deposit_creating(
670 &T::TreasuryAccountId::get(),
671 T::CollectionCreationPrice::get(),
672 ));
673 <T as Config>::Currency::settle(
674 &who,
675 imbalance,
676 WithdrawReasons::TRANSFER,
677 ExistenceRequirement::KeepAlive,
678 ).map_err(|_| Error::<T>::NoPermission)?;
665679
666 let decimal_points = match mode {680 let decimal_points = match mode {
667 CollectionMode::Fungible(points) => points,681 CollectionMode::Fungible(points) => points,
2537 > {2551 > {
2538 let tip = self.0;2552 let tip = self.0;
25392553
2540 let fee = match call.is_sub_type() {2554 let fee = Self::traditional_fee(len, info, tip);
2541 Some(Call::create_collection(..)) => T::CollectionCreationPrice::get(),
2542 _ => Self::traditional_fee(len, info, tip),
2543 };
25442555
2545 // Only mess with balances if fee is not zero.2556 // Only mess with balances if fee is not zero.
2546 if fee.is_zero() {2557 if fee.is_zero() {
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -24,7 +24,7 @@
     create_runtime_str, generic, impl_opaque_keys,
     traits::{
         Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 
-        IdentityLookup, NumberFor, Verify,
+        IdentityLookup, NumberFor, Verify, AccountIdConversion,
     },
     transaction_validity::{TransactionSource, TransactionValidity},
     ApplyExtrinsicResult, MultiSignature,
@@ -510,7 +510,6 @@
 
 parameter_types! {
 	pub const MinVestedTransfer: Balance = 10 * UNIQUE;
-	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
 }
 
 impl pallet_vesting::Config for Runtime {
@@ -521,11 +520,18 @@
 	type WeightInfo = ();
 }
 
+parameter_types! {
+	pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
+	pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
+}
+
 /// Used for the module nft in `./nft.rs`
 impl pallet_nft::Config for Runtime {
     type Event = Event;
     type WeightInfo = nft_weights::WeightInfo;
+	type Currency = Balances;
 	type CollectionCreationPrice = CollectionCreationPrice;
+	type TreasuryAccountId = TreasuryAccountId;
 }
 
 construct_runtime!(