@subwallet/extension-base 1.1.68-1 → 1.2.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 +3 -1
- package/background/handlers/State.d.ts +1 -78
- package/background/handlers/State.js +1 -428
- package/background/types.d.ts +1 -0
- package/cjs/background/handlers/State.js +1 -456
- package/cjs/constants/storage.js +3 -1
- package/cjs/koni/api/dotsama/crowdloan.js +1 -2
- package/cjs/koni/api/nft/acala_nft/index.js +1 -3
- package/cjs/koni/api/nft/assethub_nft/index.js +1 -3
- package/cjs/koni/api/nft/assethub_unique/index.js +1 -3
- package/cjs/koni/api/nft/bit.country/index.js +4 -6
- package/cjs/koni/api/nft/config.js +1 -8
- package/cjs/koni/api/nft/evm_nft/index.js +1 -3
- package/cjs/koni/api/nft/karura_nft/index.js +1 -3
- package/cjs/koni/api/nft/ordinal_nft/index.js +4 -3
- package/cjs/koni/api/nft/rmrk_nft/index.js +4 -6
- package/cjs/koni/api/nft/unique_network_nft/index.js +1 -3
- package/cjs/koni/api/nft/unique_nft/uniqueNftV2.js +1 -3
- package/cjs/koni/api/nft/vara_nft/index.js +1 -3
- package/cjs/koni/api/nft/wasm_nft/index.js +10 -17
- package/cjs/koni/api/staking/bonding/astar.js +2 -4
- package/cjs/koni/api/staking/subsquidStaking.js +9 -12
- package/cjs/koni/api/subquery/subquery.js +1 -3
- package/cjs/koni/background/handlers/Extension.js +39 -15
- package/cjs/koni/background/handlers/Mobile.js +7 -4
- package/cjs/koni/background/handlers/State.js +68 -12
- package/cjs/koni/background/handlers/Tabs.js +4 -1
- package/cjs/koni/background/handlers/index.js +71 -71
- package/cjs/koni/background/subscription.js +7 -6
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/helpers.js +3 -1
- package/cjs/services/chain-service/index.js +37 -29
- package/cjs/services/chain-service/utils/patch.js +1 -3
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +1 -2
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +2 -3
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +2 -3
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +1 -2
- package/cjs/services/earning-service/handlers/native-staking/astar.js +3 -4
- package/cjs/services/event-service/index.js +0 -1
- package/cjs/services/history-service/subsquid-multi-chain-history.js +1 -3
- package/cjs/services/keyring-service/index.js +22 -0
- package/cjs/services/migration-service/scripts/MigrateRemoveGenesisHash.js +28 -0
- package/cjs/services/migration-service/scripts/index.js +3 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +16 -21
- package/cjs/services/notification-service/NotificationService.js +3 -1
- package/cjs/services/price-service/coingecko.js +6 -7
- package/cjs/services/price-service/index.js +7 -3
- package/cjs/services/request-service/handler/PopupHandler.js +14 -15
- package/cjs/services/setting-service/SettingService.js +4 -1
- package/cjs/services/setting-service/constants.js +1 -1
- package/cjs/services/setting-service/i18n/i18n.js +2 -4
- package/cjs/services/storage-service/DatabaseService.js +1 -1
- package/cjs/services/storage-service/databases/index.js +14 -1
- package/cjs/services/storage-service/db-stores/KeyValue.js +13 -0
- package/cjs/services/subscan-service/index.js +11 -3
- package/cjs/services/transaction-service/index.js +3 -3
- package/cjs/services/wallet-connect-service/constants.js +2 -2
- package/cjs/services/wallet-connect-service/helpers.js +1 -4
- package/cjs/services/wallet-connect-service/index.js +50 -33
- package/cjs/storage/index.js +120 -23
- package/cjs/types/common/index.js +16 -0
- package/cjs/types/common/storage.js +1 -0
- package/cjs/types/index.js +11 -0
- package/cjs/utils/environment.js +1 -1
- package/cjs/utils/eth/parseTransaction/index.js +8 -10
- package/cjs/utils/fetch.js +55 -0
- package/cjs/utils/fetchStaticCache.js +2 -4
- package/cjs/utils/fetchStaticData.js +7 -4
- package/cjs/utils/index.js +24 -0
- package/cjs/utils/reportError.js +1 -3
- package/constants/storage.d.ts +1 -0
- package/constants/storage.js +1 -0
- package/koni/api/dotsama/crowdloan.js +2 -3
- package/koni/api/nft/acala_nft/index.js +0 -1
- package/koni/api/nft/assethub_nft/index.js +0 -1
- package/koni/api/nft/assethub_unique/index.js +0 -1
- package/koni/api/nft/bit.country/index.js +0 -1
- package/koni/api/nft/config.js +1 -7
- package/koni/api/nft/evm_nft/index.js +0 -1
- package/koni/api/nft/karura_nft/index.js +0 -1
- package/koni/api/nft/ordinal_nft/index.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/index.js +4 -3
- package/koni/api/nft/rmrk_nft/index.js +0 -1
- package/koni/api/nft/unique_network_nft/index.js +0 -1
- package/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
- package/koni/api/nft/vara_nft/index.js +0 -1
- package/koni/api/nft/wasm_nft/index.js +4 -10
- package/koni/api/staking/bonding/astar.js +0 -1
- package/koni/api/staking/subsquidStaking.js +10 -12
- package/koni/api/subquery/subquery.js +0 -1
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +29 -8
- package/koni/background/handlers/Mobile.js +9 -6
- package/koni/background/handlers/State.d.ts +6 -1
- package/koni/background/handlers/State.js +68 -12
- package/koni/background/handlers/Tabs.js +4 -1
- package/koni/background/handlers/index.d.ts +13 -7
- package/koni/background/handlers/index.js +67 -62
- package/koni/background/subscription.js +2 -1
- package/package.json +36 -29
- package/packageInfo.js +1 -1
- package/services/campaign-service/helpers.js +3 -1
- package/services/chain-service/index.js +37 -30
- package/services/chain-service/utils/patch.js +0 -1
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -1
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -1
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -1
- package/services/earning-service/handlers/native-staking/astar.js +0 -1
- package/services/event-service/index.js +0 -1
- package/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/services/keyring-service/index.d.ts +1 -0
- package/services/keyring-service/index.js +19 -0
- package/services/migration-service/scripts/MigrateRemoveGenesisHash.d.ts +4 -0
- package/services/migration-service/scripts/MigrateRemoveGenesisHash.js +20 -0
- package/services/migration-service/scripts/index.js +3 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +17 -21
- package/services/notification-service/NotificationService.js +3 -1
- package/services/price-service/coingecko.js +6 -6
- package/services/price-service/index.js +7 -3
- package/services/request-service/handler/PopupHandler.d.ts +1 -1
- package/services/request-service/handler/PopupHandler.js +14 -15
- package/services/setting-service/SettingService.d.ts +1 -0
- package/services/setting-service/SettingService.js +4 -1
- package/services/setting-service/constants.js +2 -2
- package/services/setting-service/i18n/i18n.js +2 -4
- package/services/storage-service/DatabaseService.js +1 -1
- package/services/storage-service/databases/index.d.ts +8 -0
- package/services/storage-service/databases/index.js +13 -1
- package/services/storage-service/db-stores/KeyValue.d.ts +4 -0
- package/services/storage-service/db-stores/KeyValue.js +5 -0
- package/services/subscan-service/index.d.ts +2 -0
- package/services/subscan-service/index.js +10 -1
- package/services/transaction-service/index.js +4 -4
- package/services/wallet-connect-service/constants.js +3 -3
- package/services/wallet-connect-service/helpers.js +1 -4
- package/services/wallet-connect-service/index.d.ts +2 -0
- package/services/wallet-connect-service/index.js +42 -31
- package/storage/index.d.ts +19 -9
- package/storage/index.js +115 -23
- package/types/common/index.d.ts +1 -0
- package/types/common/index.js +4 -0
- package/types/common/storage.d.ts +4 -0
- package/types/common/storage.js +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/utils/environment.js +1 -1
- package/utils/eth/parseTransaction/index.js +8 -10
- package/utils/fetch.d.ts +8 -0
- package/utils/fetch.js +44 -0
- package/utils/fetchStaticCache.js +2 -3
- package/utils/fetchStaticData.d.ts +1 -1
- package/utils/fetchStaticData.js +7 -4
- package/utils/index.d.ts +2 -0
- package/utils/index.js +2 -0
- package/utils/reportError.js +0 -1
- package/background/handlers/Extension.d.ts +0 -55
- package/background/handlers/Extension.js +0 -601
- package/background/handlers/Tabs.d.ts +0 -24
- package/background/handlers/Tabs.js +0 -194
- package/background/handlers/index.d.ts +0 -3
- package/background/handlers/index.js +0 -45
- package/cjs/background/handlers/Extension.js +0 -642
- package/cjs/background/handlers/Tabs.js +0 -222
- package/cjs/background/handlers/index.js +0 -54
- package/cjs/koni/background/events.js +0 -14
- package/koni/background/events.d.ts +0 -1
- package/koni/background/events.js +0 -7
|
@@ -2,78 +2,83 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { PORT_EXTENSION, PORT_MOBILE } from '@subwallet/extension-base/defaults';
|
|
5
|
-
import { NftHandler } from '@subwallet/extension-base/koni/api/nft';
|
|
6
5
|
import KoniExtension from '@subwallet/extension-base/koni/background/handlers/Extension';
|
|
7
6
|
import Mobile from '@subwallet/extension-base/koni/background/handlers/Mobile';
|
|
8
7
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
9
8
|
import KoniTabs from '@subwallet/extension-base/koni/background/handlers/Tabs';
|
|
10
|
-
|
|
11
|
-
// import Migration from '@subwallet/extension-base/koni/migration';
|
|
12
9
|
import { assert } from '@polkadot/util';
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const from = isExtension ? 'extension' : sender.url || sender.tab && sender.tab.url || '<unknown>';
|
|
48
|
-
const source = `${from}: ${id}: ${message}`;
|
|
49
|
-
|
|
50
|
-
// console.log(` [in] ${source}`); // :: ${JSON.stringify(request)}`);
|
|
51
|
-
|
|
52
|
-
const promise = isMobile ? mobile.handle(id, message, request, port) : isExtension ? extension.handle(id, message, request, port) : tabs.handle(id, message, request, from, port);
|
|
53
|
-
promise.then(response => {
|
|
54
|
-
// console.log(`[out] ${source}`); // :: ${JSON.stringify(response)}`);
|
|
10
|
+
export class SWHandler {
|
|
11
|
+
get state() {
|
|
12
|
+
if (!this._state) {
|
|
13
|
+
this._state = new KoniState();
|
|
14
|
+
}
|
|
15
|
+
return this._state;
|
|
16
|
+
}
|
|
17
|
+
get extensionHandler() {
|
|
18
|
+
if (!this._extensionHandler) {
|
|
19
|
+
this._extensionHandler = new KoniExtension(this.state);
|
|
20
|
+
}
|
|
21
|
+
return this._extensionHandler;
|
|
22
|
+
}
|
|
23
|
+
get tabHandler() {
|
|
24
|
+
if (!this._tabsHandler) {
|
|
25
|
+
this._tabsHandler = new KoniTabs(this.state);
|
|
26
|
+
}
|
|
27
|
+
return this._tabsHandler;
|
|
28
|
+
}
|
|
29
|
+
get mobileHandler() {
|
|
30
|
+
if (!this._mobileHandler) {
|
|
31
|
+
this._mobileHandler = new Mobile(this.state);
|
|
32
|
+
}
|
|
33
|
+
return this._mobileHandler;
|
|
34
|
+
}
|
|
35
|
+
handle({
|
|
36
|
+
id,
|
|
37
|
+
message,
|
|
38
|
+
request
|
|
39
|
+
}, port) {
|
|
40
|
+
const isMobile = port.name === PORT_MOBILE;
|
|
41
|
+
const isExtension = port.name === PORT_EXTENSION;
|
|
42
|
+
const sender = port.sender;
|
|
43
|
+
// console.debug('Handle', message);
|
|
55
44
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
response,
|
|
62
|
-
sender: 'BACKGROUND'
|
|
63
|
-
});
|
|
64
|
-
}).catch(error => {
|
|
65
|
-
console.error(error);
|
|
66
|
-
console.log(`[err] ${source}:: ${error.message}`);
|
|
45
|
+
const from = isExtension ? 'extension' : (sender === null || sender === void 0 ? void 0 : sender.url) || (sender === null || sender === void 0 ? void 0 : sender.tab) && (sender === null || sender === void 0 ? void 0 : sender.tab.url) || '<unknown>';
|
|
46
|
+
const source = `${from}: ${id}: ${message}`;
|
|
47
|
+
const promise = isMobile ? this.mobileHandler.handle(id, message, request, port) : isExtension ? this.extensionHandler.handle(id, message, request, port) : this.tabHandler.handle(id, message, request, from, port);
|
|
48
|
+
promise.then(response => {
|
|
49
|
+
// console.log(`[out] ${source}`); // :: ${JSON.stringify(response)}`);
|
|
67
50
|
|
|
68
|
-
|
|
69
|
-
|
|
51
|
+
// between the start and the end of the promise, the user may have closed
|
|
52
|
+
// the tab, in which case port will be undefined
|
|
53
|
+
assert(port, 'Port has been disconnected');
|
|
70
54
|
port.postMessage({
|
|
71
|
-
error: error.message,
|
|
72
|
-
errorCode: error.code,
|
|
73
|
-
errorData: error.data,
|
|
74
55
|
id,
|
|
56
|
+
response,
|
|
75
57
|
sender: 'BACKGROUND'
|
|
76
58
|
});
|
|
59
|
+
}).catch(error => {
|
|
60
|
+
console.error(error);
|
|
61
|
+
console.log(`[err] ${source}:: ${error.message}`);
|
|
62
|
+
|
|
63
|
+
// only send message back to port if it's still connected
|
|
64
|
+
if (port) {
|
|
65
|
+
port.postMessage({
|
|
66
|
+
error: error.message,
|
|
67
|
+
errorCode: error.code,
|
|
68
|
+
errorData: error.data,
|
|
69
|
+
id,
|
|
70
|
+
sender: 'BACKGROUND'
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Singleton
|
|
77
|
+
|
|
78
|
+
static get instance() {
|
|
79
|
+
if (!SWHandler._instance) {
|
|
80
|
+
SWHandler._instance = new SWHandler();
|
|
77
81
|
}
|
|
78
|
-
|
|
82
|
+
return SWHandler._instance;
|
|
83
|
+
}
|
|
79
84
|
}
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { subscribeCrowdloan } from '@subwallet/extension-base/koni/api/dotsama/crowdloan';
|
|
5
|
-
import {
|
|
5
|
+
import { NftHandler } from '@subwallet/extension-base/koni/api/nft';
|
|
6
6
|
import { COMMON_RELOAD_EVENTS } from '@subwallet/extension-base/services/event-service/types';
|
|
7
7
|
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
8
8
|
import { logger as createLogger } from '@polkadot/util';
|
|
9
|
+
const nftHandler = new NftHandler();
|
|
9
10
|
export class KoniSubscription {
|
|
10
11
|
subscriptionMap = {
|
|
11
12
|
crowdloan: undefined,
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.
|
|
20
|
+
"version": "1.2.1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -59,16 +59,6 @@
|
|
|
59
59
|
"require": "./cjs/background/errors/TransactionError.js",
|
|
60
60
|
"default": "./background/errors/TransactionError.js"
|
|
61
61
|
},
|
|
62
|
-
"./background/handlers": {
|
|
63
|
-
"types": "./background/handlers/index.d.ts",
|
|
64
|
-
"require": "./cjs/background/handlers/index.js",
|
|
65
|
-
"default": "./background/handlers/index.js"
|
|
66
|
-
},
|
|
67
|
-
"./background/handlers/Extension": {
|
|
68
|
-
"types": "./background/handlers/Extension.d.ts",
|
|
69
|
-
"require": "./cjs/background/handlers/Extension.js",
|
|
70
|
-
"default": "./background/handlers/Extension.js"
|
|
71
|
-
},
|
|
72
62
|
"./background/handlers/helpers": {
|
|
73
63
|
"types": "./background/handlers/helpers.d.ts",
|
|
74
64
|
"require": "./cjs/background/handlers/helpers.js",
|
|
@@ -84,11 +74,6 @@
|
|
|
84
74
|
"require": "./cjs/background/handlers/subscriptions.js",
|
|
85
75
|
"default": "./background/handlers/subscriptions.js"
|
|
86
76
|
},
|
|
87
|
-
"./background/handlers/Tabs": {
|
|
88
|
-
"types": "./background/handlers/Tabs.d.ts",
|
|
89
|
-
"require": "./cjs/background/handlers/Tabs.js",
|
|
90
|
-
"default": "./background/handlers/Tabs.js"
|
|
91
|
-
},
|
|
92
77
|
"./background/KoniTypes": {
|
|
93
78
|
"types": "./background/KoniTypes.d.ts",
|
|
94
79
|
"require": "./cjs/background/KoniTypes.js",
|
|
@@ -444,11 +429,6 @@
|
|
|
444
429
|
"require": "./cjs/koni/background/cron.js",
|
|
445
430
|
"default": "./koni/background/cron.js"
|
|
446
431
|
},
|
|
447
|
-
"./koni/background/events": {
|
|
448
|
-
"types": "./koni/background/events.d.ts",
|
|
449
|
-
"require": "./cjs/koni/background/events.js",
|
|
450
|
-
"default": "./koni/background/events.js"
|
|
451
|
-
},
|
|
452
432
|
"./koni/background/handlers": {
|
|
453
433
|
"types": "./koni/background/handlers/index.d.ts",
|
|
454
434
|
"require": "./cjs/koni/background/handlers/index.js",
|
|
@@ -1025,6 +1005,11 @@
|
|
|
1025
1005
|
"require": "./cjs/services/migration-service/scripts/MigrateNetworkSettings.js",
|
|
1026
1006
|
"default": "./services/migration-service/scripts/MigrateNetworkSettings.js"
|
|
1027
1007
|
},
|
|
1008
|
+
"./services/migration-service/scripts/MigrateRemoveGenesisHash": {
|
|
1009
|
+
"types": "./services/migration-service/scripts/MigrateRemoveGenesisHash.d.ts",
|
|
1010
|
+
"require": "./cjs/services/migration-service/scripts/MigrateRemoveGenesisHash.js",
|
|
1011
|
+
"default": "./services/migration-service/scripts/MigrateRemoveGenesisHash.js"
|
|
1012
|
+
},
|
|
1028
1013
|
"./services/migration-service/scripts/MigrateSettings": {
|
|
1029
1014
|
"types": "./services/migration-service/scripts/MigrateSettings.d.ts",
|
|
1030
1015
|
"require": "./cjs/services/migration-service/scripts/MigrateSettings.js",
|
|
@@ -1285,6 +1270,11 @@
|
|
|
1285
1270
|
"require": "./cjs/services/storage-service/db-stores/Crowdloan.js",
|
|
1286
1271
|
"default": "./services/storage-service/db-stores/Crowdloan.js"
|
|
1287
1272
|
},
|
|
1273
|
+
"./services/storage-service/db-stores/KeyValue": {
|
|
1274
|
+
"types": "./services/storage-service/db-stores/KeyValue.d.ts",
|
|
1275
|
+
"require": "./cjs/services/storage-service/db-stores/KeyValue.js",
|
|
1276
|
+
"default": "./services/storage-service/db-stores/KeyValue.js"
|
|
1277
|
+
},
|
|
1288
1278
|
"./services/storage-service/db-stores/MantaPay": {
|
|
1289
1279
|
"types": "./services/storage-service/db-stores/MantaPay.d.ts",
|
|
1290
1280
|
"require": "./cjs/services/storage-service/db-stores/MantaPay.js",
|
|
@@ -1585,6 +1575,16 @@
|
|
|
1585
1575
|
"require": "./cjs/types/campaigns/unlock-dot.js",
|
|
1586
1576
|
"default": "./types/campaigns/unlock-dot.js"
|
|
1587
1577
|
},
|
|
1578
|
+
"./types/common": {
|
|
1579
|
+
"types": "./types/common/index.d.ts",
|
|
1580
|
+
"require": "./cjs/types/common/index.js",
|
|
1581
|
+
"default": "./types/common/index.js"
|
|
1582
|
+
},
|
|
1583
|
+
"./types/common/storage": {
|
|
1584
|
+
"types": "./types/common/storage.d.ts",
|
|
1585
|
+
"require": "./cjs/types/common/storage.js",
|
|
1586
|
+
"default": "./types/common/storage.js"
|
|
1587
|
+
},
|
|
1588
1588
|
"./types/fee": {
|
|
1589
1589
|
"types": "./types/fee/index.d.ts",
|
|
1590
1590
|
"require": "./cjs/types/fee/index.js",
|
|
@@ -1760,6 +1760,11 @@
|
|
|
1760
1760
|
"require": "./cjs/utils/eth/parseTransaction/base.js",
|
|
1761
1761
|
"default": "./utils/eth/parseTransaction/base.js"
|
|
1762
1762
|
},
|
|
1763
|
+
"./utils/fetch": {
|
|
1764
|
+
"types": "./utils/fetch.d.ts",
|
|
1765
|
+
"require": "./cjs/utils/fetch.js",
|
|
1766
|
+
"default": "./utils/fetch.js"
|
|
1767
|
+
},
|
|
1763
1768
|
"./utils/fetchEvmChainInfo": {
|
|
1764
1769
|
"types": "./utils/fetchEvmChainInfo.d.ts",
|
|
1765
1770
|
"require": "./cjs/utils/fetchEvmChainInfo.js",
|
|
@@ -1882,19 +1887,21 @@
|
|
|
1882
1887
|
"@polkadot/ui-settings": "^3.6.6",
|
|
1883
1888
|
"@polkadot/util": "^12.6.2",
|
|
1884
1889
|
"@polkadot/util-crypto": "^12.6.2",
|
|
1890
|
+
"@polkadot/x-global": "^12.2.1",
|
|
1885
1891
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1886
1892
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1887
1893
|
"@substrate/connect": "^0.8.9",
|
|
1888
|
-
"@subwallet/chain-list": "0.2.
|
|
1889
|
-
"@subwallet/extension-base": "^1.
|
|
1890
|
-
"@subwallet/extension-chains": "^1.
|
|
1891
|
-
"@subwallet/extension-dapp": "^1.
|
|
1892
|
-
"@subwallet/extension-inject": "^1.
|
|
1894
|
+
"@subwallet/chain-list": "0.2.65",
|
|
1895
|
+
"@subwallet/extension-base": "^1.2.1",
|
|
1896
|
+
"@subwallet/extension-chains": "^1.2.1",
|
|
1897
|
+
"@subwallet/extension-dapp": "^1.2.1",
|
|
1898
|
+
"@subwallet/extension-inject": "^1.2.1",
|
|
1893
1899
|
"@subwallet/keyring": "^0.1.5",
|
|
1894
1900
|
"@subwallet/ui-keyring": "^0.1.5",
|
|
1895
|
-
"@walletconnect/
|
|
1896
|
-
"@walletconnect/
|
|
1897
|
-
"@walletconnect/
|
|
1901
|
+
"@walletconnect/keyvaluestorage": "^1.1.1",
|
|
1902
|
+
"@walletconnect/sign-client": "^2.11.3",
|
|
1903
|
+
"@walletconnect/types": "^2.11.3",
|
|
1904
|
+
"@walletconnect/utils": "^2.11.3",
|
|
1898
1905
|
"avail-js-sdk": "^0.2.12",
|
|
1899
1906
|
"axios": "^1.6.2",
|
|
1900
1907
|
"bignumber.js": "^9.1.1",
|
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.
|
|
10
|
+
version: '1.2.1'
|
|
11
11
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import { AssetLogoMap, AssetRefMap, ChainAssetMap, ChainInfoMap, ChainLogoMap, MultiChainAssetMap } from '@subwallet/chain-list';
|
|
5
5
|
import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@subwallet/chain-list/types';
|
|
6
|
-
import { _DEFAULT_ACTIVE_CHAINS,
|
|
6
|
+
import { _DEFAULT_ACTIVE_CHAINS, _ZK_ASSET_PREFIX, LATEST_CHAIN_DATA_FETCHING_INTERVAL } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
7
|
import { EvmChainHandler } from '@subwallet/extension-base/services/chain-service/handler/EvmChainHandler';
|
|
8
8
|
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
9
9
|
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
@@ -474,6 +474,7 @@ export class ChainService {
|
|
|
474
474
|
needUpdateChainApiList,
|
|
475
475
|
storedChainInfoList
|
|
476
476
|
} = updateLatestChainInfo(this.dataMap, latestChainInfo);
|
|
477
|
+
console.log('here', needUpdateChainApiList, storedChainInfoList);
|
|
477
478
|
this.dbService.bulkUpdateChainStore(storedChainInfoList).catch(console.error);
|
|
478
479
|
this.updateChainSubscription();
|
|
479
480
|
needUpdateChainApiList.forEach(chainInfo => {
|
|
@@ -577,6 +578,12 @@ export class ChainService {
|
|
|
577
578
|
visible: true
|
|
578
579
|
});
|
|
579
580
|
}
|
|
581
|
+
} else {
|
|
582
|
+
if (originChain === 'avail_mainnet') {
|
|
583
|
+
await this.updateAssetSetting(assetSlug, {
|
|
584
|
+
visible: true
|
|
585
|
+
});
|
|
586
|
+
}
|
|
580
587
|
}
|
|
581
588
|
}
|
|
582
589
|
}
|
|
@@ -638,22 +645,18 @@ export class ChainService {
|
|
|
638
645
|
this.updateChainConnectionStatus(slug, status);
|
|
639
646
|
};
|
|
640
647
|
if (chainInfo.substrateInfo !== null && chainInfo.substrateInfo !== undefined) {
|
|
641
|
-
if (_MANTA_ZK_CHAIN_GROUP.includes(chainInfo.slug) && MODULE_SUPPORT.MANTA_ZK && this.mantaChainHandler) {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
onUpdateStatus
|
|
654
|
-
});
|
|
655
|
-
this.substrateChainHandler.setSubstrateApi(chainInfo.slug, chainApi);
|
|
656
|
-
}
|
|
648
|
+
// if (_MANTA_ZK_CHAIN_GROUP.includes(chainInfo.slug) && MODULE_SUPPORT.MANTA_ZK && this.mantaChainHandler) {
|
|
649
|
+
// const apiPromise = await this.mantaChainHandler?.initMantaPay(endpoint, chainInfo.slug);
|
|
650
|
+
// const chainApi = await this.substrateChainHandler.initApi(chainInfo.slug, endpoint, { providerName, externalApiPromise: apiPromise, onUpdateStatus });
|
|
651
|
+
//
|
|
652
|
+
// this.substrateChainHandler.setSubstrateApi(chainInfo.slug, chainApi);
|
|
653
|
+
// } else {
|
|
654
|
+
const chainApi = await this.substrateChainHandler.initApi(chainInfo.slug, endpoint, {
|
|
655
|
+
providerName,
|
|
656
|
+
onUpdateStatus
|
|
657
|
+
});
|
|
658
|
+
this.substrateChainHandler.setSubstrateApi(chainInfo.slug, chainApi);
|
|
659
|
+
// }
|
|
657
660
|
}
|
|
658
661
|
|
|
659
662
|
/**
|
|
@@ -1000,17 +1003,9 @@ export class ChainService {
|
|
|
1000
1003
|
const storedAssetRegistry = await this.dbService.getAllAssetStore();
|
|
1001
1004
|
const latestAssetRegistry = filterAssetInfoMap(this.getChainInfoMap(), ChainAssetMap);
|
|
1002
1005
|
const availableChains = Object.values(this.dataMap.chainInfoMap).filter(info => info.chainStatus === _ChainStatus.ACTIVE).map(chainInfo => chainInfo.slug);
|
|
1003
|
-
|
|
1004
|
-
// Fill out zk assets from latestAssetRegistry if not supported
|
|
1005
|
-
if (!MODULE_SUPPORT.MANTA_ZK) {
|
|
1006
|
-
Object.keys(latestAssetRegistry).forEach(slug => {
|
|
1007
|
-
if (_isMantaZkAsset(latestAssetRegistry[slug])) {
|
|
1008
|
-
delete latestAssetRegistry[slug];
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1006
|
+
let finalAssetRegistry = {};
|
|
1012
1007
|
if (storedAssetRegistry.length === 0) {
|
|
1013
|
-
|
|
1008
|
+
finalAssetRegistry = latestAssetRegistry;
|
|
1014
1009
|
} else {
|
|
1015
1010
|
const mergedAssetRegistry = latestAssetRegistry;
|
|
1016
1011
|
const parsedStoredAssetRegistry = {};
|
|
@@ -1052,9 +1047,22 @@ export class ChainService {
|
|
|
1052
1047
|
deprecatedAssets.push(storedAssetInfo.slug);
|
|
1053
1048
|
}
|
|
1054
1049
|
}
|
|
1055
|
-
|
|
1050
|
+
finalAssetRegistry = mergedAssetRegistry;
|
|
1056
1051
|
await this.dbService.removeFromAssetStore(deprecatedAssets);
|
|
1057
1052
|
}
|
|
1053
|
+
|
|
1054
|
+
// Fill out zk assets from finalAssetRegistry if not supported
|
|
1055
|
+
if (!MODULE_SUPPORT.MANTA_ZK) {
|
|
1056
|
+
const zkAssets = [];
|
|
1057
|
+
Object.entries(finalAssetRegistry).forEach(([slug, assets]) => {
|
|
1058
|
+
if (_isMantaZkAsset(assets)) {
|
|
1059
|
+
zkAssets.push(slug);
|
|
1060
|
+
delete finalAssetRegistry[slug];
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
await this.dbService.removeFromAssetStore(zkAssets);
|
|
1064
|
+
}
|
|
1065
|
+
this.dataMap.assetRegistry = finalAssetRegistry;
|
|
1058
1066
|
}
|
|
1059
1067
|
updateChainStateMapSubscription() {
|
|
1060
1068
|
this.chainStateMapSubject.next(this.getChainStateMap());
|
|
@@ -1631,8 +1639,7 @@ export class ChainService {
|
|
|
1631
1639
|
const chainInfoMap = this.getChainInfoMap();
|
|
1632
1640
|
Object.values(chainInfoMap).forEach(i => {
|
|
1633
1641
|
var _i$extraInfo;
|
|
1634
|
-
const subscanSlug =
|
|
1635
|
-
|
|
1642
|
+
const subscanSlug = (_i$extraInfo = i.extraInfo) === null || _i$extraInfo === void 0 ? void 0 : _i$extraInfo.subscanSlug;
|
|
1636
1643
|
if (!subscanSlug) {
|
|
1637
1644
|
return;
|
|
1638
1645
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import fetch from 'cross-fetch';
|
|
5
4
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
7
6
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
@@ -5,7 +5,6 @@ import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/K
|
|
|
5
5
|
import { _getTokenOnChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { fakeAddress } from '@subwallet/extension-base/services/earning-service/constants';
|
|
7
7
|
import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
|
|
8
|
-
import fetch from 'cross-fetch';
|
|
9
8
|
import { BN, BN_TEN, BN_ZERO } from '@polkadot/util';
|
|
10
9
|
import BaseLiquidStakingPoolHandler from "./base.js";
|
|
11
10
|
const GRAPHQL_API = 'https://api.polkawallet.io/acala-liquid-staking-subql';
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { _getAssetDecimals, _getTokenOnChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { YieldStepType } from '@subwallet/extension-base/types';
|
|
7
|
-
import fetch from 'cross-fetch';
|
|
8
7
|
import BifrostLiquidStakingPoolHandler from "./bifrost.js";
|
|
9
8
|
const STATS_URL = 'https://api.bifrost.app/api/site';
|
|
10
9
|
const RATIO_URL = 'https://api.bifrost.app/api/omni/MANTA';
|
|
@@ -8,7 +8,6 @@ import { fakeAddress } from '@subwallet/extension-base/services/earning-service/
|
|
|
8
8
|
import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
|
|
9
9
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
10
10
|
import BigNumber from 'bignumber.js';
|
|
11
|
-
import fetch from 'cross-fetch';
|
|
12
11
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
13
12
|
import BaseLiquidStakingPoolHandler from "./base.js";
|
|
14
13
|
const STATS_URL = 'https://api.bifrost.app/api/site';
|
|
@@ -7,7 +7,6 @@ import { getERC20Contract } from '@subwallet/extension-base/koni/api/tokens/evm/
|
|
|
7
7
|
import { _getAssetDecimals, _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
8
|
import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
|
|
9
9
|
import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
|
|
10
|
-
import fetch from 'cross-fetch';
|
|
11
10
|
import { BN, BN_TEN, BN_ZERO } from '@polkadot/util';
|
|
12
11
|
import { ST_LIQUID_TOKEN_ABI } from "../../constants/index.js";
|
|
13
12
|
import BaseLiquidStakingPoolHandler from "./base.js";
|
|
@@ -7,7 +7,6 @@ import { getEarningStatusByNominations } from '@subwallet/extension-base/koni/ap
|
|
|
7
7
|
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
|
|
9
9
|
import { balanceFormatter, formatNumber, isUrl, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
10
|
-
import fetch from 'cross-fetch';
|
|
11
10
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
12
11
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
13
12
|
import BaseParaNativeStakingPoolHandler from "./base-para.js";
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import { ApolloClient, createHttpLink, gql, InMemoryCache } from '@apollo/client';
|
|
5
5
|
import { ChainType, ExtrinsicStatus, ExtrinsicType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { MAX_FETCH_PAGE_PER_SESSION, MIN__NUM_HISTORY_PER_ACCOUNT } from '@subwallet/extension-base/services/history-service/constants';
|
|
7
|
-
import fetch from 'cross-fetch';
|
|
8
7
|
import { isArray } from '@polkadot/util';
|
|
9
8
|
import { decodeAddress, encodeAddress, isEthereumAddress } from '@polkadot/util-crypto';
|
|
10
9
|
const MULTI_CHAIN_URL = 'https://squid.subsquid.io/multi-chain-tx/v/v1/graphql';
|
|
@@ -179,4 +179,23 @@ export class KeyringService {
|
|
|
179
179
|
currentGenesisHash: null
|
|
180
180
|
});
|
|
181
181
|
}
|
|
182
|
+
/* Reset */
|
|
183
|
+
|
|
184
|
+
/* Others */
|
|
185
|
+
removeNoneHardwareGenesisHash() {
|
|
186
|
+
const pairs = keyring.getPairs();
|
|
187
|
+
const needUpdatePairs = pairs.filter(({
|
|
188
|
+
meta: {
|
|
189
|
+
genesisHash,
|
|
190
|
+
isHardware
|
|
191
|
+
}
|
|
192
|
+
}) => !isHardware && genesisHash && genesisHash !== '');
|
|
193
|
+
needUpdatePairs.forEach(pair => {
|
|
194
|
+
keyring.saveAccountMeta(pair, {
|
|
195
|
+
...pair.meta,
|
|
196
|
+
genesisHash: ''
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
/* Others */
|
|
182
201
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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 MigrateRemoveGenesisHash extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
return new Promise(resolve => {
|
|
9
|
+
try {
|
|
10
|
+
this.state.keyringService.removeNoneHardwareGenesisHash();
|
|
11
|
+
} catch (e) {
|
|
12
|
+
console.error(e);
|
|
13
|
+
}
|
|
14
|
+
resolve();
|
|
15
|
+
});
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.error(e);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
import AutoEnableSomeTokens from '@subwallet/extension-base/services/migration-service/scripts/databases/AutoEnableSomeTokens';
|
|
5
5
|
import DeleteEarningData from '@subwallet/extension-base/services/migration-service/scripts/DeleteEarningData';
|
|
6
|
+
import MigrateRemoveGenesisHash from '@subwallet/extension-base/services/migration-service/scripts/MigrateRemoveGenesisHash';
|
|
6
7
|
import MigrateTransactionHistoryBySymbol from '@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol';
|
|
7
8
|
import MigrateAssetSetting from "./databases/MigrateAssetSetting.js";
|
|
8
9
|
import MigrateEarningVersion from "./databases/MigrateEarningVersion.js";
|
|
@@ -49,7 +50,8 @@ export default {
|
|
|
49
50
|
'1.1.41-01': DeleteChainStaking,
|
|
50
51
|
'1.1.46-01': AutoEnableSomeTokens,
|
|
51
52
|
'1.1.62-01': MigrateAssetSetting,
|
|
52
|
-
'1.1.62-02': MigrateTransactionHistoryBySymbol
|
|
53
|
+
'1.1.62-02': MigrateTransactionHistoryBySymbol,
|
|
54
|
+
'1.2.69-01': MigrateRemoveGenesisHash
|
|
53
55
|
// [`${EVERYTIME}-1.1.42-02`]: MigrateTransactionHistoryBySymbol
|
|
54
56
|
// [`${EVERYTIME}-1`]: AutoEnableChainsTokens
|
|
55
57
|
};
|