-
Notifications
You must be signed in to change notification settings - Fork 586
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding updates to composite router and scaffolding for LegacyIBCModule (
#7010) * chore: adding updates to composite router and scaffolding for IBCLegacyModule * chore: support construction of LegacyIBCModules over consecutive calls to AddRoute * chore: removed ack handhsake impl * chore: fix linter * chore: lint * Linter * chore: addressing PR feedback * chore: routeToLegacyModule returns a single item * Update modules/core/05-port/types/router_v2.go * Update modules/core/05-port/types/router_v2.go * Update modules/core/05-port/types/router_v2.go * chore: fix errors from merge conflict --------- Co-authored-by: bznein <nikolas.degiorgis@interchain.io> Co-authored-by: Colin Axnér <25233464+colin-axner@users.noreply.github.com>
- Loading branch information
1 parent
a4a7bdd
commit 832a0fc
Showing
6 changed files
with
279 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
package types | ||
|
||
import ( | ||
errorsmod "cosmossdk.io/errors" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" | ||
channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" | ||
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" | ||
) | ||
|
||
// TODO: IBCModule will be renamed to ClassicIBCModule in a follow up. | ||
type ClassicIBCModule IBCModule | ||
|
||
// LegacyIBCModule implements the ICS26 interface for transfer given the transfer keeper. | ||
type LegacyIBCModule struct { | ||
cbs []ClassicIBCModule | ||
} | ||
|
||
// TODO: added this for testing purposes, we can remove later if tests are refactored. | ||
func (im *LegacyIBCModule) GetCallbacks() []ClassicIBCModule { | ||
return im.cbs | ||
} | ||
|
||
// NewLegacyIBCModule creates a new IBCModule given the keeper | ||
func NewLegacyIBCModule(cbs ...ClassicIBCModule) ClassicIBCModule { | ||
return LegacyIBCModule{ | ||
cbs: cbs, | ||
} | ||
} | ||
|
||
// OnChanOpenInit implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanOpenInit( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID string, | ||
channelID string, | ||
counterparty channeltypes.Counterparty, | ||
version string, | ||
) (string, error) { | ||
return "", nil | ||
} | ||
|
||
// OnChanOpenTry implements the IBCModule interface. | ||
func (LegacyIBCModule) OnChanOpenTry( | ||
ctx sdk.Context, | ||
order channeltypes.Order, | ||
connectionHops []string, | ||
portID, | ||
channelID string, | ||
counterparty channeltypes.Counterparty, | ||
counterpartyVersion string, | ||
) (string, error) { | ||
return "", nil | ||
} | ||
|
||
// OnChanOpenAck implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanOpenAck( | ||
ctx sdk.Context, | ||
portID, | ||
channelID string, | ||
counterpartyChannelID string, | ||
counterpartyVersion string, | ||
) error { | ||
return nil | ||
} | ||
|
||
// OnChanOpenConfirm implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanOpenConfirm( | ||
ctx sdk.Context, | ||
portID, | ||
channelID string, | ||
) error { | ||
return nil | ||
} | ||
|
||
// OnChanCloseInit implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanCloseInit( | ||
ctx sdk.Context, | ||
portID, | ||
channelID string, | ||
) error { | ||
return nil | ||
} | ||
|
||
// OnChanCloseConfirm implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanCloseConfirm( | ||
ctx sdk.Context, | ||
portID, | ||
channelID string, | ||
) error { | ||
return nil | ||
} | ||
|
||
// OnSendPacket implements the IBCModule interface. | ||
func (im LegacyIBCModule) OnSendPacket( | ||
ctx sdk.Context, | ||
portID string, | ||
channelID string, | ||
sequence uint64, | ||
timeoutHeight clienttypes.Height, | ||
timeoutTimestamp uint64, | ||
dataBz []byte, | ||
signer sdk.AccAddress, | ||
) error { | ||
// to maintain backwards compatibility, OnSendPacket iterates over the callbacks in order, as they are wired from bottom to top of the stack. | ||
for _, cb := range im.cbs { | ||
if err := cb.OnSendPacket(ctx, portID, channelID, sequence, timeoutHeight, timeoutTimestamp, dataBz, signer); err != nil { | ||
return errorsmod.Wrapf(err, "send packet callback failed for portID %s channelID %s", portID, channelID) | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
// OnRecvPacket implements the IBCModule interface. A successful acknowledgement | ||
// is returned if the packet data is successfully decoded and the receive application | ||
// logic returns without error. | ||
// A nil acknowledgement may be returned when using the packet forwarding feature. This signals to core IBC that the acknowledgement will be written asynchronously. | ||
func (LegacyIBCModule) OnRecvPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
relayer sdk.AccAddress, | ||
) ibcexported.Acknowledgement { | ||
return nil | ||
} | ||
|
||
// OnAcknowledgementPacket implements the IBCModule interface | ||
func (LegacyIBCModule) OnAcknowledgementPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
acknowledgement []byte, | ||
relayer sdk.AccAddress, | ||
) error { | ||
return nil | ||
} | ||
|
||
// OnTimeoutPacket implements the IBCModule interface | ||
func (LegacyIBCModule) OnTimeoutPacket( | ||
ctx sdk.Context, | ||
packet channeltypes.Packet, | ||
relayer sdk.AccAddress, | ||
) error { | ||
return nil | ||
} | ||
|
||
// OnChanUpgradeInit implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanUpgradeInit(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) (string, error) { | ||
return "", nil | ||
} | ||
|
||
// OnChanUpgradeTry implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanUpgradeTry(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, counterpartyVersion string) (string, error) { | ||
return "", nil | ||
} | ||
|
||
// OnChanUpgradeAck implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanUpgradeAck(ctx sdk.Context, portID, channelID, counterpartyVersion string) error { | ||
return nil | ||
} | ||
|
||
// OnChanUpgradeOpen implements the IBCModule interface | ||
func (LegacyIBCModule) OnChanUpgradeOpen(ctx sdk.Context, portID, channelID string, proposedOrder channeltypes.Order, proposedConnectionHops []string, proposedVersion string) { | ||
} | ||
|
||
// UnmarshalPacketData attempts to unmarshal the provided packet data bytes | ||
// into a FungibleTokenPacketData. This function implements the optional | ||
// PacketDataUnmarshaler interface required for ADR 008 support. | ||
func (LegacyIBCModule) UnmarshalPacketData(ctx sdk.Context, portID, channelID string, bz []byte) (interface{}, error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.