StorageSlotMock.sol 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // SPDX-License-Identifier: MIT
  2. // This file was procedurally generated from scripts/generate/templates/StorageSlotMock.js.
  3. pragma solidity ^0.8.20;
  4. import {Multicall} from "../utils/Multicall.sol";
  5. import {StorageSlot} from "../utils/StorageSlot.sol";
  6. contract StorageSlotMock is Multicall {
  7. using StorageSlot for *;
  8. function setAddressSlot(bytes32 slot, address value) public {
  9. slot.getAddressSlot().value = value;
  10. }
  11. function setBooleanSlot(bytes32 slot, bool value) public {
  12. slot.getBooleanSlot().value = value;
  13. }
  14. function setBytes32Slot(bytes32 slot, bytes32 value) public {
  15. slot.getBytes32Slot().value = value;
  16. }
  17. function setUint256Slot(bytes32 slot, uint256 value) public {
  18. slot.getUint256Slot().value = value;
  19. }
  20. function setInt256Slot(bytes32 slot, int256 value) public {
  21. slot.getInt256Slot().value = value;
  22. }
  23. function getAddressSlot(bytes32 slot) public view returns (address) {
  24. return slot.getAddressSlot().value;
  25. }
  26. function getBooleanSlot(bytes32 slot) public view returns (bool) {
  27. return slot.getBooleanSlot().value;
  28. }
  29. function getBytes32Slot(bytes32 slot) public view returns (bytes32) {
  30. return slot.getBytes32Slot().value;
  31. }
  32. function getUint256Slot(bytes32 slot) public view returns (uint256) {
  33. return slot.getUint256Slot().value;
  34. }
  35. function getInt256Slot(bytes32 slot) public view returns (int256) {
  36. return slot.getInt256Slot().value;
  37. }
  38. mapping(uint256 key => string) public stringMap;
  39. function setStringSlot(bytes32 slot, string calldata value) public {
  40. slot.getStringSlot().value = value;
  41. }
  42. function setStringStorage(uint256 key, string calldata value) public {
  43. stringMap[key].getStringSlot().value = value;
  44. }
  45. function getStringSlot(bytes32 slot) public view returns (string memory) {
  46. return slot.getStringSlot().value;
  47. }
  48. function getStringStorage(uint256 key) public view returns (string memory) {
  49. return stringMap[key].getStringSlot().value;
  50. }
  51. mapping(uint256 key => bytes) public bytesMap;
  52. function setBytesSlot(bytes32 slot, bytes calldata value) public {
  53. slot.getBytesSlot().value = value;
  54. }
  55. function setBytesStorage(uint256 key, bytes calldata value) public {
  56. bytesMap[key].getBytesSlot().value = value;
  57. }
  58. function getBytesSlot(bytes32 slot) public view returns (bytes memory) {
  59. return slot.getBytesSlot().value;
  60. }
  61. function getBytesStorage(uint256 key) public view returns (bytes memory) {
  62. return bytesMap[key].getBytesSlot().value;
  63. }
  64. }