Skip to content

cast call returns integers in scientific notation #6598

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

Closed
2 tasks done
Inphi opened this issue Dec 14, 2023 · 5 comments
Closed
2 tasks done

cast call returns integers in scientific notation #6598

Inphi opened this issue Dec 14, 2023 · 5 comments
Labels
T-bug Type: bug

Comments

@Inphi
Copy link
Contributor

Inphi commented Dec 14, 2023

Component

Cast

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

  • Foundry
  • 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 Inphi added the T-bug Type: bug label Dec 14, 2023
@gakonst gakonst added this to Foundry Dec 14, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Dec 14, 2023
@CodeSandwich
Copy link
Contributor

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.

@mds1
Copy link
Collaborator

mds1 commented Dec 14, 2023

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

@jordaniza
Copy link

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

@CodeSandwich
Copy link
Contributor

Should we close this issue as a duplicate of #6600?

@DaniPopes
Copy link
Member

Duplicate of #6600

@DaniPopes DaniPopes marked this as a duplicate of #6600 Jun 27, 2024
@DaniPopes DaniPopes closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

5 participants