From 0108877a3201281be96ea501d7872c64f923a330 Mon Sep 17 00:00:00 2001 From: mmsqe Date: Mon, 15 Apr 2024 18:51:51 +0800 Subject: [PATCH] Release/v0.50.x backport (#298) * fix(x/bank): align query with multi denoms for send-enabled (#20028) * fix(client/v2): respect output format from client ctx (#20033) --- CHANGELOG.md | 4 ++++ client/v2/CHANGELOG.md | 1 + client/v2/autocli/common.go | 16 ++++++++++++++-- x/bank/autocli.go | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c58b5416df74..bb86c24d7c1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#261](https://github.com/crypto-org-chain/cosmos-sdk/pull/261) `ctx.BlockHeader` don't do protobuf deep copy, shallow copy seems enough, reduce scope of mutex in `PriorityNonceMempool.Remove`. +### Bug Fixes + +* (x/bank) [#20028](https://github.com/cosmos/cosmos-sdk/pull/20028) Align query with multi denoms for send-enabled. + ## [Unreleased-Upstream] ### Bug Fixes diff --git a/client/v2/CHANGELOG.md b/client/v2/CHANGELOG.md index 4aac3deaf2c1..555a5bbfa6bf 100644 --- a/client/v2/CHANGELOG.md +++ b/client/v2/CHANGELOG.md @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#19377](https://github.com/cosmos/cosmos-sdk/pull/19377) Partly fix comment parsing in autocli. * [#19060](https://github.com/cosmos/cosmos-sdk/pull/19060) Simplify key flag parsing logic in flag handler. +* [#20033](https://github.com/cosmos/cosmos-sdk/pull/20033) Respect output format from client ctx. ## [v2.0.0-beta.1] - 2023-11-07 diff --git a/client/v2/autocli/common.go b/client/v2/autocli/common.go index 4c9a8f07dc2b..de5cc523434a 100644 --- a/client/v2/autocli/common.go +++ b/client/v2/autocli/common.go @@ -10,6 +10,8 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" "cosmossdk.io/client/v2/internal/flags" "cosmossdk.io/client/v2/internal/util" + + "github.com/cosmos/cosmos-sdk/client" ) type cmdType int @@ -225,11 +227,21 @@ func enhanceCustomCmd(builder *Builder, cmd *cobra.Command, cmdType cmdType, mod // outOrStdoutFormat formats the output based on the output flag and writes it to the command's output stream. func (b *Builder) outOrStdoutFormat(cmd *cobra.Command, out []byte) error { + clientCtx := client.Context{} + if v := cmd.Context().Value(client.ClientContextKey); v != nil { + clientCtx = *(v.(*client.Context)) + } + flagSet := cmd.Flags() + if clientCtx.OutputFormat == "" || flagSet.Changed(flags.FlagOutput) { + output, _ := flagSet.GetString(flags.FlagOutput) + clientCtx = clientCtx.WithOutputFormat(output) + } + var err error - outputType := cmd.Flag(flags.FlagOutput) + outputType := clientCtx.OutputFormat // if the output type is text, convert the json to yaml // if output type is json or nil, default to json - if outputType != nil && outputType.Value.String() == flags.OutputFormatText { + if outputType == flags.OutputFormatText { out, err = yaml.JSONToYAML(out) if err != nil { return err diff --git a/x/bank/autocli.go b/x/bank/autocli.go index 4224dbafacd1..6c421ab0aa42 100644 --- a/x/bank/autocli.go +++ b/x/bank/autocli.go @@ -82,7 +82,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { To look up one or more specific denoms, supply them as arguments to this command. To look up all denoms, do not provide any arguments.`, ), - PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "denoms"}}, + PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "denoms", Varargs: true}}, }, }, },