Skip to content

Commit 28cd56e

Browse files
chore(suite): add migration for deprecated coins
1 parent 28f54f4 commit 28cd56e

File tree

1 file changed

+54
-0
lines changed
  • packages/suite/src/storage/migrations

1 file changed

+54
-0
lines changed

packages/suite/src/storage/migrations/index.ts

+54
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export const migrate: OnUpgradeFunc<SuiteDBSchema> = async (
270270

271271
if (oldVersion < 26) {
272272
await updateAll(transaction, 'accounts', account => {
273+
// @ts-expect-error
273274
if (account.symbol === 'vtc' && account.accountType === 'normal') {
274275
// change account type from normal to segwit
275276
account.accountType = 'segwit';
@@ -280,6 +281,7 @@ export const migrate: OnUpgradeFunc<SuiteDBSchema> = async (
280281

281282
await updateAll(transaction, 'discovery', d => {
282283
// reset discovery
284+
// @ts-expect-error
283285
if (d.networks.includes('vtc')) {
284286
d.index = 0;
285287
d.loaded = 0;
@@ -1176,4 +1178,56 @@ export const migrate: OnUpgradeFunc<SuiteDBSchema> = async (
11761178
return account;
11771179
});
11781180
}
1181+
1182+
// Deprecate Vertcoin (VTC) and other networks
1183+
if (oldVersion < 52) {
1184+
const deprecatedNetworks = ['vtc', 'btg', 'nmc', 'dgb', 'dash'];
1185+
1186+
// Remove transactions related to deprecated networks
1187+
await updateAll(transaction, 'txs', tx => {
1188+
if (deprecatedNetworks.includes(tx.tx.symbol)) {
1189+
return null; // Delete transaction
1190+
}
1191+
1192+
return tx;
1193+
});
1194+
1195+
// Remove accounts related to deprecated networks
1196+
await updateAll(transaction, 'accounts', account => {
1197+
if (deprecatedNetworks.includes(account.symbol)) {
1198+
return null; // Delete account
1199+
}
1200+
1201+
return account;
1202+
});
1203+
1204+
// Remove deprecated networks from enabled networks in wallet settings
1205+
await updateAll(transaction, 'walletSettings', walletSettings => {
1206+
walletSettings.enabledNetworks = walletSettings.enabledNetworks.filter(
1207+
network => !deprecatedNetworks.includes(network), // Exclude deprecated networks from enabled networks
1208+
);
1209+
1210+
return walletSettings;
1211+
});
1212+
1213+
// Remove deprecated networks from discovery networks
1214+
await updateAll(transaction, 'discovery', discovery => {
1215+
discovery.networks = discovery.networks.filter(
1216+
network => !deprecatedNetworks.includes(network), // Exclude deprecated networks from discovery
1217+
);
1218+
discovery.failed = []; // Clear failed discovery attempts
1219+
1220+
return discovery;
1221+
});
1222+
1223+
// Remove deprecated networks from backend settings
1224+
const backendSettings = transaction.objectStore('backendSettings');
1225+
for (const network of deprecatedNetworks) {
1226+
await backendSettings.delete(network as NetworkSymbol); // Delete backend settings for each deprecated network
1227+
}
1228+
1229+
console.log(
1230+
'Deprecated networks (VTC, BTG, NMC, DGB, DASH) have been deprecated successfully.',
1231+
);
1232+
}
11791233
};

0 commit comments

Comments
 (0)