Skip to content

Commit

Permalink
Replace Router with PortKeeper in IBCKeeper.
Browse files Browse the repository at this point in the history
  • Loading branch information
bznein committed Apr 10, 2024
1 parent c15cf6f commit 1deee4e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
5 changes: 5 additions & 0 deletions modules/core/05-port/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,8 @@ func (k Keeper) LookupModuleByPort(ctx sdk.Context, portID string) (string, *cap

return types.GetModuleOwner(modules), capability, nil
}

// GetRoute() returns a IBCModule for a given module.
func (k Keeper) GetRoute(module string) (types.IBCModule, bool) {
return k.Router.GetRoute(module)
}
1 change: 0 additions & 1 deletion modules/core/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type Keeper struct {
ConnectionKeeper connectionkeeper.Keeper
ChannelKeeper channelkeeper.Keeper
PortKeeper *portkeeper.Keeper
Router *porttypes.Router

authority string
}
Expand Down
30 changes: 15 additions & 15 deletions modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (k Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChan
}

// Retrieve application callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel open init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -262,7 +262,7 @@ func (k Keeper) ChannelOpenTry(goCtx context.Context, msg *channeltypes.MsgChann
}

// Retrieve application callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel open try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -309,7 +309,7 @@ func (k Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChann
}

// Retrieve application callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel open ack failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -351,7 +351,7 @@ func (k Keeper) ChannelOpenConfirm(goCtx context.Context, msg *channeltypes.MsgC
}

// Retrieve application callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel open confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -389,7 +389,7 @@ func (k Keeper) ChannelCloseInit(goCtx context.Context, msg *channeltypes.MsgCha
}

// Retrieve callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel close init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -423,7 +423,7 @@ func (k Keeper) ChannelCloseConfirm(goCtx context.Context, msg *channeltypes.Msg
}

// Retrieve callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel close confirm failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -463,7 +463,7 @@ func (k Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPacke
}

// Retrieve callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("receive packet failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -544,7 +544,7 @@ func (k Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*c
}

// Retrieve callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("timeout failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -616,7 +616,7 @@ func (k Keeper) TimeoutOnClose(goCtx context.Context, msg *channeltypes.MsgTimeo
}

// Retrieve callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("timeout on close failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -691,7 +691,7 @@ func (k Keeper) Acknowledgement(goCtx context.Context, msg *channeltypes.MsgAckn
}

// Retrieve callbacks from router
cbs, ok := k.Router.GetRoute(module)
cbs, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("acknowledgement failed", "port-id", msg.Packet.SourcePort, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -753,7 +753,7 @@ func (k Keeper) ChannelUpgradeInit(goCtx context.Context, msg *channeltypes.MsgC
return nil, errorsmod.Wrap(err, "could not retrieve module from port-id")
}

app, ok := k.Router.GetRoute(module)
app, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel upgrade init failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -801,7 +801,7 @@ func (k Keeper) ChannelUpgradeTry(goCtx context.Context, msg *channeltypes.MsgCh
return nil, errorsmod.Wrap(err, "could not retrieve module from port-id")
}

app, ok := k.Router.GetRoute(module)
app, ok := k.PortKeeper.GetRoute(module)
if !ok {
ctx.Logger().Error("channel upgrade try failed", "port-id", msg.PortId, "error", errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module))
return nil, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
Expand Down Expand Up @@ -862,7 +862,7 @@ func (k Keeper) ChannelUpgradeAck(goCtx context.Context, msg *channeltypes.MsgCh
return nil, errorsmod.Wrap(err, "could not retrieve module from port-id")
}

app, ok := k.Router.GetRoute(module)
app, ok := k.PortKeeper.GetRoute(module)
if !ok {
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
ctx.Logger().Error("channel upgrade ack failed", "port-id", msg.PortId, "error", err)
Expand Down Expand Up @@ -928,7 +928,7 @@ func (k Keeper) ChannelUpgradeConfirm(goCtx context.Context, msg *channeltypes.M
return nil, errorsmod.Wrap(err, "could not retrieve module from port-id")
}

app, ok := k.Router.GetRoute(module)
app, ok := k.PortKeeper.GetRoute(module)
if !ok {
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
ctx.Logger().Error("channel upgrade confirm failed", "port-id", msg.PortId, "error", err)
Expand Down Expand Up @@ -989,7 +989,7 @@ func (k Keeper) ChannelUpgradeOpen(goCtx context.Context, msg *channeltypes.MsgC
return nil, errorsmod.Wrap(err, "could not retrieve module from port-id")
}

app, ok := k.Router.GetRoute(module)
app, ok := k.PortKeeper.GetRoute(module)
if !ok {
err = errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module)
ctx.Logger().Error("channel upgrade open failed", "port-id", msg.PortId, "error", err)
Expand Down

0 comments on commit 1deee4e

Please sign in to comment.