-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from BootNodeDev/arbitrum-compatible-xerc20-tests
Arbitrum compatible xerc20 tests
- Loading branch information
Showing
9 changed files
with
186 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
import { XERC20 } from "xerc20/contracts/XERC20.sol"; | ||
|
||
interface IL1CustomGateway { | ||
function registerTokenToL2( | ||
address _l2Address, | ||
uint256 _maxGas, | ||
uint256 _gasPriceBid, | ||
uint256 _maxSubmissionCost, | ||
address _creditBackAddress | ||
) | ||
external | ||
payable | ||
returns (uint256); | ||
|
||
function router() external returns (address); | ||
} | ||
|
||
interface IL1GatewayRouter { | ||
function setGateway( | ||
address _gateway, | ||
uint256 _maxGas, | ||
uint256 _gasPriceBid, | ||
uint256 _maxSubmissionCost, | ||
address _creditBackAddress | ||
) | ||
external | ||
payable | ||
returns (uint256); | ||
} | ||
|
||
contract L1ArbitrumEnabledXERC20 is XERC20 { | ||
address internal gatewayAddress; | ||
|
||
constructor( | ||
string memory _name, | ||
string memory _symbol, | ||
address _owner, | ||
address _gatewayAddress | ||
) | ||
XERC20(_name, _symbol, _owner) | ||
{ | ||
gatewayAddress = _gatewayAddress; | ||
} | ||
|
||
function isArbitrumEnabled() external pure returns (uint8) { | ||
return uint8(0xb1); | ||
} | ||
|
||
function registerTokenOnL2( | ||
address l2TokenAddress, | ||
uint256 maxSubmissionCostForGateway, | ||
uint256 maxSubmissionCostForRouter, | ||
uint256 maxGasForGateway, | ||
uint256 maxGasForRouter, | ||
uint256 gasPriceBid, | ||
uint256 valueForGateway, | ||
uint256 valueForRouter, | ||
address creditBackAddress | ||
) | ||
public | ||
payable | ||
onlyOwner | ||
{ | ||
IL1CustomGateway gateway = IL1CustomGateway(gatewayAddress); | ||
|
||
gateway.registerTokenToL2{ value: valueForGateway }( | ||
l2TokenAddress, maxGasForGateway, gasPriceBid, maxSubmissionCostForGateway, creditBackAddress | ||
); | ||
IL1GatewayRouter(gateway.router()).setGateway{ value: valueForRouter }( | ||
gatewayAddress, maxGasForRouter, gasPriceBid, maxSubmissionCostForRouter, creditBackAddress | ||
); | ||
} | ||
} |
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,19 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
import { XERC20 } from "xerc20/contracts/XERC20.sol"; | ||
|
||
contract L2ArbitrumEnabledXERC20 is XERC20 { | ||
address public l1Address; | ||
|
||
constructor( | ||
string memory _name, | ||
string memory _symbol, | ||
address _owner, | ||
address _l1Address | ||
) | ||
XERC20(_name, _symbol, _owner) | ||
{ | ||
l1Address = _l1Address; | ||
} | ||
} |
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
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,24 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
// solhint-disable-next-line | ||
import { console2 } from "forge-std/console2.sol"; | ||
|
||
import { XERC20 } from "xerc20/contracts/XERC20.sol"; | ||
|
||
import { L2ArbitrumEnabledXERC20 } from "src/L2ArbitrumEnabledXERC20.sol"; | ||
|
||
import { L2XERC20GatewayTest } from "test/L2XERC20Gateway.t.sol"; | ||
|
||
contract L2XERC20GatewayArbitrumCompatibleTokenTest is L2XERC20GatewayTest { | ||
L2ArbitrumEnabledXERC20 internal arbEnabledToken; | ||
|
||
function _createXERC20() internal override { | ||
arbEnabledToken = new L2ArbitrumEnabledXERC20("ArbitrumEnabledToken", "AET", _owner, l1Token); | ||
xerc20 = XERC20(address(arbEnabledToken)); | ||
} | ||
|
||
function _setBridgeable() internal override { | ||
bridgeable = address(xerc20); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity >=0.8.25 <0.9.0; | ||
|
||
// solhint-disable-next-line | ||
import { console2 } from "forge-std/console2.sol"; | ||
|
||
import { XERC20 } from "xerc20/contracts/XERC20.sol"; | ||
|
||
import { L1ArbitrumEnabledXERC20 } from "src/L1ArbitrumEnabledXERC20.sol"; | ||
|
||
import { L1XERC20GatewayForkingTest } from "test/forking/L1XERC20Gateway.t.sol"; | ||
|
||
contract L1XERC20GatewayArbitrumCompatibleTokenTest is L1XERC20GatewayForkingTest { | ||
L1ArbitrumEnabledXERC20 internal arbEnabledToken; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
bridgeable = address(arbEnabledToken); | ||
} | ||
|
||
function _createXERC20() internal override { | ||
arbEnabledToken = new L1ArbitrumEnabledXERC20("ArbitrumEnabledToken", "AET", _owner, address(l1Gateway)); | ||
xerc20 = XERC20(address(arbEnabledToken)); | ||
} | ||
} |