Add validation in Governor on ERC-721 or ERC-1155 received by clauBv23 · Pull Request #4314 · OpenZeppelin/openzeppelin-contracts (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation22 Commits15 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

clauBv23

Fixes #4307

Add validation to onERC1155Received, onERC1155BatchReceived, and onERC721Received hooks in Governor to check it is the executor.
Add test to the validations.

Note: This PR should be refactored after merging #4261 and #4284

PR Checklist

@clauBv23

@clauBv23

@changeset-bot

@clauBv23

@Amxx Amxx mentioned this pull request

Jun 5, 2023

3 tasks

Amxx

Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

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

If possible, the expectRevert should not be unspecified.

@clauBv23

@clauBv23

@Amxx

@Amxx good catch! But what do you mean whit if possible, is there any specific reason for not specifying it? In this case for example what is the reason for not doing it?

it("doesn't accept ether transfers", async function () {
await expectRevert.unspecified(web3.eth.sendTransaction({ from: owner, to: this.mock.address, value: 1 }));
});

If there is no revert string, or if the revert is a panic, then unspecified might be the way.
Also, maybe some of our current unspecified should be specified.

@clauBv23

oh perfect makes sense @Amxx thanks!

ernestognw

Choose a reason for hiding this comment

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

This looks good @clauBv23! Thanks. I'm adding a few suggestions and also requesting review from others.

Thanks!

@clauBv23

@clauBv23

Amxx

Amxx previously approved these changes Jun 7, 2023

Collaborator

@Amxx Amxx left a comment

Choose a reason for hiding this comment

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

LGTM

@Amxx

@Amxx

@Amxx

@frangio @ernestognw I merged master into this and realised the following:

ERC1155 acceptance hook was written in a way that bubble error string, but not custom error. The result is that the Governor custom error (GovernorDisabledDeposit) is replaced by the default one (ERC1155InvalidReceiver)

Do we want to change the ERC1155 hook to use the syntax from ERC721 (which bubble the custom errors)?

@Amxx

@frangio

Do we want to change the ERC1155 hook to use the syntax from ERC721 (which bubble the custom errors)?

I'd say yes.

@Amxx

@Amxx

clauBv23

@Amxx @clauBv23

Co-authored-by: Claudia Barcelo claudiabarcelovaldes40@gmail.com

This was referenced

Sep 10, 2024

This was referenced

Sep 12, 2024

This was referenced

Nov 8, 2024

This was referenced

Nov 9, 2024