@subwallet/extension-base 1.1.34-0 → 1.1.35-0
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/cjs/constants/staking.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +1 -1
- package/cjs/services/chain-service/index.js +44 -1
- package/cjs/services/storage-service/DatabaseService.js +34 -0
- package/cjs/services/storage-service/db-stores/AssetRef.js +24 -0
- package/constants/staking.js +1 -1
- package/package.json +10 -5
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +1 -1
- package/services/chain-service/constants.js +1 -1
- package/services/chain-service/index.d.ts +3 -0
- package/services/chain-service/index.js +44 -1
- package/services/storage-service/DatabaseService.js +34 -0
- package/services/storage-service/databases/index.d.ts +4 -1
- package/services/storage-service/db-stores/AssetRef.d.ts +7 -0
- package/services/storage-service/db-stores/AssetRef.js +16 -0
package/cjs/constants/staking.js
CHANGED
package/cjs/packageInfo.js
CHANGED
|
@@ -278,7 +278,7 @@ const EVM_REFORMAT_DECIMALS = {
|
|
|
278
278
|
acala: ['acala_evm', 'karura_evm']
|
|
279
279
|
};
|
|
280
280
|
exports.EVM_REFORMAT_DECIMALS = EVM_REFORMAT_DECIMALS;
|
|
281
|
-
const LATEST_CHAIN_DATA_FETCHING_INTERVAL =
|
|
281
|
+
const LATEST_CHAIN_DATA_FETCHING_INTERVAL = 120000;
|
|
282
282
|
|
|
283
283
|
// TODO: review
|
|
284
284
|
exports.LATEST_CHAIN_DATA_FETCHING_INTERVAL = LATEST_CHAIN_DATA_FETCHING_INTERVAL;
|
|
@@ -410,7 +410,10 @@ class ChainService {
|
|
|
410
410
|
|
|
411
411
|
// TODO: reconsider the flow of initiation
|
|
412
412
|
this.multiChainAssetMapSubject.next(_chainList.MultiChainAssetMap);
|
|
413
|
-
|
|
413
|
+
// const storedAssetRefMap = await this.dbService.getAssetRefMap();
|
|
414
|
+
//
|
|
415
|
+
// this.dataMap.assetRefMap = storedAssetRefMap && Object.values(storedAssetRefMap).length > 0 ? storedAssetRefMap : AssetRefMap;
|
|
416
|
+
|
|
414
417
|
await this.initChains();
|
|
415
418
|
this.chainInfoMapSubject.next(this.getChainInfoMap());
|
|
416
419
|
this.updateChainStateMapSubscription();
|
|
@@ -418,10 +421,31 @@ class ChainService {
|
|
|
418
421
|
this.xcmRefMapSubject.next(this.dataMap.assetRefMap);
|
|
419
422
|
await this.initApis();
|
|
420
423
|
await this.initAssetSettings();
|
|
424
|
+
await this.initAssetRefMap();
|
|
421
425
|
this.checkLatestData();
|
|
422
426
|
}
|
|
427
|
+
async initAssetRefMap() {
|
|
428
|
+
try {
|
|
429
|
+
const fetchPromise = this.fetchLatestBlockedAssetRef();
|
|
430
|
+
const timeout = new Promise(resolve => {
|
|
431
|
+
const id = setTimeout(() => {
|
|
432
|
+
clearTimeout(id);
|
|
433
|
+
resolve(null);
|
|
434
|
+
}, 1000);
|
|
435
|
+
});
|
|
436
|
+
const disabledAssetRefs = (await Promise.race([timeout, fetchPromise])) || null;
|
|
437
|
+
if (disabledAssetRefs) {
|
|
438
|
+
this.handleLatestBlockedAssetRef(disabledAssetRefs);
|
|
439
|
+
} else {
|
|
440
|
+
this.dataMap.assetRefMap = _chainList.AssetRefMap;
|
|
441
|
+
}
|
|
442
|
+
} catch (e) {
|
|
443
|
+
this.dataMap.assetRefMap = _chainList.AssetRefMap;
|
|
444
|
+
}
|
|
445
|
+
}
|
|
423
446
|
checkLatestData() {
|
|
424
447
|
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
448
|
+
this.handleLatestData();
|
|
425
449
|
this.refreshLatestChainDataTimeOut = setInterval(this.handleLatestData.bind(this), _constants.LATEST_CHAIN_DATA_FETCHING_INTERVAL);
|
|
426
450
|
}
|
|
427
451
|
stopCheckLatestChainData() {
|
|
@@ -446,6 +470,19 @@ class ChainService {
|
|
|
446
470
|
console.error('Error fetching latest chain data');
|
|
447
471
|
}
|
|
448
472
|
}
|
|
473
|
+
handleLatestBlockedAssetRef(latestBlockedAssetRefList) {
|
|
474
|
+
const updatedAssetRefMap = {
|
|
475
|
+
..._chainList.AssetRefMap
|
|
476
|
+
};
|
|
477
|
+
latestBlockedAssetRefList.forEach(blockedAssetRef => {
|
|
478
|
+
delete updatedAssetRefMap[blockedAssetRef];
|
|
479
|
+
});
|
|
480
|
+
this.dataMap.assetRefMap = updatedAssetRefMap;
|
|
481
|
+
|
|
482
|
+
// this.dbService.setAssetRef(this.dataMap.assetRefMap).catch(console.error);
|
|
483
|
+
this.xcmRefMapSubject.next(this.dataMap.assetRefMap);
|
|
484
|
+
this.logger.log('Finished updating latest asset ref');
|
|
485
|
+
}
|
|
449
486
|
handleLatestPriceId(latestPriceIds) {
|
|
450
487
|
Object.entries(latestPriceIds).forEach(_ref3 => {
|
|
451
488
|
let [slug, priceId] = _ref3;
|
|
@@ -461,6 +498,9 @@ class ChainService {
|
|
|
461
498
|
this.fetchLatestChainData().then(latestChainInfo => {
|
|
462
499
|
this.handleLatestProviderData(latestChainInfo);
|
|
463
500
|
}).catch(console.error);
|
|
501
|
+
this.fetchLatestBlockedAssetRef().then(latestAssetRef => {
|
|
502
|
+
this.handleLatestBlockedAssetRef(latestAssetRef);
|
|
503
|
+
}).catch(console.error);
|
|
464
504
|
|
|
465
505
|
// this.fetchLatestPriceIdsData().then((latestPriceIds) => {
|
|
466
506
|
// this.handleLatestPriceId(latestPriceIds);
|
|
@@ -666,6 +706,9 @@ class ChainService {
|
|
|
666
706
|
async fetchLatestPriceIdsData() {
|
|
667
707
|
return await (0, _utils2.fetchStaticData)('chain-assets/price-map');
|
|
668
708
|
}
|
|
709
|
+
async fetchLatestBlockedAssetRef() {
|
|
710
|
+
return await (0, _utils2.fetchStaticData)('chain-assets/disabled-xcm-channels');
|
|
711
|
+
}
|
|
669
712
|
async initChains() {
|
|
670
713
|
const storedChainSettings = await this.dbService.getAllChainStore();
|
|
671
714
|
const defaultChainInfoMap = _chainList.ChainInfoMap;
|
|
@@ -47,8 +47,10 @@ class DatabaseService {
|
|
|
47
47
|
nominatorMetadata: new _NominatorMetadata.default(this._db.nominatorMetadata),
|
|
48
48
|
mantaPay: new _MantaPay.default(this._db.mantaPay),
|
|
49
49
|
campaign: new _Campaign.default(this._db.campaign)
|
|
50
|
+
// assetRef: new AssetRefStore(this._db.assetRef)
|
|
50
51
|
};
|
|
51
52
|
}
|
|
53
|
+
|
|
52
54
|
async updatePriceStore(priceData) {
|
|
53
55
|
await this.stores.price.table.put(priceData);
|
|
54
56
|
}
|
|
@@ -324,5 +326,37 @@ class DatabaseService {
|
|
|
324
326
|
async getExportJson() {
|
|
325
327
|
return JSON.parse(await this.exportDB());
|
|
326
328
|
}
|
|
329
|
+
|
|
330
|
+
// public setAssetRef (assetRef: Record<string, _AssetRef>) {
|
|
331
|
+
// const assetRefList = Object.entries(assetRef).map(([slug, item]) => {
|
|
332
|
+
// return {
|
|
333
|
+
// slug,
|
|
334
|
+
// ...item
|
|
335
|
+
// } as IAssetRef;
|
|
336
|
+
// });
|
|
337
|
+
//
|
|
338
|
+
// return this.stores.assetRef.bulkUpsert(assetRefList);
|
|
339
|
+
// }
|
|
340
|
+
//
|
|
341
|
+
// public getAssetRef (slug: string) {
|
|
342
|
+
// return this.stores.assetRef.getAssetRef(slug);
|
|
343
|
+
// }
|
|
344
|
+
//
|
|
345
|
+
// public async getAssetRefMap (): Promise<Record<string, _AssetRef>> {
|
|
346
|
+
// const assetRefList = await this.stores.assetRef.getAll();
|
|
347
|
+
// const assetRefObj: Record<string, _AssetRef> = {};
|
|
348
|
+
//
|
|
349
|
+
// assetRefList.forEach((item) => {
|
|
350
|
+
// assetRefObj[item.slug] = {
|
|
351
|
+
// ...item
|
|
352
|
+
// };
|
|
353
|
+
// });
|
|
354
|
+
//
|
|
355
|
+
// return assetRefObj;
|
|
356
|
+
// }
|
|
357
|
+
//
|
|
358
|
+
// public subscribeAssetRef () {
|
|
359
|
+
// return this.stores.assetRef.subscribeAssetRef();
|
|
360
|
+
// }
|
|
327
361
|
}
|
|
328
362
|
exports.default = DatabaseService;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _BaseStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStore"));
|
|
9
|
+
var _dexie = require("dexie");
|
|
10
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
class AssetRefStore extends _BaseStore.default {
|
|
14
|
+
async getAll() {
|
|
15
|
+
return this.table.toArray();
|
|
16
|
+
}
|
|
17
|
+
async getAssetRef(slug) {
|
|
18
|
+
return this.table.get(slug);
|
|
19
|
+
}
|
|
20
|
+
subscribeAssetRef() {
|
|
21
|
+
return (0, _dexie.liveQuery)(async () => await this.table.toArray());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = AssetRefStore;
|
package/constants/staking.js
CHANGED
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.35-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -978,6 +978,11 @@
|
|
|
978
978
|
"require": "./cjs/services/storage-service/db-stores/Asset.js",
|
|
979
979
|
"default": "./services/storage-service/db-stores/Asset.js"
|
|
980
980
|
},
|
|
981
|
+
"./services/storage-service/db-stores/AssetRef": {
|
|
982
|
+
"types": "./services/storage-service/db-stores/AssetRef.d.ts",
|
|
983
|
+
"require": "./cjs/services/storage-service/db-stores/AssetRef.js",
|
|
984
|
+
"default": "./services/storage-service/db-stores/AssetRef.js"
|
|
985
|
+
},
|
|
981
986
|
"./services/storage-service/db-stores/Balance": {
|
|
982
987
|
"types": "./services/storage-service/db-stores/Balance.d.ts",
|
|
983
988
|
"require": "./cjs/services/storage-service/db-stores/Balance.js",
|
|
@@ -1399,10 +1404,10 @@
|
|
|
1399
1404
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1400
1405
|
"@substrate/connect": "^0.7.26",
|
|
1401
1406
|
"@subwallet/chain-list": "0.2.39",
|
|
1402
|
-
"@subwallet/extension-base": "^1.1.
|
|
1403
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1404
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1405
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1407
|
+
"@subwallet/extension-base": "^1.1.35-0",
|
|
1408
|
+
"@subwallet/extension-chains": "^1.1.35-0",
|
|
1409
|
+
"@subwallet/extension-dapp": "^1.1.35-0",
|
|
1410
|
+
"@subwallet/extension-inject": "^1.1.35-0",
|
|
1406
1411
|
"@subwallet/keyring": "^0.1.1",
|
|
1407
1412
|
"@subwallet/ui-keyring": "^0.1.1",
|
|
1408
1413
|
"@walletconnect/sign-client": "^2.8.4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.1.
|
|
10
|
+
version: '1.1.35-0'
|
|
11
11
|
};
|
|
@@ -96,7 +96,7 @@ export declare const EVM_PASS_CONNECT_STATUS: Record<string, string[]>;
|
|
|
96
96
|
export declare const EVM_REFORMAT_DECIMALS: {
|
|
97
97
|
acala: string[];
|
|
98
98
|
};
|
|
99
|
-
export declare const LATEST_CHAIN_DATA_FETCHING_INTERVAL =
|
|
99
|
+
export declare const LATEST_CHAIN_DATA_FETCHING_INTERVAL = 120000;
|
|
100
100
|
export declare const _CHAIN_INFO_SRC: string;
|
|
101
101
|
export declare const _CHAIN_ASSET_SRC: string;
|
|
102
102
|
export declare const _ASSET_REF_SRC: string;
|
|
@@ -252,7 +252,7 @@ export const EVM_PASS_CONNECT_STATUS = {
|
|
|
252
252
|
export const EVM_REFORMAT_DECIMALS = {
|
|
253
253
|
acala: ['acala_evm', 'karura_evm']
|
|
254
254
|
};
|
|
255
|
-
export const LATEST_CHAIN_DATA_FETCHING_INTERVAL =
|
|
255
|
+
export const LATEST_CHAIN_DATA_FETCHING_INTERVAL = 120000;
|
|
256
256
|
|
|
257
257
|
// TODO: review
|
|
258
258
|
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni-dev' : 'master';
|
|
@@ -71,9 +71,11 @@ export declare class ChainService {
|
|
|
71
71
|
deleteAssetsByChain(chainSlug: string): void;
|
|
72
72
|
deleteCustomAssets(targetAssets: string[]): void;
|
|
73
73
|
init(): Promise<void>;
|
|
74
|
+
initAssetRefMap(): Promise<void>;
|
|
74
75
|
checkLatestData(): void;
|
|
75
76
|
stopCheckLatestChainData(): void;
|
|
76
77
|
handleLatestProviderData(latestChainInfo: _ChainInfo[]): void;
|
|
78
|
+
handleLatestBlockedAssetRef(latestBlockedAssetRefList: string[]): void;
|
|
77
79
|
handleLatestPriceId(latestPriceIds: Record<string, string | null>): void;
|
|
78
80
|
handleLatestData(): void;
|
|
79
81
|
private initApis;
|
|
@@ -86,6 +88,7 @@ export declare class ChainService {
|
|
|
86
88
|
private checkExistedPredefinedChain;
|
|
87
89
|
private fetchLatestChainData;
|
|
88
90
|
private fetchLatestPriceIdsData;
|
|
91
|
+
private fetchLatestBlockedAssetRef;
|
|
89
92
|
private initChains;
|
|
90
93
|
private initAssetRegistry;
|
|
91
94
|
private updateChainStateMapSubscription;
|
|
@@ -396,7 +396,10 @@ export class ChainService {
|
|
|
396
396
|
|
|
397
397
|
// TODO: reconsider the flow of initiation
|
|
398
398
|
this.multiChainAssetMapSubject.next(MultiChainAssetMap);
|
|
399
|
-
this.
|
|
399
|
+
// const storedAssetRefMap = await this.dbService.getAssetRefMap();
|
|
400
|
+
//
|
|
401
|
+
// this.dataMap.assetRefMap = storedAssetRefMap && Object.values(storedAssetRefMap).length > 0 ? storedAssetRefMap : AssetRefMap;
|
|
402
|
+
|
|
400
403
|
await this.initChains();
|
|
401
404
|
this.chainInfoMapSubject.next(this.getChainInfoMap());
|
|
402
405
|
this.updateChainStateMapSubscription();
|
|
@@ -404,10 +407,31 @@ export class ChainService {
|
|
|
404
407
|
this.xcmRefMapSubject.next(this.dataMap.assetRefMap);
|
|
405
408
|
await this.initApis();
|
|
406
409
|
await this.initAssetSettings();
|
|
410
|
+
await this.initAssetRefMap();
|
|
407
411
|
this.checkLatestData();
|
|
408
412
|
}
|
|
413
|
+
async initAssetRefMap() {
|
|
414
|
+
try {
|
|
415
|
+
const fetchPromise = this.fetchLatestBlockedAssetRef();
|
|
416
|
+
const timeout = new Promise(resolve => {
|
|
417
|
+
const id = setTimeout(() => {
|
|
418
|
+
clearTimeout(id);
|
|
419
|
+
resolve(null);
|
|
420
|
+
}, 1000);
|
|
421
|
+
});
|
|
422
|
+
const disabledAssetRefs = (await Promise.race([timeout, fetchPromise])) || null;
|
|
423
|
+
if (disabledAssetRefs) {
|
|
424
|
+
this.handleLatestBlockedAssetRef(disabledAssetRefs);
|
|
425
|
+
} else {
|
|
426
|
+
this.dataMap.assetRefMap = AssetRefMap;
|
|
427
|
+
}
|
|
428
|
+
} catch (e) {
|
|
429
|
+
this.dataMap.assetRefMap = AssetRefMap;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
409
432
|
checkLatestData() {
|
|
410
433
|
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
434
|
+
this.handleLatestData();
|
|
411
435
|
this.refreshLatestChainDataTimeOut = setInterval(this.handleLatestData.bind(this), LATEST_CHAIN_DATA_FETCHING_INTERVAL);
|
|
412
436
|
}
|
|
413
437
|
stopCheckLatestChainData() {
|
|
@@ -432,6 +456,19 @@ export class ChainService {
|
|
|
432
456
|
console.error('Error fetching latest chain data');
|
|
433
457
|
}
|
|
434
458
|
}
|
|
459
|
+
handleLatestBlockedAssetRef(latestBlockedAssetRefList) {
|
|
460
|
+
const updatedAssetRefMap = {
|
|
461
|
+
...AssetRefMap
|
|
462
|
+
};
|
|
463
|
+
latestBlockedAssetRefList.forEach(blockedAssetRef => {
|
|
464
|
+
delete updatedAssetRefMap[blockedAssetRef];
|
|
465
|
+
});
|
|
466
|
+
this.dataMap.assetRefMap = updatedAssetRefMap;
|
|
467
|
+
|
|
468
|
+
// this.dbService.setAssetRef(this.dataMap.assetRefMap).catch(console.error);
|
|
469
|
+
this.xcmRefMapSubject.next(this.dataMap.assetRefMap);
|
|
470
|
+
this.logger.log('Finished updating latest asset ref');
|
|
471
|
+
}
|
|
435
472
|
handleLatestPriceId(latestPriceIds) {
|
|
436
473
|
Object.entries(latestPriceIds).forEach(([slug, priceId]) => {
|
|
437
474
|
if (this.dataMap.assetRegistry[slug]) {
|
|
@@ -446,6 +483,9 @@ export class ChainService {
|
|
|
446
483
|
this.fetchLatestChainData().then(latestChainInfo => {
|
|
447
484
|
this.handleLatestProviderData(latestChainInfo);
|
|
448
485
|
}).catch(console.error);
|
|
486
|
+
this.fetchLatestBlockedAssetRef().then(latestAssetRef => {
|
|
487
|
+
this.handleLatestBlockedAssetRef(latestAssetRef);
|
|
488
|
+
}).catch(console.error);
|
|
449
489
|
|
|
450
490
|
// this.fetchLatestPriceIdsData().then((latestPriceIds) => {
|
|
451
491
|
// this.handleLatestPriceId(latestPriceIds);
|
|
@@ -649,6 +689,9 @@ export class ChainService {
|
|
|
649
689
|
async fetchLatestPriceIdsData() {
|
|
650
690
|
return await fetchStaticData('chain-assets/price-map');
|
|
651
691
|
}
|
|
692
|
+
async fetchLatestBlockedAssetRef() {
|
|
693
|
+
return await fetchStaticData('chain-assets/disabled-xcm-channels');
|
|
694
|
+
}
|
|
652
695
|
async initChains() {
|
|
653
696
|
const storedChainSettings = await this.dbService.getAllChainStore();
|
|
654
697
|
const defaultChainInfoMap = ChainInfoMap;
|
|
@@ -39,8 +39,10 @@ export default class DatabaseService {
|
|
|
39
39
|
nominatorMetadata: new NominatorMetadataStore(this._db.nominatorMetadata),
|
|
40
40
|
mantaPay: new MantaPayStore(this._db.mantaPay),
|
|
41
41
|
campaign: new CampaignStore(this._db.campaign)
|
|
42
|
+
// assetRef: new AssetRefStore(this._db.assetRef)
|
|
42
43
|
};
|
|
43
44
|
}
|
|
45
|
+
|
|
44
46
|
async updatePriceStore(priceData) {
|
|
45
47
|
await this.stores.price.table.put(priceData);
|
|
46
48
|
}
|
|
@@ -315,4 +317,36 @@ export default class DatabaseService {
|
|
|
315
317
|
async getExportJson() {
|
|
316
318
|
return JSON.parse(await this.exportDB());
|
|
317
319
|
}
|
|
320
|
+
|
|
321
|
+
// public setAssetRef (assetRef: Record<string, _AssetRef>) {
|
|
322
|
+
// const assetRefList = Object.entries(assetRef).map(([slug, item]) => {
|
|
323
|
+
// return {
|
|
324
|
+
// slug,
|
|
325
|
+
// ...item
|
|
326
|
+
// } as IAssetRef;
|
|
327
|
+
// });
|
|
328
|
+
//
|
|
329
|
+
// return this.stores.assetRef.bulkUpsert(assetRefList);
|
|
330
|
+
// }
|
|
331
|
+
//
|
|
332
|
+
// public getAssetRef (slug: string) {
|
|
333
|
+
// return this.stores.assetRef.getAssetRef(slug);
|
|
334
|
+
// }
|
|
335
|
+
//
|
|
336
|
+
// public async getAssetRefMap (): Promise<Record<string, _AssetRef>> {
|
|
337
|
+
// const assetRefList = await this.stores.assetRef.getAll();
|
|
338
|
+
// const assetRefObj: Record<string, _AssetRef> = {};
|
|
339
|
+
//
|
|
340
|
+
// assetRefList.forEach((item) => {
|
|
341
|
+
// assetRefObj[item.slug] = {
|
|
342
|
+
// ...item
|
|
343
|
+
// };
|
|
344
|
+
// });
|
|
345
|
+
//
|
|
346
|
+
// return assetRefObj;
|
|
347
|
+
// }
|
|
348
|
+
//
|
|
349
|
+
// public subscribeAssetRef () {
|
|
350
|
+
// return this.stores.assetRef.subscribeAssetRef();
|
|
351
|
+
// }
|
|
318
352
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
1
|
+
import { _AssetRef, _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { CampaignData, ChainStakingMetadata, CrowdloanItem, MetadataItem, NftCollection, NftItem, NominatorMetadata, PriceJson, StakingItem, TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { BalanceItem } from '@subwallet/extension-base/types';
|
|
4
4
|
import Dexie, { Table } from 'dexie';
|
|
@@ -31,6 +31,9 @@ export interface IMetadataItem extends MetadataItem, DefaultChainDoc {
|
|
|
31
31
|
}
|
|
32
32
|
export declare type IMantaPayLedger = any;
|
|
33
33
|
export declare type ICampaign = CampaignData;
|
|
34
|
+
export interface IAssetRef extends _AssetRef {
|
|
35
|
+
slug: string;
|
|
36
|
+
}
|
|
34
37
|
export default class KoniDatabase extends Dexie {
|
|
35
38
|
price: Table<PriceJson, object>;
|
|
36
39
|
balances: Table<IBalance, object>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IAssetRef } from '@subwallet/extension-base/services/storage-service/databases';
|
|
2
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
3
|
+
export default class AssetRefStore extends BaseStore<IAssetRef> {
|
|
4
|
+
getAll(): Promise<IAssetRef[]>;
|
|
5
|
+
getAssetRef(slug: string): Promise<IAssetRef | undefined>;
|
|
6
|
+
subscribeAssetRef(): import("dexie").Observable<IAssetRef[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseStore from '@subwallet/extension-base/services/storage-service/db-stores/BaseStore';
|
|
5
|
+
import { liveQuery } from 'dexie';
|
|
6
|
+
export default class AssetRefStore extends BaseStore {
|
|
7
|
+
async getAll() {
|
|
8
|
+
return this.table.toArray();
|
|
9
|
+
}
|
|
10
|
+
async getAssetRef(slug) {
|
|
11
|
+
return this.table.get(slug);
|
|
12
|
+
}
|
|
13
|
+
subscribeAssetRef() {
|
|
14
|
+
return liveQuery(async () => await this.table.toArray());
|
|
15
|
+
}
|
|
16
|
+
}
|