Solidity: Make ERC20 permit optional when votes is enabled#778
Solidity: Make ERC20 permit optional when votes is enabled#778ericglau merged 7 commits intoOpenZeppelin:masterfrom
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis pull request decouples ERC20Permit from ERC20Votes in the OpenZeppelin Wizard. Previously, enabling ERC20Votes automatically included ERC20Permit; now Permit is optional and independent. Changes include core logic modifications, UI updates to reflect the decoupling, and documentation updates describing the new behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/core/solidity/src/erc20.ts (1)
118-125:⚠️ Potential issue | 🟠 MajorAdd test coverage for the
{ permit: false, votes: true }combination.This newly enabled path is not currently covered by tests. Existing tests include
permit: truealone,votes: truealone, and both together, but notpermit: false, votes: true. Add a snapshot/unit test case verifying:
ERC20Permitis absent from the generated output- The standalone
Noncesoverride (set up inaddVotesat lines 194–203) is present and correct🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/solidity/src/erc20.ts` around lines 118 - 125, Add a unit/snapshot test that exercises the combination { permit: false, votes: true } by invoking the same generator used by the existing tests (the ones that cover permit:true, votes:true, and both together) but passing allOpts with permit: false and votes: true; assert that the generated output does NOT include the ERC20Permit contract (verify absence of "ERC20Permit") and that the Nonces override added by addVotes (the standalone Nonces override created in addVotes) is present and matches the expected override shape and contents used in the other votes tests. Use the same test harness and snapshot style as the existing ERC20 tests so the new case sits alongside the current coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/core/solidity/src/erc20.ts`:
- Around line 118-125: Add a unit/snapshot test that exercises the combination {
permit: false, votes: true } by invoking the same generator used by the existing
tests (the ones that cover permit:true, votes:true, and both together) but
passing allOpts with permit: false and votes: true; assert that the generated
output does NOT include the ERC20Permit contract (verify absence of
"ERC20Permit") and that the Nonces override added by addVotes (the standalone
Nonces override created in addVotes) is present and matches the expected
override shape and contents used in the other votes tests. Use the same test
harness and snapshot style as the existing ERC20 tests so the new case sits
alongside the current coverage.
ℹ️ Review info
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
.changeset/lucky-pianos-poke.md.changeset/wide-pianos-pay.mdpackages/common/src/ai/descriptions/solidity.tspackages/core/solidity/src/erc20.tspackages/ui/src/solidity/ERC20Controls.svelte
A Permit and
Note that we no longer recommend |
Co-authored-by: Ernesto García <ernestognw@gmail.com>
In OpenZeppelin Contracts v5, the Votes module has its own EIP712 and Nonces built-in, so it no longer implicitly requires ERC20Permit. Permit remains useful for gasless token transfers, but is no longer tied to Votes functionality.
However if ERC20Permit is not used, the user's contract needs to initialize the EIP712 domain separator.