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

CW-2981 extension #24

Merged
merged 17 commits into from
Jan 13, 2022
Merged

CW-2981 extension #24

merged 17 commits into from
Jan 13, 2022

Conversation

the-frey
Copy link
Collaborator

@the-frey the-frey commented Nov 6, 2021

Appreciate this might need some refining and/or further discussion.

A minimal example of the EIP-2981 spec implemented in CW-land. i.e. #7

It's a very light wrapper/extension for CW721 compliant contracts that adds two additional query messages:

  • RoyaltyInfo to be called when selling an NFT, to find out what royalties are owed
  • CheckRoyalties to be called on the contract, to see if it implements CW-2981

This adds royalty information at token mint time.

The main thing are the queries that are called when the marketplace sells an NFT. Different contracts might implement them differently, e.g. to do more complex logic than the straight percentage here, but the returned queries should conform to the shape here.

Aside - could move those (and the extension handlers) to a package, if it makes them more reusable.

Copy link
Collaborator

@JakeHartnell JakeHartnell left a comment

Choose a reason for hiding this comment

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

Small comment about types, but otherwise LGTM.

contracts/cw2981-royalties/src/lib.rs Outdated Show resolved Hide resolved
contracts/cw2981-royalties/src/msg.rs Show resolved Hide resolved
@the-frey
Copy link
Collaborator Author

Will address the comments and add some more tests 👍

JakeHartnell
JakeHartnell previously approved these changes Nov 16, 2021
@the-frey
Copy link
Collaborator Author

If this is GTM could it be merged? Otherwise before long I'll have to update the PR because things will have shifted.... 🙃

@JakeHartnell
Copy link
Collaborator

If this is GTM could it be merged? Otherwise before long I'll have to update the PR because things will have shifted.... upside_down_face

Well if things shift it will need to be updated anyway. 🙃

Needs one more thumbs up.

@the-frey the-frey requested a review from orkunkl December 2, 2021 08:14
@the-frey the-frey requested a review from ben2x4 December 3, 2021 09:04
ethanfrey
ethanfrey previously approved these changes Dec 7, 2021
Copy link
Contributor

@ethanfrey ethanfrey left a comment

Choose a reason for hiding this comment

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

A few points that could use cleanup.
Otherwise fine.

contracts/cw2981-royalties/src/lib.rs Show resolved Hide resolved
contracts/cw2981-royalties/src/msg.rs Show resolved Hide resolved

pub fn check_royalties(_deps: Deps) -> StdResult<CheckRoyaltiesResponse> {
Ok(CheckRoyaltiesResponse {
royalty_payments: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, always true?

What about ext.royalty_percentage.is_some()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Me being a little lazy as it's an example contract - it's a check at contract level, for this one the answer to "should I see if, when a token controlled by this contract is sold, royalties are owed?" will always be yes. I think ext.royalty_percentage.is_some() would be relevant if you were querying on the token_id. Then again, this is based on my interpretation of the granularity of the EIP spec, so I could have it wrong 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems like this is a case where we don't need to follow Ethereum exactly. The boolean seems redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, it will still return boolean regardless - that's the interface, I'm just saying that ext.royalty_percentage.is_some() is at a different level of granularity - token, vs contract

Copy link
Collaborator Author

@the-frey the-frey Dec 21, 2021

Choose a reason for hiding this comment

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

Rechecked the spec and this interface needs to return a boolean, so yeah the answer to:

Checking if the NFT being sold on your marketplace implemented royalties

For a function that takes a contract and returns a boolean - this is the correct base case, and then if contracts want to implement custom logic, they can. This is just the most basic correct example, which is that when token is sold, it signals you should call query_royalties_info with the token ID.

Happy to write a better description of this in the README or what have you, but the important thing is to set the expectation from marketplaces that they should check, in case there is more complex behaviour than a default true.

In some ways, this repo is also a way of documenting How To Do Things With NFTs:tm: so I'm not that worried that the base case is ostensibly redundant, just that it is enumerated for those that have a requirement for more custom logic in future.

To that end, I will add a better comment on it in the code now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Still not a big fan of the CheckRoyalties query as I think it's mostly pointless. It's more important in the context of Ethereum.

Could just query RoyaltiesInfo and see if it returns a response for the same effect.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@orkunkl, any thoughts on this?

@the-frey the-frey dismissed stale reviews from ethanfrey and JakeHartnell via 89f3ea7 December 10, 2021 13:46
@the-frey
Copy link
Collaborator Author

Okay I think that's all the review points closed off.

@the-frey the-frey requested a review from shanev December 12, 2021 12:53
@orkunkl
Copy link
Contributor

orkunkl commented Dec 28, 2021

@the-frey Do you think we can get this PR in this year xp

@the-frey
Copy link
Collaborator Author

@orkunkl I mean, if people want to review it then maybe we can get it in lol

orkunkl
orkunkl previously approved these changes Dec 29, 2021
Copy link
Contributor

@orkunkl orkunkl left a comment

Choose a reason for hiding this comment

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

Now it's time...

@the-frey
Copy link
Collaborator Author

the-frey commented Jan 8, 2022

Okay @orkunkl and @JakeHartnell have updated again with changes from main which means it has cleared your reviews. If you are both still ok to merge, could you review pls 🙏

@the-frey the-frey merged commit d1a3631 into main Jan 13, 2022
@the-frey the-frey deleted the cw2981_extension branch January 13, 2022 09:36
@JakeHartnell JakeHartnell mentioned this pull request Jul 17, 2022
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.

6 participants