Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(client/v2): better method naming (backport #17858) #17860

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/v2/autocli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error {
}

func (appOptions AppOptions) EnhanceRootCommandWithBuilder(rootCmd *cobra.Command, builder *Builder) error {
if err := builder.Validate(); err != nil {
if err := builder.ValidateAndComplete(); err != nil {
return err
}

Expand Down
6 changes: 5 additions & 1 deletion client/v2/autocli/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ type Builder struct {
AddTxConnFlags func(*cobra.Command)
}

func (b *Builder) Validate() error {
// ValidateAndComplete the builder fields.
// It returns an error if any of the required fields are missing.
// If the Logger is nil, it will be set to a nop logger.
// If the keyring is nil, it will be set to a no keyring.
func (b *Builder) ValidateAndComplete() error {
if b.Logger == nil {
b.Logger = log.NewNopLogger()
}
Expand Down
2 changes: 1 addition & 1 deletion client/v2/autocli/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func initFixture(t *testing.T) *fixture {
AddQueryConnFlags: flags.AddQueryFlagsToCmd,
AddTxConnFlags: flags.AddTxFlagsToCmd,
}
assert.NilError(t, b.Validate())
assert.NilError(t, b.ValidateAndComplete())

return &fixture{
conn: conn,
Expand Down
56 changes: 28 additions & 28 deletions client/v2/autocli/testdata/help-deprecated-msg.golden
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ Usage:
test deprecatedmsg send [flags]

Flags:
--a-bool
--a-coin cosmos.base.v1beta1.Coin
--a-message testpb.AMessage (json)
--a-validator-address account address or key name
--a-bool
--a-coin cosmos.base.v1beta1.Coin
--a-message testpb.AMessage (json)
--a-validator-address account address or key name
-a, --account-number uint The account number of the signing account (offline mode only)
--an-address account address or key name
--an-address account address or 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 binary
--bz binary
--chain-id string The network chain ID
--deprecated-field string
--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)
--duration duration
--durations duration (repeated)
--enums Enum (unspecified | one | two | five | neg-three) (repeated)
--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
Expand All @@ -31,9 +31,9 @@ Flags:
--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
--hidden-bool
--i32 int32
--i64 int
--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
Expand All @@ -42,24 +42,24 @@ Flags:
--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 binary
--page-limit uint
--page-offset uint
--page-reverse
--positional1 int32
--positional2 string
--positional3-varargs cosmos.base.v1beta1.Coin (repeated)
--page-count-total
--page-key binary
--page-limit uint
--page-offset uint
--page-reverse
--positional1 int32
--positional2 string
--positional3-varargs cosmos.base.v1beta1.Coin (repeated)
-s, --sequence uint The sequence number of the signing account (offline mode only)
--shorthand-deprecated-field string
--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
--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)
--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
--u32 uint32
--u64 uint
--uints uints (default [])
-y, --yes Skip tx broadcasting prompt confirmation
62 changes: 31 additions & 31 deletions client/v2/autocli/testdata/help-deprecated.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@ Usage:
test deprecatedecho echo [flags]

Flags:
--a-bool
--a-coin cosmos.base.v1beta1.Coin
--a-consensus-address account address or key name
--a-message testpb.AMessage (json)
--a-validator-address account address or key name
--an-address account address or key name
--a-bool
--a-coin cosmos.base.v1beta1.Coin
--a-consensus-address account address or key name
--a-message testpb.AMessage (json)
--a-validator-address account address or key name
--an-address account address or key name
--an-enum Enum (unspecified | one | two | five | neg-three) (default unspecified)
--bools bools (default [])
--bz binary
--deprecated-field string
--duration duration
--durations duration (repeated)
--enums Enum (unspecified | one | two | five | neg-three) (repeated)
--bz binary
--deprecated-field string
--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
--map-string-coin map[string]cosmos.base.v1beta1.Coin
--hidden-bool
--i32 int32
--i64 int
--map-string-coin map[string]cosmos.base.v1beta1.Coin
--map-string-string stringToString (default [])
--map-string-uint32 stringToUint32
--map-string-uint32 stringToUint32
--no-indent Do not indent JSON output
--node string <host>:<port> 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 binary
--page-limit uint
--page-offset uint
--page-reverse
--positional1 int32
--positional2 string
--positional3-varargs cosmos.base.v1beta1.Coin (repeated)
--shorthand-deprecated-field string
--some-messages testpb.AMessage (json) (repeated)
--str string
--strings strings
--timestamp timestamp (RFC 3339)
--u32 uint32
--u64 uint
--page-count-total
--page-key binary
--page-limit uint
--page-offset uint
--page-reverse
--positional1 int32
--positional2 string
--positional3-varargs cosmos.base.v1beta1.Coin (repeated)
--shorthand-deprecated-field string
--some-messages testpb.AMessage (json) (repeated)
--str string
--strings strings
--timestamp timestamp (RFC 3339)
--u32 uint32
--u64 uint
--uints uints (default [])
38 changes: 19 additions & 19 deletions client/v2/autocli/testdata/help-echo-msg.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ Examples:
send 1 abc {}

Flags:
--a-bool
--a-coin cosmos.base.v1beta1.Coin
--a-message testpb.AMessage (json)
--a-validator-address account address or key name
--a-bool
--a-coin cosmos.base.v1beta1.Coin
--a-message testpb.AMessage (json)
--a-validator-address account address or key name
-a, --account-number uint The account number of the signing account (offline mode only)
--an-address account address or key name
--an-address account address or 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 binary
--bz binary
--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)
--duration duration
--durations duration (repeated)
--enums Enum (unspecified | one | two | five | neg-three) (repeated)
--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
Expand All @@ -37,7 +37,7 @@ Flags:
--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
--i64 int
--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
Expand All @@ -46,19 +46,19 @@ Flags:
--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 binary
--page-limit uint
--page-offset uint
--page-reverse
--page-count-total
--page-key binary
--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
--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)
--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
Expand Down
Loading
Loading