Skip to content

Commit 4bfb08b

Browse files
authored
fix(stdlib): make variables not meant for end-users private (#28)
1 parent 5e53a7f commit 4bfb08b

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/stdlib.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ abstract contract stdCheats {
99

1010
// we use custom names that are unlikely to cause collisions so this contract
1111
// can be inherited easily
12-
Vm constant vm_std_cheats = Vm(address(uint160(uint256(keccak256('hevm cheat code')))));
13-
StdStorage std_store_std_cheats;
12+
Vm private constant vm_std_cheats = Vm(address(uint160(uint256(keccak256('hevm cheat code')))));
13+
StdStorage private std_store_std_cheats;
1414

1515
// Skip forward or rewind time by the specified number of seconds
1616
function skip(uint256 time) public {
@@ -129,7 +129,7 @@ library stdStorage {
129129
event SlotFound(address who, bytes4 fsig, bytes32 keysHash, uint slot);
130130
event WARNING_UninitedSlot(address who, uint slot);
131131

132-
Vm constant stdstore_vm = Vm(address(uint160(uint256(keccak256('hevm cheat code')))));
132+
Vm private constant vm_std_store = Vm(address(uint160(uint256(keccak256('hevm cheat code')))));
133133

134134
function sigs(
135135
string memory sigStr
@@ -163,16 +163,16 @@ library stdStorage {
163163
return self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))];
164164
}
165165
bytes memory cald = abi.encodePacked(fsig, flatten(ins));
166-
stdstore_vm.record();
166+
vm_std_store.record();
167167
bytes32 fdat;
168168
{
169169
(, bytes memory rdat) = who.staticcall(cald);
170170
fdat = bytesToBytes32(rdat, 32*field_depth);
171171
}
172172

173-
(bytes32[] memory reads, ) = stdstore_vm.accesses(address(who));
173+
(bytes32[] memory reads, ) = vm_std_store.accesses(address(who));
174174
if (reads.length == 1) {
175-
bytes32 curr = stdstore_vm.load(who, reads[0]);
175+
bytes32 curr = vm_std_store.load(who, reads[0]);
176176
if (curr == bytes32(0)) {
177177
emit WARNING_UninitedSlot(who, uint256(reads[0]));
178178
}
@@ -184,12 +184,12 @@ library stdStorage {
184184
self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;
185185
} else if (reads.length > 1) {
186186
for (uint256 i = 0; i < reads.length; i++) {
187-
bytes32 prev = stdstore_vm.load(who, reads[i]);
187+
bytes32 prev = vm_std_store.load(who, reads[i]);
188188
if (prev == bytes32(0)) {
189189
emit WARNING_UninitedSlot(who, uint256(reads[i]));
190190
}
191191
// store
192-
stdstore_vm.store(who, reads[i], bytes32(hex"1337"));
192+
vm_std_store.store(who, reads[i], bytes32(hex"1337"));
193193
{
194194
(, bytes memory rdat) = who.staticcall(cald);
195195
fdat = bytesToBytes32(rdat, 32*field_depth);
@@ -200,10 +200,10 @@ library stdStorage {
200200
emit SlotFound(who, fsig, keccak256(abi.encodePacked(ins, field_depth)), uint256(reads[i]));
201201
self.slots[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = uint256(reads[i]);
202202
self.finds[who][fsig][keccak256(abi.encodePacked(ins, field_depth))] = true;
203-
stdstore_vm.store(who, reads[i], prev);
203+
vm_std_store.store(who, reads[i], prev);
204204
break;
205205
}
206-
stdstore_vm.store(who, reads[i], prev);
206+
vm_std_store.store(who, reads[i], prev);
207207
}
208208
} else {
209209
require(false, "No storage use detected for target");
@@ -289,12 +289,12 @@ library stdStorage {
289289
(, bytes memory rdat) = who.staticcall(cald);
290290
fdat = bytesToBytes32(rdat, 32*field_depth);
291291
}
292-
bytes32 curr = stdstore_vm.load(who, slot);
292+
bytes32 curr = vm_std_store.load(who, slot);
293293

294294
if (fdat != curr) {
295295
require(false, "Packed slot. This would cause dangerous overwriting and currently isnt supported");
296296
}
297-
stdstore_vm.store(who, slot, set);
297+
vm_std_store.store(who, slot, set);
298298
delete self._target;
299299
delete self._sig;
300300
delete self._keys;

0 commit comments

Comments
 (0)