difftreelog
feat explicit collection creation fee
in: master
2 files changed
pallets/nft/src/lib.rsdiffbeforeafterboth20 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;437437438 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}440442441#[cfg(feature = "runtime-benchmarks")]443#[cfg(feature = "runtime-benchmarks")]663 // Anyone can create a collection665 // Anyone can create a collection664 let who = ensure_signed(origin)?;666 let who = ensure_signed(origin)?;667668 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)?;665679666 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;253925532540 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 };254425552545 // 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() {runtime/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!(