forked from OffchainLabs/arbitrum-classic
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor custom refund entrypoint to only be available in L1 (Offchai…
…nLabs#2376) * refactor custom refund entrypoint only available in L1 * cleanup interface * fix: remove IERC165 from IERC721.sol * test: new interfaces for compatibility Co-authored-by: gzeon <[email protected]>
- Loading branch information
Showing
9 changed files
with
206 additions
and
97 deletions.
There are no files selected for viewing
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
56 changes: 56 additions & 0 deletions
56
...ages/arb-bridge-peripherals/contracts/tokenbridge/ethereum/gateway/IL1ArbitrumGateway.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,56 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/* | ||
* Copyright 2020, Offchain Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// solhint-disable-next-line compiler-version | ||
pragma solidity >=0.6.9 <0.9.0; | ||
|
||
import "../../libraries/gateway/ITokenGateway.sol"; | ||
import "../../libraries/IERC165.sol"; | ||
|
||
/** | ||
* @title Common interface for gatways on L1 messaging to Arbitrum. | ||
*/ | ||
interface IL1ArbitrumGateway is ITokenGateway, IERC165 { | ||
/** | ||
* @notice Deposit ERC20 token from Ethereum into Arbitrum. If L2 side hasn't been deployed yet, includes name/symbol/decimals data for initial L2 deploy. Initiate by GatewayRouter. | ||
* @dev L2 address alias will not be applied to the following types of addresses on L1: | ||
* - an externally-owned account | ||
* - a contract in construction | ||
* - an address where a contract will be created | ||
* - an address where a contract lived, but was destroyed | ||
* @param _l1Token L1 address of ERC20 | ||
* @param _refundTo Account, or its L2 alias if it have code in L1, to be credited with excess gas refund in L2 | ||
* @param _to Account to be credited with the tokens in the L2 (can be the user's L2 account or a contract), not subject to L2 aliasing | ||
This account, or its L2 alias if it have code in L1, will also be able to cancel the retryable ticket and receive callvalue refund | ||
* @param _amount Token Amount | ||
* @param _maxGas Max gas deducted from user's L2 balance to cover L2 execution | ||
* @param _gasPriceBid Gas price for L2 execution | ||
* @param _data encoded data from router and user | ||
* @return res abi encoded inbox sequence number | ||
*/ | ||
// * @param maxSubmissionCost Max gas deducted from user's L2 balance to cover base submission fee | ||
function outboundTransferCustomRefund( | ||
address _l1Token, | ||
address _refundTo, | ||
address _to, | ||
uint256 _amount, | ||
uint256 _maxGas, | ||
uint256 _gasPriceBid, | ||
bytes calldata _data | ||
) external payable returns (bytes memory); | ||
} |
93 changes: 93 additions & 0 deletions
93
packages/arb-bridge-peripherals/contracts/tokenbridge/ethereum/gateway/IL1GatewayRouter.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,93 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
/* | ||
* Copyright 2020, Offchain Labs, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// solhint-disable-next-line compiler-version | ||
pragma solidity >=0.6.9 <0.9.0; | ||
|
||
import "../../libraries/gateway/ITokenGateway.sol"; | ||
import "../../libraries/IERC165.sol"; | ||
|
||
/** | ||
* @title Handles deposits from Erhereum into Arbitrum. Tokens are routered to their appropriate L1 gateway (Router itself also conforms to the Gateway itnerface). | ||
* @notice Router also serves as an L1-L2 token address oracle. | ||
*/ | ||
interface IL1GatewayRouter is ITokenGateway, IERC165 { | ||
/** | ||
* @notice Deposit ERC20 token from Ethereum into Arbitrum using the registered or otherwise default gateway | ||
* @dev Some legacy gateway might not have the outboundTransferCustomRefund method and will revert, in such case use outboundTransfer instead | ||
* L2 address alias will not be applied to the following types of addresses on L1: | ||
* - an externally-owned account | ||
* - a contract in construction | ||
* - an address where a contract will be created | ||
* - an address where a contract lived, but was destroyed | ||
* @param _token L1 address of ERC20 | ||
* @param _refundTo Account, or its L2 alias if it have code in L1, to be credited with excess gas refund in L2 | ||
* @param _to Account to be credited with the tokens in the L2 (can be the user's L2 account or a contract), not subject to L2 aliasing | ||
This account, or its L2 alias if it have code in L1, will also be able to cancel the retryable ticket and receive callvalue refund | ||
* @param _amount Token Amount | ||
* @param _maxGas Max gas deducted from user's L2 balance to cover L2 execution | ||
* @param _gasPriceBid Gas price for L2 execution | ||
* @param _data encoded data from router and user | ||
* @return res abi encoded inbox sequence number | ||
*/ | ||
function outboundTransferCustomRefund( | ||
address _token, | ||
address _refundTo, | ||
address _to, | ||
uint256 _amount, | ||
uint256 _maxGas, | ||
uint256 _gasPriceBid, | ||
bytes calldata _data | ||
) external payable returns (bytes memory); | ||
|
||
/** | ||
* @notice Allows L1 Token contract to trustlessly register its gateway. | ||
* @param _gateway l1 gateway address | ||
* @param _maxGas max gas for L2 retryable exrecution | ||
* @param _gasPriceBid gas price for L2 retryable ticket | ||
* @param _maxSubmissionCost base submission cost L2 retryable tick3et | ||
* @param _creditBackAddress address for crediting back overpayment of _maxSubmissionCost | ||
* @return Retryable ticket ID | ||
*/ | ||
function setGateway( | ||
address _gateway, | ||
uint256 _maxGas, | ||
uint256 _gasPriceBid, | ||
uint256 _maxSubmissionCost, | ||
address _creditBackAddress | ||
) external payable returns (uint256); | ||
|
||
/** | ||
* @notice Allows L1 Token contract to trustlessly register its gateway. (other setGateway method allows excess eth recovery from _maxSubmissionCost and is recommended) | ||
* @param _gateway l1 gateway address | ||
* @param _maxGas max gas for L2 retryable exrecution | ||
* @param _gasPriceBid gas price for L2 retryable ticket | ||
* @param _maxSubmissionCost base submission cost L2 retryable tick3et | ||
* @return Retryable ticket ID | ||
*/ | ||
function setGateway( | ||
address _gateway, | ||
uint256 _maxGas, | ||
uint256 _gasPriceBid, | ||
uint256 _maxSubmissionCost | ||
) external payable returns (uint256); | ||
|
||
function owner() external view returns (address); | ||
|
||
function inbox() external view returns (address); | ||
} |
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
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
Oops, something went wrong.