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] 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 = {