Skip to content

Commit 8210b50

Browse files
mergify[bot]fastfadingvioletsjulienrbrt
authored
fix(client/v2/autocli): prevent duplicate addition of customCommands (backport #22576) (#22615)
Co-authored-by: violet <[email protected]> Co-authored-by: Julien Robert <[email protected]>
1 parent 56c2c7d commit 8210b50

File tree

6 files changed

+19
-7
lines changed

6 files changed

+19
-7
lines changed

client/v2/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
3636

3737
## [Unreleased]
3838

39+
## [v2.0.0-beta.6] - 2024-11-21
40+
3941
### Improvements
4042

4143
* [#22443](https://github.com/cosmos/cosmos-sdk/pull/22443) Add keyring flags in query commands.
@@ -44,6 +46,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
4446
### Bug Fixes
4547

4648
* [#21809](https://github.com/cosmos/cosmos-sdk/pull/21809) Correctly handle enhanced sub commands.
49+
* [#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
4750

4851
## [v2.0.0-beta.5] - 2024-09-18
4952

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
}

simapp/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.21
44

55
require (
66
cosmossdk.io/api v0.7.6
7-
cosmossdk.io/client/v2 v2.0.0-beta.5
7+
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e
88
cosmossdk.io/collections v0.4.0 // indirect
99
cosmossdk.io/core v0.11.1
1010
cosmossdk.io/depinject v1.1.0

simapp/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V
184184
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
185185
cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY=
186186
cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
187-
cosmossdk.io/client/v2 v2.0.0-beta.5 h1:0LVv3nEByn//hFDIrYLs2WvsEU3HodOelh4SDHnA/1I=
188-
cosmossdk.io/client/v2 v2.0.0-beta.5/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
187+
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e h1:NqQEVIjRqSdsAfTI9uDRZ1oU/cQuCoAbUuIkndQM+Bo=
188+
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
189189
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
190190
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
191191
cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA=

tests/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ require (
3636
cloud.google.com/go/compute/metadata v0.5.0 // indirect
3737
cloud.google.com/go/iam v1.1.6 // indirect
3838
cloud.google.com/go/storage v1.38.0 // indirect
39-
cosmossdk.io/client/v2 v2.0.0-beta.5 // indirect
39+
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e // indirect
4040
cosmossdk.io/collections v0.4.0 // indirect
4141
cosmossdk.io/x/circuit v0.1.1 // indirect
4242
filippo.io/edwards25519 v1.0.0 // indirect

tests/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1V
184184
cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M=
185185
cosmossdk.io/api v0.7.6 h1:PC20PcXy1xYKH2KU4RMurVoFjjKkCgYRbVAD4PdqUuY=
186186
cosmossdk.io/api v0.7.6/go.mod h1:IcxpYS5fMemZGqyYtErK7OqvdM0C8kdW3dq8Q/XIG38=
187-
cosmossdk.io/client/v2 v2.0.0-beta.5 h1:0LVv3nEByn//hFDIrYLs2WvsEU3HodOelh4SDHnA/1I=
188-
cosmossdk.io/client/v2 v2.0.0-beta.5/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
187+
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e h1:NqQEVIjRqSdsAfTI9uDRZ1oU/cQuCoAbUuIkndQM+Bo=
188+
cosmossdk.io/client/v2 v2.0.0-beta.5.0.20241121152743-3dad36d9a29e/go.mod h1:4p0P6o0ro+FizakJUYS9SeM94RNbv0thLmkHRw5o5as=
189189
cosmossdk.io/collections v0.4.0 h1:PFmwj2W8szgpD5nOd8GWH6AbYNi1f2J6akWXJ7P5t9s=
190190
cosmossdk.io/collections v0.4.0/go.mod h1:oa5lUING2dP+gdDquow+QjlF45eL1t4TJDypgGd+tv0=
191191
cosmossdk.io/core v0.11.1 h1:h9WfBey7NAiFfIcUhDVNS503I2P2HdZLebJlUIs8LPA=

0 commit comments

Comments
 (0)