foundry icon indicating copy to clipboard operation
foundry copied to clipboard

cast call returns integers in scientific notation

Open Inphi opened this issue 1 year ago • 4 comments

Component

Cast

Have you ensured that all of these are up to date?

  • [X] Foundry
  • [X] Foundryup

What version of Foundry are you on?

cast 0.2.0 (53b15e6 2023-12-14T00:16:29.514805588Z)

What command(s) is the bug in?

cast call

Operating System

Linux

Describe the bug

cast call --rpc-url $ALCHEMY_URL  0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 'balanceOf(address) returns(uint256)' 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
78077338549235265036291 [7.807e22]

The returned numeric output of cast call includes the values in scientific notation. I'm not sure when this change in behavior occurred, but the previous versions of cast didn't do this. This breaks scripts that expect a certain format. The old behavior was something like this:

cast call --rpc-url $ALCHEMY_URL  0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 'balanceOf(address) returns(uint256)' 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
78077338549235265036291

Inphi avatar Dec 14 '23 00:12 Inphi

I just git hit by this too. I worked it around by adding | cut -f 1 -d " " to every cast call in the script.

The scientific notion doesn't show up for small numbers, so it's not consistent. A script that doesn't expect that may crash only when specific data is returned, which may happen after executing many expensive operations or operations that need a closure.

CodeSandwich avatar Dec 14 '23 10:12 CodeSandwich

I think adding the scientific notation output was a breaking change? I don't remember that always being there. If so, that does break cast integrations and usage in scripts. I think we should revert the default to what it used to be to preserve integrations, and have a --verbose/-v flag which adds the scientific notation, or use --pretty which is consistent with forge inspect

mds1 avatar Dec 14 '23 16:12 mds1

Almost certainly a breaking change. I, like @CodeSandwich, am just using trivial unix commands to slice the output but would prefer it be opt-in given the inconsistency

jordaniza avatar Feb 05 '24 07:02 jordaniza

Should we close this issue as a duplicate of https://github.com/foundry-rs/foundry/issues/6600?

CodeSandwich avatar Feb 05 '24 09:02 CodeSandwich

Duplicate of #6600

DaniPopes avatar Jun 27 '24 10:06 DaniPopes