StorageSlotMockUpgradeable.sol 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../utils/StorageSlotUpgradeable.sol";
  4. import "../proxy/utils/Initializable.sol";
  5. contract StorageSlotMockUpgradeable is Initializable {
  6. function __StorageSlotMock_init() internal onlyInitializing {
  7. }
  8. function __StorageSlotMock_init_unchained() internal onlyInitializing {
  9. }
  10. using StorageSlotUpgradeable for bytes32;
  11. function setBoolean(bytes32 slot, bool value) public {
  12. slot.getBooleanSlot().value = value;
  13. }
  14. function setAddress(bytes32 slot, address value) public {
  15. slot.getAddressSlot().value = value;
  16. }
  17. function setBytes32(bytes32 slot, bytes32 value) public {
  18. slot.getBytes32Slot().value = value;
  19. }
  20. function setUint256(bytes32 slot, uint256 value) public {
  21. slot.getUint256Slot().value = value;
  22. }
  23. function getBoolean(bytes32 slot) public view returns (bool) {
  24. return slot.getBooleanSlot().value;
  25. }
  26. function getAddress(bytes32 slot) public view returns (address) {
  27. return slot.getAddressSlot().value;
  28. }
  29. function getBytes32(bytes32 slot) public view returns (bytes32) {
  30. return slot.getBytes32Slot().value;
  31. }
  32. function getUint256(bytes32 slot) public view returns (uint256) {
  33. return slot.getUint256Slot().value;
  34. }
  35. /**
  36. * This empty reserved space is put in place to allow future versions to add new
  37. * variables without shifting down storage in the inheritance chain.
  38. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
  39. */
  40. uint256[50] private __gap;
  41. }