Skip to content

Commit

Permalink
fix: add migration to avoid errors thrown because of storage and slic…
Browse files Browse the repository at this point in the history
…e value mismatch (#68)
  • Loading branch information
Polybius93 authored Apr 2, 2024
1 parent 9d678e8 commit 7f08871
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/hooks/use-ethereum-observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export function useEthereumObserver(): void {
});

protocolContract.on('SetStatusFunded', async (...args: any[]) => {
console.log('SetStatusFunded', args);
const vaultOwner = args[2];

if (vaultOwner.toLowerCase() !== address) return;
Expand Down
24 changes: 24 additions & 0 deletions src/app/store/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-nocheck
import { EthereumNetworkID } from '@models/ethereum-network';
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import { accountSlice, initialAccountState } from '@store/slices/account/account.slice';
import { modalSlice } from '@store/slices/modal/modal.slice';
import { vaultSlice } from '@store/slices/vault/vault.slice';
import {
FLUSH,
MigrationManifest,
PAUSE,
PERSIST,
PURGE,
Expand All @@ -14,6 +18,8 @@ import {
persistStore,
} from 'redux-persist';
import expireReducer from 'redux-persist-expire';
import createMigrate from 'redux-persist/es/createMigrate';
import autoMergeLevel2 from 'redux-persist/es/stateReconciler/autoMergeLevel2';
import storage from 'redux-persist/lib/storage';

import { mintUnmintSlice } from './slices/mintunmint/mintunmint.slice';
Expand All @@ -32,9 +38,27 @@ const rootReducer = combineReducers({
mintunmint: mintUnmintSlice.reducer,
});

const migrations: MigrationManifest = {
1: state => {
return {
...state,
vault: {
...state.vault,
vaults: {
...state.vault.vaults,
[EthereumNetworkID.ArbSepolia]: [],
},
},
};
},
};

const persistConfig: PersistConfig<RootState> = {
key: 'root',
version: 1,
storage: storage,
migrate: createMigrate(migrations),
stateReconciler: autoMergeLevel2,
whitelist: ['account', 'vault'],
transforms: [
expireReducer('account', {
Expand Down

0 comments on commit 7f08871

Please sign in to comment.