forked from lavanet/lava
-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.go
42 lines (37 loc) · 1.45 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package pairing
import (
"fmt"
sdkerrors "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
legacyerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/lavanet/lava/x/pairing/keeper"
"github.com/lavanet/lava/x/pairing/types"
)
// 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.MsgStakeProvider:
res, err := msgServer.StakeProvider(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgUnstakeProvider:
res, err := msgServer.UnstakeProvider(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgRelayPayment:
res, err := msgServer.RelayPayment(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgFreezeProvider:
res, err := msgServer.FreezeProvider(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgUnfreezeProvider:
res, err := msgServer.UnfreezeProvider(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(legacyerrors.ErrUnknownRequest, errMsg)
}
}
}