Merge PR #4536: Return account queries with height

This commit is contained in:
colin axner 2019-06-13 06:54:17 -07:00 committed by Alexander Bezobchuk
parent 8c89023e9f
commit 95f3d32250
20 changed files with 125 additions and 104 deletions

View File

@ -0,0 +1 @@
#4536 cli context queries return query height and accounts are returned with query height

View File

@ -29,28 +29,34 @@ func (ctx CLIContext) GetNode() (rpcclient.Client, error) {
return ctx.Client, nil
}
// Query performs a query for information about the connected node.
func (ctx CLIContext) Query(path string, data cmn.HexBytes) (res []byte, err error) {
// Query performs a query to a Tendermint node with the provided path.
// It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) Query(path string, data cmn.HexBytes) ([]byte, int64, error) {
return ctx.query(path, data)
}
// Query information about the connected node with a data payload
func (ctx CLIContext) QueryWithData(path string, data []byte) (res []byte, err error) {
// QueryWithData performs a query to a Tendermint node with the provided path
// and a data payload. It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) QueryWithData(path string, data []byte) ([]byte, int64, error) {
return ctx.query(path, data)
}
// QueryStore performs a query from a Tendermint node with the provided key and
// store name.
func (ctx CLIContext) QueryStore(key cmn.HexBytes, storeName string) (res []byte, err error) {
// QueryStore performs a query to a Tendermint node with the provided key and
// store name. It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) QueryStore(key cmn.HexBytes, storeName string) ([]byte, int64, error) {
return ctx.queryStore(key, storeName, "key")
}
// QuerySubspace performs a query from a Tendermint node with the provided
// store name and subspace.
func (ctx CLIContext) QuerySubspace(subspace []byte, storeName string) (res []sdk.KVPair, err error) {
resRaw, err := ctx.queryStore(subspace, storeName, "subspace")
// QuerySubspace performs a query to a Tendermint node with the provided
// store name and subspace. It returns key value pair and height of the query
// upon success or an error if the query fails.
func (ctx CLIContext) QuerySubspace(subspace []byte, storeName string) (res []sdk.KVPair, height int64, err error) {
resRaw, height, err := ctx.queryStore(subspace, storeName, "subspace")
if err != nil {
return res, err
return res, height, err
}
ctx.Codec.MustUnmarshalBinaryLengthPrefixed(resRaw, &res)
@ -134,7 +140,7 @@ func (ctx CLIContext) queryAccount(addr sdk.AccAddress) ([]byte, error) {
route := fmt.Sprintf("custom/%s/%s", ctx.AccountStore, authtypes.QueryAccount)
res, err := ctx.QueryWithData(route, bz)
res, _, err := ctx.query(route, bz)
if err != nil {
return nil, err
}
@ -142,12 +148,13 @@ func (ctx CLIContext) queryAccount(addr sdk.AccAddress) ([]byte, error) {
return res, nil
}
// query performs a query from a Tendermint node with the provided store name
// and path.
func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err error) {
// query performs a query to a Tendermint node with the provided store name
// and path. It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, height int64, err error) {
node, err := ctx.GetNode()
if err != nil {
return res, err
return res, height, err
}
opts := rpcclient.ABCIQueryOptions{
@ -157,25 +164,25 @@ func (ctx CLIContext) query(path string, key cmn.HexBytes) (res []byte, err erro
result, err := node.ABCIQueryWithOptions(path, key, opts)
if err != nil {
return res, err
return res, height, err
}
resp := result.Response
if !resp.IsOK() {
return res, errors.New(resp.Log)
return res, height, errors.New(resp.Log)
}
// data from trusted node or subspace query doesn't need verification
if ctx.TrustNode || !isQueryStoreWithProof(path) {
return resp.Value, nil
return resp.Value, resp.Height, nil
}
err = ctx.verifyProof(path, resp)
if err != nil {
return nil, err
return res, height, err
}
return resp.Value, nil
return resp.Value, resp.Height, nil
}
// Verify verifies the consensus proof at given height.
@ -231,9 +238,10 @@ func (ctx CLIContext) verifyProof(queryPath string, resp abci.ResponseQuery) err
return nil
}
// queryStore performs a query from a Tendermint node with the provided a store
// name and path.
func (ctx CLIContext) queryStore(key cmn.HexBytes, storeName, endPath string) ([]byte, error) {
// queryStore performs a query to a Tendermint node with the provided a store
// name and path. It returns the result and height of the query upon success
// or an error if the query fails.
func (ctx CLIContext) queryStore(key cmn.HexBytes, storeName, endPath string) ([]byte, int64, error) {
path := fmt.Sprintf("/store/%s/%s", storeName, endPath)
return ctx.query(path, key)
}

View File

@ -35,7 +35,7 @@ func CLIVersionRequestHandler(w http.ResponseWriter, r *http.Request) {
// connected node version REST handler endpoint
func NodeVersionRequestHandler(cliCtx context.CLIContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
version, err := cliCtx.Query("/app/version", nil)
version, _, err := cliCtx.Query("/app/version", nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -127,12 +127,12 @@ func EnrichWithGas(txBldr authtypes.TxBuilder, cliCtx context.CLIContext, msgs [
// CalculateGas simulates the execution of a transaction and returns
// both the estimate obtained by the query and the adjusted amount.
func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, error),
func CalculateGas(queryFunc func(string, common.HexBytes) ([]byte, int64, error),
cdc *codec.Codec, txBytes []byte, adjustment float64) (estimate, adjusted uint64, err error) {
// run a simulation (via /app/simulate query) to
// estimate gas and update TxBuilder accordingly
rawRes, err := queryFunc("/app/simulate", txBytes)
rawRes, _, err := queryFunc("/app/simulate", txBytes)
if err != nil {
return
}

View File

@ -36,12 +36,12 @@ func TestParseQueryResponse(t *testing.T) {
func TestCalculateGas(t *testing.T) {
cdc := makeCodec()
makeQueryFunc := func(gasUsed uint64, wantErr bool) func(string, common.HexBytes) ([]byte, error) {
return func(string, common.HexBytes) ([]byte, error) {
makeQueryFunc := func(gasUsed uint64, wantErr bool) func(string, common.HexBytes) ([]byte, int64, error) {
return func(string, common.HexBytes) ([]byte, int64, error) {
if wantErr {
return nil, errors.New("")
return nil, 0, errors.New("")
}
return cdc.MustMarshalBinaryLengthPrefixed(sdk.Result{GasUsed: gasUsed}), nil
return cdc.MustMarshalBinaryLengthPrefixed(sdk.Result{GasUsed: gasUsed}), 0, nil
}
}
type args struct {

View File

@ -12,6 +12,13 @@ import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
// AccountWithHeight wraps the embedded Account
// with the height it was queried at
type AccountWithHeight struct {
types.Account
Height int64 `json:"height"`
}
// register REST routes
func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, storeName string) {
r.HandleFunc(
@ -45,7 +52,7 @@ func QueryAccountRequestHandlerFn(
return
}
res, err := cliCtx.QueryStore(types.AddressStoreKey(addr), storeName)
res, height, err := cliCtx.QueryStore(types.AddressStoreKey(addr), storeName)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -64,7 +71,7 @@ func QueryAccountRequestHandlerFn(
return
}
rest.PostProcessResponse(w, cliCtx, account)
rest.PostProcessResponse(w, cliCtx, AccountWithHeight{account, height})
}
}
@ -89,7 +96,7 @@ func QueryBalancesRequestHandlerFn(
return
}
res, err := cliCtx.QueryStore(types.AddressStoreKey(addr), storeName)
res, _, err := cliCtx.QueryStore(types.AddressStoreKey(addr), storeName)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -86,7 +86,7 @@ $ %s query distr validator-outstanding-rewards cosmosvaloper1lwjmdnks33xwnmfayc6
return err
}
resp, err := cliCtx.QueryWithData(
resp, _, err := cliCtx.QueryWithData(
fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryValidatorOutstandingRewards),
bz,
)
@ -178,7 +178,7 @@ $ %s query distr slashes cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 0
return err
}
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/validator_slashes", queryRoute), bz)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/validator_slashes", queryRoute), bz)
if err != nil {
return err
}
@ -252,7 +252,7 @@ $ %s query distr community-pool
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/community_pool", queryRoute), nil)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/community_pool", queryRoute), nil)
if err != nil {
return err
}

View File

@ -12,25 +12,25 @@ import (
func QueryParams(cliCtx context.CLIContext, queryRoute string) (PrettyParams, error) {
route := fmt.Sprintf("custom/%s/params/%s", queryRoute, types.ParamCommunityTax)
retCommunityTax, err := cliCtx.QueryWithData(route, []byte{})
retCommunityTax, _, err := cliCtx.QueryWithData(route, []byte{})
if err != nil {
return PrettyParams{}, err
}
route = fmt.Sprintf("custom/%s/params/%s", queryRoute, types.ParamBaseProposerReward)
retBaseProposerReward, err := cliCtx.QueryWithData(route, []byte{})
retBaseProposerReward, _, err := cliCtx.QueryWithData(route, []byte{})
if err != nil {
return PrettyParams{}, err
}
route = fmt.Sprintf("custom/%s/params/%s", queryRoute, types.ParamBonusProposerReward)
retBonusProposerReward, err := cliCtx.QueryWithData(route, []byte{})
retBonusProposerReward, _, err := cliCtx.QueryWithData(route, []byte{})
if err != nil {
return PrettyParams{}, err
}
route = fmt.Sprintf("custom/%s/params/%s", queryRoute, types.ParamWithdrawAddrEnabled)
retWithdrawAddrEnabled, err := cliCtx.QueryWithData(route, []byte{})
retWithdrawAddrEnabled, _, err := cliCtx.QueryWithData(route, []byte{})
if err != nil {
return PrettyParams{}, err
}
@ -47,10 +47,11 @@ func QueryDelegatorTotalRewards(cliCtx context.CLIContext, queryRoute, delAddr s
return nil, err
}
return cliCtx.QueryWithData(
res, _, err := cliCtx.QueryWithData(
fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegatorTotalRewards),
cliCtx.Codec.MustMarshalJSON(types.NewQueryDelegatorParams(delegatorAddr)),
)
return res, err
}
// QueryDelegationRewards queries a delegation rewards.
@ -65,27 +66,30 @@ func QueryDelegationRewards(cliCtx context.CLIContext, queryRoute, delAddr, valA
return nil, err
}
return cliCtx.QueryWithData(
res, _, err := cliCtx.QueryWithData(
fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegationRewards),
cliCtx.Codec.MustMarshalJSON(types.NewQueryDelegationRewardsParams(delegatorAddr, validatorAddr)),
)
return res, err
}
// QueryDelegatorValidators returns delegator's list of validators
// it submitted delegations to.
func QueryDelegatorValidators(cliCtx context.CLIContext, queryRoute string, delegatorAddr sdk.AccAddress) ([]byte, error) {
return cliCtx.QueryWithData(
res, _, err := cliCtx.QueryWithData(
fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegatorValidators),
cliCtx.Codec.MustMarshalJSON(types.NewQueryDelegatorParams(delegatorAddr)),
)
return res, err
}
// QueryValidatorCommission returns a validator's commission.
func QueryValidatorCommission(cliCtx context.CLIContext, queryRoute string, validatorAddr sdk.ValAddress) ([]byte, error) {
return cliCtx.QueryWithData(
res, _, err := cliCtx.QueryWithData(
fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryValidatorCommission),
cliCtx.Codec.MustMarshalJSON(types.NewQueryValidatorCommissionParams(validatorAddr)),
)
return res, err
}
// WithdrawAllDelegatorRewards builds a multi-message slice to be used

View File

@ -115,7 +115,7 @@ func delegatorWithdrawalAddrHandlerFn(cliCtx context.CLIContext, queryRoute stri
}
bz := cliCtx.Codec.MustMarshalJSON(types.NewQueryDelegatorWithdrawAddrParams(delegatorAddr))
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/withdraw_addr", queryRoute), bz)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/withdraw_addr", queryRoute), bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -232,7 +232,7 @@ func communityPoolHandler(cliCtx context.CLIContext, queryRoute string) http.Han
return
}
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/community_pool", queryRoute), nil)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/community_pool", queryRoute), nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -262,7 +262,7 @@ func outstandingRewardsHandlerFn(cliCtx context.CLIContext, queryRoute string) h
}
bin := cliCtx.Codec.MustMarshalJSON(types.NewQueryValidatorOutstandingRewardsParams(validatorAddr))
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/validator_outstanding_rewards", queryRoute), bin)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/validator_outstanding_rewards", queryRoute), bin)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -141,7 +141,7 @@ $ %s query gov proposals --status (DepositPeriod|VotingPeriod|Passed|Rejected)
cliCtx := context.NewCLIContext().WithCodec(cdc)
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/proposals", queryRoute), bz)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/proposals", queryRoute), bz)
if err != nil {
return err
}
@ -210,7 +210,7 @@ $ %s query gov vote 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
return err
}
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/vote", queryRoute), bz)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/vote", queryRoute), bz)
if err != nil {
return err
}
@ -278,7 +278,7 @@ $ %s query gov votes 1
if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) {
res, err = gcutils.QueryVotesByTxQuery(cliCtx, params)
} else {
res, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/votes", queryRoute), bz)
res, _, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/votes", queryRoute), bz)
}
if err != nil {
@ -334,7 +334,7 @@ $ %s query gov deposit 1 cosmos1skjwj5whet0lpe65qaq4rpq03hjxlwd9nf39lk
return err
}
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/deposit", queryRoute), bz)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/deposit", queryRoute), bz)
if err != nil {
return err
}
@ -399,7 +399,7 @@ $ %s query gov deposits 1
if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) {
res, err = gcutils.QueryDepositsByTxQuery(cliCtx, params)
} else {
res, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/deposits", queryRoute), bz)
res, _, err = cliCtx.QueryWithData(fmt.Sprintf("custom/%s/deposits", queryRoute), bz)
}
if err != nil {
@ -452,7 +452,7 @@ $ %s query gov tally 1
}
// Query store
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/tally", queryRoute), bz)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/tally", queryRoute), bz)
if err != nil {
return err
}
@ -481,15 +481,15 @@ $ %s query gov params
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
tp, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/tallying", queryRoute), nil)
tp, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/tallying", queryRoute), nil)
if err != nil {
return err
}
dp, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/deposit", queryRoute), nil)
dp, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/deposit", queryRoute), nil)
if err != nil {
return err
}
vp, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/voting", queryRoute), nil)
vp, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/voting", queryRoute), nil)
if err != nil {
return err
}
@ -527,7 +527,7 @@ $ %s query gov param deposit
cliCtx := context.NewCLIContext().WithCodec(cdc)
// Query store
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/%s", queryRoute, args[0]), nil)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/params/%s", queryRoute, args[0]), nil)
if err != nil {
return err
}

View File

@ -201,7 +201,7 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/gov/%s/%s", types.QueryParams, paramType), nil)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/gov/%s/%s", types.QueryParams, paramType), nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusNotFound, err.Error())
return
@ -240,7 +240,7 @@ func queryProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/gov/proposal", bz)
res, _, err := cliCtx.QueryWithData("custom/gov/proposal", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -273,7 +273,7 @@ func queryDepositsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/gov/proposal", bz)
res, _, err := cliCtx.QueryWithData("custom/gov/proposal", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -291,7 +291,7 @@ func queryDepositsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) {
res, err = gcutils.QueryDepositsByTxQuery(cliCtx, params)
} else {
res, err = cliCtx.QueryWithData("custom/gov/deposits", bz)
res, _, err = cliCtx.QueryWithData("custom/gov/deposits", bz)
}
if err != nil {
@ -370,7 +370,7 @@ func queryDepositHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/gov/deposit", bz)
res, _, err := cliCtx.QueryWithData("custom/gov/deposit", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -392,7 +392,7 @@ func queryDepositHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err = cliCtx.QueryWithData("custom/gov/proposal", bz)
res, _, err = cliCtx.QueryWithData("custom/gov/proposal", bz)
if err != nil || len(res) == 0 {
err := fmt.Errorf("proposalID %d does not exist", proposalID)
rest.WriteErrorResponse(w, http.StatusNotFound, err.Error())
@ -452,7 +452,7 @@ func queryVoteHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/gov/vote", bz)
res, _, err := cliCtx.QueryWithData("custom/gov/vote", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -474,7 +474,7 @@ func queryVoteHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err = cliCtx.QueryWithData("custom/gov/proposal", bz)
res, _, err = cliCtx.QueryWithData("custom/gov/proposal", bz)
if err != nil || len(res) == 0 {
err := fmt.Errorf("proposalID %d does not exist", proposalID)
rest.WriteErrorResponse(w, http.StatusNotFound, err.Error())
@ -522,7 +522,7 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/gov/proposal", bz)
res, _, err := cliCtx.QueryWithData("custom/gov/proposal", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -540,7 +540,7 @@ func queryVotesOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
if !(propStatus == types.StatusVotingPeriod || propStatus == types.StatusDepositPeriod) {
res, err = gcutils.QueryVotesByTxQuery(cliCtx, params)
} else {
res, err = cliCtx.QueryWithData("custom/gov/votes", bz)
res, _, err = cliCtx.QueryWithData("custom/gov/votes", bz)
}
if err != nil {
@ -607,7 +607,7 @@ func queryProposalsWithParameterFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/gov/proposals", bz)
res, _, err := cliCtx.QueryWithData("custom/gov/proposals", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -647,7 +647,7 @@ func queryTallyOnProposalHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/gov/tally", bz)
res, _, err := cliCtx.QueryWithData("custom/gov/tally", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -229,7 +229,7 @@ func QueryProposalByID(proposalID uint64, cliCtx context.CLIContext, queryRoute
return nil, err
}
res, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/proposal", queryRoute), bz)
res, _, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/proposal", queryRoute), bz)
if err != nil {
return nil, err
}

View File

@ -157,7 +157,8 @@ OUTER:
}
func query(node string, key []byte, storeName string) (res []byte, err error) {
return context.NewCLIContext().WithNodeURI(node).QueryStore(key, storeName)
res, _, err = context.NewCLIContext().WithNodeURI(node).QueryStore(key, storeName)
return res, err
}
// nolint: unparam

View File

@ -45,7 +45,7 @@ func GetCmdQueryParams(cdc *codec.Codec) *cobra.Command {
cliCtx := context.NewCLIContext().WithCodec(cdc)
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters)
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
return err
}
@ -71,7 +71,7 @@ func GetCmdQueryInflation(cdc *codec.Codec) *cobra.Command {
cliCtx := context.NewCLIContext().WithCodec(cdc)
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryInflation)
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
return err
}
@ -97,7 +97,7 @@ func GetCmdQueryAnnualProvisions(cdc *codec.Codec) *cobra.Command {
cliCtx := context.NewCLIContext().WithCodec(cdc)
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAnnualProvisions)
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
return err
}

View File

@ -37,7 +37,7 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -56,7 +56,7 @@ func queryInflationHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -75,7 +75,7 @@ func queryAnnualProvisionsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc
return
}
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -58,7 +58,7 @@ $ <appcli> query slashing signing-info cosmosvalconspub1zcjduepqfhvwcmt7p06fvdge
consAddr := sdk.ConsAddress(pk.Address())
key := types.GetValidatorSigningInfoKey(consAddr)
res, err := cliCtx.QueryStore(key, storeName)
res, _, err := cliCtx.QueryStore(key, storeName)
if err != nil {
return err
}
@ -88,7 +88,7 @@ $ <appcli> query slashing params
cliCtx := context.NewCLIContext().WithCodec(cdc)
route := fmt.Sprintf("custom/%s/parameters", types.QuerierRoute)
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
return err
}

View File

@ -53,7 +53,7 @@ func signingInfoHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QuerySigningInfo)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -85,7 +85,7 @@ func signingInfoHandlerListFn(cliCtx context.CLIContext) http.HandlerFunc {
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QuerySigningInfos)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -104,7 +104,7 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
route := fmt.Sprintf("custom/%s/parameters", types.QuerierRoute)
res, err := cliCtx.QueryWithData(route, nil)
res, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -66,7 +66,7 @@ $ %s query staking validator cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhff
return err
}
res, err := cliCtx.QueryStore(types.GetValidatorKey(addr), storeName)
res, _, err := cliCtx.QueryStore(types.GetValidatorKey(addr), storeName)
if err != nil {
return err
}
@ -98,7 +98,7 @@ $ %s query staking validators
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
resKVs, err := cliCtx.QuerySubspace(types.ValidatorsKey, storeName)
resKVs, _, err := cliCtx.QuerySubspace(types.ValidatorsKey, storeName)
if err != nil {
return err
}
@ -142,7 +142,7 @@ $ %s query staking unbonding-delegations-from cosmosvaloper1gghjut3ccd8ay0zduzj6
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryValidatorUnbondingDelegations)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -184,7 +184,7 @@ $ %s query staking redelegations-from cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fx
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryRedelegations)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -233,7 +233,7 @@ $ %s query staking delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p cosm
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegation)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -278,7 +278,7 @@ $ %s query staking delegations cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegatorDelegations)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -323,7 +323,7 @@ $ %s query staking delegations-to cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ld
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryValidatorDelegations)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -373,7 +373,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryUnbondingDelegation)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -413,7 +413,7 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDelegatorUnbondingDelegations)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -468,7 +468,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p co
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryRedelegations)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -513,7 +513,7 @@ $ %s query staking redelegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld75ru9p
}
route := fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryRedelegations)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
return err
}
@ -546,7 +546,7 @@ $ %s query staking pool
RunE: func(cmd *cobra.Command, args []string) error {
cliCtx := context.NewCLIContext().WithCodec(cdc)
res, err := cliCtx.QueryStore(types.PoolKey, storeName)
res, _, err := cliCtx.QueryStore(types.PoolKey, storeName)
if err != nil {
return err
}
@ -575,7 +575,7 @@ $ %s query staking params
cliCtx := context.NewCLIContext().WithCodec(cdc)
route := fmt.Sprintf("custom/%s/%s", storeName, types.QueryParameters)
bz, err := cliCtx.QueryWithData(route, nil)
bz, _, err := cliCtx.QueryWithData(route, nil)
if err != nil {
return err
}

View File

@ -227,7 +227,7 @@ func redelegationsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/staking/redelegations", bz)
res, _, err := cliCtx.QueryWithData("custom/staking/redelegations", bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -279,7 +279,7 @@ func validatorsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryValidators)
res, err := cliCtx.QueryWithData(route, bz)
res, _, err := cliCtx.QueryWithData(route, bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -311,7 +311,7 @@ func poolHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/staking/pool", nil)
res, _, err := cliCtx.QueryWithData("custom/staking/pool", nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -329,7 +329,7 @@ func paramsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData("custom/staking/parameters", nil)
res, _, err := cliCtx.QueryWithData("custom/staking/parameters", nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return

View File

@ -62,7 +62,7 @@ func queryBonds(cliCtx context.CLIContext, endpoint string) http.HandlerFunc {
return
}
res, err := cliCtx.QueryWithData(endpoint, bz)
res, _, err := cliCtx.QueryWithData(endpoint, bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -95,7 +95,7 @@ func queryDelegator(cliCtx context.CLIContext, endpoint string) http.HandlerFunc
return
}
res, err := cliCtx.QueryWithData(endpoint, bz)
res, _, err := cliCtx.QueryWithData(endpoint, bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
@ -128,7 +128,7 @@ func queryValidator(cliCtx context.CLIContext, endpoint string) http.HandlerFunc
return
}
res, err := cliCtx.QueryWithData(endpoint, bz)
res, _, err := cliCtx.QueryWithData(endpoint, bz)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return