From 78db2526554523b68476da59d21e032907b24b11 Mon Sep 17 00:00:00 2001 From: violet Date: Wed, 20 Nov 2024 10:52:04 -0500 Subject: [PATCH 1/2] fix: prevent duplicate addition of customCommands by autocli --- client/v2/CHANGELOG.md | 1 + client/v2/autocli/common.go | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/v2/CHANGELOG.md b/client/v2/CHANGELOG.md index f475f2049513..9fea6d3d24d1 100644 --- a/client/v2/CHANGELOG.md +++ b/client/v2/CHANGELOG.md @@ -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` ## [v2.0.0-beta.5] - 2024-09-18 diff --git a/client/v2/autocli/common.go b/client/v2/autocli/common.go index 5c32f16ca32a..409198267cfd 100644 --- a/client/v2/autocli/common.go +++ b/client/v2/autocli/common.go @@ -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 } From d60e74028a38d429eb16ab2a613375b5abdddf14 Mon Sep 17 00:00:00 2001 From: violet <158512193+fastfadingviolets@users.noreply.github.com> Date: Thu, 21 Nov 2024 09:47:38 -0500 Subject: [PATCH 2/2] Update client/v2/CHANGELOG.md Co-authored-by: Julien Robert --- client/v2/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/v2/CHANGELOG.md b/client/v2/CHANGELOG.md index 9fea6d3d24d1..5cff1928e437 100644 --- a/client/v2/CHANGELOG.md +++ b/client/v2/CHANGELOG.md @@ -58,7 +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` +* [#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