Skip to content

Commit

Permalink
contracts-bedrock: add legacy getters
Browse files Browse the repository at this point in the history
  • Loading branch information
tynes committed Nov 29, 2022
1 parent 87a3722 commit 7723df4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 26 deletions.
35 changes: 18 additions & 17 deletions packages/contracts-bedrock/.gas-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -108,41 +108,42 @@ L2OutputOracleUpgradeable_Test:test_cannotInitImpl() (gas: 15171)
L2OutputOracleUpgradeable_Test:test_cannotInitProxy() (gas: 20152)
L2OutputOracleUpgradeable_Test:test_initValuesOnProxy() (gas: 26095)
L2OutputOracleUpgradeable_Test:test_upgrading() (gas: 180457)
L2StandardBridge_Test:test_cannotWithdrawEthWithoutSendingIt() (gas: 19643)
L2StandardBridge_Test:test_cannotWithdrawEthWithoutSendingIt() (gas: 19621)
L2StandardBridge_Test:test_finalizeBridgeETH_incorrectValueReverts() (gas: 23733)
L2StandardBridge_Test:test_finalizeBridgeETH_sendToMessengerReverts() (gas: 23960)
L2StandardBridge_Test:test_finalizeBridgeETH_sendToSelfReverts() (gas: 23793)
L2StandardBridge_Test:test_finalizeDeposit() (gas: 89316)
L2StandardBridge_Test:test_finalizeDeposit() (gas: 89363)
L2StandardBridge_Test:test_initialize() (gas: 10536)
L2StandardBridge_Test:test_receive() (gas: 131820)
L2StandardBridge_Test:test_withdraw() (gas: 343912)
L2StandardBridge_Test:test_withdrawTo() (gas: 344641)
L2StandardBridge_Test:test_withdraw() (gas: 343951)
L2StandardBridge_Test:test_withdrawTo() (gas: 344680)
L2StandardBridge_Test:test_withdraw_onlyEOA() (gas: 251816)
L2ToL1MessagePasserTest:test_burn() (gas: 112530)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromContract() (gas: 70246)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromEOA() (gas: 75764)
LegacyERC20ETH_Test:test_approve() (gas: 10723)
LegacyERC20ETH_Test:test_burn() (gas: 10592)
LegacyERC20ETH_Test:test_crossDomain() (gas: 6306)
LegacyERC20ETH_Test:test_decreaseAllowance() (gas: 10679)
LegacyERC20ETH_Test:test_burn() (gas: 10615)
LegacyERC20ETH_Test:test_crossDomain() (gas: 6339)
LegacyERC20ETH_Test:test_decreaseAllowance() (gas: 10657)
LegacyERC20ETH_Test:test_increaseAllowance() (gas: 10667)
LegacyERC20ETH_Test:test_metadata() (gas: 15391)
LegacyERC20ETH_Test:test_metadata() (gas: 15414)
LegacyERC20ETH_Test:test_mint() (gas: 10649)
LegacyERC20ETH_Test:test_transfer() (gas: 10733)
LegacyERC20ETH_Test:test_transfer() (gas: 10711)
LegacyERC20ETH_Test:test_transferFrom() (gas: 12887)
LegacyMessagePasser_Test:test_LegacyMessagePasser_passMessageToL1_Succeeds() (gas: 34519)
OptimismMintableERC20_Test:test_bridge() (gas: 7624)
OptimismMintableERC20_Test:test_burn() (gas: 51012)
OptimismMintableERC20_Test:test_burnRevertsFromNotBridge() (gas: 11141)
OptimismMintableERC20_Test:test_erc165_supportsInterface() (gas: 7696)
OptimismMintableERC20_Test:test_bridge() (gas: 7599)
OptimismMintableERC20_Test:test_burn() (gas: 51031)
OptimismMintableERC20_Test:test_burnRevertsFromNotBridge() (gas: 11164)
OptimismMintableERC20_Test:test_erc165_supportsInterface() (gas: 7765)
OptimismMintableERC20_Test:test_l1Token() (gas: 7622)
OptimismMintableERC20_Test:test_l2Bridge() (gas: 7633)
OptimismMintableERC20_Test:test_l2Bridge() (gas: 7688)
OptimismMintableERC20_Test:test_legacy() (gas: 14300)
OptimismMintableERC20_Test:test_mint() (gas: 63609)
OptimismMintableERC20_Test:test_mintRevertsFromNotBridge() (gas: 11098)
OptimismMintableERC20_Test:test_remoteToken() (gas: 7624)
OptimismMintableERC20_Test:test_remoteToken() (gas: 7644)
OptimismMintableTokenFactory_Test:test_bridge() (gas: 7577)
OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1083647)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2153437)
OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1095274)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2176691)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenShouldRevertIfRemoteIsZero() (gas: 9413)
OptimismPortalUpgradeable_Test:test_initialize_cannotInitImpl_reverts() (gas: 10791)
OptimismPortalUpgradeable_Test:test_initialize_cannotInitProxy_reverts() (gas: 15767)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ contract OptimismMintableERC20_Test is Bridge_Initializer {
assertEq(L2Token.l2Bridge(), address(L2Bridge));
}

function test_legacy() external {
// Getters for the remote token
assertEq(L2Token.REMOTE_TOKEN(), address(L1Token));
assertEq(L2Token.remoteToken(), address(L1Token));
assertEq(L2Token.l1Token(), address(L1Token));
// Getters for the bridge
assertEq(L2Token.BRIDGE(), address(L2Bridge));
assertEq(L2Token.bridge(), address(L2Bridge));
assertEq(L2Token.l2Bridge(), address(L2Bridge));
}

function test_mint() external {
vm.expectEmit(true, true, true, true);
emit Mint(alice, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
/**
* @notice Address of the corresponding version of this token on the remote chain.
*/
address immutable public remoteToken;
address immutable public REMOTE_TOKEN;

/**
* @notice Address of the StandardBridge on this network.
*/
address immutable public bridge;
address immutable public BRIDGE;

/**
* @notice Emitted whenever tokens are minted for an account.
Expand All @@ -43,7 +43,7 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
* @notice A modifier that only allows the bridge to call
*/
modifier onlyBridge() {
require(msg.sender == bridge, "OptimismMintableERC20: only bridge can mint and burn");
require(msg.sender == BRIDGE, "OptimismMintableERC20: only bridge can mint and burn");
_;
}

Expand All @@ -59,8 +59,8 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) {
remoteToken = _remoteToken;
bridge = _bridge;
REMOTE_TOKEN = _remoteToken;
BRIDGE = _bridge;
}

/**
Expand Down Expand Up @@ -113,17 +113,33 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,

/**
* @custom:legacy
* @notice Legacy getter for the remote token. Use remoteToken going forward.
* @notice Legacy getter for the remote token. Use REMOTE_TOKEN going forward.
*/
function l1Token() public view returns (address) {
return remoteToken;
return REMOTE_TOKEN;
}

/**
* @custom:legacy
* @notice Legacy getter for the bridge. Use bridge going forward.
* @notice Legacy getter for the bridge. Use BRIDGE going forward.
*/
function l2Bridge() public view returns (address) {
return bridge;
return BRIDGE;
}

/**
* @custom:legacy
* @notice Legacy getter for REMOTE_TOKEN.
*/
function remoteToken() public view returns (address) {
return REMOTE_TOKEN;
}

/**
* @custom:legacy
* @notice Legacy getter for BRIDGE.
*/
function bridge() public view returns (address) {
return BRIDGE;
}
}

0 comments on commit 7723df4

Please sign in to comment.