diff --git a/x/cdp/client/rest/query.go b/x/cdp/client/rest/query.go index 7f3f05a8..7503affb 100644 --- a/x/cdp/client/rest/query.go +++ b/x/cdp/client/rest/query.go @@ -25,6 +25,11 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { func queryCdpHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } vars := mux.Vars(r) ownerBech32 := vars[types.RestOwner] collateralDenom := vars[types.RestCollateralDenom] @@ -57,6 +62,11 @@ func queryCdpHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func queryCdpsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } vars := mux.Vars(r) collateralDenom := vars[types.RestCollateralDenom] @@ -82,6 +92,11 @@ func queryCdpsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func queryCdpsByRatioHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } vars := mux.Vars(r) collateralDenom := vars[types.RestCollateralDenom] ratioStr := vars[types.RestRatio] @@ -113,6 +128,11 @@ func queryCdpsByRatioHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func queryCdpDepositsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } vars := mux.Vars(r) ownerBech32 := vars[types.RestOwner] collateralDenom := vars[types.RestCollateralDenom] @@ -145,6 +165,11 @@ func queryCdpDepositsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func getParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } // Get the params res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/cdp/%s", types.QueryGetParams), nil) cliCtx = cliCtx.WithHeight(height) diff --git a/x/pricefeed/client/rest/query.go b/x/pricefeed/client/rest/query.go index 1b54260e..b99cec96 100644 --- a/x/pricefeed/client/rest/query.go +++ b/x/pricefeed/client/rest/query.go @@ -23,6 +23,11 @@ func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { func queryRawPricesHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } vars := mux.Vars(r) paramMarketID := vars[RestMarketID] queryRawPricesParams := types.NewQueryWithMarketIDParams(paramMarketID) @@ -46,6 +51,11 @@ func queryRawPricesHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func queryPriceHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } vars := mux.Vars(r) paramMarketID := vars[RestMarketID] queryPriceParams := types.NewQueryWithMarketIDParams(paramMarketID) @@ -69,6 +79,11 @@ func queryPriceHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func queryMarketsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryMarkets), nil) if err != nil { rest.WriteErrorResponse(w, http.StatusNotFound, err.Error()) @@ -82,6 +97,11 @@ func queryMarketsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func queryOraclesHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } vars := mux.Vars(r) paramMarketID := vars[RestMarketID] queryOraclesParams := types.NewQueryWithMarketIDParams(paramMarketID) @@ -105,6 +125,11 @@ func queryOraclesHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { func queryParamsHandlerFn(cliCtx context.CLIContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + // Parse the query height + cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) + if !ok { + return + } res, height, err := cliCtx.QueryWithData(fmt.Sprintf("custom/%s/%s", types.ModuleName, types.QueryGetParams), nil) if err != nil { rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())