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:
colin axner
2019-07-01 17:48:13 +01:00
committed by Alessio Treglia
parent 5d5f0149a4
commit 8d8fd9df1a
13 changed files with 209 additions and 38 deletions
+6 -3
View File
@@ -53,12 +53,13 @@ func signingInfoHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QuerySigningInfo)
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)
}
}
@@ -85,12 +86,13 @@ func signingInfoHandlerListFn(cliCtx context.CLIContext) http.HandlerFunc {
}
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QuerySigningInfos)
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)
}
}
@@ -104,12 +106,13 @@ func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
route := fmt.Sprintf("custom/%s/parameters", types.QuerierRoute)
res, _, err := cliCtx.QueryWithData(route, nil)
res, height, err := cliCtx.QueryWithData(route, nil)
if err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}
cliCtx = cliCtx.WithHeight(height)
rest.PostProcessResponse(w, cliCtx, res)
}
}