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

add contract_metadata_update event #423

Merged

Conversation

lachlanglen
Copy link
Contributor

Added contract_metadata_update event to Standards -> Tokens -> NonFungibleToken as per the following discussion: https://gov.near.org/t/extending-nep-171-events-standard-to-include-contract-metadata-update-events/30384

Implementation of this new event enables 3rd party applications to listen for updates to NFT contract metadata, e.g. a new dedicated IPFS gateway (base_uri) and provide a consistent and higher quality experience for their users.

@lachlanglen lachlanglen requested a review from a team as a code owner November 2, 2022 13:21
@nearbuild
Copy link

@frol asked nft builder group to review, not sure if there are any contentions, wanted to move this up the NEP process

@frol frol added S-draft/needs-moderator-review A NEP in the DRAFT stage that needs a moderator review. A-NEP-Extension A new functionality proposal to existing NEP. Once original author merges changes, we close this. labels Nov 15, 2022
@frol
Copy link
Collaborator

frol commented Nov 15, 2022

@lachlanglen Thanks for submitting this NEP extension proposal!

As a moderator, I reviewed this PR and move it to the subject matter experts review stage.

@frol frol added S-review/needs-sme-review A NEP in the REVIEW stage is waiting for Subject Matter Expert review. and removed S-draft/needs-moderator-review A NEP in the DRAFT stage that needs a moderator review. labels Nov 15, 2022
@frol
Copy link
Collaborator

frol commented Nov 15, 2022

I see that there were already several LGTMs from @MinorityProgrammers, @mattlockyer, and @nearbuild on NEAR Gov Forum, so I take them as SME reviews.

As a working group member, I will review this proposal later today.

specs/Standards/Tokens/NonFungibleToken/Event.md Outdated Show resolved Hide resolved
"version": "1.1.0",
"event": "contract_metadata_update",
"data": [
{ "metadata": { "base_uri": "..." } }
Copy link
Collaborator

Choose a reason for hiding this comment

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

The above spec uses NFTContractMetadata type and this means that all the required fields should be present, yet this example implies that only modified fields become part of the emitted event. What is the actual path you propose to go and why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it probably makes more sense to actually not include the contract_metadata at all in the event, primarily due to the fact that icon would be included which could easily put the log over the 16KB limit. I'll update to reflect this.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lachlanglen This is a very good point that I also was thinking about. I still think it is worth including the list of fields that were updated. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@frol I hear your point that the listener can choose to act only if the updated fields are relevant to them, but since they need to request the full metadata object anyway via nft_metadata, I'm not sure how much benefit this provides. Additionally, it introduces a requirement for the contract to keep track of which fields were updated, rather than simply being able to accept an NFTContractMetadata object in an update method and set the whole thing. Wdyt?

Copy link
Collaborator

@frol frol Nov 16, 2022

Choose a reason for hiding this comment

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

@lachlanglen Are you familiar with the near-sdk-rs implementation of NFT events? There are two reasons for my question:

  1. We will need someone to contribute the implementation to near-sdk-rs (Developer Governance strives for community contributions all across the ecosystem)
  2. I wonder how to integrate this event in such a way, that we can ensure that near-sdk-rs users are safeguarded and don't need to keep in mind that they need to emit the event (e.g. mint and burn events are emitted in the internal near-sdk-rs implementation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I'm happy to contribute the near-sdk-rs implementation.

I guess we should add the update method then? thoughts on the naming? e.g. contract_metadata_update or set_contract_metadata (possibly more accurate if the whole object is being received and set rather than individual elements)

fn set_contract_metadata(&mut self, metadata: NFTContractMetadata);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I guess something like set_nft_metadata or nft_metadata_set would be more consistent with current methods... though I don't like convention of calling the contract's metadata nft_metadata as I find it misleading and confusing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lachlanglen Naming is hard, so I would like someone to find the best UX as part of this contribution. Currently, examples do not give any examples of updating the metadata, but implementors can alter the metadata directly, which should be redesigned, I believe.

https://github.com/near/near-sdk-rs/blob/master/examples/non-fungible-token/nft/src/lib.rs#L33

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@frol implementors can alter the metadata directly - what do you mean by this?

Copy link
Collaborator

@frol frol Nov 17, 2022

Choose a reason for hiding this comment

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

@lachlanglen As NFT contract author I can just implement a new method like:

fn lets_update_metadata_and_do_something_else(&mut self) {
    self.metadata.set(NftMetadata { ... });
}

Given that metadata is defined as:

pub struct Contract {
    tokens: NonFungibleToken,
    metadata: LazyOption<NFTContractMetadata>,
}

The interface won't guard me against doing this, and this way I won't emit the metadata update event unless I know that I should emit it. This makes the interface fragile, and most of the implementations won't emit the metadata update events. Ideally, we should suggest using such an interface that would make it impossible to avoid emitting the event. (please, see this talk)

@frol frol added S-review/needs-author-revision A NEP in the REVIEW stage that needs an author revision. WG-contract-standards Contract Standards Work Group should be accountable and removed S-review/needs-sme-review A NEP in the REVIEW stage is waiting for Subject Matter Expert review. labels Nov 15, 2022
@lachlanglen
Copy link
Contributor Author

Thanks for the feedback @frol, made changes as per your notes.

@frol frol added S-voting/needs-wg-voting-indication A NEP in the VOTING stage that needs the working group voting indication. and removed S-review/needs-author-revision A NEP in the REVIEW stage that needs an author revision. labels Nov 16, 2022
@frol frol self-requested a review November 16, 2022 15:16
@frol
Copy link
Collaborator

frol commented Nov 16, 2022

As a working group member, I lean towards approving this proposal given there are no breaking changes and this could be quite beneficial for indexers.

@near/wg-contract-standards I invite the rest of the working group members to review this NEP extension.

@nearbuild
Copy link

When will this go to vote?

@ori-near
Copy link
Contributor

When will this go to vote?

We are waiting for the working group members to add their voting indication, which should hopefully happen this week. From there, we will schedule the next call.

@mfornet
Copy link
Member

mfornet commented Dec 21, 2022

I'm leaning toward approving this proposal.

@abacabadabacaba
Copy link
Collaborator

I'm leaning towards approving this proposal.

@ori-near ori-near added S-voting/final-comment-period A NEP in the final REVIEW stage. Last chance to bring up concerns before the voting call. and removed S-voting/needs-wg-voting-indication A NEP in the VOTING stage that needs the working group voting indication. labels Jan 6, 2023
@ori-near
Copy link
Contributor

ori-near commented Jan 6, 2023

As the moderator, I would like to thank the author @lachlanglen for submitting this NEP extension, and for the @near/wg-contract-standards working group members for your review. Based on the voting indications above, it seems like this proposal is close to a decision. We are therefore scheduling the third Contract Standards Working group meeting next week, where this NEP can enter the final voting stage. We encourage anyone who is interested to join the meeting.

Meeting Info
📅 Date: Friday, Jan 13, 4pm UTC
✏️ Register

@ori-near
Copy link
Contributor

ori-near commented Jan 14, 2023

Thank you to everyone who attended the third Contract Standards Working Group meeting today! The working group members reviewed the NEP and reached the following consensus:

Status: Approved

Meeting Recording:
https://youtu.be/pBLN9UyE6AA

@lachlanglen Thank you for authoring this NEP!

Next Steps:

Implementation Status:
Needs support in SDK and API packages

Community contributions to the SDKs are welcome!

@ori-near ori-near added S-approved A NEP that was approved by a working group. and removed S-voting/final-comment-period A NEP in the final REVIEW stage. Last chance to bring up concerns before the voting call. labels Jan 14, 2023
@frol
Copy link
Collaborator

frol commented Jan 24, 2023

@lachlanglen I went ahead with #351 and added the "Decision Context" section with Benefits and Concerns there. Would you be able to follow the pattern and update this PR accordingly, so we can merge it?

frol added 2 commits March 6, 2023 14:17
… values in the TypeScript interface (just aligned with the text description)
@frol frol merged commit b452c82 into near:master Mar 7, 2023
@frol frol mentioned this pull request Mar 21, 2023
2 tasks
@nearbuild nearbuild mentioned this pull request Apr 12, 2023
2 tasks
@robert-zaremba robert-zaremba mentioned this pull request Sep 27, 2023
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NEP-Extension A new functionality proposal to existing NEP. Once original author merges changes, we close this. S-approved A NEP that was approved by a working group. WG-contract-standards Contract Standards Work Group should be accountable
Projects
Status: APPROVED NEPs
Development

Successfully merging this pull request may close these issues.

8 participants