@subwallet/extension-base 1.0.1 → 1.0.2-1b

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 (220) hide show
  1. package/background/KoniTypes.d.ts +25 -36
  2. package/background/KoniTypes.js +12 -7
  3. package/background/errors/TransactionError.js +21 -1
  4. package/cjs/background/KoniTypes.js +14 -8
  5. package/cjs/background/errors/TransactionError.js +20 -0
  6. package/cjs/constants/index.js +13 -28
  7. package/cjs/koni/api/dotsama/balance.js +60 -224
  8. package/cjs/koni/api/dotsama/transfer.js +30 -29
  9. package/cjs/koni/api/nft/acala_nft/index.js +4 -1
  10. package/cjs/koni/api/nft/bit.country/index.js +4 -1
  11. package/cjs/koni/api/nft/evm_nft/index.js +7 -3
  12. package/cjs/koni/api/nft/index.js +3 -6
  13. package/cjs/koni/api/nft/karura_nft/index.js +4 -1
  14. package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
  15. package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
  16. package/cjs/koni/api/nft/unique_nft/index.js +6 -1
  17. package/cjs/koni/api/nft/wasm_nft/index.js +169 -111
  18. package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
  19. package/cjs/koni/api/staking/bonding/amplitude.js +18 -10
  20. package/cjs/koni/api/staking/bonding/astar.js +37 -238
  21. package/cjs/koni/api/staking/bonding/index.js +26 -14
  22. package/cjs/koni/api/staking/bonding/paraChain.js +100 -11
  23. package/cjs/koni/api/staking/bonding/relayChain.js +174 -16
  24. package/cjs/koni/api/staking/bonding/utils.js +55 -10
  25. package/cjs/koni/api/tokens/wasm/index.js +5 -4
  26. package/cjs/koni/api/tokens/wasm/utils.js +63 -0
  27. package/cjs/koni/api/xcm/index.js +0 -111
  28. package/cjs/koni/api/xcm/polkadotXcm.js +2 -2
  29. package/cjs/koni/api/xcm/utils.js +18 -13
  30. package/cjs/koni/api/xcm/xTokens.js +3 -5
  31. package/cjs/koni/api/xcm/xcmPallet.js +9 -6
  32. package/cjs/koni/background/cron.js +179 -77
  33. package/cjs/koni/background/handlers/Extension.js +231 -195
  34. package/cjs/koni/background/handlers/State.js +147 -111
  35. package/cjs/koni/background/handlers/Tabs.js +48 -39
  36. package/cjs/koni/background/subscription.js +64 -56
  37. package/cjs/packageInfo.js +1 -1
  38. package/cjs/page/index.js +5 -0
  39. package/cjs/services/chain-service/constants.js +1 -11
  40. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
  41. package/cjs/services/chain-service/handler/light-client/index.js +2 -0
  42. package/cjs/services/chain-service/index.js +39 -6
  43. package/cjs/services/chain-service/utils.js +4 -0
  44. package/cjs/services/event-service/index.js +75 -0
  45. package/cjs/services/event-service/types.js +11 -0
  46. package/cjs/services/history-service/index.js +46 -21
  47. package/cjs/services/history-service/subsquid-multi-chain-history.js +19 -11
  48. package/cjs/services/keyring-service/index.js +101 -0
  49. package/cjs/services/migration-service/index.js +13 -10
  50. package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
  51. package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
  52. package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
  53. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
  54. package/cjs/services/migration-service/scripts/index.js +13 -4
  55. package/cjs/services/price-service/coingecko.js +15 -3
  56. package/cjs/services/price-service/index.js +15 -18
  57. package/cjs/services/request-service/constants.js +8 -2
  58. package/cjs/services/request-service/handler/AuthRequestHandler.js +43 -12
  59. package/cjs/services/request-service/index.js +3 -0
  60. package/cjs/services/storage-service/DatabaseService.js +53 -34
  61. package/cjs/services/storage-service/databases/index.js +1 -1
  62. package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
  63. package/cjs/services/storage-service/db-stores/Nft.js +8 -18
  64. package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
  65. package/cjs/services/subscan-service/index.js +107 -0
  66. package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
  67. package/cjs/services/subscan-service/types.js +1 -0
  68. package/cjs/services/transaction-service/event-parser/index.js +20 -48
  69. package/cjs/services/transaction-service/index.js +66 -22
  70. package/cjs/services/transaction-service/utils.js +4 -6
  71. package/cjs/utils/address.js +9 -1
  72. package/cjs/utils/index.js +30 -26
  73. package/constants/index.d.ts +8 -13
  74. package/constants/index.js +8 -13
  75. package/koni/api/dotsama/balance.d.ts +0 -1
  76. package/koni/api/dotsama/balance.js +33 -197
  77. package/koni/api/dotsama/transfer.js +5 -4
  78. package/koni/api/nft/acala_nft/index.js +3 -1
  79. package/koni/api/nft/bit.country/index.js +3 -1
  80. package/koni/api/nft/evm_nft/index.js +6 -3
  81. package/koni/api/nft/index.d.ts +1 -2
  82. package/koni/api/nft/index.js +3 -6
  83. package/koni/api/nft/karura_nft/index.js +3 -1
  84. package/koni/api/nft/nft.d.ts +1 -0
  85. package/koni/api/nft/rmrk_nft/index.js +8 -1
  86. package/koni/api/nft/statemine_nft/index.js +3 -1
  87. package/koni/api/nft/unique_nft/index.js +5 -1
  88. package/koni/api/nft/wasm_nft/index.d.ts +0 -2
  89. package/koni/api/nft/wasm_nft/index.js +167 -109
  90. package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
  91. package/koni/api/nft/wasm_nft/utils.js +7 -5
  92. package/koni/api/staking/bonding/amplitude.d.ts +1 -2
  93. package/koni/api/staking/bonding/amplitude.js +22 -13
  94. package/koni/api/staking/bonding/astar.d.ts +2 -11
  95. package/koni/api/staking/bonding/astar.js +39 -231
  96. package/koni/api/staking/bonding/index.d.ts +5 -2
  97. package/koni/api/staking/bonding/index.js +27 -17
  98. package/koni/api/staking/bonding/paraChain.d.ts +4 -1
  99. package/koni/api/staking/bonding/paraChain.js +101 -14
  100. package/koni/api/staking/bonding/relayChain.d.ts +6 -2
  101. package/koni/api/staking/bonding/relayChain.js +172 -17
  102. package/koni/api/staking/bonding/utils.d.ts +15 -2
  103. package/koni/api/staking/bonding/utils.js +53 -11
  104. package/koni/api/tokens/wasm/index.js +5 -4
  105. package/koni/api/tokens/wasm/utils.d.ts +6 -0
  106. package/koni/api/tokens/wasm/utils.js +54 -0
  107. package/koni/api/xcm/index.js +1 -112
  108. package/koni/api/xcm/polkadotXcm.js +3 -3
  109. package/koni/api/xcm/utils.d.ts +5 -6
  110. package/koni/api/xcm/utils.js +15 -10
  111. package/koni/api/xcm/xTokens.js +5 -7
  112. package/koni/api/xcm/xcmPallet.js +10 -9
  113. package/koni/background/cron.d.ts +6 -1
  114. package/koni/background/cron.js +179 -76
  115. package/koni/background/handlers/Extension.d.ts +2 -2
  116. package/koni/background/handlers/Extension.js +161 -125
  117. package/koni/background/handlers/State.d.ts +21 -20
  118. package/koni/background/handlers/State.js +144 -111
  119. package/koni/background/handlers/Tabs.js +30 -20
  120. package/koni/background/subscription.d.ts +1 -1
  121. package/koni/background/subscription.js +64 -58
  122. package/package.json +63 -18
  123. package/packageInfo.js +1 -1
  124. package/page/index.d.ts +2 -0
  125. package/page/index.js +4 -0
  126. package/services/chain-service/constants.d.ts +0 -1
  127. package/services/chain-service/constants.js +0 -9
  128. package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
  129. package/services/chain-service/handler/light-client/index.d.ts +17 -1
  130. package/services/chain-service/handler/light-client/index.js +1 -1
  131. package/services/chain-service/helper/psp22_abi.json +1041 -881
  132. package/services/chain-service/helper/psp34_abi.json +2963 -1807
  133. package/services/chain-service/index.d.ts +6 -4
  134. package/services/chain-service/index.js +40 -9
  135. package/services/chain-service/utils.d.ts +1 -0
  136. package/services/chain-service/utils.js +3 -0
  137. package/services/event-service/index.d.ts +22 -0
  138. package/services/event-service/index.js +63 -0
  139. package/services/event-service/types.d.ts +28 -0
  140. package/services/event-service/types.js +4 -0
  141. package/services/history-service/index.d.ts +5 -3
  142. package/services/history-service/index.js +46 -21
  143. package/services/history-service/subsquid-multi-chain-history.js +22 -13
  144. package/services/keyring-service/index.d.ts +19 -0
  145. package/services/keyring-service/index.js +93 -0
  146. package/services/migration-service/index.js +11 -9
  147. package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
  148. package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
  149. package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
  150. package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
  151. package/services/migration-service/scripts/MigrateSettings.js +23 -0
  152. package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
  153. package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
  154. package/services/migration-service/scripts/index.d.ts +1 -0
  155. package/services/migration-service/scripts/index.js +10 -3
  156. package/services/price-service/coingecko.js +15 -3
  157. package/services/price-service/index.d.ts +5 -3
  158. package/services/price-service/index.js +15 -18
  159. package/services/request-service/constants.d.ts +1 -0
  160. package/services/request-service/constants.js +6 -1
  161. package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
  162. package/services/request-service/handler/AuthRequestHandler.js +44 -13
  163. package/services/request-service/index.d.ts +7 -1
  164. package/services/request-service/index.js +3 -0
  165. package/services/storage-service/DatabaseService.d.ts +1 -0
  166. package/services/storage-service/DatabaseService.js +53 -34
  167. package/services/storage-service/databases/index.js +1 -1
  168. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
  169. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
  170. package/services/storage-service/db-stores/Nft.d.ts +3 -3
  171. package/services/storage-service/db-stores/Nft.js +8 -17
  172. package/services/storage-service/db-stores/Transaction.js +10 -7
  173. package/services/subscan-service/index.d.ts +20 -0
  174. package/services/subscan-service/index.js +99 -0
  175. package/services/subscan-service/subscan-chain-map.d.ts +5 -0
  176. package/services/subscan-service/subscan-chain-map.js +63 -0
  177. package/services/subscan-service/types.d.ts +27 -0
  178. package/services/subscan-service/types.js +1 -0
  179. package/services/transaction-service/event-parser/index.d.ts +2 -2
  180. package/services/transaction-service/event-parser/index.js +21 -49
  181. package/services/transaction-service/index.d.ts +4 -2
  182. package/services/transaction-service/index.js +66 -22
  183. package/services/transaction-service/utils.js +5 -6
  184. package/utils/address.d.ts +1 -0
  185. package/utils/address.js +9 -2
  186. package/utils/index.d.ts +2 -1
  187. package/utils/index.js +26 -23
  188. package/cjs/background/errors/EvmRpcError.js +0 -21
  189. package/cjs/background/errors/SubWalletProviderError.js +0 -17
  190. package/cjs/constants/ethereum.js +0 -19
  191. package/cjs/errors/SubWalletProviderError.js +0 -17
  192. package/cjs/koni/api/xcm/astar.js +0 -160
  193. package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
  194. package/cjs/koni/api/xcm/statemintXcm.js +0 -197
  195. package/cjs/koni/api/xcm/substrateXcm.js +0 -213
  196. package/cjs/koni/migration/Base.js +0 -20
  197. package/cjs/koni/migration/index.js +0 -45
  198. package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
  199. package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
  200. package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
  201. package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
  202. package/cjs/koni/migration/scripts/index.js +0 -22
  203. package/cjs/koni/page/index.js +0 -16
  204. package/cjs/services/asset-service/index.js +0 -91
  205. package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
  206. package/cjs/stores/Balance.js +0 -18
  207. package/cjs/stores/Crowdloan.js +0 -18
  208. package/cjs/stores/CustomEvmToken.js +0 -18
  209. package/cjs/stores/NetworkMap.js +0 -18
  210. package/cjs/stores/Nft.js +0 -18
  211. package/cjs/stores/NftCollection.js +0 -18
  212. package/cjs/stores/Price.js +0 -18
  213. package/cjs/stores/Staking.js +0 -18
  214. package/cjs/stores/StakingReward.js +0 -18
  215. package/cjs/utils/eth/parseTransactionData.js +0 -284
  216. package/koni/page/index.d.ts +0 -2
  217. package/koni/page/index.js +0 -9
  218. /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
  219. /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
  220. /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
@@ -14,7 +14,9 @@ var _paraChain = require("@subwallet/extension-base/koni/api/staking/paraChain")
14
14
  var _handlers = require("@subwallet/extension-base/koni/background/handlers");
15
15
  var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
16
16
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
17
+ var _types = require("@subwallet/extension-base/services/event-service/types");
17
18
  var _util = require("@polkadot/util");
19
+ var _utilCrypto = require("@polkadot/util-crypto");
18
20
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
19
21
  // SPDX-License-Identifier: Apache-2.0
20
22
 
@@ -56,34 +58,35 @@ class KoniSubscription {
56
58
  }
57
59
  }
58
60
  start() {
61
+ var _this$state$keyringSe;
59
62
  this.logger.log('Starting subscription');
60
- this.state.getCurrentAccount(currentAccountInfo => {
61
- if (currentAccountInfo) {
62
- const {
63
- address
64
- } = currentAccountInfo;
65
- this.subscribeBalancesAndCrowdloans(address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
66
- this.subscribeStakingOnChain(address, this.state.getSubstrateApiMap());
63
+ const currentAddress = (_this$state$keyringSe = this.state.keyringService.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.address;
64
+ if (currentAddress) {
65
+ this.subscribeBalancesAndCrowdloans(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
66
+ this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
67
+ }
68
+ this.eventHandler = (events, eventTypes) => {
69
+ var _serviceInfo$currentA;
70
+ const serviceInfo = this.state.getServiceInfo();
71
+ const needReload = eventTypes.some(eventType => _types.COMMON_RELOAD_EVENTS.includes(eventType));
72
+ if (!needReload) {
73
+ return;
67
74
  }
68
- });
69
- !this.serviceSubscription && (this.serviceSubscription = this.state.subscribeServiceInfo().subscribe({
70
- next: serviceInfo => {
71
- var _serviceInfo$currentA;
72
- this.logger.log('ServiceInfo updated, restarting...');
73
- const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
74
- if (!address) {
75
- return;
76
- }
77
- this.subscribeBalancesAndCrowdloans(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate, serviceInfo.chainApiMap.evm);
78
- this.subscribeStakingOnChain(address, serviceInfo.chainApiMap.substrate);
75
+ this.logger.log('ServiceInfo updated, restarting...');
76
+ const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
77
+ if (!address) {
78
+ return;
79
79
  }
80
- }));
80
+ this.subscribeBalancesAndCrowdloans(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate, serviceInfo.chainApiMap.evm);
81
+ this.subscribeStakingOnChain(address, serviceInfo.chainApiMap.substrate);
82
+ };
83
+ this.state.eventService.onLazy(this.eventHandler);
81
84
  }
82
85
  stop() {
83
86
  this.logger.log('Stopping subscription');
84
- if (this.serviceSubscription) {
85
- this.serviceSubscription.unsubscribe();
86
- this.serviceSubscription = undefined;
87
+ if (this.eventHandler) {
88
+ this.state.eventService.offLazy(this.eventHandler);
89
+ this.eventHandler = undefined;
87
90
  }
88
91
  this.stopAllSubscription();
89
92
  }
@@ -109,25 +112,22 @@ class KoniSubscription {
109
112
  });
110
113
  }
111
114
  subscribeBalancesAndCrowdloans(address, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime) {
112
- this.state.switchAccount(address).then(() => {
113
- this.state.getDecodedAddresses(address).then(addresses => {
114
- if (!addresses.length) {
115
- return;
116
- }
117
- this.updateSubscription('balance', this.initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime));
118
- this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
119
- }).catch(this.logger.error);
115
+ this.state.handleSwitchAccount(address).then(() => {
116
+ const addresses = this.state.getDecodedAddresses(address);
117
+ if (!addresses.length) {
118
+ return;
119
+ }
120
+ this.updateSubscription('balance', this.initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime));
121
+ this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
120
122
  }).catch(err => this.logger.warn(err));
121
123
  }
122
124
  subscribeStakingOnChain(address, substrateApiMap, onlyRunOnFirstTime) {
123
- this.state.resetStaking(address).then(() => {
124
- this.state.getDecodedAddresses(address).then(addresses => {
125
- if (!addresses.length) {
126
- return;
127
- }
128
- this.updateSubscription('stakingOnChain', this.initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
129
- }).catch(this.logger.error);
130
- }).catch(err => this.logger.warn(err));
125
+ this.state.resetStaking(address);
126
+ const addresses = this.state.getDecodedAddresses(address);
127
+ if (!addresses.length) {
128
+ return;
129
+ }
130
+ this.updateSubscription('stakingOnChain', this.initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
131
131
  }
132
132
  initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime) {
133
133
  const unsub = (0, _staking.stakingOnChainApi)(addresses, substrateApiMap, (networkKey, rs) => {
@@ -143,9 +143,9 @@ class KoniSubscription {
143
143
  }
144
144
  initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, evmApiMap, onlyRunOnFirstTime) {
145
145
  const filteredChainInfoMap = {};
146
- Object.values(chainInfoMap).forEach(chainInfo => {
147
- if (chainStateMap[chainInfo.slug].active) {
148
- filteredChainInfoMap[chainInfo.slug] = chainInfo;
146
+ Object.values(chainStateMap).forEach(chainState => {
147
+ if (chainState.active) {
148
+ filteredChainInfoMap[chainState.slug] = chainInfoMap[chainState.slug];
149
149
  }
150
150
  });
151
151
  const unsub = (0, _balance.subscribeBalance)(addresses, filteredChainInfoMap, substrateApiMap, evmApiMap, result => {
@@ -172,12 +172,11 @@ class KoniSubscription {
172
172
  };
173
173
  }
174
174
  subscribeNft(address, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
175
- this.state.getDecodedAddresses(address).then(addresses => {
176
- if (!addresses.length) {
177
- return;
178
- }
179
- this.initNftSubscription(addresses, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap);
180
- }).catch(this.logger.error);
175
+ const addresses = this.state.getDecodedAddresses(address);
176
+ if (!addresses.length) {
177
+ return;
178
+ }
179
+ this.initNftSubscription(addresses, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap);
181
180
  }
182
181
  initNftSubscription(addresses, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
183
182
  var _this = this;
@@ -189,12 +188,12 @@ class KoniSubscription {
189
188
  return _this.state.updateNftData(...arguments);
190
189
  }, function () {
191
190
  return _this.state.setNftCollection(...arguments);
192
- }).then(() => {
193
- this.logger.log('nft state updated');
191
+ }, function () {
192
+ return _this.state.cleanUpNfts(...arguments);
194
193
  }).catch(this.logger.log);
195
194
  }
196
195
  async subscribeStakingReward(address) {
197
- const addresses = await this.state.getDecodedAddresses(address);
196
+ const addresses = this.state.getDecodedAddresses(address);
198
197
  if (!addresses.length) {
199
198
  return;
200
199
  }
@@ -209,10 +208,9 @@ class KoniSubscription {
209
208
  });
210
209
  const result = await (0, _staking.getNominationStakingRewardData)(addresses, targetNetworkMap);
211
210
  this.state.updateStakingReward(result, 'slowInterval');
212
- this.logger.log('Set staking reward state done', result);
213
211
  }
214
212
  async subscribeStakingRewardFastInterval(address) {
215
- const addresses = await this.state.getDecodedAddresses(address);
213
+ const addresses = this.state.getDecodedAddresses(address);
216
214
  if (!addresses.length) {
217
215
  return;
218
216
  }
@@ -239,15 +237,21 @@ class KoniSubscription {
239
237
  const [poolingStakingRewards, amplitudeUnclaimedStakingRewards] = await Promise.all([(0, _staking.getPoolingStakingRewardData)(pooledAddresses, targetChainMap, this.state.getSubstrateApiMap()), (0, _paraChain.getAmplitudeUnclaimedStakingReward)(this.state.getSubstrateApiMap(), addresses, chainInfoMap, activeNetworks)]);
240
238
  const result = [...poolingStakingRewards, ...amplitudeUnclaimedStakingRewards];
241
239
  this.state.updateStakingReward(result, 'fastInterval');
242
- this.logger.log('Set staking reward state with fast interval done', result);
243
240
  }
244
241
  async fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap) {
245
- await Promise.all(Object.values(chainInfoMap).map(async chainInfo => {
242
+ const filteredChainInfoMap = {};
243
+ Object.values(chainInfoMap).forEach(chainInfo => {
246
244
  const chainState = chainStateMap[chainInfo.slug];
247
245
  if (chainState !== null && chainState !== void 0 && chainState.active && (0, _utils._isChainSupportSubstrateStaking)(chainInfo)) {
248
- const chainStakingMetadata = await (0, _bonding.getChainStakingMetadata)(chainInfo.slug, substrateApiMap[chainInfo.slug]);
249
- this.state.updateChainStakingMetadata(chainStakingMetadata);
246
+ filteredChainInfoMap[chainInfo.slug] = chainInfo;
250
247
  }
248
+ });
249
+ if (Object.values(filteredChainInfoMap).length === 0) {
250
+ return;
251
+ }
252
+ await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
253
+ const chainStakingMetadata = await (0, _bonding.getChainStakingMetadata)(chainInfo, substrateApiMap[chainInfo.slug]);
254
+ this.state.updateChainStakingMetadata(chainStakingMetadata);
251
255
  }));
252
256
  }
253
257
  async fetchNominatorMetadata(currentAddress, chainInfoMap, chainStateMap, substrateApiMap) {
@@ -263,7 +267,11 @@ class KoniSubscription {
263
267
  addresses = await this.state.getStakingOwnersByChains(Object.keys(filteredChainInfoMap));
264
268
  }
265
269
  await Promise.all(addresses.map(async address => {
270
+ const isEvmAddress = (0, _utilCrypto.isEthereumAddress)(address);
266
271
  await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
272
+ if (isEvmAddress && !(0, _utils._isChainEvmCompatible)(chainInfo)) {
273
+ return;
274
+ }
267
275
  if ((0, _utils._isSubstrateRelayChain)(chainInfo) && _constants2._STAKING_CHAIN_GROUP.nominationPool.includes(chainInfo.slug)) {
268
276
  const poolMemberMetadata = await (0, _relayChain.getRelayChainPoolMemberMetadata)(chainInfo, address, substrateApiMap[chainInfo.slug]);
269
277
  if (poolMemberMetadata) {
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.0.1'
16
+ version: '1.0.2-1'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
package/cjs/page/index.js CHANGED
@@ -6,9 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.enable = enable;
8
8
  exports.handleResponse = handleResponse;
9
+ exports.initEvmProvider = initEvmProvider;
9
10
  exports.sendMessage = sendMessage;
10
11
  var _ProviderError = require("@subwallet/extension-base/background/errors/ProviderError");
11
12
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
13
+ var _SubWalleEvmProvider = require("@subwallet/extension-base/page/SubWalleEvmProvider");
12
14
  var _defaults = require("../defaults");
13
15
  var _getId = require("../utils/getId");
14
16
  var _Injected = _interopRequireDefault(require("./Injected"));
@@ -62,4 +64,7 @@ function handleResponse(data) {
62
64
  } else {
63
65
  handler.resolve(data.response);
64
66
  }
67
+ }
68
+ function initEvmProvider(version) {
69
+ return new _SubWalleEvmProvider.SubWalletEvmProvider(sendMessage, version);
65
70
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports._XCM_TYPE = exports._XCM_CHAIN_USE_LIMITED_WEIGHT = exports._XCM_CHAIN_GROUP = exports._TRANSFER_NOT_SUPPORTED_CHAINS = exports._TRANSFER_CHAIN_GROUP = exports._SUBSTRATE_DEFAULT_INFLATION_PARAMS = exports._STAKING_ERA_LENGTH_MAP = exports._STAKING_CHAIN_GROUP = exports._PURE_EVM_CHAINS = exports._PREDEFINED_SINGLE_MODES = exports._PARACHAIN_INFLATION_DISTRIBUTION = exports._NFT_CHAIN_GROUP = exports._KNOWN_CHAIN_INFLATION_PARAMS = exports._DEFAULT_ACTIVE_CHAINS = exports._BALANCE_TOKEN_GROUP = exports._BALANCE_PARSING_CHAIN_GROUP = exports._BALANCE_CHAIN_GROUP = exports._API_OPTIONS_CHAIN_GROUP = exports.API_MAX_RETRY = exports.API_AUTO_CONNECT_MS = void 0;
6
+ exports._XCM_TYPE = exports._XCM_CHAIN_GROUP = exports._TRANSFER_NOT_SUPPORTED_CHAINS = exports._TRANSFER_CHAIN_GROUP = exports._SUBSTRATE_DEFAULT_INFLATION_PARAMS = exports._STAKING_ERA_LENGTH_MAP = exports._STAKING_CHAIN_GROUP = exports._PURE_EVM_CHAINS = exports._PREDEFINED_SINGLE_MODES = exports._PARACHAIN_INFLATION_DISTRIBUTION = exports._NFT_CHAIN_GROUP = exports._KNOWN_CHAIN_INFLATION_PARAMS = exports._DEFAULT_ACTIVE_CHAINS = exports._BALANCE_TOKEN_GROUP = exports._BALANCE_PARSING_CHAIN_GROUP = exports._BALANCE_CHAIN_GROUP = exports._API_OPTIONS_CHAIN_GROUP = exports.API_MAX_RETRY = exports.API_AUTO_CONNECT_MS = void 0;
7
7
  var _chainList = require("@subwallet/chain-list");
8
8
  var _types = require("@subwallet/chain-list/types");
9
9
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
@@ -207,18 +207,8 @@ const _XCM_CHAIN_GROUP = {
207
207
  polkadotXcm: ['astar', 'shiden', 'statemine', 'statemint'],
208
208
  xcmPallet: ['polkadot', 'kusama']
209
209
  // default is xTokens pallet
210
- // moonbeam: ['moonbeam', 'moonriver', 'moonbase'],
211
- // astar: ['astar', 'shiden'],
212
- // statemine: ['statemint', 'statemine'],
213
- // bifrost: ['bifrost'],
214
- // genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
215
- // kintsugi: ['kintsugi', 'kintsugi_test', 'interlay'],
216
- // acala: ['karura', 'acala', 'acala_testnet'],
217
- // astarEvm: ['astarEvm', 'shidenEvm']
218
210
  };
219
211
  exports._XCM_CHAIN_GROUP = _XCM_CHAIN_GROUP;
220
- const _XCM_CHAIN_USE_LIMITED_WEIGHT = ['acala', 'karura', 'statemint'];
221
- exports._XCM_CHAIN_USE_LIMITED_WEIGHT = _XCM_CHAIN_USE_LIMITED_WEIGHT;
222
212
  const _XCM_TYPE = {
223
213
  RP: `${_types._SubstrateChainType.RELAYCHAIN}-${_types._SubstrateChainType.PARACHAIN}`,
224
214
  // DMP
@@ -7,6 +7,7 @@ exports.SubstrateChainHandler = exports.DEFAULT_AUX = void 0;
7
7
  var _api = require("@acala-network/api");
8
8
  var _types = require("@oak-foundation/types");
9
9
  var _types2 = require("@subwallet/chain-list/types");
10
+ var _utils = require("@subwallet/extension-base/koni/api/tokens/wasm/utils");
10
11
  var _lightClient = require("@subwallet/extension-base/services/chain-service/handler/light-client");
11
12
  var _api2 = require("@polkadot/api");
12
13
  var _apiContract = require("@polkadot/api-contract");
@@ -94,13 +95,13 @@ class SubstrateChainHandler {
94
95
  if (tokenType === _types2._AssetType.PSP22) {
95
96
  tokenContract = new _apiContract.ContractPromise(substrateApi.api, _helper._PSP22_ABI, contractAddress);
96
97
  const [nameResp, symbolResp, decimalsResp] = await Promise.all([tokenContract.query['psp22Metadata::tokenName'](contractCaller || contractAddress, {
97
- gasLimit: -1
98
+ gasLimit: (0, _utils.getDefaultWeightV2)(substrateApi.api)
98
99
  }),
99
100
  // read-only operation so no gas limit
100
101
  tokenContract.query['psp22Metadata::tokenSymbol'](contractCaller || contractAddress, {
101
- gasLimit: -1
102
+ gasLimit: (0, _utils.getDefaultWeightV2)(substrateApi.api)
102
103
  }), tokenContract.query['psp22Metadata::tokenDecimals'](contractCaller || contractAddress, {
103
- gasLimit: -1
104
+ gasLimit: (0, _utils.getDefaultWeightV2)(substrateApi.api)
104
105
  })]);
105
106
  if (!(nameResp.result.isOk && symbolResp.result.isOk && decimalsResp.result.isOk) || !nameResp.output || !decimalsResp.output || !symbolResp.output) {
106
107
  this.logger.error('Error response while validating WASM contract');
@@ -111,18 +112,22 @@ class SubstrateChainHandler {
111
112
  contractError: true
112
113
  };
113
114
  } else {
114
- var _symbolResp$output, _decimalsResp$output, _symbolResp$output2;
115
- name = (_symbolResp$output = symbolResp.output) === null || _symbolResp$output === void 0 ? void 0 : _symbolResp$output.toHuman();
116
- decimals = parseInt((_decimalsResp$output = decimalsResp.output) === null || _decimalsResp$output === void 0 ? void 0 : _decimalsResp$output.toHuman());
117
- symbol = (_symbolResp$output2 = symbolResp.output) === null || _symbolResp$output2 === void 0 ? void 0 : _symbolResp$output2.toHuman();
115
+ var _symbolResp$output, _decimalsResp$output, _nameResp$output;
116
+ const symbolObj = (_symbolResp$output = symbolResp.output) === null || _symbolResp$output === void 0 ? void 0 : _symbolResp$output.toHuman();
117
+ const decimalsObj = (_decimalsResp$output = decimalsResp.output) === null || _decimalsResp$output === void 0 ? void 0 : _decimalsResp$output.toHuman();
118
+ const nameObj = (_nameResp$output = nameResp.output) === null || _nameResp$output === void 0 ? void 0 : _nameResp$output.toHuman();
119
+ name = nameResp.output ? nameObj.Ok || nameObj.ok : '';
120
+ decimals = decimalsResp.output ? new _util.BN(decimalsObj.Ok || decimalsObj.ok).toNumber() : 0;
121
+ symbol = decimalsResp.output ? symbolObj.Ok || symbolObj.ok : '';
118
122
  if (name === '' || symbol === '') {
119
123
  contractError = true;
120
124
  }
125
+ console.log('validate PSP22', name, symbol, decimals);
121
126
  }
122
127
  } else {
123
128
  tokenContract = new _apiContract.ContractPromise(substrateApi.api, _helper._PSP34_ABI, contractAddress);
124
129
  const collectionIdResp = await tokenContract.query['psp34::collectionId'](contractCaller || contractAddress, {
125
- gasLimit: -1
130
+ gasLimit: (0, _utils.getDefaultWeightV2)(substrateApi.api)
126
131
  }); // read-only operation so no gas limit
127
132
 
128
133
  if (!collectionIdResp.result.isOk || !collectionIdResp.output) {
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.ProviderPlaceholder = void 0;
6
7
  exports.getSubstrateConnectProvider = getSubstrateConnectProvider;
7
8
  exports.relayChainSpecs = exports.paraChainSpecs = void 0;
8
9
  var _rpcProvider = require("@polkadot/rpc-provider");
@@ -103,6 +104,7 @@ class ProviderPlaceholder {
103
104
  });
104
105
  }
105
106
  }
107
+ exports.ProviderPlaceholder = ProviderPlaceholder;
106
108
  function getSubstrateConnectProvider(specLink) {
107
109
  const [relayName, paraName] = specLink.split('/');
108
110
  const relaySpec = relayChainSpecs[relayName];
@@ -28,8 +28,6 @@ class ChainService {
28
28
  assetRegistry: {},
29
29
  assetRefMap: {}
30
30
  };
31
- // to save chain, token settings from user
32
-
33
31
  lockChainInfoMap = false; // prevent unwanted changes (edit, enable, disable) to chainInfoMap
34
32
 
35
33
  // TODO: consider BehaviorSubject
@@ -42,8 +40,9 @@ class ChainService {
42
40
  // Todo: Update to new store indexed DB
43
41
  store = new _AssetSetting.default();
44
42
  assetSettingSubject = new _rxjs.BehaviorSubject({});
45
- constructor(dbService) {
43
+ constructor(dbService, eventService) {
46
44
  this.dbService = dbService;
45
+ this.eventService = eventService;
47
46
  this.substrateChainHandler = new _SubstrateChainHandler.SubstrateChainHandler();
48
47
  this.evmChainHandler = new _EvmChainHandler.EvmChainHandler();
49
48
  this.chainInfoMapSubject.next(this.dataMap.chainInfoMap);
@@ -217,9 +216,13 @@ class ChainService {
217
216
  return this.getAssetRegistry()[slug];
218
217
  }
219
218
  getFungibleTokensByChain(chainSlug) {
219
+ let checkActive = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
220
220
  const result = {};
221
+ const assetSettings = this.assetSettingSubject.value;
221
222
  Object.values(this.getAssetRegistry()).forEach(chainAsset => {
222
- if (chainAsset.originChain === chainSlug && (0, _utils._isAssetFungibleToken)(chainAsset)) {
223
+ var _assetSettings$chainA;
224
+ const _filterActive = !checkActive || ((_assetSettings$chainA = assetSettings[chainAsset.slug]) === null || _assetSettings$chainA === void 0 ? void 0 : _assetSettings$chainA.visible);
225
+ if (chainAsset.originChain === chainSlug && (0, _utils._isAssetFungibleToken)(chainAsset) && _filterActive) {
223
226
  result[chainAsset.slug] = chainAsset;
224
227
  }
225
228
  });
@@ -283,6 +286,7 @@ class ChainService {
283
286
  this.dbService.removeFromChainStore([slug]).catch(console.error);
284
287
  this.updateChainSubscription();
285
288
  this.lockChainInfoMap = false;
289
+ this.eventService.emit('chain.updateState', slug);
286
290
  return true;
287
291
  }
288
292
  resetChainInfoMap(excludedChains) {
@@ -316,6 +320,10 @@ class ChainService {
316
320
  token.slug = `${_types3._CUSTOM_PREFIX}${defaultSlug}`;
317
321
  }
318
322
  }
323
+ if (token.originChain && (0, _utils._isAssetFungibleToken)(token)) {
324
+ var _this$getChainInfoByK;
325
+ token.hasValue = !((_this$getChainInfoByK = this.getChainInfoByKey(token.originChain)) !== null && _this$getChainInfoByK !== void 0 && _this$getChainInfoByK.isTestnet);
326
+ }
319
327
  const assetRegistry = this.getAssetRegistry();
320
328
  assetRegistry[token.slug] = token;
321
329
  this.dbService.updateAssetStore(token).catch(e => this.logger.error(e));
@@ -343,6 +351,9 @@ class ChainService {
343
351
  this.dbService.removeFromBalanceStore(targetAssets).catch(e => this.logger.error(e));
344
352
  this.dbService.removeFromAssetStore(targetAssets).catch(e => this.logger.error(e));
345
353
  this.assetRegistrySubject.next(assetRegistry);
354
+ targetAssets.forEach(assetSlug => {
355
+ this.eventService.emit('asset.updateState', assetSlug);
356
+ });
346
357
  }
347
358
 
348
359
  // Business logic
@@ -415,6 +426,7 @@ class ChainService {
415
426
  currentProvider: chainStateMap[chainSlug].currentProvider
416
427
  }).catch(console.error);
417
428
  this.lockChainInfoMap = false;
429
+ this.eventService.emit('chain.updateState', chainSlug);
418
430
  return true;
419
431
  }
420
432
  enableChain(chainSlug) {
@@ -449,6 +461,7 @@ class ChainService {
449
461
  }).catch(console.error);
450
462
  this.updateChainStateMapSubscription();
451
463
  this.lockChainInfoMap = false;
464
+ this.eventService.emit('chain.updateState', chainSlug);
452
465
  return true;
453
466
  }
454
467
  checkExistedPredefinedChain(genesisHash, evmChainId) {
@@ -671,6 +684,8 @@ class ChainService {
671
684
  ...targetChainInfo,
672
685
  active: targetChainState.active,
673
686
  currentProvider: targetChainState.currentProvider
687
+ }).then(() => {
688
+ this.eventService.emit('chain.updateState', chainSlug);
674
689
  }).catch(e => this.logger.error(e));
675
690
  }
676
691
  insertChain(params) {
@@ -755,6 +770,8 @@ class ChainService {
755
770
  active: true,
756
771
  currentProvider: params.chainEditInfo.currentProvider,
757
772
  ...chainInfo
773
+ }).then(() => {
774
+ this.eventService.emit('chain.add', newChainSlug);
758
775
  }).catch(e => this.logger.error(e));
759
776
  return nativeTokenSlug;
760
777
  }
@@ -1100,12 +1117,25 @@ class ChainService {
1100
1117
  };
1101
1118
  }
1102
1119
  });
1103
- this.setAssetSettings(assetSettings);
1120
+ this.setAssetSettings(assetSettings, false);
1104
1121
  }
1105
- console.log('Done init asset settings');
1122
+ this.eventService.emit('asset.ready', true);
1106
1123
  }
1107
1124
  setAssetSettings(assetSettings) {
1125
+ let emitEvent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1126
+ const updateAssets = [];
1127
+ if (emitEvent) {
1128
+ Object.keys(assetSettings).forEach(slug => {
1129
+ var _this$assetSettingSub;
1130
+ if (((_this$assetSettingSub = this.assetSettingSubject.value[slug]) === null || _this$assetSettingSub === void 0 ? void 0 : _this$assetSettingSub.visible) !== assetSettings[slug].visible) {
1131
+ updateAssets.push(slug);
1132
+ }
1133
+ });
1134
+ }
1108
1135
  this.assetSettingSubject.next(assetSettings);
1136
+ updateAssets.forEach(slug => {
1137
+ this.eventService.emit('asset.updateState', slug);
1138
+ });
1109
1139
  this.store.set('AssetSetting', assetSettings);
1110
1140
  }
1111
1141
  async getStoreAssetSettings() {
@@ -1122,6 +1152,7 @@ class ChainService {
1122
1152
  }
1123
1153
  async updateAssetSetting(assetSlug, assetSetting) {
1124
1154
  const currentAssetSettings = await this.getAssetSettings();
1155
+ let needUpdateSubject;
1125
1156
 
1126
1157
  // Update settings
1127
1158
  currentAssetSettings[assetSlug] = assetSetting;
@@ -1133,8 +1164,10 @@ class ChainService {
1133
1164
  // if chain not enabled, then automatically enable
1134
1165
  if (chainState && !chainState.active) {
1135
1166
  this.enableChain(chainState.slug);
1167
+ needUpdateSubject = true;
1136
1168
  }
1137
1169
  }
1170
+ return needUpdateSubject;
1138
1171
  }
1139
1172
  async updateAssetSettingByChain(chainSlug, visible) {
1140
1173
  const storedAssetSettings = await this.getAssetSettings();
@@ -50,6 +50,7 @@ exports._isCustomChain = _isCustomChain;
50
50
  exports._isCustomProvider = _isCustomProvider;
51
51
  exports._isEqualContractAddress = _isEqualContractAddress;
52
52
  exports._isEqualSmartContractAsset = _isEqualSmartContractAsset;
53
+ exports._isLocalToken = _isLocalToken;
53
54
  exports._isNativeToken = _isNativeToken;
54
55
  exports._isNativeTokenBySlug = _isNativeTokenBySlug;
55
56
  exports._isPureEvmChain = _isPureEvmChain;
@@ -272,6 +273,9 @@ function _getChainNativeTokenSlug(chainInfo) {
272
273
  }
273
274
  return `${chainInfo.slug}-${_types._AssetType.NATIVE}-${_getChainNativeTokenBasicInfo(chainInfo).symbol}`;
274
275
  }
276
+ function _isLocalToken(tokenInfo) {
277
+ return tokenInfo.assetType === _types._AssetType.LOCAL;
278
+ }
275
279
  function _isTokenEvmSmartContract(tokenInfo) {
276
280
  return [_types._AssetType.ERC721, _types._AssetType.ERC20].includes(tokenInfo.assetType);
277
281
  }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.EventService = void 0;
8
+ var _eventemitter = _interopRequireDefault(require("eventemitter3"));
9
+ // Copyright 2019-2022 @subwallet/extension-base
10
+ // SPDX-License-Identifier: Apache-2.0
11
+
12
+ // Stateless service handle runtime event on background
13
+
14
+ class EventService extends _eventemitter.default {
15
+ pendingEvents = [];
16
+ lazyEmitter = new _eventemitter.default();
17
+ constructor() {
18
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
19
+ lazyTime: 300
20
+ };
21
+ super();
22
+ this.lazyTime = options.lazyTime;
23
+ this.timeoutId = null;
24
+ this.waitKeyringReady = this.generateWaitPromise('keyring.ready');
25
+ this.waitAccountReady = this.generateWaitPromise('account.ready');
26
+ this.waitChainReady = this.generateWaitPromise('chain.ready');
27
+ this.waitAssetReady = this.generateWaitPromise('asset.ready');
28
+ }
29
+ generateWaitPromise(eventType) {
30
+ return new Promise(resolve => {
31
+ this.once(eventType, isReady => {
32
+ resolve(isReady);
33
+ });
34
+ });
35
+ }
36
+ setLazyTimeout() {
37
+ if (this.timeoutId) {
38
+ clearTimeout(this.timeoutId);
39
+ }
40
+ this.timeoutId = setTimeout(() => {
41
+ this.emitLazy();
42
+ }, this.lazyTime);
43
+ }
44
+ emitLazy() {
45
+ try {
46
+ this.lazyEmitter.emit('lazy', this.pendingEvents, this.pendingEvents.map(e => e.type));
47
+ } catch (e) {
48
+ console.error('Get error in some listener of lazy event', e);
49
+ }
50
+ this.pendingEvents = [];
51
+ this.timeoutId = null;
52
+ }
53
+ onLazy(callback) {
54
+ this.lazyEmitter.on('lazy', callback);
55
+ }
56
+ offLazy(callback) {
57
+ this.lazyEmitter.off('lazy', callback);
58
+ }
59
+ onceLazy(callback) {
60
+ this.lazyEmitter.once('lazy', callback);
61
+ }
62
+ emit(eventType) {
63
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
64
+ args[_key - 1] = arguments[_key];
65
+ }
66
+ console.debug('Emit event: ', eventType, ...args);
67
+ this.pendingEvents.push({
68
+ type: eventType,
69
+ data: args
70
+ });
71
+ this.setLazyTimeout();
72
+ return super.emit(eventType, ...args);
73
+ }
74
+ }
75
+ exports.EventService = EventService;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.COMMON_RELOAD_EVENTS = void 0;
7
+ // Copyright 2019-2022 @subwallet/extension-base
8
+ // SPDX-License-Identifier: Apache-2.0
9
+
10
+ const COMMON_RELOAD_EVENTS = ['account.updateCurrent', 'asset.updateState', 'account.add', 'chain.updateState', 'account.remove', 'chain.add'];
11
+ exports.COMMON_RELOAD_EVENTS = COMMON_RELOAD_EVENTS;