-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: modify OptimismMintableERC20Factory for convert #17
Changes from 7 commits
5542ee9
ef1785f
a6b9fcb
dcae6b0
ce50ea8
90d1e7d
8209d4b
f8e736e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ pragma solidity 0.8.15; | |
import { OptimismMintableERC20 } from "src/universal/OptimismMintableERC20.sol"; | ||
import { ISemver } from "src/universal/ISemver.sol"; | ||
import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol"; | ||
import { IOptimismERC20Factory } from "src/L2/IOptimismERC20Factory.sol"; | ||
|
||
/// @custom:proxied | ||
/// @custom:predeployed 0x4200000000000000000000000000000000000012 | ||
|
@@ -12,7 +13,7 @@ import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable | |
/// 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 OptimismMintableERC20Factory is ISemver, Initializable { | ||
contract OptimismMintableERC20Factory is ISemver, Initializable, IOptimismERC20Factory { | ||
/// @custom:spacer OptimismMintableERC20Factory's initializer slot spacing | ||
/// @notice Spacer to avoid packing into the initializer slot | ||
bytes30 private spacer_0_2_30; | ||
|
@@ -21,10 +22,14 @@ contract OptimismMintableERC20Factory is ISemver, Initializable { | |
/// @custom:network-specific | ||
address public bridge; | ||
|
||
/// @notice Mapping of local token address to remote token address. | ||
/// This is used to keep track of the token deployments. | ||
mapping(address => address) public deployments; | ||
|
||
/// @notice Reserve extra slots in the storage layout for future upgrades. | ||
/// A gap size of 49 was chosen here, so that the first slot used in a child contract | ||
/// would be 1 plus a multiple of 50. | ||
uint256[49] private __gap; | ||
/// A gap size of 48 was chosen here, so that the first slot used in a child contract | ||
/// would be a multiple of 50. | ||
uint256[48] private __gap; | ||
|
||
/// @custom:legacy | ||
/// @notice Emitted whenever a new OptimismMintableERC20 is created. Legacy version of the newer | ||
|
@@ -43,8 +48,8 @@ contract OptimismMintableERC20Factory is ISemver, Initializable { | |
/// the OptimismMintableERC20 token contract since this contract | ||
/// is responsible for deploying OptimismMintableERC20 contracts. | ||
/// @notice Semantic version. | ||
/// @custom:semver 1.9.0 | ||
string public constant version = "1.9.0"; | ||
/// @custom:semver 1.10.0 | ||
string public constant version = "1.10.0"; | ||
|
||
/// @notice Constructs the OptimismMintableERC20Factory contract. | ||
constructor() { | ||
|
@@ -104,29 +109,29 @@ contract OptimismMintableERC20Factory is ISemver, Initializable { | |
/// @param _name ERC20 name. | ||
/// @param _symbol ERC20 symbol. | ||
/// @param _decimals ERC20 decimals | ||
/// @return Address of the newly created token. | ||
/// @return _localToken Address of the newly created token. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure if there is a convention, but they dont use underscore for localToken in their current version. |
||
function createOptimismMintableERC20WithDecimals( | ||
address _remoteToken, | ||
string memory _name, | ||
string memory _symbol, | ||
uint8 _decimals | ||
) | ||
public | ||
returns (address) | ||
returns (address _localToken) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They use returns (address) instead of declaring the variable here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok we can rollback it to make the less changes possible |
||
{ | ||
require(_remoteToken != address(0), "OptimismMintableERC20Factory: must provide remote token address"); | ||
|
||
bytes32 salt = keccak256(abi.encode(_remoteToken, _name, _symbol, _decimals)); | ||
address localToken = | ||
address(new OptimismMintableERC20{ salt: salt }(bridge, _remoteToken, _name, _symbol, _decimals)); | ||
|
||
_localToken = address(new OptimismMintableERC20{ salt: salt }(bridge, _remoteToken, _name, _symbol, _decimals)); | ||
|
||
deployments[_localToken] = _remoteToken; | ||
|
||
// Emit the old event too for legacy support. | ||
emit StandardL2TokenCreated(_remoteToken, localToken); | ||
emit StandardL2TokenCreated(_remoteToken, _localToken); | ||
|
||
// Emit the updated event. The arguments here differ from the legacy event, but | ||
// are consistent with the ordering used in StandardBridge events. | ||
emit OptimismMintableERC20Created(localToken, _remoteToken, msg.sender); | ||
|
||
return localToken; | ||
emit OptimismMintableERC20Created(_localToken, _remoteToken, msg.sender); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question here with the returned arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Newer contracts like
L2ToL2CrossDomainMessenger
have it like that, so not fixing for now unless it is asked for