2019-04-16 06:43:08 -07:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// QueryDelegatorTotalRewardsResponse defines the properties of
|
|
|
|
// QueryDelegatorTotalRewards query's response.
|
|
|
|
type QueryDelegatorTotalRewardsResponse struct {
|
2019-07-05 16:25:56 -07:00
|
|
|
Rewards []DelegationDelegatorReward `json:"rewards" yaml:"rewards"`
|
|
|
|
Total sdk.DecCoins `json:"total" yaml:"total"`
|
2019-04-16 06:43:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse
|
|
|
|
func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward,
|
|
|
|
total sdk.DecCoins) QueryDelegatorTotalRewardsResponse {
|
|
|
|
return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (res QueryDelegatorTotalRewardsResponse) String() string {
|
|
|
|
out := "Delegator Total Rewards:\n"
|
|
|
|
out += " Rewards:"
|
|
|
|
for _, reward := range res.Rewards {
|
|
|
|
out += fmt.Sprintf(`
|
|
|
|
ValidatorAddress: %s
|
|
|
|
Reward: %s`, reward.ValidatorAddress, reward.Reward)
|
|
|
|
}
|
|
|
|
out += fmt.Sprintf("\n Total: %s\n", res.Total)
|
|
|
|
return strings.TrimSpace(out)
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewDelegationDelegatorReward constructs a DelegationDelegatorReward.
|
|
|
|
func NewDelegationDelegatorReward(valAddr sdk.ValAddress,
|
|
|
|
reward sdk.DecCoins) DelegationDelegatorReward {
|
|
|
|
return DelegationDelegatorReward{ValidatorAddress: valAddr, Reward: reward}
|
|
|
|
}
|