From b360003c11d81f0bd037bf88fd6077a15378799f Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 2 Mar 2023 16:23:16 -0600 Subject: [PATCH 1/6] feat(autocli): add text|json output for flag output --- client/v2/autocli/app.go | 1 + client/v2/autocli/builder.go | 2 ++ client/v2/autocli/common.go | 26 +++++++++++++++++++ client/v2/autocli/common_test.go | 2 ++ client/v2/autocli/msg.go | 2 +- client/v2/autocli/msg_test.go | 19 ++++++++++++++ client/v2/autocli/query.go | 6 +---- client/v2/autocli/query_test.go | 18 +++++++++++++ .../testdata/help-deprecated-msg.golden | 5 ++++ .../autocli/testdata/help-deprecated.golden | 5 ++++ .../v2/autocli/testdata/help-echo-msg.golden | 5 ++++ client/v2/autocli/testdata/help-echo.golden | 5 ++++ 12 files changed, 90 insertions(+), 6 deletions(-) diff --git a/client/v2/autocli/app.go b/client/v2/autocli/app.go index e99763d93f24..32f22afcaec3 100644 --- a/client/v2/autocli/app.go +++ b/client/v2/autocli/app.go @@ -62,6 +62,7 @@ func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error { return client.GetClientQueryContext(cmd) }, AddQueryConnFlags: flags.AddQueryFlagsToCmd, + AddTxConnFlags: flags.AddTxFlagsToCmd, } return appOptions.EnhanceRootCommandWithBuilder(rootCmd, builder) diff --git a/client/v2/autocli/builder.go b/client/v2/autocli/builder.go index fc83b7e73dde..5766c5aa8770 100644 --- a/client/v2/autocli/builder.go +++ b/client/v2/autocli/builder.go @@ -17,4 +17,6 @@ type Builder struct { GetClientConn func(*cobra.Command) (grpc.ClientConnInterface, error) AddQueryConnFlags func(*cobra.Command) + + AddTxConnFlags func(*cobra.Command) } diff --git a/client/v2/autocli/common.go b/client/v2/autocli/common.go index b7df4ed36fc0..557c78d02c94 100644 --- a/client/v2/autocli/common.go +++ b/client/v2/autocli/common.go @@ -2,8 +2,11 @@ package autocli import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" + "fmt" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" "google.golang.org/protobuf/reflect/protoreflect" + "sigs.k8s.io/yaml" "cosmossdk.io/client/v2/internal/util" ) @@ -62,6 +65,10 @@ func (b *Builder) buildMethodCommandCommon(descriptor protoreflect.MethodDescrip b.AddQueryConnFlags(cmd) } + if b.AddTxConnFlags != nil { + b.AddTxConnFlags(cmd) + } + return cmd, nil } @@ -108,3 +115,22 @@ func (b *Builder) enhanceCommandCommon(cmd *cobra.Command, moduleOptions map[str return nil } + +// outOrStdoutFormat formats the output based on the output flag and writes it to the command's output stream. +func (b *Builder) outOrStdoutFormat(cmd *cobra.Command, out []byte) error { + var err error + outputType := cmd.Flag(flags.FlagOutput) + if outputType == nil { + return fmt.Errorf("output flag not found") + + } + if outputType.Value.String() == "text" { + out, err = yaml.JSONToYAML(out) + if err != nil { + return err + } + } + _, err = fmt.Fprintln(cmd.OutOrStdout(), string(out)) + + return nil +} diff --git a/client/v2/autocli/common_test.go b/client/v2/autocli/common_test.go index d865c92de095..060b31adb0c5 100644 --- a/client/v2/autocli/common_test.go +++ b/client/v2/autocli/common_test.go @@ -3,6 +3,7 @@ package autocli import ( "bytes" "cosmossdk.io/client/v2/internal/testpb" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/spf13/cobra" "google.golang.org/grpc" "gotest.tools/v3/assert" @@ -43,6 +44,7 @@ func testExecCommon(t *testing.T, buildModuleCommand func(string, *Builder) (*co GetClientConn: func(*cobra.Command) (grpc.ClientConnInterface, error) { return conn, nil }, + AddQueryConnFlags: flags.AddQueryFlagsToCmd, } cmd, err := buildModuleCommand("test", b) diff --git a/client/v2/autocli/msg.go b/client/v2/autocli/msg.go index 6586cf5fe0c4..d88cd254fbeb 100644 --- a/client/v2/autocli/msg.go +++ b/client/v2/autocli/msg.go @@ -110,7 +110,7 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor return err } - _, err = fmt.Fprintln(cmd.OutOrStdout(), string(bz)) + err = b.outOrStdoutFormat(cmd, bz) return err }) } diff --git a/client/v2/autocli/msg_test.go b/client/v2/autocli/msg_test.go index fd8e2a041e43..fc1a4dbf63df 100644 --- a/client/v2/autocli/msg_test.go +++ b/client/v2/autocli/msg_test.go @@ -104,6 +104,7 @@ func TestMsgOptions(t *testing.T) { "send", "5", "6", `{"denom":"foo","amount":"1"}`, "--uint32", "7", "--u64", "8", + "--output", "json", ) response := conn.out.String() var output testpb.MsgRequest @@ -114,6 +115,23 @@ func TestMsgOptions(t *testing.T) { assert.Equal(t, output.GetPositional2(), "6") } +func TestMsgOutputFormat(t *testing.T) { + conn := testExecCommon(t, buildModuleMsgCommand, + "send", "5", "6", `{"denom":"foo","amount":"1"}`, + "--output", "json", + ) + fmt.Println(conn.out.String()) + assert.Assert(t, strings.Contains(conn.out.String(), ` "positional1": 5`)) + conn = testExecCommon(t, buildModuleMsgCommand, + "send", "5", "6", `{"denom":"foo","amount":"1"}`, + "--output", "text", + ) + fmt.Println(conn.out.String()) + + assert.Assert(t, strings.Contains(conn.out.String(), "positional1: 5")) + +} + func TestMsgOptionsError(t *testing.T) { conn := testExecCommon(t, buildModuleMsgCommand, "send", "5", @@ -151,6 +169,7 @@ func TestEverythingMsg(t *testing.T) { "abc", `{"denom":"foo","amount":"1234"}`, `{"denom":"bar","amount":"4321"}`, + "--output", "json", "--a-bool", "--an-enum", "two", "--a-message", `{"bar":"abc", "baz":-3}`, diff --git a/client/v2/autocli/query.go b/client/v2/autocli/query.go index d939f0d64886..d435dda48ca1 100644 --- a/client/v2/autocli/query.go +++ b/client/v2/autocli/query.go @@ -131,16 +131,12 @@ func (b *Builder) BuildQueryMethodCommand(descriptor protoreflect.MethodDescript return err } - _, err = fmt.Fprintln(cmd.OutOrStdout(), string(bz)) + err = b.outOrStdoutFormat(cmd, bz) return err }) if err != nil { return nil, err } - if b.AddQueryConnFlags != nil { - b.AddQueryConnFlags(cmd) - } - return cmd, nil } diff --git a/client/v2/autocli/query_test.go b/client/v2/autocli/query_test.go index 828bd307e0c8..911f31dc368a 100644 --- a/client/v2/autocli/query_test.go +++ b/client/v2/autocli/query_test.go @@ -157,6 +157,24 @@ func TestOptions(t *testing.T) { assert.Equal(t, uint64(5), lastReq.U64) // no opt default value got set } +func TestOutputFormat(t *testing.T) { + conn := testExecCommon(t, buildModuleQueryCommand, + "echo", + "1", "abc", `{"denom":"foo","amount":"1"}`, + "--output", "json", + ) + fmt.Println(conn.out.String()) + assert.Assert(t, strings.Contains(conn.out.String(), ` "positional1": 1,`)) + conn = testExecCommon(t, buildModuleQueryCommand, + "echo", + "1", "abc", `{"denom":"foo","amount":"1"}`, + "--output", "text", + ) + fmt.Println(conn.out.String()) + assert.Assert(t, strings.Contains(conn.out.String(), " positional1: 1")) + +} + func TestHelp(t *testing.T) { conn := testExecCommon(t, buildModuleQueryCommand, "-h") golden.Assert(t, conn.out.String(), "help-toplevel.golden") diff --git a/client/v2/autocli/testdata/help-deprecated-msg.golden b/client/v2/autocli/testdata/help-deprecated-msg.golden index ded8e9c79bfa..45f7bed963b8 100644 --- a/client/v2/autocli/testdata/help-deprecated-msg.golden +++ b/client/v2/autocli/testdata/help-deprecated-msg.golden @@ -16,10 +16,15 @@ Flags: --duration duration --durations duration (repeated) --enums Enum (unspecified | one | two | five | neg-three) (repeated) + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) -h, --help help for send --hidden-bool --i32 int32 --i64 int + --node string : to CometBFT RPC interface for this chain (default "tcp://localhost:26657") + -o, --output string Output format (text|json) (default "text") --page-count-total --page-key bytesBase64 --page-limit uint diff --git a/client/v2/autocli/testdata/help-deprecated.golden b/client/v2/autocli/testdata/help-deprecated.golden index e01341910269..e781139e8e2c 100644 --- a/client/v2/autocli/testdata/help-deprecated.golden +++ b/client/v2/autocli/testdata/help-deprecated.golden @@ -14,10 +14,15 @@ Flags: --duration duration --durations duration (repeated) --enums Enum (unspecified | one | two | five | neg-three) (repeated) + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) -h, --help help for echo --hidden-bool --i32 int32 --i64 int + --node string : to CometBFT RPC interface for this chain (default "tcp://localhost:26657") + -o, --output string Output format (text|json) (default "text") --page-count-total --page-key bytesBase64 --page-limit uint diff --git a/client/v2/autocli/testdata/help-echo-msg.golden b/client/v2/autocli/testdata/help-echo-msg.golden index eed1203f3327..4c1705981b97 100644 --- a/client/v2/autocli/testdata/help-echo-msg.golden +++ b/client/v2/autocli/testdata/help-echo-msg.golden @@ -21,9 +21,14 @@ Flags: --duration duration --durations duration (repeated) --enums Enum (unspecified | one | two | five | neg-three) (repeated) + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) -h, --help help for send --i32 int32 some random int32 --i64 int + --node string : to CometBFT RPC interface for this chain (default "tcp://localhost:26657") + -o, --output string Output format (text|json) (default "text") --page-count-total --page-key bytesBase64 --page-limit uint diff --git a/client/v2/autocli/testdata/help-echo.golden b/client/v2/autocli/testdata/help-echo.golden index 33b0752654c2..7728612c2344 100644 --- a/client/v2/autocli/testdata/help-echo.golden +++ b/client/v2/autocli/testdata/help-echo.golden @@ -21,9 +21,14 @@ Flags: --duration duration --durations duration (repeated) --enums Enum (unspecified | one | two | five | neg-three) (repeated) + --grpc-addr string the gRPC endpoint to use for this chain + --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS + --height int Use a specific height to query state at (this can error if the node is pruning state) -h, --help help for echo --i32 int32 some random int32 --i64 int + --node string : to CometBFT RPC interface for this chain (default "tcp://localhost:26657") + -o, --output string Output format (text|json) (default "text") --page-count-total --page-key bytesBase64 --page-limit uint From 556cad9c083d614ac56a93d3d05032dfa5a4f9e7 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 2 Mar 2023 16:25:38 -0600 Subject: [PATCH 2/6] t --- client/v2/autocli/msg_test.go | 2 -- client/v2/autocli/query_test.go | 2 -- 2 files changed, 4 deletions(-) diff --git a/client/v2/autocli/msg_test.go b/client/v2/autocli/msg_test.go index fc1a4dbf63df..5ad54e8690dc 100644 --- a/client/v2/autocli/msg_test.go +++ b/client/v2/autocli/msg_test.go @@ -120,13 +120,11 @@ func TestMsgOutputFormat(t *testing.T) { "send", "5", "6", `{"denom":"foo","amount":"1"}`, "--output", "json", ) - fmt.Println(conn.out.String()) assert.Assert(t, strings.Contains(conn.out.String(), ` "positional1": 5`)) conn = testExecCommon(t, buildModuleMsgCommand, "send", "5", "6", `{"denom":"foo","amount":"1"}`, "--output", "text", ) - fmt.Println(conn.out.String()) assert.Assert(t, strings.Contains(conn.out.String(), "positional1: 5")) diff --git a/client/v2/autocli/query_test.go b/client/v2/autocli/query_test.go index 911f31dc368a..a8be979f2d8f 100644 --- a/client/v2/autocli/query_test.go +++ b/client/v2/autocli/query_test.go @@ -163,14 +163,12 @@ func TestOutputFormat(t *testing.T) { "1", "abc", `{"denom":"foo","amount":"1"}`, "--output", "json", ) - fmt.Println(conn.out.String()) assert.Assert(t, strings.Contains(conn.out.String(), ` "positional1": 1,`)) conn = testExecCommon(t, buildModuleQueryCommand, "echo", "1", "abc", `{"denom":"foo","amount":"1"}`, "--output", "text", ) - fmt.Println(conn.out.String()) assert.Assert(t, strings.Contains(conn.out.String(), " positional1: 1")) } From 70b7ce6dfe7e12d68fc487810a2ce783c98cf812 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 2 Mar 2023 16:41:06 -0600 Subject: [PATCH 3/6] t --- client/v2/autocli/msg_test.go | 2 +- client/v2/autocli/query_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client/v2/autocli/msg_test.go b/client/v2/autocli/msg_test.go index 5ad54e8690dc..2035b1d71d23 100644 --- a/client/v2/autocli/msg_test.go +++ b/client/v2/autocli/msg_test.go @@ -120,7 +120,7 @@ func TestMsgOutputFormat(t *testing.T) { "send", "5", "6", `{"denom":"foo","amount":"1"}`, "--output", "json", ) - assert.Assert(t, strings.Contains(conn.out.String(), ` "positional1": 5`)) + assert.Assert(t, strings.Contains(conn.out.String(), "{")) conn = testExecCommon(t, buildModuleMsgCommand, "send", "5", "6", `{"denom":"foo","amount":"1"}`, "--output", "text", diff --git a/client/v2/autocli/query_test.go b/client/v2/autocli/query_test.go index a8be979f2d8f..9677cd373a61 100644 --- a/client/v2/autocli/query_test.go +++ b/client/v2/autocli/query_test.go @@ -163,12 +163,13 @@ func TestOutputFormat(t *testing.T) { "1", "abc", `{"denom":"foo","amount":"1"}`, "--output", "json", ) - assert.Assert(t, strings.Contains(conn.out.String(), ` "positional1": 1,`)) + assert.Assert(t, strings.Contains(conn.out.String(), "{")) conn = testExecCommon(t, buildModuleQueryCommand, "echo", "1", "abc", `{"denom":"foo","amount":"1"}`, "--output", "text", ) + fmt.Println(conn.out.String()) assert.Assert(t, strings.Contains(conn.out.String(), " positional1: 1")) } From b47ad16c3abcd4cb8f7fbaeb79dc1818ddd7d50e Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Thu, 2 Mar 2023 17:05:28 -0600 Subject: [PATCH 4/6] minor change for not duplicating some flags --- client/v2/autocli/common.go | 14 ++++----- client/v2/autocli/common_test.go | 1 + client/v2/autocli/msg.go | 6 +++- client/v2/autocli/query.go | 4 +++ .../testdata/help-deprecated-msg.golden | 30 +++++++++++++++---- .../v2/autocli/testdata/help-echo-msg.golden | 30 +++++++++++++++---- 6 files changed, 67 insertions(+), 18 deletions(-) diff --git a/client/v2/autocli/common.go b/client/v2/autocli/common.go index 557c78d02c94..acaaa2dc683b 100644 --- a/client/v2/autocli/common.go +++ b/client/v2/autocli/common.go @@ -61,13 +61,13 @@ func (b *Builder) buildMethodCommandCommon(descriptor protoreflect.MethodDescrip return exec(cmd, input) } - if b.AddQueryConnFlags != nil { - b.AddQueryConnFlags(cmd) - } - - if b.AddTxConnFlags != nil { - b.AddTxConnFlags(cmd) - } + //if b.AddQueryConnFlags != nil { + // b.AddQueryConnFlags(cmd) + //} + // + //if b.AddTxConnFlags != nil { + // b.AddTxConnFlags(cmd) + //} return cmd, nil } diff --git a/client/v2/autocli/common_test.go b/client/v2/autocli/common_test.go index 060b31adb0c5..6d55d8315f3d 100644 --- a/client/v2/autocli/common_test.go +++ b/client/v2/autocli/common_test.go @@ -45,6 +45,7 @@ func testExecCommon(t *testing.T, buildModuleCommand func(string, *Builder) (*co return conn, nil }, AddQueryConnFlags: flags.AddQueryFlagsToCmd, + AddTxConnFlags: flags.AddTxFlagsToCmd, } cmd, err := buildModuleCommand("test", b) diff --git a/client/v2/autocli/msg.go b/client/v2/autocli/msg.go index d88cd254fbeb..26384fdab37a 100644 --- a/client/v2/autocli/msg.go +++ b/client/v2/autocli/msg.go @@ -104,7 +104,7 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor Resolver: b.TypeResolver, } - return b.buildMethodCommandCommon(descriptor, options, func(cmd *cobra.Command, input protoreflect.Message) error { + cmd, err := b.buildMethodCommandCommon(descriptor, options, func(cmd *cobra.Command, input protoreflect.Message) error { bz, err := jsonMarshalOptions.Marshal(input.Interface()) if err != nil { return err @@ -113,4 +113,8 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor err = b.outOrStdoutFormat(cmd, bz) return err }) + if cmd != nil && b.AddTxConnFlags != nil { + b.AddTxConnFlags(cmd) + } + return cmd, err } diff --git a/client/v2/autocli/query.go b/client/v2/autocli/query.go index d435dda48ca1..c8c701d56b35 100644 --- a/client/v2/autocli/query.go +++ b/client/v2/autocli/query.go @@ -138,5 +138,9 @@ func (b *Builder) BuildQueryMethodCommand(descriptor protoreflect.MethodDescript return nil, err } + if cmd != nil && b.AddQueryConnFlags != nil { + b.AddQueryConnFlags(cmd) + } + return cmd, nil } diff --git a/client/v2/autocli/testdata/help-deprecated-msg.golden b/client/v2/autocli/testdata/help-deprecated-msg.golden index 45f7bed963b8..8836c5101ea3 100644 --- a/client/v2/autocli/testdata/help-deprecated-msg.golden +++ b/client/v2/autocli/testdata/help-deprecated-msg.golden @@ -8,23 +8,38 @@ Flags: --a-bool --a-coin cosmos.base.v1beta1.Coin (json) --a-message testpb.AMessage (json) + -a, --account-number uint The account number of the signing account (offline mode only) --an-address bech32 account address key name --an-enum Enum (unspecified | one | two | five | neg-three) (default unspecified) + --aux Generate aux signer data instead of sending a tx --bools bools (default []) + -b, --broadcast-mode string Transaction broadcasting mode (sync|async) (default "sync") --bz bytesBase64 + --chain-id string The network chain ID --deprecated-field string + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) --duration duration --durations duration (repeated) --enums Enum (unspecified | one | two | five | neg-three) (repeated) - --grpc-addr string the gRPC endpoint to use for this chain - --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS - --height int Use a specific height to query state at (this can error if the node is pruning state) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) -h, --help help for send --hidden-bool --i32 int32 --i64 int - --node string : to CometBFT RPC interface for this chain (default "tcp://localhost:26657") - -o, --output string Output format (text|json) (default "text") + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) (default "os") + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string : to CometBFT rpc interface for this chain (default "tcp://localhost:26657") + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) (default "json") --page-count-total --page-key bytesBase64 --page-limit uint @@ -33,11 +48,16 @@ Flags: --positional1 int32 --positional2 string --positional3-varargs cosmos.base.v1beta1.Coin (json) (repeated) + -s, --sequence uint The sequence number of the signing account (offline mode only) --shorthand-deprecated-field string + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature --some-messages testpb.AMessage (json) (repeated) --str string --strings strings + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height --timestamp timestamp (RFC 3339) + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator --u32 uint32 --u64 uint --uints uints (default []) + -y, --yes Skip tx broadcasting prompt confirmation diff --git a/client/v2/autocli/testdata/help-echo-msg.golden b/client/v2/autocli/testdata/help-echo-msg.golden index 4c1705981b97..aaca2983aa25 100644 --- a/client/v2/autocli/testdata/help-echo-msg.golden +++ b/client/v2/autocli/testdata/help-echo-msg.golden @@ -13,33 +13,53 @@ Flags: --a-bool --a-coin cosmos.base.v1beta1.Coin (json) --a-message testpb.AMessage (json) + -a, --account-number uint The account number of the signing account (offline mode only) --an-address bech32 account address key name --an-enum Enum (unspecified | one | two | five | neg-three) (default unspecified) + --aux Generate aux signer data instead of sending a tx --bools bools (default []) + -b, --broadcast-mode string Transaction broadcasting mode (sync|async) (default "sync") --bz bytesBase64 + --chain-id string The network chain ID --deprecated-field string (DEPRECATED: don't use this) + --dry-run ignore the --gas flag and perform a simulation of a transaction, but don't broadcast it (when enabled, the local Keybase is not accessible) --duration duration --durations duration (repeated) --enums Enum (unspecified | one | two | five | neg-three) (repeated) - --grpc-addr string the gRPC endpoint to use for this chain - --grpc-insecure allow gRPC over insecure channels, if not the server must use TLS - --height int Use a specific height to query state at (this can error if the node is pruning state) + --fee-granter string Fee granter grants fees for the transaction + --fee-payer string Fee payer pays fees for the transaction instead of deducting from the signer + --fees string Fees to pay along with transaction; eg: 10uatom + --from string Name or address of private key with which to sign + --gas string gas limit to set per-transaction; set to "auto" to calculate sufficient gas automatically. Note: "auto" option doesn't always report accurate results. Set a valid coin value to adjust the result. Can be used instead of "fees". (default 200000) + --gas-adjustment float adjustment factor to be multiplied against the estimate returned by the tx simulation; if the gas limit is set manually this flag is ignored (default 1) + --gas-prices string Gas prices in decimal format to determine the transaction fee (e.g. 0.1uatom) + --generate-only Build an unsigned transaction and write it to STDOUT (when enabled, the local Keybase only accessed when providing a key name) -h, --help help for send --i32 int32 some random int32 --i64 int - --node string : to CometBFT RPC interface for this chain (default "tcp://localhost:26657") - -o, --output string Output format (text|json) (default "text") + --keyring-backend string Select keyring's backend (os|file|kwallet|pass|test|memory) (default "os") + --keyring-dir string The client Keyring directory; if omitted, the default 'home' directory will be used + --ledger Use a connected Ledger device + --node string : to CometBFT rpc interface for this chain (default "tcp://localhost:26657") + --note string Note to add a description to the transaction (previously --memo) + --offline Offline mode (does not allow any online functionality) + -o, --output string Output format (text|json) (default "json") --page-count-total --page-key bytesBase64 --page-limit uint --page-offset uint --page-reverse + -s, --sequence uint The sequence number of the signing account (offline mode only) -d, --shorthand-deprecated-field string (DEPRECATED: bad idea) + --sign-mode string Choose sign mode (direct|amino-json|direct-aux), this is an advanced feature --some-messages testpb.AMessage (json) (repeated) --str string --strings strings + --timeout-height uint Set a block timeout height to prevent the tx from being committed past a certain height --timestamp timestamp (RFC 3339) + --tip string Tip is the amount that is going to be transferred to the fee payer on the target chain. This flag is only valid when used with --aux, and is ignored if the target chain didn't enable the TipDecorator --u64 uint some random uint64 -u, --uint32 uint32 some random uint32 --uints uints (default []) -v, --version version for send + -y, --yes Skip tx broadcasting prompt confirmation From 6c83881fffe219cf195c651f88c1bf49ed5f2805 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Fri, 3 Mar 2023 09:46:31 -0600 Subject: [PATCH 5/6] remove comments --- client/v2/autocli/common.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/client/v2/autocli/common.go b/client/v2/autocli/common.go index acaaa2dc683b..33284c2d886d 100644 --- a/client/v2/autocli/common.go +++ b/client/v2/autocli/common.go @@ -61,14 +61,6 @@ func (b *Builder) buildMethodCommandCommon(descriptor protoreflect.MethodDescrip return exec(cmd, input) } - //if b.AddQueryConnFlags != nil { - // b.AddQueryConnFlags(cmd) - //} - // - //if b.AddTxConnFlags != nil { - // b.AddTxConnFlags(cmd) - //} - return cmd, nil } From e781274b2e5257a77fea704e2177de7a938809d0 Mon Sep 17 00:00:00 2001 From: Jeancarlo Date: Fri, 3 Mar 2023 15:12:19 -0600 Subject: [PATCH 6/6] not allowing nil cmd to exist --- client/v2/autocli/common.go | 4 ---- client/v2/autocli/msg.go | 11 +++++++++-- client/v2/autocli/query.go | 17 ++++++++++++----- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/client/v2/autocli/common.go b/client/v2/autocli/common.go index 33284c2d886d..634947efb136 100644 --- a/client/v2/autocli/common.go +++ b/client/v2/autocli/common.go @@ -17,10 +17,6 @@ func (b *Builder) buildMethodCommandCommon(descriptor protoreflect.MethodDescrip options = &autocliv1.RpcCommandOptions{} } - if options.Skip { - return nil, nil - } - long := options.Long if long == "" { long = util.DescriptorDocs(descriptor) diff --git a/client/v2/autocli/msg.go b/client/v2/autocli/msg.go index 26384fdab37a..93dabe7a2b17 100644 --- a/client/v2/autocli/msg.go +++ b/client/v2/autocli/msg.go @@ -82,7 +82,14 @@ func (b *Builder) AddMsgServiceCommands(cmd *cobra.Command, cmdDescriptor *autoc methodsLength := methods.Len() for i := 0; i < methodsLength; i++ { methodDescriptor := methods.Get(i) - methodOpts := rpcOptMap[methodDescriptor.Name()] + methodOpts, ok := rpcOptMap[methodDescriptor.Name()] + if !ok { + methodOpts = &autocliv1.RpcCommandOptions{} + } + + if methodOpts.Skip { + continue + } methodCmd, err := b.BuildMsgMethodCommand(methodDescriptor, methodOpts) if err != nil { return err @@ -113,7 +120,7 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor err = b.outOrStdoutFormat(cmd, bz) return err }) - if cmd != nil && b.AddTxConnFlags != nil { + if b.AddTxConnFlags != nil { b.AddTxConnFlags(cmd) } return cmd, err diff --git a/client/v2/autocli/query.go b/client/v2/autocli/query.go index c8c701d56b35..1f0734da1d77 100644 --- a/client/v2/autocli/query.go +++ b/client/v2/autocli/query.go @@ -84,15 +84,22 @@ func (b *Builder) AddQueryServiceCommands(cmd *cobra.Command, cmdDescriptor *aut n := methods.Len() for i := 0; i < n; i++ { methodDescriptor := methods.Get(i) - methodOpts := rpcOptMap[methodDescriptor.Name()] + methodOpts, ok := rpcOptMap[methodDescriptor.Name()] + if !ok { + methodOpts = &autocliv1.RpcCommandOptions{} + } + + if methodOpts.Skip { + continue + } + methodCmd, err := b.BuildQueryMethodCommand(methodDescriptor, methodOpts) if err != nil { return err } - if methodCmd != nil { - cmd.AddCommand(methodCmd) - } + cmd.AddCommand(methodCmd) + } return nil @@ -138,7 +145,7 @@ func (b *Builder) BuildQueryMethodCommand(descriptor protoreflect.MethodDescript return nil, err } - if cmd != nil && b.AddQueryConnFlags != nil { + if b.AddQueryConnFlags != nil { b.AddQueryConnFlags(cmd) }