Commit 49d33b08 authored by smartcontracts's avatar smartcontracts Committed by GitHub

fix(ctb): universal contract comments/errs/events (#2940)

Standardizes the comments, errors, and events for all contracts within
the /universal folder.
parent 297af083
---
'@eth-optimism/contracts-bedrock': patch
---
Standardizes comments, errors, and events for contracts in the /universal package
...@@ -103,18 +103,18 @@ OVM_ETH_Test:test_transfer() (gas: 10726) ...@@ -103,18 +103,18 @@ OVM_ETH_Test:test_transfer() (gas: 10726)
OVM_ETH_Test:test_transferFrom() (gas: 13008) OVM_ETH_Test:test_transferFrom() (gas: 13008)
OptimismMintableERC20_Test:test_bridge() (gas: 9785) OptimismMintableERC20_Test:test_bridge() (gas: 9785)
OptimismMintableERC20_Test:test_burn() (gas: 52791) OptimismMintableERC20_Test:test_burn() (gas: 52791)
OptimismMintableERC20_Test:test_burnRevertsFromNotBridge() (gas: 13211) OptimismMintableERC20_Test:test_burnRevertsFromNotBridge() (gas: 13241)
OptimismMintableERC20_Test:test_erc165_supportsInterface() (gas: 7828) OptimismMintableERC20_Test:test_erc165_supportsInterface() (gas: 7828)
OptimismMintableERC20_Test:test_l1Token() (gas: 9779) OptimismMintableERC20_Test:test_l1Token() (gas: 9779)
OptimismMintableERC20_Test:test_l2Bridge() (gas: 9790) OptimismMintableERC20_Test:test_l2Bridge() (gas: 9790)
OptimismMintableERC20_Test:test_mint() (gas: 65687) OptimismMintableERC20_Test:test_mint() (gas: 65687)
OptimismMintableERC20_Test:test_mintRevertsFromNotBridge() (gas: 13235) OptimismMintableERC20_Test:test_mintRevertsFromNotBridge() (gas: 13265)
OptimismMintableERC20_Test:test_remoteToken() (gas: 9784) OptimismMintableERC20_Test:test_remoteToken() (gas: 9784)
OptimismMintableTokenFactory_Test:test_bridge() (gas: 9707) OptimismMintableTokenFactory_Test:test_bridge() (gas: 9707)
OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1100125) OptimismMintableTokenFactory_Test:test_createStandardL2Token() (gas: 1115359)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2181161) OptimismMintableTokenFactory_Test:test_createStandardL2TokenSameTwice() (gas: 2211629)
OptimismMintableTokenFactory_Test:test_createStandardL2TokenShouldRevertIfRemoteIsZero() (gas: 9374) OptimismMintableTokenFactory_Test:test_createStandardL2TokenShouldRevertIfRemoteIsZero() (gas: 9407)
OptimismMintableTokenFactory_Test:test_initializeShouldRevert() (gas: 12696) OptimismMintableTokenFactory_Test:test_initializeShouldRevert() (gas: 12732)
OptimismPortalUpgradeable_Test:test_cannotInitImpl() (gas: 10936) OptimismPortalUpgradeable_Test:test_cannotInitImpl() (gas: 10936)
OptimismPortalUpgradeable_Test:test_cannotInitProxy() (gas: 15934) OptimismPortalUpgradeable_Test:test_cannotInitProxy() (gas: 15934)
OptimismPortalUpgradeable_Test:test_initValuesOnProxy() (gas: 16034) OptimismPortalUpgradeable_Test:test_initValuesOnProxy() (gas: 16034)
...@@ -137,12 +137,12 @@ OptimismPortal_Test:test_simple_isOutputFinalized() (gas: 23877) ...@@ -137,12 +137,12 @@ OptimismPortal_Test:test_simple_isOutputFinalized() (gas: 23877)
Proxy_Test:test_clashingFunctionSignatures() (gas: 101427) Proxy_Test:test_clashingFunctionSignatures() (gas: 101427)
Proxy_Test:test_implementationKey() (gas: 20942) Proxy_Test:test_implementationKey() (gas: 20942)
Proxy_Test:test_implementationProxyCallIfNotAdmin() (gas: 30021) Proxy_Test:test_implementationProxyCallIfNotAdmin() (gas: 30021)
Proxy_Test:test_implementationZeroAddress() (gas: 48006) Proxy_Test:test_implementationZeroAddress() (gas: 48007)
Proxy_Test:test_itDelegatesToTheImplementation() (gas: 45173) Proxy_Test:test_itDelegatesToTheImplementation() (gas: 45173)
Proxy_Test:test_ownerKey() (gas: 19113) Proxy_Test:test_ownerKey() (gas: 19113)
Proxy_Test:test_ownerProxyCallIfNotAdmin() (gas: 34733) Proxy_Test:test_ownerProxyCallIfNotAdmin() (gas: 34733)
Proxy_Test:test_payableUpgradeToAndCall() (gas: 53887) Proxy_Test:test_payableUpgradeToAndCall() (gas: 53887)
Proxy_Test:test_revertUpgradeToAndCall() (gas: 104501) Proxy_Test:test_revertUpgradeToAndCall() (gas: 104654)
Proxy_Test:test_upgradeToAndCall() (gas: 125238) Proxy_Test:test_upgradeToAndCall() (gas: 125238)
Proxy_Test:test_zeroAddressCaller() (gas: 14758) Proxy_Test:test_zeroAddressCaller() (gas: 14758)
ProxyAdmin_Test:test_chugsplashChangeProxyAdmin() (gas: 35647) ProxyAdmin_Test:test_chugsplashChangeProxyAdmin() (gas: 35647)
...@@ -155,7 +155,7 @@ ProxyAdmin_Test:test_delegateResolvedGetProxyAdmin() (gas: 17685) ...@@ -155,7 +155,7 @@ ProxyAdmin_Test:test_delegateResolvedGetProxyAdmin() (gas: 17685)
ProxyAdmin_Test:test_delegateResolvedGetProxyImplementation() (gas: 62016) ProxyAdmin_Test:test_delegateResolvedGetProxyImplementation() (gas: 62016)
ProxyAdmin_Test:test_delegateResolvedUpgrade() (gas: 58422) ProxyAdmin_Test:test_delegateResolvedUpgrade() (gas: 58422)
ProxyAdmin_Test:test_delegateResolvedUpgradeAndCall() (gas: 97948) ProxyAdmin_Test:test_delegateResolvedUpgradeAndCall() (gas: 97948)
ProxyAdmin_Test:test_erc1967ChangeProxyAdmin() (gas: 33862) ProxyAdmin_Test:test_erc1967ChangeProxyAdmin() (gas: 33863)
ProxyAdmin_Test:test_erc1967GetProxyAdmin() (gas: 15672) ProxyAdmin_Test:test_erc1967GetProxyAdmin() (gas: 15672)
ProxyAdmin_Test:test_erc1967GetProxyImplementation() (gas: 52124) ProxyAdmin_Test:test_erc1967GetProxyImplementation() (gas: 52124)
ProxyAdmin_Test:test_erc1967Upgrade() (gas: 50036) ProxyAdmin_Test:test_erc1967Upgrade() (gas: 50036)
......
...@@ -41,7 +41,7 @@ contract OptimismMintableERC20_Test is Bridge_Initializer { ...@@ -41,7 +41,7 @@ contract OptimismMintableERC20_Test is Bridge_Initializer {
function test_mintRevertsFromNotBridge() external { function test_mintRevertsFromNotBridge() external {
// NOT the bridge // NOT the bridge
vm.expectRevert("Only L2 Bridge can mint and burn"); vm.expectRevert("OptimismMintableERC20: only bridge can mint and burn");
vm.prank(address(alice)); vm.prank(address(alice));
L2Token.mint(alice, 100); L2Token.mint(alice, 100);
} }
...@@ -61,7 +61,7 @@ contract OptimismMintableERC20_Test is Bridge_Initializer { ...@@ -61,7 +61,7 @@ contract OptimismMintableERC20_Test is Bridge_Initializer {
function test_burnRevertsFromNotBridge() external { function test_burnRevertsFromNotBridge() external {
// NOT the bridge // NOT the bridge
vm.expectRevert("Only L2 Bridge can mint and burn"); vm.expectRevert("OptimismMintableERC20: only bridge can mint and burn");
vm.prank(address(alice)); vm.prank(address(alice));
L2Token.burn(alice, 100); L2Token.burn(alice, 100);
} }
......
...@@ -17,7 +17,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer { ...@@ -17,7 +17,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
} }
function test_initializeShouldRevert() external { function test_initializeShouldRevert() external {
vm.expectRevert("Already initialized."); vm.expectRevert("OptimismMintableTokenFactory: already initialized");
L2TokenFactory.initialize(address(L1Bridge)); L2TokenFactory.initialize(address(L1Bridge));
} }
...@@ -73,7 +73,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer { ...@@ -73,7 +73,7 @@ contract OptimismMintableTokenFactory_Test is Bridge_Initializer {
function test_createStandardL2TokenShouldRevertIfRemoteIsZero() external { function test_createStandardL2TokenShouldRevertIfRemoteIsZero() external {
address remote = address(0); address remote = address(0);
vm.expectRevert("Must provide L1 token address"); vm.expectRevert("OptimismMintableTokenFactory: must provide remote token address");
L2TokenFactory.createStandardL2Token(remote, "Beep", "BOOP"); L2TokenFactory.createStandardL2Token(remote, "Beep", "BOOP");
} }
} }
...@@ -184,7 +184,7 @@ contract Proxy_Test is Test { ...@@ -184,7 +184,7 @@ contract Proxy_Test is Test {
// Set the new SimpleStorage as the implementation // Set the new SimpleStorage as the implementation
// and call. This reverts because the calldata doesn't // and call. This reverts because the calldata doesn't
// match a function on the implementation. // match a function on the implementation.
vm.expectRevert(); vm.expectRevert("Proxy: delegatecall to new implementation contract failed");
vm.prank(alice); vm.prank(alice);
proxy.upgradeToAndCall( proxy.upgradeToAndCall(
address(simpleStorage), address(simpleStorage),
......
...@@ -6,32 +6,44 @@ import "./SupportedInterfaces.sol"; ...@@ -6,32 +6,44 @@ import "./SupportedInterfaces.sol";
/** /**
* @title OptimismMintableERC20 * @title OptimismMintableERC20
* This contract represents the remote representation * @notice OptimismMintableERC20 is a standard extension of the base ERC20 token contract designed
* of an ERC20 token. It is linked to the address of * to allow the StandardBridge contracts to mint and burn tokens. This makes it possible to
* a token in another domain and tokens can be locked * use an OptimismMintablERC20 as the L2 representation of an L1 token, or vice-versa.
* in the StandardBridge which will mint tokens in the * Designed to be backwards compatible with the older StandardL2ERC20 token which was only
* other domain. * meant for use on L2.
*/ */
contract OptimismMintableERC20 is ERC20 { contract OptimismMintableERC20 is ERC20 {
event Mint(address indexed _account, uint256 _amount); /**
event Burn(address indexed _account, uint256 _amount); * @notice Emitted whenever tokens are minted for an account.
*
* @param account Address of the account tokens are being minted for.
* @param amount Amount of tokens minted.
*/
event Mint(address indexed account, uint256 amount);
/** /**
* @notice The address of the token in the remote domain * @notice Emitted whenever tokens are burned from an account.
*
* @param account Address of the account tokens are being burned from.
* @param amount Amount of tokens burned.
*/
event Burn(address indexed account, uint256 amount);
/**
* @notice Address of the corresponding version of this token on the remote chain.
*/ */
address public remoteToken; address public remoteToken;
/** /**
* @notice The address of the bridge responsible for * @notice Address of the StandardBridge on this network.
* minting. It is in the same domain.
*/ */
address public bridge; address public bridge;
/** /**
* @param _bridge Address of the L2 standard bridge. * @param _bridge Address of the L2 standard bridge.
* @param _remoteToken Address of the corresponding L1 token. * @param _remoteToken Address of the corresponding L1 token.
* @param _name ERC20 name. * @param _name ERC20 name.
* @param _symbol ERC20 symbol. * @param _symbol ERC20 symbol.
*/ */
constructor( constructor(
address _bridge, address _bridge,
...@@ -44,17 +56,16 @@ contract OptimismMintableERC20 is ERC20 { ...@@ -44,17 +56,16 @@ contract OptimismMintableERC20 is ERC20 {
} }
/** /**
* @notice Returns the corresponding L1 token address. * @custom:legacy
* This is a legacy function and wraps the remoteToken value. * @notice Legacy getter for the remote token. Use remoteToken going forward.
*/ */
function l1Token() public view returns (address) { function l1Token() public view returns (address) {
return remoteToken; return remoteToken;
} }
/** /**
* @notice The address of the bridge contract * @custom:legacy
* responsible for minting tokens. This is a legacy * @notice Legacy getter for the bridge. Use bridge going forward.
* getter function
*/ */
function l2Bridge() public view returns (address) { function l2Bridge() public view returns (address) {
return bridge; return bridge;
...@@ -64,15 +75,18 @@ contract OptimismMintableERC20 is ERC20 { ...@@ -64,15 +75,18 @@ contract OptimismMintableERC20 is ERC20 {
* @notice A modifier that only allows the bridge to call * @notice A modifier that only allows the bridge to call
*/ */
modifier onlyBridge() { modifier onlyBridge() {
require(msg.sender == bridge, "Only L2 Bridge can mint and burn"); require(msg.sender == bridge, "OptimismMintableERC20: only bridge can mint and burn");
_; _;
} }
/** /**
* @notice ERC165 * @notice ERC165 interface check function.
*
* @param _interfaceId Interface ID to check.
*
* @return Whether or not the interface is supported by this contract.
*/ */
// slither-disable-next-line external-function function supportsInterface(bytes4 _interfaceId) external pure returns (bool) {
function supportsInterface(bytes4 _interfaceId) public pure returns (bool) {
bytes4 iface1 = type(IERC165).interfaceId; bytes4 iface1 = type(IERC165).interfaceId;
bytes4 iface2 = type(IL1Token).interfaceId; bytes4 iface2 = type(IL1Token).interfaceId;
bytes4 iface3 = type(IRemoteToken).interfaceId; bytes4 iface3 = type(IRemoteToken).interfaceId;
...@@ -80,22 +94,24 @@ contract OptimismMintableERC20 is ERC20 { ...@@ -80,22 +94,24 @@ contract OptimismMintableERC20 is ERC20 {
} }
/** /**
* @notice The bridge can mint tokens * @notice Allows the StandardBridge on this network to mint tokens.
*
* @param _to Address to mint tokens to.
* @param _amount Amount of tokens to mint.
*/ */
// slither-disable-next-line external-function function mint(address _to, uint256 _amount) external virtual onlyBridge {
function mint(address _to, uint256 _amount) public virtual onlyBridge {
_mint(_to, _amount); _mint(_to, _amount);
emit Mint(_to, _amount); emit Mint(_to, _amount);
} }
/** /**
* @notice The bridge can burn tokens * @notice Allows the StandardBridge on this network to burn tokens.
*
* @param _from Address to burn tokens from.
* @param _amount Amount of tokens to burn.
*/ */
// slither-disable-next-line external-function function burn(address _from, uint256 _amount) external virtual onlyBridge {
function burn(address _from, uint256 _amount) public virtual onlyBridge {
_burn(_from, _amount); _burn(_from, _amount);
emit Burn(_from, _amount); emit Burn(_from, _amount);
} }
} }
...@@ -6,50 +6,77 @@ import { OptimismMintableERC20 } from "../universal/OptimismMintableERC20.sol"; ...@@ -6,50 +6,77 @@ import { OptimismMintableERC20 } from "../universal/OptimismMintableERC20.sol";
import { Lib_PredeployAddresses } from "../libraries/Lib_PredeployAddresses.sol"; import { Lib_PredeployAddresses } from "../libraries/Lib_PredeployAddresses.sol";
/** /**
* @custom:proxied
* @custom:predeployed 0x4200000000000000000000000000000000000012
* @title OptimismMintableTokenFactory * @title OptimismMintableTokenFactory
* @dev Factory contract for creating standard remote token representations of * @notice OptimismMintableTokenFactory is a factory contract that generates OptimismMintableERC20
* local ERC20s. This can be used to bridge native L1 ERC20s to L2 or native L2 * contracts on the network it's deployed to. Simplifies the deployment process for users
* ERC20s to L1. The tokens created through this factory are meant to operate * who may be less familiar with deploying smart contracts. Designed to be backwards
* with the StandardBridge contract for deposits/withdrawals. * compatible with the older StandardL2ERC20Factory contract.
* This contract is a predeploy on L2 at 0x4200000000000000000000000000000000000012
* TODO: deploy to a deterministic address on L1 networks?
* TODO: should this be extended for L1/L2 with hardcoded values in
* the base contract's initialize?
*/ */
contract OptimismMintableTokenFactory { contract OptimismMintableTokenFactory {
event StandardL2TokenCreated(address indexed _remoteToken, address indexed _localToken); /**
* @custom:legacy
* @notice Emitted whenever a new OptimismMintableERC20 is created. Legacy version of the newer
* OptimismMintableERC20Created event. We recommend relying on that event instead.
*
* @param remoteToken Address of the token on the remote chain.
* @param localToken Address of the created token on the local chain.
*/
event StandardL2TokenCreated(address indexed remoteToken, address indexed localToken);
/**
* @notice Emitted whenever a new OptimismMintableERC20 is created.
*
* @param localToken Address of the created token on the local chain.
* @param remoteToken Address of the corresponding token on the remote chain.
* @param deployer Address of the account that deployed the token.
*/
event OptimismMintableTokenCreated( event OptimismMintableTokenCreated(
address indexed _localToken, address indexed localToken,
address indexed _remoteToken, address indexed remoteToken,
address _deployer address deployer
); );
/**
* @notice Address of the StandardBridge on this chain.
*/
address public bridge; address public bridge;
/** /**
* @dev Initialize the factory * @notice Initializer.
* On L2 _bridge should be Lib_PredeployAddresses.L2_STANDARD_BRIDGE, *
* On L1 _bridge should be the L1StandardBridge * @param _bridge Address of the StandardBridge on this chain.
*/ */
function initialize(address _bridge) public { function initialize(address _bridge) public {
require(bridge == address(0), "Already initialized."); require(bridge == address(0), "OptimismMintableTokenFactory: already initialized");
bridge = _bridge; bridge = _bridge;
} }
/** /**
* @dev Creates an instance of the standard ERC20 token on L2. * @notice Creates an instance of the OptimismMintableERC20 contract. Legacy version of the
* @param _remoteToken Address of the corresponding L1 token. * newer createOptimismMintableERC20 function, which has a more intuitive name.
* @param _name ERC20 name. *
* @param _symbol ERC20 symbol. * @param _remoteToken Address of the token on the remote chain.
* @return Address of the new token. * @param _name ERC20 name.
* @param _symbol ERC20 symbol.
*
* @return Address of the newly created token.
*/ */
function createStandardL2Token( function createStandardL2Token(
address _remoteToken, address _remoteToken,
string memory _name, string memory _name,
string memory _symbol string memory _symbol
) external returns (address) { ) external returns (address) {
require(_remoteToken != address(0), "Must provide L1 token address"); require(
require(bridge != address(0), "Must initialize first"); _remoteToken != address(0),
"OptimismMintableTokenFactory: must provide remote token address"
);
require(
bridge != address(0),
"OptimismMintableTokenFactory: must initialize contract first"
);
OptimismMintableERC20 localToken = new OptimismMintableERC20( OptimismMintableERC20 localToken = new OptimismMintableERC20(
bridge, bridge,
...@@ -58,7 +85,7 @@ contract OptimismMintableTokenFactory { ...@@ -58,7 +85,7 @@ contract OptimismMintableTokenFactory {
_symbol _symbol
); );
// Legacy Purposes // Emit the old event too for legacy support.
emit StandardL2TokenCreated(_remoteToken, address(localToken)); emit StandardL2TokenCreated(_remoteToken, address(localToken));
emit OptimismMintableTokenCreated(_remoteToken, address(localToken), msg.sender); emit OptimismMintableTokenCreated(_remoteToken, address(localToken), msg.sender);
......
...@@ -3,22 +3,22 @@ pragma solidity ^0.8.9; ...@@ -3,22 +3,22 @@ pragma solidity ^0.8.9;
/** /**
* @title Proxy * @title Proxy
* @notice Proxy is a transparent proxy that passes through the call * @notice Proxy is a transparent proxy that passes through the call if the caller is the owner or
* if the caller is the owner or if the caller is `address(0)`, * if the caller is address(0), meaning that the call originated from an off-chain
* meaning that the call originated from an offchain simulation. * simulation.
*/ */
contract Proxy { contract Proxy {
/** /**
* @notice An event that is emitted each time the implementation is changed. * @notice An event that is emitted each time the implementation is changed. This event is part
* This event is part of the EIP 1967 spec. * of the EIP-1967 specification.
* *
* @param implementation The address of the implementation contract * @param implementation The address of the implementation contract
*/ */
event Upgraded(address indexed implementation); event Upgraded(address indexed implementation);
/** /**
* @notice An event that is emitted each time the owner is upgraded. * @notice An event that is emitted each time the owner is upgraded. This event is part of the
* This event is part of the EIP 1967 spec. * EIP-1967 specification.
* *
* @param previousAdmin The previous owner of the contract * @param previousAdmin The previous owner of the contract
* @param newAdmin The new owner of the contract * @param newAdmin The new owner of the contract
...@@ -40,12 +40,12 @@ contract Proxy { ...@@ -40,12 +40,12 @@ contract Proxy {
0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103; 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/** /**
* @notice set the initial owner during contract deployment. The * @notice Sets the initial admin during contract deployment. Admin address is stored at the
* owner is stored at the eip1967 owner storage slot so that * EIP-1967 admin storage slot so that accidental storage collision with the
* storage collision with the implementation is not possible. * implementation is not possible.
* *
* @param _admin Address of the initial contract owner. The owner has * @param _admin Address of the initial contract admin. Admin as the ability to access the
* the ability to access the transparent proxy interface. * transparent proxy interface.
*/ */
constructor(address _admin) { constructor(address _admin) {
_changeAdmin(_admin); _changeAdmin(_admin);
...@@ -58,11 +58,10 @@ contract Proxy { ...@@ -58,11 +58,10 @@ contract Proxy {
} }
/** /**
* @notice A modifier that reverts if not called by the owner * @notice A modifier that reverts if not called by the owner or by address(0) to allow
* or by `address(0)` to allow `eth_call` to interact * eth_call to interact with this proxy without needing to use low-level storage
* with the proxy without needing to use low level storage * inspection. We assume that nobody is able to trigger calls from address(0) during
* inspection. It is assumed that nobody controls the private * normal EVM execution.
* key for `address(0)`.
*/ */
modifier proxyCallIfNotAdmin() { modifier proxyCallIfNotAdmin() {
if (msg.sender == _getAdmin() || msg.sender == address(0)) { if (msg.sender == _getAdmin() || msg.sender == address(0)) {
...@@ -74,23 +73,21 @@ contract Proxy { ...@@ -74,23 +73,21 @@ contract Proxy {
} }
/** /**
* @notice Set the implementation contract address. The code at this * @notice Set the implementation contract address. The code at the given address will execute
* address will execute when this contract is called. * when this contract is called.
* *
* @param _implementation The address of the implementation contract * @param _implementation Address of the implementation contract.
*/ */
function upgradeTo(address _implementation) external proxyCallIfNotAdmin { function upgradeTo(address _implementation) external proxyCallIfNotAdmin {
_setImplementation(_implementation); _setImplementation(_implementation);
} }
/** /**
* @notice Set the implementation and call a function in a single * @notice Set the implementation and call a function in a single transaction. Useful to ensure
* transaction. This is useful to ensure atomic `initialize()` * atomic execution of initialization-based upgrades.
* based upgrades.
* *
* @param _implementation The address of the implementation contract * @param _implementation Address of the implementation contract.
* @param _data The calldata to delegatecall the new * @param _data Calldata to delegatecall the new implementation with.
* implementation with
*/ */
function upgradeToAndCall(address _implementation, bytes calldata _data) function upgradeToAndCall(address _implementation, bytes calldata _data)
external external
...@@ -100,7 +97,7 @@ contract Proxy { ...@@ -100,7 +97,7 @@ contract Proxy {
{ {
_setImplementation(_implementation); _setImplementation(_implementation);
(bool success, bytes memory returndata) = _implementation.delegatecall(_data); (bool success, bytes memory returndata) = _implementation.delegatecall(_data);
require(success); require(success, "Proxy: delegatecall to new implementation contract failed");
return returndata; return returndata;
} }
...@@ -146,7 +143,7 @@ contract Proxy { ...@@ -146,7 +143,7 @@ contract Proxy {
/** /**
* @notice Queries the implementation address. * @notice Queries the implementation address.
* *
* @return implementation address. * @return Implementation address.
*/ */
function _getImplementation() internal view returns (address) { function _getImplementation() internal view returns (address) {
address implementation; address implementation;
...@@ -172,7 +169,7 @@ contract Proxy { ...@@ -172,7 +169,7 @@ contract Proxy {
/** /**
* @notice Queries the owner of the proxy contract. * @notice Queries the owner of the proxy contract.
* *
* @return owner address. * @return Owner address.
*/ */
function _getAdmin() internal view returns (address) { function _getAdmin() internal view returns (address) {
address owner; address owner;
...@@ -187,7 +184,6 @@ contract Proxy { ...@@ -187,7 +184,6 @@ contract Proxy {
*/ */
function _doProxyCall() internal { function _doProxyCall() internal {
address implementation = _getImplementation(); address implementation = _getImplementation();
require(implementation != address(0), "Proxy: implementation not initialized"); require(implementation != address(0), "Proxy: implementation not initialized");
assembly { assembly {
......
...@@ -5,17 +5,17 @@ pragma solidity ^0.8.9; ...@@ -5,17 +5,17 @@ pragma solidity ^0.8.9;
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
interface IRemoteToken { interface IRemoteToken {
function mint(address _to, uint256 _amount) external virtual; function mint(address _to, uint256 _amount) external;
function burn(address _from, uint256 _amount) external virtual; function burn(address _from, uint256 _amount) external;
function remoteToken() external virtual; function remoteToken() external;
} }
interface IL1Token { interface IL1Token {
function mint(address _to, uint256 _amount) external virtual; function mint(address _to, uint256 _amount) external;
function burn(address _from, uint256 _amount) external virtual; function burn(address _from, uint256 _amount) external;
function l1Token() external virtual; function l1Token() external;
} }
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