github.com/cosmos/cosmos-sdk@v0.50.10/x/distribution/types/query.go (about)

     1  package types
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	sdk "github.com/cosmos/cosmos-sdk/types"
     8  )
     9  
    10  // QueryDelegatorTotalRewardsResponse defines the properties of
    11  // QueryDelegatorTotalRewards query's response.
    12  type QueryDelegatorTotalRewardsResponse struct {
    13  	Rewards []DelegationDelegatorReward `json:"rewards" yaml:"rewards"`
    14  	Total   sdk.DecCoins                `json:"total" yaml:"total"`
    15  }
    16  
    17  // NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse
    18  func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, total sdk.DecCoins) QueryDelegatorTotalRewardsResponse {
    19  	return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total}
    20  }
    21  
    22  func (res QueryDelegatorTotalRewardsResponse) String() string {
    23  	out := "Delegator Total Rewards:\n"
    24  	out += "  Rewards:"
    25  	for _, reward := range res.Rewards {
    26  		out += fmt.Sprintf(`  
    27  	ValidatorAddress: %s
    28  	Reward: %s`, reward.ValidatorAddress, reward.Reward)
    29  	}
    30  	out += fmt.Sprintf("\n  Total: %s\n", res.Total)
    31  	return strings.TrimSpace(out)
    32  }
    33  
    34  // NewDelegationDelegatorReward constructs a DelegationDelegatorReward.
    35  func NewDelegationDelegatorReward(valAddr string, reward sdk.DecCoins) DelegationDelegatorReward {
    36  	return DelegationDelegatorReward{ValidatorAddress: valAddr, Reward: reward}
    37  }