Skip to content

Commit

Permalink
feat: RegisterAndSetArbCustomGatewayAction (#308)
Browse files Browse the repository at this point in the history
* feat: RegisterAndSetGatewayAction

* fix: send value

* chore: rename to RegisterAndSetArbCustomGatewayAction

* fix: make payable
  • Loading branch information
gzeoneth authored Oct 15, 2024
1 parent 0d210c6 commit bf74af2
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
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
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ contract RegisterL2TokenInArbCustomGatewayAction {
uint256 _maxGas,
uint256 _gasPriceBid,
uint256 _maxSubmissionCost
) external {
) external payable {
TokenBridgeActionLib.ensureAllContracts(_l1Tokens);

addressRegistry.customGateway().forceRegisterTokenToL2(
_l1Tokens, _l2Tokens, _maxGas, _gasPriceBid, _maxSubmissionCost
);
addressRegistry.customGateway().forceRegisterTokenToL2{
value: _maxGas * _gasPriceBid + _maxSubmissionCost
}(_l1Tokens, _l2Tokens, _maxGas, _gasPriceBid, _maxSubmissionCost);
}
}
8 changes: 4 additions & 4 deletions src/gov-action-contracts/token-bridge/SetGatewayAction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ contract SetGatewayAction {
uint256 _maxGas,
uint256 _gasPriceBid,
uint256 _maxSubmissionCost
) external {
) external payable {
TokenBridgeActionLib.ensureAllContracts(_tokens);
TokenBridgeActionLib.ensureAllContracts(_gateways);

addressRegistry.gatewayRouter().setGateways(
_tokens, _gateways, _maxGas, _gasPriceBid, _maxSubmissionCost
);
addressRegistry.gatewayRouter().setGateways{
value: _maxGas * _gasPriceBid + _maxSubmissionCost
}(_tokens, _gateways, _maxGas, _gasPriceBid, _maxSubmissionCost);
}
}

0 comments on commit bf74af2

Please sign in to comment.