-
Notifications
You must be signed in to change notification settings - Fork 170
/
module.go
47 lines (39 loc) · 1.3 KB
/
module.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
43
44
45
46
47
package ibctransfer
import (
sdk "github.com/cosmos/cosmos-sdk/types"
ibctransfer "github.com/cosmos/ibc-go/v2/modules/apps/transfer"
ibctransfertypes "github.com/cosmos/ibc-go/v2/modules/apps/transfer/types"
channeltypes "github.com/cosmos/ibc-go/v2/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/v2/modules/core/exported"
"github.com/umee-network/umee/x/ibctransfer/keeper"
)
// AppModule embeds the ICS-20 transfer AppModule where we only override specific
// methods.
type AppModule struct {
// embed the ICS-20 transfer's AppModule
ibctransfer.AppModule
keeper keeper.Keeper
}
func NewAppModule(am ibctransfer.AppModule, k keeper.Keeper) AppModule {
return AppModule{
AppModule: am,
keeper: k,
}
}
// OnRecvPacket delegates the OnRecvPacket call to the embedded ICS-20 transfer
// AppModule and updates metadata if successful.
func (am AppModule) OnRecvPacket(
ctx sdk.Context,
packet channeltypes.Packet,
relayer sdk.AccAddress,
) ibcexported.Acknowledgement {
ack := am.AppModule.OnRecvPacket(ctx, packet, relayer)
if ack.Success() {
var data ibctransfertypes.FungibleTokenPacketData
if err := ibctransfertypes.ModuleCdc.UnmarshalJSON(packet.GetData(), &data); err == nil {
// track metadata
am.keeper.PostOnRecvPacket(ctx, packet, data)
}
}
return ack
}