From d9f9dc00bd8bc397541d7c0c7cdf9daf163c9069 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Thu, 26 Sep 2024 23:16:20 +0200 Subject: [PATCH 1/4] fix: redux-persist error spew --- src/state/reducer.ts | 47 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/state/reducer.ts b/src/state/reducer.ts index 49b785d8728..f9947d15873 100644 --- a/src/state/reducer.ts +++ b/src/state/reducer.ts @@ -13,15 +13,7 @@ import type { SnapshotState } from './apis/snapshot/snapshot' import { snapshot, snapshotApi } from './apis/snapshot/snapshot' import { swapperApi } from './apis/swapper/swapperApi' import { zapper, zapperApi } from './apis/zapper/zapperApi' -import { - clearAssetsMigrations, - clearMarketDataMigrations, - clearNftsMigrations, - clearOpportunitiesMigrations, - clearPortfolioMigrations, - clearSnapshotMigrations, - clearTxHistoryMigrations, -} from './migrations' +import { clearAssetsMigrations } from './migrations' import type { AssetsState } from './slices/assetsSlice/assetsSlice' import { assetApi, assets } from './slices/assetsSlice/assetsSlice' import type { LocalWalletState } from './slices/localWalletSlice/localWalletSlice' @@ -62,49 +54,62 @@ const preferencesPersistConfig = { const txHistoryPersistConfig = { key: 'txHistory', storage: localforage, - version: Math.max(...Object.keys(clearTxHistoryMigrations).map(Number)), - migrate: createMigrate(clearTxHistoryMigrations, { debug: false }), + version: 0, + // Uncomment me when introducing the first migration for this slice + // version: Math.max(...Object.keys(clearTxHistoryMigrations).map(Number)), + // migrate: createMigrate(clearTxHistoryMigrations, { debug: false }), } const portfolioPersistConfig = { key: 'portfolio', storage: localforage, - version: Math.max(...Object.keys(clearPortfolioMigrations).map(Number)), - migrate: createMigrate(clearPortfolioMigrations, { debug: false }), + version: 0, + // Uncomment me when introducing the first migration for this slice + // version: Math.max(...Object.keys(clearPortfolioMigrations).map(Number)), + // migrate: createMigrate(clearPortfolioMigrations, { debug: false }), } const opportunitiesPersistConfig = { key: 'opportunities', storage: localforage, - version: Math.max(...Object.keys(clearOpportunitiesMigrations).map(Number)), - migrate: createMigrate(clearOpportunitiesMigrations, { debug: false }), + version: 0, + // Uncomment me when introducing the first migration for this slice + // version: Math.max(...Object.keys(clearOpportunitiesMigrations).map(Number)), + // migrate: createMigrate(clearOpportunitiesMigrations, { debug: false }), } const nftPersistConfig = { key: 'nft', storage: localforage, - version: Math.max(...Object.keys(clearNftsMigrations).map(Number)), - migrate: createMigrate(clearNftsMigrations, { debug: false }), + version: 0, + // Uncomment me when introducing the first migration for this slice + // version: Math.max(...Object.keys(clearNftsMigrations).map(Number)), + // migrate: createMigrate(clearNftsMigrations, { debug: false }), } const snapshotPersistConfig = { key: 'snapshot', storage: localforage, - version: Math.max(...Object.keys(clearSnapshotMigrations).map(Number)), - migrate: createMigrate(clearSnapshotMigrations, { debug: false }), + version: 0, + // Uncomment me when introducing the first migration for this slice + // version: Math.max(...Object.keys(clearSnapshotMigrations).map(Number)), + // migrate: createMigrate(clearSnapshotMigrations, { debug: false }), } const localWalletSlicePersistConfig = { key: 'localWalletSlice', storage: localforage, + version: 0, // no migrations for localWalletSlice yet - stay tuned! } const marketDataPersistConfig = { key: 'marketData', storage: localforage, - version: Math.max(...Object.keys(clearMarketDataMigrations).map(Number)), - migrate: createMigrate(clearMarketDataMigrations, { debug: false }), + version: 0, + // Uncomment me when introducing the first migration for this slice + // version: Math.max(...Object.keys(clearMarketDataMigrations).map(Number)), + // migrate: createMigrate(clearMarketDataMigrations, { debug: false }), } const assetsPersistConfig = { From baa4d53a36e75190a705bd0f6e40f9baabd46384 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Fri, 27 Sep 2024 09:28:00 +0200 Subject: [PATCH 2/4] fix: tests --- src/state/slices/opportunitiesSlice/opportunitiesSlice.test.ts | 2 +- src/state/slices/txHistorySlice/txHistorySlice.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/state/slices/opportunitiesSlice/opportunitiesSlice.test.ts b/src/state/slices/opportunitiesSlice/opportunitiesSlice.test.ts index 3ee7b5c5494..6364a81e0ba 100644 --- a/src/state/slices/opportunitiesSlice/opportunitiesSlice.test.ts +++ b/src/state/slices/opportunitiesSlice/opportunitiesSlice.test.ts @@ -25,7 +25,7 @@ describe('opportunitiesSlice', () => { ...initialState, _persist: { rehydrated: true, - version: -Infinity, + version: 0, }, }) }) diff --git a/src/state/slices/txHistorySlice/txHistorySlice.test.ts b/src/state/slices/txHistorySlice/txHistorySlice.test.ts index 38828843f25..536ea974314 100644 --- a/src/state/slices/txHistorySlice/txHistorySlice.test.ts +++ b/src/state/slices/txHistorySlice/txHistorySlice.test.ts @@ -20,7 +20,7 @@ describe('txHistorySlice', () => { expect(store.getState().txHistory).toEqual({ _persist: { rehydrated: true, - version: -Infinity, + version: 0, }, hydrationMeta: {}, txs: { From 0419d91f575db80b665e44c3a3f6b66077b048b1 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:44:00 +0200 Subject: [PATCH 3/4] feat: actualy migrate --- src/state/migrations/index.ts | 24 +++++++++--------- src/state/reducer.ts | 46 +++++++++++++++-------------------- 2 files changed, 32 insertions(+), 38 deletions(-) diff --git a/src/state/migrations/index.ts b/src/state/migrations/index.ts index 50085e245ec..8a862ee33ec 100644 --- a/src/state/migrations/index.ts +++ b/src/state/migrations/index.ts @@ -1,25 +1,27 @@ import type { MigrationManifest } from 'redux-persist' import { clearAssets } from './clearAssets' +import { clearMarketData } from './clearMarketData' +import { clearNfts } from './clearNfts' +import { clearOpportunities } from './clearOpportunities' +import { clearPortfolio } from './clearPortfolio' +import { clearSnapshot } from './clearSnapshot' +import { clearTxHistory } from './clearTxHistory' export const clearTxHistoryMigrations = { - // Uncomment me when introducing the first migration for this slice - // 0: clearTxHistory, + 0: clearTxHistory, } as unknown as Omit export const clearOpportunitiesMigrations = { - // Uncomment me when introducing the first migration for this slice - // 0: clearOpportunities, + 0: clearOpportunities, } as unknown as Omit export const clearPortfolioMigrations = { - // Uncomment me when introducing the first migration for this slice - // 0: clearPortfolio, + 0: clearPortfolio, } as unknown as Omit export const clearNftsMigrations = { - // Uncomment me when introducing the first migration for this slice - // 0: clearNfts, + 0: clearNfts, } as unknown as Omit export const clearAssetsMigrations = { @@ -28,11 +30,9 @@ export const clearAssetsMigrations = { } as unknown as Omit export const clearMarketDataMigrations = { - // Uncomment me when introducing the first migration for this slice - // 0: clearMarketData, + 0: clearMarketData, } as unknown as Omit export const clearSnapshotMigrations = { - // Uncomment me when introducing the first migration for this slice - // 0: clearSnapshot, + 0: clearSnapshot, } as unknown as Omit diff --git a/src/state/reducer.ts b/src/state/reducer.ts index f9947d15873..67126780f2d 100644 --- a/src/state/reducer.ts +++ b/src/state/reducer.ts @@ -13,7 +13,15 @@ import type { SnapshotState } from './apis/snapshot/snapshot' import { snapshot, snapshotApi } from './apis/snapshot/snapshot' import { swapperApi } from './apis/swapper/swapperApi' import { zapper, zapperApi } from './apis/zapper/zapperApi' -import { clearAssetsMigrations } from './migrations' +import { + clearAssetsMigrations, + clearMarketDataMigrations, + clearNftsMigrations, + clearOpportunitiesMigrations, + clearPortfolioMigrations, + clearSnapshotMigrations, + clearTxHistoryMigrations, +} from './migrations' import type { AssetsState } from './slices/assetsSlice/assetsSlice' import { assetApi, assets } from './slices/assetsSlice/assetsSlice' import type { LocalWalletState } from './slices/localWalletSlice/localWalletSlice' @@ -54,62 +62,48 @@ const preferencesPersistConfig = { const txHistoryPersistConfig = { key: 'txHistory', storage: localforage, - version: 0, - // Uncomment me when introducing the first migration for this slice - // version: Math.max(...Object.keys(clearTxHistoryMigrations).map(Number)), - // migrate: createMigrate(clearTxHistoryMigrations, { debug: false }), + version: Math.max(...Object.keys(clearTxHistoryMigrations).map(Number)), + migrate: createMigrate(clearTxHistoryMigrations, { debug: false }), } const portfolioPersistConfig = { key: 'portfolio', storage: localforage, - version: 0, - // Uncomment me when introducing the first migration for this slice - // version: Math.max(...Object.keys(clearPortfolioMigrations).map(Number)), - // migrate: createMigrate(clearPortfolioMigrations, { debug: false }), + version: Math.max(...Object.keys(clearPortfolioMigrations).map(Number)), + migrate: createMigrate(clearPortfolioMigrations, { debug: false }), } const opportunitiesPersistConfig = { key: 'opportunities', storage: localforage, - version: 0, - // Uncomment me when introducing the first migration for this slice - // version: Math.max(...Object.keys(clearOpportunitiesMigrations).map(Number)), - // migrate: createMigrate(clearOpportunitiesMigrations, { debug: false }), + version: Math.max(...Object.keys(clearOpportunitiesMigrations).map(Number)), } const nftPersistConfig = { key: 'nft', storage: localforage, - version: 0, - // Uncomment me when introducing the first migration for this slice - // version: Math.max(...Object.keys(clearNftsMigrations).map(Number)), - // migrate: createMigrate(clearNftsMigrations, { debug: false }), + version: Math.max(...Object.keys(clearNftsMigrations).map(Number)), + migrate: createMigrate(clearNftsMigrations, { debug: false }), } const snapshotPersistConfig = { key: 'snapshot', storage: localforage, - version: 0, - // Uncomment me when introducing the first migration for this slice - // version: Math.max(...Object.keys(clearSnapshotMigrations).map(Number)), - // migrate: createMigrate(clearSnapshotMigrations, { debug: false }), + version: Math.max(...Object.keys(clearSnapshotMigrations).map(Number)), + migrate: createMigrate(clearSnapshotMigrations, { debug: false }), } const localWalletSlicePersistConfig = { key: 'localWalletSlice', storage: localforage, - version: 0, // no migrations for localWalletSlice yet - stay tuned! } const marketDataPersistConfig = { key: 'marketData', storage: localforage, - version: 0, - // Uncomment me when introducing the first migration for this slice - // version: Math.max(...Object.keys(clearMarketDataMigrations).map(Number)), - // migrate: createMigrate(clearMarketDataMigrations, { debug: false }), + version: Math.max(...Object.keys(clearMarketDataMigrations).map(Number)), + migrate: createMigrate(clearMarketDataMigrations, { debug: false }), } const assetsPersistConfig = { From 84ee140c0f937e79b18dd640ab71359461643719 Mon Sep 17 00:00:00 2001 From: gomes <17035424+gomesalexandre@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:04:48 +0200 Subject: [PATCH 4/4] fix: derp --- src/state/reducer.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/state/reducer.ts b/src/state/reducer.ts index 67126780f2d..49b785d8728 100644 --- a/src/state/reducer.ts +++ b/src/state/reducer.ts @@ -77,6 +77,7 @@ const opportunitiesPersistConfig = { key: 'opportunities', storage: localforage, version: Math.max(...Object.keys(clearOpportunitiesMigrations).map(Number)), + migrate: createMigrate(clearOpportunitiesMigrations, { debug: false }), } const nftPersistConfig = {