46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package colinearcore
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"colinear/x/colinearcore/keeper"
|
|
"colinear/x/colinearcore/types"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
)
|
|
|
|
// NewHandler ...
|
|
func NewHandler(k keeper.Keeper) sdk.Handler {
|
|
msgServer := keeper.NewMsgServerImpl(k)
|
|
|
|
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
|
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
|
|
|
switch msg := msg.(type) {
|
|
case *types.MsgNewAuction:
|
|
res, err := msgServer.NewAuction(sdk.WrapSDKContext(ctx), msg)
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
|
case *types.MsgNewBid:
|
|
res, err := msgServer.NewBid(sdk.WrapSDKContext(ctx), msg)
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
|
case *types.MsgLockFunds:
|
|
res, err := msgServer.LockFunds(sdk.WrapSDKContext(ctx), msg)
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
|
case *types.MsgUnlockFunds:
|
|
res, err := msgServer.UnlockFunds(sdk.WrapSDKContext(ctx), msg)
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
|
case *types.MsgUnlockAllFunds:
|
|
res, err := msgServer.UnlockAllFunds(sdk.WrapSDKContext(ctx), msg)
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
|
case *types.MsgClaimFunds:
|
|
res, err := msgServer.ClaimFunds(sdk.WrapSDKContext(ctx), msg)
|
|
return sdk.WrapServiceResult(ctx, res, err)
|
|
// this line is used by starport scaffolding # 1
|
|
default:
|
|
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
|
|
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
|
|
}
|
|
}
|
|
}
|