Merge PR #4047: Fix queryDelegationRewards

This commit is contained in:
Alexander Bezobchuk 2019-04-04 13:53:22 -04:00 committed by GitHub
parent cbc9ab0df2
commit 3361871198
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -114,6 +114,8 @@
either the truncated coins or the change coins.
* [\#3915](https://github.com/cosmos/cosmos-sdk/issues/3915) Remove ';' delimiting support from ParseDecCoins
* [\#3977](https://github.com/cosmos/cosmos-sdk/issues/3977) Fix docker image build
* [\#4020](https://github.com/cosmos/cosmos-sdk/issues/4020) Fix queryDelegationRewards by returning an error
when the validator or delegation do not exist.
## 0.33.2

View File

@ -207,7 +207,17 @@ func queryDelegationRewards(ctx sdk.Context, _ []string, req abci.RequestQuery,
ctx, _ = ctx.CacheContext()
val := k.stakingKeeper.Validator(ctx, params.ValidatorAddress)
if val == nil {
// TODO: Should use ErrNoValidatorFound from staking/types
return nil, sdk.ErrInternal(fmt.Sprintf("validator %s does not exist", params.ValidatorAddress))
}
del := k.stakingKeeper.Delegation(ctx, params.DelegatorAddress, params.ValidatorAddress)
if del == nil {
// TODO: Should use ErrNoDelegation from staking/types
return nil, sdk.ErrInternal("delegation does not exist")
}
endingPeriod := k.incrementValidatorPeriod(ctx, val)
rewards := k.calculateDelegationRewards(ctx, val, del, endingPeriod)