-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(suite-native): add migration for suite-native
- Loading branch information
1 parent
a9b0d18
commit 22960bc
Showing
3 changed files
with
47 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { NetworkSymbol } from '@suite-common/wallet-config'; | ||
|
||
const deprecatedNetworks: NetworkSymbol[] = ['dash', 'btg', 'nmc', 'vtc', 'dgb']; | ||
|
||
export const migrateDiscoveryDeprecateNetworks = ( | ||
oldEnabledDiscoveryNetworkSymbols: NetworkSymbol[], | ||
): NetworkSymbol[] => | ||
oldEnabledDiscoveryNetworkSymbols.filter( | ||
networkSymbol => !deprecatedNetworks.includes(networkSymbol), | ||
); |
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 |
---|---|---|
@@ -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
26
suite-native/storage/src/migrations/wallet/transactions/v3.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 |
---|---|---|
@@ -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; | ||
}; |