-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01160d0
commit 674f4dc
Showing
9 changed files
with
36 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,7 @@ | ||
import type { ReduxState } from 'state/reducer' | ||
import type { PersistPartial } from 'redux-persist/es/persistReducer' | ||
import type { AssetsState } from 'state/slices/assetsSlice/assetsSlice' | ||
import { initialState } from 'state/slices/assetsSlice/assetsSlice' | ||
|
||
export const clearAssets = (state: ReduxState): ReduxState => { | ||
return { | ||
...state, | ||
assets: initialState, | ||
// This is very ugly but also very correct | ||
// Typically, to achieve this, we would dispatch nftapi.util.resetApiState as a side effect | ||
// But we can't do this here because circular deps, so we have to do it manually | ||
// https://redux-toolkit.js.org/rtk-query/api/created-api/api-slice-utils#resetapistate | ||
assetApi: { | ||
queries: {}, | ||
mutations: {}, | ||
provided: {}, | ||
subscriptions: {}, | ||
config: { | ||
online: true, | ||
focused: true, | ||
middlewareRegistered: true, | ||
refetchOnFocus: false, | ||
refetchOnReconnect: true, | ||
refetchOnMountOrArgChange: false, | ||
keepUnusedDataFor: 60, | ||
reducerPath: 'assetApi', | ||
}, | ||
}, | ||
} | ||
export const clearAssets = (_state: AssetsState): AssetsState & PersistPartial => { | ||
return initialState as AssetsState & PersistPartial | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
import type { ReduxState } from 'state/reducer' | ||
import type { PersistPartial } from 'redux-persist/es/persistReducer' | ||
import { initialState } from 'state/slices/marketDataSlice/marketDataSlice' | ||
import type { MarketDataState } from 'state/slices/marketDataSlice/types' | ||
|
||
export const clearMarketData = (state: ReduxState): ReduxState => { | ||
export const clearMarketData = (_state: MarketDataState): MarketDataState & PersistPartial => { | ||
// Migration to clear marketData state | ||
return { | ||
...state, | ||
marketData: initialState, | ||
} | ||
return initialState as MarketDataState & PersistPartial | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,7 @@ | ||
import type { PersistPartial } from 'redux-persist/es/persistReducer' | ||
import type { NftState } from 'state/apis/nft/nftApi' | ||
import { initialState } from 'state/apis/nft/nftApi' | ||
import type { ReduxState } from 'state/reducer' | ||
|
||
export const clearNfts = (state: ReduxState): ReduxState => { | ||
return { | ||
...state, | ||
nft: initialState as NftState & PersistPartial, | ||
// This is very ugly but also very correct | ||
// Typically, to achieve this, we would dispatch nftapi.util.resetApiState as a side effect | ||
// But we can't do this here because circular deps, so we have to do it manually | ||
// https://redux-toolkit.js.org/rtk-query/api/created-api/api-slice-utils#resetapistate | ||
nftApi: { | ||
queries: {}, | ||
mutations: {}, | ||
provided: {}, | ||
subscriptions: {}, | ||
config: { | ||
online: true, | ||
focused: false, | ||
middlewareRegistered: true, | ||
refetchOnFocus: false, | ||
refetchOnReconnect: true, | ||
refetchOnMountOrArgChange: false, | ||
keepUnusedDataFor: 60, | ||
reducerPath: 'nftApi', | ||
}, | ||
}, | ||
} | ||
export const clearNfts = (_state: NftState): NftState & PersistPartial => { | ||
return initialState as NftState & PersistPartial | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
import type { PersistPartial } from 'redux-persist/es/persistReducer' | ||
import type { ReduxState } from 'state/reducer' | ||
import type { OpportunitiesState } from 'state/slices/opportunitiesSlice/types' | ||
|
||
import { initialState } from '../slices/opportunitiesSlice/opportunitiesSlice' | ||
|
||
export const clearOpportunities = (state: ReduxState): ReduxState => { | ||
export const clearOpportunities = ( | ||
_state: OpportunitiesState, | ||
): OpportunitiesState & PersistPartial => { | ||
// Migration to clear opportunitiesApi and opportunitiesApi state | ||
return { | ||
...state, | ||
opportunities: initialState as OpportunitiesState & PersistPartial, | ||
} | ||
return initialState as OpportunitiesState & PersistPartial | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,7 @@ | ||
import type { PersistPartial } from 'redux-persist/es/persistReducer' | ||
import type { ReduxState } from 'state/reducer' | ||
import type { Portfolio } from 'state/slices/portfolioSlice/portfolioSliceCommon' | ||
import { initialState } from 'state/slices/portfolioSlice/portfolioSliceCommon' | ||
|
||
export const clearPortfolio = (state: ReduxState): ReduxState => { | ||
return { | ||
...state, | ||
portfolio: initialState as Portfolio & PersistPartial, | ||
// This is very ugly but also very correct | ||
// Typically, to achieve this, we would dispatch nftapi.util.resetApiState as a side effect | ||
// But we can't do this here because circular deps, so we have to do it manually | ||
// https://redux-toolkit.js.org/rtk-query/api/created-api/api-slice-utils#resetapistate | ||
portfolioApi: { | ||
queries: {}, | ||
mutations: {}, | ||
provided: {}, | ||
subscriptions: {}, | ||
config: { | ||
online: true, | ||
focused: true, | ||
middlewareRegistered: true, | ||
refetchOnFocus: false, | ||
refetchOnReconnect: true, | ||
refetchOnMountOrArgChange: false, | ||
keepUnusedDataFor: 60, | ||
reducerPath: 'portfolioApi', | ||
}, | ||
}, | ||
} | ||
export const clearPortfolio = (_state: Portfolio): Portfolio & PersistPartial => { | ||
return initialState as Portfolio & PersistPartial | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
import type { PersistPartial } from 'redux-persist/es/persistReducer' | ||
import type { SnapshotState } from 'state/apis/snapshot/snapshot' | ||
import { initialState } from 'state/apis/snapshot/snapshot' | ||
import type { ReduxState } from 'state/reducer' | ||
|
||
export const clearSnapshot = (state: ReduxState): ReduxState => { | ||
export const clearSnapshot = (_state: SnapshotState): SnapshotState & PersistPartial => { | ||
// Migration to clear snapshot API | ||
return { | ||
...state, | ||
snapshot: initialState as SnapshotState & PersistPartial, | ||
} | ||
return initialState as SnapshotState & PersistPartial | ||
} |
22 changes: 10 additions & 12 deletions
22
src/state/migrations/clearWalletConnectWalletsMetadata.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import type { ReduxState } from 'state/reducer' | ||
import type { PersistPartial } from 'redux-persist/es/persistReducer' | ||
import type { Portfolio } from 'state/slices/portfolioSlice/portfolioSliceCommon' | ||
|
||
export const clearWalletConnectWalletsMetadata = (state: ReduxState): ReduxState => { | ||
const updatedWalletIds = state.portfolio.wallet.ids.filter(id => !id.startsWith('wc:')) | ||
export const clearWalletConnectWalletsMetadata = (state: Portfolio): Portfolio & PersistPartial => { | ||
const updatedWalletIds = state.wallet.ids.filter(id => !id.startsWith('wc:')) | ||
const updatedWalletById = Object.fromEntries( | ||
Object.entries(state.portfolio.wallet.byId).filter(([walletId]) => !walletId.startsWith('wc:')), | ||
Object.entries(state.wallet.byId).filter(([walletId]) => !walletId.startsWith('wc:')), | ||
) | ||
|
||
return { | ||
...state, | ||
portfolio: { | ||
...state.portfolio, | ||
wallet: { | ||
...state.portfolio.wallet, | ||
ids: updatedWalletIds, | ||
byId: updatedWalletById, | ||
}, | ||
wallet: { | ||
...state.wallet, | ||
ids: updatedWalletIds, | ||
byId: updatedWalletById, | ||
}, | ||
} | ||
} as Portfolio & PersistPartial | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters