Skip to content

Commit

Permalink
feat: actualy migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Sep 27, 2024
1 parent baa4d53 commit 0419d91
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
24 changes: 12 additions & 12 deletions src/state/migrations/index.ts
Original file line number Diff line number Diff line change
@@ -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<MigrationManifest, '_persist'>

export const clearOpportunitiesMigrations = {
// Uncomment me when introducing the first migration for this slice
// 0: clearOpportunities,
0: clearOpportunities,
} as unknown as Omit<MigrationManifest, '_persist'>

export const clearPortfolioMigrations = {
// Uncomment me when introducing the first migration for this slice
// 0: clearPortfolio,
0: clearPortfolio,
} as unknown as Omit<MigrationManifest, '_persist'>

export const clearNftsMigrations = {
// Uncomment me when introducing the first migration for this slice
// 0: clearNfts,
0: clearNfts,
} as unknown as Omit<MigrationManifest, '_persist'>

export const clearAssetsMigrations = {
Expand All @@ -28,11 +30,9 @@ export const clearAssetsMigrations = {
} as unknown as Omit<MigrationManifest, '_persist'>

export const clearMarketDataMigrations = {
// Uncomment me when introducing the first migration for this slice
// 0: clearMarketData,
0: clearMarketData,
} as unknown as Omit<MigrationManifest, '_persist'>

export const clearSnapshotMigrations = {
// Uncomment me when introducing the first migration for this slice
// 0: clearSnapshot,
0: clearSnapshot,
} as unknown as Omit<MigrationManifest, '_persist'>
46 changes: 20 additions & 26 deletions src/state/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit 0419d91

Please sign in to comment.