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

Dependency Injection Trait Locker for Uniques Pallet #11025

Merged

Conversation

HashWarlock
Copy link
Contributor

@HashWarlock HashWarlock commented Mar 13, 2022

Description

Within the RMRK Standard there requires a locking mechanism for the NFT to ensure that when a NFT is listed in the rmrk-market pallet, the NFT must be locked and can no longer allow any interactions with the NFT. Since the RMRK pallet extends the uniques pallet, implementing the Locker trait in the config of rmrk-core creates a situation where a user can bypass the lock and execute a do_transfer directly to the uniques pallet. We looked using the freeze mechanism for an asset instance, but the implementation was not feasible and led to some centralized problems if the RMRK Admin were to be defined as the freezer for all NFT collections.

The proposal here is to create a dependency injection trait named Locker in the uniques pallet config that has a impl of Locker for () that has function named should_check_lock that defaults a return of false, but can be implemented downstream for a pallet like RMRK to enable a simple locking mechanism to ensure the lock cannot be bypassed by directly calling the uniques pallet do_transfer. A working example of this in the RMRK pallet is defined here.

Note
Use case defined in RMRK substrate pallet in this PR: rmrk-team/rmrk-substrate#76 where the code currently is pointing to a branch off of the stable branch version of v0.19.17 with the same changes as this PR. This is my first PR to Substrate so let me know if I may have missed any details and I'll gladly add them. Thank you.

cumulus-companion: paritytech/cumulus#1085

…ted downstream to enable locking of an asset. Use case defined in RMRK substrate pallet PR76
@cla-bot-2021
Copy link

cla-bot-2021 bot commented Mar 13, 2022

User @HashWarlock, please sign the CLA here.

@h4x3rotab
Copy link
Contributor

LGTM

frame/uniques/src/impl_locker.rs Outdated Show resolved Hide resolved
frame/uniques/src/impl_locker.rs Outdated Show resolved Hide resolved
frame/uniques/src/impl_locker.rs Outdated Show resolved Hide resolved
@shawntabrizi shawntabrizi added B7-runtimenoteworthy C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit labels Mar 16, 2022
Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

Looks broadly good to me, have some minor notes to address before merge.

@HashWarlock
Copy link
Contributor Author

Any other updates I need to make to ensure this gets merged?

@kianenigma
Copy link
Contributor

Looking at the checks, you need a polkadot companion. Otherwise good to go 👍

@HashWarlock
Copy link
Contributor Author

Looking at the checks, you need a polkadot companion. Otherwise good to go +1

Would this be the companion you mean? paritytech/cumulus#1085 or I need to add additional one to the polkadot repo as well?

@kianenigma
Copy link
Contributor

Yes but you have to put it in the PR description (which I did for you now :) )

@kianenigma
Copy link
Contributor

bot merge

@paritytech-processbot
Copy link

Error: pr-custom-review is not passing for paritytech/cumulus#1085

@HashWarlock
Copy link
Contributor Author

Yes but you have to put it in the PR description (which I did for you now :) )

Thank you for the help. Do I need labels and approvals on the cumulus PR as well?

@kianenigma
Copy link
Contributor

We have to wait for the new review rules to approve the cumulus companion, sorry for the delay!

@shawntabrizi
Copy link
Member

bot merge

@paritytech-processbot
Copy link

Error: "Check reviews" status is not passing for paritytech/cumulus#1085

@shawntabrizi shawntabrizi added the B0-silent Changes should not be mentioned in any release notes label Apr 23, 2022
@shawntabrizi
Copy link
Member

bot merge

@paritytech-processbot
Copy link

Waiting for commit status.

@paritytech-processbot
Copy link

Merge cancelled due to error. Error: Checks failed for cb4eeb2

@shawntabrizi
Copy link
Member

bot rebase

@paritytech-processbot
Copy link

Rebasing

@gilescope
Copy link
Contributor

bot merge

@paritytech-processbot paritytech-processbot bot merged commit a79c69a into paritytech:master Apr 28, 2022
godcodehunter pushed a commit to sensoriumxr/substrate that referenced this pull request Jun 22, 2022
* Create a dependency injection trait named Locker that can be implemented downstream to enable locking of an asset. Use case defined in RMRK substrate pallet PR76

* Formatting

* Change impl Locker function name to is_locked

* Remove unused import

* Add docstring header

* Remove impl_locker file and add Locker trait to frame_support::traits

* Expose Locker from frame_support::traits::misc

* Formatting

* Move to tokens folder

* Move to tokens folder

* Format and remove Locker from misc traits

* Punctuation

* Update frame/support/src/traits/tokens/misc.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
DaviRain-Su pushed a commit to octopus-network/substrate that referenced this pull request Aug 23, 2022
* Create a dependency injection trait named Locker that can be implemented downstream to enable locking of an asset. Use case defined in RMRK substrate pallet PR76

* Formatting

* Change impl Locker function name to is_locked

* Remove unused import

* Add docstring header

* Remove impl_locker file and add Locker trait to frame_support::traits

* Expose Locker from frame_support::traits::misc

* Formatting

* Move to tokens folder

* Move to tokens folder

* Format and remove Locker from misc traits

* Punctuation

* Update frame/support/src/traits/tokens/misc.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
ark0f pushed a commit to gear-tech/substrate that referenced this pull request Feb 27, 2023
* Create a dependency injection trait named Locker that can be implemented downstream to enable locking of an asset. Use case defined in RMRK substrate pallet PR76

* Formatting

* Change impl Locker function name to is_locked

* Remove unused import

* Add docstring header

* Remove impl_locker file and add Locker trait to frame_support::traits

* Expose Locker from frame_support::traits::misc

* Formatting

* Move to tokens folder

* Move to tokens folder

* Format and remove Locker from misc traits

* Punctuation

* Update frame/support/src/traits/tokens/misc.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Giles Cope <gilescope@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
B0-silent Changes should not be mentioned in any release notes C1-low PR touches the given topic and has a low impact on builders. D3-trivial 🧸 PR contains trivial changes in a runtime directory that do not require an audit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants