diff --git a/src/redux/migrations.test.ts b/src/redux/migrations.test.ts index d08f40a5101..9df5c58049d 100644 --- a/src/redux/migrations.test.ts +++ b/src/redux/migrations.test.ts @@ -55,6 +55,7 @@ import { v21Schema, v222Schema, v227Schema, + v228Schema, v28Schema, v2Schema, v35Schema, @@ -84,6 +85,7 @@ import { vNeg1Schema, } from 'test/schemas' import { + mockEarnDepositTransaction, mockInvitableRecipient, mockInvitableRecipient2, mockPositionsLegacy, @@ -1664,4 +1666,33 @@ describe('Redux persist migrations', () => { )) expect(migratedSchema).toStrictEqual(expectedSchema) }) + it('works from 228 to 229', () => { + const oldSchema = { + ...v228Schema, + transactions: { + ...v228Schema.transactions, + transactionsByNetworkId: { + ...v228Schema.transactions.transactionsByNetworkId, + [NetworkId['arbitrum-sepolia']]: [ + { ...mockEarnDepositTransaction, providerId: 'aave-v3' }, + ], + }, + standbyTransactions: [ + { + ...mockEarnDepositTransaction, + providerId: 'aave-v3', + status: TransactionStatus.Pending, + }, + ...v228Schema.transactions.standbyTransactions, + ], + }, + } + const migratedSchema = migrations[229](oldSchema) + const expectedSchema: any = _.cloneDeep(oldSchema) + expectedSchema.transactions.transactionsByNetworkId[ + NetworkId['arbitrum-sepolia'] + ][0].providerId = 'aave' + expectedSchema.transactions.standbyTransactions[0].providerId = 'aave' + expect(migratedSchema).toStrictEqual(expectedSchema) + }) }) diff --git a/src/redux/migrations.ts b/src/redux/migrations.ts index a5e1b632743..9bca232d53b 100644 --- a/src/redux/migrations.ts +++ b/src/redux/migrations.ts @@ -1877,4 +1877,28 @@ export const migrations = { 'mtwAddress' ), }), + 229: (state: any) => { + const transactionsByNetworkId: any = {} + for (const networkId of Object.keys(state.transactions.transactionsByNetworkId)) { + const transactions = [] + for (const tx of state.transactions.transactionsByNetworkId[networkId]) { + ;(networkId === NetworkId['arbitrum-one'] || networkId === NetworkId['arbitrum-sepolia']) && + tx.providerId && + tx.providerId === 'aave-v3' + ? transactions.push({ ...tx, providerId: 'aave' }) + : transactions.push(tx) + } + transactionsByNetworkId[networkId] = transactions + } + return { + ...state, + transactions: { + ...state.transactions, + transactionsByNetworkId, + standbyTransactions: state.transactions.standbyTransactions.map((tx: any) => { + return tx.providerId && tx.providerId === 'aave-v3' ? { ...tx, providerId: 'aave' } : tx + }), + }, + } + }, } diff --git a/src/redux/store.test.ts b/src/redux/store.test.ts index c353e2c25a7..3f62740dd9c 100644 --- a/src/redux/store.test.ts +++ b/src/redux/store.test.ts @@ -98,7 +98,7 @@ describe('store state', () => { { "_persist": { "rehydrated": true, - "version": 228, + "version": 229, }, "account": { "acceptedTerms": false, diff --git a/src/redux/store.ts b/src/redux/store.ts index c1b1a1dfd0f..ad2be010b80 100644 --- a/src/redux/store.ts +++ b/src/redux/store.ts @@ -21,7 +21,7 @@ const persistConfig: PersistConfig = { key: 'root', // default is -1, increment as we make migrations // See https://github.com/valora-inc/wallet/tree/main/WALLET.md#redux-state-migration - version: 228, + version: 229, keyPrefix: `reduxStore-`, // the redux-persist default is `persist:` which doesn't work with some file systems. storage: FSStorage(), blacklist: ['networkInfo', 'alert', 'imports', 'keylessBackup', 'jumpstart'], diff --git a/test/schemas.ts b/test/schemas.ts index bca129318b4..5bbe87e934b 100644 --- a/test/schemas.ts +++ b/test/schemas.ts @@ -3495,6 +3495,14 @@ export const v228Schema = { ), } +export const v229Schema = { + ...v228Schema, + _persist: { + ...v228Schema._persist, + version: 229, + }, +} + export function getLatestSchema(): Partial { - return v228Schema as Partial + return v229Schema as Partial }