From e0771cc9e8ad117f76e04691da5e25eda4bbbfc9 Mon Sep 17 00:00:00 2001 From: Ruaridh Date: Mon, 5 Oct 2020 20:11:55 +0100 Subject: [PATCH] Incentive query fixes (#681) * fix claims endpoint * fix cli query claims --- x/incentive/client/cli/query.go | 8 ++++---- x/incentive/client/rest/query.go | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/x/incentive/client/cli/query.go b/x/incentive/client/cli/query.go index ec5755ab..e3dc4bf7 100644 --- a/x/incentive/client/cli/query.go +++ b/x/incentive/client/cli/query.go @@ -35,13 +35,13 @@ func GetQueryCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { func queryClaimsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { return &cobra.Command{ - Use: "claims [owner-addr] [denom]", - Short: "get claims by onwer and denom", + Use: "claims [owner-addr] [collateral-type]", + Short: "get claims by owner and collateral-type", Long: strings.TrimSpace( fmt.Sprintf(`Get all claims owned by the owner address for the particular collateral type. Example: - $ %s query %s claims kava15qdefkmwswysgg4qxgqpqr35k3m49pkx2jdfnw bnb`, version.ClientName, types.ModuleName)), + $ %s query %s claims kava15qdefkmwswysgg4qxgqpqr35k3m49pkx2jdfnw bnb-a`, version.ClientName, types.ModuleName)), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { cliCtx := context.NewCLIContext().WithCodec(cdc) @@ -66,7 +66,7 @@ func queryClaimsCmd(queryRoute string, cdc *codec.Codec) *cobra.Command { } cliCtx = cliCtx.WithHeight(height) - var claims types.Claims + var claims types.AugmentedClaims if err := cdc.UnmarshalJSON(res, &claims); err != nil { return fmt.Errorf("failed to unmarshal claims: %w", err) } diff --git a/x/incentive/client/rest/query.go b/x/incentive/client/rest/query.go index 09177618..429c97b0 100644 --- a/x/incentive/client/rest/query.go +++ b/x/incentive/client/rest/query.go @@ -13,13 +13,8 @@ import ( "github.com/kava-labs/kava/x/incentive/types" ) -const ( - restOwner = "owner" - restDenom = "denom" -) - func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) { - r.HandleFunc(fmt.Sprintf("/%s/claims/{%s}/{%s}", types.ModuleName, restOwner, restDenom), queryClaimsHandlerFn(cliCtx)).Methods("GET") + r.HandleFunc(fmt.Sprintf("/%s/claims/{%s}/{%s}", types.ModuleName, types.RestClaimOwner, types.RestClaimCollateralType), queryClaimsHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/rewardperiods", types.ModuleName), queryRewardPeriodsHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/claimperiods", types.ModuleName), queryClaimPeriodsHandlerFn(cliCtx)).Methods("GET") r.HandleFunc(fmt.Sprintf("/%s/parameters", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET")