generalize query response with height (#4573)
Addition to #4536, no longer specific to account queries. Allows for validator endpoints to return height in the response. Closes: #4609
This commit is contained in:
committed by
Alessio Treglia
parent
5d5f0149a4
commit
8d8fd9df1a
@@ -234,12 +234,13 @@ func redelegationsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryWithData("custom/staking/redelegations", bz)
|
||||
res, height, err := cliCtx.QueryWithData("custom/staking/redelegations", bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, cliCtx, res)
|
||||
}
|
||||
}
|
||||
@@ -286,11 +287,13 @@ func validatorsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryValidators)
|
||||
res, _, err := cliCtx.QueryWithData(route, bz)
|
||||
res, height, err := cliCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, cliCtx, res)
|
||||
}
|
||||
}
|
||||
@@ -318,12 +321,13 @@ func poolHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryWithData("custom/staking/pool", nil)
|
||||
res, height, err := cliCtx.QueryWithData("custom/staking/pool", nil)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, cliCtx, res)
|
||||
}
|
||||
}
|
||||
@@ -336,12 +340,13 @@ func paramsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryWithData("custom/staking/parameters", nil)
|
||||
res, height, err := cliCtx.QueryWithData("custom/staking/parameters", nil)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, cliCtx, res)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,11 +66,13 @@ func queryBonds(cliCtx context.CLIContext, endpoint string) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryWithData(endpoint, bz)
|
||||
res, height, err := cliCtx.QueryWithData(endpoint, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, cliCtx, res)
|
||||
}
|
||||
}
|
||||
@@ -99,11 +101,13 @@ func queryDelegator(cliCtx context.CLIContext, endpoint string) http.HandlerFunc
|
||||
return
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryWithData(endpoint, bz)
|
||||
res, height, err := cliCtx.QueryWithData(endpoint, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, cliCtx, res)
|
||||
}
|
||||
}
|
||||
@@ -132,11 +136,13 @@ func queryValidator(cliCtx context.CLIContext, endpoint string) http.HandlerFunc
|
||||
return
|
||||
}
|
||||
|
||||
res, _, err := cliCtx.QueryWithData(endpoint, bz)
|
||||
res, height, err := cliCtx.QueryWithData(endpoint, bz)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
cliCtx = cliCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, cliCtx, res)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user