Skip to content

Commit 0c2b19c

Browse files
jsidorenkoSzegoogilescopeKiChjangggwpez
authored andcommitted
NFTs 2.0 (paritytech#12765)
* Copy Uniques into Nfts * Connect new pallet * Update weights * Nfts: Multiple approvals (paritytech#12178) * multiple approvals * clear * tests & clean up * fix in logic & fmt * fix benchmarks * deadline * test deadline * current_block + deadline * update ApprovedTransfer event * benchmark * docs * Update frame/nfts/src/lib.rs Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * fmt fix * Update frame/nfts/src/lib.rs Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * update tests * anyone can cancel * Update frame/nfts/src/tests.rs Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * fmt * fix logic * unnecessary line * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Update frame/nfts/src/lib.rs * Update lib.rs * fmt * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * fmt * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * suggestion * new line * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Co-authored-by: command-bot <> Co-authored-by: Squirrel <gilescope@gmail.com> * Fixes * cargo fmt * Fixes * Fixes * Fix CI * Nfts: Fix Auto-Increment (paritytech#12223) * commit * passing benchmarks * clean up * sync * runtime implementation * fix * fmt * fix benchmark * cfg * remove try-increment-id * remove unused error * impl Incrementable for unsigned types * clean up * fix in tests * not needed anymore * Use OptionQuery Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> * Rename Origin to RuntimeOrigin * [Uniques V2] Tips (paritytech#12168) * Allow to add tips when buying an NFT * Chore * Rework tips feature * Add weights + benchmarks * Convert tuple to struct * Fix benchmark * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Update frame/nfts/src/benchmarking.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix benchmarks * Revert the bounded_vec![] approach * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts Co-authored-by: command-bot <> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * [Uniques V2] Atomic NFTs swap (paritytech#12285) * Atomic NFTs swap * Fmt * Fix benchmark * Rename swap -> atomic_swap * Update target balance * Rollback * Fix * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Make desired item optional * Apply suggestions * Update frame/nfts/src/features/atomic_swap.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Rename fields * Optimisation * Add a comment * deadline -> maybe_deadline * Add docs * Change comments * Add price direction field * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Wrap price and direction * Fix benchmarks * Use ensure! instead of if {} * Make duration param mandatory and limit it to MaxDeadlineDuration * Make the code safer * Fix clippy * Chore * Remove unused vars * try * try 2 * try 3 Co-authored-by: command-bot <> Co-authored-by: Squirrel <gilescope@gmail.com> * [Uniques V2] Feature flags (paritytech#12367) * Basics * WIP: change the data format * Refactor * Remove redundant new() method * Rename settings * Enable tests * Chore * Change params order * Delete the config on collection removal * Chore * Remove redundant system features * Rename force_item_status to force_collection_status * Update node runtime * Chore * Remove thaw_collection * Chore * Connect collection.is_frozen to config * Allow to lock the collection in a new way * Move free_holding into settings * Connect collection's metadata locker to feature flags * DRY * Chore * Connect pallet level feature flags * Prepare tests for the new changes * Implement Item settings * Allow to lock the metadata or attributes of an item * Common -> Settings * Extract settings related code to a separate file * Move feature flag checks inside the do_* methods * Split settings.rs into parts * Extract repeated code into macro * Extract macros into their own file * Chore * Fix traits * Fix traits * Test SystemFeatures * Fix benchmarks * Add missing benchmark * Fix node/runtime/lib.rs * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Keep item's config on burn if it's not empty * Fix the merge artifacts * Fmt * Add SystemFeature::NoSwaps check * Rename SystemFeatures to PalletFeatures * Rename errors * Add docs * Change error message * Rework pallet features * Move macros * Change comments * Fmt * Refactor Incrementable * Use pub(crate) for do_* functions * Update comments * Refactor freeze and lock functions * Rework Collection config and Item confg api * Chore * Make clippy happy * Chore * Update comment * RequiredDeposit => DepositRequired * Address comments Co-authored-by: command-bot <> * [Uniques V2] Refactor roles (paritytech#12437) * Basics * WIP: change the data format * Refactor * Remove redundant new() method * Rename settings * Enable tests * Chore * Change params order * Delete the config on collection removal * Chore * Remove redundant system features * Rename force_item_status to force_collection_status * Update node runtime * Chore * Remove thaw_collection * Chore * Connect collection.is_frozen to config * Allow to lock the collection in a new way * Move free_holding into settings * Connect collection's metadata locker to feature flags * DRY * Chore * Connect pallet level feature flags * Prepare tests for the new changes * Implement Item settings * Allow to lock the metadata or attributes of an item * Common -> Settings * Extract settings related code to a separate file * Move feature flag checks inside the do_* methods * Split settings.rs into parts * Extract repeated code into macro * Extract macros into their own file * Chore * Fix traits * Fix traits * Test SystemFeatures * Fix benchmarks * Add missing benchmark * Fix node/runtime/lib.rs * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Keep item's config on burn if it's not empty * Fix the merge artifacts * Fmt * Add SystemFeature::NoSwaps check * Refactor roles structure * Rename SystemFeatures to PalletFeatures * Rename errors * Add docs * Change error message * Rework pallet features * Move macros * Change comments * Fmt * Refactor Incrementable * Use pub(crate) for do_* functions * Update comments * Refactor freeze and lock functions * Rework Collection config and Item confg api * Chore * Make clippy happy * Chore * Fix artifacts * Address comments * Further refactoring * Add comments * Add tests for group_roles_by_account() * Update frame/nfts/src/impl_nonfungibles.rs * Add test * Replace Itertools group_by with a custom implementation * ItemsNotTransferable => ItemsNonTransferable * Update frame/nfts/src/features/roles.rs Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> * Address PR comments * Add missed comment Co-authored-by: command-bot <> Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> * Fix copy * Remove storage_prefix * Remove transactional * Update comment * [Uniques V2] Minting options (paritytech#12483) * Basics * WIP: change the data format * Refactor * Remove redundant new() method * Rename settings * Enable tests * Chore * Change params order * Delete the config on collection removal * Chore * Remove redundant system features * Rename force_item_status to force_collection_status * Update node runtime * Chore * Remove thaw_collection * Chore * Connect collection.is_frozen to config * Allow to lock the collection in a new way * Move free_holding into settings * Connect collection's metadata locker to feature flags * DRY * Chore * Connect pallet level feature flags * Prepare tests for the new changes * Implement Item settings * Allow to lock the metadata or attributes of an item * Common -> Settings * Extract settings related code to a separate file * Move feature flag checks inside the do_* methods * Split settings.rs into parts * Extract repeated code into macro * Extract macros into their own file * Chore * Fix traits * Fix traits * Test SystemFeatures * Fix benchmarks * Add missing benchmark * Fix node/runtime/lib.rs * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Keep item's config on burn if it's not empty * Fix the merge artifacts * Fmt * Add SystemFeature::NoSwaps check * Rename SystemFeatures to PalletFeatures * Rename errors * Add docs * Change error message * Change the format of CollectionConfig to store more data * Move max supply to the CollectionConfig and allow to change it * Remove ItemConfig from the mint() function and use the one set in mint settings * Add different mint options * Allow to change the mint settings * Add a force_mint() method * Check mint params * Some optimisations * Cover with tests * Remove merge artifacts * Chore * Use the new has_role() method * Rework item deposits * More tests * Refactoring * Address comments * Refactor lock_collection() * Update frame/nfts/src/types.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/types.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Private => Issuer * Add more tests * Fix benchmarks * Add benchmarks for new methods * [Uniques v2] Refactoring (paritytech#12570) * Move do_set_price() and do_buy_item() to buy_sell.rs * Move approvals to feature file * Move metadata to feature files * Move the rest of methods to feature files * Remove artifacts * Split force_collection_status into 2 methods * Fix benchmarks * Fix benchmarks * Update deps Co-authored-by: command-bot <> Co-authored-by: Squirrel <gilescope@gmail.com> * [Uniques V2] Smart attributes (paritytech#12702) * Basics * WIP: change the data format * Refactor * Remove redundant new() method * Rename settings * Enable tests * Chore * Change params order * Delete the config on collection removal * Chore * Remove redundant system features * Rename force_item_status to force_collection_status * Update node runtime * Chore * Remove thaw_collection * Chore * Connect collection.is_frozen to config * Allow to lock the collection in a new way * Move free_holding into settings * Connect collection's metadata locker to feature flags * DRY * Chore * Connect pallet level feature flags * Prepare tests for the new changes * Implement Item settings * Allow to lock the metadata or attributes of an item * Common -> Settings * Extract settings related code to a separate file * Move feature flag checks inside the do_* methods * Split settings.rs into parts * Extract repeated code into macro * Extract macros into their own file * Chore * Fix traits * Fix traits * Test SystemFeatures * Fix benchmarks * Add missing benchmark * Fix node/runtime/lib.rs * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Keep item's config on burn if it's not empty * Fix the merge artifacts * Fmt * Add SystemFeature::NoSwaps check * Rename SystemFeatures to PalletFeatures * Rename errors * Add docs * Change error message * Change the format of CollectionConfig to store more data * Move max supply to the CollectionConfig and allow to change it * Remove ItemConfig from the mint() function and use the one set in mint settings * Add different mint options * Allow to change the mint settings * Add a force_mint() method * Check mint params * Some optimisations * Cover with tests * Remove merge artifacts * Chore * Use the new has_role() method * Rework item deposits * More tests * Refactoring * Address comments * Refactor lock_collection() * Update frame/nfts/src/types.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/types.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Private => Issuer * Add more tests * Fix benchmarks * Add benchmarks for new methods * [Uniques v2] Refactoring (paritytech#12570) * Move do_set_price() and do_buy_item() to buy_sell.rs * Move approvals to feature file * Move metadata to feature files * Move the rest of methods to feature files * Remove artifacts * Smart attributes * Split force_collection_status into 2 methods * Fix benchmarks * Fix benchmarks * Update deps * Fix merge artifact * Weights + benchmarks + docs * Change params order * Chore * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Update docs * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * Add PalletId * Chore * Add tests * More tests * Add doc * Update errors snapshots * Ensure we track the owner_deposit field correctly Co-authored-by: command-bot <> Co-authored-by: Squirrel <gilescope@gmail.com> * [Uniques V2] Final improvements (paritytech#12736) * Use KeyPrefixIterator instead of Box * Change create_collection() * Restrict from claiming NFTs twice * Update Readme * Remove dead code * Refactoring * Update readme * Fix clippy * Update frame/nfts/src/lib.rs Co-authored-by: Squirrel <gilescope@gmail.com> * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Update docs * Typo * Fix benchmarks * Add more docs * DepositRequired setting should affect only the attributes within the CollectionOwner namespace * [NFTs] Implement missed methods to set the attributes from other pallets (paritytech#12919) * Implement missed methods to set the attributes from other pallets * Revert snapshots * Update snapshot * Update snapshot * Revert snapshot changes * Update snapshots * Yet another snapshot update.. * Update frame/support/src/traits/tokens/nonfungible_v2.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/support/src/traits/tokens/nonfungible_v2.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/support/src/traits/tokens/nonfungible_v2.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/support/src/traits/tokens/nonfungibles_v2.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/support/src/traits/tokens/nonfungible_v2.rs * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/support/src/traits/tokens/nonfungibles_v2.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Address comments * [NFTs] Add the new `owner` param to mint() method (paritytech#12997) * Add the new `owner` param to mint() method * Fmt * Address comments * ".git/.scripts/bench-bot.sh" pallet dev pallet_nfts * Update frame/nfts/src/common_functions.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/types.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/types.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/types.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/types.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update frame/nfts/src/types.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Add call indexes * Update snapshots Co-authored-by: Sergej Sakac <73715684+Szegoo@users.noreply.github.com> Co-authored-by: Squirrel <gilescope@gmail.com> Co-authored-by: Keith Yeung <kungfukeith11@gmail.com> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com> Co-authored-by: command-bot <> Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
1 parent 8aa13e0 commit 0c2b19c

36 files changed

+9269
-13
lines changed

Cargo.lock

+21-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ members = [
122122
"frame/preimage",
123123
"frame/proxy",
124124
"frame/message-queue",
125+
"frame/nfts",
125126
"frame/nomination-pools",
126127
"frame/nomination-pools/fuzzer",
127128
"frame/nomination-pools/benchmarking",

bin/node/runtime/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pallet-membership = { version = "4.0.0-dev", default-features = false, path = ".
7878
pallet-message-queue = { version = "7.0.0-dev", default-features = false, path = "../../../frame/message-queue" }
7979
pallet-mmr = { version = "4.0.0-dev", default-features = false, path = "../../../frame/merkle-mountain-range" }
8080
pallet-multisig = { version = "4.0.0-dev", default-features = false, path = "../../../frame/multisig" }
81+
pallet-nfts = { version = "4.0.0-dev", default-features = false, path = "../../../frame/nfts" }
8182
pallet-nomination-pools = { version = "1.0.0", default-features = false, path = "../../../frame/nomination-pools"}
8283
pallet-nomination-pools-benchmarking = { version = "1.0.0", default-features = false, optional = true, path = "../../../frame/nomination-pools/benchmarking" }
8384
pallet-nomination-pools-runtime-api = { version = "1.0.0-dev", default-features = false, path = "../../../frame/nomination-pools/runtime-api" }
@@ -197,6 +198,7 @@ std = [
197198
"pallet-root-testing/std",
198199
"pallet-recovery/std",
199200
"pallet-uniques/std",
201+
"pallet-nfts/std",
200202
"pallet-vesting/std",
201203
"log/std",
202204
"frame-try-runtime?/std",
@@ -253,6 +255,7 @@ runtime-benchmarks = [
253255
"pallet-treasury/runtime-benchmarks",
254256
"pallet-utility/runtime-benchmarks",
255257
"pallet-uniques/runtime-benchmarks",
258+
"pallet-nfts/runtime-benchmarks",
256259
"pallet-vesting/runtime-benchmarks",
257260
"pallet-whitelist/runtime-benchmarks",
258261
"frame-system-benchmarking/runtime-benchmarks",
@@ -312,6 +315,7 @@ try-runtime = [
312315
"pallet-asset-tx-payment/try-runtime",
313316
"pallet-transaction-storage/try-runtime",
314317
"pallet-uniques/try-runtime",
318+
"pallet-nfts/try-runtime",
315319
"pallet-vesting/try-runtime",
316320
"pallet-whitelist/try-runtime",
317321
]

bin/node/runtime/src/lib.rs

+38
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ use pallet_grandpa::{
5656
fg_primitives, AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList,
5757
};
5858
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
59+
use pallet_nfts::PalletFeatures;
5960
use pallet_nis::WithMaximumOf;
6061
use pallet_session::historical::{self as pallet_session_historical};
6162
pub use pallet_transaction_payment::{CurrencyAdapter, Multiplier, TargetedFeeAdjustment};
@@ -301,6 +302,7 @@ impl InstanceFilter<RuntimeCall> for ProxyType {
301302
RuntimeCall::Balances(..) |
302303
RuntimeCall::Assets(..) |
303304
RuntimeCall::Uniques(..) |
305+
RuntimeCall::Nfts(..) |
304306
RuntimeCall::Vesting(pallet_vesting::Call::vested_transfer { .. }) |
305307
RuntimeCall::Indices(pallet_indices::Call::transfer { .. })
306308
),
@@ -1528,6 +1530,10 @@ parameter_types! {
15281530
pub const ItemDeposit: Balance = 1 * DOLLARS;
15291531
pub const KeyLimit: u32 = 32;
15301532
pub const ValueLimit: u32 = 256;
1533+
pub const ApprovalsLimit: u32 = 20;
1534+
pub const ItemAttributesApprovalsLimit: u32 = 20;
1535+
pub const MaxTips: u32 = 10;
1536+
pub const MaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
15311537
}
15321538

15331539
impl pallet_uniques::Config for Runtime {
@@ -1551,6 +1557,36 @@ impl pallet_uniques::Config for Runtime {
15511557
type Locker = ();
15521558
}
15531559

1560+
parameter_types! {
1561+
pub Features: PalletFeatures = PalletFeatures::all_enabled();
1562+
}
1563+
1564+
impl pallet_nfts::Config for Runtime {
1565+
type RuntimeEvent = RuntimeEvent;
1566+
type CollectionId = u32;
1567+
type ItemId = u32;
1568+
type Currency = Balances;
1569+
type ForceOrigin = frame_system::EnsureRoot<AccountId>;
1570+
type CollectionDeposit = CollectionDeposit;
1571+
type ItemDeposit = ItemDeposit;
1572+
type MetadataDepositBase = MetadataDepositBase;
1573+
type AttributeDepositBase = MetadataDepositBase;
1574+
type DepositPerByte = MetadataDepositPerByte;
1575+
type StringLimit = StringLimit;
1576+
type KeyLimit = KeyLimit;
1577+
type ValueLimit = ValueLimit;
1578+
type ApprovalsLimit = ApprovalsLimit;
1579+
type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit;
1580+
type MaxTips = MaxTips;
1581+
type MaxDeadlineDuration = MaxDeadlineDuration;
1582+
type Features = Features;
1583+
type WeightInfo = pallet_nfts::weights::SubstrateWeight<Runtime>;
1584+
#[cfg(feature = "runtime-benchmarks")]
1585+
type Helper = ();
1586+
type CreateOrigin = AsEnsureOriginWithArg<EnsureSigned<AccountId>>;
1587+
type Locker = ();
1588+
}
1589+
15541590
impl pallet_transaction_storage::Config for Runtime {
15551591
type RuntimeEvent = RuntimeEvent;
15561592
type Currency = Balances;
@@ -1705,6 +1741,7 @@ construct_runtime!(
17051741
Lottery: pallet_lottery,
17061742
Nis: pallet_nis,
17071743
Uniques: pallet_uniques,
1744+
Nfts: pallet_nfts,
17081745
TransactionStorage: pallet_transaction_storage,
17091746
VoterList: pallet_bags_list::<Instance1>,
17101747
StateTrieMigration: pallet_state_trie_migration,
@@ -1836,6 +1873,7 @@ mod benches {
18361873
[pallet_transaction_storage, TransactionStorage]
18371874
[pallet_treasury, Treasury]
18381875
[pallet_uniques, Uniques]
1876+
[pallet_nfts, Nfts]
18391877
[pallet_utility, Utility]
18401878
[pallet_vesting, Vesting]
18411879
[pallet_whitelist, Whitelist]

frame/nfts/Cargo.toml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[package]
2+
name = "pallet-nfts"
3+
version = "4.0.0-dev"
4+
authors = ["Parity Technologies <admin@parity.io>"]
5+
edition = "2021"
6+
license = "Apache-2.0"
7+
homepage = "https://substrate.io"
8+
repository = "https://github.com/paritytech/substrate/"
9+
description = "FRAME NFTs pallet"
10+
readme = "README.md"
11+
12+
[package.metadata.docs.rs]
13+
targets = ["x86_64-unknown-linux-gnu"]
14+
15+
[dependencies]
16+
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false }
17+
enumflags2 = { version = "0.7.5" }
18+
log = { version = "0.4.17", default-features = false }
19+
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
20+
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, path = "../benchmarking" }
21+
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
22+
frame-system = { version = "4.0.0-dev", default-features = false, path = "../system" }
23+
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
24+
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }
25+
26+
[dev-dependencies]
27+
pallet-balances = { version = "4.0.0-dev", path = "../balances" }
28+
sp-core = { version = "7.0.0", path = "../../primitives/core" }
29+
sp-io = { version = "7.0.0", path = "../../primitives/io" }
30+
sp-std = { version = "5.0.0", path = "../../primitives/std" }
31+
32+
[features]
33+
default = ["std"]
34+
std = [
35+
"codec/std",
36+
"frame-benchmarking?/std",
37+
"frame-support/std",
38+
"frame-system/std",
39+
"log/std",
40+
"scale-info/std",
41+
"sp-runtime/std",
42+
"sp-std/std",
43+
]
44+
runtime-benchmarks = [
45+
"frame-benchmarking/runtime-benchmarks",
46+
"frame-system/runtime-benchmarks",
47+
"sp-runtime/runtime-benchmarks",
48+
]
49+
try-runtime = ["frame-support/try-runtime"]

frame/nfts/README.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# NFTs pallet
2+
3+
A pallet for dealing with non-fungible assets.
4+
5+
## Overview
6+
7+
The NFTs pallet provides functionality for non-fungible tokens' management, including:
8+
9+
* Collection Creation
10+
* NFT Minting
11+
* NFT Transfers and Atomic Swaps
12+
* NFT Trading methods
13+
* Attributes Management
14+
* NFT Burning
15+
16+
To use it in your runtime, you need to implement [`nfts::Config`](https://paritytech.github.io/substrate/master/pallet_nfts/pallet/trait.Config.html).
17+
18+
The supported dispatchable functions are documented in the [`nfts::Call`](https://paritytech.github.io/substrate/master/pallet_nfts/pallet/enum.Call.html) enum.
19+
20+
### Terminology
21+
22+
* **Collection creation:** The creation of a new collection.
23+
* **NFT minting:** The action of creating a new item within a collection.
24+
* **NFT transfer:** The action of sending an item from one account to another.
25+
* **Atomic swap:** The action of exchanging items between accounts without needing a 3rd party service.
26+
* **NFT burning:** The destruction of an item.
27+
* **Non-fungible token (NFT):** An item for which each unit has unique characteristics. There is exactly
28+
one instance of such an item in existence and there is exactly one owning account (though that owning account could be a proxy account or multi-sig account).
29+
* **Soul Bound NFT:** An item that is non-transferable from the account which it is minted into.
30+
31+
### Goals
32+
33+
The NFTs pallet in Substrate is designed to make the following possible:
34+
35+
* Allow accounts to permissionlessly create nft collections.
36+
* Allow a named (permissioned) account to mint and burn unique items within a collection.
37+
* Move items between accounts permissionlessly.
38+
* Allow a named (permissioned) account to freeze and unfreeze items within a
39+
collection or the entire collection.
40+
* Allow the owner of an item to delegate the ability to transfer the item to some
41+
named third-party.
42+
* Allow third-parties to store information in an NFT _without_ owning it (Eg. save game state).
43+
44+
## Interface
45+
46+
### Permissionless dispatchables
47+
48+
* `create`: Create a new collection by placing a deposit.
49+
* `mint`: Mint a new item within a collection (when the minting is public).
50+
* `transfer`: Send an item to a new owner.
51+
* `redeposit`: Update the deposit amount of an item, potentially freeing funds.
52+
* `approve_transfer`: Name a delegate who may authorize a transfer.
53+
* `cancel_approval`: Revert the effects of a previous `approve_transfer`.
54+
* `approve_item_attributes`: Name a delegate who may change item's attributes within a namespace.
55+
* `cancel_item_attributes_approval`: Revert the effects of a previous `approve_item_attributes`.
56+
* `set_price`: Set the price for an item.
57+
* `buy_item`: Buy an item.
58+
* `pay_tips`: Pay tips, could be used for paying the creator royalties.
59+
* `create_swap`: Create an offer to swap an NFT for another NFT and optionally some fungibles.
60+
* `cancel_swap`: Cancel previously created swap offer.
61+
* `claim_swap`: Swap items in an atomic way.
62+
63+
64+
### Permissioned dispatchables
65+
66+
* `destroy`: Destroy a collection. This destroys all the items inside the collection and refunds the deposit.
67+
* `force_mint`: Mint a new item within a collection.
68+
* `burn`: Destroy an item within a collection.
69+
* `lock_item_transfer`: Prevent an individual item from being transferred.
70+
* `unlock_item_transfer`: Revert the effects of a previous `lock_item_transfer`.
71+
* `clear_all_transfer_approvals`: Clears all transfer approvals set by calling the `approve_transfer`.
72+
* `lock_collection`: Prevent all items within a collection from being transferred (making them all `soul bound`).
73+
* `lock_item_properties`: Lock item's metadata or attributes.
74+
* `transfer_ownership`: Alter the owner of a collection, moving all associated deposits. (Ownership of individual items will not be affected.)
75+
* `set_team`: Alter the permissioned accounts of a collection.
76+
* `set_collection_max_supply`: Change the max supply of a collection.
77+
* `update_mint_settings`: Update the minting settings for collection.
78+
79+
80+
### Metadata (permissioned) dispatchables
81+
82+
* `set_attribute`: Set a metadata attribute of an item or collection.
83+
* `clear_attribute`: Remove a metadata attribute of an item or collection.
84+
* `set_metadata`: Set general metadata of an item (E.g. an IPFS address of an image url).
85+
* `clear_metadata`: Remove general metadata of an item.
86+
* `set_collection_metadata`: Set general metadata of a collection.
87+
* `clear_collection_metadata`: Remove general metadata of a collection.
88+
89+
90+
### Force (i.e. governance) dispatchables
91+
92+
* `force_create`: Create a new collection (the collection id can not be chosen).
93+
* `force_collection_owner`: Change collection's owner.
94+
* `force_collection_config`: Change collection's config.
95+
* `force_set_attribute`: Set an attribute.
96+
97+
Please refer to the [`Call`](https://paritytech.github.io/substrate/master/pallet_nfts/pallet/enum.Call.html) enum
98+
and its associated variants for documentation on each function.
99+
100+
## Related Modules
101+
102+
* [`System`](https://docs.rs/frame-system/latest/frame_system/)
103+
* [`Support`](https://docs.rs/frame-support/latest/frame_support/)
104+
* [`Assets`](https://docs.rs/pallet-assets/latest/pallet_assets/)
105+
106+
License: Apache-2.0

0 commit comments

Comments
 (0)