Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
co-authored by
Julien Robert
parent
8dcd61baf0
commit
bdbd2b09c9
@@ -39,7 +39,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
### Improvements
|
||||
|
||||
* [#19060](https://github.com/cosmos/cosmos-sdk/pull/19060) Use client context from root (or enhanced) command in autocli commands.
|
||||
* Note, the given command must have a `client.Context` in its context.
|
||||
* Note, the given command must have a `client.Context` in its context.
|
||||
* [#19216](https://github.com/cosmos/cosmos-sdk/pull/19216) Do not overwrite TxConfig, use directly the one provided in context. TxConfig should always be set in the `client.Context` in `root.go` of an app.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
sdkflags "github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
)
|
||||
|
||||
// AppOptions are autocli options for an app. These options can be built via depinject based on an app config. Ex:
|
||||
@@ -48,9 +47,6 @@ type AppOptions struct {
|
||||
|
||||
// ClientCtx contains the necessary information needed to execute the commands.
|
||||
ClientCtx client.Context
|
||||
|
||||
// TxConfigOptions are the transactions config options.
|
||||
TxConfigOpts tx.ConfigOptions
|
||||
}
|
||||
|
||||
// EnhanceRootCommand enhances the provided root command with autocli AppOptions,
|
||||
@@ -78,7 +74,6 @@ func (appOptions AppOptions) EnhanceRootCommand(rootCmd *cobra.Command) error {
|
||||
ConsensusAddressCodec: appOptions.ConsensusAddressCodec,
|
||||
Keyring: appOptions.Keyring,
|
||||
},
|
||||
TxConfigOpts: appOptions.TxConfigOpts,
|
||||
GetClientConn: func(cmd *cobra.Command) (grpc.ClientConnInterface, error) {
|
||||
return client.GetClientQueryContext(cmd)
|
||||
},
|
||||
|
||||
@@ -5,8 +5,6 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
|
||||
"cosmossdk.io/client/v2/autocli/flag"
|
||||
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
)
|
||||
|
||||
// Builder manages options for building CLI commands.
|
||||
@@ -18,9 +16,6 @@ type Builder struct {
|
||||
// from a given context.
|
||||
GetClientConn func(*cobra.Command) (grpc.ClientConnInterface, error)
|
||||
|
||||
// TxConfigOptions is required to support sign mode textual
|
||||
TxConfigOpts authtx.ConfigOptions
|
||||
|
||||
// AddQueryConnFlags and AddTxConnFlags are functions that add flags to query and transaction commands
|
||||
AddQueryConnFlags func(*cobra.Command)
|
||||
AddTxConnFlags func(*cobra.Command)
|
||||
|
||||
@@ -16,10 +16,6 @@ import (
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
clienttx "github.com/cosmos/cosmos-sdk/client/tx"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx/signing"
|
||||
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
||||
authtxconfig "github.com/cosmos/cosmos-sdk/x/auth/tx/config"
|
||||
)
|
||||
|
||||
// BuildMsgCommand builds the msg commands for all the provided modules. If a custom command is provided for a
|
||||
@@ -121,24 +117,6 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor
|
||||
clientCtx = clientCtx.WithCmdContext(cmd.Context())
|
||||
clientCtx = clientCtx.WithOutput(cmd.OutOrStdout())
|
||||
|
||||
// enable sign mode textual
|
||||
// the config is always overwritten as we need to have set the flags to the client context
|
||||
// this ensures that the context has the correct client.
|
||||
if !clientCtx.Offline {
|
||||
b.TxConfigOpts.EnabledSignModes = append(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
|
||||
b.TxConfigOpts.TextualCoinMetadataQueryFn = authtxconfig.NewGRPCCoinMetadataQueryFn(clientCtx)
|
||||
|
||||
txConfig, err := authtx.NewTxConfigWithOptions(
|
||||
codec.NewProtoCodec(clientCtx.InterfaceRegistry),
|
||||
b.TxConfigOpts,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithTxConfig(txConfig)
|
||||
}
|
||||
|
||||
// set signer to signer field if empty
|
||||
fd := input.Descriptor().Fields().ByName(protoreflect.Name(flag.GetSignerFieldName(input.Descriptor())))
|
||||
if addr := input.Get(fd).String(); addr == "" {
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ require (
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.11.0 // indirect
|
||||
github.com/spf13/cast v1.6.0 // indirect
|
||||
github.com/spf13/viper v1.18.1 // indirect
|
||||
github.com/spf13/viper v1.18.2 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
github.com/subosito/gotenv v1.6.0 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
|
||||
|
||||
+2
-2
@@ -676,8 +676,8 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/spf13/viper v1.18.1 h1:rmuU42rScKWlhhJDyXZRKJQHXFX02chSVW1IvkPGiVM=
|
||||
github.com/spf13/viper v1.18.1/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
|
||||
github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
|
||||
github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
|
||||
github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw=
|
||||
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
|
||||
|
||||
Reference in New Issue
Block a user