forked from OpenZeppelin/openzeppelin-contracts
-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathStorageSlotMock.sol
More file actions
85 lines (62 loc) · 2.47 KB
/
StorageSlotMock.sol
File metadata and controls
85 lines (62 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {StorageSlot} from "../utils/StorageSlot.sol";
contract StorageSlotMock {
using StorageSlot for *;
function setBooleanSlot(bytes32 slot, bool value) public {
slot.getBooleanSlot().value = value;
}
function setAddressSlot(bytes32 slot, address value) public {
slot.getAddressSlot().value = value;
}
function setBytes32Slot(bytes32 slot, bytes32 value) public {
slot.getBytes32Slot().value = value;
}
function setUint256Slot(bytes32 slot, uint256 value) public {
slot.getUint256Slot().value = value;
}
function setInt256Slot(bytes32 slot, int256 value) public {
slot.getInt256Slot().value = value;
}
function getBooleanSlot(bytes32 slot) public view returns (bool) {
return slot.getBooleanSlot().value;
}
function getAddressSlot(bytes32 slot) public view returns (address) {
return slot.getAddressSlot().value;
}
function getBytes32Slot(bytes32 slot) public view returns (bytes32) {
return slot.getBytes32Slot().value;
}
function getUint256Slot(bytes32 slot) public view returns (uint256) {
return slot.getUint256Slot().value;
}
function getInt256Slot(bytes32 slot) public view returns (int256) {
return slot.getInt256Slot().value;
}
mapping(uint256 key => string) public stringMap;
function setStringSlot(bytes32 slot, string calldata value) public {
slot.getStringSlot().value = value;
}
function setStringStorage(uint256 key, string calldata value) public {
stringMap[key].getStringSlot().value = value;
}
function getStringSlot(bytes32 slot) public view returns (string memory) {
return slot.getStringSlot().value;
}
function getStringStorage(uint256 key) public view returns (string memory) {
return stringMap[key].getStringSlot().value;
}
mapping(uint256 key => bytes) public bytesMap;
function setBytesSlot(bytes32 slot, bytes calldata value) public {
slot.getBytesSlot().value = value;
}
function setBytesStorage(uint256 key, bytes calldata value) public {
bytesMap[key].getBytesSlot().value = value;
}
function getBytesSlot(bytes32 slot) public view returns (bytes memory) {
return slot.getBytesSlot().value;
}
function getBytesStorage(uint256 key) public view returns (bytes memory) {
return bytesMap[key].getBytesSlot().value;
}
}