Skip to content

Commit c31c597

Browse files
authored
fix: updates coding example and minor spelling/grammar fixes (#24)
1 parent 5b713a9 commit c31c597

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ forge install brockelmore/forge-std
1111
## Contracts
1212
### stdError
1313

14-
This is a helper contract for errors and reverts in solidity. In `forge`, this contract is particularly helpful for the `expectRevert` cheatcode, as it provides all compiler builtin errors.
14+
This is a helper contract for errors and reverts. In `forge`, this contract is particularly helpful for the `expectRevert` cheatcode, as it provides all compiler builtin errors.
1515

1616
See the contract itself for all error codes.
1717

@@ -23,7 +23,7 @@ import "ds-test/test.sol";
2323
import "forge-std/stdlib.sol";
2424
import "forge-std/Vm.sol";
2525
26-
contract TestContract is DSTest, stdError {
26+
contract TestContract is DSTest {
2727
Vm public constant vm = Vm(HEVM_ADDRESS);
2828
2929
ErrorsTest test;
@@ -47,7 +47,7 @@ contract ErrorsTest {
4747

4848
### stdStorage
4949

50-
This is a rather large contract due to all of the overloading to make the UX decent. Primarly, it is a wrapper around the `record` and `accesses` cheatcodes. It can *always* find and write the storage slot(s) associated with a particular variable without knowing the storage layout. The one _major_ caveat to this is while a slot can be found for packed storage variables, we can't write to that variable safely. If a user tries to write to a packed slot, the execution throws an error, unless it is uninitialized (`bytes32(0)`).
50+
This is a rather large contract due to all of the overloading to make the UX decent. Primarily, it is a wrapper around the `record` and `accesses` cheatcodes. It can *always* find and write the storage slot(s) associated with a particular variable without knowing the storage layout. The one _major_ caveat to this is while a slot can be found for packed storage variables, we can't write to that variable safely. If a user tries to write to a packed slot, the execution throws an error, unless it is uninitialized (`bytes32(0)`).
5151

5252
This works by recording all `SLOAD`s and `SSTORE`s during a function call. If there is a single slot read or written to, it immediately returns the slot. Otherwise, behind the scenes, we iterate through and check each one (assuming the user passed in a `depth` parameter). If the variable is a struct, you can pass in a `depth` parameter which is basically the field depth.
5353

@@ -99,14 +99,14 @@ contract TestContract is DSTest {
9999
100100
// It supports arbitrary storage layouts, like assembly based storage locations
101101
function testFindHidden() public {
102-
// hidden is a random hash of a bytes, iteration through slots would
102+
// `hidden` is a random hash of a bytes, iteration through slots would
103103
// not find it. Our mechanism does
104-
// Also, you can use the selector instead of string
104+
// Also, you can use the selector instead of a string
105105
uint256 slot = stdstore.target(address(test)).sig(test.hidden.selector).find();
106106
assertEq(slot, keccak256("my.random.var"));
107107
}
108108
109-
// if targeting a mapping, you have to pass in the keys necessary to perform the find
109+
// If targeting a mapping, you have to pass in the keys necessary to perform the find
110110
// i.e.:
111111
function testFindMapping() public {
112112
uint256 slot = stdstore
@@ -183,7 +183,7 @@ With these 4 functions, you can find any slot (or write to it with their counter
183183

184184
### stdCheats
185185

186-
This is a wrapper over miscellaneous cheatcodes that need wrappers to be more dev friendly. Currently there are only function related to `prank`. In general, users may expect ETH to be put into an address on `prank`, but this is not the case for safety reasons. Explicitly this `hoax` function should only be used for address that have expected balances as it will get overwritten. If an address already has Eth, you should just use `prank`. If you want to change that balance explicitly, just use `deal`. If you want to do both, `hoax` is also right for you.
186+
This is a wrapper over miscellaneous cheatcodes that need wrappers to be more dev friendly. Currently there are only functions related to `prank`. In general, users may expect ETH to be put into an address on `prank`, but this is not the case for safety reasons. Explicitly this `hoax` function should only be used for address that have expected balances as it will get overwritten. If an address already has ETH, you should just use `prank`. If you want to change that balance explicitly, just use `deal`. If you want to do both, `hoax` is also right for you.
187187

188188

189189
#### Example usage:
@@ -206,22 +206,22 @@ contract StdCheatsTest is DSTest, stdCheats {
206206
}
207207
208208
function testHoax() public {
209-
// we call the hoax, which gives the target address
209+
// we call `hoax`, which gives the target address
210210
// eth and then calls `prank`
211211
hoax(address(1337));
212212
test.bar{value: 100}(address(1337));
213213
214214
// overloaded to allow you to specify how much eth to
215-
// initialize the addres with
215+
// initialize the address with
216216
hoax(address(1337), 1);
217217
test.bar{value: 1}(address(1337));
218218
}
219219
220220
function testStartHoax() public {
221-
// we call the startHoax, which gives the target address
221+
// we call `startHoax`, which gives the target address
222222
// eth and then calls `startPrank`
223223
//
224-
// it is also overloaded so that you can specify eth amount
224+
// it is also overloaded so that you can specify an eth amount
225225
startHoax(address(1337));
226226
test.bar{value: 100}(address(1337));
227227
test.bar{value: 100}(address(1337));

0 commit comments

Comments
 (0)