From f7a945edabc4f2448d259fa117769d2bd3941722 Mon Sep 17 00:00:00 2001 From: Daniel Wedul Date: Tue, 24 Jan 2023 02:23:37 -0700 Subject: [PATCH 1/2] feat(gov,cli): Create AddGovPropFlagsToCmd and ReadGovPropFlags. (#14718) (cherry picked from commit 66744022162c2fb164728b434233aac42be26533) # Conflicts: # CHANGELOG.md # x/feegrant/client/cli/tx_test.go # x/upgrade/client/cli/parse_test.go --- CHANGELOG.md | 9 + x/feegrant/client/cli/tx_test.go | 5 + x/gov/client/cli/tx.go | 12 +- x/gov/client/cli/util.go | 51 +++ x/gov/client/cli/util_test.go | 483 +++++++++++++++++++++++++++++ x/upgrade/client/cli/parse.go | 2 +- x/upgrade/client/cli/parse_test.go | 4 + x/upgrade/client/cli/tx.go | 8 +- 8 files changed, 563 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6c6a269b7ca..24c56c99307f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,15 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/auth) [#13210](https://github.com/cosmos/cosmos-sdk/pull/13210) Add `Query/AccountInfo` endpoint for simplified access to basic account info. * (x/consensus) [#12905](https://github.com/cosmos/cosmos-sdk/pull/12905) Create a new `x/consensus` module that is now responsible for maintaining Tendermint consensus parameters instead of `x/param`. Legacy types remain in order to facilitate parameter migration from the deprecated `x/params`. App developers should ensure that they execute `baseapp.MigrateParams` during their chain upgrade. These legacy types will be removed in a future release. * (client/tx) [#13670](https://github.com/cosmos/cosmos-sdk/pull/13670) Add validation in `BuildUnsignedTx` to prevent simple inclusion of valid mnemonics +<<<<<<< HEAD +======= +* [#13473](https://github.com/cosmos/cosmos-sdk/pull/13473) ADR-038: Go plugin system proposal +* [#14356](https://github.com/cosmos/cosmos-sdk/pull/14356) Add `events.GetAttributes` and `event.GetAttribute` methods to simplify the retrieval of an attribute from event(s). +* [#14472](https://github.com/cosmos/cosmos-sdk/pull/14356) The recommended metadata format for x/gov and x/group proposals now uses an array of strings (instead of a single string) for the `authors` field. +* (mempool) [#14484](https://github.com/cosmos/cosmos-sdk/pull/14484) Add priority nonce mempool option for transaction replacement. +* (client) [#14509](https://github.com/cosmos/cosmos-sdk/pull/#14509) Added `AddKeyringFlags` function. +* (x/gov,cli) [#14718](https://github.com/cosmos/cosmos-sdk/pull/14718) Added `AddGovPropFlagsToCmd` and `ReadGovPropFlags` functions. +>>>>>>> 667440221 (feat(gov,cli): Create AddGovPropFlagsToCmd and ReadGovPropFlags. (#14718)) ### Improvements diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index 64b833f5aff9..941c619bb190 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -614,8 +614,13 @@ func (s *CLITestSuite) msgSubmitLegacyProposal(clientCtx client.Context, from, t args := append([]string{ fmt.Sprintf("--%s=%s", govcli.FlagTitle, title), +<<<<<<< HEAD fmt.Sprintf("--%s=%s", govcli.FlagDescription, description), fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType), +======= + fmt.Sprintf("--%s=%s", govcli.FlagDescription, description), //nolint:staticcheck // SA1019: govcli.FlagDescription is deprecated: use FlagDescription instead + fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType), //nolint:staticcheck // SA1019: govcli.FlagProposalType is deprecated: use FlagProposalType instead +>>>>>>> 667440221 (feat(gov,cli): Create AddGovPropFlagsToCmd and ReadGovPropFlags. (#14718)) fmt.Sprintf("--%s=%s", flags.FlagFrom, from), }, commonArgs...) diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 460d3aafebe1..16f1ca1d9e75 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -20,7 +20,6 @@ import ( // Proposal flags const ( - // Deprecated: only used for v1beta1 legacy proposals. FlagTitle = "title" // Deprecated: only used for v1beta1 legacy proposals. FlagDescription = "description" @@ -30,7 +29,8 @@ const ( flagVoter = "voter" flagDepositor = "depositor" flagStatus = "status" - flagMetadata = "metadata" + FlagMetadata = "metadata" + FlagSummary = "summary" // Deprecated: only used for v1beta1 legacy proposals. FlagProposal = "proposal" ) @@ -303,7 +303,7 @@ $ %s tx gov vote 1 yes --from mykey return err } - metadata, err := cmd.Flags().GetString(flagMetadata) + metadata, err := cmd.Flags().GetString(FlagMetadata) if err != nil { return err } @@ -315,7 +315,7 @@ $ %s tx gov vote 1 yes --from mykey }, } - cmd.Flags().String(flagMetadata, "", "Specify metadata of the vote") + cmd.Flags().String(FlagMetadata, "", "Specify metadata of the vote") flags.AddTxFlagsToCmd(cmd) return cmd @@ -358,7 +358,7 @@ $ %s tx gov weighted-vote 1 yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05 --from return err } - metadata, err := cmd.Flags().GetString(flagMetadata) + metadata, err := cmd.Flags().GetString(FlagMetadata) if err != nil { return err } @@ -369,7 +369,7 @@ $ %s tx gov weighted-vote 1 yes=0.6,no=0.3,abstain=0.05,no_with_veto=0.05 --from }, } - cmd.Flags().String(flagMetadata, "", "Specify metadata of the weighted vote") + cmd.Flags().String(FlagMetadata, "", "Specify metadata of the weighted vote") flags.AddTxFlagsToCmd(cmd) return cmd diff --git a/x/gov/client/cli/util.go b/x/gov/client/cli/util.go index 2873b3082fda..fe3e8d0a26e3 100644 --- a/x/gov/client/cli/util.go +++ b/x/gov/client/cli/util.go @@ -5,11 +5,14 @@ import ( "fmt" "os" + "github.com/spf13/cobra" "github.com/spf13/pflag" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" govutils "github.com/cosmos/cosmos-sdk/x/gov/client/utils" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" ) type legacyProposal struct { @@ -118,3 +121,51 @@ func parseSubmitProposal(cdc codec.Codec, path string) ([]sdk.Msg, string, strin return msgs, proposal.Metadata, proposal.Title, proposal.Summary, deposit, nil } + +// AddGovPropFlagsToCmd adds flags for defining MsgSubmitProposal fields. +// +// See also ReadGovPropFlags. +func AddGovPropFlagsToCmd(cmd *cobra.Command) { + cmd.Flags().String(FlagDeposit, "", "The deposit to include with the governance proposal") + cmd.Flags().String(FlagMetadata, "", "The metadata to include with the governance proposal") + cmd.Flags().String(FlagTitle, "", "The title to put on the governance proposal") + cmd.Flags().String(FlagSummary, "", "The summary to include with the governance proposal") +} + +// ReadGovPropFlags parses a MsgSubmitProposal from the provided context and flags. +// Setting the messages is up to the caller. +// +// See also AddGovPropFlagsToCmd. +func ReadGovPropFlags(clientCtx client.Context, flagSet *pflag.FlagSet) (*govv1.MsgSubmitProposal, error) { + rv := &govv1.MsgSubmitProposal{} + + deposit, err := flagSet.GetString(FlagDeposit) + if err != nil { + return nil, fmt.Errorf("could not read deposit: %w", err) + } + if len(deposit) > 0 { + rv.InitialDeposit, err = sdk.ParseCoinsNormalized(deposit) + if err != nil { + return nil, fmt.Errorf("invalid deposit: %w", err) + } + } + + rv.Metadata, err = flagSet.GetString(FlagMetadata) + if err != nil { + return nil, fmt.Errorf("could not read metadata: %w", err) + } + + rv.Title, err = flagSet.GetString(FlagTitle) + if err != nil { + return nil, fmt.Errorf("could not read title: %w", err) + } + + rv.Summary, err = flagSet.GetString(FlagSummary) + if err != nil { + return nil, fmt.Errorf("could not read summary: %w", err) + } + + rv.Proposer = clientCtx.GetFromAddress().String() + + return rv, nil +} diff --git a/x/gov/client/cli/util_test.go b/x/gov/client/cli/util_test.go index dc22c691d544..7abfd86c0eb4 100644 --- a/x/gov/client/cli/util_test.go +++ b/x/gov/client/cli/util_test.go @@ -1,12 +1,19 @@ package cli import ( + "bytes" "encoding/base64" "fmt" + "io" + "os" + "strings" "testing" + "github.com/spf13/cobra" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil" @@ -201,3 +208,479 @@ func TestParseSubmitProposal(t *testing.T) { err = badJSON.Close() require.Nil(t, err, "unexpected error") } + +func getCommandHelp(t *testing.T, cmd *cobra.Command) string { + // Create a pipe, so we can capture the help sent to stdout. + reader, writer, err := os.Pipe() + require.NoError(t, err, "creating os.Pipe()") + outChan := make(chan string) + defer func(origCmdOut io.Writer) { + cmd.SetOut(origCmdOut) + // Ignoring these errors since we're just ensuring cleanup here, + // and they will return an error if already called (which we don't care about). + _ = reader.Close() + _ = writer.Close() + close(outChan) + }(cmd.OutOrStdout()) + cmd.SetOut(writer) + + // Do the reading in a separate goroutine from the writing (a best practice). + go func() { + var b bytes.Buffer + _, buffErr := io.Copy(&b, reader) + if buffErr != nil { + // Due to complexities of goroutines and multiple channels, I'm sticking with a + // single channel and just putting the error in there (which I'll test for later). + b.WriteString("buffer error: " + buffErr.Error()) + } + outChan <- b.String() + }() + + err = cmd.Help() + require.NoError(t, err, "cmd.Help()") + require.NoError(t, writer.Close(), "pipe writer .Close()") + rv := <-outChan + require.NotContains(t, rv, "buffer error: ", "buffer output") + return rv +} + +func TestAddGovPropFlagsToCmd(t *testing.T) { + cmd := &cobra.Command{ + Short: "Just a test command that does nothing but we can add flags to it.", + Run: func(cmd *cobra.Command, args []string) { + t.Errorf("The cmd has run with the args %q, but Run shouldn't have been called.", args) + }, + } + testFunc := func() { + AddGovPropFlagsToCmd(cmd) + } + require.NotPanics(t, testFunc, "AddGovPropFlagsToCmd") + + help := getCommandHelp(t, cmd) + + expDepositDesc := "The deposit to include with the governance proposal" + expMetadataDesc := "The metadata to include with the governance proposal" + expTitleDesc := "The title to put on the governance proposal" + expSummaryDesc := "The summary to include with the governance proposal" + // Regexp notes: (?m:...) = multi-line mode so ^ and $ match the beginning and end of each line. + // Each regexp assertion checks for a line containing only a specific flag and its description. + assert.Regexp(t, `(?m:^\s+--`+FlagDeposit+` string\s+`+expDepositDesc+`$)`, help, "help output") + assert.Regexp(t, `(?m:^\s+--`+FlagMetadata+` string\s+`+expMetadataDesc+`$)`, help, "help output") + assert.Regexp(t, `(?m:^\s+--`+FlagTitle+` string\s+`+expTitleDesc+`$)`, help, "help output") + assert.Regexp(t, `(?m:^\s+--`+FlagSummary+` string\s+`+expSummaryDesc+`$)`, help, "help output") +} + +func TestReadGovPropFlags(t *testing.T) { + fromAddr := sdk.AccAddress("from_addr___________") + argDeposit := "--" + FlagDeposit + argMetadata := "--" + FlagMetadata + argTitle := "--" + FlagTitle + argSummary := "--" + FlagSummary + + // cz is a shorter way to define coins objects for these tests. + cz := func(coins string) sdk.Coins { + rv, err := sdk.ParseCoinsNormalized(coins) + require.NoError(t, err, "ParseCoinsNormalized(%q)", coins) + return rv + } + + tests := []struct { + name string + fromAddr sdk.AccAddress + args []string + exp *v1.MsgSubmitProposal + expErr []string + }{ + { + name: "no args no from", + fromAddr: nil, + args: []string{}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only from defined", + fromAddr: fromAddr, + args: []string{}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: fromAddr.String(), + Metadata: "", + Title: "", + Summary: "", + }, + }, + + // only deposit tests. + { + name: "only deposit empty string", + fromAddr: nil, + args: []string{argDeposit, ""}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only deposit one coin", + fromAddr: nil, + args: []string{argDeposit, "1bigcoin"}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("1bigcoin"), + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only deposit invalid coins", + fromAddr: nil, + args: []string{argDeposit, "not really coins"}, + expErr: []string{"invalid deposit", "invalid decimal coin expression", "not really coins"}, + }, + { + name: "only deposit two coins", + fromAddr: nil, + args: []string{argDeposit, "1acoin,2bcoin"}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("1acoin,2bcoin"), + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only deposit two coins other order", + fromAddr: nil, + args: []string{argDeposit, "2bcoin,1acoin"}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("1acoin,2bcoin"), + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only deposit coin 1 of 3 bad", + fromAddr: nil, + args: []string{argDeposit, "1bad^coin,2bcoin,3ccoin"}, + expErr: []string{"invalid deposit", "invalid decimal coin expression", "1bad^coin"}, + }, + { + name: "only deposit coin 2 of 3 bad", + fromAddr: nil, + args: []string{argDeposit, "1acoin,2bad^coin,3ccoin"}, + expErr: []string{"invalid deposit", "invalid decimal coin expression", "2bad^coin"}, + }, + { + name: "only deposit coin 3 of 3 bad", + fromAddr: nil, + args: []string{argDeposit, "1acoin,2bcoin,3bad^coin"}, + expErr: []string{"invalid deposit", "invalid decimal coin expression", "3bad^coin"}, + }, + // As far as I can tell, there's no way to make flagSet.GetString return an error for a defined string flag. + // So I don't have a test for the "could not read deposit" error case. + + // only metadata tests. + { + name: "only metadata empty", + fromAddr: nil, + args: []string{argMetadata, ""}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only metadata simple", + fromAddr: nil, + args: []string{argMetadata, "just some metadata"}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "just some metadata", + Title: "", + Summary: "", + }, + }, + { + name: "only metadata super long", + fromAddr: nil, + args: []string{argMetadata, strings.Repeat("Long", 1_000_000)}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: strings.Repeat("Long", 1_000_000), + Title: "", + Summary: "", + }, + }, + // As far as I can tell, there's no way to make flagSet.GetString return an error for a defined string flag. + // So I don't have a test for the "could not read metadata" error case. + + // only title tests. + { + name: "only title empty", + fromAddr: nil, + args: []string{argTitle, ""}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only title simple", + fromAddr: nil, + args: []string{argTitle, "just a title"}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "just a title", + Summary: "", + }, + }, + { + name: "only title super long", + fromAddr: nil, + args: []string{argTitle, strings.Repeat("Long", 1_000_000)}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: strings.Repeat("Long", 1_000_000), + Summary: "", + }, + }, + // As far as I can tell, there's no way to make flagSet.GetString return an error for a defined string flag. + // So I don't have a test for the "could not read title" error case. + + // only summary tests. + { + name: "only summary empty", + fromAddr: nil, + args: []string{argSummary, ""}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "only summary simple", + fromAddr: nil, + args: []string{argSummary, "just a short summary"}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: "just a short summary", + }, + }, + { + name: "only summary super long", + fromAddr: nil, + args: []string{argSummary, strings.Repeat("Long", 1_000_000)}, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: strings.Repeat("Long", 1_000_000), + }, + }, + // As far as I can tell, there's no way to make flagSet.GetString return an error for a defined string flag. + // So I don't have a test for the "could not read summary" error case. + + // Combo tests. + { + name: "all together order 1", + fromAddr: fromAddr, + args: []string{ + argDeposit, "56depcoin", + argMetadata, "my proposal is cool", + argTitle, "Simple Gov Prop Title", + argSummary, "This is just a test summary on a simple gov prop.", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("56depcoin"), + Proposer: fromAddr.String(), + Metadata: "my proposal is cool", + Title: "Simple Gov Prop Title", + Summary: "This is just a test summary on a simple gov prop.", + }, + }, + { + name: "all together order 2", + fromAddr: fromAddr, + args: []string{ + argTitle, "This title is a *bit* more complex.", + argSummary, "This\nis\na\ncrazy\nsummary", + argDeposit, "78coolcoin", + argMetadata, "this proposal is cooler", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("78coolcoin"), + Proposer: fromAddr.String(), + Metadata: "this proposal is cooler", + Title: "This title is a *bit* more complex.", + Summary: "This\nis\na\ncrazy\nsummary", + }, + }, + { + name: "all except proposer", + fromAddr: nil, + args: []string{ + argMetadata, "https://example.com/lucky", + argDeposit, "33luckycoin", + argSummary, "This proposal will bring you luck and good fortune in the new year.", + argTitle, "Increase Luck", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("33luckycoin"), + Proposer: "", + Metadata: "https://example.com/lucky", + Title: "Increase Luck", + Summary: "This proposal will bring you luck and good fortune in the new year.", + }, + }, + { + name: "all except proposer but all empty", + fromAddr: nil, + args: []string{ + argMetadata, "", + argDeposit, "", + argSummary, "", + argTitle, "", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: "", + Metadata: "", + Title: "", + Summary: "", + }, + }, + { + name: "all except deposit", + fromAddr: fromAddr, + args: []string{ + argTitle, "This is a Title", + argSummary, "This is a useless summary", + argMetadata, "worthless metadata", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: nil, + Proposer: fromAddr.String(), + Metadata: "worthless metadata", + Title: "This is a Title", + Summary: "This is a useless summary", + }, + expErr: nil, + }, + { + name: "all except metadata", + fromAddr: fromAddr, + args: []string{ + argTitle, "Bland Title", + argSummary, "Boring summary", + argDeposit, "99mdcoin", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("99mdcoin"), + Proposer: fromAddr.String(), + Metadata: "", + Title: "Bland Title", + Summary: "Boring summary", + }, + }, + { + name: "all except title", + fromAddr: fromAddr, + args: []string{ + argMetadata, "this metadata does not have the title either", + argDeposit, "71whatcoin", + argSummary, "This is a summary on a titleless proposal.", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("71whatcoin"), + Proposer: fromAddr.String(), + Metadata: "this metadata does not have the title either", + Title: "", + Summary: "This is a summary on a titleless proposal.", + }, + expErr: nil, + }, + { + name: "all except summary", + fromAddr: fromAddr, + args: []string{ + argMetadata, "28", + argTitle, "Now This is What I Call A Governance Proposal 28", + argDeposit, "42musiccoin", + }, + exp: &v1.MsgSubmitProposal{ + InitialDeposit: cz("42musiccoin"), + Proposer: fromAddr.String(), + Metadata: "28", + Title: "Now This is What I Call A Governance Proposal 28", + Summary: "", + }, + expErr: nil, + }, + } + + for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { + cmd := &cobra.Command{ + Short: tc.name, + Run: func(cmd *cobra.Command, args []string) { + t.Errorf("The cmd for %q has run with the args %q, but Run shouldn't have been called.", tc.name, args) + }, + } + AddGovPropFlagsToCmd(cmd) + err := cmd.ParseFlags(tc.args) + require.NoError(t, err, "parsing test case args using cmd: %q", tc.args) + flagSet := cmd.Flags() + + clientCtx := client.Context{ + FromAddress: tc.fromAddr, + } + + var msg *v1.MsgSubmitProposal + testFunc := func() { + msg, err = ReadGovPropFlags(clientCtx, flagSet) + } + require.NotPanics(t, testFunc, "ReadGovPropFlags") + if len(tc.expErr) > 0 { + require.Error(t, err, "ReadGovPropFlags error") + for _, exp := range tc.expErr { + assert.ErrorContains(t, err, exp, "ReadGovPropFlags error") + } + } else { + require.NoError(t, err, "ReadGovPropFlags error") + } + assert.Equal(t, tc.exp, msg, "ReadGovPropFlags msg") + }) + } +} diff --git a/x/upgrade/client/cli/parse.go b/x/upgrade/client/cli/parse.go index e6b103791c4b..6c3d7ed72475 100644 --- a/x/upgrade/client/cli/parse.go +++ b/x/upgrade/client/cli/parse.go @@ -8,7 +8,7 @@ import ( ) func parseArgsToContent(fs *pflag.FlagSet, name string) (gov.Content, error) { - title, err := fs.GetString(cli.FlagTitle) //nolint:staticcheck // we are intentionally using a deprecated flag here. + title, err := fs.GetString(cli.FlagTitle) if err != nil { return nil, err } diff --git a/x/upgrade/client/cli/parse_test.go b/x/upgrade/client/cli/parse_test.go index b5ce54e4b179..d1923e04858e 100644 --- a/x/upgrade/client/cli/parse_test.go +++ b/x/upgrade/client/cli/parse_test.go @@ -23,7 +23,11 @@ func TestParseArgsToContent(t *testing.T) { } fs.Set(cli.FlagTitle, proposal.Title) +<<<<<<< HEAD fs.Set(cli.FlagDescription, proposal.Description) +======= + fs.Set(cli.FlagDescription, proposal.Description) //nolint:staticcheck // SA1019: cli.FlagDescription is deprecated: use cli.FlagProposalDescription instead +>>>>>>> 667440221 (feat(gov,cli): Create AddGovPropFlagsToCmd and ReadGovPropFlags. (#14718)) fs.Set(FlagUpgradeHeight, strconv.FormatInt(proposal.Plan.Height, 10)) fs.Set(FlagUpgradeInfo, proposal.Plan.Info) diff --git a/x/upgrade/client/cli/tx.go b/x/upgrade/client/cli/tx.go index affba7151c19..db1683a057bf 100644 --- a/x/upgrade/client/cli/tx.go +++ b/x/upgrade/client/cli/tx.go @@ -93,7 +93,7 @@ func NewCmdSubmitLegacyUpgradeProposal() *cobra.Command { }, } - cmd.Flags().String(cli.FlagTitle, "", "title of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here. + cmd.Flags().String(cli.FlagTitle, "", "title of proposal") cmd.Flags().String(cli.FlagDescription, "", "description of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here. cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") cmd.Flags().Int64(FlagUpgradeHeight, 0, "The height at which the upgrade must happen") @@ -129,7 +129,7 @@ func NewCmdSubmitLegacyCancelUpgradeProposal() *cobra.Command { return err } - title, err := cmd.Flags().GetString(cli.FlagTitle) //nolint:staticcheck // we are intentionally using a deprecated flag here. + title, err := cmd.Flags().GetString(cli.FlagTitle) if err != nil { return err } @@ -150,10 +150,10 @@ func NewCmdSubmitLegacyCancelUpgradeProposal() *cobra.Command { }, } - cmd.Flags().String(cli.FlagTitle, "", "title of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here. + cmd.Flags().String(cli.FlagTitle, "", "title of proposal") cmd.Flags().String(cli.FlagDescription, "", "description of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here. cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal") - cmd.MarkFlagRequired(cli.FlagTitle) //nolint:staticcheck // we are intentionally using a deprecated flag here. + cmd.MarkFlagRequired(cli.FlagTitle) cmd.MarkFlagRequired(cli.FlagDescription) //nolint:staticcheck // we are intentionally using a deprecated flag here. return cmd From 1ee484f4b65edd9f5f9dbccaf7f4d472d525978b Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Mon, 20 Mar 2023 15:56:31 +0100 Subject: [PATCH 2/2] fix conflicts --- CHANGELOG.md | 15 ++++++--------- x/feegrant/client/cli/tx_test.go | 5 ----- x/upgrade/client/cli/parse_test.go | 4 ---- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24c56c99307f..f4bd9514b2d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,12 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog +## [Unreleased] + +### Features + +* (x/gov,cli) [#14718](https://github.com/cosmos/cosmos-sdk/pull/14718) Added `AddGovPropFlagsToCmd` and `ReadGovPropFlags` functions. + ## [v0.47.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0) - 2023-03-14 ### Features @@ -61,15 +67,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (x/auth) [#13210](https://github.com/cosmos/cosmos-sdk/pull/13210) Add `Query/AccountInfo` endpoint for simplified access to basic account info. * (x/consensus) [#12905](https://github.com/cosmos/cosmos-sdk/pull/12905) Create a new `x/consensus` module that is now responsible for maintaining Tendermint consensus parameters instead of `x/param`. Legacy types remain in order to facilitate parameter migration from the deprecated `x/params`. App developers should ensure that they execute `baseapp.MigrateParams` during their chain upgrade. These legacy types will be removed in a future release. * (client/tx) [#13670](https://github.com/cosmos/cosmos-sdk/pull/13670) Add validation in `BuildUnsignedTx` to prevent simple inclusion of valid mnemonics -<<<<<<< HEAD -======= -* [#13473](https://github.com/cosmos/cosmos-sdk/pull/13473) ADR-038: Go plugin system proposal -* [#14356](https://github.com/cosmos/cosmos-sdk/pull/14356) Add `events.GetAttributes` and `event.GetAttribute` methods to simplify the retrieval of an attribute from event(s). -* [#14472](https://github.com/cosmos/cosmos-sdk/pull/14356) The recommended metadata format for x/gov and x/group proposals now uses an array of strings (instead of a single string) for the `authors` field. -* (mempool) [#14484](https://github.com/cosmos/cosmos-sdk/pull/14484) Add priority nonce mempool option for transaction replacement. -* (client) [#14509](https://github.com/cosmos/cosmos-sdk/pull/#14509) Added `AddKeyringFlags` function. -* (x/gov,cli) [#14718](https://github.com/cosmos/cosmos-sdk/pull/14718) Added `AddGovPropFlagsToCmd` and `ReadGovPropFlags` functions. ->>>>>>> 667440221 (feat(gov,cli): Create AddGovPropFlagsToCmd and ReadGovPropFlags. (#14718)) ### Improvements diff --git a/x/feegrant/client/cli/tx_test.go b/x/feegrant/client/cli/tx_test.go index 941c619bb190..64b833f5aff9 100644 --- a/x/feegrant/client/cli/tx_test.go +++ b/x/feegrant/client/cli/tx_test.go @@ -614,13 +614,8 @@ func (s *CLITestSuite) msgSubmitLegacyProposal(clientCtx client.Context, from, t args := append([]string{ fmt.Sprintf("--%s=%s", govcli.FlagTitle, title), -<<<<<<< HEAD fmt.Sprintf("--%s=%s", govcli.FlagDescription, description), fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType), -======= - fmt.Sprintf("--%s=%s", govcli.FlagDescription, description), //nolint:staticcheck // SA1019: govcli.FlagDescription is deprecated: use FlagDescription instead - fmt.Sprintf("--%s=%s", govcli.FlagProposalType, proposalType), //nolint:staticcheck // SA1019: govcli.FlagProposalType is deprecated: use FlagProposalType instead ->>>>>>> 667440221 (feat(gov,cli): Create AddGovPropFlagsToCmd and ReadGovPropFlags. (#14718)) fmt.Sprintf("--%s=%s", flags.FlagFrom, from), }, commonArgs...) diff --git a/x/upgrade/client/cli/parse_test.go b/x/upgrade/client/cli/parse_test.go index d1923e04858e..b5ce54e4b179 100644 --- a/x/upgrade/client/cli/parse_test.go +++ b/x/upgrade/client/cli/parse_test.go @@ -23,11 +23,7 @@ func TestParseArgsToContent(t *testing.T) { } fs.Set(cli.FlagTitle, proposal.Title) -<<<<<<< HEAD fs.Set(cli.FlagDescription, proposal.Description) -======= - fs.Set(cli.FlagDescription, proposal.Description) //nolint:staticcheck // SA1019: cli.FlagDescription is deprecated: use cli.FlagProposalDescription instead ->>>>>>> 667440221 (feat(gov,cli): Create AddGovPropFlagsToCmd and ReadGovPropFlags. (#14718)) fs.Set(FlagUpgradeHeight, strconv.FormatInt(proposal.Plan.Height, 10)) fs.Set(FlagUpgradeInfo, proposal.Plan.Info)