Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
feat: add pallet-nfts
Browse files Browse the repository at this point in the history
  • Loading branch information
peterwht committed Oct 3, 2023
1 parent 8aa876d commit 2d6b7af
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 3 deletions.
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ pallet-contracts-primitives = { git = "https://github.com/paritytech/substrate",
pallet-democracy = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-identity = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-multisig = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-nfts = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-preimage = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-insecure-randomness-collective-flip = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
pallet-session = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v1.0.0" }
Expand Down
3 changes: 3 additions & 0 deletions runtime/stout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ pallet-contracts = { workspace = true }
pallet-contracts-primitives = { workspace = true }
pallet-identity = { workspace = true }
pallet-multisig = { workspace = true }
pallet-nfts = { workspace = true }
pallet-preimage = { workspace = true }
pallet-insecure-randomness-collective-flip = { workspace = true }
pallet-session = { workspace = true }
Expand Down Expand Up @@ -135,6 +136,7 @@ std = [
"pallet-dex-rpc-runtime-api/std",
"pallet-identity/std",
"pallet-multisig/std",
"pallet-nfts/std",
"pallet-insecure-randomness-collective-flip/std",
"pallet-scheduler/std",
"pallet-session/std",
Expand Down Expand Up @@ -179,6 +181,7 @@ runtime-benchmarks = [
"pallet-dex/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-uniques/runtime-benchmarks",
Expand Down
45 changes: 43 additions & 2 deletions runtime/stout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use sp_api::impl_runtime_apis;
use sp_core::{crypto::KeyTypeId, ConstBool, ConstU8, 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, Perbill,
};
Expand Down Expand Up @@ -61,7 +61,7 @@ pub use parachains_common as common;
pub use parachains_common::{
impls::{AssetsToBlockAuthor, DealWithFees},
opaque, AccountId, AuraId, Balance, BlockNumber, Hash, Header, Signature,
AVERAGE_ON_INITIALIZE_RATIO, HOURS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO,
AVERAGE_ON_INITIALIZE_RATIO, HOURS, DAYS, MAXIMUM_BLOCK_WEIGHT, MINUTES, NORMAL_DISPATCH_RATIO,
SLOT_DURATION,
};
use sp_std::prelude::*;
Expand Down Expand Up @@ -389,6 +389,45 @@ impl pallet_assets::Config for Runtime {
type BenchmarkHelper = ();
}

parameter_types! {
pub NftsPalletFeatures: pallet_nfts::PalletFeatures = pallet_nfts::PalletFeatures::all_enabled();
pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
pub const NftsMetadataDepositBase: Balance = deposit(1, 129);
pub const NftsAttributeDepositBase: Balance = deposit(1, 0);
pub const NftsDepositPerByte: Balance = deposit(0, 1);
pub const NftsCollectionDeposit: Balance = 100 * UNITS;
pub const NftsItemDeposit: Balance = 1 * UNITS;
}

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<128>;
type KeyLimit = ConstU32<32>;
type ValueLimit = ConstU32<64>;
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 = pallet_nfts::weights::SubstrateWeight<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}

parameter_types! {
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}
Expand Down Expand Up @@ -588,6 +627,7 @@ construct_runtime!(
Preimage: pallet_preimage = 48,
Multisig: pallet_multisig = 49,
Dex: pallet_dex = 50,
Nfts: pallet_nfts = 51,

Spambot: cumulus_ping::{Pallet, Call, Storage, Event<T>} = 99,
AssetRegistry: pallet_asset_registry::{Pallet, Call, Storage, Event<T>} = 111,
Expand All @@ -611,6 +651,7 @@ mod benches {
[pallet_assets, Assets]
[pallet_identity, Identity]
[pallet_multisig, Multisig]
[pallet_nfts, Nfts]
[pallet_uniques, Uniques]
[pallet_dex, Dex]
[pallet_scheduler, Scheduler]
Expand Down
4 changes: 4 additions & 0 deletions runtime/trappist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pallet-contracts-primitives = { workspace = true }
pallet-democracy = { workspace = true }
pallet-identity = { workspace = true }
pallet-multisig = { workspace = true }
pallet-nfts = { workspace = true }
pallet-preimage = { workspace = true }
pallet-insecure-randomness-collective-flip = { workspace = true }
pallet-session = { workspace = true }
Expand Down Expand Up @@ -151,6 +152,7 @@ std = [
"pallet-preimage/std",
"pallet-withdraw-teleport/std",
"pallet-multisig/std",
"pallet-nfts/std",
"pallet-insecure-randomness-collective-flip/std",
"pallet-scheduler/std",
"pallet-session/std",
Expand Down Expand Up @@ -202,6 +204,7 @@ runtime-benchmarks = [
"pallet-lockdown-mode/runtime-benchmarks",
"pallet-preimage/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-nfts/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-treasury/runtime-benchmarks",
Expand Down Expand Up @@ -231,6 +234,7 @@ try-runtime = [
"pallet-identity/try-runtime",
"pallet-lockdown-mode/try-runtime",
"pallet-multisig/try-runtime",
"pallet-nfts/try-runtime",
"pallet-scheduler/try-runtime",
"pallet-timestamp/try-runtime",
"pallet-treasury/try-runtime",
Expand Down
43 changes: 42 additions & 1 deletion runtime/trappist/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use sp_core::{crypto::KeyTypeId, ConstBool, ConstU8, OpaqueMetadata};
pub use sp_runtime::BuildStorage;
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::{InvalidTransaction, TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill, Percent, Permill,
};
Expand Down Expand Up @@ -392,6 +392,45 @@ impl pallet_assets::Config for Runtime {
type BenchmarkHelper = ();
}

parameter_types! {
pub NftsPalletFeatures: pallet_nfts::PalletFeatures = pallet_nfts::PalletFeatures::all_enabled();
pub const NftsMaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
pub const NftsMetadataDepositBase: Balance = deposit(1, 129);
pub const NftsAttributeDepositBase: Balance = deposit(1, 0);
pub const NftsDepositPerByte: Balance = deposit(0, 1);
pub const NftsCollectionDeposit: Balance = 100 * UNITS;
pub const NftsItemDeposit: Balance = 1 * UNITS;
}

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<128>;
type KeyLimit = ConstU32<32>;
type ValueLimit = ConstU32<64>;
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 = pallet_nfts::weights::SubstrateWeight<Runtime>;
#[cfg(feature = "runtime-benchmarks")]
type Helper = ();
}

parameter_types! {
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * RuntimeBlockWeights::get().max_block;
}
Expand Down Expand Up @@ -701,6 +740,7 @@ construct_runtime!(
Scheduler: pallet_scheduler = 44,
Preimage: pallet_preimage = 45,
LockdownMode: pallet_lockdown_mode = 46,
Nfts: pallet_nfts = 47,

// Handy utilities.
Utility: pallet_utility::{Pallet, Call, Event} = 50,
Expand Down Expand Up @@ -771,6 +811,7 @@ mod benches {
[pallet_dex, Dex]
[pallet_identity, Identity]
[pallet_multisig, Multisig]
[pallet_nfts, Nfts]
[pallet_uniques, Uniques]
[pallet_scheduler, Scheduler]
[pallet_utility, Utility]
Expand Down

0 comments on commit 2d6b7af

Please sign in to comment.