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 validation in Governor on ERC-721 or ERC-1155 received #4314

Conversation

clauBv23
Copy link
Contributor

@clauBv23 clauBv23 commented Jun 5, 2023

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

  • Tests
  • Documentation
  • Changeset entry (run npx changeset add)

@changeset-bot
Copy link

changeset-bot bot commented Jun 5, 2023

🦋 Changeset detected

Latest commit: 2d53fa7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
openzeppelin-solidity Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
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
Copy link
Contributor Author

clauBv23 commented Jun 5, 2023

@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 }));
});

@Amxx
Copy link
Collaborator

Amxx commented Jun 5, 2023

@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
Copy link
Contributor Author

clauBv23 commented Jun 5, 2023

oh perfect makes sense @Amxx thanks!

ernestognw
ernestognw previously approved these changes Jun 5, 2023
Copy link
Member

@ernestognw ernestognw left a comment

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!

contracts/governance/Governor.sol Outdated Show resolved Hide resolved
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
contracts/governance/Governor.sol Outdated Show resolved Hide resolved
@ernestognw ernestognw requested review from Amxx and frangio June 5, 2023 22:27
Amxx
Amxx previously approved these changes Jun 7, 2023
Copy link
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 force-pushed the add-validation-in-governor-when-receive-erc721-erc1155 branch from a3e43b5 to 1c324a0 Compare June 14, 2023 10:10
@Amxx
Copy link
Collaborator

Amxx commented Jun 14, 2023

@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)?

@frangio
Copy link
Contributor

frangio commented Jun 14, 2023

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 requested a review from ernestognw June 14, 2023 14:32
Co-authored-by: Claudia Barcelo <claudiabarcelovaldes40@gmail.com>
This was referenced Sep 10, 2024
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.

Governor should revert on ERC1155 and ERC721 receive hooks when it's not executor
4 participants