Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rouzwelt committed Dec 10, 2024
1 parent a88ef1d commit 2641528
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
15 changes: 6 additions & 9 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,12 @@ export async function handleRevert(
receipt: TransactionReceipt,
rawtx: RawTx,
signerBalance: BigNumber,
): Promise<
| {
err: any;
nodeError: boolean;
snapshot: string;
rawRevertError?: TxRevertError;
}
| undefined
> {
): Promise<{
err: any;
nodeError: boolean;
snapshot: string;
rawRevertError?: TxRevertError;
}> {
const header = "transaction reverted onchain";
try {
const gasErr = checkGasIssue(receipt, rawtx, signerBalance);
Expand Down
33 changes: 23 additions & 10 deletions src/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,29 @@ export async function handleReceipt(
}
return result;
} else {
// wait at least 90s before simulating the revert tx
// in order for rpcs to catch up
await sleep(Math.max(90_000 + time - Date.now(), 0));
const simulation = await handleRevert(
signer,
txhash as `0x${string}`,
receipt,
rawtx,
signerBalance,
);
const simulation = await (async () => {
const result = await handleRevert(
signer,
txhash as `0x${string}`,
receipt,
rawtx,
signerBalance,
);
if (result.snapshot.includes("simulation failed to find the revert reason")) {
// wait at least 90s before simulating the revert tx
// in order for rpcs to catch up
await sleep(Math.max(90_000 + time - Date.now(), 0));
return await handleRevert(
signer,
txhash as `0x${string}`,
receipt,
rawtx,
signerBalance,
);
} else {
return result;
}
})();
if (simulation) {
result.error = simulation;
spanAttributes["txNoneNodeError"] = !simulation.nodeError;
Expand Down

0 comments on commit 2641528

Please sign in to comment.