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

Decide if we use another nft pallet #7

Open
tonimateos opened this issue Sep 28, 2023 · 9 comments
Open

Decide if we use another nft pallet #7

tonimateos opened this issue Sep 28, 2023 · 9 comments
Labels
research Work required to define future user stories

Comments

@tonimateos
Copy link
Contributor

tonimateos commented Sep 28, 2023

As a LAOS dev I want to understand if integrating an existing nft pallet would save a lot of work (compared to writing all methods by ourselves), and how I could integrate it.

Worth having a look at using it via traits here

ACCEPTANCE:

  • an analysis is presented to the team, and a decision is made (devs + PO) about using existing nft pallet
@tonimateos tonimateos added this to the Deliverable 2.1 milestone Sep 28, 2023
@tonimateos tonimateos added the research Work required to define future user stories label Sep 28, 2023
@ghost ghost self-assigned this Oct 5, 2023
@ghost
Copy link

ghost commented Oct 9, 2023

criteria External pallet (nfts, uniques) Own pallet
Effort Less effort required Will have to build from scratch, "re-invent the bicycle"
Customizability Won't be able to customize it Can customize it however we want, according to our needs
Maintenance Minimal effort required, only version upgrades Maintain it as any other local pallet (migrations, version upgrades, etc.)
Audit Less effort required during the audit, even if the pallet itself is not audited, it still comes from reputable team paritytech Audit will require more effort and more resources

Some notes for now

@ghost
Copy link

ghost commented Oct 13, 2023

Problems with pallet_nfts:

1. not possible to set collection attributes with traits.

This means that we can't set BaseURI for a new collection and token_uri call won't work.

Mutate trait has set_collection_attribute which works, but it's not possible to read the collection attribute after it was set. This is a bug that I will open an issue. But it seems like they are already going in that direction already with a separate trait for Metadata
paritytech/polkadot-sdk#1561

More context:
https://substrate.stackexchange.com/questions/9974/setting-metadata-of-an-item-of-the-nfts-pallet-in-a-custom-pallet

2. it's possible to hide extrinsics, but we can't hide events.

I.e when we create collection or transfer through evm all the pallet_nfts events will be emitted on substrate side. There's no way to hide it because, pallet_nfts::Config uses RuntimeEvent

3. another dependency to substrate (similar to parity-bridges-common)

we add another dependency to our list and if we encounter any bugs, issues or want to change the behaviour, we should make PR to substrate and wait until it's merged. And some proposals may actually get rejected from the substrate side. In short, it might slow down the development.

@ghost
Copy link

ghost commented Oct 13, 2023

this is how our precompiles would look like (on a high-level) if we were to use pallet-nfts

#67

@ghost ghost linked a pull request Oct 13, 2023 that will close this issue
@ghost
Copy link

ghost commented Oct 16, 2023

@jsidorenko
Copy link

but it's not possible to read the collection attribute after it was set.

Hi, actually, there is a way to read the collection's metadata and attributes, it's the collection_attribute() method on the Inspect trait. You can see it here: https://github.com/paritytech/polkadot-sdk/blob/e3892745f7c58e877d8838587e1471a93796ead4/substrate/frame/nfts/src/impl_nonfungibles.rs#L100C5-L100C25

@ghost
Copy link

ghost commented Oct 17, 2023

but it's not possible to read the collection attribute after it was set.

Hi, actually, there is a way to read the collection's metadata and attributes, it's the collection_attribute() method on the Inspect trait. You can see it here: https://github.com/paritytech/polkadot-sdk/blob/e3892745f7c58e877d8838587e1471a93796ead4/substrate/frame/nfts/src/impl_nonfungibles.rs#L100C5-L100C25

hey @jsidorenko

thanks for reaching out here.

yes, we are aware of the collection_attribute() function. But it's currently not possible to read the collection_attribute once we set it, because when setting AttributeNamespace::Pallet is used and when reading AttributeNamespace::CollectionOwner is used for the value of namespace.

I think this is a bug, since users who use the pallet-nfts through nonfungibles_v2 traits can't read back the attribute they set.

I was actually thinking of making a PR for this, just want to confirm with you if this is actually a bug or there is something I am missing?

@jsidorenko
Copy link

Oh, I see! The easiest solution would be to change that line: https://github.com/paritytech/polkadot-sdk/blob/e3892745f7c58e877d8838587e1471a93796ead4/substrate/frame/nfts/src/impl_nonfungibles.rs#L87 and make the item param optional.

How would you solve that issue?

@ghost
Copy link

ghost commented Oct 17, 2023

Oh, I see! The easiest solution would be to change that line: https://github.com/paritytech/polkadot-sdk/blob/e3892745f7c58e877d8838587e1471a93796ead4/substrate/frame/nfts/src/impl_nonfungibles.rs#L87 and make the item param optional.

How would you solve that issue?

yes, that's what I was going to propose

@jsidorenko
Copy link

Cool, I can open a PR later today, or feel free to submit it first :)

@asiniscalchi asiniscalchi unassigned ghost Oct 19, 2023
jsidorenko pushed a commit to paritytech/polkadot-sdk that referenced this issue Oct 26, 2023
# Description

- What does this PR do?

While working with `pallet_nfts` through `nonfungibles_v2` traits
`Inspect, Mutate`, I found out that once you have set the collection
attribute with `<Nfts as Mutate>::set_collection_attribute()`, it's not
possible to read it with `<Nfts as Inspect>::collection_attribute()`
since they use different `namespace` values. When setting the attribute,
`AttributeNamespace::Pallet` is used, while
`AttributeNamespace::CollectionOwner` is used when reading.

more context:
freeverseio/laos#7 (comment)

This PR makes `item` an optional parameter in
`Inspect::system_attribute()`, to be able to read collection attributes.

- Why are these changes needed?

To be able to read collection level attributes when reading attributes
of the collection. It will be possible to read collection attributes by
passing `None` for `item`

- How were these changes implemented and what do they affect?

`NftsApi` is also affected and `NftsApi::system_attribute()` now accepts
optional `item` parameter.

## Breaking change

Because of the change in the `NftsApi::system_attribute()` method's
`item` param, parachains who integrated the `NftsApi` need to update
their API code and frontend integrations accordingly. AssetHubs are
unaffected since the NftsApi wasn't released on those parachains yet.
s0me0ne-unkn0wn pushed a commit to paritytech/polkadot-sdk that referenced this issue Oct 29, 2023
# Description

- What does this PR do?

While working with `pallet_nfts` through `nonfungibles_v2` traits
`Inspect, Mutate`, I found out that once you have set the collection
attribute with `<Nfts as Mutate>::set_collection_attribute()`, it's not
possible to read it with `<Nfts as Inspect>::collection_attribute()`
since they use different `namespace` values. When setting the attribute,
`AttributeNamespace::Pallet` is used, while
`AttributeNamespace::CollectionOwner` is used when reading.

more context:
freeverseio/laos#7 (comment)

This PR makes `item` an optional parameter in
`Inspect::system_attribute()`, to be able to read collection attributes.

- Why are these changes needed?

To be able to read collection level attributes when reading attributes
of the collection. It will be possible to read collection attributes by
passing `None` for `item`

- How were these changes implemented and what do they affect?

`NftsApi` is also affected and `NftsApi::system_attribute()` now accepts
optional `item` parameter.

## Breaking change

Because of the change in the `NftsApi::system_attribute()` method's
`item` param, parachains who integrated the `NftsApi` need to update
their API code and frontend integrations accordingly. AssetHubs are
unaffected since the NftsApi wasn't released on those parachains yet.
bgallois pushed a commit to duniter/duniter-polkadot-sdk that referenced this issue Mar 25, 2024
# Description

- What does this PR do?

While working with `pallet_nfts` through `nonfungibles_v2` traits
`Inspect, Mutate`, I found out that once you have set the collection
attribute with `<Nfts as Mutate>::set_collection_attribute()`, it's not
possible to read it with `<Nfts as Inspect>::collection_attribute()`
since they use different `namespace` values. When setting the attribute,
`AttributeNamespace::Pallet` is used, while
`AttributeNamespace::CollectionOwner` is used when reading.

more context:
freeverseio/laos#7 (comment)

This PR makes `item` an optional parameter in
`Inspect::system_attribute()`, to be able to read collection attributes.

- Why are these changes needed?

To be able to read collection level attributes when reading attributes
of the collection. It will be possible to read collection attributes by
passing `None` for `item`

- How were these changes implemented and what do they affect?

`NftsApi` is also affected and `NftsApi::system_attribute()` now accepts
optional `item` parameter.

## Breaking change

Because of the change in the `NftsApi::system_attribute()` method's
`item` param, parachains who integrated the `NftsApi` need to update
their API code and frontend integrations accordingly. AssetHubs are
unaffected since the NftsApi wasn't released on those parachains yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
research Work required to define future user stories
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants