Skip to content

Commit

Permalink
arbitrum gateways
Browse files Browse the repository at this point in the history
  • Loading branch information
aalavandhan committed Nov 2, 2021
1 parent 4aa8b6e commit 67529a1
Show file tree
Hide file tree
Showing 9 changed files with 1,958 additions and 0 deletions.
85 changes: 85 additions & 0 deletions contracts/_mocks/MockArbitrum.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.6.11;
pragma experimental ABIEncoderV2;

import {InboxMock} from "arb-bridge-peripherals/contracts/tokenbridge/test/InboxMock.sol";
import {L1ArbitrumMessenger} from "arb-bridge-peripherals/contracts/tokenbridge/ethereum/L1ArbitrumMessenger.sol";
import {L2ArbitrumMessenger} from "arb-bridge-peripherals/contracts/tokenbridge/arbitrum/L2ArbitrumMessenger.sol";
import {L1ArbitrumTestMessenger} from "arb-bridge-peripherals/contracts/tokenbridge/test/GatewayTest.sol";
import {L2ArbitrumTestMessenger} from "arb-bridge-peripherals/contracts/tokenbridge/test/GatewayTest.sol";
import {IBridge} from "arb-bridge-peripherals/contracts/tokenbridge/test/GatewayTest.sol";
import {AMPLArbitrumGateway} from "../base-chain/bridge-gateways/AMPLArbitrumGateway.sol";
import {ArbitrumXCAmpleGateway} from "../satellite-chain/bridge-gateways/ArbitrumXCAmpleGateway.sol";

contract MockArbitrumInbox is InboxMock {}

// Mocking sendTxToL2
// https://shorturl.at/dgABO
contract MockAMPLArbitrumGateway is L1ArbitrumTestMessenger, AMPLArbitrumGateway {
constructor(
address ampl_,
address policy_,
address vault_
) public AMPLArbitrumGateway(ampl_, policy_, vault_) {}

function sendTxToL2(
address _inbox,
address _to,
address _user,
uint256 _l1CallValue,
uint256 _l2CallValue,
uint256 _maxSubmissionCost,
uint256 _maxGas,
uint256 _gasPriceBid,
bytes memory _data
) internal virtual override(L1ArbitrumMessenger, L1ArbitrumTestMessenger) returns (uint256) {
return
L1ArbitrumTestMessenger.sendTxToL2(
_inbox,
_to,
_user,
_l1CallValue,
_l2CallValue,
_maxSubmissionCost,
_maxGas,
_gasPriceBid,
_data
);
}

function getL2ToL1Sender(address _inbox)
internal
view
virtual
override(L1ArbitrumMessenger, L1ArbitrumTestMessenger)
returns (address)
{
return L1ArbitrumTestMessenger.getL2ToL1Sender(_inbox);
}

function getBridge(address _inbox)
internal
view
virtual
override(L1ArbitrumMessenger, L1ArbitrumTestMessenger)
returns (IBridge)
{
return L1ArbitrumTestMessenger.getBridge(_inbox);
}
}

contract MockArbitrumXCAmpleGateway is L2ArbitrumTestMessenger, ArbitrumXCAmpleGateway {
constructor(address xcAmple_, address xcController_)
public
ArbitrumXCAmpleGateway(xcAmple_, xcController_)
{}

function sendTxToL1(
uint256 _l1CallValue,
address _from,
address _to,
bytes memory _data
) internal virtual override(L2ArbitrumMessenger, L2ArbitrumTestMessenger) returns (uint256) {
return L2ArbitrumTestMessenger.sendTxToL1(_l1CallValue, _from, _to, _data);
}
}
24 changes: 24 additions & 0 deletions contracts/_test/UFragmentsTestnet.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Importing uFragments contract dependencies to be compiled for integration tests
pragma solidity 0.7.6;

import {UFragments} from "uFragments/contracts/UFragments.sol";

contract UFragmentsTestnet is UFragments {
event Result(bool result, bytes reason);

function isArbitrumEnabled() external view returns (uint8) {
return uint8(0xa4b1);
}

// NOTE: this allows the token contarct to register itself with the bridge on testnet
// The AMPL contract on mainnet is immutable and this can't be used!
function externalCall(
address destination,
bytes calldata data,
uint256 value
) external payable {
(bool result, bytes memory reason) = destination.call{value: value}(data);
emit Result(result, reason);
}
}
Loading

0 comments on commit 67529a1

Please sign in to comment.