foundry icon indicating copy to clipboard operation
foundry copied to clipboard

bug(`cheatcodes`): `vm.parseJsonUint` can't parse numbers with scientific notation

Open anajuliabit opened this issue 6 months ago • 5 comments

Component

Forge

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

  • [X] Foundry
  • [ ] Foundryup

What version of Foundry are you on?

forge 0.2.0 (VERGEN_IDEMPOTENT_OUTPUT 2024-07-15T11:19:03.935375000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

With the following JSON:

    "1284": {
        "addRewardInfo": {
            "amount": 74258225772486694040708e18,
            "endTimestamp": 1725593400,
            "pid": 15,
            "rewardPerSec": 0.03069536448928848133e18,
            "target": "STELLASWAP_REWARDER"
        },
        ...

Using vm.parseJsonUint

       string memory key = ".1284.addRewardInfo.amount";
        uint parsedUint = vm.parseJsonUint(data, key);

Output:

    ├─ [0] VM::parseJsonUint("<stringified JSON>", ".1284.addRewardInfo.amount") [staticcall]
    │   └─ ← [Revert] failed parsing "74258.225772486694040708e18" as type `uint256`: parser error:
74258.225772486694040708e18

anajuliabit avatar Jul 30 '24 19:07 anajuliabit