Skip to content

Add NFT contract and token metadata handling#69

Merged
stevieraykatz merged 9 commits into
mainfrom
token-uri
Jul 23, 2024
Merged

Add NFT contract and token metadata handling#69
stevieraykatz merged 9 commits into
mainfrom
token-uri

Conversation

@stevieraykatz

@stevieraykatz stevieraykatz commented Jul 19, 2024

Copy link
Copy Markdown
Member

Our secondary marketplace experience is extremely lacking without token metadata. In lieu of setting metadata through proving ownership of the contracts with OpenSea (and for each other marketplace), we should just support standard on-chain metadata standards.

For reference: existing BaseRegistrar opensea experience https://testnets.opensea.io/collection/unidentified-contract-360b18e5-733c-4d39-b08e-dacf

Desired cleanliness: https://opensea.io/collection/ens

@stevieraykatz stevieraykatz marked this pull request as ready for review July 19, 2024 20:30
Comment thread src/L2/BaseRegistrar.sol Outdated
function tokenURI(uint256) public pure override returns (string memory) {
return "";
function tokenURI(uint256 tokenId) public view override returns (string memory) {
return bytes(baseURI).length > 0 ? string.concat(baseURI, tokenId.toString()) : "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should do an existence check, revert if know ownerOf

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good call. Added onlyNonExpired modifier for reverting when queried for either an unowned or an expired name.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hm I feel like maybe we still have metadata for expired names and show through the metadata image/name that it is expired.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I would be concerned as a prospective renter of an expired name that the token is just borked for some reason if no metadata loads for it vs. if it shows me intentionally it is expired, I feel more comfortable to rent it out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

From an offline conversation with @ilikesymmetry I think we landed on this being sufficient.

Cases:

  1. Name has never been registered -- This will revert but we also don't expect that this method will be queried for any such token.
  2. Name has been registered but is expired -- This will revert but the previous metadata will be cached on opensea
  3. Name is registered: return happily

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

One thought is to format the url param for tokenId as hex versus a raw string conversion of uint256. This will help keep urls shorter, but that's more for aesthetic than anything else. I've found it unwieldy sharing ENS token links before because of this but maybe that's just me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think formatting as strings rather than hex will lead to less headaches

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How will this revert if I pass a tokenId that hasn't been minted?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

    /// @notice Decorator for determining if a name has expired.
    ///
    /// @param id The id being checked for expiry.
    modifier onlyNonExpired(uint256 id) {
        if (nameExpires[id] <= block.timestamp) revert Expired(id);
        _;
    }

nameExpires[id] == 0 for tokens that haven't been minted.

Comment thread src/L2/BaseRegistrar.sol
Comment thread test/BaseRegistrar/BaseRegistrarBase.t.sol Outdated

@ilikesymmetry ilikesymmetry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Most important imo is to just follow convention set by ENS. I'm not sure how they handle behavior for previously-owned, expired tokens, but not returning any metadata for those feels weird to me.

Additionally, I think we should use 4906 to be more indexer-friendly if we do ever make refactors to the metadata in the future.

@ilikesymmetry

ilikesymmetry commented Jul 19, 2024

Copy link
Copy Markdown
Collaborator

We also probably want collection-level metadata defined here via 7572.

@stevieraykatz stevieraykatz changed the title Add token URI and owner only setter method Add token and contract URI endpoints and owner only setter methods Jul 22, 2024
@stevieraykatz stevieraykatz changed the title Add token and contract URI endpoints and owner only setter methods Add NFT contract and token metadata handling Jul 22, 2024
Comment thread src/L2/BaseRegistrar.sol Outdated
Comment thread src/L2/BaseRegistrar.sol Outdated

@ilikesymmetry ilikesymmetry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Only remaining thought from me is follow through on editing the deployment scripts PR to use the proper uri arguments now that the constructor is different

@cb-heimdall

Copy link
Copy Markdown
Collaborator

Review Error for ilikesymmetry @ 2024-07-22 20:01:18 UTC
User failed mfa authentication, see go/mfa-help

@cb-heimdall

Copy link
Copy Markdown
Collaborator

Review Error for wilsoncusack @ 2024-07-22 21:14:46 UTC
User failed mfa authentication, see go/mfa-help

@cb-elileers cb-elileers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might need a change on the using LibString, need @stevieraykatz to doublecheck.

Otherwise, looks good from security standpoint. Just adds a couple of string vars, and functions to read them publicly and update them as Owner.

Comment thread script/deploy/DeployBaseRegistrar.s.sol
Comment thread src/L2/BaseRegistrar.sol
@cb-heimdall

Copy link
Copy Markdown
Collaborator

Review Error for cb-elileers @ 2024-07-23 20:11:05 UTC
User failed mfa authentication, public email is not set on your github profile. see go/mfa-help

@stevieraykatz stevieraykatz merged commit 43de039 into main Jul 23, 2024
@stevieraykatz stevieraykatz deleted the token-uri branch July 23, 2024 20:14
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.

5 participants