Bug report: QueryStakingSummary returns 0 when coins are staked
Prerequisites
- [X] I am running the latest CosmPy version.
- [X] I checked the documentation and found no answer to my problem.
- [X] I checked the existing issues to make sure my problem has not already been reported.
- [X] I have read the code of conduct before creating this issue.
Expected Behavior
When executing client.query_staking_summary(some_address), I expect to receive a dict containing accurate total_rewards value and relevant current_positions.
Current Behavior
The total_rewards is 0.
When stepping through the code at https://github.com/fetchai/cosmpy/blob/master/cosmpy/aerial/client/init.py#L396 I identify that the reward_amount is accurate, however the // COSMOS_SDK_DEC_COIN_PRECISION floor division results in a value of 0.0.
Because the reward_amount is being divided by 10**18, the resultant output is 0 since 10**18 is greater than the base unit of the cosmoshub blockchain.
I think the // COSMOS_SDK_DEC_COIN_PRECISION may be unnecessary in this line of code, but I don't know the full context of how this is used across all blockchains.
A possible fix is to rewrite this line to simply be:
int(float(reward.amount))
without any division
To Reproduce
No response
Context
I instantiated a aerial client using the cosmoshub blockchain and requested staking details of an address that has > 1uatom of staking rewards.
Failure Logs
No response
import cosmpy.aerial.client
cosmpy.aerial.client.__dict__["COSMOS_SDK_DEC_COIN_PRECISION"] = 1
I've also encountered the same issue. The current solution is to use the following code to set this constant and make the method return the correct result.