Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions yarn-project/pxe/src/pxe_service/pxe_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,23 @@ export class PXEService implements PXE {
}

public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
let txReceipt = new TxReceipt(txHash, TxStatus.DROPPED, 'Tx dropped by P2P node.');

// We first check if the tx is in pending (instead of first checking if it is mined) because if we first check
// for mined and then for pending there could be a race condition where the tx is mined between the two checks
// and we would incorrectly return a TxReceipt with status DROPPED
const pendingTx = await this.node.getPendingTxByHash(txHash);
if (pendingTx) {
txReceipt = new TxReceipt(txHash, TxStatus.PENDING, '');
}

const settledTx = await this.node.getTx(txHash);
if (settledTx) {
const deployedContractAddress = settledTx.newContractData.find(
c => !c.contractAddress.equals(AztecAddress.ZERO),
)?.contractAddress;

return new TxReceipt(
txReceipt = new TxReceipt(
txHash,
TxStatus.MINED,
'',
Expand All @@ -371,12 +381,7 @@ export class PXEService implements PXE {
);
}

const pendingTx = await this.node.getPendingTxByHash(txHash);
if (pendingTx) {
return new TxReceipt(txHash, TxStatus.PENDING, '');
}

return new TxReceipt(txHash, TxStatus.DROPPED, 'Tx dropped by P2P node.');
return txReceipt;
}

public async getTx(txHash: TxHash): Promise<L2Tx | undefined> {
Expand Down