Skip to content

Commit c4b2516

Browse files
committed
RevertString fixed + done!
1 parent 3f0da6d commit c4b2516

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

src/RevertCustom.huff

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
#define error OnlyHuff()
1515

1616
#define macro MAIN() = takes(0) returns(0) {
17-
17+
__ERROR(OnlyHuff) 0x00 mstore
18+
0x20 0x00 revert
1819
}

src/RevertString.huff

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,7 @@
1313

1414

1515
#define macro MAIN() = takes(0) returns(0) {
16-
16+
0x4f6e6c7920487566660000000000000000000000000000000000000000000000
17+
0x00 mstore
18+
0x09 0x00 revert
1719
}

src/SimpleStore.huff

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,32 @@
1616

1717

1818
#define macro MAIN() = takes(0) returns(0) {
19-
19+
// get 4 first bytes
20+
0x00
21+
calldataload
22+
0xe0
23+
shr
24+
25+
// read()
26+
dup1
27+
__FUNC_SIG(read) eq
28+
read jumpi
29+
// store()
30+
__FUNC_SIG(store) eq
31+
store jumpi
32+
0x00 0x00 revert
33+
34+
read:
35+
pop
36+
0x00 sload
37+
0x00 mstore
38+
retvalue jump
39+
40+
store:
41+
0x04 calldataload
42+
0x00 sstore
43+
retvalue jump
44+
45+
retvalue:
46+
0x20 0x00 return
2047
}

test/RevertString.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ contract RevertStringTest is Test {
2323
require(!success, "call expected to fail");
2424
assertEq(
2525
keccak256(bytes("Only Huff")),
26-
keccak256(abi.decode(revertData, (bytes))),
26+
keccak256(revertData),
2727
"Expected the call to revert with custom error 'Only Huff' but it didn't "
2828
);
2929
}

0 commit comments

Comments
 (0)