Move UUPSUpgradeable to proxy/utils
This commit is contained in:
@ -3,8 +3,6 @@
|
||||
// solhint-disable-next-line compiler-version
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../../utils/Address.sol";
|
||||
|
||||
/**
|
||||
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
|
||||
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
|
||||
|
||||
26
contracts/proxy/utils/UUPSUpgradeable.sol
Normal file
26
contracts/proxy/utils/UUPSUpgradeable.sol
Normal file
@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "../ERC1967/ERC1967Upgrade.sol";
|
||||
|
||||
/**
|
||||
* @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes
|
||||
* publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify
|
||||
* continuation of the upgradability.
|
||||
*
|
||||
* The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.
|
||||
*/
|
||||
abstract contract UUPSUpgradeable is ERC1967Upgrade {
|
||||
function upgradeTo(address newImplementation) external virtual {
|
||||
_authorizeUpgrade(newImplementation);
|
||||
_upgradeToAndCallSecure(newImplementation, bytes(""), false);
|
||||
}
|
||||
|
||||
function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {
|
||||
_authorizeUpgrade(newImplementation);
|
||||
_upgradeToAndCallSecure(newImplementation, data, true);
|
||||
}
|
||||
|
||||
function _authorizeUpgrade(address newImplementation) internal virtual;
|
||||
}
|
||||
Reference in New Issue
Block a user