github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/x/distribution/types/query.go (about) 1 package types 2 3 import ( 4 "fmt" 5 "strings" 6 7 sdk "github.com/fibonacci-chain/fbc/libs/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, 19 total sdk.DecCoins) QueryDelegatorTotalRewardsResponse { 20 return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total} 21 } 22 23 func (res QueryDelegatorTotalRewardsResponse) String() string { 24 out := "Delegator Total Rewards:\n" 25 out += " Rewards:" 26 for _, reward := range res.Rewards { 27 out += fmt.Sprintf(` 28 ValidatorAddress: %s 29 Reward: %s`, reward.ValidatorAddress, reward.Reward) 30 } 31 out += fmt.Sprintf("\n Total: %s\n", res.Total) 32 return strings.TrimSpace(out) 33 } 34 35 // DelegationDelegatorReward defines the properties 36 // of a delegator's delegation reward. 37 type DelegationDelegatorReward struct { 38 ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` 39 Reward sdk.DecCoins `json:"reward" yaml:"reward"` 40 } 41 42 // NewDelegationDelegatorReward constructs a DelegationDelegatorReward. 43 func NewDelegationDelegatorReward(valAddr sdk.ValAddress, 44 reward sdk.DecCoins) DelegationDelegatorReward { 45 return DelegationDelegatorReward{ValidatorAddress: valAddr, Reward: reward} 46 }