-
Notifications
You must be signed in to change notification settings - Fork 379
NFTs 2.0 on Statemine #2314
NFTs 2.0 on Statemine #2314
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ use sp_api::impl_runtime_apis; | |
use sp_core::{crypto::KeyTypeId, OpaqueMetadata}; | ||
use sp_runtime::{ | ||
create_runtime_str, generic, impl_opaque_keys, | ||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto}, | ||
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, Verify}, | ||
transaction_validity::{TransactionSource, TransactionValidity}, | ||
ApplyExtrinsicResult, | ||
}; | ||
|
@@ -57,11 +57,12 @@ use frame_system::{ | |
limits::{BlockLength, BlockWeights}, | ||
EnsureRoot, EnsureSigned, | ||
}; | ||
use pallet_nfts::PalletFeatures; | ||
pub use parachains_common as common; | ||
use parachains_common::{ | ||
impls::{AssetsToBlockAuthor, DealWithFees}, | ||
opaque, AccountId, AssetIdForTrustBackedAssets, AuraId, Balance, BlockNumber, Hash, Header, | ||
Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, | ||
Index, Signature, AVERAGE_ON_INITIALIZE_RATIO, DAYS, HOURS, MAXIMUM_BLOCK_WEIGHT, | ||
NORMAL_DISPATCH_RATIO, SLOT_DURATION, | ||
}; | ||
use xcm_config::{KsmLocation, TrustBackedAssetsConvertedConcreteId, XcmConfig}; | ||
|
@@ -338,6 +339,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |
c, | ||
RuntimeCall::Balances { .. } | | ||
RuntimeCall::Assets { .. } | | ||
RuntimeCall::Nfts { .. } | | ||
RuntimeCall::Uniques { .. } | ||
), | ||
ProxyType::CancelProxy => matches!( | ||
|
@@ -352,7 +354,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |
RuntimeCall::Assets { .. } | | ||
RuntimeCall::Utility { .. } | | ||
RuntimeCall::Multisig { .. } | | ||
RuntimeCall::Uniques { .. } | ||
RuntimeCall::Nfts { .. } | RuntimeCall::Uniques { .. } | ||
) | ||
}, | ||
ProxyType::AssetOwner => matches!( | ||
|
@@ -366,6 +368,13 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |
RuntimeCall::Assets(TrustBackedAssetsCall::set_team { .. }) | | ||
RuntimeCall::Assets(TrustBackedAssetsCall::set_metadata { .. }) | | ||
RuntimeCall::Assets(TrustBackedAssetsCall::clear_metadata { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::create { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::destroy { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::redeposit { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::transfer_ownership { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::set_team { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::set_collection_max_supply { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::lock_collection { .. }) | | ||
RuntimeCall::Uniques(pallet_uniques::Call::create { .. }) | | ||
RuntimeCall::Uniques(pallet_uniques::Call::destroy { .. }) | | ||
RuntimeCall::Uniques(pallet_uniques::Call::transfer_ownership { .. }) | | ||
|
@@ -388,6 +397,17 @@ impl InstanceFilter<RuntimeCall> for ProxyType { | |
RuntimeCall::Assets(TrustBackedAssetsCall::thaw { .. }) | | ||
RuntimeCall::Assets(TrustBackedAssetsCall::freeze_asset { .. }) | | ||
RuntimeCall::Assets(TrustBackedAssetsCall::thaw_asset { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::force_mint { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::update_mint_settings { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::mint_pre_signed { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::set_attributes_pre_signed { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::lock_item_transfer { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::unlock_item_transfer { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::lock_item_properties { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::set_metadata { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::clear_metadata { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::set_collection_metadata { .. }) | | ||
RuntimeCall::Nfts(pallet_nfts::Call::clear_collection_metadata { .. }) | | ||
RuntimeCall::Uniques(pallet_uniques::Call::mint { .. }) | | ||
RuntimeCall::Uniques(pallet_uniques::Call::burn { .. }) | | ||
RuntimeCall::Uniques(pallet_uniques::Call::freeze { .. }) | | ||
|
@@ -559,14 +579,11 @@ impl pallet_asset_tx_payment::Config for Runtime { | |
} | ||
|
||
parameter_types! { | ||
pub const CollectionDeposit: Balance = UNITS / 10; // 1 / 10 UNIT deposit to create asset class | ||
pub const ItemDeposit: Balance = UNITS / 1_000; // 1 / 1000 UNIT deposit to create asset instance | ||
pub const KeyLimit: u32 = 32; // Max 32 bytes per key | ||
pub const ValueLimit: u32 = 64; // Max 64 bytes per value | ||
pub const UniquesCollectionDeposit: Balance = UNITS / 10; // 1 / 10 UNIT deposit to create a collection | ||
pub const UniquesItemDeposit: Balance = UNITS / 1_000; // 1 / 1000 UNIT deposit to mint an item | ||
pub const UniquesMetadataDepositBase: Balance = deposit(1, 129); | ||
pub const AttributeDepositBase: Balance = deposit(1, 0); | ||
pub const DepositPerByte: Balance = deposit(0, 1); | ||
pub const UniquesStringLimit: u32 = 128; | ||
pub const UniquesAttributeDepositBase: Balance = deposit(1, 0); | ||
pub const UniquesDepositPerByte: Balance = deposit(0, 1); | ||
} | ||
|
||
impl pallet_uniques::Config for Runtime { | ||
|
@@ -575,21 +592,61 @@ impl pallet_uniques::Config for Runtime { | |
type ItemId = u32; | ||
type Currency = Balances; | ||
type ForceOrigin = AssetsForceOrigin; | ||
type CollectionDeposit = CollectionDeposit; | ||
type ItemDeposit = ItemDeposit; | ||
type CollectionDeposit = UniquesCollectionDeposit; | ||
type ItemDeposit = UniquesItemDeposit; | ||
type MetadataDepositBase = UniquesMetadataDepositBase; | ||
type AttributeDepositBase = AttributeDepositBase; | ||
type DepositPerByte = DepositPerByte; | ||
type StringLimit = UniquesStringLimit; | ||
type KeyLimit = KeyLimit; | ||
type ValueLimit = ValueLimit; | ||
type AttributeDepositBase = UniquesAttributeDepositBase; | ||
type DepositPerByte = UniquesDepositPerByte; | ||
type StringLimit = ConstU32<128>; | ||
type KeyLimit = ConstU32<32>; | ||
type ValueLimit = ConstU32<64>; | ||
type WeightInfo = weights::pallet_uniques::WeightInfo<Runtime>; | ||
#[cfg(feature = "runtime-benchmarks")] | ||
type Helper = (); | ||
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>; | ||
type Locker = (); | ||
} | ||
|
||
parameter_types! { | ||
pub NftsPalletFeatures: PalletFeatures = PalletFeatures::all_enabled(); | ||
pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS; | ||
// re-use the Uniques deposits | ||
pub const NftsCollectionDeposit: Balance = UniquesCollectionDeposit::get(); | ||
pub const NftsItemDeposit: Balance = UniquesItemDeposit::get(); | ||
pub const NftsMetadataDepositBase: Balance = UniquesMetadataDepositBase::get(); | ||
pub const NftsAttributeDepositBase: Balance = UniquesAttributeDepositBase::get(); | ||
pub const NftsDepositPerByte: Balance = UniquesDepositPerByte::get(); | ||
} | ||
|
||
impl pallet_nfts::Config for Runtime { | ||
type RuntimeEvent = RuntimeEvent; | ||
type CollectionId = u32; | ||
type ItemId = u32; | ||
type Currency = Balances; | ||
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>; | ||
type ForceOrigin = AssetsForceOrigin; | ||
type Locker = (); | ||
type CollectionDeposit = NftsCollectionDeposit; | ||
type ItemDeposit = NftsItemDeposit; | ||
type MetadataDepositBase = NftsMetadataDepositBase; | ||
type AttributeDepositBase = NftsAttributeDepositBase; | ||
type DepositPerByte = NftsDepositPerByte; | ||
type StringLimit = ConstU32<256>; | ||
type KeyLimit = ConstU32<64>; | ||
type ValueLimit = ConstU32<256>; | ||
Comment on lines
+634
to
+636
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a rationale how those numbers were chosen and why they are different between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
type ApprovalsLimit = ConstU32<20>; | ||
type ItemAttributesApprovalsLimit = ConstU32<30>; | ||
type MaxTips = ConstU32<10>; | ||
type MaxDeadlineDuration = NftsMaxDeadlineDuration; | ||
type MaxAttributesPerCall = ConstU32<10>; | ||
type Features = NftsPalletFeatures; | ||
type OffchainSignature = Signature; | ||
type OffchainPublic = <Signature as Verify>::Signer; | ||
type WeightInfo = weights::pallet_nfts::WeightInfo<Runtime>; | ||
#[cfg(feature = "runtime-benchmarks")] | ||
type Helper = (); | ||
} | ||
|
||
// Create the runtime by composing the FRAME pallets that were previously configured. | ||
construct_runtime!( | ||
pub enum Runtime where | ||
|
@@ -632,6 +689,7 @@ construct_runtime!( | |
// The main stage. | ||
Assets: pallet_assets::<Instance1>::{Pallet, Call, Storage, Event<T>} = 50, | ||
Uniques: pallet_uniques::{Pallet, Call, Storage, Event<T>} = 51, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's going to stay for now until we get the UI support for the new pallet and make a decision on the proper migration path |
||
Nfts: pallet_nfts::{Pallet, Call, Storage, Event<T>} = 52, | ||
|
||
#[cfg(feature = "state-trie-version-1")] | ||
StateTrieMigration: pallet_state_trie_migration = 70, | ||
|
@@ -686,6 +744,7 @@ mod benches { | |
[pallet_assets, Assets] | ||
[pallet_balances, Balances] | ||
[pallet_multisig, Multisig] | ||
[pallet_nfts, Nfts] | ||
[pallet_proxy, Proxy] | ||
[pallet_session, SessionBench::<Runtime>] | ||
[pallet_uniques, Uniques] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should allow foreign origins as well, so that collectives can create collections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could also be an upgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do this as an upgrade once we get to the integration with collectives