Open CryptoKiddies opened 10 months ago
just a bump on this; if you guys want help, let me know @fvictorio.
Hi @CryptoKiddies!
I still think this is a valuable feature, but to be honest the implementation is not quite easy.
The way Hardhat's console.log
works is by delegating the formating to node's util.format
which, AFAIK, doesn't support binary specifiers (nor octal, nor hex).
One way to work around this is to do something like:
%s %b %i
and arguments ["foo", 31, 5678]
. You'd like this to be logged as foo 0b11111 5678
.util.format
, the result will be foo %b 31 5678
, which is obviously not what you want.%b
with %s
, and replace 31 with the string "0b11111"
. And you need to do this for all possible %b
s in the format string.%b
in it.This is doable with a simple state machine, but it may be more effort that what you'd like to invest here.
On top of that, we will eventually move this functionality to EDR, and we'll probably implement our own formatter there. Supporting %b
while/after doing that seems better than temporarily doing it in javascript just to discard it later.
So my proposal would be to transfer this issue to the EDR repo, and for us to do it when the time comes to port the console.log feature. Wdyt?
Describe the feature
I have this utility created to see the bitwise values in a word for testing and debugging contract logic, particularly when using bit masks. Wondering if you'd be interested in adding support directly in console.sol with this util? I'm suggesting a feature indicated with a %b flag perhaps.
This is great for low level developers (who are still commonplace for now) in the solidity ecosystem. Any bitwise operations or state packing optimization testing would benefit from being able to see the word printed out as 1s and 0s., like
Here's my result 11101001...
. Wonder if I can contribute, but definitely agree this is pre-processed as discussed here with discussed here with @fvictorio.code: https://github.com/YOLOrekt/community-bug-bounty/blob/bounty-head/contracts/utils/LogBinary.sol
Search terms
console.sol console log debugging