Merge PR #4047: Fix queryDelegationRewards
This commit is contained in:
parent
cbc9ab0df2
commit
3361871198
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue