@subwallet/extension-base 1.1.68-2 → 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.
Files changed (168) hide show
  1. package/background/KoniTypes.d.ts +3 -1
  2. package/background/handlers/State.d.ts +1 -78
  3. package/background/handlers/State.js +1 -428
  4. package/background/types.d.ts +1 -0
  5. package/cjs/background/handlers/State.js +1 -456
  6. package/cjs/constants/storage.js +3 -1
  7. package/cjs/koni/api/dotsama/crowdloan.js +1 -2
  8. package/cjs/koni/api/nft/acala_nft/index.js +1 -3
  9. package/cjs/koni/api/nft/assethub_nft/index.js +1 -3
  10. package/cjs/koni/api/nft/assethub_unique/index.js +1 -3
  11. package/cjs/koni/api/nft/bit.country/index.js +4 -6
  12. package/cjs/koni/api/nft/config.js +1 -8
  13. package/cjs/koni/api/nft/evm_nft/index.js +1 -3
  14. package/cjs/koni/api/nft/karura_nft/index.js +1 -3
  15. package/cjs/koni/api/nft/ordinal_nft/index.js +4 -3
  16. package/cjs/koni/api/nft/rmrk_nft/index.js +4 -6
  17. package/cjs/koni/api/nft/unique_network_nft/index.js +1 -3
  18. package/cjs/koni/api/nft/unique_nft/uniqueNftV2.js +1 -3
  19. package/cjs/koni/api/nft/vara_nft/index.js +1 -3
  20. package/cjs/koni/api/nft/wasm_nft/index.js +10 -17
  21. package/cjs/koni/api/staking/bonding/astar.js +2 -4
  22. package/cjs/koni/api/staking/subsquidStaking.js +9 -12
  23. package/cjs/koni/api/subquery/subquery.js +1 -3
  24. package/cjs/koni/background/handlers/Extension.js +39 -15
  25. package/cjs/koni/background/handlers/Mobile.js +7 -4
  26. package/cjs/koni/background/handlers/State.js +68 -12
  27. package/cjs/koni/background/handlers/Tabs.js +4 -1
  28. package/cjs/koni/background/handlers/index.js +71 -71
  29. package/cjs/koni/background/subscription.js +7 -6
  30. package/cjs/packageInfo.js +1 -1
  31. package/cjs/services/campaign-service/helpers.js +3 -1
  32. package/cjs/services/chain-service/index.js +36 -27
  33. package/cjs/services/chain-service/utils/patch.js +1 -3
  34. package/cjs/services/earning-service/handlers/liquid-staking/acala.js +1 -2
  35. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +2 -3
  36. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +2 -3
  37. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +1 -2
  38. package/cjs/services/earning-service/handlers/native-staking/astar.js +3 -4
  39. package/cjs/services/event-service/index.js +0 -1
  40. package/cjs/services/history-service/subsquid-multi-chain-history.js +1 -3
  41. package/cjs/services/keyring-service/index.js +22 -0
  42. package/cjs/services/migration-service/scripts/MigrateRemoveGenesisHash.js +28 -0
  43. package/cjs/services/migration-service/scripts/index.js +3 -1
  44. package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +16 -21
  45. package/cjs/services/notification-service/NotificationService.js +3 -1
  46. package/cjs/services/price-service/coingecko.js +6 -7
  47. package/cjs/services/price-service/index.js +7 -3
  48. package/cjs/services/request-service/handler/PopupHandler.js +14 -15
  49. package/cjs/services/setting-service/SettingService.js +4 -1
  50. package/cjs/services/setting-service/constants.js +1 -1
  51. package/cjs/services/setting-service/i18n/i18n.js +2 -4
  52. package/cjs/services/storage-service/DatabaseService.js +1 -1
  53. package/cjs/services/storage-service/databases/index.js +14 -1
  54. package/cjs/services/storage-service/db-stores/KeyValue.js +13 -0
  55. package/cjs/services/subscan-service/index.js +11 -3
  56. package/cjs/services/transaction-service/index.js +3 -3
  57. package/cjs/services/wallet-connect-service/constants.js +2 -2
  58. package/cjs/services/wallet-connect-service/helpers.js +1 -4
  59. package/cjs/services/wallet-connect-service/index.js +50 -33
  60. package/cjs/storage/index.js +120 -23
  61. package/cjs/types/common/index.js +16 -0
  62. package/cjs/types/common/storage.js +1 -0
  63. package/cjs/types/index.js +11 -0
  64. package/cjs/utils/environment.js +1 -1
  65. package/cjs/utils/eth/parseTransaction/index.js +8 -10
  66. package/cjs/utils/fetch.js +55 -0
  67. package/cjs/utils/fetchStaticCache.js +2 -4
  68. package/cjs/utils/fetchStaticData.js +7 -4
  69. package/cjs/utils/index.js +24 -0
  70. package/cjs/utils/reportError.js +1 -3
  71. package/constants/storage.d.ts +1 -0
  72. package/constants/storage.js +1 -0
  73. package/koni/api/dotsama/crowdloan.js +2 -3
  74. package/koni/api/nft/acala_nft/index.js +0 -1
  75. package/koni/api/nft/assethub_nft/index.js +0 -1
  76. package/koni/api/nft/assethub_unique/index.js +0 -1
  77. package/koni/api/nft/bit.country/index.js +0 -1
  78. package/koni/api/nft/config.js +1 -7
  79. package/koni/api/nft/evm_nft/index.js +0 -1
  80. package/koni/api/nft/karura_nft/index.js +0 -1
  81. package/koni/api/nft/ordinal_nft/index.d.ts +2 -0
  82. package/koni/api/nft/ordinal_nft/index.js +4 -3
  83. package/koni/api/nft/rmrk_nft/index.js +0 -1
  84. package/koni/api/nft/unique_network_nft/index.js +0 -1
  85. package/koni/api/nft/unique_nft/uniqueNftV2.js +0 -1
  86. package/koni/api/nft/vara_nft/index.js +0 -1
  87. package/koni/api/nft/wasm_nft/index.js +4 -10
  88. package/koni/api/staking/bonding/astar.js +0 -1
  89. package/koni/api/staking/subsquidStaking.js +10 -12
  90. package/koni/api/subquery/subquery.js +0 -1
  91. package/koni/background/handlers/Extension.d.ts +4 -0
  92. package/koni/background/handlers/Extension.js +29 -8
  93. package/koni/background/handlers/Mobile.js +9 -6
  94. package/koni/background/handlers/State.d.ts +6 -1
  95. package/koni/background/handlers/State.js +68 -12
  96. package/koni/background/handlers/Tabs.js +4 -1
  97. package/koni/background/handlers/index.d.ts +13 -7
  98. package/koni/background/handlers/index.js +67 -62
  99. package/koni/background/subscription.js +2 -1
  100. package/package.json +35 -28
  101. package/packageInfo.js +1 -1
  102. package/services/campaign-service/helpers.js +3 -1
  103. package/services/chain-service/index.js +36 -28
  104. package/services/chain-service/utils/patch.js +0 -1
  105. package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
  106. package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +0 -1
  107. package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -1
  108. package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -1
  109. package/services/earning-service/handlers/native-staking/astar.js +0 -1
  110. package/services/event-service/index.js +0 -1
  111. package/services/history-service/subsquid-multi-chain-history.js +0 -1
  112. package/services/keyring-service/index.d.ts +1 -0
  113. package/services/keyring-service/index.js +19 -0
  114. package/services/migration-service/scripts/MigrateRemoveGenesisHash.d.ts +4 -0
  115. package/services/migration-service/scripts/MigrateRemoveGenesisHash.js +20 -0
  116. package/services/migration-service/scripts/index.js +3 -1
  117. package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +17 -21
  118. package/services/notification-service/NotificationService.js +3 -1
  119. package/services/price-service/coingecko.js +6 -6
  120. package/services/price-service/index.js +7 -3
  121. package/services/request-service/handler/PopupHandler.d.ts +1 -1
  122. package/services/request-service/handler/PopupHandler.js +14 -15
  123. package/services/setting-service/SettingService.d.ts +1 -0
  124. package/services/setting-service/SettingService.js +4 -1
  125. package/services/setting-service/constants.js +2 -2
  126. package/services/setting-service/i18n/i18n.js +2 -4
  127. package/services/storage-service/DatabaseService.js +1 -1
  128. package/services/storage-service/databases/index.d.ts +8 -0
  129. package/services/storage-service/databases/index.js +13 -1
  130. package/services/storage-service/db-stores/KeyValue.d.ts +4 -0
  131. package/services/storage-service/db-stores/KeyValue.js +5 -0
  132. package/services/subscan-service/index.d.ts +2 -0
  133. package/services/subscan-service/index.js +10 -1
  134. package/services/transaction-service/index.js +4 -4
  135. package/services/wallet-connect-service/constants.js +3 -3
  136. package/services/wallet-connect-service/helpers.js +1 -4
  137. package/services/wallet-connect-service/index.d.ts +2 -0
  138. package/services/wallet-connect-service/index.js +42 -31
  139. package/storage/index.d.ts +19 -9
  140. package/storage/index.js +115 -23
  141. package/types/common/index.d.ts +1 -0
  142. package/types/common/index.js +4 -0
  143. package/types/common/storage.d.ts +4 -0
  144. package/types/common/storage.js +1 -0
  145. package/types/index.d.ts +1 -0
  146. package/types/index.js +1 -0
  147. package/utils/environment.js +1 -1
  148. package/utils/eth/parseTransaction/index.js +8 -10
  149. package/utils/fetch.d.ts +8 -0
  150. package/utils/fetch.js +44 -0
  151. package/utils/fetchStaticCache.js +2 -3
  152. package/utils/fetchStaticData.d.ts +1 -1
  153. package/utils/fetchStaticData.js +7 -4
  154. package/utils/index.d.ts +2 -0
  155. package/utils/index.js +2 -0
  156. package/utils/reportError.js +0 -1
  157. package/background/handlers/Extension.d.ts +0 -55
  158. package/background/handlers/Extension.js +0 -601
  159. package/background/handlers/Tabs.d.ts +0 -24
  160. package/background/handlers/Tabs.js +0 -194
  161. package/background/handlers/index.d.ts +0 -3
  162. package/background/handlers/index.js +0 -45
  163. package/cjs/background/handlers/Extension.js +0 -642
  164. package/cjs/background/handlers/Tabs.js +0 -222
  165. package/cjs/background/handlers/index.js +0 -54
  166. package/cjs/koni/background/events.js +0 -14
  167. package/koni/background/events.d.ts +0 -1
  168. 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 const state = new KoniState();
14
- export const extension = new KoniExtension(state);
15
- export const tabs = new KoniTabs(state);
16
- export const mobile = new Mobile(state);
17
- export const nftHandler = new NftHandler();
18
-
19
- // Migration
20
- // async function makeSureStateReady () {
21
- // const poll = (resolve: (value: unknown) => void) => {
22
- // if (state.isReady()) {
23
- // resolve(true);
24
- // } else {
25
- // console.log('Waiting for State is ready...');
26
- // setTimeout(() => poll(resolve), 400);
27
- // }
28
- // };
29
- //
30
- // return new Promise(poll);
31
- // }
32
-
33
- // makeSureStateReady().then(() => {
34
- // const migration = new Migration(state);
35
- //
36
- // migration.run().catch((err) => console.warn(err));
37
- // }).catch((e) => console.warn(e));
38
-
39
- export default function handlers({
40
- id,
41
- message,
42
- request
43
- }, port, extensionPortName = PORT_EXTENSION) {
44
- const isMobile = port.name === PORT_MOBILE;
45
- const isExtension = port.name === extensionPortName;
46
- const sender = port.sender;
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
- // between the start and the end of the promise, the user may have closed
57
- // the tab, in which case port will be undefined
58
- assert(port, 'Port has been disconnected');
59
- port.postMessage({
60
- id,
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
- // only send message back to port if it's still connected
69
- if (port) {
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 { nftHandler } from '@subwallet/extension-base/koni/background/handlers';
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.1.68-2",
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
1894
  "@subwallet/chain-list": "0.2.65",
1889
- "@subwallet/extension-base": "^1.1.68-2",
1890
- "@subwallet/extension-chains": "^1.1.68-2",
1891
- "@subwallet/extension-dapp": "^1.1.68-2",
1892
- "@subwallet/extension-inject": "^1.1.68-2",
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/sign-client": "^2.8.4",
1896
- "@walletconnect/types": "^2.8.4",
1897
- "@walletconnect/utils": "^2.8.4",
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.1.68-2'
10
+ version: '1.2.1'
11
11
  };
@@ -21,7 +21,9 @@ export const runCampaign = (notificationService, campaign) => {
21
21
  if (metadata) {
22
22
  const url = metadata.url;
23
23
  if (url) {
24
- window.open(url);
24
+ chrome.tabs.create({
25
+ url
26
+ }).catch(console.error);
25
27
  }
26
28
  }
27
29
  break;
@@ -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, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX, LATEST_CHAIN_DATA_FETCHING_INTERVAL } from '@subwallet/extension-base/services/chain-service/constants';
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
- var _this$mantaChainHandl;
643
- const apiPromise = await ((_this$mantaChainHandl = this.mantaChainHandler) === null || _this$mantaChainHandl === void 0 ? void 0 : _this$mantaChainHandl.initMantaPay(endpoint, chainInfo.slug));
644
- const chainApi = await this.substrateChainHandler.initApi(chainInfo.slug, endpoint, {
645
- providerName,
646
- externalApiPromise: apiPromise,
647
- onUpdateStatus
648
- });
649
- this.substrateChainHandler.setSubstrateApi(chainInfo.slug, chainApi);
650
- } else {
651
- const chainApi = await this.substrateChainHandler.initApi(chainInfo.slug, endpoint, {
652
- providerName,
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
- this.dataMap.assetRegistry = latestAssetRegistry;
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
- this.dataMap.assetRegistry = mergedAssetRegistry;
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());
@@ -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";
@@ -32,7 +32,6 @@ export class EventService extends EventEmitter {
32
32
  generateWaitPromise(eventType) {
33
33
  return new Promise(resolve => {
34
34
  this.once(eventType, isReady => {
35
- console.log('===LOG generateWaitPromise eventType', eventType);
36
35
  resolve(isReady);
37
36
  });
38
37
  });
@@ -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';
@@ -24,4 +24,5 @@ export declare class KeyringService {
24
24
  addInjectAccounts(accounts: InjectedAccountWithMeta[]): void;
25
25
  removeInjectAccounts(_addresses: string[]): void;
26
26
  resetWallet(resetAll: boolean): Promise<void>;
27
+ removeNoneHardwareGenesisHash(): void;
27
28
  }
@@ -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,4 @@
1
+ import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
2
+ export default class MigrateRemoveGenesisHash extends BaseMigrationJob {
3
+ run(): Promise<void>;
4
+ }
@@ -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
  };