A lot of CLI commands add a \n at the end of their output (e.g. forge inspect, cast ... etc) and the FFI cheatcode is unable to decode hexadecimal of such output.
This is because the following code only trims the 0x prefix but doesn't trim whitespace at the end:
|
hexOut, err := hex.DecodeString(strings.TrimPrefix(string(stdout), "0x")) |
I suggest to make this decoding logic stronger by trying to trim whitespace.
For example, Foundry does it:
https://github.com/foundry-rs/foundry/blob/1bcd17c8299d7c0792a77b2d4a0cf2c531a5cab2/crates/cheatcodes/src/fs.rs#L598-L602