x/distribution: gRPC query service (#6600)
* WIP: adding grpc * added grpc for query withdraw address * Fix outstanding rewards query * added inteerface registry * added gRPC for delegation rewards * added remaining commands * lint issue * added tests * added test for community pool * fixed error * added test for delegator validators * updated to use test suite * updated tests * more test checks added * updated tests * Add sdk wrap * removed pagination for outstanding rewards * fixed distr tests issue * fixed slashes issue * migrated tests to table driven tests * docs updated * review changes * review changes * review changes * Update x/distribution/keeper/grpc_query.go Co-authored-by: sahith-narahari <sahithnarahari@gmail.com> Co-authored-by: anilCSE <anil@vitwit.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com>
This commit is contained in:
parent
7678f8a913
commit
be111ef036
|
@ -179,3 +179,17 @@ message DelegatorStartingInfo {
|
||||||
uint64 height = 3
|
uint64 height = 3
|
||||||
[(gogoproto.moretags) = "yaml:\"creation_height\"", (gogoproto.jsontag) = "creation_height"];
|
[(gogoproto.moretags) = "yaml:\"creation_height\"", (gogoproto.jsontag) = "creation_height"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DelegationDelegatorReward defines the properties
|
||||||
|
// of a delegator's delegation reward.
|
||||||
|
message DelegationDelegatorReward {
|
||||||
|
bytes validator_address = 1 [
|
||||||
|
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress",
|
||||||
|
(gogoproto.moretags) = "yaml:\"validator_address\""
|
||||||
|
];
|
||||||
|
|
||||||
|
repeated cosmos.DecCoin reward = 2 [
|
||||||
|
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
|
||||||
|
(gogoproto.nullable) = false
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,141 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
package cosmos.distribution;
|
||||||
|
|
||||||
|
import "cosmos/query/pagination.proto";
|
||||||
|
import "gogoproto/gogo.proto";
|
||||||
|
import "cosmos/cosmos.proto";
|
||||||
|
import "cosmos/distribution/distribution.proto";
|
||||||
|
|
||||||
|
option go_package = "github.com/cosmos/cosmos-sdk/x/distribution/types";
|
||||||
|
|
||||||
|
// Query defines the gRPC querier service for distribution module
|
||||||
|
service Query {
|
||||||
|
// Params queries params of distribution module
|
||||||
|
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {}
|
||||||
|
|
||||||
|
// ValidatorOutstandingRewards queries rewards of a validator address
|
||||||
|
rpc ValidatorOutstandingRewards(QueryValidatorOutstandingRewardsRequest) returns (QueryValidatorOutstandingRewardsResponse) {}
|
||||||
|
|
||||||
|
// ValidatorCommission queries accumulated commission for a validator
|
||||||
|
rpc ValidatorCommission (QueryValidatorCommissionRequest) returns (QueryValidatorCommissionResponse) {}
|
||||||
|
|
||||||
|
// ValidatorSlashes queries slash events of a validator
|
||||||
|
rpc ValidatorSlashes (QueryValidatorSlashesRequest) returns (QueryValidatorSlashesResponse) {}
|
||||||
|
|
||||||
|
// DelegationRewards the total rewards accrued by a delegation
|
||||||
|
rpc DelegationRewards (QueryDelegationRewardsRequest) returns (QueryDelegationRewardsResponse) {}
|
||||||
|
|
||||||
|
// DelegationTotalRewards the total rewards accrued by a each validator
|
||||||
|
rpc DelegationTotalRewards (QueryDelegationTotalRewardsRequest) returns (QueryDelegationTotalRewardsResponse) {}
|
||||||
|
|
||||||
|
// DelegatorValidators queries the validators of a delegator
|
||||||
|
rpc DelegatorValidators (QueryDelegatorValidatorsRequest) returns (QueryDelegatorValidatorsResponse) {}
|
||||||
|
|
||||||
|
// DelegatorWithdrawAddress queries withdraw address of a delegator
|
||||||
|
rpc DelegatorWithdrawAddress (QueryDelegatorWithdrawAddressRequest) returns (QueryDelegatorWithdrawAddressResponse) {}
|
||||||
|
|
||||||
|
// CommunityPool queries the community pool coins
|
||||||
|
rpc CommunityPool (QueryCommunityPoolRequest) returns (QueryCommunityPoolResponse) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryParamsRequest is the request type for the Query/Params RPC method
|
||||||
|
message QueryParamsRequest { }
|
||||||
|
|
||||||
|
// QueryParamsResponse is the response type for the Query/Params RPC method
|
||||||
|
message QueryParamsResponse {
|
||||||
|
Params params = 1 [(gogoproto.nullable) = false];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryValidatorOutstandingRewardsRequest is the request type for the Query/ValidatorOutstandingRewards RPC method
|
||||||
|
message QueryValidatorOutstandingRewardsRequest {
|
||||||
|
bytes validator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryValidatorOutstandingRewardsResponse is the response type for the Query/ValidatorOutstandingRewards RPC method
|
||||||
|
message QueryValidatorOutstandingRewardsResponse {
|
||||||
|
ValidatorOutstandingRewards rewards = 1 [(gogoproto.nullable) = false];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryValidatorCommissionRequest is the request type for the Query/ValidatorCommission RPC method
|
||||||
|
message QueryValidatorCommissionRequest {
|
||||||
|
bytes validator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryValidatorCommissionResponse is the response type for the Query/ValidatorCommission RPC method
|
||||||
|
message QueryValidatorCommissionResponse {
|
||||||
|
ValidatorAccumulatedCommission commission = 1 [(gogoproto.nullable) = false];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryValidatorSlashesRequest is the request type for the Query/ValidatorSlashes RPC method
|
||||||
|
message QueryValidatorSlashesRequest {
|
||||||
|
bytes validator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
|
||||||
|
uint64 starting_height = 2;
|
||||||
|
uint64 ending_height = 3;
|
||||||
|
cosmos.query.PageRequest req = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryValidatorSlashesResponse is the response type for the Query/ValidatorSlashes RPC method
|
||||||
|
message QueryValidatorSlashesResponse {
|
||||||
|
repeated ValidatorSlashEvent slashes = 1 [(gogoproto.nullable) = false];
|
||||||
|
|
||||||
|
cosmos.query.PageResponse res = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegationRewardsRequest is the request type for the Query/DelegationRewards RPC method
|
||||||
|
message QueryDelegationRewardsRequest {
|
||||||
|
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||||
|
bytes validator_address = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegationRewardsResponse is the response type for the Query/DelegationRewards RPC method
|
||||||
|
message QueryDelegationRewardsResponse {
|
||||||
|
repeated cosmos.DecCoin rewards = 1 [
|
||||||
|
(gogoproto.nullable) = false,
|
||||||
|
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegationTotalRewardsRequest is the request type for the Query/DelegationTotalRewards RPC method
|
||||||
|
message QueryDelegationTotalRewardsRequest {
|
||||||
|
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegationTotalRewardsResponse is the response type for the Query/DelegationTotalRewards RPC method
|
||||||
|
message QueryDelegationTotalRewardsResponse {
|
||||||
|
repeated DelegationDelegatorReward rewards = 1 [(gogoproto.nullable) = false];
|
||||||
|
repeated cosmos.DecCoin total = 2 [
|
||||||
|
(gogoproto.nullable) = false,
|
||||||
|
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegatorValidatorsRequest is the request type for the Query/DelegatorValidators RPC method
|
||||||
|
message QueryDelegatorValidatorsRequest {
|
||||||
|
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegatorValidatorsResponse is the response type for the Query/DelegatorValidators RPC method
|
||||||
|
message QueryDelegatorValidatorsResponse {
|
||||||
|
repeated bytes validators = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegatorWithdrawAddressRequest is the request type for the Query/DelegatorWithdrawAddress RPC method
|
||||||
|
message QueryDelegatorWithdrawAddressRequest {
|
||||||
|
bytes delegator_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryDelegatorWithdrawAddressResponse is the response type for the Query/DelegatorWithdrawAddress RPC method
|
||||||
|
message QueryDelegatorWithdrawAddressResponse {
|
||||||
|
bytes withdraw_address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC method
|
||||||
|
message QueryCommunityPoolRequest {}
|
||||||
|
|
||||||
|
// QueryCommunityPoolResponse is the response type for the Query/CommunityPool RPC method
|
||||||
|
message QueryCommunityPoolResponse {
|
||||||
|
repeated cosmos.DecCoin pool = 1 [
|
||||||
|
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
|
||||||
|
(gogoproto.nullable) = false
|
||||||
|
];
|
||||||
|
}
|
|
@ -0,0 +1,214 @@
|
||||||
|
package keeper
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/staking/exported"
|
||||||
|
"google.golang.org/grpc/codes"
|
||||||
|
"google.golang.org/grpc/status"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ types.QueryServer = Keeper{}
|
||||||
|
|
||||||
|
// Params queries params of distribution module
|
||||||
|
func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) {
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
var params types.Params
|
||||||
|
k.paramSpace.GetParamSet(ctx, ¶ms)
|
||||||
|
|
||||||
|
return &types.QueryParamsResponse{Params: params}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidatorOutstandingRewards queries rewards of a validator address
|
||||||
|
func (k Keeper) ValidatorOutstandingRewards(c context.Context, req *types.QueryValidatorOutstandingRewardsRequest) (*types.QueryValidatorOutstandingRewardsResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.ValidatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty validator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
rewards := k.GetValidatorOutstandingRewards(ctx, req.ValidatorAddress)
|
||||||
|
|
||||||
|
return &types.QueryValidatorOutstandingRewardsResponse{Rewards: rewards}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidatorCommission queries accumulated commission for a validator
|
||||||
|
func (k Keeper) ValidatorCommission(c context.Context, req *types.QueryValidatorCommissionRequest) (*types.QueryValidatorCommissionResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.ValidatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty validator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
commission := k.GetValidatorAccumulatedCommission(ctx, req.ValidatorAddress)
|
||||||
|
|
||||||
|
return &types.QueryValidatorCommissionResponse{Commission: commission}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ValidatorSlashes queries slash events of a validator
|
||||||
|
func (k Keeper) ValidatorSlashes(c context.Context, req *types.QueryValidatorSlashesRequest) (*types.QueryValidatorSlashesResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.ValidatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty validator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.EndingHeight < req.StartingHeight {
|
||||||
|
return nil, status.Errorf(codes.InvalidArgument, "starting height greater than ending height (%d > %d)", req.StartingHeight, req.EndingHeight)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
events := make([]types.ValidatorSlashEvent, 0)
|
||||||
|
store := ctx.KVStore(k.storeKey)
|
||||||
|
slashesStore := prefix.NewStore(store, types.GetValidatorSlashEventPrefix(req.ValidatorAddress))
|
||||||
|
|
||||||
|
res, err := query.FilteredPaginate(slashesStore, req.Req, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||||
|
var result types.ValidatorSlashEvent
|
||||||
|
err := k.cdc.UnmarshalBinaryBare(value, &result)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if result.ValidatorPeriod < req.StartingHeight || result.ValidatorPeriod > req.EndingHeight {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if accumulate {
|
||||||
|
events = append(events, result)
|
||||||
|
}
|
||||||
|
return true, nil
|
||||||
|
})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return &types.QueryValidatorSlashesResponse{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &types.QueryValidatorSlashesResponse{Slashes: events, Res: res}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelegationRewards the total rewards accrued by a delegation
|
||||||
|
func (k Keeper) DelegationRewards(c context.Context, req *types.QueryDelegationRewardsRequest) (*types.QueryDelegationRewardsResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.DelegatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty delegator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.ValidatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty validator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
|
||||||
|
val := k.stakingKeeper.Validator(ctx, req.ValidatorAddress)
|
||||||
|
if val == nil {
|
||||||
|
return nil, sdkerrors.Wrap(types.ErrNoValidatorExists, req.ValidatorAddress.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
del := k.stakingKeeper.Delegation(ctx, req.DelegatorAddress, req.ValidatorAddress)
|
||||||
|
if del == nil {
|
||||||
|
return nil, types.ErrNoDelegationExists
|
||||||
|
}
|
||||||
|
|
||||||
|
endingPeriod := k.IncrementValidatorPeriod(ctx, val)
|
||||||
|
rewards := k.CalculateDelegationRewards(ctx, val, del, endingPeriod)
|
||||||
|
|
||||||
|
return &types.QueryDelegationRewardsResponse{Rewards: rewards}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelegationTotalRewards the total rewards accrued by a each validator
|
||||||
|
func (k Keeper) DelegationTotalRewards(c context.Context, req *types.QueryDelegationTotalRewardsRequest) (*types.QueryDelegationTotalRewardsResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.DelegatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty delegator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
|
||||||
|
total := sdk.DecCoins{}
|
||||||
|
var delRewards []types.DelegationDelegatorReward
|
||||||
|
|
||||||
|
k.stakingKeeper.IterateDelegations(
|
||||||
|
ctx, req.DelegatorAddress,
|
||||||
|
func(_ int64, del exported.DelegationI) (stop bool) {
|
||||||
|
valAddr := del.GetValidatorAddr()
|
||||||
|
val := k.stakingKeeper.Validator(ctx, valAddr)
|
||||||
|
endingPeriod := k.IncrementValidatorPeriod(ctx, val)
|
||||||
|
delReward := k.CalculateDelegationRewards(ctx, val, del, endingPeriod)
|
||||||
|
|
||||||
|
delRewards = append(delRewards, types.NewDelegationDelegatorReward(valAddr, delReward))
|
||||||
|
total = total.Add(delReward...)
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
return &types.QueryDelegationTotalRewardsResponse{Rewards: delRewards, Total: total}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelegatorValidators queries the validators list of a delegator
|
||||||
|
func (k Keeper) DelegatorValidators(c context.Context, req *types.QueryDelegatorValidatorsRequest) (*types.QueryDelegatorValidatorsResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.DelegatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty delegator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
|
||||||
|
var validators []sdk.ValAddress
|
||||||
|
|
||||||
|
k.stakingKeeper.IterateDelegations(
|
||||||
|
ctx, req.DelegatorAddress,
|
||||||
|
func(_ int64, del exported.DelegationI) (stop bool) {
|
||||||
|
validators = append(validators, del.GetValidatorAddr())
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
return &types.QueryDelegatorValidatorsResponse{Validators: validators}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DelegatorWithdrawAddress queries Query/delegatorWithdrawAddress
|
||||||
|
func (k Keeper) DelegatorWithdrawAddress(c context.Context, req *types.QueryDelegatorWithdrawAddressRequest) (*types.QueryDelegatorWithdrawAddressResponse, error) {
|
||||||
|
if req == nil {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "invalid request")
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.DelegatorAddress.Empty() {
|
||||||
|
return nil, status.Error(codes.InvalidArgument, "empty delegator address")
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
withdrawAddr := k.GetDelegatorWithdrawAddr(ctx, req.DelegatorAddress)
|
||||||
|
|
||||||
|
return &types.QueryDelegatorWithdrawAddressResponse{WithdrawAddress: withdrawAddr}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CommunityPool queries the community pool coins
|
||||||
|
func (k Keeper) CommunityPool(c context.Context, req *types.QueryCommunityPoolRequest) (*types.QueryCommunityPoolResponse, error) {
|
||||||
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
|
pool := k.GetFeePoolCommunityCoins(ctx)
|
||||||
|
|
||||||
|
return &types.QueryCommunityPoolResponse{Pool: pool}, nil
|
||||||
|
}
|
|
@ -0,0 +1,661 @@
|
||||||
|
package keeper_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
gocontext "context"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||||
|
"github.com/cosmos/cosmos-sdk/simapp"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/types/query"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||||
|
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||||
|
"github.com/stretchr/testify/suite"
|
||||||
|
abci "github.com/tendermint/tendermint/abci/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
type KeeperTestSuite struct {
|
||||||
|
suite.Suite
|
||||||
|
|
||||||
|
app *simapp.SimApp
|
||||||
|
ctx sdk.Context
|
||||||
|
queryClient types.QueryClient
|
||||||
|
addrs []sdk.AccAddress
|
||||||
|
valAddrs []sdk.ValAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) SetupTest() {
|
||||||
|
app := simapp.Setup(false)
|
||||||
|
ctx := app.BaseApp.NewContext(false, abci.Header{})
|
||||||
|
|
||||||
|
queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
|
||||||
|
types.RegisterQueryServer(queryHelper, app.DistrKeeper)
|
||||||
|
queryClient := types.NewQueryClient(queryHelper)
|
||||||
|
|
||||||
|
suite.app = app
|
||||||
|
suite.ctx = ctx
|
||||||
|
suite.queryClient = queryClient
|
||||||
|
|
||||||
|
suite.addrs = simapp.AddTestAddrs(app, ctx, 2, sdk.NewInt(1000000000))
|
||||||
|
suite.valAddrs = simapp.ConvertAddrsToValAddrs(suite.addrs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) TestGRPCParams() {
|
||||||
|
app, ctx, queryClient := suite.app, suite.ctx, suite.queryClient
|
||||||
|
|
||||||
|
var (
|
||||||
|
params types.Params
|
||||||
|
req *types.QueryParamsRequest
|
||||||
|
expParams types.Params
|
||||||
|
)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty params request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryParamsRequest{}
|
||||||
|
expParams = types.DefaultParams()
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"valid request",
|
||||||
|
func() {
|
||||||
|
params = types.Params{
|
||||||
|
CommunityTax: sdk.NewDecWithPrec(3, 1),
|
||||||
|
BaseProposerReward: sdk.NewDecWithPrec(2, 1),
|
||||||
|
BonusProposerReward: sdk.NewDecWithPrec(1, 1),
|
||||||
|
WithdrawAddrEnabled: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
app.DistrKeeper.SetParams(ctx, params)
|
||||||
|
req = &types.QueryParamsRequest{}
|
||||||
|
expParams = params
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
paramsRes, err := queryClient.Params(gocontext.Background(), req)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().NotNil(paramsRes)
|
||||||
|
suite.Require().Equal(paramsRes.Params, expParams)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) TestGRPCValidatorOutstandingRewards() {
|
||||||
|
app, ctx, queryClient, valAddrs := suite.app, suite.ctx, suite.queryClient, suite.valAddrs
|
||||||
|
|
||||||
|
valCommission := sdk.DecCoins{
|
||||||
|
sdk.NewDecCoinFromDec("mytoken", sdk.NewDec(5000)),
|
||||||
|
sdk.NewDecCoinFromDec("stake", sdk.NewDec(300)),
|
||||||
|
}
|
||||||
|
|
||||||
|
// set outstanding rewards
|
||||||
|
app.DistrKeeper.SetValidatorOutstandingRewards(ctx, valAddrs[0], types.ValidatorOutstandingRewards{Rewards: valCommission})
|
||||||
|
rewards := app.DistrKeeper.GetValidatorOutstandingRewards(ctx, valAddrs[0])
|
||||||
|
|
||||||
|
var req *types.QueryValidatorOutstandingRewardsRequest
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryValidatorOutstandingRewardsRequest{}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
}, {
|
||||||
|
"valid request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryValidatorOutstandingRewardsRequest{ValidatorAddress: valAddrs[0]}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
validatorOutstandingRewards, err := queryClient.ValidatorOutstandingRewards(gocontext.Background(), req)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(rewards, validatorOutstandingRewards.Rewards)
|
||||||
|
suite.Require().Equal(valCommission, validatorOutstandingRewards.Rewards.Rewards)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(validatorOutstandingRewards)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) TestGRPCValidatorCommission() {
|
||||||
|
app, ctx, queryClient, valAddrs := suite.app, suite.ctx, suite.queryClient, suite.valAddrs
|
||||||
|
|
||||||
|
commission := sdk.DecCoins{{Denom: "token1", Amount: sdk.NewDec(4)}, {Denom: "token2", Amount: sdk.NewDec(2)}}
|
||||||
|
app.DistrKeeper.SetValidatorAccumulatedCommission(ctx, valAddrs[0], types.ValidatorAccumulatedCommission{Commission: commission})
|
||||||
|
|
||||||
|
var req *types.QueryValidatorCommissionRequest
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryValidatorCommissionRequest{}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"valid request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryValidatorCommissionRequest{ValidatorAddress: valAddrs[0]}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
commissionRes, err := queryClient.ValidatorCommission(gocontext.Background(), req)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().NotNil(commissionRes)
|
||||||
|
suite.Require().Equal(commissionRes.Commission.Commission, commission)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(commissionRes)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) TestGRPCValidatorSlashes() {
|
||||||
|
app, ctx, queryClient, valAddrs := suite.app, suite.ctx, suite.queryClient, suite.valAddrs
|
||||||
|
|
||||||
|
slashes := []types.ValidatorSlashEvent{
|
||||||
|
types.NewValidatorSlashEvent(3, sdk.NewDecWithPrec(5, 1)),
|
||||||
|
types.NewValidatorSlashEvent(5, sdk.NewDecWithPrec(5, 1)),
|
||||||
|
types.NewValidatorSlashEvent(7, sdk.NewDecWithPrec(5, 1)),
|
||||||
|
types.NewValidatorSlashEvent(9, sdk.NewDecWithPrec(5, 1)),
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, slash := range slashes {
|
||||||
|
app.DistrKeeper.SetValidatorSlashEvent(ctx, valAddrs[0], uint64(i+2), 0, slash)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
req *types.QueryValidatorSlashesRequest
|
||||||
|
expRes *types.QueryValidatorSlashesResponse
|
||||||
|
)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryValidatorSlashesRequest{}
|
||||||
|
expRes = &types.QueryValidatorSlashesResponse{}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Ending height lesser than start height request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryValidatorSlashesRequest{
|
||||||
|
ValidatorAddress: valAddrs[1],
|
||||||
|
StartingHeight: 10,
|
||||||
|
EndingHeight: 1,
|
||||||
|
}
|
||||||
|
expRes = &types.QueryValidatorSlashesResponse{Res: &query.PageResponse{}}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"no slash event validator request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryValidatorSlashesRequest{
|
||||||
|
ValidatorAddress: valAddrs[1],
|
||||||
|
StartingHeight: 1,
|
||||||
|
EndingHeight: 10,
|
||||||
|
}
|
||||||
|
expRes = &types.QueryValidatorSlashesResponse{Res: &query.PageResponse{}}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"request slashes with offset 2 and limit 2",
|
||||||
|
func() {
|
||||||
|
pageReq := &query.PageRequest{
|
||||||
|
Offset: 2,
|
||||||
|
Limit: 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
req = &types.QueryValidatorSlashesRequest{
|
||||||
|
ValidatorAddress: valAddrs[0],
|
||||||
|
StartingHeight: 1,
|
||||||
|
EndingHeight: 10,
|
||||||
|
Req: pageReq,
|
||||||
|
}
|
||||||
|
|
||||||
|
expRes = &types.QueryValidatorSlashesResponse{
|
||||||
|
Slashes: slashes[2:],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"request slashes with page limit 3 and count total",
|
||||||
|
func() {
|
||||||
|
pageReq := &query.PageRequest{
|
||||||
|
Limit: 3,
|
||||||
|
CountTotal: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
req = &types.QueryValidatorSlashesRequest{
|
||||||
|
ValidatorAddress: valAddrs[0],
|
||||||
|
StartingHeight: 1,
|
||||||
|
EndingHeight: 10,
|
||||||
|
Req: pageReq,
|
||||||
|
}
|
||||||
|
|
||||||
|
expRes = &types.QueryValidatorSlashesResponse{
|
||||||
|
Slashes: slashes[:3],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"request slashes with page limit 4 and count total",
|
||||||
|
func() {
|
||||||
|
pageReq := &query.PageRequest{
|
||||||
|
Limit: 4,
|
||||||
|
CountTotal: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
req = &types.QueryValidatorSlashesRequest{
|
||||||
|
ValidatorAddress: valAddrs[0],
|
||||||
|
StartingHeight: 1,
|
||||||
|
EndingHeight: 10,
|
||||||
|
Req: pageReq,
|
||||||
|
}
|
||||||
|
|
||||||
|
expRes = &types.QueryValidatorSlashesResponse{
|
||||||
|
Slashes: slashes[:4],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
slashesRes, err := queryClient.ValidatorSlashes(gocontext.Background(), req)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(expRes.GetSlashes(), slashesRes.GetSlashes())
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(slashesRes)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) TestGRPCDelegationRewards() {
|
||||||
|
app, ctx, addrs, valAddrs := suite.app, suite.ctx, suite.addrs, suite.valAddrs
|
||||||
|
|
||||||
|
sh := staking.NewHandler(app.StakingKeeper)
|
||||||
|
comm := stakingtypes.NewCommissionRates(sdk.NewDecWithPrec(5, 1), sdk.NewDecWithPrec(5, 1), sdk.NewDec(0))
|
||||||
|
msg := stakingtypes.NewMsgCreateValidator(
|
||||||
|
valAddrs[0], valConsPk1, sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), stakingtypes.Description{}, comm, sdk.OneInt(),
|
||||||
|
)
|
||||||
|
|
||||||
|
res, err := sh(ctx, msg)
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().NotNil(res)
|
||||||
|
|
||||||
|
staking.EndBlocker(ctx, app.StakingKeeper)
|
||||||
|
ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1)
|
||||||
|
|
||||||
|
queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry())
|
||||||
|
types.RegisterQueryServer(queryHelper, app.DistrKeeper)
|
||||||
|
queryClient := types.NewQueryClient(queryHelper)
|
||||||
|
|
||||||
|
val := app.StakingKeeper.Validator(ctx, valAddrs[0])
|
||||||
|
|
||||||
|
initial := int64(10)
|
||||||
|
tokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial)}}
|
||||||
|
app.DistrKeeper.AllocateTokensToValidator(ctx, val, tokens)
|
||||||
|
|
||||||
|
// test command delegation rewards grpc
|
||||||
|
var (
|
||||||
|
req *types.QueryDelegationRewardsRequest
|
||||||
|
expRes *types.QueryDelegationRewardsResponse
|
||||||
|
)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryDelegationRewardsRequest{}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"empty delegator request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryDelegationRewardsRequest{
|
||||||
|
DelegatorAddress: nil,
|
||||||
|
ValidatorAddress: valAddrs[0],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"empty validator request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryDelegationRewardsRequest{
|
||||||
|
DelegatorAddress: addrs[1],
|
||||||
|
ValidatorAddress: nil,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"request with wrong delegator and validator",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryDelegationRewardsRequest{
|
||||||
|
DelegatorAddress: addrs[1],
|
||||||
|
ValidatorAddress: valAddrs[1],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"valid request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryDelegationRewardsRequest{
|
||||||
|
DelegatorAddress: addrs[0],
|
||||||
|
ValidatorAddress: valAddrs[0],
|
||||||
|
}
|
||||||
|
|
||||||
|
expRes = &types.QueryDelegationRewardsResponse{
|
||||||
|
Rewards: sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
rewards, err := queryClient.DelegationRewards(gocontext.Background(), req)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(expRes, rewards)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(rewards)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// test command delegator total rewards grpc
|
||||||
|
var (
|
||||||
|
totalRewardsReq *types.QueryDelegationTotalRewardsRequest
|
||||||
|
expTotalRewardsRes *types.QueryDelegationTotalRewardsResponse
|
||||||
|
)
|
||||||
|
|
||||||
|
testCases = []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty request",
|
||||||
|
func() {
|
||||||
|
totalRewardsReq = &types.QueryDelegationTotalRewardsRequest{}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"valid total delegation rewards",
|
||||||
|
func() {
|
||||||
|
totalRewardsReq = &types.QueryDelegationTotalRewardsRequest{
|
||||||
|
DelegatorAddress: addrs[0],
|
||||||
|
}
|
||||||
|
|
||||||
|
expectedDelReward := types.NewDelegationDelegatorReward(valAddrs[0],
|
||||||
|
sdk.DecCoins{sdk.NewInt64DecCoin("stake", 5)})
|
||||||
|
|
||||||
|
expTotalRewardsRes = &types.QueryDelegationTotalRewardsResponse{
|
||||||
|
Rewards: []types.DelegationDelegatorReward{expectedDelReward},
|
||||||
|
Total: expectedDelReward.Reward,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
totalRewardsRes, err := queryClient.DelegationTotalRewards(gocontext.Background(), totalRewardsReq)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(totalRewardsRes, expTotalRewardsRes)
|
||||||
|
} else {
|
||||||
|
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(totalRewardsRes)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// test command validator delegators grpc
|
||||||
|
var (
|
||||||
|
delegatorValidatorsReq *types.QueryDelegatorValidatorsRequest
|
||||||
|
expDelegatorValidatorsRes *types.QueryDelegatorValidatorsResponse
|
||||||
|
)
|
||||||
|
|
||||||
|
testCases = []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty request",
|
||||||
|
func() {
|
||||||
|
delegatorValidatorsReq = &types.QueryDelegatorValidatorsRequest{}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"request no delegations address",
|
||||||
|
func() {
|
||||||
|
delegatorValidatorsReq = &types.QueryDelegatorValidatorsRequest{
|
||||||
|
DelegatorAddress: addrs[1],
|
||||||
|
}
|
||||||
|
|
||||||
|
expDelegatorValidatorsRes = &types.QueryDelegatorValidatorsResponse{}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"valid request",
|
||||||
|
func() {
|
||||||
|
delegatorValidatorsReq = &types.QueryDelegatorValidatorsRequest{
|
||||||
|
DelegatorAddress: addrs[0],
|
||||||
|
}
|
||||||
|
expDelegatorValidatorsRes = &types.QueryDelegatorValidatorsResponse{
|
||||||
|
Validators: valAddrs[:1],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
validators, err := queryClient.DelegatorValidators(gocontext.Background(), delegatorValidatorsReq)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(validators, expDelegatorValidatorsRes)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(validators)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) TestGRPCDelegatorWithdrawAddress() {
|
||||||
|
app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs
|
||||||
|
|
||||||
|
err := app.DistrKeeper.SetWithdrawAddr(ctx, addrs[0], addrs[1])
|
||||||
|
suite.Require().Nil(err)
|
||||||
|
|
||||||
|
var req *types.QueryDelegatorWithdrawAddressRequest
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"empty request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryDelegatorWithdrawAddressRequest{}
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"valid request",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryDelegatorWithdrawAddressRequest{DelegatorAddress: addrs[0]}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
withdrawAddress, err := queryClient.DelegatorWithdrawAddress(gocontext.Background(), req)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(withdrawAddress.WithdrawAddress, addrs[1])
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(withdrawAddress)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (suite *KeeperTestSuite) TestGRPCCommunityPool() {
|
||||||
|
app, ctx, queryClient, addrs := suite.app, suite.ctx, suite.queryClient, suite.addrs
|
||||||
|
|
||||||
|
var (
|
||||||
|
req *types.QueryCommunityPoolRequest
|
||||||
|
expPool *types.QueryCommunityPoolResponse
|
||||||
|
)
|
||||||
|
|
||||||
|
testCases := []struct {
|
||||||
|
msg string
|
||||||
|
malleate func()
|
||||||
|
expPass bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"valid request empty community pool",
|
||||||
|
func() {
|
||||||
|
req = &types.QueryCommunityPoolRequest{}
|
||||||
|
expPool = &types.QueryCommunityPoolResponse{}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"valid request",
|
||||||
|
func() {
|
||||||
|
amount := sdk.NewCoins(sdk.NewInt64Coin("stake", 100))
|
||||||
|
suite.Require().NoError(app.BankKeeper.SetBalances(ctx, addrs[0], amount))
|
||||||
|
|
||||||
|
err := app.DistrKeeper.FundCommunityPool(ctx, amount, addrs[0])
|
||||||
|
suite.Require().Nil(err)
|
||||||
|
req = &types.QueryCommunityPoolRequest{}
|
||||||
|
|
||||||
|
expPool = &types.QueryCommunityPoolResponse{Pool: sdk.NewDecCoinsFromCoins(amount...)}
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, testCase := range testCases {
|
||||||
|
suite.Run(fmt.Sprintf("Case %s", testCase.msg), func() {
|
||||||
|
testCase.malleate()
|
||||||
|
|
||||||
|
pool, err := queryClient.CommunityPool(gocontext.Background(), req)
|
||||||
|
|
||||||
|
if testCase.expPass {
|
||||||
|
suite.Require().NoError(err)
|
||||||
|
suite.Require().Equal(expPool, pool)
|
||||||
|
} else {
|
||||||
|
suite.Require().Error(err)
|
||||||
|
suite.Require().Nil(pool)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestDistributionTestSuite(t *testing.T) {
|
||||||
|
suite.Run(t, new(KeeperTestSuite))
|
||||||
|
}
|
|
@ -134,7 +134,9 @@ func (am AppModule) NewQuerierHandler() sdk.Querier {
|
||||||
return keeper.NewQuerier(am.keeper)
|
return keeper.NewQuerier(am.keeper)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (am AppModule) RegisterQueryService(grpc.Server) {}
|
func (am AppModule) RegisterQueryService(server grpc.Server) {
|
||||||
|
types.RegisterQueryServer(server, am.keeper)
|
||||||
|
}
|
||||||
|
|
||||||
// InitGenesis performs genesis initialization for the distribution module. It returns
|
// InitGenesis performs genesis initialization for the distribution module. It returns
|
||||||
// no validator updates.
|
// no validator updates.
|
||||||
|
|
|
@ -727,6 +727,60 @@ func (m *DelegatorStartingInfo) GetHeight() uint64 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DelegationDelegatorReward defines the properties
|
||||||
|
// of a delegator's delegation reward.
|
||||||
|
type DelegationDelegatorReward struct {
|
||||||
|
ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"`
|
||||||
|
Reward github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,2,rep,name=reward,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"reward"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DelegationDelegatorReward) Reset() { *m = DelegationDelegatorReward{} }
|
||||||
|
func (m *DelegationDelegatorReward) String() string { return proto.CompactTextString(m) }
|
||||||
|
func (*DelegationDelegatorReward) ProtoMessage() {}
|
||||||
|
func (*DelegationDelegatorReward) Descriptor() ([]byte, []int) {
|
||||||
|
return fileDescriptor_49870d4e3df20cf9, []int{14}
|
||||||
|
}
|
||||||
|
func (m *DelegationDelegatorReward) XXX_Unmarshal(b []byte) error {
|
||||||
|
return m.Unmarshal(b)
|
||||||
|
}
|
||||||
|
func (m *DelegationDelegatorReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||||
|
if deterministic {
|
||||||
|
return xxx_messageInfo_DelegationDelegatorReward.Marshal(b, m, deterministic)
|
||||||
|
} else {
|
||||||
|
b = b[:cap(b)]
|
||||||
|
n, err := m.MarshalToSizedBuffer(b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return b[:n], nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func (m *DelegationDelegatorReward) XXX_Merge(src proto.Message) {
|
||||||
|
xxx_messageInfo_DelegationDelegatorReward.Merge(m, src)
|
||||||
|
}
|
||||||
|
func (m *DelegationDelegatorReward) XXX_Size() int {
|
||||||
|
return m.Size()
|
||||||
|
}
|
||||||
|
func (m *DelegationDelegatorReward) XXX_DiscardUnknown() {
|
||||||
|
xxx_messageInfo_DelegationDelegatorReward.DiscardUnknown(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var xxx_messageInfo_DelegationDelegatorReward proto.InternalMessageInfo
|
||||||
|
|
||||||
|
func (m *DelegationDelegatorReward) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress {
|
||||||
|
if m != nil {
|
||||||
|
return m.ValidatorAddress
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DelegationDelegatorReward) GetReward() github_com_cosmos_cosmos_sdk_types.DecCoins {
|
||||||
|
if m != nil {
|
||||||
|
return m.Reward
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
proto.RegisterType((*MsgSetWithdrawAddress)(nil), "cosmos.distribution.MsgSetWithdrawAddress")
|
proto.RegisterType((*MsgSetWithdrawAddress)(nil), "cosmos.distribution.MsgSetWithdrawAddress")
|
||||||
proto.RegisterType((*MsgWithdrawDelegatorReward)(nil), "cosmos.distribution.MsgWithdrawDelegatorReward")
|
proto.RegisterType((*MsgWithdrawDelegatorReward)(nil), "cosmos.distribution.MsgWithdrawDelegatorReward")
|
||||||
|
@ -742,6 +796,7 @@ func init() {
|
||||||
proto.RegisterType((*FeePool)(nil), "cosmos.distribution.FeePool")
|
proto.RegisterType((*FeePool)(nil), "cosmos.distribution.FeePool")
|
||||||
proto.RegisterType((*CommunityPoolSpendProposal)(nil), "cosmos.distribution.CommunityPoolSpendProposal")
|
proto.RegisterType((*CommunityPoolSpendProposal)(nil), "cosmos.distribution.CommunityPoolSpendProposal")
|
||||||
proto.RegisterType((*DelegatorStartingInfo)(nil), "cosmos.distribution.DelegatorStartingInfo")
|
proto.RegisterType((*DelegatorStartingInfo)(nil), "cosmos.distribution.DelegatorStartingInfo")
|
||||||
|
proto.RegisterType((*DelegationDelegatorReward)(nil), "cosmos.distribution.DelegationDelegatorReward")
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -749,76 +804,78 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var fileDescriptor_49870d4e3df20cf9 = []byte{
|
var fileDescriptor_49870d4e3df20cf9 = []byte{
|
||||||
// 1098 bytes of a gzipped FileDescriptorProto
|
// 1126 bytes of a gzipped FileDescriptorProto
|
||||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xcd, 0x6f, 0x1b, 0x45,
|
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xcd, 0x6f, 0x1b, 0x45,
|
||||||
0x14, 0xf7, 0x38, 0x6e, 0x9a, 0x4c, 0xd3, 0xa4, 0xdd, 0xd8, 0x49, 0xe4, 0x80, 0x37, 0x1a, 0x89,
|
0x14, 0xf7, 0xb8, 0xae, 0x9b, 0x4c, 0xd3, 0xa4, 0xdd, 0xd8, 0x49, 0x70, 0xc0, 0x1b, 0x8d, 0x44,
|
||||||
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0, 0x1a, 0x57, 0x85, 0xae, 0xce, 0x34, 0x5c, 0x5d, 0x1b, 0x98, 0x73, 0x5a, 0x73, 0xf6,
|
||||||
0x1c, 0x2b, 0x32, 0x6f, 0x19, 0xab, 0x79, 0x51, 0x0f, 0x01, 0x2c, 0x35, 0x58, 0xd0, 0x16, 0x17,
|
0xc3, 0x44, 0x8e, 0x15, 0x99, 0x37, 0x8c, 0xd5, 0xdc, 0xa8, 0x07, 0x00, 0x16, 0xeb, 0x2c, 0x68,
|
||||||
0x24, 0x0c, 0x29, 0x09, 0xef, 0x0d, 0x2c, 0xe1, 0x15, 0x23, 0xa1, 0x1f, 0x28, 0x72, 0x26, 0x95,
|
0x89, 0x33, 0x12, 0xae, 0x28, 0x09, 0xef, 0x0e, 0x2c, 0xe1, 0x65, 0x23, 0xa1, 0x1f, 0x28, 0x72,
|
||||||
0xbd, 0x47, 0xc4, 0x0e, 0x2c, 0x75, 0x35, 0x93, 0x3a, 0x09, 0x70, 0xc3, 0x27, 0xde, 0x4c, 0x61,
|
0xc6, 0x95, 0xbd, 0x47, 0xc4, 0x16, 0x2c, 0x76, 0x35, 0x93, 0x1a, 0x09, 0x70, 0xdd, 0x27, 0xde,
|
||||||
0x0e, 0xcc, 0x8f, 0xd4, 0xe6, 0x52, 0xd4, 0xbe, 0x6e, 0xc8, 0x99, 0xcc, 0xf6, 0x91, 0x35, 0x6d,
|
0x54, 0x6e, 0x06, 0xcc, 0x0e, 0x55, 0x67, 0x52, 0xd4, 0xbe, 0x6e, 0xc8, 0x19, 0xef, 0xec, 0x23,
|
||||||
0x5d, 0x2a, 0x7c, 0xfb, 0xd8, 0xce, 0xa1, 0x87, 0x79, 0x58, 0x4e, 0xde, 0xcb, 0xdb, 0x54, 0x48,
|
0x2b, 0xda, 0xba, 0x90, 0xfb, 0xf6, 0x91, 0x9d, 0x41, 0x0f, 0xb2, 0xb0, 0x94, 0xdc, 0x97, 0xb7,
|
||||||
0xc6, 0xa9, 0x8b, 0x7d, 0xcd, 0x2c, 0xac, 0xef, 0x01, 0x9c, 0x76, 0xdb, 0xad, 0xb6, 0x8f, 0x25,
|
0xa8, 0x90, 0x8c, 0x53, 0x17, 0xfb, 0x9a, 0x59, 0x58, 0xdf, 0x03, 0x38, 0xe9, 0xb6, 0x9a, 0x2d,
|
||||||
0x3d, 0x24, 0x46, 0x66, 0x9d, 0x63, 0x49, 0x99, 0xa9, 0xd9, 0x89, 0xb8, 0x66, 0x57, 0x89, 0xab,
|
0x1f, 0x4b, 0xba, 0x4f, 0x8c, 0xcc, 0x1a, 0xc7, 0x92, 0x32, 0x53, 0xb3, 0x63, 0x71, 0xcd, 0x2e,
|
||||||
0xca, 0xf6, 0xfd, 0x28, 0x24, 0xe7, 0x1d, 0xbb, 0x62, 0xf2, 0xdb, 0xff, 0x34, 0x7a, 0xf2, 0xdc,
|
0x13, 0x57, 0x95, 0xed, 0x7b, 0x51, 0x48, 0x4e, 0xdb, 0x76, 0xd9, 0xe4, 0xb7, 0xff, 0x6e, 0xf4,
|
||||||
0x7e, 0xfd, 0x72, 0x41, 0xd3, 0xb5, 0x5d, 0x4a, 0x81, 0xb4, 0x38, 0x27, 0x82, 0xb1, 0x56, 0xe0,
|
0xf8, 0x99, 0xfd, 0xda, 0xf9, 0x82, 0xa6, 0x6b, 0xbb, 0x98, 0x02, 0x69, 0x71, 0x4e, 0x04, 0x63,
|
||||||
0x04, 0x27, 0x7b, 0x84, 0x93, 0xc0, 0x25, 0x75, 0x57, 0xbd, 0xa5, 0xa8, 0x38, 0x6e, 0xd6, 0xca,
|
0x2d, 0xc1, 0x31, 0x4e, 0x76, 0x08, 0x27, 0x81, 0x4b, 0x6a, 0xae, 0xba, 0x4b, 0x51, 0x71, 0xdc,
|
||||||
0xe7, 0x1d, 0x7b, 0x4a, 0x4b, 0xe8, 0x71, 0x40, 0xce, 0x78, 0x62, 0x59, 0x51, 0x86, 0xaf, 0x01,
|
0xa8, 0x96, 0x4e, 0xdb, 0xf6, 0x84, 0x96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 0x00, 0x00,
|
0xe9, 0x49, 0x39, 0xf3, 0xeb, 0x49, 0x39, 0xf3, 0xc1, 0x9d, 0x7f, 0x85, 0x3c, 0xec, 0xfe, 0x5b,
|
||||||
|
0xa6, 0x18, 0xea, 0x79, 0xf5, 0x87, 0xea, 0xee, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xd9, 0xca,
|
||||||
|
0xc4, 0x1b, 0xba, 0x0d, 0x00, 0x00,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *MsgSetWithdrawAddress) Equal(that interface{}) bool {
|
func (this *MsgSetWithdrawAddress) Equal(that interface{}) bool {
|
||||||
|
@ -1239,6 +1296,38 @@ func (this *DelegatorStartingInfo) Equal(that interface{}) bool {
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
func (this *DelegationDelegatorReward) Equal(that interface{}) bool {
|
||||||
|
if that == nil {
|
||||||
|
return this == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
that1, ok := that.(*DelegationDelegatorReward)
|
||||||
|
if !ok {
|
||||||
|
that2, ok := that.(DelegationDelegatorReward)
|
||||||
|
if ok {
|
||||||
|
that1 = &that2
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if that1 == nil {
|
||||||
|
return this == nil
|
||||||
|
} else if this == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if !bytes.Equal(this.ValidatorAddress, that1.ValidatorAddress) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if len(this.Reward) != len(that1.Reward) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
for i := range this.Reward {
|
||||||
|
if !this.Reward[i].Equal(&that1.Reward[i]) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
func (m *MsgSetWithdrawAddress) Marshal() (dAtA []byte, err error) {
|
func (m *MsgSetWithdrawAddress) Marshal() (dAtA []byte, err error) {
|
||||||
size := m.Size()
|
size := m.Size()
|
||||||
dAtA = make([]byte, size)
|
dAtA = make([]byte, size)
|
||||||
|
@ -1821,6 +1910,50 @@ func (m *DelegatorStartingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
return len(dAtA) - i, nil
|
return len(dAtA) - i, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *DelegationDelegatorReward) Marshal() (dAtA []byte, err error) {
|
||||||
|
size := m.Size()
|
||||||
|
dAtA = make([]byte, size)
|
||||||
|
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return dAtA[:n], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DelegationDelegatorReward) MarshalTo(dAtA []byte) (int, error) {
|
||||||
|
size := m.Size()
|
||||||
|
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *DelegationDelegatorReward) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||||
|
i := len(dAtA)
|
||||||
|
_ = i
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
if len(m.Reward) > 0 {
|
||||||
|
for iNdEx := len(m.Reward) - 1; iNdEx >= 0; iNdEx-- {
|
||||||
|
{
|
||||||
|
size, err := m.Reward[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
i -= size
|
||||||
|
i = encodeVarintDistribution(dAtA, i, uint64(size))
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0x12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(m.ValidatorAddress) > 0 {
|
||||||
|
i -= len(m.ValidatorAddress)
|
||||||
|
copy(dAtA[i:], m.ValidatorAddress)
|
||||||
|
i = encodeVarintDistribution(dAtA, i, uint64(len(m.ValidatorAddress)))
|
||||||
|
i--
|
||||||
|
dAtA[i] = 0xa
|
||||||
|
}
|
||||||
|
return len(dAtA) - i, nil
|
||||||
|
}
|
||||||
|
|
||||||
func encodeVarintDistribution(dAtA []byte, offset int, v uint64) int {
|
func encodeVarintDistribution(dAtA []byte, offset int, v uint64) int {
|
||||||
offset -= sovDistribution(v)
|
offset -= sovDistribution(v)
|
||||||
base := offset
|
base := offset
|
||||||
|
@ -2070,6 +2203,25 @@ func (m *DelegatorStartingInfo) Size() (n int) {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *DelegationDelegatorReward) Size() (n int) {
|
||||||
|
if m == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
var l int
|
||||||
|
_ = l
|
||||||
|
l = len(m.ValidatorAddress)
|
||||||
|
if l > 0 {
|
||||||
|
n += 1 + l + sovDistribution(uint64(l))
|
||||||
|
}
|
||||||
|
if len(m.Reward) > 0 {
|
||||||
|
for _, e := range m.Reward {
|
||||||
|
l = e.Size()
|
||||||
|
n += 1 + l + sovDistribution(uint64(l))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
func sovDistribution(x uint64) (n int) {
|
func sovDistribution(x uint64) (n int) {
|
||||||
return (math_bits.Len64(x|1) + 6) / 7
|
return (math_bits.Len64(x|1) + 6) / 7
|
||||||
}
|
}
|
||||||
|
@ -3677,6 +3829,127 @@ func (m *DelegatorStartingInfo) Unmarshal(dAtA []byte) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (m *DelegationDelegatorReward) Unmarshal(dAtA []byte) error {
|
||||||
|
l := len(dAtA)
|
||||||
|
iNdEx := 0
|
||||||
|
for iNdEx < l {
|
||||||
|
preIndex := iNdEx
|
||||||
|
var wire uint64
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowDistribution
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
wire |= uint64(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fieldNum := int32(wire >> 3)
|
||||||
|
wireType := int(wire & 0x7)
|
||||||
|
if wireType == 4 {
|
||||||
|
return fmt.Errorf("proto: DelegationDelegatorReward: wiretype end group for non-group")
|
||||||
|
}
|
||||||
|
if fieldNum <= 0 {
|
||||||
|
return fmt.Errorf("proto: DelegationDelegatorReward: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||||
|
}
|
||||||
|
switch fieldNum {
|
||||||
|
case 1:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType)
|
||||||
|
}
|
||||||
|
var byteLen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowDistribution
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
byteLen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if byteLen < 0 {
|
||||||
|
return ErrInvalidLengthDistribution
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + byteLen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthDistribution
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...)
|
||||||
|
if m.ValidatorAddress == nil {
|
||||||
|
m.ValidatorAddress = []byte{}
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
case 2:
|
||||||
|
if wireType != 2 {
|
||||||
|
return fmt.Errorf("proto: wrong wireType = %d for field Reward", wireType)
|
||||||
|
}
|
||||||
|
var msglen int
|
||||||
|
for shift := uint(0); ; shift += 7 {
|
||||||
|
if shift >= 64 {
|
||||||
|
return ErrIntOverflowDistribution
|
||||||
|
}
|
||||||
|
if iNdEx >= l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
b := dAtA[iNdEx]
|
||||||
|
iNdEx++
|
||||||
|
msglen |= int(b&0x7F) << shift
|
||||||
|
if b < 0x80 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if msglen < 0 {
|
||||||
|
return ErrInvalidLengthDistribution
|
||||||
|
}
|
||||||
|
postIndex := iNdEx + msglen
|
||||||
|
if postIndex < 0 {
|
||||||
|
return ErrInvalidLengthDistribution
|
||||||
|
}
|
||||||
|
if postIndex > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
m.Reward = append(m.Reward, types.DecCoin{})
|
||||||
|
if err := m.Reward[len(m.Reward)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
iNdEx = postIndex
|
||||||
|
default:
|
||||||
|
iNdEx = preIndex
|
||||||
|
skippy, err := skipDistribution(dAtA[iNdEx:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if skippy < 0 {
|
||||||
|
return ErrInvalidLengthDistribution
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) < 0 {
|
||||||
|
return ErrInvalidLengthDistribution
|
||||||
|
}
|
||||||
|
if (iNdEx + skippy) > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
iNdEx += skippy
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if iNdEx > l {
|
||||||
|
return io.ErrUnexpectedEOF
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func skipDistribution(dAtA []byte) (n int, err error) {
|
func skipDistribution(dAtA []byte) (n int, err error) {
|
||||||
l := len(dAtA)
|
l := len(dAtA)
|
||||||
iNdEx := 0
|
iNdEx := 0
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
import sdk "github.com/cosmos/cosmos-sdk/types"
|
import (
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
)
|
||||||
|
|
||||||
// querier keys
|
// querier keys
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -32,13 +32,6 @@ func (res QueryDelegatorTotalRewardsResponse) String() string {
|
||||||
return strings.TrimSpace(out)
|
return strings.TrimSpace(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DelegationDelegatorReward defines the properties
|
|
||||||
// of a delegator's delegation reward.
|
|
||||||
type DelegationDelegatorReward struct {
|
|
||||||
ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"`
|
|
||||||
Reward sdk.DecCoins `json:"reward" yaml:"reward"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewDelegationDelegatorReward constructs a DelegationDelegatorReward.
|
// NewDelegationDelegatorReward constructs a DelegationDelegatorReward.
|
||||||
func NewDelegationDelegatorReward(valAddr sdk.ValAddress,
|
func NewDelegationDelegatorReward(valAddr sdk.ValAddress,
|
||||||
reward sdk.DecCoins) DelegationDelegatorReward {
|
reward sdk.DecCoins) DelegationDelegatorReward {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue