-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: RegisterAndSetArbCustomGatewayAction (#308)
* feat: RegisterAndSetGatewayAction * fix: send value * chore: rename to RegisterAndSetArbCustomGatewayAction * fix: make payable
- Loading branch information
Showing
3 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/gov-action-contracts/token-bridge/RegisterAndSetArbCustomGatewayAction.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
pragma solidity 0.8.16; | ||
|
||
import "../address-registries/interfaces.sol"; | ||
import "./TokenBridgeActionLib.sol"; | ||
|
||
contract RegisterAndSetArbCustomGatewayAction { | ||
IL1AddressRegistry public immutable addressRegistry; | ||
|
||
constructor(IL1AddressRegistry _addressRegistry) { | ||
addressRegistry = _addressRegistry; | ||
} | ||
|
||
function perform( | ||
address[] memory _l1Tokens, | ||
address[] memory _l2Tokens, | ||
uint256 _maxGasForRegister, | ||
uint256 _gasPriceBidForRegister, | ||
uint256 _maxSubmissionCostForRegister, | ||
uint256 _maxGasForSetGateway, | ||
uint256 _gasPriceBidForSetGateway, | ||
uint256 _maxSubmissionCostForSetGateway | ||
) external payable { | ||
TokenBridgeActionLib.ensureAllContracts(_l1Tokens); | ||
|
||
IL1CustomGateway customGateway = addressRegistry.customGateway(); | ||
|
||
customGateway.forceRegisterTokenToL2{ | ||
value: _maxGasForRegister * _gasPriceBidForRegister + _maxSubmissionCostForRegister | ||
}( | ||
_l1Tokens, | ||
_l2Tokens, | ||
_maxGasForRegister, | ||
_gasPriceBidForRegister, | ||
_maxSubmissionCostForRegister | ||
); | ||
|
||
address[] memory gateways = new address[](_l1Tokens.length); | ||
for (uint256 i = 0; i < _l1Tokens.length; i++) { | ||
gateways[i] = address(customGateway); | ||
} | ||
addressRegistry.gatewayRouter().setGateways{ | ||
value: _maxGasForSetGateway * _gasPriceBidForSetGateway + _maxSubmissionCostForSetGateway | ||
}( | ||
_l1Tokens, | ||
gateways, | ||
_maxGasForSetGateway, | ||
_gasPriceBidForSetGateway, | ||
_maxSubmissionCostForSetGateway | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters