forked from Kava-Labs/kava
/
tx.go
91 lines (80 loc) · 2.1 KB
/
tx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package cli
import (
"fmt"
"strings"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/version"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/mokitanetwork/aether/x/aethdist/types"
)
// GetCmdSubmitProposal implements the command to submit a community-pool multi-spend proposal
func GetCmdSubmitProposal() *cobra.Command {
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 AETH!",
"recipient_list": [
{
"address": "aeth1mz2003lathm95n5vnlthmtfvrzrjkrr53j4464",
"amount": [
{
"denom": "uaeth",
"amount": "1000000"
}
]
},
{
"address": "aeth1zqezafa0luyetvtj8j67g336vaqtuudnsjq7vm",
"amount": [
{
"denom": "uaeth",
"amount": "1000000"
}
]
}
],
"deposit": [
{
"denom": "uaeth",
"amount": "1000000000"
}
]
}
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
proposal, err := ParseCommunityPoolMultiSpendProposalJSON(clientCtx.Codec, args[0])
if err != nil {
return err
}
from := clientCtx.GetFromAddress()
content := types.NewCommunityPoolMultiSpendProposal(proposal.Title, proposal.Description, proposal.RecipientList)
msg, err := govtypes.NewMsgSubmitProposal(content, proposal.Deposit, from)
if err != nil {
return err
}
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
return cmd
}