diff --git a/.changeset/funny-hairs-destroy.md b/.changeset/funny-hairs-destroy.md new file mode 100644 index 0000000000..465ab2b9ef --- /dev/null +++ b/.changeset/funny-hairs-destroy.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/store-sync": patch +--- + +Improved error handling of `TransactionReceiptNotFoundError` in `waitForTransaction` when Viem versions aren't aligned. diff --git a/packages/store-sync/src/createStoreSync.ts b/packages/store-sync/src/createStoreSync.ts index a359d8d813..a7a5ce992a 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 { GetTransactionReceiptErrorType, Hex } from "viem"; import { StorageAdapter, StorageAdapterBlock, @@ -290,10 +290,13 @@ export async function createStoreSync( 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; } }),