From 3ba3b6fe148cf115d8769575af36d69800fe391e Mon Sep 17 00:00:00 2001 From: bznein Date: Thu, 19 Sep 2024 14:26:34 +0100 Subject: [PATCH] add constructor for MsgRecvPacket --- modules/apps/transfer/transfer_v2_test.go | 7 +------ modules/core/04-channel/v2/types/msgs.go | 12 ++++++++++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/modules/apps/transfer/transfer_v2_test.go b/modules/apps/transfer/transfer_v2_test.go index ec7c5c4ec00..360e863c60d 100644 --- a/modules/apps/transfer/transfer_v2_test.go +++ b/modules/apps/transfer/transfer_v2_test.go @@ -133,12 +133,7 @@ func (suite *TransferV2TestSuite) TestHandleMsgV2Transfer() { packetV2 := channeltypesv2.NewPacketV2(1, pathAToB.EndpointB.ChannelID, pathAToB.EndpointA.ChannelID, timeoutTimestamp, *channeltypes.NewPacketData("transfer", "transfer", *channeltypes.NewPayload(types.V2, "json", bz))) - msgRecvPacket := &channeltypesv2.MsgRecvPacket{ - Packet: packetV2, - ProofCommitment: proof, - ProofHeight: proofHeight, - Signer: suite.chainA.SenderAccount.GetAddress().String(), - } + msgRecvPacket := channeltypesv2.NewMsgRecvPacket(packetV2, proof, proofHeight, suite.chainA.SenderAccount.GetAddress().String()) res, err = suite.chainA.SendMsgs(msgRecvPacket) suite.Require().NoError(err) diff --git a/modules/core/04-channel/v2/types/msgs.go b/modules/core/04-channel/v2/types/msgs.go index aa891900d68..a2013e8bd7d 100644 --- a/modules/core/04-channel/v2/types/msgs.go +++ b/modules/core/04-channel/v2/types/msgs.go @@ -2,6 +2,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" v1types "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" ) @@ -16,3 +18,13 @@ func NewMsgSendPacket(sourceID string, timeoutTimestamp uint64, signer string, p Signer: signer, } } + +// NewMsgRecvPacket constructs and returns a new MsgRecvPacket +func NewMsgRecvPacket(packet v1types.PacketV2, proofCommitment []byte, proofHeight clienttypes.Height, signer string) *MsgRecvPacket { + return &MsgRecvPacket{ + Packet: packet, + ProofCommitment: proofCommitment, + ProofHeight: proofHeight, + Signer: signer, + } +}