forge-std
forge-std copied to clipboard
Feature request: adding console.log(string,bytes32)
I often find myself needing to log bytes32 and currently this only works with console.logBytes32. Is there a possibility of extending console to add in console.log(bytes32) or console.log(string,bytes32)?
Related: https://github.com/NomicFoundation/hardhat/issues/1440
Maybe console2 could pick up these changes quicker than waiting for changes to console. And couldn't I just be required to explicitly cast to bytes32 in the case of ambiguity. For example: console.log('var', bytes32(0x1337)). This would still be a nicer UX compared to console.logBytes32, imo, but either is good.
I agree, not having to use console.logBytes32
would be a better DX.
I'd say PRs for things like this into console2.sol
are good, but we should leave console.sol
1:1 with hardhat. @ZeroEkkusu let me know if that seems reasonable.
And couldn't I just be required to explicitly cast to bytes32 in the case of ambiguity. For example: console.log('var', bytes32(0x1337)). This would still be a nicer UX compared to console.logBytes32, imo, but either is good.
Yea if there's ambiguity in your call solc will just force you to cast and be explicit, which I think is ok
Agree with console
/console2
.
Is there a possibility of extending console to add in console.log(bytes32) or console.log(string,bytes32)?
As hinted at above, the reason it's console.logBytes32(bytes32)
and why we shouldn't add support for console.log(bytes32)
(and similar for the overload with a leading string arg) is because then something like console.log("x")
becomes ambiguous, as solc doesn't know if "x"
is bytes32 or a string. So this would end up being a big breaking change for users by requiring type casts to existing code. As a result I'm going to close this 🙂
If you'd prefer the overload + required casting, I'd suggest leaving a comment on https://github.com/foundry-rs/foundry/issues/3782 since there may eventually be a vm.consoleLog
type of cheat