fix: set current redux version to 3 (#7578)

* fix: set current redux version to 3

* fix: tests
This commit is contained in:
eddie 2023-11-13 14:21:50 -08:00 committed by GitHub
parent 9f06747958
commit 2227a38276
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

@ -13,7 +13,7 @@ const defaultState = {
user: {}, user: {},
_persist: { _persist: {
rehydrated: true, rehydrated: true,
version: 2, version: 3,
}, },
application: { application: {
chainId: null, chainId: null,

@ -4,6 +4,7 @@ import { MigrationConfig } from 'redux-persist/es/createMigrate'
import { migration0 } from './migrations/0' import { migration0 } from './migrations/0'
import { migration1 } from './migrations/1' import { migration1 } from './migrations/1'
import { migration2 } from './migrations/2' import { migration2 } from './migrations/2'
import { migration3 } from './migrations/3'
import { legacyLocalStorageMigration } from './migrations/legacy' import { legacyLocalStorageMigration } from './migrations/legacy'
/** /**
@ -19,6 +20,7 @@ export const migrations: MigrationManifest = {
0: migration0, 0: migration0,
1: migration1, 1: migration1,
2: migration2, 2: migration2,
3: migration3,
} }
// We use a custom migration function for the initial state, because redux-persist // We use a custom migration function for the initial state, because redux-persist

@ -26,7 +26,7 @@ export const migration3 = (state: PersistAppStateV3 | undefined) => {
} }
for (const [chainId, address] of Object.entries(USDCe_ADDRESSES)) { for (const [chainId, address] of Object.entries(USDCe_ADDRESSES)) {
const chainIdKey = Number(chainId) as ChainId const chainIdKey = Number(chainId) as ChainId
if (state.user.tokens[chainIdKey]?.[address]) { if (state.user.tokens?.[chainIdKey]?.[address]) {
state.user.tokens[chainIdKey][address] = serializeToken( state.user.tokens[chainIdKey][address] = serializeToken(
new Token(chainIdKey, address, 6, 'USDC.e', 'Bridged USDC') new Token(chainIdKey, address, 6, 'USDC.e', 'Bridged USDC')
) )
@ -40,7 +40,7 @@ export const migration3 = (state: PersistAppStateV3 | undefined) => {
'USDbC', 'USDbC',
'USD Base Coin' '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) state.user.tokens[ChainId.BASE][USDbC_BASE.address] = serializeToken(USDbC_BASE)
} }
return { return {

@ -44,7 +44,7 @@ export type AppState = ReturnType<typeof appReducer>
const persistConfig: PersistConfig<AppState> = { const persistConfig: PersistConfig<AppState> = {
key: 'interface', 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({ storage: localForage.createInstance({
name: 'redux', name: 'redux',
}), }),