2021-06-02 17:03:25 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
2021-06-02 17:03:25 +00:00
|
|
|
"github.com/cosmos/cosmos-sdk/version"
|
2023-04-04 00:08:45 +00:00
|
|
|
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
2021-06-02 17:03:25 +00:00
|
|
|
|
|
|
|
"github.com/kava-labs/kava/x/kavadist/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetCmdSubmitProposal implements the command to submit a community-pool multi-spend proposal
|
2022-01-08 00:39:27 +00:00
|
|
|
func GetCmdSubmitProposal() *cobra.Command {
|
2021-06-02 17:03:25 +00:00
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "community-pool-multi-spend [proposal-file]",
|
|
|
|
Args: cobra.ExactArgs(1),
|
|
|
|
Short: "Submit a community pool multi-spend proposal",
|
|
|
|
Long: strings.TrimSpace(
|
|
|
|
fmt.Sprintf(`Submit a community pool multi-spend proposal along with an initial deposit.
|
|
|
|
The proposal details must be supplied via a JSON file.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
$ %s tx gov submit-proposal community-pool-multi-spend <path/to/proposal.json> --from=<key_or_address>
|
|
|
|
|
|
|
|
Where proposal.json contains:
|
|
|
|
|
|
|
|
{
|
|
|
|
"title": "Community Pool Multi-Spend",
|
|
|
|
"description": "Pay many users some KAVA!",
|
|
|
|
"recipient_list": [
|
|
|
|
{
|
|
|
|
"address": "kava1mz2003lathm95n5vnlthmtfvrzrjkrr53j4464",
|
|
|
|
"amount": [
|
|
|
|
{
|
|
|
|
"denom": "ukava",
|
|
|
|
"amount": "1000000"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"address": "kava1zqezafa0luyetvtj8j67g336vaqtuudnsjq7vm",
|
|
|
|
"amount": [
|
|
|
|
{
|
|
|
|
"denom": "ukava",
|
|
|
|
"amount": "1000000"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"deposit": [
|
|
|
|
{
|
|
|
|
"denom": "ukava",
|
|
|
|
"amount": "1000000000"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
`,
|
2022-01-08 00:39:27 +00:00
|
|
|
version.AppName,
|
2021-06-02 17:03:25 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2022-01-08 00:39:27 +00:00
|
|
|
clientCtx, err := client.GetClientTxContext(cmd)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
proposal, err := ParseCommunityPoolMultiSpendProposalJSON(clientCtx.Codec, args[0])
|
2021-06-02 17:03:25 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
from := clientCtx.GetFromAddress()
|
2021-06-02 17:03:25 +00:00
|
|
|
content := types.NewCommunityPoolMultiSpendProposal(proposal.Title, proposal.Description, proposal.RecipientList)
|
2023-04-04 00:08:45 +00:00
|
|
|
msg, err := govv1beta1.NewMsgSubmitProposal(content, proposal.Deposit, from)
|
2022-01-08 00:39:27 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2021-06-02 17:03:25 +00:00
|
|
|
if err := msg.ValidateBasic(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2022-01-08 00:39:27 +00:00
|
|
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
2021-06-02 17:03:25 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd
|
|
|
|
}
|