-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: migrating usdc to native flow #24
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -78,25 +78,22 @@ contract L1OpUSDCBridgeAdapter is OpUSDCBridgeAdapter, UUPSUpgradeable, IL1OpUSD | |||
/** | ||||
* @notice Sets the amount of USDC tokens that will be burned when the burnLockedUSDC function is called | ||||
* @param _amount The amount of USDC tokens that will be burned | ||||
* @dev Only callable by the UpgradeManager | ||||
* @dev Only callable by a whitelisted messenger during its migration process | ||||
*/ | ||||
function setBurnAmount(uint256 _amount) external onlyUpgradeManager { | ||||
function setBurnAmount(uint256 _amount) external { | ||||
if ( | ||||
messengerStatus[msg.sender] != Status.Upgrading | ||||
|| ICrossDomainMessenger(msg.sender).xDomainMessageSender() != LINKED_ADAPTER | ||||
) { | ||||
revert IOpUSDCBridgeAdapter_InvalidSender(); | ||||
} | ||||
|
||||
burnAmount = _amount; | ||||
messengerStatus[msg.sender] = Status.Deprecated; | ||||
|
||||
emit BurnAmountSet(_amount); | ||||
} | ||||
|
||||
/** | ||||
* @notice Sets the address of the Circle contract | ||||
* @param _circle The address of the Circle contract | ||||
* @dev Only callable by the UpgradeManager | ||||
*/ | ||||
function setCircle(address _circle) external onlyUpgradeManager { | ||||
circle = _circle; | ||||
|
||||
emit CircleSet(_circle); | ||||
} | ||||
|
||||
/** | ||||
* @notice Resume messaging on the messenger | ||||
* @dev Only callable by the UpgradeManager | ||||
|
@@ -252,11 +249,34 @@ contract L1OpUSDCBridgeAdapter is OpUSDCBridgeAdapter, UUPSUpgradeable, IL1OpUSD | |||
|
||||
/** | ||||
* @notice Initiates the process to migrate the bridged USDC to native USDC | ||||
* @param _l1Messenger The address of the L1 messenger | ||||
* @param _messenger The address of the L1 messenger | ||||
* @param _circle The address to transfer ownerships to | ||||
* @param _minGasLimitReceiveOnL2 Minimum gas limit that the message can be executed with on L2 | ||||
* @param _minGasLimitSetBurnAmount Minimum gas limit that the message can be executed with to set the burn amount | ||||
*/ | ||||
function migrateToNative(address _l1Messenger, address _circle) external { | ||||
// TODO: Implement this in future PR | ||||
function migrateToNative( | ||||
address _messenger, | ||||
address _circle, | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing a check over There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But maybe this check would fit better inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a check for this opUSDC/src/contracts/UpgradeManager.sol Line 127 in a0eb0dd
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True 👍 |
||||
uint32 _minGasLimitReceiveOnL2, | ||||
uint32 _minGasLimitSetBurnAmount | ||||
) external onlyUpgradeManager { | ||||
// Ensure messaging is enabled | ||||
// Leave this flow open to resend upgrading flow incase message fails on L2 | ||||
if (messengerStatus[_messenger] != Status.Active && messengerStatus[_messenger] != Status.Upgrading) { | ||||
revert IOpUSDCBridgeAdapter_MessagingDisabled(); | ||||
} | ||||
if (circle != address(0)) revert IOpUSDCBridgeAdapter_MigrationInProgress(); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to remove this check right? Otherwise if it's in |
||||
|
||||
circle = _circle; | ||||
messengerStatus[_messenger] = Status.Upgrading; | ||||
|
||||
ICrossDomainMessenger(_messenger).sendMessage( | ||||
LINKED_ADAPTER, | ||||
abi.encodeWithSignature('receiveMigrateToNative(address,uint32)', _circle, _minGasLimitSetBurnAmount), | ||||
_minGasLimitReceiveOnL2 | ||||
); | ||||
|
||||
emit MigratingToNative(_messenger, _circle); | ||||
} | ||||
|
||||
/** | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,9 +55,9 @@ contract L2OpUSDCFactory is IL2OpUSDCFactory { | |
} | ||
|
||
// Execute the L2 Adapter initialization transactions | ||
if (_l2AdapterInitTxs.length > 1) { | ||
if (_l2AdapterInitTxs.length > 0) { | ||
// Initialize L2 adapter | ||
for (uint256 i = 1; i < _l2AdapterInitTxs.length; i++) { | ||
for (uint256 i; i < _l2AdapterInitTxs.length; i++) { | ||
Comment on lines
57
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It started from |
||
(bool _success,) = _adapterProxy.call(_l2AdapterInitTxs[i]); | ||
if (!_success) { | ||
revert IL2OpUSDCFactory_AdapterInitializationFailed(); | ||
|
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.
This change is not applied on the interface.