From ea06380c5b82119486f04967801a4f51d6aa6b13 Mon Sep 17 00:00:00 2001 From: Jin Date: Thu, 16 Jan 2025 11:19:26 -0700 Subject: [PATCH] Fix nonce issue for dropped transactions (#6402) * Bump nonce persist version * Remove unnecessary nonce persist migration * Treat API responses that have a txn object status the same as not having a tx object yet, as it means it has not been indexed by our third parties yet --- src/resources/transactions/transaction.ts | 2 +- src/state/nonces/index.ts | 22 +--------------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/src/resources/transactions/transaction.ts b/src/resources/transactions/transaction.ts index 8280e63975d..9b9ab39c038 100644 --- a/src/resources/transactions/transaction.ts +++ b/src/resources/transactions/transaction.ts @@ -46,7 +46,7 @@ export const fetchTransaction = async ({ }); const tx = response?.data?.payload?.transaction; - if (!tx) { + if (!tx || !tx?.status || (tx?.status as string) === '') { return null; } const parsedTx = await parseTransaction(tx, currency, chainId); diff --git a/src/state/nonces/index.ts b/src/state/nonces/index.ts index d49d40e9c89..21d7f7a0075 100644 --- a/src/state/nonces/index.ts +++ b/src/state/nonces/index.ts @@ -106,27 +106,7 @@ export const nonceStore = createStore>( { persist: { name: 'nonces', - version: 1, - migrate: (persistedState: unknown, version: number) => { - if (version === 0) { - const chainsIdByName = useBackendNetworksStore.getState().getChainsIdByName(); - const oldState = persistedState as CurrentNonceState; - const newNonces: CurrentNonceState['nonces'] = {}; - for (const [address, networkNonces] of Object.entries(oldState.nonces)) { - for (const [network, nonceData] of Object.entries(networkNonces)) { - if (!newNonces[address]) { - newNonces[address] = {} as Record; - } - newNonces[address][chainsIdByName[network as Network]] = nonceData; - } - } - return { - ...oldState, - nonces: newNonces, - }; - } - return persistedState as CurrentNonceState; - }, + version: 2, }, } );