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(simapp): improve autocli legacy wiring example #19215

Closed
wants to merge 2 commits into from
Closed
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
6 changes: 3 additions & 3 deletions client/v2/autocli/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"cosmossdk.io/client/v2/autocli/keyring"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/depinject"
"cosmossdk.io/x/auth/tx"
authtx "cosmossdk.io/x/auth/tx"

"github.com/cosmos/cosmos-sdk/client"
sdkflags "github.com/cosmos/cosmos-sdk/client/flags"
Expand Down Expand Up @@ -42,8 +42,8 @@ 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
// TxConfigOpts are the transactions config options.
TxConfigOpts authtx.ConfigOptions
}

// EnhanceRootCommand enhances the provided root command with autocli AppOptions,
Expand Down
12 changes: 8 additions & 4 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"cosmossdk.io/log"
"cosmossdk.io/simapp"
"cosmossdk.io/simapp/params"
"cosmossdk.io/x/auth/tx"
authtx "cosmossdk.io/x/auth/tx"
txmodule "cosmossdk.io/x/auth/tx/config"
"cosmossdk.io/x/auth/types"

Expand Down Expand Up @@ -76,12 +76,12 @@ func NewRootCmd() *cobra.Command {
// sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode
// is only available if the client is online.
if !initClientCtx.Offline {
enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
txConfigOpts := tx.ConfigOptions{
enabledSignModes := append(authtx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
txConfigOpts := authtx.ConfigOptions{
EnabledSignModes: enabledSignModes,
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx),
}
txConfig, err := tx.NewTxConfigWithOptions(
txConfig, err := authtx.NewTxConfigWithOptions(
initClientCtx.Codec,
txConfigOpts,
)
Expand Down Expand Up @@ -116,6 +116,10 @@ func NewRootCmd() *cobra.Command {
autoCliOpts := tempApp.AutoCliOpts()
autoCliOpts.Keyring, _ = keyring.NewAutoCLIKeyring(initClientCtx.Keyring)
autoCliOpts.ClientCtx = initClientCtx
autoCliOpts.TxConfigOpts = authtx.ConfigOptions{
Copy link
Member Author

@julienrbrt julienrbrt Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the latest client/v2 we are able to read from the root context, so we can actually remove this field. However, this is what is working with the current latest tagged client/v2.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, we already set those in the app.go when manually wiring, so this seems triple work.

EnabledSignModes: authtx.DefaultSignModes,
TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx),
}

if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
Expand Down
Loading