Skip to content

Commit

Permalink
chore(suite-native): add migration for suite-native
Browse files Browse the repository at this point in the history
  • Loading branch information
MiroslavProchazka committed Jan 9, 2025
1 parent 5e5dca4 commit 53e914c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions suite-native/storage/src/migrations/discovery/v3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { NetworkSymbol } from '@suite-common/wallet-config';
// @ts-expect-error
const deprecatedNetworks: NetworkSymbol[] = ['dash', 'btg', 'nmc', 'vtc', 'dgb'];

export const migrateDiscoveryDeprecateNetworks = (
oldEnabledDiscoveryNetworkSymbols: NetworkSymbol[],
): NetworkSymbol[] =>
oldEnabledDiscoveryNetworkSymbols.filter(
networkSymbol => !deprecatedNetworks.includes(networkSymbol),
);
11 changes: 11 additions & 0 deletions suite-native/storage/src/migrations/wallet/accounts/v3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type Account = {
symbol: string;
key: string;
};

const deprecatedNetworks: string[] = ['dash', 'btg', 'nmc', 'vtc', 'dgb'];

export const migrateAccountsDeprecateNetworks = (
oldAccounts: Account[] | undefined,
): Account[] | undefined =>
oldAccounts?.filter(account => !deprecatedNetworks.includes(account.symbol));
26 changes: 26 additions & 0 deletions suite-native/storage/src/migrations/wallet/transactions/v3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
type TransactionStub = {
symbol: string;
};

type AccountTransactionsType = {
[x: string]: TransactionStub[];
};

const deprecatedNetworks: string[] = ['dash', 'btg', 'nmc', 'vtc', 'dgb'];

export const migrateTransactionsDeprecateNetworks = (
oldTransactions: AccountTransactionsType | undefined,
): AccountTransactionsType | undefined => {
const newTransactions: AccountTransactionsType = {};

for (const oldKey in oldTransactions) {
const oldTxns = oldTransactions[oldKey];

const newTxns = oldTxns.filter(txn => !deprecatedNetworks.includes(txn.symbol));
if (newTxns.length > 0) {
newTransactions[oldKey] = newTxns;
}
}

return newTransactions;
};

0 comments on commit 53e914c

Please sign in to comment.