From 4297a9ea2a01ffacfe5a400ff86d5be5ba7393f9 Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Fri, 23 Sep 2022 12:31:48 +0100 Subject: [PATCH] Adding private sendTx function (#2257) --- .../27-interchain-accounts/controller/keeper/msg_server.go | 3 ++- .../apps/27-interchain-accounts/controller/keeper/relay.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/apps/27-interchain-accounts/controller/keeper/msg_server.go b/modules/apps/27-interchain-accounts/controller/keeper/msg_server.go index 52f86d286a7..c0277b4b45a 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/msg_server.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/msg_server.go @@ -50,7 +50,8 @@ func (s msgServer) SendTx(goCtx context.Context, msg *types.MsgSendTx) (*types.M } // explicitly passing nil as the argument is discarded as the channel capability is retrieved in SendTx. - seq, err := s.Keeper.SendTx(ctx, nil, msg.ConnectionId, portID, msg.PacketData, msg.TimeoutTimestamp) + absoluteTimeout := uint64(ctx.BlockTime().UnixNano()) + msg.TimeoutTimestamp + seq, err := s.Keeper.SendTx(ctx, nil, msg.ConnectionId, portID, msg.PacketData, absoluteTimeout) if err != nil { return nil, err } diff --git a/modules/apps/27-interchain-accounts/controller/keeper/relay.go b/modules/apps/27-interchain-accounts/controller/keeper/relay.go index 1473a0acfae..a94552705c7 100644 --- a/modules/apps/27-interchain-accounts/controller/keeper/relay.go +++ b/modules/apps/27-interchain-accounts/controller/keeper/relay.go @@ -17,6 +17,10 @@ import ( // absolute timeoutTimestamp must be provided. If the packet is timed out, the channel will be closed. // In the case of channel closure, a new channel may be reopened to reconnect to the host chain. func (k Keeper) SendTx(ctx sdk.Context, _ *capabilitytypes.Capability, connectionID, portID string, icaPacketData icatypes.InterchainAccountPacketData, timeoutTimestamp uint64) (uint64, error) { + return k.sendTx(ctx, connectionID, portID, icaPacketData, timeoutTimestamp) +} + +func (k Keeper) sendTx(ctx sdk.Context, connectionID, portID string, icaPacketData icatypes.InterchainAccountPacketData, timeoutTimestamp uint64) (uint64, error) { activeChannelID, found := k.GetOpenActiveChannel(ctx, connectionID, portID) if !found { return 0, sdkerrors.Wrapf(icatypes.ErrActiveChannelNotFound, "failed to retrieve active channel on connection %s for port %s", connectionID, portID)