Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[Uniques V2] Smart attributes #12702

Merged
Merged
Show file tree
Hide file tree
Changes from 105 commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
97a7e30
Basics
jsidorenko Sep 21, 2022
a85608f
WIP: change the data format
jsidorenko Sep 23, 2022
6db840a
Refactor
jsidorenko Sep 24, 2022
fa3a2a7
Remove redundant new() method
jsidorenko Sep 24, 2022
472a753
Rename settings
jsidorenko Sep 24, 2022
2611dd4
Enable tests
jsidorenko Sep 24, 2022
52d7d38
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-feature-f…
jsidorenko Sep 24, 2022
46a6b7e
Chore
jsidorenko Sep 24, 2022
5ff7048
Change params order
jsidorenko Sep 24, 2022
f7ddfed
Delete the config on collection removal
jsidorenko Sep 24, 2022
d0d1d60
Chore
jsidorenko Sep 24, 2022
7d4b31f
Remove redundant system features
jsidorenko Sep 24, 2022
dd84637
Rename force_item_status to force_collection_status
jsidorenko Sep 24, 2022
4920a0c
Update node runtime
jsidorenko Sep 26, 2022
7456e73
Chore
jsidorenko Sep 26, 2022
9ff45b8
Remove thaw_collection
jsidorenko Sep 26, 2022
c41a48c
Chore
jsidorenko Sep 26, 2022
fee3ade
Connect collection.is_frozen to config
jsidorenko Sep 26, 2022
a9ab6f8
Allow to lock the collection in a new way
jsidorenko Sep 26, 2022
254816d
Move free_holding into settings
jsidorenko Sep 26, 2022
5878197
Connect collection's metadata locker to feature flags
jsidorenko Sep 26, 2022
95e21fb
DRY
jsidorenko Sep 27, 2022
17b7c9e
Chore
jsidorenko Sep 27, 2022
dc6d2f0
Connect pallet level feature flags
jsidorenko Sep 27, 2022
cc64873
Prepare tests for the new changes
jsidorenko Sep 27, 2022
5153080
Implement Item settings
jsidorenko Sep 27, 2022
08a2048
Allow to lock the metadata or attributes of an item
jsidorenko Sep 27, 2022
1551714
Common -> Settings
jsidorenko Sep 27, 2022
8830a4c
Extract settings related code to a separate file
jsidorenko Sep 27, 2022
f8800df
Move feature flag checks inside the do_* methods
jsidorenko Sep 28, 2022
3ccf04e
Split settings.rs into parts
jsidorenko Sep 28, 2022
f83fb73
Extract repeated code into macro
jsidorenko Sep 28, 2022
df97cce
Extract macros into their own file
jsidorenko Sep 28, 2022
3bb6eb5
Chore
jsidorenko Sep 28, 2022
8563a31
Fix traits
jsidorenko Sep 29, 2022
09aca13
Fix traits
jsidorenko Sep 29, 2022
114e519
Test SystemFeatures
jsidorenko Sep 29, 2022
d6536fc
Fix benchmarks
jsidorenko Sep 29, 2022
09a4ed6
Add missing benchmark
jsidorenko Sep 29, 2022
d408b32
Fix node/runtime/lib.rs
jsidorenko Sep 29, 2022
fd86e41
".git/.scripts/bench-bot.sh" pallet dev pallet_nfts
Oct 3, 2022
c002f8b
Keep item's config on burn if it's not empty
jsidorenko Oct 5, 2022
b16435a
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-feature-f…
jsidorenko Oct 5, 2022
d0ee824
Fix the merge artifacts
jsidorenko Oct 5, 2022
0eb568e
Fmt
jsidorenko Oct 5, 2022
998691e
Add SystemFeature::NoSwaps check
jsidorenko Oct 6, 2022
b8c6f5e
Rename SystemFeatures to PalletFeatures
jsidorenko Oct 7, 2022
8bef776
Rename errors
jsidorenko Oct 7, 2022
ddaa884
Add docs
jsidorenko Oct 7, 2022
4c01fc5
Change error message
jsidorenko Oct 7, 2022
30d2bde
Change the format of CollectionConfig to store more data
jsidorenko Oct 10, 2022
9449641
Move max supply to the CollectionConfig and allow to change it
jsidorenko Oct 10, 2022
443578d
Remove ItemConfig from the mint() function and use the one set in min…
jsidorenko Oct 11, 2022
0efc4ec
Add different mint options
jsidorenko Oct 11, 2022
2ab076f
Allow to change the mint settings
jsidorenko Oct 11, 2022
ad083ce
Add a force_mint() method
jsidorenko Oct 12, 2022
4ca6f00
Check mint params
jsidorenko Oct 12, 2022
340cb81
Some optimisations
jsidorenko Oct 12, 2022
025cfdd
Cover with tests
jsidorenko Oct 12, 2022
50b617c
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-minting-o…
jsidorenko Oct 19, 2022
6b96856
Remove merge artifacts
jsidorenko Oct 19, 2022
45227f5
Chore
jsidorenko Oct 19, 2022
f36d4b9
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-minting-o…
jsidorenko Oct 20, 2022
277d1a6
Use the new has_role() method
jsidorenko Oct 20, 2022
9d1d11b
Rework item deposits
jsidorenko Oct 20, 2022
8ffe4fd
More tests
jsidorenko Oct 21, 2022
c7dcdb0
Refactoring
jsidorenko Oct 21, 2022
e1195c5
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-minting-o…
jsidorenko Oct 23, 2022
1ab5043
Address comments
jsidorenko Nov 1, 2022
387bf2c
Refactor lock_collection()
jsidorenko Nov 1, 2022
1c51efd
Update frame/nfts/src/types.rs
jsidorenko Nov 8, 2022
9e9b969
Update frame/nfts/src/types.rs
jsidorenko Nov 8, 2022
b82fbe9
Update frame/nfts/src/lib.rs
jsidorenko Nov 8, 2022
e495da6
Update frame/nfts/src/lib.rs
jsidorenko Nov 8, 2022
670bb28
Private => Issuer
jsidorenko Nov 8, 2022
5093b89
Add more tests
jsidorenko Nov 8, 2022
c376b43
Fix benchmarks
jsidorenko Nov 8, 2022
7fe301a
Add benchmarks for new methods
jsidorenko Nov 8, 2022
f246c52
Merge branch 'js/uniques-v2-minting-options_' into js/uniques-v2-mint…
jsidorenko Nov 8, 2022
cfa90dd
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-minting-o…
jsidorenko Nov 8, 2022
d667fb7
[Uniques v2] Refactoring (#12570)
jsidorenko Nov 14, 2022
0ef95b7
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-minting-o…
jsidorenko Nov 14, 2022
5102020
Smart attributes
jsidorenko Nov 14, 2022
820891c
Split force_collection_status into 2 methods
jsidorenko Nov 15, 2022
51328b0
Fix benchmarks
jsidorenko Nov 15, 2022
c1e71a2
Fix benchmarks
jsidorenko Nov 15, 2022
011db15
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-minting-o…
jsidorenko Nov 16, 2022
67d5643
Update deps
jsidorenko Nov 16, 2022
43d84dd
Merge branch 'js/uniques-v2-minting-options' into js/uniques-v2-smart…
jsidorenko Nov 16, 2022
9bdd37d
Fix merge artifact
jsidorenko Nov 16, 2022
83e9221
Weights + benchmarks + docs
jsidorenko Nov 16, 2022
9531c9f
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-smart-att…
jsidorenko Nov 16, 2022
255b095
Change params order
jsidorenko Nov 16, 2022
3b1f69d
Chore
jsidorenko Nov 16, 2022
9cad6fb
Update frame/nfts/src/lib.rs
jsidorenko Nov 16, 2022
be11b17
Update frame/nfts/src/lib.rs
jsidorenko Nov 16, 2022
ff3daf0
Update docs
jsidorenko Nov 16, 2022
01075b3
Update frame/nfts/src/lib.rs
jsidorenko Nov 16, 2022
3a5cabf
Add PalletId
jsidorenko Nov 16, 2022
fc5ab54
Chore
jsidorenko Nov 16, 2022
6b5fe82
Add tests
jsidorenko Nov 16, 2022
99249ae
More tests
jsidorenko Nov 16, 2022
7d98c81
Add doc
jsidorenko Nov 17, 2022
f59bdd8
Merge branch 'js/uniques-v2-main-branch' into js/uniques-v2-smart-att…
jsidorenko Nov 17, 2022
fae8421
Update errors snapshots
jsidorenko Nov 17, 2022
6737024
Ensure we track the owner_deposit field correctly
jsidorenko Nov 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,7 @@ parameter_types! {
pub const KeyLimit: u32 = 32;
pub const ValueLimit: u32 = 256;
pub const ApprovalsLimit: u32 = 20;
pub const ItemAttributesApprovalsLimit: u32 = 20;
pub const MaxTips: u32 = 10;
pub const MaxDeadlineDuration: BlockNumber = 12 * 30 * DAYS;
}
Expand Down Expand Up @@ -1535,6 +1536,7 @@ impl pallet_nfts::Config for Runtime {
type KeyLimit = KeyLimit;
type ValueLimit = ValueLimit;
type ApprovalsLimit = ApprovalsLimit;
type ItemAttributesApprovalsLimit = ItemAttributesApprovalsLimit;
type MaxTips = MaxTips;
type MaxDeadlineDuration = MaxDeadlineDuration;
type Features = Features;
Expand Down
106 changes: 101 additions & 5 deletions frame/nfts/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ fn add_item_attribute<T: Config<I>, I: 'static>(
SystemOrigin::Signed(caller.clone()).into(),
T::Helper::collection(0),
Some(item),
AttributeNamespace::CollectionOwner,
key.clone(),
vec![0; T::ValueLimit::get() as usize].try_into().unwrap(),
));
Expand Down Expand Up @@ -338,20 +339,115 @@ benchmarks_instance_pallet! {

let (collection, caller, _) = create_collection::<T, I>();
let (item, ..) = mint_item::<T, I>(0);
add_item_metadata::<T, I>(item);
}: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone(), value.clone())
}: _(SystemOrigin::Signed(caller), collection, Some(item), AttributeNamespace::CollectionOwner, key.clone(), value.clone())
verify {
assert_last_event::<T, I>(
Event::AttributeSet {
collection,
maybe_item: Some(item),
namespace: AttributeNamespace::CollectionOwner,
key,
value,
}
.into(),
);
}

force_set_attribute {
let key: BoundedVec<_, _> = vec![0u8; T::KeyLimit::get() as usize].try_into().unwrap();
let value: BoundedVec<_, _> = vec![0u8; T::ValueLimit::get() as usize].try_into().unwrap();

let (collection, caller, _) = create_collection::<T, I>();
let (item, ..) = mint_item::<T, I>(0);
}: _(SystemOrigin::Root, Some(caller), collection, Some(item), AttributeNamespace::CollectionOwner, key.clone(), value.clone())
verify {
assert_last_event::<T, I>(Event::AttributeSet { collection, maybe_item: Some(item), key, value }.into());
assert_last_event::<T, I>(
Event::AttributeSet {
collection,
maybe_item: Some(item),
namespace: AttributeNamespace::CollectionOwner,
key,
value,
}
.into(),
);
}

clear_attribute {
let (collection, caller, _) = create_collection::<T, I>();
let (item, ..) = mint_item::<T, I>(0);
add_item_metadata::<T, I>(item);
let (key, ..) = add_item_attribute::<T, I>(item);
}: _(SystemOrigin::Signed(caller), collection, Some(item), key.clone())
}: _(SystemOrigin::Signed(caller), collection, Some(item), AttributeNamespace::CollectionOwner, key.clone())
verify {
assert_last_event::<T, I>(
Event::AttributeCleared {
collection,
maybe_item: Some(item),
namespace: AttributeNamespace::CollectionOwner,
key,
}.into(),
);
}

approve_item_attributes {
let (collection, caller, _) = create_collection::<T, I>();
let (item, ..) = mint_item::<T, I>(0);
let target: T::AccountId = account("target", 0, SEED);
let target_lookup = T::Lookup::unlookup(target.clone());
}: _(SystemOrigin::Signed(caller), collection, item, target_lookup)
verify {
assert_last_event::<T, I>(Event::AttributeCleared { collection, maybe_item: Some(item), key }.into());
assert_last_event::<T, I>(
Event::ItemAttributesApprovalAdded {
collection,
item,
delegate: target,
}
.into(),
);
}

cancel_item_attributes_approval {
let n in 0 .. 1_000;

let (collection, caller, _) = create_collection::<T, I>();
let (item, ..) = mint_item::<T, I>(0);
let target: T::AccountId = account("target", 0, SEED);
let target_lookup = T::Lookup::unlookup(target.clone());
Nfts::<T, I>::approve_item_attributes(
SystemOrigin::Signed(caller.clone()).into(),
collection,
item,
target_lookup.clone(),
)?;
T::Currency::make_free_balance_be(&target, DepositBalanceOf::<T, I>::max_value());
let value: BoundedVec<_, _> = vec![0u8; T::ValueLimit::get() as usize].try_into().unwrap();
for i in 0..n {
let mut key = vec![0u8; T::KeyLimit::get() as usize];
let mut s = Vec::from((i as u16).to_be_bytes());
key.truncate(s.len());
key.append(&mut s);

Nfts::<T, I>::set_attribute(
SystemOrigin::Signed(target.clone()).into(),
T::Helper::collection(0),
Some(item),
AttributeNamespace::Account(target.clone()),
key.try_into().unwrap(),
value.clone(),
)?;
}
let witness = CancelAttributesApprovalWitness { account_attributes: n };
}: _(SystemOrigin::Signed(caller), collection, item, target_lookup, witness)
verify {
assert_last_event::<T, I>(
Event::ItemAttributesApprovalRemoved {
collection,
item,
delegate: target,
}
.into(),
);
}

set_metadata {
Expand Down
Loading