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 18, 2024
1 parent 19ef099 commit b8eeb31
Showing 1 changed file with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
// 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 "src/universal/IOptimismMintableERC20.sol";
import { ISemver } from "src/universal/ISemver.sol";

/// @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, ISemver {
contract OptimismMintableUpgradableERC20 is Initializable, IOptimismMintableERC20, ILegacyMintableERC20, ERC20Upgradeable, ISemver {
/// @notice Address of the corresponding version of this token on the remote chain.
address public immutable REMOTE_TOKEN;
/// @notice Breaking the naming convention to remain as close as possible to the non-
/// upgradable version (where this is immutable)
address public REMOTE_TOKEN;

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

/// @notice Decimals of the token
uint8 private immutable DECIMALS;
/// @notice Breaking the naming convention to remain as close as possible to the non-
/// upgradable version (where this is immutable)
uint8 private DECIMALS;

/// @notice Emitted whenever tokens are minted for an account.
/// @param account Address of the account tokens are being minted for.
Expand All @@ -42,19 +49,23 @@ contract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20,
/// @custom:semver 1.3.0
string public constant version = "1.3.0";

constructor() {
_disableInitializers();
}

/// @param _bridge Address of the L2 standard bridge.
/// @param _remoteToken Address of the corresponding L1 token.
/// @param _name ERC20 name.
/// @param _symbol ERC20 symbol.
constructor(
function initialize(
address _bridge,
address _remoteToken,
string memory _name,
string memory _symbol,
uint8 _decimals
)
ERC20(_name, _symbol)
) initializer public
{
__ERC20_init(_name, _symbol);
REMOTE_TOKEN = _remoteToken;
BRIDGE = _bridge;
DECIMALS = _decimals;
Expand Down

0 comments on commit b8eeb31

Please sign in to comment.