diff --git a/typescript/sdk/src/core/HyperlaneCore.ts b/typescript/sdk/src/core/HyperlaneCore.ts index 7db721361a..0ff53d6c12 100644 --- a/typescript/sdk/src/core/HyperlaneCore.ts +++ b/typescript/sdk/src/core/HyperlaneCore.ts @@ -120,6 +120,22 @@ export class HyperlaneCore extends HyperlaneApp { } } + async getProcessedReceipt( + message: DispatchedMessage, + ): Promise { + const destinationChain = this.getDestination(message); + const mailbox = this.contractsMap[destinationChain].mailbox; + + const processedBlock = await mailbox.processedAt(message.id); + const events = await mailbox.queryFilter( + mailbox.filters.ProcessId(message.id), + processedBlock, + processedBlock, + ); + const processedEvent = events[0]; + return processedEvent.getTransactionReceipt(); + } + async relayMessage( message: DispatchedMessage, ): Promise { @@ -130,14 +146,8 @@ export class HyperlaneCore extends HyperlaneApp { const isDelivered = await mailbox.delivered(message.id); if (isDelivered) { - const processedBlock = await mailbox.processedAt(message.id); - const events = await mailbox.queryFilter( - mailbox.filters.ProcessId(message.id), - processedBlock, - processedBlock, - ); - const processedEvent = events[0]; - return processedEvent.getTransactionReceipt(); + this.logger.debug(`Message ${message.id} already delivered`); + return this.getProcessedReceipt(message); } return this.multiProvider.handleTx(