From 44d4d195651e757bce8dc49f6d5fa6972b2c98d4 Mon Sep 17 00:00:00 2001 From: Denali Marsh Date: Mon, 8 Feb 2021 15:14:25 +0100 Subject: [PATCH] fix incentive rewards query REST res (#802) --- x/incentive/client/rest/query.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/x/incentive/client/rest/query.go b/x/incentive/client/rest/query.go index 998400a4..bcf371eb 100644 --- a/x/incentive/client/rest/query.go +++ b/x/incentive/client/rest/query.go @@ -128,6 +128,8 @@ func executeBothRewardQueries(w http.ResponseWriter, cliCtx context.CLIContext, rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } + var hardClaims types.HardLiquidityProviderClaims + cliCtx.Codec.MustUnmarshalJSON(hardRes, &hardClaims) usdxMintingBz, err := cliCtx.Codec.MarshalJSON(usdxMintingParams) if err != nil { @@ -140,7 +142,26 @@ func executeBothRewardQueries(w http.ResponseWriter, cliCtx context.CLIContext, rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) return } + var usdxMintingClaims types.USDXMintingClaims + cliCtx.Codec.MustUnmarshalJSON(usdxMintingRes, &usdxMintingClaims) cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, append(hardRes, usdxMintingRes...)) + + type rewardResult struct { + HardClaims types.HardLiquidityProviderClaims `json:"hard_claims" yaml:"hard_claims"` + UsdxMintingClaims types.USDXMintingClaims `json:"usdx_minting_claims" yaml:"usdx_minting_claims"` + } + + res := rewardResult{ + HardClaims: hardClaims, + UsdxMintingClaims: usdxMintingClaims, + } + + resBz, err := cliCtx.Codec.MarshalJSON(res) + if err != nil { + rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal result: %s", err)) + return + } + + rest.PostProcessResponse(w, cliCtx, resBz) }