-
Notifications
You must be signed in to change notification settings - Fork 206
/
tx.go
93 lines (77 loc) · 2.67 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
92
93
package cli
import (
"fmt"
"strings"
"time"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/version"
// "github.com/cosmos/cosmos-sdk/client/flags"
sdk "github.com/cosmos/cosmos-sdk/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/lavanet/lava/x/plans/client/utils"
"github.com/lavanet/lava/x/plans/types"
)
var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds())
const (
flagPacketTimeoutTimestamp = "packet-timeout-timestamp"
listSeparator = ","
)
// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
// this line is used by starport scaffolding # 1
return cmd
}
// NewSubmitParamChangeProposalTxCmd returns a CLI command handler for creating
// a parameter change proposal governance transaction.
func NewSubmitPlansAddProposalTxCmd() *cobra.Command {
return &cobra.Command{
Use: "plans-add [proposal-file,proposal-file,...]",
Args: cobra.ExactArgs(1),
Short: "Submit a plans add proposal",
Long: strings.TrimSpace(
fmt.Sprintf(`Submit a parameter proposal along with an initial deposit.
The proposal details must be supplied via a JSON file. For values that contains
objects, only non-empty fields will be updated.
IMPORTANT: Currently changes are evaluated but not validated, so it is
very important that any "value" change is valid (ie. correct type and within bounds)
Proper vetting of a plans add proposal should prevent this from happening
(no deposits should occur during the governance process), but it should be noted
regardless.
Example:
$ %s tx gov plans-proposal plans-add <path/to/proposal.json> --from=<key_or_address>
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
proposal, err := utils.ParsePlansAddProposalJSON(clientCtx.LegacyAmino, args[0])
if err != nil {
return err
}
from := clientCtx.GetFromAddress()
content := &proposal.Proposal
deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit)
if err != nil {
return err
}
msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
}