-
Notifications
You must be signed in to change notification settings - Fork 43
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
Missing decimal in DecCoin amount string. #247
Comments
This is tracked here: cosmos/cosmos-sdk#10863 |
Manually using decCoin.amount = Math.floor(
decodeCosmosSdkDecFromProto(
decCoin.amount
).toFloatApproximation()
).toString() |
Sounds good. But if you want a string anyways, there is no need to convert to a float first an lose precision. You can just do: decCoin.amount = decodeCosmosSdkDecFromProto(decCoin.amount).toString() |
I want a string of the floored integer first. Though I guess I could do |
Decimal can do that for you: |
Ah perfect! Thank you. |
If you miss any operations on Decimal, let me know. Often they can be implemented without loss of precision in the Decimal type directly. |
Awesome :) Appreciate it. |
So... basically any I did a quick search:
and of course
what i did was a little "dirty": i manually modified the
this way i don't have to modify either the message or the query response of anything returning i hope i'm not doing anything wrong :( |
This is pretty cool! What is We can make this an option and test it out for sure |
@pyramation I use
|
I'd not pull in the Decimal type here. But what we can do is implement the string conversion
in Telescope. The resulting string can then be read into a |
you're right. I use |
this could potentially solve this issue, we have a new flag to test for this now:
change the default config to be true to enable (default is false) |
closed with #332 |
Source
method
DelegatorDelegations
of servicecosmos.staking.v1beta1.Query
withdelegatorAddr: juno1egefqhp4tv9gjat3p4clxhstfhw5djfl920p6zcfe8xdymqpuq7s33csz6
using the
client.staking.v1beta1.delegatorDelegations
function ofinterchain-rpc
Issue
This query returns the following object:
The
balance
property of the delegation response is properly typed with a ujuno integer, representing 1.337 $JUNO. Thedelegation.shares
property of the delegation response is typed in decimal ujuno, which has 18 decimals, but appears to be missing the decimal in its string serialization.Expected behavior
junod query staking delegations juno1egefqhp4tv9gjat3p4clxhstfhw5djfl920p6zcfe8xdymqpuq7s33csz6 --output json | jq
outputs the following object:
and the LCD query responds with the following object:
Both of these responses correctly insert the decimal place where expected.
Preliminary investigation
This also occurs with
interchain-rpc
'sclient.distribution.v1beta1.delegationTotalRewards
function, which responds with:The junod and LCD equivalents, as expected, insert the decimal point before their 18 decimal places.
It seems to be an issue serializing
DecCoin
ininterchain-rpc
. The correctly typedbalance
property, which is a ujuno integer, uses theCoin
type, whereas all the numbers with missing decimal points ininterchain-rpc
's responses are typed withDecCoin
.Coin
andDecCoin
ininterchain-rpc/src/codegen/cosmos/base/v1beta1/coin.ts
appear to encode and decode in the exact same way. It seems likely to me thatDecCoin
should be decoding the values differently, aware of decimals.The text was updated successfully, but these errors were encountered: