From 2227a382766b61b8616e3aef1c791f31b457a57a Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Mon, 13 Nov 2023 14:21:50 -0800 Subject: [PATCH] fix: set current redux version to 3 (#7578) * fix: set current redux version to 3 * fix: tests --- src/state/migrations.test.ts | 2 +- src/state/migrations.ts | 2 ++ src/state/migrations/3.ts | 4 ++-- src/state/reducer.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/state/migrations.test.ts b/src/state/migrations.test.ts index 56b9b8fbb3..55470d5b28 100644 --- a/src/state/migrations.test.ts +++ b/src/state/migrations.test.ts @@ -13,7 +13,7 @@ const defaultState = { user: {}, _persist: { rehydrated: true, - version: 2, + version: 3, }, application: { chainId: null, diff --git a/src/state/migrations.ts b/src/state/migrations.ts index 6bb84163f7..7815412818 100644 --- a/src/state/migrations.ts +++ b/src/state/migrations.ts @@ -4,6 +4,7 @@ import { MigrationConfig } from 'redux-persist/es/createMigrate' import { migration0 } from './migrations/0' import { migration1 } from './migrations/1' import { migration2 } from './migrations/2' +import { migration3 } from './migrations/3' import { legacyLocalStorageMigration } from './migrations/legacy' /** @@ -19,6 +20,7 @@ export const migrations: MigrationManifest = { 0: migration0, 1: migration1, 2: migration2, + 3: migration3, } // We use a custom migration function for the initial state, because redux-persist diff --git a/src/state/migrations/3.ts b/src/state/migrations/3.ts index 2ce89bca0d..51397d91c2 100644 --- a/src/state/migrations/3.ts +++ b/src/state/migrations/3.ts @@ -26,7 +26,7 @@ export const migration3 = (state: PersistAppStateV3 | undefined) => { } for (const [chainId, address] of Object.entries(USDCe_ADDRESSES)) { const chainIdKey = Number(chainId) as ChainId - if (state.user.tokens[chainIdKey]?.[address]) { + if (state.user.tokens?.[chainIdKey]?.[address]) { state.user.tokens[chainIdKey][address] = serializeToken( new Token(chainIdKey, address, 6, 'USDC.e', 'Bridged USDC') ) @@ -40,7 +40,7 @@ export const migration3 = (state: PersistAppStateV3 | undefined) => { 'USDbC', 'USD Base Coin' ) - if (state.user.tokens[ChainId.BASE]?.[USDbC_BASE.address]) { + if (state.user.tokens?.[ChainId.BASE]?.[USDbC_BASE.address]) { state.user.tokens[ChainId.BASE][USDbC_BASE.address] = serializeToken(USDbC_BASE) } return { diff --git a/src/state/reducer.ts b/src/state/reducer.ts index 642aaeea19..5cf65cf015 100644 --- a/src/state/reducer.ts +++ b/src/state/reducer.ts @@ -44,7 +44,7 @@ export type AppState = ReturnType const persistConfig: PersistConfig = { key: 'interface', - version: 2, // see migrations.ts for more details about this version + version: 3, // see migrations.ts for more details about this version storage: localForage.createInstance({ name: 'redux', }),