github.com/Finschia/finschia-sdk@v0.48.1/x/distribution/types/query.go (about) 1 package types 2 3 import ( 4 "fmt" 5 "strings" 6 7 sdk "github.com/Finschia/finschia-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, 19 total sdk.DecCoins, 20 ) QueryDelegatorTotalRewardsResponse { 21 return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total} 22 } 23 24 func (res QueryDelegatorTotalRewardsResponse) String() string { 25 out := "Delegator Total Rewards:\n" 26 out += " Rewards:" 27 for _, reward := range res.Rewards { 28 out += fmt.Sprintf(` 29 ValidatorAddress: %s 30 Reward: %s`, reward.ValidatorAddress, reward.Reward) 31 } 32 out += fmt.Sprintf("\n Total: %s\n", res.Total) 33 return strings.TrimSpace(out) 34 } 35 36 // NewDelegationDelegatorReward constructs a DelegationDelegatorReward. 37 // 38 //nolint:interfacer 39 func NewDelegationDelegatorReward(valAddr sdk.ValAddress, 40 reward sdk.DecCoins, 41 ) DelegationDelegatorReward { 42 return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward} 43 }