gpu-compute-chain/x/cosmostest/handler.go

33 lines
960 B
Go
Raw Normal View History

2022-08-25 16:51:14 -07:00
package cosmostest
import (
"fmt"
"cosmos-test/x/cosmostest/keeper"
"cosmos-test/x/cosmostest/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// NewHandler ...
func NewHandler(k keeper.Keeper) sdk.Handler {
2022-08-27 14:19:03 -07:00
msgServer := keeper.NewMsgServerImpl(k)
2022-08-25 16:51:14 -07:00
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
ctx = ctx.WithEventManager(sdk.NewEventManager())
switch msg := msg.(type) {
2022-08-27 14:19:03 -07:00
case *types.MsgNewAuction:
res, err := msgServer.NewAuction(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
2022-08-28 10:57:06 -07:00
case *types.MsgNewBid:
res, err := msgServer.NewBid(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
2022-08-27 14:19:03 -07:00
// this line is used by starport scaffolding # 1
2022-08-25 16:51:14 -07:00
default:
errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg)
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
}
}
}