Skip to content

Commit

Permalink
fix(store-sync): handle TransactionReceiptNotFoundError (#3115)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Ingersoll <[email protected]>
  • Loading branch information
CryptoSpaces and holic authored Sep 1, 2024
1 parent 0738d29 commit 603b2ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-hairs-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store-sync": patch
---

Improved error handling of `TransactionReceiptNotFoundError` in `waitForTransaction` when Viem versions aren't aligned.
9 changes: 6 additions & 3 deletions packages/store-sync/src/createStoreSync.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { storeEventsAbi } from "@latticexyz/store";
import { Hex, TransactionReceiptNotFoundError } from "viem";
import { GetTransactionReceiptErrorType, Hex } from "viem";
import {
StorageAdapter,
StorageAdapterBlock,
Expand Down Expand Up @@ -290,10 +290,13 @@ export async function createStoreSync<config extends StoreConfig = StoreConfig>(
if (lastBlock.blockNumber >= blockNumber) {
return { status, blockNumber, transactionHash };
}
} catch (error) {
if (error instanceof TransactionReceiptNotFoundError) {
} catch (e) {
const error = e as GetTransactionReceiptErrorType;

if (error.name === "TransactionReceiptNotFoundError") {
return;
}

throw error;
}
}),
Expand Down

0 comments on commit 603b2ab

Please sign in to comment.