Skip to content

Commit

Permalink
fix(client/v2): set context for queries (#18323)
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Nov 1, 2023
1 parent 79246d2 commit 630836e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions client/v2/autocli/query.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package autocli

import (
"context"
"fmt"
"io"
"time"

autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
"cosmossdk.io/x/tx/signing/aminojson"
"github.com/cockroachdb/errors"
"github.com/cosmos/cosmos-sdk/client"
"github.com/spf13/cobra"
"google.golang.org/protobuf/reflect/protoreflect"

Expand Down Expand Up @@ -112,9 +114,7 @@ func (b *Builder) BuildQueryMethodCommand(descriptor protoreflect.MethodDescript
}

cmd, err := b.buildMethodCommandCommon(descriptor, options, func(cmd *cobra.Command, input protoreflect.Message) error {
if noIndent, _ := cmd.Flags().GetBool(flags.FlagNoIndent); noIndent {
encoderOptions.Indent = ""
}
cmd.SetContext(context.WithValue(context.Background(), client.ClientContextKey, &b.ClientCtx))

clientConn, err := getClientConn(cmd)
if err != nil {
Expand All @@ -126,6 +126,10 @@ func (b *Builder) BuildQueryMethodCommand(descriptor protoreflect.MethodDescript
return err
}

if noIndent, _ := cmd.Flags().GetBool(flags.FlagNoIndent); noIndent {
encoderOptions.Indent = ""
}

enc := encoder(aminojson.NewEncoder(encoderOptions))
bz, err := enc.Marshal(output.Interface())
if err != nil {
Expand Down

0 comments on commit 630836e

Please sign in to comment.