Skip to content

Commit

Permalink
Fix nonce issue for dropped transactions (#6402)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jinchung authored and ibrahimtaveras00 committed Jan 16, 2025
1 parent 2415caa commit ea06380
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/resources/transactions/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
22 changes: 1 addition & 21 deletions src/state/nonces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,27 +106,7 @@ export const nonceStore = createStore<CurrentNonceState<Nonces>>(
{
persist: {
name: 'nonces',
version: 1,
migrate: (persistedState: unknown, version: number) => {
if (version === 0) {
const chainsIdByName = useBackendNetworksStore.getState().getChainsIdByName();
const oldState = persistedState as CurrentNonceState<NoncesV0>;
const newNonces: CurrentNonceState<Nonces>['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<ChainId, NonceData>;
}
newNonces[address][chainsIdByName[network as Network]] = nonceData;
}
}
return {
...oldState,
nonces: newNonces,
};
}
return persistedState as CurrentNonceState<Nonces>;
},
version: 2,
},
}
);
Expand Down

0 comments on commit ea06380

Please sign in to comment.