-
Notifications
You must be signed in to change notification settings - Fork 12.3k
ERC1155: Check that owner is not the zero address when adding an operator #6171
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
base: master
Are you sure you want to change the base?
ERC1155: Check that owner is not the zero address when adding an operator #6171
Conversation
|
WalkthroughThis change adds input validation to the Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
test/token/ERC1155/ERC1155.test.js (1)
184-190: Consider expanding test coverage.The test correctly verifies the zero-address owner validation. To enhance completeness, consider:
- Testing with
approved = falseto ensure the validation applies regardless of the approval state- Clarifying the test description to explicitly mention "zero-address owner/approver" rather than focusing on "adding an operator"
Example expansion:
describe('_setApprovalForAll', function () { - it("reverts when adding an operator over the zero account's tokens", async function () { + it('reverts when the owner is the zero address', async function () { await expect(this.token.$_setApprovalForAll(ethers.ZeroAddress, this.operator, true)) .to.be.revertedWithCustomError(this.token, 'ERC1155InvalidApprover') .withArgs(ethers.ZeroAddress); + + await expect(this.token.$_setApprovalForAll(ethers.ZeroAddress, this.operator, false)) + .to.be.revertedWithCustomError(this.token, 'ERC1155InvalidApprover') + .withArgs(ethers.ZeroAddress); }); });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
contracts/token/ERC1155/ERC1155.sol(1 hunks)test/token/ERC1155/ERC1155.test.js(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: Amxx
Repo: OpenZeppelin/openzeppelin-contracts PR: 5904
File: contracts/mocks/crosschain/ERC7786RecipientMock.sol:12-14
Timestamp: 2025-08-29T13:16:08.640Z
Learning: In OpenZeppelin contracts, mock contracts (like ERC7786RecipientMock) don't require input validation such as zero-address checks in constructors, as they are only used for testing purposes in controlled environments.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
- GitHub Check: slither
- GitHub Check: tests-foundry
- GitHub Check: tests-upgradeable
- GitHub Check: coverage
- GitHub Check: tests
- GitHub Check: Redirect rules - solidity-contracts
- GitHub Check: Header rules - solidity-contracts
- GitHub Check: Pages changed - solidity-contracts
- GitHub Check: halmos
🔇 Additional comments (1)
contracts/token/ERC1155/ERC1155.sol (1)
359-361: LGTM! Defensive validation added.The zero-address owner check correctly prevents invalid state by reverting with the appropriate
ERC1155InvalidApprovererror. This mirrors the existing operator validation pattern and protects against misuse when the internal function is called directly by derived contracts.
Alternate to #5994
PR Checklist
npx changeset add)