Skip to content

Commit

Permalink
feat: make OptimismMintableUpgradableERC20.sol upgradable
Browse files Browse the repository at this point in the history
  • Loading branch information
sander2 committed Apr 17, 2024
1 parent d890e12 commit 510485a
Showing 1 changed file with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.15;

import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { ERC20Upgradeable } from "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import { ILegacyMintableERC20, IOptimismMintableERC20 } from "./IOptimismMintableERC20.sol";
import { Semver } from "../universal/Semver.sol";

contract SimpleSemver {
function version() public view returns (string memory) {
return string(abi.encodePacked("1.0.0"));
}
}

/**
* @title OptimismMintableERC20
* @notice OptimismMintableERC20 is a standard extension of the base ERC20 token contract designed
* @title OptimismMintableUpgradableERC20
* @notice OptimismMintableUpgradableERC20 is a standard extension of the base ERC20 token contract designed
* to allow the StandardBridge contracts to mint and burn tokens. This makes it possible to
* use an OptimismMintablERC20 as the L2 representation of an L1 token, or vice-versa.
* Designed to be backwards compatible with the older StandardL2ERC20 token which was only
* meant for use on L2.
*/
contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ERC20, Semver {
contract OptimismMintableUpgradableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, Initializable, ERC20Upgradeable, SimpleSemver {
/**
* @notice Address of the corresponding version of this token on the remote chain.
* @notice Breaking the naming convention to remain as close as possible to the non-
* upgradable version (where this is immutable)
*/
address public immutable REMOTE_TOKEN;
address public REMOTE_TOKEN;

/**
* @notice Address of the StandardBridge on this network.
* @notice Breaking the naming convention to remain as close as possible to the non-
* upgradable version (where this is immutable)
*/
address public immutable BRIDGE;
address public BRIDGE;

/**
* @notice Emitted whenever tokens are minted for an account.
Expand All @@ -49,6 +59,10 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
_;
}

constructor() {
_disableInitializers();
}

/**
* @custom:semver 1.0.0
*
Expand All @@ -57,12 +71,13 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
* @param _name ERC20 name.
* @param _symbol ERC20 symbol.
*/
constructor(
function initialize(
address _bridge,
address _remoteToken,
string memory _name,
string memory _symbol
) ERC20(_name, _symbol) Semver(1, 0, 0) {
) initializer public {
__ERC20_init(_name, _symbol);
REMOTE_TOKEN = _remoteToken;
BRIDGE = _bridge;
}
Expand Down

0 comments on commit 510485a

Please sign in to comment.