Skip to content

Commit f2b0f2e

Browse files
fix: prevent duplicate addition of customCommands by autocli
1 parent d810b77 commit f2b0f2e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

client/v2/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
5858
### Bug Fixes
5959

6060
* [#21853](https://github.com/cosmos/cosmos-sdk/pull/21853) Fix `*big.Int` unmarshalling in txs.
61+
* [cosmos/gaia#3412](https://github.com/cosmos/gaia/issues/3412) Fix duplicate command addition in `autocli`
6162

6263
## [v2.0.0-beta.5] - 2024-09-18
6364

client/v2/autocli/common.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,16 @@ func (b *Builder) enhanceCommandCommon(
140140

141141
// if we have a custom command use that instead of generating one
142142
if custom, ok := customCmds[moduleName]; ok {
143-
if hasModuleOptions { // check if we need to enhance the existing command
143+
// Custom may not be called the same as its module, so we need to have a separate check here
144+
if subCmd := findSubCommand(cmd, custom.Name()); subCmd != nil {
145+
if hasModuleOptions { // check if we need to enhance the existing command
146+
if err := enhanceCustomCmd(b, subCmd, cmdType, modOpts); err != nil {
147+
return err
148+
}
149+
}
150+
continue
151+
}
152+
if hasModuleOptions { // check if we need to enhance the new command
144153
if err := enhanceCustomCmd(b, custom, cmdType, modOpts); err != nil {
145154
return err
146155
}

0 commit comments

Comments
 (0)