Skip to content

Borsh seems to fail when deserializing numbers in scientific notation like 7e+24 #134

Open
@felixniemeyer

Description

Hi there,

I'm trying to call a contract function with a big number in the args that is represented in the scientific format in the serialized string.

...
    "A": {
        "field": 7e+24,
       ...
    }

The contract function execution fails with:

{"index":0,"kind":{"ExecutionError":"Smart contract panicked: panicked at 'Failed to deserialize input from JSON.: Error(\"expected `,` or `}`\", line: 1, column: 135)'

The column 135 is exactly the "e" character in the number "7e+24" and I think borsh can't cope with the scientific notation of numbers.

I'd expect borsh to deserialize "7e+24" into 7000000000000000000000000 just fine.

Maybe this error is also somehow intentional, because I'm trying to deserialize into a u128 and not every number with a scientific notation can be parsed into a u128. But then I'd expect a different error message, telling me that types are incompatible or so.

Hope this helps

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions