diff --git a/packages/store-sync/src/createStoreSync.ts b/packages/store-sync/src/createStoreSync.ts index a359d8d813..bb61296452 100644 --- a/packages/store-sync/src/createStoreSync.ts +++ b/packages/store-sync/src/createStoreSync.ts @@ -1,5 +1,5 @@ import { storeEventsAbi } from "@latticexyz/store"; -import { Hex, TransactionReceiptNotFoundError } from "viem"; +import { Hex } from "viem"; import { StorageAdapter, StorageAdapterBlock, @@ -34,6 +34,7 @@ import { bigIntMax, chunk, isDefined, waitForIdle } from "@latticexyz/common/uti import { getSnapshot } from "./getSnapshot"; import { fetchAndStoreLogs } from "./fetchAndStoreLogs"; import { Store as StoreConfig } from "@latticexyz/store"; +import { isViemTransactionReceiptNotFoundError } from "@latticexyz/store-sync/isViemTransactionReceiptNotFoundError"; const debug = parentDebug.extend("createStoreSync"); @@ -291,7 +292,7 @@ export async function createStoreSync( return { status, blockNumber, transactionHash }; } } catch (error) { - if (error instanceof TransactionReceiptNotFoundError) { + if (isViemTransactionReceiptNotFoundError(error)) { return; } throw error; diff --git a/packages/store-sync/src/isViemTransactionReceiptNotFoundError.ts b/packages/store-sync/src/isViemTransactionReceiptNotFoundError.ts new file mode 100644 index 0000000000..833a835451 --- /dev/null +++ b/packages/store-sync/src/isViemTransactionReceiptNotFoundError.ts @@ -0,0 +1,16 @@ +import { TransactionReceiptNotFoundErrorType } from "viem"; + +type PartialViemError = Partial; + +export function isViemTransactionReceiptNotFoundError(error: unknown): error is Error & PartialViemError { + if (!(error instanceof Error)) { + return false; + } + + const maybeTransactionReceiptNotFoundErrorType = error as PartialViemError; + + return ( + maybeTransactionReceiptNotFoundErrorType.name === "TransactionReceiptNotFoundError" && + !!maybeTransactionReceiptNotFoundErrorType.version?.match(/Version: viem@\d+\.\d+\.\d+/gi) + ); +}