@@ -272,26 +272,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
272272 );
273273 _processWarpMessage (warpMessage, relayerRewardAddress);
274274 }
275-
276- /**
277- * @dev Emits a {ReceiveCrossChainMessage} event.
278- * Receives a Warp message as a byte payload and processes it.
279- * Re-entrancy is explicitly disallowed between receiving functions. One message is not able to receive another message.
280- * Requirements:
281- *
282- * - Valid warp message is decoded from the payload
283- *
284- * @inheritdoc ITeleporterMessenger
285- */
286- function receiveInterChainMessage (
287- ICMMessage calldata icmMessage ,
288- address relayerRewardAddress
289- ) external receiverNonReentrant {
290- WarpMessage memory warpMessage =
291- _warpMessenger.getVerifiedICMMessage (icmMessage);
292- _processWarpMessage (warpMessage, relayerRewardAddress);
293- }
294-
275+
295276 /**
296277 * @dev A Teleporter message has an associated `requiredGasLimit` that is used to execute the message.
297278 * If the `requiredGasLimit` is too low, then the message execution will fail. This method allows
@@ -672,45 +653,16 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
672653 TeleporterMessageInput memory messageInput ,
673654 TeleporterMessageReceipt[] memory receipts
674655 ) private returns (bytes32 ) {
675-
676- (bytes32 messageID , TeleporterMessage memory teleporterMessage , TeleporterFeeInfo memory adjustedFeeInfo )
677- = _prepareTeleporterMessage (messageInput, receipts);
678-
679- bytes memory teleporterMessageBytes = abi.encode (teleporterMessage);
680- sentMessageInfo[messageID] = SentMessageInfo ({
681- messageHash: keccak256 (teleporterMessageBytes),
682- feeInfo: adjustedFeeInfo
683- });
684-
685- emit SendCrossChainMessage (
686- messageID, messageInput.destinationBlockchainID, teleporterMessage, adjustedFeeInfo
687- );
688-
689- // Submit the message to the AWM precompile.
690- _warpMessenger.sendWarpMessage (teleporterMessageBytes);
691-
692- return messageID;
693- }
694-
695-
696- /**
697- * @dev Helper function that assempbles the actual telepoter message and associated
698- * metadata (message id, fee info)
699- */
700- function _prepareTeleporterMessage (
701- TeleporterMessageInput memory messageInput ,
702- TeleporterMessageReceipt[] memory receipts
703- ) private returns (bytes32 messageID , TeleporterMessage memory teleporterMessage , TeleporterFeeInfo memory ) {
704656 // If the blockchain ID has yet to be initialized, do so now.
705657 bytes32 blockchainID_ = initializeBlockchainID ();
706658
707659 // Get the message ID to use for this message by incrementing it.
708660 uint256 messageNonce_ = ++ messageNonce;
709- messageID =
661+ bytes32 messageID =
710662 calculateMessageID (blockchainID_, messageInput.destinationBlockchainID, messageNonce_);
711663
712664 // Construct and serialize the message.
713- teleporterMessage = TeleporterMessage ({
665+ TeleporterMessage memory teleporterMessage = TeleporterMessage ({
714666 messageNonce: messageNonce_,
715667 originSenderAddress: msg .sender ,
716668 destinationBlockchainID: messageInput.destinationBlockchainID,
@@ -720,7 +672,7 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
720672 receipts: receipts,
721673 message: messageInput.message
722674 });
723-
675+ bytes memory teleporterMessageBytes = abi.encode (teleporterMessage);
724676
725677 // If the fee amount is non-zero, transfer the asset into control of this TeleporterMessenger contract instance.
726678 // The fee is allowed to be 0 because it's possible for someone to run their own relayer and deliver their own messages,
@@ -745,8 +697,19 @@ contract TeleporterMessenger is ITeleporterMessenger, ReentrancyGuards, Initiali
745697 feeTokenAddress: messageInput.feeInfo.feeTokenAddress,
746698 amount: adjustedFeeAmount
747699 });
700+ sentMessageInfo[messageID] = SentMessageInfo ({
701+ messageHash: keccak256 (teleporterMessageBytes),
702+ feeInfo: adjustedFeeInfo
703+ });
748704
749- return (messageID, teleporterMessage, adjustedFeeInfo);
705+ emit SendCrossChainMessage (
706+ messageID, messageInput.destinationBlockchainID, teleporterMessage, adjustedFeeInfo
707+ );
708+
709+ // Submit the message to the AWM precompile.
710+ _warpMessenger.sendWarpMessage (teleporterMessageBytes);
711+
712+ return messageID;
750713 }
751714
752715 /**
0 commit comments