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
24 create_runtime_str, generic, impl_opaque_keys,24 create_runtime_str, generic, impl_opaque_keys,
25 traits::{25 traits::{
26 Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 26 Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount,
27 IdentityLookup, NumberFor, Verify,27 IdentityLookup, NumberFor, Verify, AccountIdConversion,
28 },28 },
29 transaction_validity::{TransactionSource, TransactionValidity},29 transaction_validity::{TransactionSource, TransactionValidity},
30 ApplyExtrinsicResult, MultiSignature,30 ApplyExtrinsicResult, MultiSignature,
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;
514}513}
515514
516impl pallet_vesting::Config for Runtime {515impl pallet_vesting::Config for Runtime {
521 type WeightInfo = ();520 type WeightInfo = ();
522}521}
522
523parameter_types! {
524 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();
525 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;
526}
523527
524/// Used for the module nft in `./nft.rs`528/// Used for the module nft in `./nft.rs`
525impl pallet_nft::Config for Runtime {529impl pallet_nft::Config for Runtime {
526 type Event = Event;530 type Event = Event;
527 type WeightInfo = nft_weights::WeightInfo;531 type WeightInfo = nft_weights::WeightInfo;
532 type Currency = Balances;
528 type CollectionCreationPrice = CollectionCreationPrice;533 type CollectionCreationPrice = CollectionCreationPrice;
534 type TreasuryAccountId = TreasuryAccountId;
529}535}
530536
531construct_runtime!(537construct_runtime!(