UUPSUpgradeable.sol 1.0 KB

1234567891011121314151617181920212223242526
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../ERC1967/ERC1967Upgrade.sol";
  4. /**
  5. * @dev Base contract for building openzeppelin-upgrades compatible implementations for the {ERC1967Proxy}. It includes
  6. * publicly available upgrade functions that are called by the plugin and by the secure upgrade mechanism to verify
  7. * continuation of the upgradability.
  8. *
  9. * The {_authorizeUpgrade} function MUST be overridden to include access restriction to the upgrade mechanism.
  10. */
  11. abstract contract UUPSUpgradeable is ERC1967Upgrade {
  12. function upgradeTo(address newImplementation) external virtual {
  13. _authorizeUpgrade(newImplementation);
  14. _upgradeToAndCallSecure(newImplementation, bytes(""), false);
  15. }
  16. function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual {
  17. _authorizeUpgrade(newImplementation);
  18. _upgradeToAndCallSecure(newImplementation, data, true);
  19. }
  20. function _authorizeUpgrade(address newImplementation) internal virtual;
  21. }