Incentive query fixes (#681)

* fix claims endpoint

* fix cli query claims
This commit is contained in:
Ruaridh 2020-10-05 20:11:55 +01:00 committed by GitHub
parent 1a8a4b86e7
commit e0771cc9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 10 deletions

View File

@ -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)
}

View File

@ -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")