Skip to content

Commit

Permalink
migrate NewWithdrawAllRewardsCmd to proto
Browse files Browse the repository at this point in the history
  • Loading branch information
anilcse committed Sep 5, 2020
1 parent edadee4 commit 28c8997
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions x/distribution/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cli

import (
"context"
"fmt"
"strings"

Expand All @@ -12,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/distribution/client/common"
"github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
Expand Down Expand Up @@ -158,9 +158,18 @@ $ %s tx distribution withdraw-all-rewards --from mykey
return fmt.Errorf("cannot generate tx in offline mode")
}

msgs, err := common.WithdrawAllDelegatorRewards(clientCtx, delAddr)
if err != nil {
return err
queryClient := types.NewQueryClient(clientCtx)
delValsRes, err := queryClient.DelegatorValidators(context.Background(), &types.QueryDelegatorValidatorsRequest{DelegatorAddress: delAddr})

validators := delValsRes.Validators
// build multi-message transaction
msgs := make([]sdk.Msg, 0, len(validators))
for _, valAddr := range validators {
msg := types.NewMsgWithdrawDelegatorReward(delAddr, valAddr)
if err := msg.ValidateBasic(); err != nil {
return err
}
msgs = append(msgs, msg)
}

chunkSize, _ := cmd.Flags().GetInt(FlagMaxMessagesPerTx)
Expand Down

0 comments on commit 28c8997

Please sign in to comment.