diff --git a/packages/contracts-bedrock/src/L2/L2StandardBridgeInterop.sol b/packages/contracts-bedrock/src/L2/L2StandardBridgeInterop.sol index 0061cfd11535..3383bd0d2733 100644 --- a/packages/contracts-bedrock/src/L2/L2StandardBridgeInterop.sol +++ b/packages/contracts-bedrock/src/L2/L2StandardBridgeInterop.sol @@ -52,8 +52,8 @@ contract L2StandardBridgeInterop is L2StandardBridge { function convert(address _from, address _to, uint256 _amount) external { _validatePair(_from, _to); - IMintableAndBurnableERC20(_from).__superchainMint(msg.sender, _amount); - IMintableAndBurnableERC20(_to).__superchainBurn(msg.sender, _amount); + IMintableAndBurnableERC20(_from).mint(msg.sender, _amount); + IMintableAndBurnableERC20(_to).burn(msg.sender, _amount); emit Converted(_from, _to, msg.sender, _amount); } diff --git a/packages/contracts-bedrock/src/L2/OptimismSuperchainERC20.sol b/packages/contracts-bedrock/src/L2/OptimismSuperchainERC20.sol index 0442e21a7fe3..93f7e18664f5 100644 --- a/packages/contracts-bedrock/src/L2/OptimismSuperchainERC20.sol +++ b/packages/contracts-bedrock/src/L2/OptimismSuperchainERC20.sol @@ -84,7 +84,7 @@ contract OptimismSuperchainERC20 is SuperchainERC20, Initializable, ERC165, IOpt _mint(_to, _amount); - emit Burn(_to, _amount); + emit Mint(_to, _amount); } /// @notice Allows the L2StandardBridge and SuperchainERC20Bridge to burn tokens. diff --git a/packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol b/packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol index 015985a787f8..103fe5794a1d 100644 --- a/packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol +++ b/packages/contracts-bedrock/src/L2/SuperchainERC20Bridge.sol @@ -6,7 +6,7 @@ import { Predeploys } from "src/libraries/Predeploys.sol"; // Interfaces import { ISuperchainERC20Bridge } from "src/L2/interfaces/ISuperchainERC20Bridge.sol"; -import { IMintableAndBurnableERC20 } from "src/L2/interfaces/IMintableAndBurnableERC20.sol"; +import { ISuperchainERC20 } from "src/L2/interfaces/ISuperchainERC20.sol"; import { IL2ToL2CrossDomainMessenger } from "src/L2/interfaces/IL2ToL2CrossDomainMessenger.sol"; /// @custom:proxied true @@ -29,7 +29,7 @@ contract SuperchainERC20Bridge is ISuperchainERC20Bridge { /// @param _amount Amount of tokens to send. /// @param _chainId Chain ID of the destination chain. function sendERC20(address _token, address _to, uint256 _amount, uint256 _chainId) external { - IMintableAndBurnableERC20(_token).__superchainBurn(msg.sender, _amount); + ISuperchainERC20(_token).__superchainBurn(msg.sender, _amount); bytes memory message = abi.encodeCall(this.relayERC20, (_token, msg.sender, _to, _amount)); IL2ToL2CrossDomainMessenger(MESSENGER).sendMessage(_chainId, address(this), message); @@ -51,7 +51,7 @@ contract SuperchainERC20Bridge is ISuperchainERC20Bridge { uint256 source = IL2ToL2CrossDomainMessenger(MESSENGER).crossDomainMessageSource(); - IMintableAndBurnableERC20(_token).__superchainMint(_to, _amount); + ISuperchainERC20(_token).__superchainMint(_to, _amount); emit RelayERC20(_token, _from, _to, _amount, source); } diff --git a/packages/contracts-bedrock/src/L2/interfaces/IMintableAndBurnableERC20.sol b/packages/contracts-bedrock/src/L2/interfaces/IMintableAndBurnableERC20.sol index d6070df06d04..166fa0c8077f 100644 --- a/packages/contracts-bedrock/src/L2/interfaces/IMintableAndBurnableERC20.sol +++ b/packages/contracts-bedrock/src/L2/interfaces/IMintableAndBurnableERC20.sol @@ -9,10 +9,10 @@ interface IMintableAndBurnableERC20 is IERC20 { /// @notice Mints `_amount` of tokens to `_to`. /// @param _to Address to mint tokens to. /// @param _amount Amount of tokens to mint. - function __superchainMint(address _to, uint256 _amount) external; + function mint(address _to, uint256 _amount) external; /// @notice Burns `_amount` of tokens from `_from`. /// @param _from Address to burn tokens from. /// @param _amount Amount of tokens to burn. - function __superchainBurn(address _from, uint256 _amount) external; + function burn(address _from, uint256 _amount) external; } diff --git a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol index 09d4ecefb5b6..dce9ba3774d5 100644 --- a/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol +++ b/packages/contracts-bedrock/test/L2/L2StandardBridgeInterop.t.sol @@ -203,14 +203,10 @@ contract L2StandardBridgeInterop_LegacyToSuper_Test is L2StandardBridgeInterop_T // Mock and expect the `burn` and `mint` functions _mockAndExpect( - _from, - abi.encodeWithSelector(IMintableAndBurnableERC20.__superchainBurn.selector, _caller, _amount), - abi.encode() + _from, abi.encodeWithSelector(IMintableAndBurnableERC20.burn.selector, _caller, _amount), abi.encode() ); _mockAndExpect( - _to, - abi.encodeWithSelector(IMintableAndBurnableERC20.__superchainMint.selector, _caller, _amount), - abi.encode() + _to, abi.encodeWithSelector(IMintableAndBurnableERC20.mint.selector, _caller, _amount), abi.encode() ); // Act @@ -365,14 +361,10 @@ contract L2StandardBridgeInterop_SuperToLegacy_Test is L2StandardBridgeInterop_T // Mock and expect the `burn` and `mint` functions _mockAndExpect( - _from, - abi.encodeWithSelector(IMintableAndBurnableERC20.__superchainBurn.selector, _caller, _amount), - abi.encode() + _from, abi.encodeWithSelector(IMintableAndBurnableERC20.burn.selector, _caller, _amount), abi.encode() ); _mockAndExpect( - _to, - abi.encodeWithSelector(IMintableAndBurnableERC20.__superchainMint.selector, _caller, _amount), - abi.encode() + _to, abi.encodeWithSelector(IMintableAndBurnableERC20.mint.selector, _caller, _amount), abi.encode() ); // Act diff --git a/packages/contracts-bedrock/test/L2/OptimismSuperchainERC20.t.sol b/packages/contracts-bedrock/test/L2/OptimismSuperchainERC20.t.sol index 630eb5214f78..ce67bc12d116 100644 --- a/packages/contracts-bedrock/test/L2/OptimismSuperchainERC20.t.sol +++ b/packages/contracts-bedrock/test/L2/OptimismSuperchainERC20.t.sol @@ -16,7 +16,11 @@ import { IBeacon } from "@openzeppelin/contracts-v5/proxy/beacon/IBeacon.sol"; import { BeaconProxy } from "@openzeppelin/contracts-v5/proxy/beacon/BeaconProxy.sol"; // Target contract -import { OptimismSuperchainERC20, IOptimismSuperchainERC20Extension } from "src/L2/OptimismSuperchainERC20.sol"; +import { OptimismSuperchainERC20 } from "src/L2/OptimismSuperchainERC20.sol"; +import { + IOptimismSuperchainERC20Extension, + IOptimismSuperchainERC20Errors +} from "src/L2/interfaces/IOptimismSuperchainERC20.sol"; import { ISuperchainERC20Errors } from "src/L2/interfaces/ISuperchainERC20.sol"; /// @title OptimismSuperchainERC20Test @@ -119,12 +123,12 @@ contract OptimismSuperchainERC20Test is Test { // Ensure the caller is not the bridge vm.assume(_caller != L2_BRIDGE); - // Expect the revert with `OnlySuperchainERC20Bridge` selector - vm.expectRevert(ISuperchainERC20Errors.OnlySuperchainERC20Bridge.selector); + // Expect the revert with `OnlyL2StandardBridge` selector + vm.expectRevert(IOptimismSuperchainERC20Errors.OnlyL2StandardBridge.selector); // Call the `mint` function with the non-bridge caller vm.prank(_caller); - optimismSuperchainERC20.__superchainMint(_to, _amount); + optimismSuperchainERC20.mint(_to, _amount); } /// @notice Tests the `mint` function reverts when the amount is zero. @@ -134,7 +138,7 @@ contract OptimismSuperchainERC20Test is Test { // Call the `mint` function with the zero address vm.prank(L2_BRIDGE); - optimismSuperchainERC20.__superchainMint({ _to: ZERO_ADDRESS, _amount: _amount }); + optimismSuperchainERC20.mint({ _to: ZERO_ADDRESS, _amount: _amount }); } /// @notice Tests the `mint` succeeds and emits the `Mint` event. @@ -156,7 +160,7 @@ contract OptimismSuperchainERC20Test is Test { // Call the `mint` function with the bridge caller vm.prank(L2_BRIDGE); - optimismSuperchainERC20.__superchainMint(_to, _amount); + optimismSuperchainERC20.mint(_to, _amount); // Check the total supply and balance of `_to` after the mint were updated correctly assertEq(optimismSuperchainERC20.totalSupply(), _totalSupplyBefore + _amount); @@ -168,12 +172,12 @@ contract OptimismSuperchainERC20Test is Test { // Ensure the caller is not the bridge vm.assume(_caller != L2_BRIDGE); - // Expect the revert with `OnlySuperchainERC20Bridge` selector - vm.expectRevert(ISuperchainERC20Errors.OnlySuperchainERC20Bridge.selector); + // Expect the revert with `OnlyL2StandardBridge` selector + vm.expectRevert(IOptimismSuperchainERC20Errors.OnlyL2StandardBridge.selector); // Call the `burn` function with the non-bridge caller vm.prank(_caller); - optimismSuperchainERC20.__superchainBurn(_from, _amount); + optimismSuperchainERC20.burn(_from, _amount); } /// @notice Tests the `burn` function reverts when the amount is zero. @@ -183,7 +187,7 @@ contract OptimismSuperchainERC20Test is Test { // Call the `burn` function with the zero address vm.prank(L2_BRIDGE); - optimismSuperchainERC20.__superchainBurn({ _from: ZERO_ADDRESS, _amount: _amount }); + optimismSuperchainERC20.burn({ _from: ZERO_ADDRESS, _amount: _amount }); } /// @notice Tests the `burn` burns the amount and emits the `Burn` event. @@ -193,7 +197,7 @@ contract OptimismSuperchainERC20Test is Test { // Mint some tokens to `_from` so then they can be burned vm.prank(L2_BRIDGE); - optimismSuperchainERC20.__superchainMint(_from, _amount); + optimismSuperchainERC20.mint(_from, _amount); // Get the total supply and balance of `_from` before the burn to compare later on the assertions uint256 _totalSupplyBefore = optimismSuperchainERC20.totalSupply(); @@ -209,7 +213,7 @@ contract OptimismSuperchainERC20Test is Test { // Call the `burn` function with the bridge caller vm.prank(L2_BRIDGE); - optimismSuperchainERC20.__superchainBurn(_from, _amount); + optimismSuperchainERC20.burn(_from, _amount); // Check the total supply and balance of `_from` after the burn were updated correctly assertEq(optimismSuperchainERC20.totalSupply(), _totalSupplyBefore - _amount); diff --git a/packages/contracts-bedrock/test/vendor/Initializable.t.sol b/packages/contracts-bedrock/test/vendor/Initializable.t.sol index 0228c7bb53b5..d5c1a9e5e4c3 100644 --- a/packages/contracts-bedrock/test/vendor/Initializable.t.sol +++ b/packages/contracts-bedrock/test/vendor/Initializable.t.sol @@ -401,7 +401,7 @@ contract Initializer_Test is Bridge_Initializer { excludes[0] = "src/L1/SystemConfigInterop.sol"; excludes[1] = "src/L1/OptimismPortalInterop.sol"; // Contract is currently not being deployed as part of the standard deployment script. - excludes[2] = "src/L2/SuperchainERC20.sol"; + excludes[2] = "src/L2/OptimismSuperchainERC20.sol"; // Periphery contracts don't get deployed as part of the standard deployment script. excludes[3] = "src/periphery/*"; // TODO: Deployment script is currently "broken" in the sense that it doesn't properly