We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug
To Reproduce
Expected behavior
Should only show 6 decimals. This should probably be handled in the API.
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered:
I think in this case api is returning rewards as expected (6 decimal points):
Query:
{ rewards(networkId: "cosmos-hub-mainnet", delegatorAddress: "cosmos16d7lk68ruw5556wumhc3tle9vj333lhzalnfmf") { validator { operatorAddress } amount } }
Response:
{ "data": { "rewards": [ { "validator": { "operatorAddress": "cosmosvaloper1qwl879nx9t6kef4supyazayf7vjhennyh568ys" }, "amount": "0.000492" }, { "validator": { "operatorAddress": "cosmosvaloper15r4tc0m6hc7z8drq3dzlrtcs6rq2q9l2nvwher" }, "amount": "0.000048" }, { "validator": { "operatorAddress": "cosmosvaloper1k9a0cs97vul8w2vwknlfmpez6prv8klv03lv3d" }, "amount": "0.000079" }, { "validator": { "operatorAddress": "cosmosvaloper1uutuwrwt3z2a5z8z3uasml3rftlpmu25aga5c6" }, "amount": "0.000052" } ] } }
The problem is at frontend, the following code is returning 0,0006709999999999999 (classic javascript floating point issue):
0,0006709999999999999
totalRewards() { return this.rewards.reduce((sum, { amount }) => sum + Number(amount), 0) },
So to fix this behaviour we can change it to:
totalRewards() { return this.rewards .reduce((sum, { amount }) => sum + Number(amount), 0) .toFixed(6) },
Which returns 0,000671 as desired.
0,000671
Sorry, something went wrong.
mariopino
Successfully merging a pull request may close this issue.
Describe the bug
To Reproduce
Expected behavior
Should only show 6 decimals.
This should probably be handled in the API.
Screenshots
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: