Add ERC-20 option for embedding ERC-7786 based crosschain bridge, use Contracts 5.6.0#747
Conversation
WalkthroughThis PR adds support for ERC-7786 native cross-chain bridging option across OpenZeppelin Wizard for ERC20, stablecoin, and Real World Asset contracts. It introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes
Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
All alerts resolved. Learn more about Socket for GitHub. This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. Ignoring alerts on:
|
packages/core/solidity/src/erc20.ts
Outdated
| args: [ | ||
| { name: 'gateway', type: 'address' }, | ||
| { name: 'counterpart', type: 'bytes memory' }, | ||
| { name: 'allowOverride', type: 'bool' }, |
There was a problem hiding this comment.
I don't think this should be an argument in the public function. The contract has to hardcode a value IIUC. CC @Amxx
There was a problem hiding this comment.
From @Amxx: allowOverride should be false by default so that links are immutable once set.
There was a problem hiding this comment.
Also consider adding a comment explaining the choice of false and when to consider changing it.
There was a problem hiding this comment.
Added an option for this with default as false.
|
I think "ERC-7786 Native" instead of "Embedded" is a clearer and more compelling name. Open to other suggestions involving ERC-7786. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
| import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";␊ | ||
| ␊ | ||
| contract MyToken is ERC20, ERC20Bridgeable, ERC20Permit {␊ | ||
| contract MyToken is ERC20, ERC20Bridgeable, Ownable, ERC20Permit {␊ |
There was a problem hiding this comment.
What would it take to join the ERC20XXX inheritance and have Ownable at the end. Not really an issue, but it would be cleaner if we could achieve that easily
There was a problem hiding this comment.
I started to do this but realized that would make it have a different order than the parent initializer calls. We document that the parent initializer calls should be in linearization order, and the Upgrades Plugins would give a warning if they are not.
We should aim to eventually stabilize and reorganize these, but it may require a larger change in how the code is generated in order to do this properly.
Opened #750 to track this as an enhancement request.
Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
|
Leaving as Draft to avoid merging until 5.6.0 final version is released. |
Overview
In Solidity ERC-20's Cross-Chain Bridging section, adds an ERC-7866 Native option to use
ERC20Crosschain. When this is selected, it also shows a sub-option Allow Link Overrides which defaults tofalse.Both the ERC-7866 Native (
ERC20Crosschain) and Custom (ERC20Bridgeable) bridging options will require access control.ERC-7866 Native requires OpenZeppelin Contracts 5.6.0.
Breaking Changes
Custom bridging option now requires access control to allow privileged roles to update the token bridge address after deployment.
Rationale: Tokens may want to update their bridge address to use a
BridgeERC7802, which requires the token address as a constructor argument to set an immutable variable. This implies the token must be deployed before the bridge.New Features
ERC-7786 Native (
ERC20Crosschain) embeds an ERC-7786 based bridge directly in the token contract. This option requires access control to manage crosschain links.false.