Skip to content

[Bug]: Type cosmossdk_io_math.LegacyDec (from package cosmossdk.io/math) not show correctly if the cli generated using autocli #19975

@QuocThi

Description

@QuocThi

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

I am facing an issue with the client cli command generated using autocli. Any Msg response from server that has field with type DecCoin (underlying type is cosmossdk_io_math.LegacyDec) will be shown incorrectly. Here are some examples:
I have a custom module that will return a DecCoin type when query balances of account:
message QueryBalancesResponse { repeated cosmos.base.v1beta1.DecCoin coins = 1; }

NOTE: the correct balances is: 4000000000ntoken OR 4token

When using autocli to generate the client query cmd it show incorrect balances:

binaryd q gm balances address1q9mhu97ju0qckqgqf5fnhdqe5el63kzq33phdc                                                                                                                                                           
coins:
- amount: "4000000000000000000"
  denom: token

when using the cosmos's bank module to show, it shows correctly (because cosmos's bank using: cosmos.base.v1beta1.Coin):

binaryd q bank balances address1q9mhu97ju0qckqgqf5fnhdqe5el63kzq33phdc                                                                                                                                                         
balances:
- amount: "4000000000"
  denom: ntoken

If I use custom command (which uses client.PrintProto() from package "github.com/cosmos/cosmos-sdk/client") it also print output correctly.

binaryd q gm balances address1q9mhu97ju0qckqgqf5fnhdqe5el63kzq33phdc                                                                                                                                                            
coins:
- amount: "4.000000000000000000"
  denom: token

The gov module also show wrong number if the Params have type DecCoin.
cosmos.base.v1beta1.DecCoin minimum_gas_prices
proposal.json:

cat draft_proposal.json
{
  "messages": [
    {
      "@type": "/chain.custom_module.v1.MsgUpdateParams",
      "authority": "address10d07y265gmmuvt4z0w9aw880jnsr700jzx3uhc",
      "params": {
        "minimum_gas_prices": [
          {
            "denom": "ntoken",
            "amount": "10000.000000000000000000"
          }
        ]
      }
    }
  ],
  "metadata": "ipfs://CID",
  "deposit": "10000token",
  "title": "asd",
  "summary": "asd",
  "expedited": false
}

gov query output:

binaryd q gov proposals
pagination:
  total: "1"
proposals:
- deposit_end_time: "2024-04-10T04:14:28.10353Z"
  final_tally_result:
    abstain_count: "0"
    no_count: "0"
    no_with_veto_count: "0"
    yes_count: "0"
  id: "1"
  messages:
  - type: cosmos-sdk/custom_module/MsgUpdateParams
    value:
      authority: address10d07y265gmmuvt4z0w9aw880jnsr700jzx3uhc
      params:
        minimum_gas_prices:
        - amount: "10000000000000000000000"
          denom: ntoken
     ....

My previous solution is using EnhanceCustomCommand: true and keep our custom client cli to use the client.PrintProto() for our custom modules. But problem still happen with cosmos's core module like staking, gov. Here is the list of comos's module still use DecCoin type.

Cosmos SDK Version

0.50.3

How to reproduce?

No response

Metadata

Metadata

Assignees

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