Skip to content

Commit

Permalink
Fix: setNonce only when nonce is greater than currentNonce now that a…
Browse files Browse the repository at this point in the history
…ddNewtx and updateTxn have been consolidated and a gapped nonce can be picked up
  • Loading branch information
jinchung committed Dec 2, 2024
1 parent 7926efb commit 3e97e65
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/state/pendingTransactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,18 @@ export const addNewTransaction = ({
transaction: NewTransaction;
}) => {
const { addPendingTransaction } = pendingTransactionsStore.getState();
const { setNonce } = nonceStore.getState();
const { getNonce, setNonce } = nonceStore.getState();
const parsedTransaction = convertNewTransactionToRainbowTransaction(transaction);
addPendingTransaction({ address, pendingTransaction: parsedTransaction });
setNonce({
address,
chainId,
currentNonce: transaction.nonce,
});
const localNonceData = getNonce({ address, chainId });
const localNonce = localNonceData?.currentNonce || 0;
if (transaction.nonce > localNonce) {
setNonce({
address,
chainId,
currentNonce: transaction.nonce,
});
}
};

export const updateTransaction = ({
Expand Down

0 comments on commit 3e97e65

Please sign in to comment.