diff --git a/x/axelarnet/handler.go b/x/axelarnet/handler.go index 73a585c91..a467f9002 100644 --- a/x/axelarnet/handler.go +++ b/x/axelarnet/handler.go @@ -111,7 +111,7 @@ func NewProposalHandler(k keeper.Keeper, nexusK types.Nexus, accountK types.Acco payloadHash := crypto.Keccak256(contractCall.Payload) msgID, txID, nonce := nexusK.GenerateMessageID(ctx) - msg := nexus.NewGeneralMessage_(msgID, sender, recipient, payloadHash, txID, nonce, nil) + msg := nexus.NewGeneralMessage(msgID, sender, recipient, payloadHash, txID, nonce, nil) events.Emit(ctx, &types.ContractCallSubmitted{ MessageID: msg.ID, diff --git a/x/axelarnet/keeper/msg_server.go b/x/axelarnet/keeper/msg_server.go index a9a1f3ba2..651584261 100644 --- a/x/axelarnet/keeper/msg_server.go +++ b/x/axelarnet/keeper/msg_server.go @@ -76,7 +76,7 @@ func (s msgServer) CallContract(c context.Context, req *types.CallContractReques payloadHash := crypto.Keccak256(req.Payload) msgID, txID, nonce := s.nexus.GenerateMessageID(ctx) - msg := nexus.NewGeneralMessage_(msgID, sender, recipient, payloadHash, txID, nonce, nil) + msg := nexus.NewGeneralMessage(msgID, sender, recipient, payloadHash, txID, nonce, nil) events.Emit(ctx, &types.ContractCallSubmitted{ MessageID: msg.ID, diff --git a/x/axelarnet/message_handler.go b/x/axelarnet/message_handler.go index fb4853b90..8bc9322c8 100644 --- a/x/axelarnet/message_handler.go +++ b/x/axelarnet/message_handler.go @@ -246,7 +246,7 @@ func handleMessage(ctx sdk.Context, n types.Nexus, b types.BankKeeper, sourceAdd destChain := funcs.MustOk(n.GetChain(ctx, nexus.ChainName(msg.DestinationChain))) recipient := nexus.CrossChainAddress{Chain: destChain, Address: msg.DestinationAddress} - m := nexus.NewGeneralMessage_( + m := nexus.NewGeneralMessage( id, sourceAddress, recipient, @@ -283,7 +283,7 @@ func handleMessageWithToken(ctx sdk.Context, n types.Nexus, b types.BankKeeper, destChain := funcs.MustOk(n.GetChain(ctx, nexus.ChainName(msg.DestinationChain))) recipient := nexus.CrossChainAddress{Chain: destChain, Address: msg.DestinationAddress} - m := nexus.NewGeneralMessage_( + m := nexus.NewGeneralMessage( id, sourceAddress, recipient, diff --git a/x/evm/abci.go b/x/evm/abci.go index a48a25f6e..c2c593381 100644 --- a/x/evm/abci.go +++ b/x/evm/abci.go @@ -214,7 +214,7 @@ func setMessageToNexus(ctx sdk.Context, n types.Nexus, event types.Event, asset Address: e.ContractCall.ContractAddress, } - message = nexus.NewGeneralMessage_( + message = nexus.NewGeneralMessage( string(event.GetID()), sender, recipient, @@ -239,7 +239,7 @@ func setMessageToNexus(ctx sdk.Context, n types.Nexus, event types.Event, asset Address: e.ContractCallWithToken.ContractAddress, } - message = nexus.NewGeneralMessage_( + message = nexus.NewGeneralMessage( string(event.GetID()), sender, recipient, diff --git a/x/evm/abci_test.go b/x/evm/abci_test.go index 7891318a9..01f2a1c59 100644 --- a/x/evm/abci_test.go +++ b/x/evm/abci_test.go @@ -66,7 +66,7 @@ func TestHandleGeneralMessage(t *testing.T) { asset := rand.Coin() givenMessage := Given("a message", func() { - msg = nexus.NewGeneralMessage(evmTestUtils.RandomHash().Hex(), sender, receiver, evmCrypto.Keccak256(payload), nexus.Approved, evmTestUtils.RandomHash().Bytes()[:], uint64(rand.I64Between(0, 10000)), nil) + msg = nexus.NewGeneralMessage(evmTestUtils.RandomHash().Hex(), sender, receiver, evmCrypto.Keccak256(payload), evmTestUtils.RandomHash().Bytes()[:], uint64(rand.I64Between(0, 10000)), nil) ctx, _, n, multisigKeeper, _, destinationCk = setup() n.SetMessageFailedFunc = func(ctx sdk.Context, id string) error { @@ -280,7 +280,10 @@ func TestHandleGeneralMessages(t *testing.T) { destChain.Module = types.ModuleName sender := nexus.CrossChainAddress{Chain: srcChain, Address: evmTestUtils.RandomAddress().Hex()} receiver := nexus.CrossChainAddress{Chain: destChain, Address: evmTestUtils.RandomAddress().Hex()} - msg := nexus.NewGeneralMessage(evmTestUtils.RandomHash().Hex(), sender, receiver, evmTestUtils.RandomHash().Bytes(), nexus.Processing, evmTestUtils.RandomHash().Bytes()[:], uint64(rand.I64Between(0, 10000)), nil) + + msg := nexus.NewGeneralMessage(evmTestUtils.RandomHash().Hex(), sender, receiver, evmTestUtils.RandomHash().Bytes(), evmTestUtils.RandomHash().Bytes()[:], uint64(rand.I64Between(0, 10000)), nil) + msg.Status = nexus.Processing + msgs = append(msgs, msg) } return msgs diff --git a/x/evm/types/command_test.go b/x/evm/types/command_test.go index a9ba25cad..607703ccb 100644 --- a/x/evm/types/command_test.go +++ b/x/evm/types/command_test.go @@ -37,7 +37,7 @@ func TestNewApproveContractCallCommandFromGeneralMessage(t *testing.T) { destChain := nexus.Chain{Name: nexus.ChainName(rand.StrBetween(8, 64)), Module: types.ModuleName} sender := nexus.CrossChainAddress{Chain: srcChain, Address: rand.AccAddr().String()} receiver := nexus.CrossChainAddress{Chain: destChain, Address: testutils.RandomAddress().Hex()} - msg := nexus.NewGeneralMessage(txID.Hex(), sender, receiver, payloadHash, nexus.Approved, txID[:], eventIndex, nil) + msg := nexus.NewGeneralMessage(txID.Hex(), sender, receiver, payloadHash, txID[:], eventIndex, nil) actual := types.NewApproveContractCallCommandGeneric(chainID, keyID, common.HexToAddress(msg.GetDestinationAddress()), common.BytesToHash(msg.PayloadHash), common.BytesToHash(msg.SourceTxID), msg.GetSourceChain(), msg.GetSourceAddress(), msg.SourceTxIndex, msg.ID) diff --git a/x/nexus/exported/testutils/rand.go b/x/nexus/exported/testutils/rand.go index 7e9085d9b..0879fcbd9 100644 --- a/x/nexus/exported/testutils/rand.go +++ b/x/nexus/exported/testutils/rand.go @@ -45,14 +45,17 @@ func RandomMessage(statuses ...exported.GeneralMessage_Status) exported.GeneralM statuses = []exported.GeneralMessage_Status{exported.Approved, exported.Processing, exported.Executed, exported.Failed} } coin := rand.Coin() - return exported.NewGeneralMessage( + + msg := exported.NewGeneralMessage( rand.StrBetween(10, 20), RandomCrossChainAddress(), RandomCrossChainAddress(), rand.Bytes(32), - rand.Of(statuses...), rand.Bytes(32), uint64(rand.I64Between(0, 10000)), &coin, ) + msg.Status = rand.Of(statuses...) + + return msg } diff --git a/x/nexus/exported/types.go b/x/nexus/exported/types.go index 5431f3b08..cb5a89015 100644 --- a/x/nexus/exported/types.go +++ b/x/nexus/exported/types.go @@ -240,23 +240,8 @@ func (m TransferDirection) ValidateBasic() error { } } -// NewGeneralMessage returns a GeneralMessage struct -// Deprecated: use NewGeneralMessage_ instead -func NewGeneralMessage(id string, sender CrossChainAddress, recipient CrossChainAddress, payloadHash []byte, status GeneralMessage_Status, sourceTxID []byte, sourceTxIndex uint64, asset *sdk.Coin) GeneralMessage { - return GeneralMessage{ - ID: id, - Sender: sender, - Recipient: recipient, - PayloadHash: payloadHash, - Status: status, - Asset: asset, - SourceTxID: sourceTxID, - SourceTxIndex: sourceTxIndex, - } -} - -// NewGeneralMessage_ returns a GeneralMessage struct with status set to approved -func NewGeneralMessage_(id string, sender CrossChainAddress, recipient CrossChainAddress, payloadHash []byte, sourceTxID []byte, sourceTxIndex uint64, asset *sdk.Coin) GeneralMessage { +// NewGeneralMessage returns a GeneralMessage struct with status set to approved +func NewGeneralMessage(id string, sender CrossChainAddress, recipient CrossChainAddress, payloadHash []byte, sourceTxID []byte, sourceTxIndex uint64, asset *sdk.Coin) GeneralMessage { return GeneralMessage{ ID: id, Sender: sender, diff --git a/x/nexus/keeper/msg_dispatcher.go b/x/nexus/keeper/msg_dispatcher.go index 0dc117a40..5758fb2cf 100644 --- a/x/nexus/keeper/msg_dispatcher.go +++ b/x/nexus/keeper/msg_dispatcher.go @@ -67,7 +67,7 @@ func (m Messenger) routeMsg(ctx sdk.Context, msg exported.WasmMessage) error { sender := exported.CrossChainAddress{Chain: sourceChain, Address: msg.SourceAddress} recipient := exported.CrossChainAddress{Chain: destinationChain, Address: msg.DestinationAddress} - nexusMsg := exported.NewGeneralMessage_(id, sender, recipient, msg.PayloadHash, msg.SourceTxID, msg.SourceTxIndex, nil) + nexusMsg := exported.NewGeneralMessage(id, sender, recipient, msg.PayloadHash, msg.SourceTxID, msg.SourceTxIndex, nil) if err := m.Nexus.SetNewMessage(ctx, nexusMsg); err != nil { return err }