* feat: Add CLI for new proposal * Add changelog * Add comment * Add metadata * Add tests for parsing * Add CLI test * Use legacy submit proposal in other modules * Update x/gov/client/cli/tx.go * Update x/gov/client/cli/tx.go * Update x/gov/client/cli/tx.go * Remove deprecated cobra field * Update x/gov/client/cli/tx.go Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com>
72 lines
2.5 KiB
Go
72 lines
2.5 KiB
Go
package testutil
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/testutil"
|
|
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
|
)
|
|
|
|
var commonArgs = []string{
|
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()),
|
|
}
|
|
|
|
// MsgSubmitProposal creates a tx for submit proposal
|
|
func MsgSubmitProposal(clientCtx client.Context, from, title, description, proposalType string, extraArgs ...string) (testutil.BufferWriter, error) {
|
|
args := append([]string{
|
|
fmt.Sprintf("--%s=%s", govcli.FlagTitle, title),
|
|
fmt.Sprintf("--%s=%s", govcli.FlagDescription, description),
|
|
fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
|
|
}, commonArgs...)
|
|
|
|
args = append(args, extraArgs...)
|
|
|
|
return clitestutil.ExecTestCLICmd(clientCtx, govcli.NewCmdSubmitProposal(), args)
|
|
}
|
|
|
|
// MsgSubmitLegacyProposal creates a tx for submit legacy proposal
|
|
func MsgSubmitLegacyProposal(clientCtx client.Context, from, title, description, proposalType string, extraArgs ...string) (testutil.BufferWriter, error) {
|
|
args := append([]string{
|
|
fmt.Sprintf("--%s=%s", govcli.FlagTitle, title),
|
|
fmt.Sprintf("--%s=%s", govcli.FlagDescription, description),
|
|
fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType),
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
|
|
}, commonArgs...)
|
|
|
|
args = append(args, extraArgs...)
|
|
|
|
return clitestutil.ExecTestCLICmd(clientCtx, govcli.NewCmdSubmitLegacyProposal(), args)
|
|
}
|
|
|
|
// MsgVote votes for a proposal
|
|
func MsgVote(clientCtx client.Context, from, id, vote string, extraArgs ...string) (testutil.BufferWriter, error) {
|
|
args := append([]string{
|
|
id,
|
|
vote,
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
|
|
}, commonArgs...)
|
|
|
|
args = append(args, extraArgs...)
|
|
|
|
return clitestutil.ExecTestCLICmd(clientCtx, govcli.NewCmdWeightedVote(), args)
|
|
}
|
|
|
|
func MsgDeposit(clientCtx client.Context, from, id, deposit string, extraArgs ...string) (testutil.BufferWriter, error) {
|
|
args := append([]string{
|
|
id,
|
|
deposit,
|
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
|
|
}, commonArgs...)
|
|
|
|
args = append(args, extraArgs...)
|
|
|
|
return clitestutil.ExecTestCLICmd(clientCtx, govcli.NewCmdDeposit(), args)
|
|
}
|