From 5065d616e767226d2b8d7e09e8c6d7eed9cdb0c9 Mon Sep 17 00:00:00 2001 From: rustdev Date: Tue, 21 May 2024 23:31:00 +0100 Subject: [PATCH] import custom pfm into app.go --- app/app.go | 2 ++ custom/custompfm/keeper/keeper.go | 40 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 custom/custompfm/keeper/keeper.go diff --git a/app/app.go b/app/app.go index f3f036fb..6b4a4ed3 100644 --- a/app/app.go +++ b/app/app.go @@ -88,6 +88,7 @@ import ( ibcclientclient "github.com/cosmos/ibc-go/v7/modules/core/02-client/client" ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + custompfm "github.com/notional-labs/composable/v6/custom/custompfm/keeper" customibctransfer "github.com/notional-labs/composable/v6/custom/ibc-transfer" customstaking "github.com/notional-labs/composable/v6/custom/staking" "github.com/spf13/cast" @@ -339,6 +340,7 @@ func NewComposableApp( enabledProposals, ) + custompfm.NewIBCMiddleware() // transferModule := transfer.NewAppModule(app.TransferKeeper) transferModule := customibctransfer.NewAppModule(appCodec, app.TransferKeeper, app.BankKeeper) routerModule := router.NewAppModule(app.RouterKeeper) diff --git a/custom/custompfm/keeper/keeper.go b/custom/custompfm/keeper/keeper.go new file mode 100644 index 00000000..e38e19b1 --- /dev/null +++ b/custom/custompfm/keeper/keeper.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + router "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward" + "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/keeper" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" +) + +var _ porttypes.Middleware = &IBCMiddleware{} + +// IBCMiddleware implements the ICS26 callbacks for the forward middleware given the +// forward keeper and the underlying application. +type IBCMiddleware struct { + router.IBCMiddleware +} + +func NewIBCMiddleware( + app porttypes.IBCModule, + k *keeper.Keeper, + retriesOnTimeout uint8, + forwardTimeout time.Duration, + refundTimeout time.Duration, +) IBCMiddleware { + return IBCMiddleware{ + IBCMiddleware: router.NewIBCMiddleware(app, k, retriesOnTimeout, forwardTimeout, refundTimeout), + } +} + +func (im IBCMiddleware) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + relayer sdk.AccAddress, +) ibcexported.Acknowledgement { + return im.IBCMiddleware.OnRecvPacket(ctx, packet, relayer) +}