Skip to content

Commit ea06380

Browse files
jinchungibrahimtaveras00
authored andcommitted
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
1 parent 2415caa commit ea06380

File tree

2 files changed

+2
-22
lines changed

2 files changed

+2
-22
lines changed

src/resources/transactions/transaction.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const fetchTransaction = async ({
4646
});
4747

4848
const tx = response?.data?.payload?.transaction;
49-
if (!tx) {
49+
if (!tx || !tx?.status || (tx?.status as string) === '') {
5050
return null;
5151
}
5252
const parsedTx = await parseTransaction(tx, currency, chainId);

src/state/nonces/index.ts

+1-21
Original file line numberDiff line numberDiff line change
@@ -106,27 +106,7 @@ export const nonceStore = createStore<CurrentNonceState<Nonces>>(
106106
{
107107
persist: {
108108
name: 'nonces',
109-
version: 1,
110-
migrate: (persistedState: unknown, version: number) => {
111-
if (version === 0) {
112-
const chainsIdByName = useBackendNetworksStore.getState().getChainsIdByName();
113-
const oldState = persistedState as CurrentNonceState<NoncesV0>;
114-
const newNonces: CurrentNonceState<Nonces>['nonces'] = {};
115-
for (const [address, networkNonces] of Object.entries(oldState.nonces)) {
116-
for (const [network, nonceData] of Object.entries(networkNonces)) {
117-
if (!newNonces[address]) {
118-
newNonces[address] = {} as Record<ChainId, NonceData>;
119-
}
120-
newNonces[address][chainsIdByName[network as Network]] = nonceData;
121-
}
122-
}
123-
return {
124-
...oldState,
125-
nonces: newNonces,
126-
};
127-
}
128-
return persistedState as CurrentNonceState<Nonces>;
129-
},
109+
version: 2,
130110
},
131111
}
132112
);

0 commit comments

Comments
 (0)