ERC1967Proxy.sol 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. // SPDX-License-Identifier: MIT
  2. // OpenZeppelin Contracts v4.4.0-rc.0 (proxy/ERC1967/ERC1967Proxy.sol)
  3. pragma solidity ^0.8.0;
  4. import "../Proxy.sol";
  5. import "./ERC1967Upgrade.sol";
  6. /**
  7. * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an
  8. * implementation address that can be changed. This address is stored in storage in the location specified by
  9. * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the
  10. * implementation behind the proxy.
  11. */
  12. contract ERC1967Proxy is Proxy, ERC1967Upgrade {
  13. /**
  14. * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.
  15. *
  16. * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded
  17. * function call, and allows initializating the storage of the proxy like a Solidity constructor.
  18. */
  19. constructor(address _logic, bytes memory _data) payable {
  20. assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
  21. _upgradeToAndCall(_logic, _data, false);
  22. }
  23. /**
  24. * @dev Returns the current implementation address.
  25. */
  26. function _implementation() internal view virtual override returns (address impl) {
  27. return ERC1967Upgrade._getImplementation();
  28. }
  29. }