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

[Staking] query response should be Coins #513

Closed
yun-yeo opened this issue Aug 28, 2020 · 4 comments
Closed

[Staking] query response should be Coins #513

yun-yeo opened this issue Aug 28, 2020 · 4 comments

Comments

@yun-yeo
Copy link

yun-yeo commented Aug 28, 2020

The staking delegation query response's rewards must be []Coin not Coin, https://github.com/cosmos/cosmos-sdk/blob/6a624c3f68900e99255846b4a63fb79285af54ce/x/distribution/types/query.go#L14

pub amount: Coin,

@ethanfrey
Copy link
Member

There are quite a few steps between this. And two calls for the delegations - simple and full.

Here is the full Delegation type in CosmWasm. This is returned from AllDelegations query which uses tokensFromShares to compute the number of bonded tokens.

This amount an only be a coin, as it must be the bonded denom (only one is allowed) and returns the total amount bonded.

However, digging down a bit more, there is a FullDelegation response, which does have an accumulated_rewards field, which is what you are looking for.

If you look into the go query handler, which calls into the Keeper to get the rewards. This is then transformed into the cosmwasm type to pass it into Rust. And should have the reward info.

Digging in, I see this was left as a TODO as I had no idea how to get such info from the staking module.

@ethanfrey
Copy link
Member

I issue raised is not an issue but rather a confusion of the API. However, it did reveal two other issues (maybe we rename this issue or make new ones):

I am happy to modify the type of accumuated_rewards in CosmWasm, that is quite straightforward, but if you have any idea how I can get such information on rewards from the delegation module, please let me know.

@ethanfrey
Copy link
Member

Replaced this with those two above issues: #515 and CosmWasm/wasmd#263

Thank you for reporting this and I would be grateful for any insights into CosmWasm/wasmd#263

@yun-yeo
Copy link
Author

yun-yeo commented Aug 28, 2020

ok Thanks

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

2 participants