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

Support ERC/CW2981 in pointer contracts #1669

Merged
merged 2 commits into from
May 15, 2024
Merged

Support ERC/CW2981 in pointer contracts #1669

merged 2 commits into from
May 15, 2024

Conversation

codchen
Copy link
Collaborator

@codchen codchen commented May 15, 2024

Describe your changes and provide context

This PR adds ERC/CW2981 support, which involves the following query endpoints:

  • For ERC721 pointing to CW721
    • supportsInterface
    • royaltyInfo
  • For CW721 pointing to ERC721
    • extension:royalty_info
    • extension:check_royalties

Note that setting royalties needs to be done via mint which is not currently supported by the pointers yet.

Testing performed to validate your change

integration tests

Copy link
Contributor

@stevenlanders stevenlanders left a comment

Choose a reason for hiding this comment

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

lgtm - i think the integration test should probably be in hardhat but we can do that later

bytes memory addr = JsonPrecompile.extractAsBytes(response, "address");
uint256 amt = JsonPrecompile.extractAsUint256(response, "royalty_amount");
if (addr.length == 0) {
return (address(0), amt);
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be (address(0), 0)? I think we probably don't want to risk people burning funds on mistake.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the cw2981 implementation makes look like it's a possible scenario for the payment address to be empty while the royalty is non-zero: https://github.com/CosmWasm/cw-nfts/blob/main/contracts/cw2981-royalties/src/lib.rs#L41-L45, so I'm not sure if we want to overwrite amt here?

@codchen codchen merged commit 3be4978 into main May 15, 2024
47 checks passed
@codchen codchen deleted the erc721-royalty branch May 15, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants