-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
fix(simapp): textual wiring #18242
fix(simapp): textual wiring #18242
Conversation
WalkthroughThis pull request introduces significant changes to improve code simplicity, maintainability, and performance. It includes updates to the client context, transaction configuration, and sign modes. It also refactors the code to remove unnecessary variables and functions, and corrects typos. The changes are spread across several files, including Changes
TipsChat with CodeRabbit Bot (
|
@julienrbrt your pull request is missing a changelog! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (5)
- client/cmd.go (3 hunks)
- client/tx/factory.go (1 hunks)
- client/v2/autocli/msg.go (1 hunks)
- simapp/simd/cmd/root_v2.go (5 hunks)
- x/auth/tx/config/config.go (2 hunks)
Files skipped from review due to trivial changes (2)
- client/tx/factory.go
- x/auth/tx/config/config.go
Additional comments: 9
client/v2/autocli/msg.go (2)
118-119: The client context is now updated with the command context and output. This is a good practice as it ensures that the client context is always in sync with the command context and output.
121-135: The creation of
txConfig
and its assignment toclientCtx
is now inside the condition that checks if the application is not offline and if the sign mode textual is not enabled. This change is logical as it prevents unnecessary operations when the application is offline or the sign mode textual is already enabled. However, ensure that this change does not affect other parts of the code that rely onclientCtx
having atxConfig
even when the application is offline or the sign mode textual is already enabled.client/cmd.go (2)
11-11: The import
golang.org/x/exp/slices
is added to use theslices.Contains
function. Ensure that this package is maintained and compatible with the current codebase.287-287: The loop checking for the presence of
SignMode_SIGN_MODE_TEXTUAL
inSupportedModes()
has been replaced with a call toslices.Contains
. This is a good optimization as it simplifies the code and potentially improves performance.simapp/simd/cmd/root_v2.go (5)
27-33: The import of
authtxconfig
has been added and the variabletxConfigOpts
has been removed from theNewRootCmd
function. This change seems to be part of a larger refactoring to move the creation oftxConfig
fromNewRootCmd
toProvideClientContext
. Ensure that this change does not affect the functionality of theNewRootCmd
function.47-52: The
txConfigOpts
variable has been removed from theNewRootCmd
function. This change is part of the refactoring to move the creation oftxConfig
fromNewRootCmd
toProvideClientContext
. Ensure that this change does not affect the functionality of theNewRootCmd
function.101-101: The
ProvideClientContext
function now takestxConfigOpts
as an argument instead oftxConfig
. This change is part of the refactoring to move the creation oftxConfig
fromNewRootCmd
toProvideClientContext
. Ensure that all calls toProvideClientContext
have been updated to match the new signature.109-114: The
WithTxConfig
method call has been removed from theclientCtx
initialization. This change is part of the refactoring to move the creation oftxConfig
fromNewRootCmd
toProvideClientContext
. Ensure that this change does not affect the functionality of theclientCtx
.128-134: The
txConfig
is now created in theProvideClientContext
function usingtxConfigOpts
and theNewTxConfigWithOptions
function. ThetxConfig
is then set in theclientCtx
using theWithTxConfig
method. This change is part of the refactoring to move the creation oftxConfig
fromNewRootCmd
toProvideClientContext
. Ensure that this change does not affect the functionality of theclientCtx
andtxConfig
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested on v1 and v2. LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files ignored due to filter (1)
- client/v2/go.mod
Files selected for processing (2)
- client/tx/tx.go (2 hunks)
- client/v2/autocli/msg.go (2 hunks)
Files skipped from review due to trivial changes (1)
- client/tx/tx.go
Additional comments: 3
client/v2/autocli/msg.go (3)
6-11: The import
"golang.org/x/exp/slices"
has been removed. Ensure that this package is not used elsewhere in the code. If it is, you may need to replace its usage with an equivalent function or method.117-118: The client context is now updated with the command context and output. This is a good practice as it ensures that the client context is always in sync with the command context and output.
121-136: The check for
!clientCtx.Offline
has been moved to encompass more code, including the creation oftxConfig
. This change could potentially improve performance by avoiding unnecessary operations whenclientCtx.Offline
is true. However, ensure that this change does not affect the expected behavior of the code.- if !clientCtx.Offline && !slices.Contains(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) { + if !clientCtx.Offline {Committable suggestion (Beta)
if !clientCtx.Offline { clientCtx = clientCtx.WithCmdContext(cmd.Context()) clientCtx = clientCtx.WithOutput(cmd.OutOrStdout()) 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) }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(cherry picked from commit fd93ee7) # Conflicts: # UPGRADING.md # client/tx/factory.go # client/tx/tx.go # client/v2/go.mod
Co-authored-by: Julien Robert <[email protected]>
@@ -115,21 +114,26 @@ func (b *Builder) BuildMsgMethodCommand(descriptor protoreflect.MethodDescriptor | |||
return err | |||
} | |||
|
|||
// enable sign mode textual and config tx options | |||
if !clientCtx.Offline && !slices.Contains(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We removed this check here that !slices.Contains(b.TxConfigOpts.EnabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL)
, was that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it was intentional.
In the client (autocli or root.go), we always need to overwrite the TxConfigOpts.TextualCoinMetadataQueryFn
to use NewGRPCCoinMetadataQueryFn
. If an app is using depinject, that value will using the bank keeper, which is only correct for the server (app.go)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it and thank you!
Description
Closes: #17822
Verifies that textual works and --node flags works as well.
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
x/protocolpool
module in the UPGRADING.md file, helping developers to understand the changes and adapt their code accordingly.