diff --git a/src/entities/nonce.ts b/src/entities/nonce.ts index 1eaf28bf28f..8e48c0c5c03 100644 --- a/src/entities/nonce.ts +++ b/src/entities/nonce.ts @@ -5,7 +5,7 @@ interface NetworkNonceInfo { nonce: number; } -type AccountNonceInfo = Record; +type AccountNonceInfo = Partial>; export interface NonceManager { [key: EthereumAddress]: AccountNonceInfo; diff --git a/src/redux/nonceManager.ts b/src/redux/nonceManager.ts index 715acd83451..84930984710 100644 --- a/src/redux/nonceManager.ts +++ b/src/redux/nonceManager.ts @@ -88,7 +88,25 @@ export const updateNonce = ( saveNonceManager(updatedNonceManager); } }; +export const resetNonces = (accountAddress: EthereumAddress) => async ( + dispatch: AppDispatch, + getState: AppGetState +) => { + const { nonceManager: currentNonceData } = getState(); + + const currentAccountAddress = accountAddress.toLowerCase(); + const updatedNonceManager: NonceManager = { + ...currentNonceData, + [currentAccountAddress]: {}, + }; + + dispatch({ + payload: updatedNonceManager, + type: NONCE_MANAGER_UPDATE_NONCE, + }); + saveNonceManager(updatedNonceManager); +}; // -- Reducer ----------------------------------------- // const INITIAL_STATE: NonceManager = {}; diff --git a/src/screens/SettingsSheet/components/DevSection.tsx b/src/screens/SettingsSheet/components/DevSection.tsx index b83aca5df21..fbb1a559f71 100644 --- a/src/screens/SettingsSheet/components/DevSection.tsx +++ b/src/screens/SettingsSheet/components/DevSection.tsx @@ -57,6 +57,7 @@ import { isAuthenticated } from '@/utils/authentication'; import { DATA_UPDATE_PENDING_TRANSACTIONS_SUCCESS } from '@/redux/data'; import { saveLocalPendingTransactions } from '@/handlers/localstorage/accountLocal'; import { getFCMToken } from '@/notifications/tokens'; +import { resetNonces } from '@/redux/nonceManager'; const DevSection = () => { const { navigate } = useNavigation(); @@ -213,12 +214,14 @@ const DevSection = () => { const clearPendingTransactions = async () => { // clear local storage saveLocalPendingTransactions([], accountAddress, Network.mainnet); - // clear redux dispatch({ payload: [], type: DATA_UPDATE_PENDING_TRANSACTIONS_SUCCESS, }); + + // reset nonces + resetNonces(accountAddress); }; const clearLocalStorage = async () => {