diff --git a/x/distribution/client/cli/tx.go b/x/distribution/client/cli/tx.go index 43f6ef81d2dc..323b3f2d9038 100644 --- a/x/distribution/client/cli/tx.go +++ b/x/distribution/client/cli/tx.go @@ -156,6 +156,8 @@ $ %s tx distribution withdraw-all-rewards --from mykey return newSplitAndApply(tx.GenerateOrBroadcastTx, clientCtx, msgs, chunkSize) }, } + + cmd.Flags().Int(flagMaxMessagesPerTx, MaxMessagesPerTxDefault, "Limit the number of messages per tx (0 for unlimited)") return cmd } @@ -195,25 +197,14 @@ $ %s tx distribution set-withdraw-addr cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75 func NewFundCommunityPoolCmd(clientCtx client.Context) *cobra.Command { cmd := &cobra.Command{ - Use: "community-pool-spend [proposal-file]", + Use: "fund-community-pool [amount]", Args: cobra.ExactArgs(1), - Short: "Submit a community pool spend proposal", + Short: "Funds the community pool with the specified amount", Long: strings.TrimSpace( - fmt.Sprintf(`Submit a community pool spend proposal along with an initial deposit. -The proposal details must be supplied via a JSON file. + fmt.Sprintf(`Funds the community pool with the specified amount Example: -$ %s tx gov submit-proposal community-pool-spend --from= - -Where proposal.json contains: - -{ - "title": "Community Pool Spend", - "description": "Pay me some Atoms!", - "recipient": "cosmos1s5afhd6gxevu37mkqcvvsj8qeylhn0rz46zdlq", - "amount": "1000stake", - "deposit": "1000stake" -} +$ %s tx distribution fund-community-pool 100uatom --from mykey `, version.ClientName, ), @@ -235,6 +226,7 @@ Where proposal.json contains: return tx.GenerateOrBroadcastTx(clientCtx, msg) }, } + return cmd } @@ -298,34 +290,3 @@ Where proposal.json contains: return cmd } - -type generateOrBroadcastFunc func(client.Context, []sdk.Msg) error - -func splitAndApply( - generateOrBroadcast generateOrBroadcastFunc, - clientCtx client.Context, - msgs []sdk.Msg, - chunkSize int, -) error { - - if chunkSize == 0 { - return generateOrBroadcast(clientCtx, msgs) - } - - // split messages into slices of length chunkSize - totalMessages := len(msgs) - for i := 0; i < len(msgs); i += chunkSize { - - sliceEnd := i + chunkSize - if sliceEnd > totalMessages { - sliceEnd = totalMessages - } - - msgChunk := msgs[i:sliceEnd] - if err := generateOrBroadcast(clientCtx, msgChunk); err != nil { - return err - } - } - - return nil -} diff --git a/x/distribution/client/cli/tx_test.go b/x/distribution/client/cli/tx_test.go index f7b1e58921e2..2b5f27ca563d 100644 --- a/x/distribution/client/cli/tx_test.go +++ b/x/distribution/client/cli/tx_test.go @@ -17,7 +17,7 @@ import ( func Test_splitAndCall_NoMessages(t *testing.T) { clientCtx := client.Context{} - err := splitAndApply(nil, clientCtx, nil, 10) + err := newSplitAndApply(nil, clientCtx, nil, 10) assert.NoError(t, err, "") } @@ -39,8 +39,8 @@ func Test_splitAndCall_Splitting(t *testing.T) { const chunkSize = 2 callCount := 0 - err := splitAndApply( - func(clientCtx client.Context, msgs []sdk.Msg) error { + err := newSplitAndApply( + func(clientCtx client.Context, msgs ...sdk.Msg) error { callCount++ assert.NotNil(t, clientCtx) diff --git a/x/distribution/client/cli/utils.go b/x/distribution/client/cli/utils.go index c5310f6469ca..078085c2ae1b 100644 --- a/x/distribution/client/cli/utils.go +++ b/x/distribution/client/cli/utils.go @@ -27,7 +27,7 @@ func ParseCommunityPoolSpendProposalJSON(cdc codec.JSONMarshaler, proposalFile s return proposal, err } - if err := cdc.UnmarshalJSON(contents, &proposal); err != nil { + if err = cdc.UnmarshalJSON(contents, &proposal); err != nil { return proposal, err } diff --git a/x/distribution/client/proposal_handler.go b/x/distribution/client/proposal_handler.go index c7fcc0bdce91..517f508bff68 100644 --- a/x/distribution/client/proposal_handler.go +++ b/x/distribution/client/proposal_handler.go @@ -6,7 +6,7 @@ import ( govclient "github.com/cosmos/cosmos-sdk/x/gov/client" ) -// param change proposal handler +// ProposalHandler is the community spend proposal handler. var ( ProposalHandler = govclient.NewProposalHandler(cli.GetCmdSubmitProposal, rest.ProposalRESTHandler) )