refactor: Streamline console.sol
generation
#5759
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm working on porting console.log from Hardhat (NomicFoundation/edr#641). To better understand which exactly
console.log
functions we support and why, I refactored the build script for clarity in the process.I separated helper logic (e.g. permutation generator) and upfront declare which functions we support:
logUint, ..., logBytes32
anduint256
,string
,bool
,address
), including emptylog()
Since the calculation logic was mixed with rendering (and had to take into account duplicate signatures, for example), I disentangled it and streamlined the (data) flow. Hopefully this will be useful to anyone trying to understand this or modify in the future.
While making the changes, I also changed the function selectors in the logger.ts file to be a hexadecimal integer rather than a decimal one. This is the format everyone expects when working with it so there's no use in using decimals if a hexadecimal integer is natively supported as an object key.
In the future, we can remove the faulty
(u)int
ABI encoding; I tried to highlight and and document the backwards-compatibility here.