Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pallet uniques: Mint with extra deposit #753

Merged
merged 112 commits into from
Jul 11, 2023
Merged

Pallet uniques: Mint with extra deposit #753

merged 112 commits into from
Jul 11, 2023

Conversation

Hounsette
Copy link
Contributor

@Hounsette Hounsette commented Jun 16, 2023

  • Add create collection with extra deposit limit
  • Add update extra deposit limit for existing collections
  • Add mint with extra deposit
  • Unreserve the extra deposit on burning an item and transfer it to item owner
  • Unreserve all extra deposits on destroying a collection and transfer them to item owners
  • Repatriate the total extra deposit when the ownership of collection changes
  • Benchmark nodle-uniques-pallet
  • Relocate Uniques to SubstrateUniques pallet on runtime upgrade

@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Merging #753 (b4753fd) into master (011d189) will increase coverage by 5.71%.
The diff coverage is 73.99%.

❗ Current head b4753fd differs from pull request most recent head 7986015. Consider uploading reports for the commit 7986015 to get more accurate results

@@            Coverage Diff             @@
##           master     #753      +/-   ##
==========================================
+ Coverage   58.81%   64.53%   +5.71%     
==========================================
  Files          38       43       +5     
  Lines        4740     6116    +1376     
==========================================
+ Hits         2788     3947    +1159     
- Misses       1952     2169     +217     
Impacted Files Coverage Δ
pallets/grants/src/weights.rs 0.00% <0.00%> (ø)
pallets/uniques/src/weights.rs 0.00% <0.00%> (ø)
runtimes/eden/src/lib.rs 2.98% <0.00%> (-0.06%) ⬇️
runtimes/eden/src/migrations.rs 0.00% <0.00%> (ø)
runtimes/eden/src/weights/frame_system.rs 0.00% <0.00%> (ø)
runtimes/eden/src/weights/pallet_balances.rs 0.00% <0.00%> (ø)
...imes/eden/src/weights/pallet_collator_selection.rs 0.00% <0.00%> (ø)
runtimes/eden/src/weights/pallet_membership.rs 0.00% <0.00%> (ø)
runtimes/eden/src/weights/pallet_multisig.rs 0.00% <0.00%> (ø)
runtimes/eden/src/weights/pallet_preimage.rs 0.00% <0.00%> (ø)
... and 12 more

pallets/uniques/src/lib.rs Show resolved Hide resolved
pallets/uniques/src/lib.rs Show resolved Hide resolved
runtimes/eden/src/migrations.rs Outdated Show resolved Hide resolved
scripts/init.sh Outdated Show resolved Hide resolved

pub struct MovePalletUniquesToSubstrateUniques;
impl OnRuntimeUpgrade for MovePalletUniquesToSubstrateUniques {
fn on_runtime_upgrade() -> Weight {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this trigger...

  • check trigger
  • run and upgrade on local testnet

@@ -0,0 +1,181 @@
// This file is part of Substrate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What file did we copy? Did not all the code change?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7986015 implements it

Co-authored-by: Fredrik Simonsson <[email protected]>
Copy link
Contributor

@simonsso simonsso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments and questions upto line 217
(I will check the checkboxen later)

(collection_id, collection_owner, collection_owner_lookup)
}

fn create_collection<T: Config<I>, I: 'static>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • There is only one create collection function not two versions

/// The total extra deposit reserved so far
///
/// Ever mint with extra deposit should update this value.
total: T,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to store both total and limit one alternative could be remaining

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to be able to query the total and limit separately. Otherwise for knowing how much is the total reserved for a collection we have to check and add all the items extra deposits through potentially several queries.

pallets/uniques/src/lib.rs Outdated Show resolved Hide resolved
pallets/uniques/src/lib.rs Show resolved Hide resolved
pallets/uniques/src/lib.rs Show resolved Hide resolved
let item_owner =
pallet_uniques::Pallet::<T, I>::owner(collection, item).ok_or(Error::<T, I>::UnknownItemOwner)?;
<T as pallet_uniques::Config<I>>::Currency::unreserve(&collection_owner, extra_deposit);
<T as pallet_uniques::Config<I>>::Currency::transfer(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think extra deposit should be owned by owner as reserved tokens, shouldn't it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When there is no collection, there is no reason for keeping a fund reserved. This is the unreserve condition. Otherwise we may lock tokens forever

@aliXsed aliXsed merged commit 2ef7c21 into master Jul 11, 2023
@aliXsed aliXsed deleted the houns/uniques branch July 11, 2023 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants