Commit b9a90f32 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ctb): rename token factory to erc20 factory (#2950)

* fix(ctb): rename token factory to erc20 factory

With the intent of mirroring the naming of the ERC721 bridge, I'm
renaming the OptimismMintableTokenFactory to
OptimismMintableERC20Factory.

* contracts-bedrock: fix test

* contracts-bedrock: snapshot
Co-authored-by: default avatarMark Tyneway <mark.tyneway@gmail.com>
parent 91b31168
---
'@eth-optimism/contracts-bedrock': patch
---
Rename OptimismMintableTokenFactory to OptimismMintableERC20Factory
......@@ -10,7 +10,7 @@ const (
L2CrossDomainMessenger = "0x4200000000000000000000000000000000000007"
L2StandardBridge = "0x4200000000000000000000000000000000000010"
SequencerFeeVault = "0x4200000000000000000000000000000000000011"
OptimismMintableTokenFactory = "0x4200000000000000000000000000000000000012"
OptimismMintableERC20Factory = "0x4200000000000000000000000000000000000012"
L1BlockNumber = "0x4200000000000000000000000000000000000013"
OVM_GasPriceOracle = "0x420000000000000000000000000000000000000F"
L1Block = "0x4200000000000000000000000000000000000015"
......@@ -25,7 +25,7 @@ var (
L2CrossDomainMessengerAddr = common.HexToAddress(L2CrossDomainMessenger)
L2StandardBridgeAddr = common.HexToAddress(L2StandardBridge)
SequencerFeeVaultAddr = common.HexToAddress(SequencerFeeVault)
OptimismMintableTokenFactoryAddr = common.HexToAddress(OptimismMintableTokenFactory)
OptimismMintableERC20FactoryAddr = common.HexToAddress(OptimismMintableERC20Factory)
L1BlockNumberAddr = common.HexToAddress(L1BlockNumber)
OVM_GasPriceOracleAddr = common.HexToAddress(OVM_GasPriceOracle)
L1BlockAddr = common.HexToAddress(L1Block)
......
......@@ -120,11 +120,11 @@ OptimismMintableERC20_Test:test_l2Bridge() (gas: 9746)
OptimismMintableERC20_Test:test_mint() (gas: 65754)
OptimismMintableERC20_Test:test_mintRevertsFromNotBridge() (gas: 13243)
OptimismMintableERC20_Test:test_remoteToken() (gas: 9740)
OptimismMintableTokenFactory_Test:test_bridge() (gas: 9750)
OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1115359)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2211629)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenShouldRevertIfRemoteIsZero() (gas: 9407)
OptimismMintableTokenFactory_Test:test_initializeShouldRevert() (gas: 12732)
OptimismMintableTokenFactory_Test:test_bridge() (gas: 9772)
OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1115409)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2211729)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenShouldRevertIfRemoteIsZero() (gas: 9445)
OptimismMintableTokenFactory_Test:test_initializeShouldRevert() (gas: 12721)
OptimismPortalUpgradeable_Test:test_cannotInitImpl() (gas: 10936)
OptimismPortalUpgradeable_Test:test_cannotInitProxy() (gas: 15978)
OptimismPortalUpgradeable_Test:test_initValuesOnProxy() (gas: 16034)
......
......@@ -338,11 +338,11 @@
+--------------+-------------------------------------------------+------+--------+-------+---------------------------------------------------------------------+
=======================
➡ OptimismMintableTokenFactory
➡ OptimismMintableERC20Factory
=======================
+--------+---------+------+--------+-------+-----------------------------------------------------------------------------------+
| Name | Type | Slot | Offset | Bytes | Contract |
+==============================================================================================================================+
| bridge | address | 0 | 0 | 20 | contracts/universal/OptimismMintableTokenFactory.sol:OptimismMintableTokenFactory |
| bridge | address | 0 | 0 | 20 | contracts/universal/OptimismMintableERC20Factory.sol:OptimismMintableERC20Factory |
+--------+---------+------+--------+-------+-----------------------------------------------------------------------------------+
......@@ -7,7 +7,7 @@ import { L2OutputOracle } from "../L1/L2OutputOracle.sol";
import { L2ToL1MessagePasser } from "../L2/L2ToL1MessagePasser.sol";
import { L1StandardBridge } from "../L1/L1StandardBridge.sol";
import { L2StandardBridge } from "../L2/L2StandardBridge.sol";
import { OptimismMintableTokenFactory } from "../universal/OptimismMintableTokenFactory.sol";
import { OptimismMintableERC20Factory } from "../universal/OptimismMintableERC20Factory.sol";
import { OptimismMintableERC20 } from "../universal/OptimismMintableERC20.sol";
import { OptimismPortal } from "../L1/OptimismPortal.sol";
import { L2ToL1MessagePasser } from "../L2/L2ToL1MessagePasser.sol";
......@@ -223,8 +223,8 @@ contract Messenger_Initializer is L2OutputOracle_Initializer {
contract Bridge_Initializer is Messenger_Initializer {
L1StandardBridge L1Bridge;
L2StandardBridge L2Bridge;
OptimismMintableTokenFactory L2TokenFactory;
OptimismMintableTokenFactory L1TokenFactory;
OptimismMintableERC20Factory L2TokenFactory;
OptimismMintableERC20Factory L1TokenFactory;
ERC20 L1Token;
OptimismMintableERC20 L2Token;
ERC20 NativeL2Token;
......@@ -364,9 +364,9 @@ contract Bridge_Initializer is Messenger_Initializer {
L2Bridge.initialize(payable(address(L1Bridge)));
// Set up the L2 mintable token factory
OptimismMintableTokenFactory factory = new OptimismMintableTokenFactory();
OptimismMintableERC20Factory factory = new OptimismMintableERC20Factory();
vm.etch(PredeployAddresses.L2_STANDARD_TOKEN_FACTORY, address(factory).code);
L2TokenFactory = OptimismMintableTokenFactory(
L2TokenFactory = OptimismMintableERC20Factory(
PredeployAddresses.L2_STANDARD_TOKEN_FACTORY
);
L2TokenFactory.initialize(PredeployAddresses.L2_STANDARD_BRIDGE);
......@@ -385,7 +385,7 @@ contract Bridge_Initializer is Messenger_Initializer {
);
NativeL2Token = new ERC20("Native L2 Token", "L2T");
L1TokenFactory = new OptimismMintableTokenFactory();
L1TokenFactory = new OptimismMintableERC20Factory();
L1TokenFactory.initialize(address(L1Bridge));
RemoteL1Token = OptimismMintableERC20(
......
......@@ -6,7 +6,7 @@ import { LibRLP } from "./RLP.t.sol";
contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
event StandardL2TokenCreated(address indexed remoteToken, address indexed localToken);
event OptimismMintableTokenCreated(
event OptimismMintableERC20Created(
address indexed localToken,
address indexed remoteToken,
address deployer
......@@ -17,7 +17,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
}
function test_initializeShouldRevert() external {
vm.expectRevert("OptimismMintableTokenFactory: already initialized");
vm.expectRevert("OptimismMintableERC20Factory: already initialized");
L2TokenFactory.initialize(address(L1Bridge));
}
......@@ -36,7 +36,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
);
vm.expectEmit(true, true, true, true);
emit OptimismMintableTokenCreated(
emit OptimismMintableERC20Created(
remote,
local,
alice
......@@ -61,7 +61,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
);
vm.expectEmit(true, true, true, true);
emit OptimismMintableTokenCreated(
emit OptimismMintableERC20Created(
remote,
local,
alice
......@@ -73,7 +73,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
function test_createStandardL2TokenShouldRevertIfRemoteIsZero() external {
address remote = address(0);
vm.expectRevert("OptimismMintableTokenFactory: must provide remote token address");
vm.expectRevert("OptimismMintableERC20Factory: must provide remote token address");
L2TokenFactory.createStandardL2Token(remote, "Beep", "BOOP");
}
}
......@@ -8,13 +8,13 @@ import { PredeployAddresses } from "../libraries/PredeployAddresses.sol";
/**
* @custom:proxied
* @custom:predeployed 0x4200000000000000000000000000000000000012
* @title OptimismMintableTokenFactory
* @notice OptimismMintableTokenFactory is a factory contract that generates OptimismMintableERC20
* @title OptimismMintableERC20Factory
* @notice OptimismMintableERC20Factory is a factory contract that generates OptimismMintableERC20
* contracts on the network it's deployed to. Simplifies the deployment process for users
* who may be less familiar with deploying smart contracts. Designed to be backwards
* compatible with the older StandardL2ERC20Factory contract.
*/
contract OptimismMintableTokenFactory {
contract OptimismMintableERC20Factory {
/**
* @custom:legacy
* @notice Emitted whenever a new OptimismMintableERC20 is created. Legacy version of the newer
......@@ -32,7 +32,7 @@ contract OptimismMintableTokenFactory {
* @param remoteToken Address of the corresponding token on the remote chain.
* @param deployer Address of the account that deployed the token.
*/
event OptimismMintableTokenCreated(
event OptimismMintableERC20Created(
address indexed localToken,
address indexed remoteToken,
address deployer
......@@ -49,11 +49,12 @@ contract OptimismMintableTokenFactory {
* @param _bridge Address of the StandardBridge on this chain.
*/
function initialize(address _bridge) public {
require(bridge == address(0), "OptimismMintableTokenFactory: already initialized");
require(bridge == address(0), "OptimismMintableERC20Factory: already initialized");
bridge = _bridge;
}
/**
* @custom:legacy
* @notice Creates an instance of the OptimismMintableERC20 contract. Legacy version of the
* newer createOptimismMintableERC20 function, which has a more intuitive name.
*
......@@ -68,14 +69,31 @@ contract OptimismMintableTokenFactory {
string memory _name,
string memory _symbol
) external returns (address) {
return createOptimismMintableERC20(_remoteToken, _name, _symbol);
}
/**
* @notice Creates an instance of the OptimismMintableERC20 contract.
*
* @param _remoteToken Address of the token on the remote chain.
* @param _name ERC20 name.
* @param _symbol ERC20 symbol.
*
* @return Address of the newly created token.
*/
function createOptimismMintableERC20(
address _remoteToken,
string memory _name,
string memory _symbol
) public returns (address) {
require(
_remoteToken != address(0),
"OptimismMintableTokenFactory: must provide remote token address"
"OptimismMintableERC20Factory: must provide remote token address"
);
require(
bridge != address(0),
"OptimismMintableTokenFactory: must initialize contract first"
"OptimismMintableERC20Factory: must initialize contract first"
);
OptimismMintableERC20 localToken = new OptimismMintableERC20(
......@@ -87,7 +105,7 @@ contract OptimismMintableTokenFactory {
// Emit the old event too for legacy support.
emit StandardL2TokenCreated(_remoteToken, address(localToken));
emit OptimismMintableTokenCreated(_remoteToken, address(localToken), msg.sender);
emit OptimismMintableERC20Created(_remoteToken, address(localToken), msg.sender);
return address(localToken);
}
......
......@@ -9,7 +9,7 @@ const deployFn: DeployFunction = async (hre) => {
const { deployer } = await hre.getNamedAccounts()
const { deployConfig } = hre
await deploy('OptimismMintableTokenFactoryProxy', {
await deploy('OptimismMintableERC20FactoryProxy', {
contract: 'Proxy',
from: deployer,
args: [deployer],
......@@ -17,37 +17,37 @@ const deployFn: DeployFunction = async (hre) => {
waitConfirmations: deployConfig.deploymentWaitConfirmations,
})
await deploy('OptimismMintableTokenFactory', {
await deploy('OptimismMintableERC20Factory', {
from: deployer,
args: [],
log: true,
waitConfirmations: deployConfig.deploymentWaitConfirmations,
})
const factory = await hre.deployments.get('OptimismMintableTokenFactory')
const factory = await hre.deployments.get('OptimismMintableERC20Factory')
const bridge = await hre.deployments.get('L1StandardBridgeProxy')
const proxy = await hre.deployments.get('OptimismMintableTokenFactoryProxy')
const proxy = await hre.deployments.get('OptimismMintableERC20FactoryProxy')
const Proxy = await hre.ethers.getContractAt('Proxy', proxy.address)
const OptimismMintableTokenFactory = await hre.ethers.getContractAt(
'OptimismMintableTokenFactory',
const OptimismMintableERC20Factory = await hre.ethers.getContractAt(
'OptimismMintableERC20Factory',
proxy.address
)
const upgradeTx = await Proxy.upgradeToAndCall(
factory.address,
OptimismMintableTokenFactory.interface.encodeFunctionData(
OptimismMintableERC20Factory.interface.encodeFunctionData(
'initialize(address)',
[bridge.address]
)
)
await upgradeTx.wait()
if (bridge.address !== (await OptimismMintableTokenFactory.bridge())) {
if (bridge.address !== (await OptimismMintableERC20Factory.bridge())) {
throw new Error('bridge misconfigured')
}
}
deployFn.tags = ['OptimismMintableTokenFactory']
deployFn.tags = ['OptimismMintableERC20Factory']
export default deployFn
......@@ -28,7 +28,7 @@ contracts=(
Proxy
L1ChugSplashProxy
OptimismMintableERC20
OptimismMintableTokenFactory
OptimismMintableERC20Factory
)
dir=$(dirname "$0")
......
......@@ -13,7 +13,7 @@ export const predeploys = {
GasPriceOracle: '0x420000000000000000000000000000000000000F',
L2StandardBridge: '0x4200000000000000000000000000000000000010',
SequencerFeeVault: '0x4200000000000000000000000000000000000011',
OptimismMintableTokenFactory: '0x4200000000000000000000000000000000000012',
OptimismMintableERC20Factory: '0x4200000000000000000000000000000000000012',
L1BlockNumber: '0x4200000000000000000000000000000000000013',
L1Block: '0x4200000000000000000000000000000000000015',
LegacyERC20ETH: '0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000',
......
......@@ -102,7 +102,7 @@ task('genesis-l2', 'create a genesis config')
SequencerFeeVault: {
l1FeeWallet: ethers.constants.AddressZero,
},
OptimismMintableTokenFactory: {
OptimismMintableERC20Factory: {
bridge: ethers.constants.AddressZero,
},
L1Block: {
......
......@@ -45,7 +45,7 @@ interface StandardBridge {
The `bridgeERC20` function is used to send a token from one domain to another
domain. An `OptimismMintableERC20` token contract must exist on the remote
domain to be able to deposit tokens to that domain. One of these tokens can be
deployed using the `OptimismMintableTokenFactory` contract.
deployed using the `OptimismMintableERC20Factory` contract.
## Upgradability
......
......@@ -13,7 +13,7 @@
- [L2CrossDomainMessenger](#l2crossdomainmessenger)
- [L2StandardBridge](#l2standardbridge)
- [SequencerFeeVault](#sequencerfeevault)
- [OptimismMintableTokenFactory](#optimismmintabletokenfactory)
- [OptimismMintableERC20Factory](#OptimismMintableERC20Factory)
- [L1BlockNumber](#l1blocknumber)
- [OVM\_GasPriceOracle](#ovm_gaspriceoracle)
- [Reserved System Address 1](#reserved-system-address-1)
......@@ -47,7 +47,7 @@ or `Bedrock`. Deprecated contracts should not be used.
| L2CrossDomainMessenger | 0x4200000000000000000000000000000000000007 | Legacy | No |
| L2StandardBridge | 0x4200000000000000000000000000000000000010 | Legacy | No |
| SequencerFeeVault | 0x4200000000000000000000000000000000000011 | Legacy | No |
| OptimismMintableTokenFactory | 0x4200000000000000000000000000000000000012 | Legacy | No |
| OptimismMintableERC20Factory | 0x4200000000000000000000000000000000000012 | Legacy | No |
| L1BlockNumber | 0x4200000000000000000000000000000000000013 | Legacy | Yes |
| OVM\_GasPriceOracle | 0x420000000000000000000000000000000000000F | Legacy | No |
| Reserved System Address 1 | 0x4200000000000000000000000000000000000014 | Legacy | No |
......@@ -230,9 +230,9 @@ interface SequencerFeeVault {
}
```
## OptimismMintableTokenFactory
## OptimismMintableERC20Factory
The `OptimismMintableTokenFactory` can be used to create an ERC20 token contract
The `OptimismMintableERC20Factory` can be used to create an ERC20 token contract
on a remote domain that maps to an ERC20 token contract on the local domain
where tokens can be deposited to the remote domain. It deploys an
`OptimismMintableERC20` which has the interface that works with the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment