fix(client/v2/autocli): prevent duplicate addition of customCommands (backport #22576) (#22614)

Co-authored-by: violet <158512193+fastfadingviolets@users.noreply.github.com>
This commit is contained in:
mergify[bot] 2024-11-21 16:39:40 +01:00 committed by GitHub
parent adf5e1ee1f
commit 0d34054516
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes
* [#21853](https://github.com/cosmos/cosmos-sdk/pull/21853) Fix `*big.Int` unmarshalling in txs.
* [#22576](https://github.com/cosmos/cosmos-sdk/pull/22576) Fix duplicate command addition in `autocli` when custom enhanced command has a different name than module name
## [v2.0.0-beta.5] - 2024-09-18

View File

@ -140,7 +140,16 @@ func (b *Builder) enhanceCommandCommon(
// if we have a custom command use that instead of generating one
if custom, ok := customCmds[moduleName]; ok {
if hasModuleOptions { // check if we need to enhance the existing command
// Custom may not be called the same as its module, so we need to have a separate check here
if subCmd := findSubCommand(cmd, custom.Name()); subCmd != nil {
if hasModuleOptions { // check if we need to enhance the existing command
if err := enhanceCustomCmd(b, subCmd, cmdType, modOpts); err != nil {
return err
}
}
continue
}
if hasModuleOptions { // check if we need to enhance the new command
if err := enhanceCustomCmd(b, custom, cmdType, modOpts); err != nil {
return err
}