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: {},
_persist: {
rehydrated: true,
version: 2,
version: 3,
},
application: {
chainId: null,

@ -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

@ -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 {

@ -44,7 +44,7 @@ export type AppState = ReturnType<typeof appReducer>
const persistConfig: PersistConfig<AppState> = {
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',
}),