@subwallet/extension-base 1.0.4-0 → 1.0.4-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +25 -15
- package/background/KoniTypes.js +1 -0
- package/cjs/background/KoniTypes.js +1 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +9 -2
- package/cjs/koni/api/staking/bonding/astar.js +9 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +10 -2
- package/cjs/koni/api/staking/bonding/relayChain.js +21 -4
- package/cjs/koni/background/handlers/Extension.js +61 -19
- package/cjs/koni/background/handlers/State.js +12 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +1 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +1 -1
- package/cjs/services/chain-service/index.js +75 -26
- package/cjs/services/keyring-service/index.js +9 -0
- package/cjs/services/migration-service/index.js +7 -4
- package/cjs/services/migration-service/scripts/MigrateAuthUrls.js +39 -0
- package/cjs/services/migration-service/scripts/index.js +3 -1
- package/cjs/services/price-service/index.js +0 -1
- package/cjs/services/request-service/handler/AuthRequestHandler.js +7 -0
- package/cjs/services/request-service/handler/EvmRequestHandler.js +21 -0
- package/cjs/services/request-service/handler/MetadataRequestHandler.js +6 -0
- package/cjs/services/request-service/handler/SubstrateRequestHandler.js +6 -0
- package/cjs/services/request-service/index.js +6 -0
- package/cjs/services/setting-service/SettingService.js +4 -9
- package/cjs/services/setting-service/constants.js +12 -2
- package/cjs/services/storage-service/DatabaseService.js +14 -0
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStore.js +3 -0
- package/cjs/services/transaction-service/index.js +3 -0
- package/koni/api/staking/bonding/amplitude.js +9 -2
- package/koni/api/staking/bonding/astar.js +9 -1
- package/koni/api/staking/bonding/paraChain.js +10 -2
- package/koni/api/staking/bonding/relayChain.js +21 -4
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +42 -1
- package/koni/background/handlers/State.d.ts +1 -0
- package/koni/background/handlers/State.js +12 -0
- package/package.json +16 -11
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.js +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +1 -1
- package/services/chain-service/index.d.ts +2 -1
- package/services/chain-service/index.js +75 -26
- package/services/keyring-service/index.d.ts +1 -0
- package/services/keyring-service/index.js +9 -0
- package/services/migration-service/index.js +7 -4
- package/services/migration-service/scripts/MigrateAuthUrls.d.ts +4 -0
- package/services/migration-service/scripts/MigrateAuthUrls.js +31 -0
- package/services/migration-service/scripts/index.js +3 -1
- package/services/price-service/index.js +0 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +1 -0
- package/services/request-service/handler/AuthRequestHandler.js +7 -0
- package/services/request-service/handler/EvmRequestHandler.d.ts +1 -0
- package/services/request-service/handler/EvmRequestHandler.js +21 -0
- package/services/request-service/handler/MetadataRequestHandler.d.ts +1 -0
- package/services/request-service/handler/MetadataRequestHandler.js +6 -0
- package/services/request-service/handler/SubstrateRequestHandler.d.ts +1 -0
- package/services/request-service/handler/SubstrateRequestHandler.js +6 -0
- package/services/request-service/index.d.ts +1 -0
- package/services/request-service/index.js +6 -0
- package/services/setting-service/SettingService.d.ts +1 -0
- package/services/setting-service/SettingService.js +5 -10
- package/services/setting-service/constants.d.ts +2 -1
- package/services/setting-service/constants.js +10 -1
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +14 -0
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStore.d.ts +1 -0
- package/services/storage-service/db-stores/BaseStore.js +3 -0
- package/services/transaction-service/index.d.ts +1 -0
- package/services/transaction-service/index.js +3 -0
|
@@ -471,31 +471,43 @@ export class ChainService {
|
|
|
471
471
|
return duplicatedSlug;
|
|
472
472
|
}
|
|
473
473
|
async fetchLatestData(src, defaultValue) {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
474
|
+
return Promise.resolve(defaultValue);
|
|
475
|
+
// try {
|
|
476
|
+
// const timeout = new Promise((resolve) => {
|
|
477
|
+
// const id = setTimeout(() => {
|
|
478
|
+
// clearTimeout(id);
|
|
479
|
+
// resolve(null);
|
|
480
|
+
// }, 1500);
|
|
481
|
+
// });
|
|
482
|
+
// let result = defaultValue;
|
|
483
|
+
// const resp = await Promise.race([
|
|
484
|
+
// timeout,
|
|
485
|
+
// fetch(src)
|
|
486
|
+
// ]) as Response || null;
|
|
487
|
+
//
|
|
488
|
+
// if (!resp) {
|
|
489
|
+
// console.warn('Error fetching latest data', src);
|
|
490
|
+
//
|
|
491
|
+
// return result;
|
|
492
|
+
// }
|
|
493
|
+
//
|
|
494
|
+
// if (resp.ok) {
|
|
495
|
+
// try {
|
|
496
|
+
// result = await resp.json();
|
|
497
|
+
// console.log('Fetched latest data', src);
|
|
498
|
+
// } catch (err) {
|
|
499
|
+
// console.warn('Error parsing latest data', src, err);
|
|
500
|
+
// }
|
|
501
|
+
// }
|
|
502
|
+
//
|
|
503
|
+
// return result;
|
|
504
|
+
// } catch (e) {
|
|
505
|
+
// console.warn('Error fetching latest data', src, e);
|
|
506
|
+
//
|
|
507
|
+
// return defaultValue;
|
|
508
|
+
// }
|
|
498
509
|
}
|
|
510
|
+
|
|
499
511
|
async initChains() {
|
|
500
512
|
const storedChainSettings = await this.dbService.getAllChainStore();
|
|
501
513
|
const latestChainInfoMap = await this.fetchLatestData(_CHAIN_INFO_SRC, ChainInfoMap);
|
|
@@ -1181,13 +1193,12 @@ export class ChainService {
|
|
|
1181
1193
|
}
|
|
1182
1194
|
return this.assetSettingSubject.value;
|
|
1183
1195
|
}
|
|
1184
|
-
async updateAssetSetting(assetSlug, assetSetting) {
|
|
1196
|
+
async updateAssetSetting(assetSlug, assetSetting, autoEnableNativeToken) {
|
|
1185
1197
|
const currentAssetSettings = await this.getAssetSettings();
|
|
1186
1198
|
let needUpdateSubject;
|
|
1187
1199
|
|
|
1188
1200
|
// Update settings
|
|
1189
1201
|
currentAssetSettings[assetSlug] = assetSetting;
|
|
1190
|
-
this.setAssetSettings(currentAssetSettings);
|
|
1191
1202
|
if (assetSetting.visible) {
|
|
1192
1203
|
const assetInfo = this.getAssetBySlug(assetSlug);
|
|
1193
1204
|
const chainState = this.getChainStateByKey(assetInfo.originChain);
|
|
@@ -1196,8 +1207,15 @@ export class ChainService {
|
|
|
1196
1207
|
if (chainState && !chainState.active) {
|
|
1197
1208
|
this.enableChain(chainState.slug);
|
|
1198
1209
|
needUpdateSubject = true;
|
|
1210
|
+
if (autoEnableNativeToken) {
|
|
1211
|
+
const nativeAsset = this.getNativeTokenInfo(assetInfo.originChain);
|
|
1212
|
+
currentAssetSettings[nativeAsset.slug] = {
|
|
1213
|
+
visible: true
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1199
1216
|
}
|
|
1200
1217
|
}
|
|
1218
|
+
this.setAssetSettings(currentAssetSettings);
|
|
1201
1219
|
return needUpdateSubject;
|
|
1202
1220
|
}
|
|
1203
1221
|
async updateAssetSettingByChain(chainSlug, visible) {
|
|
@@ -1220,4 +1238,35 @@ export class ChainService {
|
|
|
1220
1238
|
async getAssetLogoMap() {
|
|
1221
1239
|
return await this.fetchLatestData(_ASSET_LOGO_MAP_SRC, AssetLogoMap);
|
|
1222
1240
|
}
|
|
1241
|
+
resetWallet(resetAll) {
|
|
1242
|
+
if (resetAll) {
|
|
1243
|
+
this.setAssetSettings({});
|
|
1244
|
+
|
|
1245
|
+
// Disconnect chain
|
|
1246
|
+
const activeChains = this.getActiveChainInfos();
|
|
1247
|
+
for (const chain of Object.keys(activeChains)) {
|
|
1248
|
+
if (!_DEFAULT_ACTIVE_CHAINS.includes(chain)) {
|
|
1249
|
+
this.disableChain(chain);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
// Remove custom chain
|
|
1254
|
+
const allChains = this.getChainInfoMap();
|
|
1255
|
+
for (const chain of Object.keys(allChains)) {
|
|
1256
|
+
if (_isCustomChain(chain)) {
|
|
1257
|
+
this.removeCustomChain(chain);
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
// Remove custom asset
|
|
1262
|
+
const assetSettings = this.getAssetSettings();
|
|
1263
|
+
const customToken = [];
|
|
1264
|
+
for (const asset of Object.keys(assetSettings)) {
|
|
1265
|
+
if (_isCustomAsset(asset)) {
|
|
1266
|
+
customToken.push(asset);
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
this.deleteCustomAssets(customToken);
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1223
1272
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
4
5
|
import { CurrentAccountStore } from '@subwallet/extension-base/stores';
|
|
5
6
|
import { keyring } from '@subwallet/ui-keyring';
|
|
6
7
|
import { BehaviorSubject } from 'rxjs';
|
|
@@ -88,4 +89,12 @@ export class KeyringService {
|
|
|
88
89
|
this.eventService.emit('account.updateCurrent', currentAccountData);
|
|
89
90
|
this.currentAccountStore.set('CurrentAccountInfo', currentAccountData);
|
|
90
91
|
}
|
|
92
|
+
resetWallet(resetAll) {
|
|
93
|
+
keyring.resetWallet(resetAll);
|
|
94
|
+
this.updateKeyringState();
|
|
95
|
+
this.currentAccountSubject.next({
|
|
96
|
+
address: ALL_ACCOUNT_KEY,
|
|
97
|
+
currentGenesisHash: null
|
|
98
|
+
});
|
|
99
|
+
}
|
|
91
100
|
}
|
|
@@ -11,8 +11,11 @@ export default class MigrationService {
|
|
|
11
11
|
async run() {
|
|
12
12
|
this.logger.log('Migrating...');
|
|
13
13
|
const keys = Object.keys(MigrationScripts).sort((a, b) => a.localeCompare(b));
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
|
|
15
|
+
// Await timeout 2s
|
|
16
|
+
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
17
|
+
for (let i = 0; i < keys.length; i++) {
|
|
18
|
+
try {
|
|
16
19
|
const JobClass = MigrationScripts[keys[i]];
|
|
17
20
|
const key = keys[i];
|
|
18
21
|
const name = JobClass.name;
|
|
@@ -30,9 +33,9 @@ export default class MigrationService {
|
|
|
30
33
|
timestamp: new Date().getTime()
|
|
31
34
|
});
|
|
32
35
|
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
this.logger.error('Migration error: ', MigrationScripts[keys[i]].name, error);
|
|
33
38
|
}
|
|
34
|
-
} catch (error) {
|
|
35
|
-
this.logger.error('Migration error: ', error);
|
|
36
39
|
}
|
|
37
40
|
this.logger.log('Migration done.');
|
|
38
41
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateSettings extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
this.state.getAuthorize(value => {
|
|
10
|
+
if (value) {
|
|
11
|
+
const key = 'app.stellaswap.com';
|
|
12
|
+
const stellaSwap = value[key];
|
|
13
|
+
if (stellaSwap) {
|
|
14
|
+
stellaSwap.currentEvmNetworkKey = 'moonbeam';
|
|
15
|
+
value[key] = stellaSwap;
|
|
16
|
+
this.state.setAuthorize(value, () => {
|
|
17
|
+
resolve();
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
resolve();
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
resolve();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
} catch (e) {
|
|
28
|
+
console.error(e);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import AutoEnableChainsTokens from '@subwallet/extension-base/services/migration-service/scripts/AutoEnableChainsTokens';
|
|
5
|
+
import MigrateAuthUrls from '@subwallet/extension-base/services/migration-service/scripts/MigrateAuthUrls';
|
|
5
6
|
import MigrateImportedToken from '@subwallet/extension-base/services/migration-service/scripts/MigrateImportedToken';
|
|
6
7
|
import MigrateNetworkSettings from '@subwallet/extension-base/services/migration-service/scripts/MigrateNetworkSettings';
|
|
7
8
|
import MigrateSettings from '@subwallet/extension-base/services/migration-service/scripts/MigrateSettings';
|
|
@@ -12,6 +13,7 @@ export default {
|
|
|
12
13
|
'1.0.1-20': MigrateImportedToken,
|
|
13
14
|
'1.0.1-30': MigrateTransactionHistory,
|
|
14
15
|
'1.0.1-40': AutoEnableChainsTokens,
|
|
15
|
-
'1.0.1-50': MigrateSettings
|
|
16
|
+
'1.0.1-50': MigrateSettings,
|
|
17
|
+
'1.0.1-60': MigrateAuthUrls
|
|
16
18
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
17
19
|
};
|
|
@@ -63,7 +63,6 @@ export class PriceService {
|
|
|
63
63
|
await this.eventService.waitAssetReady;
|
|
64
64
|
this.status = ServiceStatus.INITIALIZED;
|
|
65
65
|
this.eventService.on('asset.updateState', eventHandler);
|
|
66
|
-
this.eventService.on('asset.updateState', eventHandler);
|
|
67
66
|
}
|
|
68
67
|
async loadData() {
|
|
69
68
|
const data = await this.dbService.getPriceStore();
|
|
@@ -283,4 +283,11 @@ export default class AuthRequestHandler {
|
|
|
283
283
|
});
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
|
+
resetWallet() {
|
|
287
|
+
for (const request of Object.values(this.#authRequestsV2)) {
|
|
288
|
+
request.reject(new Error('Reset wallet'));
|
|
289
|
+
}
|
|
290
|
+
this.authSubjectV2.next([]);
|
|
291
|
+
this.setAuthorize({});
|
|
292
|
+
}
|
|
286
293
|
}
|
|
@@ -200,4 +200,25 @@ export default class EvmRequestHandler {
|
|
|
200
200
|
}
|
|
201
201
|
return true;
|
|
202
202
|
}
|
|
203
|
+
resetWallet() {
|
|
204
|
+
const confirmations = this.confirmationsQueueSubject.getValue();
|
|
205
|
+
for (const [type, requests] of Object.entries(confirmations)) {
|
|
206
|
+
for (const confirmation of Object.values(requests)) {
|
|
207
|
+
const {
|
|
208
|
+
id
|
|
209
|
+
} = confirmation;
|
|
210
|
+
const {
|
|
211
|
+
resolver
|
|
212
|
+
} = this.confirmationsPromiseMap[id];
|
|
213
|
+
if (!resolver || !confirmation) {
|
|
214
|
+
console.error('Not found confirmation', type, id);
|
|
215
|
+
} else {
|
|
216
|
+
resolver.reject(new Error('Reset wallet'));
|
|
217
|
+
}
|
|
218
|
+
delete this.confirmationsPromiseMap[id];
|
|
219
|
+
delete confirmations[type][id];
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
this.confirmationsQueueSubject.next(confirmations);
|
|
223
|
+
}
|
|
203
224
|
}
|
|
@@ -72,4 +72,10 @@ export default class MetadataRequestHandler {
|
|
|
72
72
|
this.#requestService.popupOpen();
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
|
+
resetWallet() {
|
|
76
|
+
for (const request of Object.values(this.#metaRequests)) {
|
|
77
|
+
request.reject(new Error('Reset wallet'));
|
|
78
|
+
}
|
|
79
|
+
this.metaSubject.next([]);
|
|
80
|
+
}
|
|
75
81
|
}
|
|
@@ -14,4 +14,5 @@ export default class SubstrateRequestHandler {
|
|
|
14
14
|
get numSubstrateRequests(): number;
|
|
15
15
|
sign(url: string, request: RequestSign, account: AccountJson): Promise<ResponseSigning>;
|
|
16
16
|
signTransaction(id: string, address: string, url: string, payload: SignerPayloadJSON): Promise<ResponseSigning>;
|
|
17
|
+
resetWallet(): void;
|
|
17
18
|
}
|
|
@@ -51,4 +51,5 @@ export default class RequestService {
|
|
|
51
51
|
addConfirmation<CT extends ConfirmationType>(id: string, url: string, type: CT, payload: ConfirmationDefinitions[CT][0]['payload'], options?: ConfirmationsQueueItemOptions, validator?: (input: ConfirmationDefinitions[CT][1]) => Error | undefined): Promise<ConfirmationDefinitions[CT][1]>;
|
|
52
52
|
completeConfirmation(request: RequestConfirmationComplete): Promise<boolean>;
|
|
53
53
|
get numRequests(): number;
|
|
54
|
+
resetWallet(): void;
|
|
54
55
|
}
|
|
@@ -156,4 +156,10 @@ export default class RequestService {
|
|
|
156
156
|
get numRequests() {
|
|
157
157
|
return this.numMetaRequests + this.numAuthRequests + this.numSubstrateRequests + this.numEvmRequests;
|
|
158
158
|
}
|
|
159
|
+
resetWallet() {
|
|
160
|
+
this.#authRequestHandler.resetWallet();
|
|
161
|
+
this.#substrateRequestHandler.resetWallet();
|
|
162
|
+
this.#evmRequestHandler.resetWallet();
|
|
163
|
+
this.#metadataRequestHandler.resetWallet();
|
|
164
|
+
}
|
|
159
165
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import SettingsStore from '@subwallet/extension-base/stores/Settings';
|
|
5
|
-
import {
|
|
5
|
+
import { DEFAULT_SETTING } from "./constants.js";
|
|
6
6
|
export default class SettingService {
|
|
7
7
|
settingsStore = new SettingsStore();
|
|
8
8
|
getSubject() {
|
|
@@ -11,15 +11,7 @@ export default class SettingService {
|
|
|
11
11
|
getSettings(update) {
|
|
12
12
|
this.settingsStore.get('Settings', value => {
|
|
13
13
|
if (!value) {
|
|
14
|
-
update(
|
|
15
|
-
// language: 'en',
|
|
16
|
-
browserConfirmationType: DEFAULT_NOTIFICATION_TYPE,
|
|
17
|
-
// isShowZeroBalance: true,
|
|
18
|
-
isShowBalance: false,
|
|
19
|
-
accountAllLogo: '',
|
|
20
|
-
theme: DEFAULT_THEME,
|
|
21
|
-
camera: false
|
|
22
|
-
});
|
|
14
|
+
update(DEFAULT_SETTING);
|
|
23
15
|
} else {
|
|
24
16
|
update(value);
|
|
25
17
|
}
|
|
@@ -28,4 +20,7 @@ export default class SettingService {
|
|
|
28
20
|
setSettings(data, callback) {
|
|
29
21
|
this.settingsStore.set('Settings', data, callback);
|
|
30
22
|
}
|
|
23
|
+
resetWallet() {
|
|
24
|
+
this.settingsStore.set('Settings', DEFAULT_SETTING);
|
|
25
|
+
}
|
|
31
26
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { BrowserConfirmationType, ThemeNames } from '@subwallet/extension-base/background/KoniTypes';
|
|
1
|
+
import { BrowserConfirmationType, RequestSettingsType, ThemeNames } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
export declare const DEFAULT_THEME: ThemeNames;
|
|
3
3
|
export declare const DEFAULT_NOTIFICATION_TYPE: BrowserConfirmationType;
|
|
4
|
+
export declare const DEFAULT_SETTING: RequestSettingsType;
|
|
@@ -3,4 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import { ThemeNames } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
export const DEFAULT_THEME = ThemeNames.DARK;
|
|
6
|
-
export const DEFAULT_NOTIFICATION_TYPE = 'popup';
|
|
6
|
+
export const DEFAULT_NOTIFICATION_TYPE = 'popup';
|
|
7
|
+
export const DEFAULT_SETTING = {
|
|
8
|
+
// language: 'en',
|
|
9
|
+
browserConfirmationType: DEFAULT_NOTIFICATION_TYPE,
|
|
10
|
+
// isShowZeroBalance: true,
|
|
11
|
+
isShowBalance: false,
|
|
12
|
+
accountAllLogo: '',
|
|
13
|
+
theme: DEFAULT_THEME,
|
|
14
|
+
camera: false
|
|
15
|
+
};
|
|
@@ -63,4 +63,5 @@ export default class DatabaseService {
|
|
|
63
63
|
getStakingMetadataByChain(chain: string, type?: StakingType): Promise<ChainStakingMetadata | undefined>;
|
|
64
64
|
updateNominatorMetadata(item: NominatorMetadata): Promise<unknown>;
|
|
65
65
|
getNominatorMetadata(): Promise<NominatorMetadata[]>;
|
|
66
|
+
resetWallet(resetAll: boolean): Promise<void>;
|
|
66
67
|
}
|
|
@@ -248,4 +248,18 @@ export default class DatabaseService {
|
|
|
248
248
|
async getNominatorMetadata() {
|
|
249
249
|
return this.stores.nominatorMetadata.getAll();
|
|
250
250
|
}
|
|
251
|
+
async resetWallet(resetAll) {
|
|
252
|
+
return new Promise((resolve, reject) => {
|
|
253
|
+
const stores = [this.stores.balance, this.stores.nft, this.stores.nftCollection, this.stores.crowdloan, this.stores.staking, this.stores.transaction, this.stores.nominatorMetadata];
|
|
254
|
+
if (resetAll) {
|
|
255
|
+
stores.push(this.stores.chain, this.stores.asset);
|
|
256
|
+
}
|
|
257
|
+
const promises = stores.map(store => store.clear());
|
|
258
|
+
Promise.all(promises).then(() => {
|
|
259
|
+
resolve();
|
|
260
|
+
}).catch(e => {
|
|
261
|
+
reject(e);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
}
|
|
251
265
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import Dexie from 'dexie';
|
|
5
5
|
const DEFAULT_DATABASE = 'SubWalletDB_v2';
|
|
6
6
|
export default class KoniDatabase extends Dexie {
|
|
7
|
-
constructor(name = DEFAULT_DATABASE, schemaVersion =
|
|
7
|
+
constructor(name = DEFAULT_DATABASE, schemaVersion = 11) {
|
|
8
8
|
super(name);
|
|
9
9
|
this.schemaVersion = schemaVersion;
|
|
10
10
|
this.conditionalVersion(1, {
|