Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit context background #8093

Merged
merged 14 commits into from
Feb 3, 2021
Prev Previous commit
Next Next commit
fixed minor issues
  • Loading branch information
cyberbono3 committed Feb 2, 2021
commit f3cd95c71948b7d3018c49d8a24036c3922f444b
6 changes: 2 additions & 4 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion client/keys/parse.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package keys

import (
"context"
"encoding/hex"
"errors"
"fmt"
Expand Down
20 changes: 0 additions & 20 deletions simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,6 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
return rootCmd, encodingConfig
}

// Execute executes the root command.
func Execute(rootCmd *cobra.Command) error {
// Create and set a client.Context on the command's Context. During the pre-run
// of the root command, a default initialized client.Context is provided to
// seed child command execution with values such as AccountRetriver, Keyring,
// and a Tendermint RPC. This requires the use of a pointer reference when
// getting and setting the client.Context. Ideally, we utilize
// https://github.com/spf13/cobra/pull/1118.
srvCtx := server.NewDefaultContext()
ctx := rootCmd.Context()
ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{})
ctx = context.WithValue(ctx, server.ServerContextKey, srvCtx)

rootCmd.PersistentFlags().String(flags.FlagLogLevel, zerolog.InfoLevel.String(), "The logging level (trace|debug|info|warn|error|fatal|panic)")
rootCmd.PersistentFlags().String(flags.FlagLogFormat, tmcfg.LogFormatJSON, "The logging format (json|plain)")

executor := tmcli.PrepareBaseCmd(rootCmd, "", simapp.DefaultNodeHome)
return executor.ExecuteContext(ctx)
}

func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
authclient.Codec = encodingConfig.Marshaler

Expand Down
1 change: 0 additions & 1 deletion x/auth/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"
"strings"

Expand Down
1 change: 0 additions & 1 deletion x/bank/client/testutil/cli_helpers.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package testutil

import (
"context"
"fmt"

"github.com/spf13/cobra"
Expand Down
3 changes: 1 addition & 2 deletions x/distribution/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -252,7 +251,7 @@ $ %s query distribution rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p %s1ggh
}

// query for rewards from a particular delegation
ctx := cmd.Context()
ctx := cmd.Context()
if len(args) == 2 {
validatorAddr, err := sdk.ValAddressFromBech32(args[1])
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion x/distribution/client/cli/tx.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"
"strings"

Expand Down
5 changes: 2 additions & 3 deletions x/gov/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"
"strconv"
"strings"
Expand Down Expand Up @@ -208,7 +207,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
}

// check to see if the proposal is in the store
ctx := cmd.Context()
ctx := cmd.Context()
_, err = queryClient.Proposal(
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
Expand All @@ -221,7 +220,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
if err != nil {
return err
}

res, err := queryClient.Vote(
ctx,
&types.QueryVoteRequest{ProposalId: proposalID, Voter: args[1]},
Expand Down
3 changes: 1 addition & 2 deletions x/ibc/applications/transfer/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -99,7 +98,7 @@ func GetCmdParams() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)

res, _ := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
return clientCtx.PrintOutput(res.Params)
return clientCtx.PrintProto(res.Params)
},
}

Expand Down
3 changes: 1 addition & 2 deletions x/ibc/core/02-client/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"errors"
"fmt"

Expand Down Expand Up @@ -251,7 +250,7 @@ func GetCmdParams() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)

res, _ := queryClient.ClientParams(cmd.Context(), &types.QueryClientParamsRequest{})
return clientCtx.PrintOutput(res.Params)
return clientCtx.PrintProto(res.Params)
},
}

Expand Down
1 change: 0 additions & 1 deletion x/ibc/core/03-connection/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"
Expand Down
1 change: 0 additions & 1 deletion x/ibc/core/04-channel/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"
"strconv"

Expand Down
1 change: 0 additions & 1 deletion x/mint/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"
Expand Down
2 changes: 0 additions & 2 deletions x/params/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cli

import (
"context"

"github.com/spf13/cobra"

"github.com/cosmos/cosmos-sdk/client"
Expand Down
1 change: 0 additions & 1 deletion x/slashing/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"strings"

"github.com/spf13/cobra"
Expand Down
1 change: 0 additions & 1 deletion x/staking/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"
"strconv"
"strings"
Expand Down
1 change: 0 additions & 1 deletion x/upgrade/client/cli/query.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cli

import (
"context"
"fmt"

"github.com/spf13/cobra"
Expand Down