-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.go
33 lines (26 loc) · 1.11 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
package transfer
import (
"fmt"
sdk "github.com/evoblockchain/evochain/libs/cosmos-sdk/types"
sdkerrors "github.com/evoblockchain/evochain/libs/cosmos-sdk/types/errors"
tmtypes "github.com/evoblockchain/evochain/libs/tendermint/types"
"github.com/evoblockchain/evochain/libs/ibc-go/modules/apps/transfer/keeper"
"github.com/evoblockchain/evochain/libs/ibc-go/modules/apps/transfer/types"
)
// NewHandler returns sdk.Handler for IBC token transfer module messages
func NewHandler(k keeper.Keeper) sdk.Handler {
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
if !tmtypes.HigherThanVenus1(ctx.BlockHeight()) {
errMsg := fmt.Sprintf("ibc transfer is not supported at height %d", ctx.BlockHeight())
return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg)
}
ctx.SetEventManager(sdk.NewEventManager())
switch msg := msg.(type) {
case *types.MsgTransfer:
res, err := k.Transfer(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
default:
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized ICS-20 transfer message type: %T", msg)
}
}
}