TransientSlotMock.sol 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // SPDX-License-Identifier: MIT
  2. // This file was procedurally generated from scripts/generate/templates/TransientSlotMock.js.
  3. pragma solidity ^0.8.24;
  4. import {Multicall} from "../utils/Multicall.sol";
  5. import {TransientSlot} from "../utils/TransientSlot.sol";
  6. contract TransientSlotMock is Multicall {
  7. using TransientSlot for *;
  8. event AddressValue(bytes32 slot, address value);
  9. function tloadAddress(bytes32 slot) public {
  10. emit AddressValue(slot, slot.asAddress().tload());
  11. }
  12. function tstore(bytes32 slot, address value) public {
  13. slot.asAddress().tstore(value);
  14. }
  15. event BooleanValue(bytes32 slot, bool value);
  16. function tloadBoolean(bytes32 slot) public {
  17. emit BooleanValue(slot, slot.asBoolean().tload());
  18. }
  19. function tstore(bytes32 slot, bool value) public {
  20. slot.asBoolean().tstore(value);
  21. }
  22. event Bytes32Value(bytes32 slot, bytes32 value);
  23. function tloadBytes32(bytes32 slot) public {
  24. emit Bytes32Value(slot, slot.asBytes32().tload());
  25. }
  26. function tstore(bytes32 slot, bytes32 value) public {
  27. slot.asBytes32().tstore(value);
  28. }
  29. event Uint256Value(bytes32 slot, uint256 value);
  30. function tloadUint256(bytes32 slot) public {
  31. emit Uint256Value(slot, slot.asUint256().tload());
  32. }
  33. function tstore(bytes32 slot, uint256 value) public {
  34. slot.asUint256().tstore(value);
  35. }
  36. event Int256Value(bytes32 slot, int256 value);
  37. function tloadInt256(bytes32 slot) public {
  38. emit Int256Value(slot, slot.asInt256().tload());
  39. }
  40. function tstore(bytes32 slot, int256 value) public {
  41. slot.asInt256().tstore(value);
  42. }
  43. }