Skip to content
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

Invalid string format. Only non-negative integers in decimal representation supported. #642

Open
Wgil opened this issue Jul 23, 2024 · 0 comments

Comments

@Wgil
Copy link

Wgil commented Jul 23, 2024

Dear Telescope team,

I have the following definition in a proto file:

message QueryOpenEstResponse {
  string weight_balance_ratio = 2 [
    (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
    (gogoproto.nullable) = false
  ];
}

The issue that I'm having is that such field can be a negative number as it's allowed in CosmosSDK but since it's decoded using Decimal.fromAtomics after running yarn codegen:

case 2:
          message.weightBalanceRatio = Decimal.fromAtomics(reader.string(), 18).toString();

I get an error trying to decode its value:

Error: Invalid string format. Only non-negative integers in decimal representation supported.
    at new Decimal (decimal.js:103:1)
    at Decimal.fromAtomics (decimal.js:59:1)
    at Object.decode (query.ts:2215:48)
    at eval (query.rpc.Query.ts:119:54)

Do you guys have any alternative for this?
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant