mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-14 03:55:19 +00:00
3a08fc582b
* claim hard reward keeper methods * test hard claim payout * claim hard rewards via cli * query hard claims via cli * rest txs and queries * add handler test * add claim type event field
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package incentive
|
|
|
|
import (
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
|
|
"github.com/kava-labs/kava/x/incentive/keeper"
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
|
)
|
|
|
|
// NewHandler creates an sdk.Handler for incentive module messages
|
|
func NewHandler(k keeper.Keeper) sdk.Handler {
|
|
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
|
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
|
switch msg := msg.(type) {
|
|
case types.MsgClaimUSDXMintingReward:
|
|
return handleMsgClaimUSDXMintingReward(ctx, k, msg)
|
|
case types.MsgClaimHardLiquidityProviderReward:
|
|
return handleMsgClaimHardLiquidityProviderReward(ctx, k, msg)
|
|
default:
|
|
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", ModuleName, msg)
|
|
}
|
|
}
|
|
}
|
|
|
|
func handleMsgClaimUSDXMintingReward(ctx sdk.Context, k keeper.Keeper, msg types.MsgClaimUSDXMintingReward) (*sdk.Result, error) {
|
|
|
|
err := k.ClaimUSDXMintingReward(ctx, msg.Sender, types.MultiplierName(msg.MultiplierName))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &sdk.Result{
|
|
Events: ctx.EventManager().Events(),
|
|
}, nil
|
|
}
|
|
|
|
func handleMsgClaimHardLiquidityProviderReward(ctx sdk.Context, k keeper.Keeper, msg types.MsgClaimHardLiquidityProviderReward) (*sdk.Result, error) {
|
|
|
|
err := k.ClaimHardReward(ctx, msg.Sender, types.MultiplierName(msg.MultiplierName))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &sdk.Result{
|
|
Events: ctx.EventManager().Events(),
|
|
}, nil
|
|
}
|