-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
refactor: Streamline console.sol
generation
#5759
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
[...Array(4)].flatMap((_, paramCount) => { | ||
return Array.from( | ||
genPermutations(TYPES.length, paramCount + 1), |
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.
[...Array(4)].flatMap((_, paramCount) => { | |
return Array.from( | |
genPermutations(TYPES.length, paramCount + 1), | |
[...Array(5)].flatMap((_, paramCount) => { | |
return Array.from( | |
genPermutations(TYPES.length, paramCount), |
As a side-note, this base case can handle generating the empty log()
just fine but shifted its order in the console.sol file. This is probably meaningless but I wanted to avoid making any changes; let me know if you'd like me to not explicitly handle log()
and handle this with this code, instead.
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.
That's a good point, but yes, let's leave it as is.
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.