-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(cheats): preserve struct order when parsing JSON objects #11612
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
…sorted-json-w-compiler
crates/cheatcodes/src/json.rs
Outdated
let value = serialize_value_as_json(value)?; | ||
let value = serialize_value_as_json( | ||
value, | ||
state.analysis.as_ref().and_then(|analysis| analysis.struct_defs().ok()), |
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 make this a fn on state
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.
crates/forge/src/cmd/coverage.rs
Outdated
output: &ProjectCompileOutput, | ||
mut report: CoverageReport, | ||
config: Arc<Config>, | ||
config_and_project: ConfigAndProject, |
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.
this is not needed, you can't clone it you should be able to re-use output
's compiler in build
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.
Motivation
Historical limitation in
vm.parseJson
where JSON object fields had to be sorted alphabetically, breaking compatibility with Solidity struct field order. This required developers to work around the limitation by manually ordering JSON fields.Solution
Integrate Solar's compiler output into the multi-runners. The PR introduces a
CheatcodeAnalysis
architecture that provides the cheatcode inspector access to Solar's compiler output, enabling order-preserving JSON parsing.JSON cheats improvements
parseJson
andparseJsonType
now use struct definitions to preserve field orderCheatcodeAnalysis Architecture
New
CheatcodeAnalysis
struct that provides cached, on-demand access to Solar's compiler output:the impl aims to be:
CheatcodeAnalysis
struct with the new fields and getter methodsintegrating a new analysis tool only requires setting up a new getter method (besides its impl):
note:
StructDefinitionResolver
is a HIR visitorold disc: