-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat(cheatcodes): decode structs in state diff output #11331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
* add @onbjerg * add @0xrusowsky
…ty::Gas` (#11358) fix(lint): 'unwrapped-modifier-logic' incorrectly marked with Severity::Gas
// Helper function to check if a string contains a substring | ||
function assertContains(string memory haystack, string memory needle, string memory message) internal pure { | ||
bytes memory haystackBytes = bytes(haystack); | ||
bytes memory needleBytes = bytes(needle); | ||
|
||
if (needleBytes.length > haystackBytes.length) { | ||
revert(message); | ||
} | ||
|
||
bool found = false; | ||
for (uint256 i = 0; i <= haystackBytes.length - needleBytes.length; i++) { | ||
bool isMatch = true; | ||
for (uint256 j = 0; j < needleBytes.length; j++) { | ||
if (haystackBytes[i + j] != needleBytes[j]) { | ||
isMatch = false; | ||
break; | ||
} | ||
} | ||
if (isMatch) { | ||
found = true; | ||
break; | ||
} | ||
} | ||
|
||
if (!found) { | ||
revert(message); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we move this to a helper, this is duplicated in https://github.com/foundry-rs/foundry/pull/11381/files#diff-7c006befc48f0502d1653777375b064ac35b0866dc7fe26fb332e78a5edc9371
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation lgtm, note on duplicate utility function after merging https://github.com/foundry-rs/foundry/pull/11381/files#diff-7c006befc48f0502d1653777375b064ac35b0866dc7fe26fb332e78a5edc9371
Motivation
Ref #9504
Closes #11326
Solution
handle_struct_recursive
processes both single-slot and multi-slot structs, recursing through nestedstructures.
the accessed slot
Example:
TestStruct Diff
MultiSlotStruct Diff
NestedStruct Diff
PR Checklist