Skip to content

Commit

Permalink
Implement get processed receipt
Browse files Browse the repository at this point in the history
  • Loading branch information
yorhodes committed May 1, 2024
1 parent e87bbfc commit 6379420
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions typescript/sdk/src/core/HyperlaneCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ export class HyperlaneCore extends HyperlaneApp<CoreFactories> {
}
}

async getProcessedReceipt(
message: DispatchedMessage,
): Promise<ethers.ContractReceipt> {
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<ethers.ContractReceipt> {
Expand All @@ -130,14 +146,8 @@ export class HyperlaneCore extends HyperlaneApp<CoreFactories> {

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(
Expand Down

0 comments on commit 6379420

Please sign in to comment.