Limit context background (#8093)

* limit context background

* update

* fixed minor issues

* fixed TestStatusCommand

* Fix keyring import from older versions. (#8436)

Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: sahith-narahari <sahithnarahari@gmail.com>

* Add changelog (#8490)

* fix: tendermint subcommands should not create missing files (#8481)

If the user specifies an incorrect `--home`, then the old behaviour
would automatically populate it with fresh values, but we should
fail instead.

* limit context background

* update

* fixed minor issues

* fixed TestStatusCommand

* statik.go

* replaced static.go

Co-authored-by: Jonathan Gimeno <jgimeno@gmail.com>
Co-authored-by: Alessio Treglia <alessio@tendermint.com>
Co-authored-by: sahith-narahari <sahithnarahari@gmail.com>
Co-authored-by: Michael FIG <mfig@agoric.com>
This commit is contained in:
Andrei Ivasko 2021-02-03 01:47:25 -08:00 committed by GitHub
parent ce161c4f0c
commit d37c590e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 96 additions and 107 deletions

View File

@ -97,8 +97,7 @@ func TestSetCmdClientContextHandler(t *testing.T) {
tc := tc
t.Run(tc.name, func(t *testing.T) {
ctx := context.Background()
ctx = context.WithValue(ctx, client.ClientContextKey, &client.Context{})
ctx := context.WithValue(context.Background(), client.ClientContextKey, &client.Context{})
cmd := newCmd()
_ = testutil.ApplyMockIODiscardOutErr(cmd)

View File

@ -8,12 +8,12 @@ import (
"github.com/cosmos/cosmos-sdk/client"
)
func getBlock(clientCtx client.Context, height *int64) (*ctypes.ResultBlock, error) {
func getBlock(ctx context.Context, clientCtx client.Context, height *int64) (*ctypes.ResultBlock, error) {
// get the node
node, err := clientCtx.GetNode()
if err != nil {
return nil, err
}
return node.Block(context.Background(), height)
return node.Block(ctx, height)
}

View File

@ -34,8 +34,8 @@ func NewQueryServer(clientCtx client.Context, interfaceRegistry codectypes.Inter
}
// GetSyncing implements ServiceServer.GetSyncing
func (s queryServer) GetSyncing(_ context.Context, _ *GetSyncingRequest) (*GetSyncingResponse, error) {
status, err := getNodeStatus(s.clientCtx)
func (s queryServer) GetSyncing(ctx context.Context, _ *GetSyncingRequest) (*GetSyncingResponse, error) {
status, err := getNodeStatus(ctx, s.clientCtx)
if err != nil {
return nil, err
}
@ -45,8 +45,8 @@ func (s queryServer) GetSyncing(_ context.Context, _ *GetSyncingRequest) (*GetSy
}
// GetLatestBlock implements ServiceServer.GetLatestBlock
func (s queryServer) GetLatestBlock(context.Context, *GetLatestBlockRequest) (*GetLatestBlockResponse, error) {
status, err := getBlock(s.clientCtx, nil)
func (s queryServer) GetLatestBlock(ctx context.Context, _ *GetLatestBlockRequest) (*GetLatestBlockResponse, error) {
status, err := getBlock(ctx, s.clientCtx, nil)
if err != nil {
return nil, err
}
@ -64,7 +64,7 @@ func (s queryServer) GetLatestBlock(context.Context, *GetLatestBlockRequest) (*G
}
// GetBlockByHeight implements ServiceServer.GetBlockByHeight
func (s queryServer) GetBlockByHeight(_ context.Context, req *GetBlockByHeightRequest) (*GetBlockByHeightResponse, error) {
func (s queryServer) GetBlockByHeight(ctx context.Context, req *GetBlockByHeightRequest) (*GetBlockByHeightResponse, error) {
chainHeight, err := rpc.GetChainHeight(s.clientCtx)
if err != nil {
return nil, err
@ -74,7 +74,7 @@ func (s queryServer) GetBlockByHeight(_ context.Context, req *GetBlockByHeightRe
return nil, status.Error(codes.InvalidArgument, "requested block height is bigger then the chain length")
}
res, err := getBlock(s.clientCtx, &req.Height)
res, err := getBlock(ctx, s.clientCtx, &req.Height)
if err != nil {
return nil, err
}
@ -96,7 +96,7 @@ func (s queryServer) GetLatestValidatorSet(ctx context.Context, req *GetLatestVa
return nil, err
}
validatorsRes, err := rpc.GetValidators(s.clientCtx, nil, &page, &limit)
validatorsRes, err := rpc.GetValidators(ctx, s.clientCtx, nil, &page, &limit)
if err != nil {
return nil, err
}
@ -147,7 +147,7 @@ func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *GetValida
return nil, status.Error(codes.InvalidArgument, "requested block height is bigger then the chain length")
}
validatorsRes, err := rpc.GetValidators(s.clientCtx, &req.Height, &page, &limit)
validatorsRes, err := rpc.GetValidators(ctx, s.clientCtx, &req.Height, &page, &limit)
if err != nil {
return nil, err
@ -175,7 +175,7 @@ func (s queryServer) GetValidatorSetByHeight(ctx context.Context, req *GetValida
// GetNodeInfo implements ServiceServer.GetNodeInfo
func (s queryServer) GetNodeInfo(ctx context.Context, req *GetNodeInfoRequest) (*GetNodeInfoResponse, error) {
status, err := getNodeStatus(s.clientCtx)
status, err := getNodeStatus(ctx, s.clientCtx)
if err != nil {
return nil, err
}

View File

@ -8,10 +8,10 @@ import (
"github.com/cosmos/cosmos-sdk/client"
)
func getNodeStatus(clientCtx client.Context) (*ctypes.ResultStatus, error) {
func getNodeStatus(ctx context.Context, clientCtx client.Context) (*ctypes.ResultStatus, error) {
node, err := clientCtx.GetNode()
if err != nil {
return &ctypes.ResultStatus{}, err
}
return node.Status(context.Background())
return node.Status(ctx)
}

View File

@ -1,7 +1,6 @@
package keys
import (
"context"
"encoding/hex"
"errors"
"fmt"
@ -86,7 +85,7 @@ hexadecimal into bech32 cosmos prefixed format and vice versa.
}
func parseKey(cmd *cobra.Command, args []string) error {
config, _ := sdk.GetSealedConfig(context.Background())
config, _ := sdk.GetSealedConfig(cmd.Context())
return doParseKey(cmd, config, args)
}

View File

@ -50,7 +50,7 @@ func ValidatorCommand() *cobra.Command {
page, _ := cmd.Flags().GetInt(flags.FlagPage)
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
result, err := GetValidators(clientCtx, height, &page, &limit)
result, err := GetValidators(cmd.Context(), clientCtx, height, &page, &limit)
if err != nil {
return err
}
@ -117,14 +117,14 @@ func validatorOutput(validator *tmtypes.Validator) (ValidatorOutput, error) {
}
// GetValidators from client
func GetValidators(clientCtx client.Context, height *int64, page, limit *int) (ResultValidatorsOutput, error) {
func GetValidators(ctx context.Context, clientCtx client.Context, height *int64, page, limit *int) (ResultValidatorsOutput, error) {
// get the node
node, err := clientCtx.GetNode()
if err != nil {
return ResultValidatorsOutput{}, err
}
validatorsRes, err := node.Validators(context.Background(), height, page, limit)
validatorsRes, err := node.Validators(ctx, height, page, limit)
if err != nil {
return ResultValidatorsOutput{}, err
}
@ -172,7 +172,7 @@ func ValidatorSetRequestHandlerFn(clientCtx client.Context) http.HandlerFunc {
return
}
output, err := GetValidators(clientCtx, &height, &page, &limit)
output, err := GetValidators(r.Context(), clientCtx, &height, &page, &limit)
if rest.CheckInternalServerError(w, err) {
return
}
@ -189,7 +189,7 @@ func LatestValidatorSetRequestHandlerFn(clientCtx client.Context) http.HandlerFu
return
}
output, err := GetValidators(clientCtx, nil, &page, &limit)
output, err := GetValidators(r.Context(), clientCtx, nil, &page, &limit)
if rest.CheckInternalServerError(w, err) {
return
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"strings"
@ -58,7 +57,7 @@ $ <appd> query auth params
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}
@ -90,7 +89,7 @@ func GetAccountCmd() *cobra.Command {
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Account(context.Background(), &types.QueryAccountRequest{Address: key.String()})
res, err := queryClient.Account(cmd.Context(), &types.QueryAccountRequest{Address: key.String()})
if err != nil {
return err
}

View File

@ -74,11 +74,10 @@ Example:
if err != nil {
return err
}
ctx := cmd.Context()
if denom == "" {
params := types.NewQueryAllBalancesRequest(addr, pageReq)
res, err := queryClient.AllBalances(cmd.Context(), params)
res, err := queryClient.AllBalances(ctx, params)
if err != nil {
return err
}
@ -86,7 +85,7 @@ Example:
}
params := types.NewQueryBalanceRequest(addr, denom)
res, err := queryClient.Balance(cmd.Context(), params)
res, err := queryClient.Balance(ctx, params)
if err != nil {
return err
}
@ -183,9 +182,9 @@ To query for the total supply of a specific coin denomination use:
}
queryClient := types.NewQueryClient(clientCtx)
ctx := cmd.Context()
if denom == "" {
res, err := queryClient.TotalSupply(cmd.Context(), &types.QueryTotalSupplyRequest{})
res, err := queryClient.TotalSupply(ctx, &types.QueryTotalSupplyRequest{})
if err != nil {
return err
}
@ -193,7 +192,7 @@ To query for the total supply of a specific coin denomination use:
return clientCtx.PrintProto(res)
}
res, err := queryClient.SupplyOf(cmd.Context(), &types.QuerySupplyOfRequest{Denom: denom})
res, err := queryClient.SupplyOf(ctx, &types.QuerySupplyOfRequest{Denom: denom})
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package testutil
import (
"context"
"fmt"
"github.com/spf13/cobra"
@ -59,7 +58,7 @@ ignored as it is implied from [from_key_or_address].`,
msg := types.NewMsgSend(clientCtx.GetFromAddress(), toAddr, coins)
svcMsgClientConn := &msgservice.ServiceMsgClientConn{}
bankMsgClient := types.NewMsgClient(svcMsgClientConn)
_, err = bankMsgClient.Send(context.Background(), msg)
_, err = bankMsgClient.Send(cmd.Context(), msg)
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"strconv"
"strings"
@ -50,7 +49,7 @@ func GetCmdQueryParams() *cobra.Command {
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}
@ -94,7 +93,7 @@ $ %s query distribution validator-outstanding-rewards %s1lwjmdnks33xwnmfayc64ycp
}
res, err := queryClient.ValidatorOutstandingRewards(
context.Background(),
cmd.Context(),
&types.QueryValidatorOutstandingRewardsRequest{ValidatorAddress: validatorAddr.String()},
)
if err != nil {
@ -139,7 +138,7 @@ $ %s query distribution commission %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
}
res, err := queryClient.ValidatorCommission(
context.Background(),
cmd.Context(),
&types.QueryValidatorCommissionRequest{ValidatorAddress: validatorAddr.String()},
)
if err != nil {
@ -199,7 +198,7 @@ $ %s query distribution slashes %svaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
}
res, err := queryClient.ValidatorSlashes(
context.Background(),
cmd.Context(),
&types.QueryValidatorSlashesRequest{
ValidatorAddress: validatorAddr.String(),
StartingHeight: startHeight,
@ -252,6 +251,7 @@ $ %s query distribution rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p %s1ggh
}
// query for rewards from a particular delegation
ctx := cmd.Context()
if len(args) == 2 {
validatorAddr, err := sdk.ValAddressFromBech32(args[1])
if err != nil {
@ -259,7 +259,7 @@ $ %s query distribution rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p %s1ggh
}
res, err := queryClient.DelegationRewards(
context.Background(),
ctx,
&types.QueryDelegationRewardsRequest{DelegatorAddress: delegatorAddr.String(), ValidatorAddress: validatorAddr.String()},
)
if err != nil {
@ -270,7 +270,7 @@ $ %s query distribution rewards %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p %s1ggh
}
res, err := queryClient.DelegationTotalRewards(
context.Background(),
ctx,
&types.QueryDelegationTotalRewardsRequest{DelegatorAddress: delegatorAddr.String()},
)
if err != nil {
@ -307,7 +307,7 @@ $ %s query distribution community-pool
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.CommunityPool(context.Background(), &types.QueryCommunityPoolRequest{})
res, err := queryClient.CommunityPool(cmd.Context(), &types.QueryCommunityPoolRequest{})
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"strings"
@ -155,7 +154,7 @@ $ %s tx distribution withdraw-all-rewards --from mykey
}
queryClient := types.NewQueryClient(clientCtx)
delValsRes, err := queryClient.DelegatorValidators(context.Background(), &types.QueryDelegatorValidatorsRequest{DelegatorAddress: delAddr.String()})
delValsRes, err := queryClient.DelegatorValidators(cmd.Context(), &types.QueryDelegatorValidatorsRequest{DelegatorAddress: delAddr.String()})
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"strconv"
"strings"
@ -74,7 +73,7 @@ $ %s query gov proposal 1
// Query the proposal
res, err := queryClient.Proposal(
context.Background(),
cmd.Context(),
&types.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
@ -149,7 +148,7 @@ $ %s query gov proposals --page=2 --limit=100
}
res, err := queryClient.Proposals(
context.Background(),
cmd.Context(),
&types.QueryProposalsRequest{
ProposalStatus: proposalStatus,
Voter: bechVoterAddr,
@ -208,8 +207,9 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
}
// check to see if the proposal is in the store
ctx := cmd.Context()
_, err = queryClient.Proposal(
context.Background(),
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
@ -222,7 +222,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
}
res, err := queryClient.Vote(
context.Background(),
ctx,
&types.QueryVoteRequest{ProposalId: proposalID, Voter: args[1]},
)
if err != nil {
@ -282,8 +282,9 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
}
// check to see if the proposal is in the store
ctx := cmd.Context()
proposalRes, err := queryClient.Proposal(
context.Background(),
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
@ -315,7 +316,7 @@ $ %[1]s query gov votes 1 --page=2 --limit=100
}
res, err := queryClient.Votes(
context.Background(),
ctx,
&types.QueryVotesRequest{ProposalId: proposalID, Pagination: pageReq},
)
@ -364,8 +365,9 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
}
// check to see if the proposal is in the store
ctx := cmd.Context()
_, err = queryClient.Proposal(
context.Background(),
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
@ -378,7 +380,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
}
res, err := queryClient.Deposit(
context.Background(),
ctx,
&types.QueryDepositRequest{ProposalId: proposalID, Depositor: args[1]},
)
if err != nil {
@ -434,8 +436,9 @@ $ %s query gov deposits 1
}
// check to see if the proposal is in the store
ctx := cmd.Context()
proposalRes, err := queryClient.Proposal(
context.Background(),
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
@ -464,7 +467,7 @@ $ %s query gov deposits 1
}
res, err := queryClient.Deposits(
context.Background(),
ctx,
&types.QueryDepositsRequest{ProposalId: proposalID, Pagination: pageReq},
)
@ -512,8 +515,9 @@ $ %s query gov tally 1
}
// check to see if the proposal is in the store
ctx := cmd.Context()
_, err = queryClient.Proposal(
context.Background(),
ctx,
&types.QueryProposalRequest{ProposalId: proposalID},
)
if err != nil {
@ -522,7 +526,7 @@ $ %s query gov tally 1
// Query store
res, err := queryClient.TallyResult(
context.Background(),
ctx,
&types.QueryTallyResultRequest{ProposalId: proposalID},
)
if err != nil {
@ -561,8 +565,9 @@ $ %s query gov params
queryClient := types.NewQueryClient(clientCtx)
// Query store for all 3 params
ctx := cmd.Context()
votingRes, err := queryClient.Params(
context.Background(),
ctx,
&types.QueryParamsRequest{ParamsType: "voting"},
)
if err != nil {
@ -570,7 +575,7 @@ $ %s query gov params
}
tallyRes, err := queryClient.Params(
context.Background(),
ctx,
&types.QueryParamsRequest{ParamsType: "tallying"},
)
if err != nil {
@ -578,7 +583,7 @@ $ %s query gov params
}
depositRes, err := queryClient.Params(
context.Background(),
ctx,
&types.QueryParamsRequest{ParamsType: "deposit"},
)
if err != nil {
@ -626,7 +631,7 @@ $ %s query gov param deposit
// Query store
res, err := queryClient.Params(
context.Background(),
cmd.Context(),
&types.QueryParamsRequest{ParamsType: args[0]},
)
if err != nil {

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"github.com/spf13/cobra"
@ -31,7 +30,7 @@ func GetCmdQueryDenomTrace() *cobra.Command {
Hash: args[0],
}
res, err := queryClient.DenomTrace(context.Background(), req)
res, err := queryClient.DenomTrace(cmd.Context(), req)
if err != nil {
return err
}
@ -69,7 +68,7 @@ func GetCmdQueryDenomTraces() *cobra.Command {
Pagination: pageReq,
}
res, err := queryClient.DenomTraces(context.Background(), req)
res, err := queryClient.DenomTraces(cmd.Context(), req)
if err != nil {
return err
}
@ -98,7 +97,7 @@ func GetCmdParams() *cobra.Command {
}
queryClient := types.NewQueryClient(clientCtx)
res, _ := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
res, _ := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
return clientCtx.PrintProto(res.Params)
},
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"errors"
"fmt"
@ -44,7 +43,7 @@ func GetCmdQueryClientStates() *cobra.Command {
Pagination: pageReq,
}
res, err := queryClient.ClientStates(context.Background(), req)
res, err := queryClient.ClientStates(cmd.Context(), req)
if err != nil {
return err
}
@ -118,7 +117,7 @@ func GetCmdQueryConsensusStates() *cobra.Command {
Pagination: pageReq,
}
res, err := queryClient.ConsensusStates(context.Background(), req)
res, err := queryClient.ConsensusStates(cmd.Context(), req)
if err != nil {
return err
}
@ -250,7 +249,7 @@ func GetCmdParams() *cobra.Command {
}
queryClient := types.NewQueryClient(clientCtx)
res, _ := queryClient.ClientParams(context.Background(), &types.QueryClientParamsRequest{})
res, _ := queryClient.ClientParams(cmd.Context(), &types.QueryClientParamsRequest{})
return clientCtx.PrintProto(res.Params)
},
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"github.com/spf13/cobra"
@ -39,7 +38,7 @@ func GetCmdQueryConnections() *cobra.Command {
Pagination: pageReq,
}
res, err := queryClient.Connections(context.Background(), req)
res, err := queryClient.Connections(cmd.Context(), req)
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"strconv"
@ -44,7 +43,7 @@ func GetCmdQueryChannels() *cobra.Command {
Pagination: pageReq,
}
res, err := queryClient.Channels(context.Background(), req)
res, err := queryClient.Channels(cmd.Context(), req)
if err != nil {
return err
}
@ -118,7 +117,7 @@ func GetCmdQueryConnectionChannels() *cobra.Command {
Pagination: pageReq,
}
res, err := queryClient.ConnectionChannels(context.Background(), req)
res, err := queryClient.ConnectionChannels(cmd.Context(), req)
if err != nil {
return err
}
@ -189,7 +188,7 @@ func GetCmdQueryPacketCommitments() *cobra.Command {
Pagination: pageReq,
}
res, err := queryClient.PacketCommitments(context.Background(), req)
res, err := queryClient.PacketCommitments(cmd.Context(), req)
if err != nil {
return err
}
@ -357,7 +356,7 @@ The return value represents:
PacketCommitmentSequences: seqs,
}
res, err := queryClient.UnreceivedPackets(context.Background(), req)
res, err := queryClient.UnreceivedPackets(cmd.Context(), req)
if err != nil {
return err
}
@ -407,7 +406,7 @@ The return value represents:
PacketAckSequences: seqs,
}
res, err := queryClient.UnreceivedAcks(context.Background(), req)
res, err := queryClient.UnreceivedAcks(cmd.Context(), req)
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"github.com/spf13/cobra"
@ -45,7 +44,7 @@ func GetCmdQueryParams() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryParamsRequest{}
res, err := queryClient.Params(context.Background(), params)
res, err := queryClient.Params(cmd.Context(), params)
if err != nil {
return err
@ -75,7 +74,7 @@ func GetCmdQueryInflation() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryInflationRequest{}
res, err := queryClient.Inflation(context.Background(), params)
res, err := queryClient.Inflation(cmd.Context(), params)
if err != nil {
return err
@ -105,7 +104,7 @@ func GetCmdQueryAnnualProvisions() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryAnnualProvisionsRequest{}
res, err := queryClient.AnnualProvisions(context.Background(), params)
res, err := queryClient.AnnualProvisions(cmd.Context(), params)
if err != nil {
return err

View File

@ -1,8 +1,6 @@
package cli
import (
"context"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
@ -41,7 +39,7 @@ func NewQuerySubspaceParamsCmd() *cobra.Command {
queryClient := proposal.NewQueryClient(clientCtx)
params := proposal.QueryParamsRequest{Subspace: args[0], Key: args[1]}
res, err := queryClient.Params(context.Background(), &params)
res, err := queryClient.Params(cmd.Context(), &params)
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"strings"
"github.com/spf13/cobra"
@ -58,7 +57,7 @@ $ <appd> query slashing signing-info cosmosvalconspub1zcjduepqfhvwcmt7p06fvdgexx
consAddr := sdk.ConsAddress(pk.Address())
params := &types.QuerySigningInfoRequest{ConsAddress: consAddr.String()}
res, err := queryClient.SigningInfo(context.Background(), params)
res, err := queryClient.SigningInfo(cmd.Context(), params)
if err != nil {
return err
}
@ -95,7 +94,7 @@ $ <appd> query slashing signing-infos
}
params := &types.QuerySigningInfosRequest{Pagination: pageReq}
res, err := queryClient.SigningInfos(context.Background(), params)
res, err := queryClient.SigningInfos(cmd.Context(), params)
if err != nil {
return err
}
@ -128,7 +127,7 @@ $ <appd> query slashing params
queryClient := types.NewQueryClient(clientCtx)
params := &types.QueryParamsRequest{}
res, err := queryClient.Params(context.Background(), params)
res, err := queryClient.Params(cmd.Context(), params)
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"strconv"
"strings"
@ -115,7 +114,7 @@ $ %s query staking validators
return err
}
result, err := queryClient.Validators(context.Background(), &types.QueryValidatorsRequest{
result, err := queryClient.Validators(cmd.Context(), &types.QueryValidatorsRequest{
// Leaving status empty on purpose to query all validators.
Pagination: pageReq,
})
@ -172,7 +171,7 @@ $ %s query staking unbonding-delegations-from %s1gghjut3ccd8ay0zduzj64hwre2fxs9l
Pagination: pageReq,
}
res, err := queryClient.ValidatorUnbondingDelegations(context.Background(), params)
res, err := queryClient.ValidatorUnbondingDelegations(cmd.Context(), params)
if err != nil {
return err
}
@ -227,7 +226,7 @@ $ %s query staking redelegations-from %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
Pagination: pageReq,
}
res, err := queryClient.Redelegations(context.Background(), params)
res, err := queryClient.Redelegations(cmd.Context(), params)
if err != nil {
return err
}
@ -282,7 +281,7 @@ $ %s query staking delegation %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p %s1gghju
ValidatorAddr: valAddr.String(),
}
res, err := queryClient.Delegation(context.Background(), params)
res, err := queryClient.Delegation(cmd.Context(), params)
if err != nil {
return err
}
@ -336,7 +335,7 @@ $ %s query staking delegations %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
Pagination: pageReq,
}
res, err := queryClient.DelegatorDelegations(context.Background(), params)
res, err := queryClient.DelegatorDelegations(cmd.Context(), params)
if err != nil {
return err
}
@ -391,7 +390,7 @@ $ %s query staking delegations-to %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj
Pagination: pageReq,
}
res, err := queryClient.ValidatorDelegations(context.Background(), params)
res, err := queryClient.ValidatorDelegations(cmd.Context(), params)
if err != nil {
return err
}
@ -447,7 +446,7 @@ $ %s query staking unbonding-delegation %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9
ValidatorAddr: valAddr.String(),
}
res, err := queryClient.UnbondingDelegation(context.Background(), params)
res, err := queryClient.UnbondingDelegation(cmd.Context(), params)
if err != nil {
return err
}
@ -501,7 +500,7 @@ $ %s query staking unbonding-delegations %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru
Pagination: pageReq,
}
res, err := queryClient.DelegatorUnbondingDelegations(context.Background(), params)
res, err := queryClient.DelegatorUnbondingDelegations(cmd.Context(), params)
if err != nil {
return err
}
@ -563,7 +562,7 @@ $ %s query staking redelegation %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p %s1l2r
SrcValidatorAddr: valSrcAddr.String(),
}
res, err := queryClient.Redelegations(context.Background(), params)
res, err := queryClient.Redelegations(cmd.Context(), params)
if err != nil {
return err
}
@ -617,7 +616,7 @@ $ %s query staking redelegation %s1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
Pagination: pageReq,
}
res, err := queryClient.Redelegations(context.Background(), params)
res, err := queryClient.Redelegations(cmd.Context(), params)
if err != nil {
return err
}
@ -660,7 +659,7 @@ $ %s query staking historical-info 5
}
params := &types.QueryHistoricalInfoRequest{Height: height}
res, err := queryClient.HistoricalInfo(context.Background(), params)
res, err := queryClient.HistoricalInfo(cmd.Context(), params)
if err != nil {
return err
@ -697,7 +696,7 @@ $ %s query staking pool
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Pool(context.Background(), &types.QueryPoolRequest{})
res, err := queryClient.Pool(cmd.Context(), &types.QueryPoolRequest{})
if err != nil {
return err
}
@ -733,7 +732,7 @@ $ %s query staking params
}
queryClient := types.NewQueryClient(clientCtx)
res, err := queryClient.Params(context.Background(), &types.QueryParamsRequest{})
res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{})
if err != nil {
return err
}

View File

@ -1,7 +1,6 @@
package cli
import (
"context"
"fmt"
"github.com/spf13/cobra"
@ -41,7 +40,7 @@ func GetCurrentPlanCmd() *cobra.Command {
queryClient := types.NewQueryClient(clientCtx)
params := types.QueryCurrentPlanRequest{}
res, err := queryClient.CurrentPlan(context.Background(), &params)
res, err := queryClient.CurrentPlan(cmd.Context(), &params)
if err != nil {
return err
}
@ -74,9 +73,9 @@ func GetAppliedPlanCmd() *cobra.Command {
return err
}
queryClient := types.NewQueryClient(clientCtx)
ctx := cmd.Context()
params := types.QueryAppliedPlanRequest{Name: args[0]}
res, err := queryClient.AppliedPlan(context.Background(), &params)
res, err := queryClient.AppliedPlan(ctx, &params)
if err != nil {
return err
}
@ -90,7 +89,7 @@ func GetAppliedPlanCmd() *cobra.Command {
if err != nil {
return err
}
headers, err := node.BlockchainInfo(context.Background(), res.Height, res.Height)
headers, err := node.BlockchainInfo(ctx, res.Height, res.Height)
if err != nil {
return err
}