@subwallet/extension-base 1.1.39-beta.0 → 1.1.40-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 +0 -1
- package/cjs/constants/staking.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +1 -16
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/index.js +51 -61
- package/constants/staking.js +1 -1
- package/koni/background/handlers/Extension.d.ts +0 -1
- package/koni/background/handlers/Extension.js +1 -16
- package/package.json +7 -7
- package/packageInfo.js +1 -1
- package/services/chain-service/index.d.ts +3 -7
- package/services/chain-service/index.js +43 -52
- package/services/chain-service/types.d.ts +0 -4
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
|
@@ -1645,7 +1645,6 @@ export interface KoniRequestSignatures {
|
|
|
1645
1645
|
'pri(bonding.nominationPool.submitUnbonding)': [RequestStakePoolingUnbonding, SWTransactionResponse];
|
|
1646
1646
|
'pri(chainService.subscribeChainInfoMap)': [null, Record<string, any>, Record<string, any>];
|
|
1647
1647
|
'pri(chainService.subscribeChainStateMap)': [null, Record<string, any>, Record<string, any>];
|
|
1648
|
-
'pri(chainService.subscribeChainStatusMap)': [null, Record<string, any>, Record<string, any>];
|
|
1649
1648
|
'pri(chainService.subscribeAssetRegistry)': [null, Record<string, any>, Record<string, any>];
|
|
1650
1649
|
'pri(chainService.subscribeMultiChainAssetMap)': [null, Record<string, _MultiChainAsset>, Record<string, _MultiChainAsset>];
|
|
1651
1650
|
'pri(chainService.subscribeXcmRefMap)': [null, Record<string, _AssetRef>, Record<string, _AssetRef>];
|
package/cjs/constants/staking.js
CHANGED
|
@@ -3255,19 +3255,6 @@ class KoniExtension {
|
|
|
3255
3255
|
});
|
|
3256
3256
|
return this.#koniState.getChainStateMap();
|
|
3257
3257
|
}
|
|
3258
|
-
subscribeChainStatusMap(id, port) {
|
|
3259
|
-
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3260
|
-
const chainStateMapSubscription = this.#koniState.chainService.subscribeChainStatusMap().subscribe({
|
|
3261
|
-
next: rs => {
|
|
3262
|
-
cb(rs);
|
|
3263
|
-
}
|
|
3264
|
-
});
|
|
3265
|
-
this.createUnsubscriptionHandle(id, chainStateMapSubscription.unsubscribe);
|
|
3266
|
-
port.onDisconnect.addListener(() => {
|
|
3267
|
-
this.cancelSubscription(id);
|
|
3268
|
-
});
|
|
3269
|
-
return this.#koniState.chainService.getChainStatusMap();
|
|
3270
|
-
}
|
|
3271
3258
|
async subscribeAssetRegistry(id, port) {
|
|
3272
3259
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3273
3260
|
let ready = false;
|
|
@@ -3571,7 +3558,7 @@ class KoniExtension {
|
|
|
3571
3558
|
});
|
|
3572
3559
|
const {
|
|
3573
3560
|
connectionStatus
|
|
3574
|
-
} = this.#koniState.chainService.
|
|
3561
|
+
} = this.#koniState.chainService.getChainStateByKey(_constants2._DEFAULT_MANTA_ZK_CHAIN);
|
|
3575
3562
|
if (connectionStatus !== _types2._ChainConnectionStatus.CONNECTED) {
|
|
3576
3563
|
// TODO: do better
|
|
3577
3564
|
await timeout();
|
|
@@ -4311,8 +4298,6 @@ class KoniExtension {
|
|
|
4311
4298
|
return this.subscribeChainInfoMap(id, port);
|
|
4312
4299
|
case 'pri(chainService.subscribeChainStateMap)':
|
|
4313
4300
|
return this.subscribeChainStateMap(id, port);
|
|
4314
|
-
case 'pri(chainService.subscribeChainStatusMap)':
|
|
4315
|
-
return this.subscribeChainStatusMap(id, port);
|
|
4316
4301
|
case 'pri(chainService.subscribeXcmRefMap)':
|
|
4317
4302
|
return this.subscribeXcmRefMap(id, port);
|
|
4318
4303
|
case 'pri(chainService.getSupportedContractTypes)':
|
package/cjs/packageInfo.js
CHANGED
|
@@ -38,7 +38,6 @@ class ChainService {
|
|
|
38
38
|
// TODO: consider BehaviorSubject
|
|
39
39
|
chainInfoMapSubject = new _rxjs.Subject();
|
|
40
40
|
chainStateMapSubject = new _rxjs.Subject();
|
|
41
|
-
chainStatusMapSubject = new _rxjs.BehaviorSubject({});
|
|
42
41
|
assetRegistrySubject = new _rxjs.Subject();
|
|
43
42
|
multiChainAssetMapSubject = new _rxjs.Subject();
|
|
44
43
|
xcmRefMapSubject = new _rxjs.Subject();
|
|
@@ -112,9 +111,6 @@ class ChainService {
|
|
|
112
111
|
subscribeChainStateMap() {
|
|
113
112
|
return this.chainStateMapSubject;
|
|
114
113
|
}
|
|
115
|
-
subscribeChainStatusMap() {
|
|
116
|
-
return this.chainStatusMapSubject;
|
|
117
|
-
}
|
|
118
114
|
getAssetRegistry() {
|
|
119
115
|
return this.dataMap.assetRegistry;
|
|
120
116
|
}
|
|
@@ -192,12 +188,6 @@ class ChainService {
|
|
|
192
188
|
getChainStateByKey(key) {
|
|
193
189
|
return this.dataMap.chainStateMap[key];
|
|
194
190
|
}
|
|
195
|
-
getChainStatusMap() {
|
|
196
|
-
return this.chainStatusMapSubject.getValue();
|
|
197
|
-
}
|
|
198
|
-
getChainStatusByKey(key) {
|
|
199
|
-
return this.getChainStatusMap()[key];
|
|
200
|
-
}
|
|
201
191
|
getActiveChains() {
|
|
202
192
|
return Object.entries(this.dataMap.chainStateMap).filter(_ref => {
|
|
203
193
|
let [, chainState] = _ref;
|
|
@@ -363,32 +353,9 @@ class ChainService {
|
|
|
363
353
|
this.lockChainInfoMap = false;
|
|
364
354
|
return true;
|
|
365
355
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
(0, _utils2.addLazy)('updateChainConnectionStatus', () => {
|
|
370
|
-
const chainStatusMap = this.getChainStatusMap();
|
|
371
|
-
let update = false;
|
|
372
|
-
Object.entries(this.connectionStatusQueueMap).forEach(_ref3 => {
|
|
373
|
-
let [slug, status] = _ref3;
|
|
374
|
-
if (chainStatusMap[slug]) {
|
|
375
|
-
if (chainStatusMap[slug].connectionStatus !== status) {
|
|
376
|
-
chainStatusMap[slug].connectionStatus = status;
|
|
377
|
-
chainStatusMap[slug].lastUpdated = Date.now();
|
|
378
|
-
update = true;
|
|
379
|
-
}
|
|
380
|
-
} else {
|
|
381
|
-
chainStatusMap[slug] = {
|
|
382
|
-
slug,
|
|
383
|
-
connectionStatus: status,
|
|
384
|
-
lastUpdated: Date.now()
|
|
385
|
-
};
|
|
386
|
-
update = true;
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
this.connectionStatusQueueMap = {};
|
|
390
|
-
update && this.chainStatusMapSubject.next(chainStatusMap);
|
|
391
|
-
});
|
|
356
|
+
setChainConnectionStatus(slug, connectionStatus) {
|
|
357
|
+
const chainStateMap = this.getChainStateMap();
|
|
358
|
+
chainStateMap[slug].connectionStatus = connectionStatus;
|
|
392
359
|
}
|
|
393
360
|
upsertCustomToken(token) {
|
|
394
361
|
if (token.slug.length === 0) {
|
|
@@ -517,8 +484,8 @@ class ChainService {
|
|
|
517
484
|
this.logger.log('Finished updating latest asset ref');
|
|
518
485
|
}
|
|
519
486
|
handleLatestPriceId(latestPriceIds) {
|
|
520
|
-
Object.entries(latestPriceIds).forEach(
|
|
521
|
-
let [slug, priceId] =
|
|
487
|
+
Object.entries(latestPriceIds).forEach(_ref3 => {
|
|
488
|
+
let [slug, priceId] = _ref3;
|
|
522
489
|
if (this.dataMap.assetRegistry[slug]) {
|
|
523
490
|
this.dataMap.assetRegistry[slug].priceId = priceId;
|
|
524
491
|
}
|
|
@@ -543,12 +510,12 @@ class ChainService {
|
|
|
543
510
|
async initApis() {
|
|
544
511
|
const chainInfoMap = this.getChainInfoMap();
|
|
545
512
|
const chainStateMap = this.getChainStateMap();
|
|
546
|
-
await Promise.all(Object.entries(chainInfoMap).filter(
|
|
513
|
+
await Promise.all(Object.entries(chainInfoMap).filter(_ref4 => {
|
|
547
514
|
var _chainStateMap$slug;
|
|
548
|
-
let [slug] =
|
|
515
|
+
let [slug] = _ref4;
|
|
549
516
|
return (_chainStateMap$slug = chainStateMap[slug]) === null || _chainStateMap$slug === void 0 ? void 0 : _chainStateMap$slug.active;
|
|
550
|
-
}).map(
|
|
551
|
-
let [, chainInfo] =
|
|
517
|
+
}).map(_ref5 => {
|
|
518
|
+
let [, chainInfo] = _ref5;
|
|
552
519
|
try {
|
|
553
520
|
return this.initApiForChain(chainInfo);
|
|
554
521
|
} catch (e) {
|
|
@@ -563,8 +530,13 @@ class ChainService {
|
|
|
563
530
|
providerName
|
|
564
531
|
} = this.getChainCurrentProviderByKey(chainInfo.slug);
|
|
565
532
|
const onUpdateStatus = status => {
|
|
566
|
-
const
|
|
567
|
-
|
|
533
|
+
const currentStatus = this.getChainStateByKey(chainInfo.slug).connectionStatus;
|
|
534
|
+
|
|
535
|
+
// Avoid unnecessary update in case disable chain
|
|
536
|
+
if (currentStatus !== status) {
|
|
537
|
+
this.setChainConnectionStatus(chainInfo.slug, status);
|
|
538
|
+
this.updateChainStateMapSubscription();
|
|
539
|
+
}
|
|
568
540
|
};
|
|
569
541
|
if (chainInfo.substrateInfo !== null && chainInfo.substrateInfo !== undefined) {
|
|
570
542
|
if (_constants._MANTA_ZK_CHAIN_GROUP.includes(chainInfo.slug) && _utils2.MODULE_SUPPORT.MANTA_ZK && this.mantaChainHandler) {
|
|
@@ -663,7 +635,7 @@ class ChainService {
|
|
|
663
635
|
this.lockChainInfoMap = true;
|
|
664
636
|
chainStateMap[chainSlug].active = false;
|
|
665
637
|
// Set disconnect state for inactive chain
|
|
666
|
-
|
|
638
|
+
chainStateMap[chainSlug].connectionStatus = _types3._ChainConnectionStatus.DISCONNECTED;
|
|
667
639
|
this.destroyApiForChain(chainInfo);
|
|
668
640
|
this.dbService.updateChainStore({
|
|
669
641
|
...chainInfo,
|
|
@@ -756,9 +728,9 @@ class ChainService {
|
|
|
756
728
|
this.dataMap.chainStateMap[chainInfo.slug] = {
|
|
757
729
|
currentProvider: providerKey,
|
|
758
730
|
slug: chainInfo.slug,
|
|
731
|
+
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
759
732
|
active: _constants._DEFAULT_ACTIVE_CHAINS.includes(chainInfo.slug)
|
|
760
733
|
};
|
|
761
|
-
this.updateChainConnectionStatus(chainInfo.slug, _types3._ChainConnectionStatus.DISCONNECTED);
|
|
762
734
|
|
|
763
735
|
// create data for storage
|
|
764
736
|
newStorageData.push({
|
|
@@ -809,9 +781,9 @@ class ChainService {
|
|
|
809
781
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
810
782
|
currentProvider: selectedProvider,
|
|
811
783
|
slug: storedSlug,
|
|
784
|
+
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
812
785
|
active: canActive && storedChainInfo.active
|
|
813
786
|
};
|
|
814
|
-
this.updateChainConnectionStatus(storedSlug, _types3._ChainConnectionStatus.DISCONNECTED);
|
|
815
787
|
newStorageData.push({
|
|
816
788
|
...mergedChainInfoMap[storedSlug],
|
|
817
789
|
active: canActive && storedChainInfo.active,
|
|
@@ -831,9 +803,9 @@ class ChainService {
|
|
|
831
803
|
this.dataMap.chainStateMap[duplicatedDefaultSlug] = {
|
|
832
804
|
currentProvider: storedChainInfo.currentProvider,
|
|
833
805
|
slug: duplicatedDefaultSlug,
|
|
806
|
+
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
834
807
|
active: storedChainInfo.active
|
|
835
808
|
};
|
|
836
|
-
this.updateChainConnectionStatus(duplicatedDefaultSlug, _types3._ChainConnectionStatus.DISCONNECTED);
|
|
837
809
|
newStorageData.push({
|
|
838
810
|
...mergedChainInfoMap[duplicatedDefaultSlug],
|
|
839
811
|
active: storedChainInfo.active,
|
|
@@ -858,9 +830,9 @@ class ChainService {
|
|
|
858
830
|
currentProvider: storedChainInfo.currentProvider,
|
|
859
831
|
// TODO: review
|
|
860
832
|
slug: storedSlug,
|
|
833
|
+
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
861
834
|
active: storedChainInfo.active
|
|
862
835
|
};
|
|
863
|
-
this.updateChainConnectionStatus(storedSlug, _types3._ChainConnectionStatus.DISCONNECTED);
|
|
864
836
|
newStorageData.push({
|
|
865
837
|
...mergedChainInfoMap[storedSlug],
|
|
866
838
|
active: storedChainInfo.active,
|
|
@@ -873,15 +845,15 @@ class ChainService {
|
|
|
873
845
|
}
|
|
874
846
|
|
|
875
847
|
// Fill in the missing chainState and storageData (new chains never before seen)
|
|
876
|
-
Object.entries(mergedChainInfoMap).forEach(
|
|
877
|
-
let [slug, chainInfo] =
|
|
848
|
+
Object.entries(mergedChainInfoMap).forEach(_ref6 => {
|
|
849
|
+
let [slug, chainInfo] = _ref6;
|
|
878
850
|
if (!(slug in this.dataMap.chainStateMap)) {
|
|
879
851
|
this.dataMap.chainStateMap[slug] = {
|
|
880
852
|
currentProvider: Object.keys(chainInfo.providers)[0],
|
|
881
853
|
slug,
|
|
854
|
+
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
882
855
|
active: _constants._DEFAULT_ACTIVE_CHAINS.includes(slug)
|
|
883
856
|
};
|
|
884
|
-
this.updateChainConnectionStatus(slug, _types3._ChainConnectionStatus.DISCONNECTED);
|
|
885
857
|
newStorageData.push({
|
|
886
858
|
...mergedChainInfoMap[slug],
|
|
887
859
|
active: _constants._DEFAULT_ACTIVE_CHAINS.includes(slug),
|
|
@@ -956,7 +928,9 @@ class ChainService {
|
|
|
956
928
|
}
|
|
957
929
|
}
|
|
958
930
|
updateChainStateMapSubscription() {
|
|
959
|
-
|
|
931
|
+
(0, _utils2.addLazy)('updateChainStateMapSubscription', () => {
|
|
932
|
+
this.chainStateMapSubject.next(this.getChainStateMap());
|
|
933
|
+
}, 300, 900);
|
|
960
934
|
}
|
|
961
935
|
updateChainInfoMapSubscription() {
|
|
962
936
|
this.chainInfoMapSubject.next(this.getChainInfoMap());
|
|
@@ -1065,17 +1039,10 @@ class ChainService {
|
|
|
1065
1039
|
const chainStateMap = this.getChainStateMap();
|
|
1066
1040
|
chainStateMap[newChainSlug] = {
|
|
1067
1041
|
active: true,
|
|
1042
|
+
connectionStatus: _types3._ChainConnectionStatus.DISCONNECTED,
|
|
1068
1043
|
currentProvider: params.chainEditInfo.currentProvider,
|
|
1069
1044
|
slug: newChainSlug
|
|
1070
1045
|
};
|
|
1071
|
-
|
|
1072
|
-
// const chainStatusMap = this.getChainStatusMap();
|
|
1073
|
-
// const chainStatusMap[newChainSlug] = {
|
|
1074
|
-
// slug: newChainSlug,
|
|
1075
|
-
// connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
1076
|
-
// lastUpdated: Date.now()
|
|
1077
|
-
// };
|
|
1078
|
-
|
|
1079
1046
|
await this.initApiForChain(chainInfo);
|
|
1080
1047
|
|
|
1081
1048
|
// create a record in assetRegistry for native token and update store/subscription
|
|
@@ -1360,6 +1327,29 @@ class ChainService {
|
|
|
1360
1327
|
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp()]);
|
|
1361
1328
|
this.checkLatestData();
|
|
1362
1329
|
}
|
|
1330
|
+
checkAndUpdateStatusMapForChain(chainSlug) {
|
|
1331
|
+
const substrateApiMap = this.getSubstrateApiMap();
|
|
1332
|
+
const evmApiMap = this.getEvmApiMap();
|
|
1333
|
+
const chainState = this.getChainStateByKey(chainSlug);
|
|
1334
|
+
let update = false;
|
|
1335
|
+
function updateState(current, status) {
|
|
1336
|
+
if (current.connectionStatus !== status) {
|
|
1337
|
+
current.connectionStatus = status;
|
|
1338
|
+
update = true;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
if (chainState.active) {
|
|
1342
|
+
const api = substrateApiMap[chainSlug] || evmApiMap[chainSlug];
|
|
1343
|
+
if (api) {
|
|
1344
|
+
updateState(chainState, api.isApiConnected ? _types3._ChainConnectionStatus.CONNECTED : _types3._ChainConnectionStatus.DISCONNECTED);
|
|
1345
|
+
}
|
|
1346
|
+
} else {
|
|
1347
|
+
updateState(chainState, _types3._ChainConnectionStatus.DISCONNECTED);
|
|
1348
|
+
}
|
|
1349
|
+
if (update) {
|
|
1350
|
+
this.dataMap.chainStateMap[chainSlug] = chainState;
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1363
1353
|
async initAssetSettings() {
|
|
1364
1354
|
const assetSettings = await this.getAssetSettings();
|
|
1365
1355
|
const activeChainSlugs = this.getActiveChainSlugs();
|
package/constants/staking.js
CHANGED
|
@@ -185,7 +185,6 @@ export default class KoniExtension {
|
|
|
185
185
|
private getListDeriveAccounts;
|
|
186
186
|
private subscribeChainInfoMap;
|
|
187
187
|
private subscribeChainStateMap;
|
|
188
|
-
private subscribeChainStatusMap;
|
|
189
188
|
private subscribeAssetRegistry;
|
|
190
189
|
private subscribeMultiChainAssetMap;
|
|
191
190
|
private subscribeXcmRefMap;
|
|
@@ -3169,19 +3169,6 @@ export default class KoniExtension {
|
|
|
3169
3169
|
});
|
|
3170
3170
|
return this.#koniState.getChainStateMap();
|
|
3171
3171
|
}
|
|
3172
|
-
subscribeChainStatusMap(id, port) {
|
|
3173
|
-
const cb = createSubscription(id, port);
|
|
3174
|
-
const chainStateMapSubscription = this.#koniState.chainService.subscribeChainStatusMap().subscribe({
|
|
3175
|
-
next: rs => {
|
|
3176
|
-
cb(rs);
|
|
3177
|
-
}
|
|
3178
|
-
});
|
|
3179
|
-
this.createUnsubscriptionHandle(id, chainStateMapSubscription.unsubscribe);
|
|
3180
|
-
port.onDisconnect.addListener(() => {
|
|
3181
|
-
this.cancelSubscription(id);
|
|
3182
|
-
});
|
|
3183
|
-
return this.#koniState.chainService.getChainStatusMap();
|
|
3184
|
-
}
|
|
3185
3172
|
async subscribeAssetRegistry(id, port) {
|
|
3186
3173
|
const cb = createSubscription(id, port);
|
|
3187
3174
|
let ready = false;
|
|
@@ -3471,7 +3458,7 @@ export default class KoniExtension {
|
|
|
3471
3458
|
});
|
|
3472
3459
|
const {
|
|
3473
3460
|
connectionStatus
|
|
3474
|
-
} = this.#koniState.chainService.
|
|
3461
|
+
} = this.#koniState.chainService.getChainStateByKey(_DEFAULT_MANTA_ZK_CHAIN);
|
|
3475
3462
|
if (connectionStatus !== _ChainConnectionStatus.CONNECTED) {
|
|
3476
3463
|
// TODO: do better
|
|
3477
3464
|
await timeout();
|
|
@@ -4207,8 +4194,6 @@ export default class KoniExtension {
|
|
|
4207
4194
|
return this.subscribeChainInfoMap(id, port);
|
|
4208
4195
|
case 'pri(chainService.subscribeChainStateMap)':
|
|
4209
4196
|
return this.subscribeChainStateMap(id, port);
|
|
4210
|
-
case 'pri(chainService.subscribeChainStatusMap)':
|
|
4211
|
-
return this.subscribeChainStatusMap(id, port);
|
|
4212
4197
|
case 'pri(chainService.subscribeXcmRefMap)':
|
|
4213
4198
|
return this.subscribeXcmRefMap(id, port);
|
|
4214
4199
|
case 'pri(chainService.getSupportedContractTypes)':
|
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.40-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1745,7 +1745,7 @@
|
|
|
1745
1745
|
"@metaverse-network-sdk/type-definitions": "^0.0.1-13",
|
|
1746
1746
|
"@oak-foundation/types": "^0.0.23",
|
|
1747
1747
|
"@polkadot/api": "^10.11.2",
|
|
1748
|
-
"@polkadot/api-base": "^10.
|
|
1748
|
+
"@polkadot/api-base": "^10.11.2",
|
|
1749
1749
|
"@polkadot/api-contract": "^10.11.2",
|
|
1750
1750
|
"@polkadot/api-derive": "^10.11.2",
|
|
1751
1751
|
"@polkadot/apps-config": "^0.133.1",
|
|
@@ -1762,10 +1762,10 @@
|
|
|
1762
1762
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1763
1763
|
"@substrate/connect": "^0.7.26",
|
|
1764
1764
|
"@subwallet/chain-list": "0.2.42-beta.0",
|
|
1765
|
-
"@subwallet/extension-base": "^1.1.
|
|
1766
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1767
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1768
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1765
|
+
"@subwallet/extension-base": "^1.1.40-1",
|
|
1766
|
+
"@subwallet/extension-chains": "^1.1.40-1",
|
|
1767
|
+
"@subwallet/extension-dapp": "^1.1.40-1",
|
|
1768
|
+
"@subwallet/extension-inject": "^1.1.40-1",
|
|
1769
1769
|
"@subwallet/keyring": "^0.1.3",
|
|
1770
1770
|
"@subwallet/ui-keyring": "^0.1.3",
|
|
1771
1771
|
"@walletconnect/sign-client": "^2.8.4",
|
|
@@ -1802,4 +1802,4 @@
|
|
|
1802
1802
|
"web3-eth-contract": "^1.10.0",
|
|
1803
1803
|
"web3-utils": "^1.10.0"
|
|
1804
1804
|
}
|
|
1805
|
-
}
|
|
1805
|
+
}
|
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.40-1'
|
|
11
11
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
3
3
|
import { AssetSetting, ValidateNetworkResponse } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
5
|
-
import {
|
|
5
|
+
import { _ChainConnectionStatus, _ChainState, _NetworkUpsertParams, _ValidateCustomAssetRequest, _ValidateCustomAssetResponse } from '@subwallet/extension-base/services/chain-service/types';
|
|
6
6
|
import { EventService } from '@subwallet/extension-base/services/event-service';
|
|
7
7
|
import { IMetadataItem } from '@subwallet/extension-base/services/storage-service/databases';
|
|
8
8
|
import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
|
|
@@ -19,7 +19,6 @@ export declare class ChainService {
|
|
|
19
19
|
get mantaPay(): MantaPrivateHandler | undefined;
|
|
20
20
|
private chainInfoMapSubject;
|
|
21
21
|
private chainStateMapSubject;
|
|
22
|
-
private chainStatusMapSubject;
|
|
23
22
|
private assetRegistrySubject;
|
|
24
23
|
private multiChainAssetMapSubject;
|
|
25
24
|
private xcmRefMapSubject;
|
|
@@ -41,7 +40,6 @@ export declare class ChainService {
|
|
|
41
40
|
subscribeMultiChainAssetMap(): Subject<Record<string, _MultiChainAsset>>;
|
|
42
41
|
subscribeXcmRefMap(): Subject<Record<string, _AssetRef>>;
|
|
43
42
|
subscribeChainStateMap(): Subject<Record<string, _ChainState>>;
|
|
44
|
-
subscribeChainStatusMap(): BehaviorSubject<Record<string, _ChainApiStatus>>;
|
|
45
43
|
getAssetRegistry(): Record<string, _ChainAsset>;
|
|
46
44
|
getMultiChainAssetMap(): Record<string, _MultiChainAsset>;
|
|
47
45
|
getSmartContractTokens(): Record<string, _ChainAsset>;
|
|
@@ -53,8 +51,6 @@ export declare class ChainService {
|
|
|
53
51
|
getAssetRefMap(): Record<string, _AssetRef>;
|
|
54
52
|
getChainStateMap(): Record<string, _ChainState>;
|
|
55
53
|
getChainStateByKey(key: string): _ChainState;
|
|
56
|
-
getChainStatusMap(): Record<string, _ChainApiStatus>;
|
|
57
|
-
getChainStatusByKey(key: string): _ChainApiStatus;
|
|
58
54
|
getActiveChains(): string[];
|
|
59
55
|
getSupportedSmartContractTypes(): _AssetType[];
|
|
60
56
|
getActiveChainInfoMap(): Record<string, _ChainInfo>;
|
|
@@ -70,8 +66,7 @@ export declare class ChainService {
|
|
|
70
66
|
forceRemoveChain(slug: string): boolean;
|
|
71
67
|
removeCustomChain(slug: string): boolean;
|
|
72
68
|
resetChainInfoMap(excludedChains?: string[]): boolean;
|
|
73
|
-
|
|
74
|
-
updateChainConnectionStatus(slug: string, connectionStatus: _ChainConnectionStatus): void;
|
|
69
|
+
setChainConnectionStatus(slug: string, connectionStatus: _ChainConnectionStatus): void;
|
|
75
70
|
upsertCustomToken(token: _ChainAsset): string;
|
|
76
71
|
deleteAssetsByChain(chainSlug: string): void;
|
|
77
72
|
deleteCustomAssets(targetAssets: string[]): void;
|
|
@@ -114,6 +109,7 @@ export declare class ChainService {
|
|
|
114
109
|
refreshEvmApi(slug: string): void;
|
|
115
110
|
stopAllChainApis(): Promise<void>;
|
|
116
111
|
resumeAllChainApis(): Promise<void>;
|
|
112
|
+
checkAndUpdateStatusMapForChain(chainSlug: string): void;
|
|
117
113
|
initAssetSettings(): Promise<void>;
|
|
118
114
|
setAssetSettings(assetSettings: Record<string, AssetSetting>, emitEvent?: boolean): void;
|
|
119
115
|
setMantaZkAssetSettings(visible: boolean): void;
|
|
@@ -31,7 +31,6 @@ export class ChainService {
|
|
|
31
31
|
// TODO: consider BehaviorSubject
|
|
32
32
|
chainInfoMapSubject = new Subject();
|
|
33
33
|
chainStateMapSubject = new Subject();
|
|
34
|
-
chainStatusMapSubject = new BehaviorSubject({});
|
|
35
34
|
assetRegistrySubject = new Subject();
|
|
36
35
|
multiChainAssetMapSubject = new Subject();
|
|
37
36
|
xcmRefMapSubject = new Subject();
|
|
@@ -105,9 +104,6 @@ export class ChainService {
|
|
|
105
104
|
subscribeChainStateMap() {
|
|
106
105
|
return this.chainStateMapSubject;
|
|
107
106
|
}
|
|
108
|
-
subscribeChainStatusMap() {
|
|
109
|
-
return this.chainStatusMapSubject;
|
|
110
|
-
}
|
|
111
107
|
getAssetRegistry() {
|
|
112
108
|
return this.dataMap.assetRegistry;
|
|
113
109
|
}
|
|
@@ -185,12 +181,6 @@ export class ChainService {
|
|
|
185
181
|
getChainStateByKey(key) {
|
|
186
182
|
return this.dataMap.chainStateMap[key];
|
|
187
183
|
}
|
|
188
|
-
getChainStatusMap() {
|
|
189
|
-
return this.chainStatusMapSubject.getValue();
|
|
190
|
-
}
|
|
191
|
-
getChainStatusByKey(key) {
|
|
192
|
-
return this.getChainStatusMap()[key];
|
|
193
|
-
}
|
|
194
184
|
getActiveChains() {
|
|
195
185
|
return Object.entries(this.dataMap.chainStateMap).filter(([, chainState]) => _isChainEnabled(chainState)).map(([key]) => key);
|
|
196
186
|
}
|
|
@@ -349,31 +339,9 @@ export class ChainService {
|
|
|
349
339
|
this.lockChainInfoMap = false;
|
|
350
340
|
return true;
|
|
351
341
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
addLazy('updateChainConnectionStatus', () => {
|
|
356
|
-
const chainStatusMap = this.getChainStatusMap();
|
|
357
|
-
let update = false;
|
|
358
|
-
Object.entries(this.connectionStatusQueueMap).forEach(([slug, status]) => {
|
|
359
|
-
if (chainStatusMap[slug]) {
|
|
360
|
-
if (chainStatusMap[slug].connectionStatus !== status) {
|
|
361
|
-
chainStatusMap[slug].connectionStatus = status;
|
|
362
|
-
chainStatusMap[slug].lastUpdated = Date.now();
|
|
363
|
-
update = true;
|
|
364
|
-
}
|
|
365
|
-
} else {
|
|
366
|
-
chainStatusMap[slug] = {
|
|
367
|
-
slug,
|
|
368
|
-
connectionStatus: status,
|
|
369
|
-
lastUpdated: Date.now()
|
|
370
|
-
};
|
|
371
|
-
update = true;
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
this.connectionStatusQueueMap = {};
|
|
375
|
-
update && this.chainStatusMapSubject.next(chainStatusMap);
|
|
376
|
-
});
|
|
342
|
+
setChainConnectionStatus(slug, connectionStatus) {
|
|
343
|
+
const chainStateMap = this.getChainStateMap();
|
|
344
|
+
chainStateMap[slug].connectionStatus = connectionStatus;
|
|
377
345
|
}
|
|
378
346
|
upsertCustomToken(token) {
|
|
379
347
|
if (token.slug.length === 0) {
|
|
@@ -545,8 +513,13 @@ export class ChainService {
|
|
|
545
513
|
providerName
|
|
546
514
|
} = this.getChainCurrentProviderByKey(chainInfo.slug);
|
|
547
515
|
const onUpdateStatus = status => {
|
|
548
|
-
const
|
|
549
|
-
|
|
516
|
+
const currentStatus = this.getChainStateByKey(chainInfo.slug).connectionStatus;
|
|
517
|
+
|
|
518
|
+
// Avoid unnecessary update in case disable chain
|
|
519
|
+
if (currentStatus !== status) {
|
|
520
|
+
this.setChainConnectionStatus(chainInfo.slug, status);
|
|
521
|
+
this.updateChainStateMapSubscription();
|
|
522
|
+
}
|
|
550
523
|
};
|
|
551
524
|
if (chainInfo.substrateInfo !== null && chainInfo.substrateInfo !== undefined) {
|
|
552
525
|
if (_MANTA_ZK_CHAIN_GROUP.includes(chainInfo.slug) && MODULE_SUPPORT.MANTA_ZK && this.mantaChainHandler) {
|
|
@@ -645,7 +618,7 @@ export class ChainService {
|
|
|
645
618
|
this.lockChainInfoMap = true;
|
|
646
619
|
chainStateMap[chainSlug].active = false;
|
|
647
620
|
// Set disconnect state for inactive chain
|
|
648
|
-
|
|
621
|
+
chainStateMap[chainSlug].connectionStatus = _ChainConnectionStatus.DISCONNECTED;
|
|
649
622
|
this.destroyApiForChain(chainInfo);
|
|
650
623
|
this.dbService.updateChainStore({
|
|
651
624
|
...chainInfo,
|
|
@@ -738,9 +711,9 @@ export class ChainService {
|
|
|
738
711
|
this.dataMap.chainStateMap[chainInfo.slug] = {
|
|
739
712
|
currentProvider: providerKey,
|
|
740
713
|
slug: chainInfo.slug,
|
|
714
|
+
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
741
715
|
active: _DEFAULT_ACTIVE_CHAINS.includes(chainInfo.slug)
|
|
742
716
|
};
|
|
743
|
-
this.updateChainConnectionStatus(chainInfo.slug, _ChainConnectionStatus.DISCONNECTED);
|
|
744
717
|
|
|
745
718
|
// create data for storage
|
|
746
719
|
newStorageData.push({
|
|
@@ -791,9 +764,9 @@ export class ChainService {
|
|
|
791
764
|
this.dataMap.chainStateMap[storedSlug] = {
|
|
792
765
|
currentProvider: selectedProvider,
|
|
793
766
|
slug: storedSlug,
|
|
767
|
+
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
794
768
|
active: canActive && storedChainInfo.active
|
|
795
769
|
};
|
|
796
|
-
this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);
|
|
797
770
|
newStorageData.push({
|
|
798
771
|
...mergedChainInfoMap[storedSlug],
|
|
799
772
|
active: canActive && storedChainInfo.active,
|
|
@@ -813,9 +786,9 @@ export class ChainService {
|
|
|
813
786
|
this.dataMap.chainStateMap[duplicatedDefaultSlug] = {
|
|
814
787
|
currentProvider: storedChainInfo.currentProvider,
|
|
815
788
|
slug: duplicatedDefaultSlug,
|
|
789
|
+
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
816
790
|
active: storedChainInfo.active
|
|
817
791
|
};
|
|
818
|
-
this.updateChainConnectionStatus(duplicatedDefaultSlug, _ChainConnectionStatus.DISCONNECTED);
|
|
819
792
|
newStorageData.push({
|
|
820
793
|
...mergedChainInfoMap[duplicatedDefaultSlug],
|
|
821
794
|
active: storedChainInfo.active,
|
|
@@ -840,9 +813,9 @@ export class ChainService {
|
|
|
840
813
|
currentProvider: storedChainInfo.currentProvider,
|
|
841
814
|
// TODO: review
|
|
842
815
|
slug: storedSlug,
|
|
816
|
+
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
843
817
|
active: storedChainInfo.active
|
|
844
818
|
};
|
|
845
|
-
this.updateChainConnectionStatus(storedSlug, _ChainConnectionStatus.DISCONNECTED);
|
|
846
819
|
newStorageData.push({
|
|
847
820
|
...mergedChainInfoMap[storedSlug],
|
|
848
821
|
active: storedChainInfo.active,
|
|
@@ -860,9 +833,9 @@ export class ChainService {
|
|
|
860
833
|
this.dataMap.chainStateMap[slug] = {
|
|
861
834
|
currentProvider: Object.keys(chainInfo.providers)[0],
|
|
862
835
|
slug,
|
|
836
|
+
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
863
837
|
active: _DEFAULT_ACTIVE_CHAINS.includes(slug)
|
|
864
838
|
};
|
|
865
|
-
this.updateChainConnectionStatus(slug, _ChainConnectionStatus.DISCONNECTED);
|
|
866
839
|
newStorageData.push({
|
|
867
840
|
...mergedChainInfoMap[slug],
|
|
868
841
|
active: _DEFAULT_ACTIVE_CHAINS.includes(slug),
|
|
@@ -937,7 +910,9 @@ export class ChainService {
|
|
|
937
910
|
}
|
|
938
911
|
}
|
|
939
912
|
updateChainStateMapSubscription() {
|
|
940
|
-
|
|
913
|
+
addLazy('updateChainStateMapSubscription', () => {
|
|
914
|
+
this.chainStateMapSubject.next(this.getChainStateMap());
|
|
915
|
+
}, 300, 900);
|
|
941
916
|
}
|
|
942
917
|
updateChainInfoMapSubscription() {
|
|
943
918
|
this.chainInfoMapSubject.next(this.getChainInfoMap());
|
|
@@ -1046,17 +1021,10 @@ export class ChainService {
|
|
|
1046
1021
|
const chainStateMap = this.getChainStateMap();
|
|
1047
1022
|
chainStateMap[newChainSlug] = {
|
|
1048
1023
|
active: true,
|
|
1024
|
+
connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
1049
1025
|
currentProvider: params.chainEditInfo.currentProvider,
|
|
1050
1026
|
slug: newChainSlug
|
|
1051
1027
|
};
|
|
1052
|
-
|
|
1053
|
-
// const chainStatusMap = this.getChainStatusMap();
|
|
1054
|
-
// const chainStatusMap[newChainSlug] = {
|
|
1055
|
-
// slug: newChainSlug,
|
|
1056
|
-
// connectionStatus: _ChainConnectionStatus.DISCONNECTED,
|
|
1057
|
-
// lastUpdated: Date.now()
|
|
1058
|
-
// };
|
|
1059
|
-
|
|
1060
1028
|
await this.initApiForChain(chainInfo);
|
|
1061
1029
|
|
|
1062
1030
|
// create a record in assetRegistry for native token and update store/subscription
|
|
@@ -1341,6 +1309,29 @@ export class ChainService {
|
|
|
1341
1309
|
await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp()]);
|
|
1342
1310
|
this.checkLatestData();
|
|
1343
1311
|
}
|
|
1312
|
+
checkAndUpdateStatusMapForChain(chainSlug) {
|
|
1313
|
+
const substrateApiMap = this.getSubstrateApiMap();
|
|
1314
|
+
const evmApiMap = this.getEvmApiMap();
|
|
1315
|
+
const chainState = this.getChainStateByKey(chainSlug);
|
|
1316
|
+
let update = false;
|
|
1317
|
+
function updateState(current, status) {
|
|
1318
|
+
if (current.connectionStatus !== status) {
|
|
1319
|
+
current.connectionStatus = status;
|
|
1320
|
+
update = true;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
if (chainState.active) {
|
|
1324
|
+
const api = substrateApiMap[chainSlug] || evmApiMap[chainSlug];
|
|
1325
|
+
if (api) {
|
|
1326
|
+
updateState(chainState, api.isApiConnected ? _ChainConnectionStatus.CONNECTED : _ChainConnectionStatus.DISCONNECTED);
|
|
1327
|
+
}
|
|
1328
|
+
} else {
|
|
1329
|
+
updateState(chainState, _ChainConnectionStatus.DISCONNECTED);
|
|
1330
|
+
}
|
|
1331
|
+
if (update) {
|
|
1332
|
+
this.dataMap.chainStateMap[chainSlug] = chainState;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1344
1335
|
async initAssetSettings() {
|
|
1345
1336
|
const assetSettings = await this.getAssetSettings();
|
|
1346
1337
|
const activeChainSlugs = this.getActiveChainSlugs();
|
|
@@ -22,11 +22,7 @@ export interface _ChainState {
|
|
|
22
22
|
slug: string;
|
|
23
23
|
active: boolean;
|
|
24
24
|
currentProvider: string;
|
|
25
|
-
}
|
|
26
|
-
export interface _ChainApiStatus {
|
|
27
|
-
slug: string;
|
|
28
25
|
connectionStatus: _ChainConnectionStatus;
|
|
29
|
-
lastUpdated: number;
|
|
30
26
|
}
|
|
31
27
|
export interface _SubstrateDefaultFormatBalance {
|
|
32
28
|
decimals?: number[] | number;
|