From 603b2ab6631c4f38fca0d9092d255578061987aa Mon Sep 17 00:00:00 2001 From: CryptoSpaces <39212459+CryptoSpaces@users.noreply.github.com> Date: Sun, 1 Sep 2024 20:02:56 +0200 Subject: [PATCH] fix(store-sync): handle TransactionReceiptNotFoundError (#3115) Co-authored-by: Kevin Ingersoll --- .changeset/funny-hairs-destroy.md | 5 +++++ packages/store-sync/src/createStoreSync.ts | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 .changeset/funny-hairs-destroy.md 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; } }),