Skip to content

Commit

Permalink
Updates l2 bridging script for testing (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppecrj authored Jun 4, 2024
1 parent 5e65398 commit d915c56
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 39 deletions.
60 changes: 21 additions & 39 deletions contracts/scripts/interactions/InteractBaseBridge.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,38 @@ pragma solidity ^0.8.23;

//interfaces
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IL1StandardBridge} from "./interfaces/IL1StandardBridge.sol";
import {IL2StandardBridge} from "./interfaces/IL2StandardBridge.sol";

//libraries

//contracts
import {Interaction} from "../common/Interaction.s.sol";

interface IL1StandardBridge {
function depositETH(
uint32 _minGasLimit,
bytes calldata _extraData
) external payable;

function depositETHTo(
address _to,
uint32 _minGasLimit,
bytes calldata _extraData
) external payable;

function depositERC20(
address _l1Token,
address _l2Token,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;

function depositERC20To(
address _l1Token,
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;
}

contract InteractBaseBridge is Interaction {
address l1StandardBridge = 0xfd0Bf71F60660E2f608ed56e1659C450eB113120;
address l2StandardBridge = 0x4200000000000000000000000000000000000010;

function __interact(address deployer) public override {
// vm.broadcast(deployer);
// IL1StandardBridge(l1StandardBridge).depositETH{value: 0.001 ether}(
// 100000,
// ""
// );
address riverOnSepolia = 0x40eF1bb984503bb5Adef041A88a4F9180e8586f9;
address riverOnBaseSepolia = 0x49442708a16Bf7917764F14A2D103f40Eb27BdD8;
uint256 tokensToDeposit = 1_000_000 ether;

address riverOnSepolia = 0x40eF1bb984503bb5Adef041A88a4F9180e8586f9;
address riverOnBaseSepolia = 0xDaF401580d509117738bF1F38D2CD4ABAEd3c2c5;
uint256 tokensToDeposit = 100_000 ether;
address oldRiverOnBaseSepolia = 0xDaF401580d509117738bF1F38D2CD4ABAEd3c2c5;

function __interact(address deployer) public override {
// Bridge from Base Sepolia to Sepolia
// vm.startBroadcast(deployer);
// IERC20(oldRiverOnBaseSepolia).approve(l2StandardBridge, tokensToDeposit);
// IL2StandardBridge(l2StandardBridge).bridgeERC20({
// _localToken: oldRiverOnBaseSepolia,
// _remoteToken: riverOnSepolia,
// _amount: tokensToDeposit,
// _minGasLimit: 100000,
// _extraData: ""
// });
// vm.stopBroadcast();

// Bridge from Sepolia to Base Sepolia
vm.startBroadcast(deployer);
IERC20(riverOnSepolia).approve(l1StandardBridge, tokensToDeposit);
IL1StandardBridge(l1StandardBridge).depositERC20({
Expand Down
38 changes: 38 additions & 0 deletions contracts/scripts/interactions/interfaces/IL1StandardBridge.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

// interfaces

// libraries

// contracts

interface IL1StandardBridge {
function depositETH(
uint32 _minGasLimit,
bytes calldata _extraData
) external payable;

function depositETHTo(
address _to,
uint32 _minGasLimit,
bytes calldata _extraData
) external payable;

function depositERC20(
address _l1Token,
address _l2Token,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;

function depositERC20To(
address _l1Token,
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;
}
72 changes: 72 additions & 0 deletions contracts/scripts/interactions/interfaces/IL2StandardBridge.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

interface IL2StandardBridge {
/// @notice Sends ETH to the sender's address on the other chain.
/// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
/// not be triggered with this data, but it will be emitted and can be used
/// to identify the transaction.
function bridgeETH(
uint32 _minGasLimit,
bytes calldata _extraData
) external payable;

/// @notice Sends ETH to a receiver's address on the other chain. Note that if ETH is sent to a
/// smart contract and the call fails, the ETH will be temporarily locked in the
/// StandardBridge on the other chain until the call is replayed. If the call cannot be
/// replayed with any amount of gas (call always reverts), then the ETH will be
/// permanently locked in the StandardBridge on the other chain. ETH will also
/// be locked if the receiver is the other bridge, because finalizeBridgeETH will revert
/// in that case.
/// @param _to Address of the receiver.
/// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
/// not be triggered with this data, but it will be emitted and can be used
/// to identify the transaction.
function bridgeETHTo(
address _to,
uint32 _minGasLimit,
bytes calldata _extraData
) external payable;

/// @notice Sends ERC20 tokens to the sender's address on the other chain. Note that if the
/// ERC20 token on the other chain does not recognize the local token as the correct
/// pair token, the ERC20 bridge will fail and the tokens will be returned to sender on
/// this chain.
/// @param _localToken Address of the ERC20 on this chain.
/// @param _remoteToken Address of the corresponding token on the remote chain.
/// @param _amount Amount of local tokens to deposit.
/// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
/// not be triggered with this data, but it will be emitted and can be used
/// to identify the transaction.
function bridgeERC20(
address _localToken,
address _remoteToken,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;

/// @notice Sends ERC20 tokens to a receiver's address on the other chain. Note that if the
/// ERC20 token on the other chain does not recognize the local token as the correct
/// pair token, the ERC20 bridge will fail and the tokens will be returned to sender on
/// this chain.
/// @param _localToken Address of the ERC20 on this chain.
/// @param _remoteToken Address of the corresponding token on the remote chain.
/// @param _to Address of the receiver.
/// @param _amount Amount of local tokens to deposit.
/// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
/// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
/// not be triggered with this data, but it will be emitted and can be used
/// to identify the transaction.
function bridgeERC20To(
address _localToken,
address _remoteToken,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;
}

0 comments on commit d915c56

Please sign in to comment.