Move UUPSUpgradeable to proxy/utils
(cherry picked from commit b9125001f0)
This commit is contained in:
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