@subwallet/extension-base 1.3.22-0 → 1.3.24-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/background/KoniTypes.d.ts +77 -4
  2. package/background/KoniTypes.js +2 -0
  3. package/cjs/background/KoniTypes.js +2 -0
  4. package/cjs/constants/environment.js +4 -2
  5. package/cjs/constants/index.js +21 -4
  6. package/cjs/constants/signing.js +6 -2
  7. package/cjs/core/logic-validation/recipientAddress.js +9 -1
  8. package/cjs/core/logic-validation/transfer.js +57 -36
  9. package/cjs/core/types.js +1 -0
  10. package/cjs/core/utils.js +12 -1
  11. package/cjs/defaults.js +1 -1
  12. package/cjs/koni/api/dotsama/crowdloan.js +1 -1
  13. package/cjs/koni/api/nft/index.js +9 -16
  14. package/cjs/koni/api/staking/index.js +3 -4
  15. package/cjs/koni/background/handlers/Extension.js +343 -185
  16. package/cjs/koni/background/handlers/State.js +17 -2
  17. package/cjs/koni/background/handlers/Tabs.js +1 -1
  18. package/cjs/packageInfo.js +1 -1
  19. package/cjs/services/balance-service/helpers/subscribe/cardano/consts.js +11 -0
  20. package/cjs/services/balance-service/helpers/subscribe/cardano/index.js +63 -0
  21. package/cjs/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  22. package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +74 -0
  23. package/cjs/services/balance-service/helpers/subscribe/index.js +21 -7
  24. package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +2 -2
  25. package/cjs/services/balance-service/index.js +4 -2
  26. package/cjs/services/balance-service/transfer/cardano-transfer.js +122 -0
  27. package/cjs/services/balance-service/transfer/smart-contract.js +24 -3
  28. package/cjs/services/balance-service/transfer/token.js +4 -4
  29. package/cjs/services/chain-service/handler/CardanoApi.js +176 -0
  30. package/cjs/services/chain-service/handler/CardanoChainHandler.js +83 -0
  31. package/cjs/services/chain-service/handler/TonApi.js +2 -5
  32. package/cjs/services/chain-service/index.js +40 -7
  33. package/cjs/services/chain-service/utils/index.js +40 -11
  34. package/cjs/services/chain-service/utils/patch.js +1 -1
  35. package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
  36. package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
  37. package/cjs/services/earning-service/service.js +6 -12
  38. package/cjs/services/fee-service/service.js +19 -8
  39. package/cjs/services/fee-service/utils/tokenPayFee.js +151 -0
  40. package/cjs/services/history-service/index.js +4 -6
  41. package/cjs/services/inapp-notification-service/index.js +12 -4
  42. package/cjs/services/keyring-service/context/account-context.js +17 -2
  43. package/cjs/services/keyring-service/context/handlers/Derive.js +10 -7
  44. package/cjs/services/keyring-service/context/handlers/Migration.js +268 -0
  45. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  46. package/cjs/services/keyring-service/context/handlers/Secret.js +1 -1
  47. package/cjs/services/keyring-service/utils.js +18 -0
  48. package/cjs/services/request-service/handler/CardanoRequestHandler.js +172 -0
  49. package/cjs/services/request-service/handler/EvmRequestHandler.js +1 -1
  50. package/cjs/services/request-service/handler/MetadataRequestHandler.js +5 -13
  51. package/cjs/services/request-service/index.js +22 -4
  52. package/cjs/services/setting-service/constants.js +10 -1
  53. package/cjs/services/storage-service/DatabaseService.js +3 -0
  54. package/cjs/services/storage-service/db-stores/InappNotification.js +6 -0
  55. package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -59
  56. package/cjs/services/swap-service/handler/chainflip-handler.js +33 -281
  57. package/cjs/services/swap-service/handler/hydradx-handler.js +23 -190
  58. package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -222
  59. package/cjs/services/swap-service/handler/uniswap-handler.js +331 -0
  60. package/cjs/services/swap-service/index.js +31 -22
  61. package/cjs/services/swap-service/utils.js +21 -38
  62. package/cjs/services/transaction-service/helpers/index.js +6 -1
  63. package/cjs/services/transaction-service/index.js +286 -26
  64. package/cjs/services/transaction-service/utils.js +5 -1
  65. package/cjs/types/account/info/keyring.js +12 -1
  66. package/cjs/types/fee/cardano.js +1 -0
  67. package/cjs/types/swap/index.js +7 -2
  68. package/cjs/utils/account/analyze.js +2 -1
  69. package/cjs/utils/account/common.js +29 -20
  70. package/cjs/utils/account/derive/info/solo.js +9 -4
  71. package/cjs/utils/account/derive/validate.js +36 -2
  72. package/cjs/utils/account/transform.js +38 -13
  73. package/cjs/utils/fee/transfer.js +87 -21
  74. package/cjs/utils/index.js +2 -2
  75. package/cjs/utils/staticData/index.js +7 -2
  76. package/constants/environment.d.ts +1 -0
  77. package/constants/environment.js +2 -1
  78. package/constants/index.d.ts +6 -1
  79. package/constants/index.js +14 -1
  80. package/constants/signing.js +6 -2
  81. package/core/logic-validation/recipientAddress.js +11 -3
  82. package/core/logic-validation/transfer.d.ts +1 -1
  83. package/core/logic-validation/transfer.js +33 -12
  84. package/core/substrate/xcm-parser.d.ts +1 -1
  85. package/core/types.d.ts +1 -0
  86. package/core/types.js +1 -0
  87. package/core/utils.d.ts +1 -0
  88. package/core/utils.js +13 -3
  89. package/defaults.d.ts +1 -1
  90. package/defaults.js +1 -1
  91. package/koni/api/dotsama/crowdloan.js +3 -3
  92. package/koni/api/nft/index.js +10 -16
  93. package/koni/api/nft/story_odyssey_nft/index.d.ts +1 -1
  94. package/koni/api/staking/index.js +4 -5
  95. package/koni/background/handlers/Extension.d.ts +9 -0
  96. package/koni/background/handlers/Extension.js +225 -69
  97. package/koni/background/handlers/State.d.ts +6 -2
  98. package/koni/background/handlers/State.js +18 -3
  99. package/koni/background/handlers/Tabs.js +1 -1
  100. package/package.json +76 -9
  101. package/packageInfo.js +1 -1
  102. package/services/balance-service/helpers/subscribe/cardano/consts.d.ts +1 -0
  103. package/services/balance-service/helpers/subscribe/cardano/consts.js +4 -0
  104. package/services/balance-service/helpers/subscribe/cardano/index.d.ts +2 -0
  105. package/services/balance-service/helpers/subscribe/cardano/index.js +57 -0
  106. package/services/balance-service/helpers/subscribe/cardano/types.d.ts +34 -0
  107. package/services/balance-service/helpers/subscribe/cardano/types.js +1 -0
  108. package/services/balance-service/helpers/subscribe/cardano/utils.d.ts +15 -0
  109. package/services/balance-service/helpers/subscribe/cardano/utils.js +62 -0
  110. package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
  111. package/services/balance-service/helpers/subscribe/index.js +23 -9
  112. package/services/balance-service/helpers/subscribe/ton/utils.d.ts +1 -1
  113. package/services/balance-service/helpers/subscribe/ton/utils.js +1 -1
  114. package/services/balance-service/index.js +4 -2
  115. package/services/balance-service/transfer/cardano-transfer.d.ts +24 -0
  116. package/services/balance-service/transfer/cardano-transfer.js +114 -0
  117. package/services/balance-service/transfer/smart-contract.d.ts +4 -2
  118. package/services/balance-service/transfer/smart-contract.js +24 -3
  119. package/services/balance-service/transfer/token.d.ts +1 -1
  120. package/services/balance-service/transfer/token.js +2 -2
  121. package/services/chain-service/handler/CardanoApi.d.ts +38 -0
  122. package/services/chain-service/handler/CardanoApi.js +167 -0
  123. package/services/chain-service/handler/CardanoChainHandler.d.ts +17 -0
  124. package/services/chain-service/handler/CardanoChainHandler.js +75 -0
  125. package/services/chain-service/handler/TonApi.js +3 -6
  126. package/services/chain-service/handler/types.d.ts +1 -0
  127. package/services/chain-service/index.d.ts +4 -1
  128. package/services/chain-service/index.js +41 -8
  129. package/services/chain-service/types.d.ts +9 -1
  130. package/services/chain-service/utils/index.d.ts +4 -0
  131. package/services/chain-service/utils/index.js +32 -11
  132. package/services/chain-service/utils/patch.js +1 -1
  133. package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +1 -1
  134. package/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
  135. package/services/earning-service/service.js +8 -14
  136. package/services/fee-service/interfaces.d.ts +25 -0
  137. package/services/fee-service/service.js +19 -8
  138. package/services/fee-service/utils/tokenPayFee.d.ts +8 -0
  139. package/services/fee-service/utils/tokenPayFee.js +141 -0
  140. package/services/history-service/index.js +6 -8
  141. package/services/inapp-notification-service/index.d.ts +3 -4
  142. package/services/inapp-notification-service/index.js +14 -6
  143. package/services/keyring-service/context/account-context.d.ts +6 -2
  144. package/services/keyring-service/context/account-context.js +17 -2
  145. package/services/keyring-service/context/handlers/Derive.d.ts +1 -1
  146. package/services/keyring-service/context/handlers/Derive.js +10 -8
  147. package/services/keyring-service/context/handlers/Migration.d.ts +17 -0
  148. package/services/keyring-service/context/handlers/Migration.js +258 -0
  149. package/services/keyring-service/context/handlers/Mnemonic.js +2 -2
  150. package/services/keyring-service/context/handlers/Secret.js +2 -2
  151. package/services/keyring-service/utils.d.ts +2 -0
  152. package/services/keyring-service/utils.js +11 -0
  153. package/services/request-service/handler/CardanoRequestHandler.d.ts +16 -0
  154. package/services/request-service/handler/CardanoRequestHandler.js +163 -0
  155. package/services/request-service/handler/EvmRequestHandler.js +1 -1
  156. package/services/request-service/handler/MetadataRequestHandler.d.ts +1 -1
  157. package/services/request-service/handler/MetadataRequestHandler.js +5 -13
  158. package/services/request-service/index.d.ts +7 -4
  159. package/services/request-service/index.js +21 -7
  160. package/services/setting-service/constants.d.ts +3 -0
  161. package/services/setting-service/constants.js +6 -0
  162. package/services/storage-service/DatabaseService.d.ts +1 -0
  163. package/services/storage-service/DatabaseService.js +3 -0
  164. package/services/storage-service/db-stores/InappNotification.d.ts +1 -0
  165. package/services/storage-service/db-stores/InappNotification.js +6 -0
  166. package/services/swap-service/handler/asset-hub/handler.d.ts +1 -4
  167. package/services/swap-service/handler/asset-hub/handler.js +2 -61
  168. package/services/swap-service/handler/base-handler.d.ts +1 -4
  169. package/services/swap-service/handler/chainflip-handler.d.ts +2 -9
  170. package/services/swap-service/handler/chainflip-handler.js +31 -280
  171. package/services/swap-service/handler/hydradx-handler.d.ts +1 -6
  172. package/services/swap-service/handler/hydradx-handler.js +13 -180
  173. package/services/swap-service/handler/simpleswap-handler.d.ts +1 -4
  174. package/services/swap-service/handler/simpleswap-handler.js +5 -226
  175. package/services/swap-service/handler/uniswap-handler.d.ts +41 -0
  176. package/services/swap-service/handler/uniswap-handler.js +323 -0
  177. package/services/swap-service/index.js +30 -22
  178. package/services/swap-service/utils.d.ts +1 -5
  179. package/services/swap-service/utils.js +7 -21
  180. package/services/transaction-service/helpers/index.d.ts +2 -0
  181. package/services/transaction-service/helpers/index.js +4 -0
  182. package/services/transaction-service/index.d.ts +8 -2
  183. package/services/transaction-service/index.js +273 -17
  184. package/services/transaction-service/types.d.ts +7 -0
  185. package/services/transaction-service/utils.js +7 -2
  186. package/types/account/info/keyring.d.ts +4 -1
  187. package/types/account/info/keyring.js +9 -0
  188. package/types/account/info/proxy.d.ts +2 -0
  189. package/types/balance/index.d.ts +4 -1
  190. package/types/fee/base.d.ts +1 -1
  191. package/types/fee/cardano.d.ts +18 -0
  192. package/types/fee/cardano.js +1 -0
  193. package/types/fee/option.d.ts +1 -1
  194. package/types/fee/subscription.d.ts +4 -3
  195. package/types/swap/index.d.ts +11 -3
  196. package/types/swap/index.js +7 -2
  197. package/utils/account/analyze.js +2 -1
  198. package/utils/account/common.d.ts +11 -6
  199. package/utils/account/common.js +28 -19
  200. package/utils/account/derive/info/solo.js +10 -5
  201. package/utils/account/derive/validate.d.ts +1 -0
  202. package/utils/account/derive/validate.js +34 -1
  203. package/utils/account/transform.d.ts +2 -1
  204. package/utils/account/transform.js +37 -13
  205. package/utils/fee/transfer.d.ts +3 -2
  206. package/utils/fee/transfer.js +90 -24
  207. package/utils/index.js +4 -4
  208. package/utils/staticData/index.d.ts +4 -1
  209. package/utils/staticData/index.js +5 -1
  210. package/utils/staticData/oldChainPrefix.json +1 -0
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CardanoApi = exports.API_KEY = void 0;
7
+ var _utils = require("@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/utils");
8
+ var _types = require("@subwallet/extension-base/services/chain-service/types");
9
+ var _utils2 = require("@subwallet/extension-base/utils");
10
+ var _rxjs = require("rxjs");
11
+ var _util = require("@polkadot/util");
12
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
13
+ // SPDX-License-Identifier: Apache-2.0
14
+
15
+ const API_KEY = {
16
+ mainnet: process.env.BLOCKFROST_API_KEY_MAIN || '',
17
+ testnet: process.env.BLOCKFROST_API_KEY_PREP || ''
18
+ };
19
+ exports.API_KEY = API_KEY;
20
+ class CardanoApi {
21
+ // private api: BlockFrostAPI;
22
+
23
+ apiRetry = 0;
24
+ isApiConnectedSubject = new _rxjs.BehaviorSubject(false);
25
+ connectionStatusSubject = new _rxjs.BehaviorSubject(_types._ChainConnectionStatus.DISCONNECTED);
26
+ isApiReady = false;
27
+ isApiReadyOnce = false;
28
+ constructor(chainSlug, apiUrl, _ref) {
29
+ let {
30
+ isTestnet,
31
+ providerName
32
+ } = _ref;
33
+ this.chainSlug = chainSlug;
34
+ this.apiUrl = apiUrl;
35
+ this.isTestnet = isTestnet !== null && isTestnet !== void 0 ? isTestnet : true;
36
+ this.projectId = isTestnet ? API_KEY.testnet : API_KEY.mainnet;
37
+ this.providerName = providerName || 'unknown';
38
+ // this.api = this.createProvider(isTestnet);
39
+ this.isReadyHandler = (0, _utils2.createPromiseHandler)();
40
+ this.connect();
41
+ }
42
+ get isApiConnected() {
43
+ return this.isApiConnectedSubject.getValue();
44
+ }
45
+ get connectionStatus() {
46
+ return this.connectionStatusSubject.getValue();
47
+ }
48
+ updateConnectionStatus(status) {
49
+ const isConnected = status === _types._ChainConnectionStatus.CONNECTED;
50
+ if (isConnected !== this.isApiConnectedSubject.value) {
51
+ this.isApiConnectedSubject.next(isConnected);
52
+ }
53
+ if (status !== this.connectionStatusSubject.value) {
54
+ this.connectionStatusSubject.next(status);
55
+ }
56
+ }
57
+ get isReady() {
58
+ return this.isReadyHandler.promise;
59
+ }
60
+ async updateApiUrl(apiUrl) {
61
+ if (this.apiUrl === apiUrl) {
62
+ return;
63
+ }
64
+ await this.disconnect();
65
+ this.apiUrl = apiUrl;
66
+ // this.api = this.createProvider();
67
+ }
68
+
69
+ async recoverConnect() {
70
+ await this.disconnect();
71
+ this.connect();
72
+ await this.isReadyHandler.promise;
73
+ }
74
+
75
+ // private createProvider (isTestnet = true): BlockFrostAPI {
76
+ // const projectId = isTestnet ? API_KEY.testnet : API_KEY.mainnet;
77
+ //
78
+ // return new BlockFrostAPI({
79
+ // projectId
80
+ // });
81
+ // }
82
+
83
+ connect() {
84
+ this.updateConnectionStatus(_types._ChainConnectionStatus.CONNECTING);
85
+ // There isn't a persistent network connection underlying TonClient. Cant check connection status.
86
+ // this.isApiReadyOnce = true;
87
+ this.onConnect();
88
+ }
89
+ async disconnect() {
90
+ this.onDisconnect();
91
+ this.updateConnectionStatus(_types._ChainConnectionStatus.DISCONNECTED);
92
+ return Promise.resolve();
93
+ }
94
+ destroy() {
95
+ // Todo: implement this in the future
96
+ return this.disconnect();
97
+ }
98
+ onConnect() {
99
+ if (!this.isApiConnected) {
100
+ console.log(`Connected to ${this.chainSlug} at ${this.apiUrl}`);
101
+ this.isApiReady = true;
102
+ if (this.isApiReadyOnce) {
103
+ this.isReadyHandler.resolve(this);
104
+ }
105
+ }
106
+ this.updateConnectionStatus(_types._ChainConnectionStatus.CONNECTED);
107
+ }
108
+ onDisconnect() {
109
+ this.updateConnectionStatus(_types._ChainConnectionStatus.DISCONNECTED);
110
+ if (this.isApiConnected) {
111
+ console.warn(`Disconnected from ${this.chainSlug} of ${this.apiUrl}`);
112
+ this.isApiReady = false;
113
+ this.isReadyHandler = (0, _utils2.createPromiseHandler)();
114
+ }
115
+ }
116
+ async getBalanceMap(address) {
117
+ try {
118
+ const url = this.isTestnet ? `https://cardano-preprod.blockfrost.io/api/v0/addresses/${address}` : `https://cardano-mainnet.blockfrost.io/api/v0/addresses/${address}`;
119
+ const response = await fetch(url, {
120
+ method: 'GET',
121
+ headers: {
122
+ Project_id: this.projectId
123
+ }
124
+ });
125
+ const addressBalance = await response.json();
126
+ return addressBalance.amount;
127
+ } catch (e) {
128
+ console.error('Error on getting account balance', e);
129
+ return [];
130
+ }
131
+ }
132
+ async sendCardanoTxReturnHash(tx) {
133
+ try {
134
+ const url = this.isTestnet ? 'https://cardano-preprod.blockfrost.io/api/v0/tx/submit' : 'https://cardano-mainnet.blockfrost.io/api/v0/tx/submit';
135
+ const response = await fetch(url, {
136
+ method: 'POST',
137
+ headers: {
138
+ Project_id: this.projectId,
139
+ 'Content-Type': 'application/cbor'
140
+ },
141
+ body: (0, _utils.cborToBytes)(tx)
142
+ });
143
+ const hash = (await response.text()).replace(/^"|"$/g, '');
144
+ if ((0, _util.isHex)((0, _util.hexAddPrefix)(hash))) {
145
+ return hash;
146
+ } else {
147
+ console.error('Error on submitting cardano tx');
148
+ return '';
149
+ }
150
+ } catch (e) {
151
+ console.error('Error on submitting cardano tx', e);
152
+ return '';
153
+ }
154
+ }
155
+ async getStatusByTxHash(txHash, ttl) {
156
+ const cronTime = 30000;
157
+ return (0, _utils.retryCardanoTxStatus)(async () => {
158
+ const url = this.isTestnet ? `https://cardano-preprod.blockfrost.io/api/v0/txs/${txHash}` : `https://cardano-mainnet.blockfrost.io/api/v0/txs/${txHash}`;
159
+ const response = await fetch(url, {
160
+ method: 'GET',
161
+ headers: {
162
+ Project_id: this.projectId
163
+ }
164
+ });
165
+ const txInfo = await response.json();
166
+ if (txInfo.block && txInfo.hash && txInfo.index >= 0) {
167
+ return true;
168
+ }
169
+ throw new Error('Transaction not found');
170
+ }, {
171
+ retries: ttl / cronTime,
172
+ delay: cronTime
173
+ });
174
+ }
175
+ }
176
+ exports.CardanoApi = CardanoApi;
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CardanoChainHandler = void 0;
7
+ var _AbstractChainHandler = require("@subwallet/extension-base/services/chain-service/handler/AbstractChainHandler");
8
+ var _CardanoApi = require("@subwallet/extension-base/services/chain-service/handler/CardanoApi");
9
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
10
+ // SPDX-License-Identifier: Apache-2.0
11
+
12
+ class CardanoChainHandler extends _AbstractChainHandler.AbstractChainHandler {
13
+ cardanoApiMap = {};
14
+
15
+ // eslint-disable-next-line no-useless-constructor
16
+ constructor(parent) {
17
+ super(parent);
18
+ }
19
+ getCardanoApiMap() {
20
+ return this.cardanoApiMap;
21
+ }
22
+ getCardanoApiByChain(chain) {
23
+ return this.cardanoApiMap[chain];
24
+ }
25
+ getApiByChain(chain) {
26
+ return this.getCardanoApiByChain(chain);
27
+ }
28
+ setCardanoApi(chain, cardanoApi) {
29
+ this.cardanoApiMap[chain] = cardanoApi;
30
+ }
31
+ async initApi(chainSlug, apiUrl) {
32
+ let {
33
+ isTestnet,
34
+ onUpdateStatus,
35
+ providerName
36
+ } = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
37
+ const existed = this.getCardanoApiByChain(chainSlug);
38
+ if (existed) {
39
+ existed.connect();
40
+ if (apiUrl !== existed.apiUrl) {
41
+ existed.updateApiUrl(apiUrl).catch(console.error);
42
+ }
43
+ return existed;
44
+ }
45
+ const apiObject = new _CardanoApi.CardanoApi(chainSlug, apiUrl, {
46
+ isTestnet,
47
+ providerName
48
+ });
49
+ apiObject.connectionStatusSubject.subscribe(this.handleConnection.bind(this, chainSlug));
50
+ apiObject.connectionStatusSubject.subscribe(onUpdateStatus);
51
+ return Promise.resolve(apiObject);
52
+ }
53
+ async recoverApi(chain) {
54
+ const existed = this.getCardanoApiByChain(chain);
55
+ if (existed && !existed.isApiReadyOnce) {
56
+ console.log(`Reconnect ${existed.providerName || existed.chainSlug} at ${existed.apiUrl}`);
57
+ return existed.recoverConnect();
58
+ }
59
+ }
60
+ destroyCardanoApi(chain) {
61
+ const cardanoApi = this.getCardanoApiByChain(chain);
62
+ cardanoApi === null || cardanoApi === void 0 ? void 0 : cardanoApi.destroy().catch(console.error);
63
+ }
64
+ async sleep() {
65
+ this.isSleeping = true;
66
+ this.cancelAllRecover();
67
+ await Promise.all(Object.values(this.getCardanoApiMap()).map(cardanoApi => {
68
+ return cardanoApi.disconnect().catch(console.error);
69
+ }));
70
+ return Promise.resolve();
71
+ }
72
+ wakeUp() {
73
+ var _this$parent;
74
+ this.isSleeping = false;
75
+ const activeChains = ((_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.getActiveChains()) || [];
76
+ for (const chain of activeChains) {
77
+ const cardanoApi = this.getCardanoApiByChain(chain);
78
+ cardanoApi === null || cardanoApi === void 0 ? void 0 : cardanoApi.connect();
79
+ }
80
+ return Promise.resolve();
81
+ }
82
+ }
83
+ exports.CardanoChainHandler = CardanoChainHandler;
@@ -57,10 +57,7 @@ class TonApi {
57
57
 
58
58
  // Create new provider and api
59
59
  this.apiUrl = apiUrl;
60
- this.api = new _ton.TonClient({
61
- endpoint: this.getJsonRpc(this.apiUrl),
62
- apiKey: _consts.TON_CENTER_API_KEY
63
- });
60
+ this.api = this.createProvider(apiUrl);
64
61
  }
65
62
  async recoverConnect() {
66
63
  await this.disconnect();
@@ -163,7 +160,7 @@ class TonApi {
163
160
  return await resp.json();
164
161
  }
165
162
  async getStatusByExtMsgHash(extMsgHash, extrinsicType) {
166
- return (0, _utils.retry)(async () => {
163
+ return (0, _utils.retryTonTxStatus)(async () => {
167
164
  var _externalTxInfo$out_m, _externalTxInfo$out_m2;
168
165
  // retry many times to get transaction status and transaction hex
169
166
  const externalTxInfoRaw = await this.getTxByInMsg(extMsgHash);
@@ -8,6 +8,7 @@ exports.filterAssetInfoMap = exports.ChainService = void 0;
8
8
  var _chainList = require("@subwallet/chain-list");
9
9
  var _types = require("@subwallet/chain-list/types");
10
10
  var _constants = require("@subwallet/extension-base/services/chain-service/constants");
11
+ var _CardanoChainHandler = require("@subwallet/extension-base/services/chain-service/handler/CardanoChainHandler");
11
12
  var _EvmChainHandler = require("@subwallet/extension-base/services/chain-service/handler/EvmChainHandler");
12
13
  var _MantaPrivateHandler = require("@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler");
13
14
  var _SubstrateChainHandler = require("@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler");
@@ -82,6 +83,7 @@ class ChainService {
82
83
  this.substrateChainHandler = new _SubstrateChainHandler.SubstrateChainHandler(this);
83
84
  this.evmChainHandler = new _EvmChainHandler.EvmChainHandler(this);
84
85
  this.tonChainHandler = new _TonChainHandler.TonChainHandler(this);
86
+ this.cardanoChainHandler = new _CardanoChainHandler.CardanoChainHandler(this);
85
87
  this.logger = (0, _logger.logger)('chain-service');
86
88
  }
87
89
  get value() {
@@ -157,6 +159,12 @@ class ChainService {
157
159
  getTonApiMap() {
158
160
  return this.tonChainHandler.getTonApiMap();
159
161
  }
162
+ getCardanoApi(slug) {
163
+ return this.cardanoChainHandler.getCardanoApiByChain(slug);
164
+ }
165
+ getCardanoApiMap() {
166
+ return this.cardanoChainHandler.getCardanoApiMap();
167
+ }
160
168
  getChainCurrentProviderByKey(slug) {
161
169
  const providerName = this.getChainStateByKey(slug).currentProvider;
162
170
  const providerMap = this.getChainInfoByKey(slug).providers;
@@ -211,6 +219,17 @@ class ChainService {
211
219
  });
212
220
  return assetHubToken;
213
221
  }
222
+ getHydrationAssetIdMap(chain) {
223
+ const hydrationAssetIdMap = {};
224
+ Object.values(this.getAssetRegistry()).forEach(asset => {
225
+ const originChain = (0, _utils._getAssetOriginChain)(asset);
226
+ const assetId = (0, _utils._getTokenOnChainAssetId)(asset);
227
+ if (originChain === chain && assetId !== '-1') {
228
+ hydrationAssetIdMap[asset.slug] = assetId;
229
+ }
230
+ });
231
+ return hydrationAssetIdMap;
232
+ }
214
233
  getChainInfoMap() {
215
234
  return this.dataMap.chainInfoMap;
216
235
  }
@@ -745,6 +764,15 @@ class ChainService {
745
764
  });
746
765
  this.tonChainHandler.setTonApi(chainInfo.slug, chainApi);
747
766
  }
767
+ if (chainInfo.cardanoInfo !== null && chainInfo.cardanoInfo !== undefined) {
768
+ const isTestnet = chainInfo.isTestnet;
769
+ const chainApi = await this.cardanoChainHandler.initApi(chainInfo.slug, endpoint, {
770
+ isTestnet,
771
+ providerName,
772
+ onUpdateStatus
773
+ });
774
+ this.cardanoChainHandler.setCardanoApi(chainInfo.slug, chainApi);
775
+ }
748
776
  }
749
777
  destroyApiForChain(chainInfo) {
750
778
  if (chainInfo.substrateInfo !== null) {
@@ -756,6 +784,9 @@ class ChainService {
756
784
  if (chainInfo.tonInfo !== null) {
757
785
  this.tonChainHandler.destroyTonApi(chainInfo.slug);
758
786
  }
787
+ if (chainInfo.cardanoInfo !== null) {
788
+ this.cardanoChainHandler.destroyCardanoApi(chainInfo.slug);
789
+ }
759
790
  }
760
791
  async enableChain(chainSlug) {
761
792
  const chainInfo = this.getChainInfoByKey(chainSlug);
@@ -1027,7 +1058,7 @@ class ChainService {
1027
1058
  deprecatedChainMap[storedSlug] = duplicatedDefaultSlug;
1028
1059
  deprecatedChains.push(storedSlug);
1029
1060
  } else {
1030
- var _storedChainInfo$bitc;
1061
+ var _storedChainInfo$bitc, _storedChainInfo$card;
1031
1062
  mergedChainInfoMap[storedSlug] = {
1032
1063
  slug: storedSlug,
1033
1064
  name: storedChainInfo.name,
@@ -1037,6 +1068,7 @@ class ChainService {
1037
1068
  substrateInfo: storedChainInfo.substrateInfo,
1038
1069
  bitcoinInfo: (_storedChainInfo$bitc = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc !== void 0 ? _storedChainInfo$bitc : null,
1039
1070
  tonInfo: storedChainInfo.tonInfo,
1071
+ cardanoInfo: (_storedChainInfo$card = storedChainInfo.cardanoInfo) !== null && _storedChainInfo$card !== void 0 ? _storedChainInfo$card : null,
1040
1072
  isTestnet: storedChainInfo.isTestnet,
1041
1073
  chainStatus: storedChainInfo.chainStatus,
1042
1074
  icon: storedChainInfo.icon,
@@ -1055,7 +1087,7 @@ class ChainService {
1055
1087
  this.updateChainConnectionStatus(storedSlug, _types3._ChainConnectionStatus.DISCONNECTED);
1056
1088
  }
1057
1089
  } else {
1058
- var _storedChainInfo$bitc2;
1090
+ var _storedChainInfo$bitc2, _storedChainInfo$card2;
1059
1091
  // added chain from patch
1060
1092
  mergedChainInfoMap[storedSlug] = {
1061
1093
  slug: storedSlug,
@@ -1065,6 +1097,7 @@ class ChainService {
1065
1097
  substrateInfo: storedChainInfo.substrateInfo,
1066
1098
  bitcoinInfo: (_storedChainInfo$bitc2 = storedChainInfo.bitcoinInfo) !== null && _storedChainInfo$bitc2 !== void 0 ? _storedChainInfo$bitc2 : null,
1067
1099
  tonInfo: storedChainInfo.tonInfo,
1100
+ cardanoInfo: (_storedChainInfo$card2 = storedChainInfo.cardanoInfo) !== null && _storedChainInfo$card2 !== void 0 ? _storedChainInfo$card2 : null,
1068
1101
  isTestnet: storedChainInfo.isTestnet,
1069
1102
  chainStatus: storedChainInfo.chainStatus,
1070
1103
  icon: storedChainInfo.icon,
@@ -1236,6 +1269,7 @@ class ChainService {
1236
1269
  let substrateInfo = null;
1237
1270
  let evmInfo = null;
1238
1271
  const tonInfo = null;
1272
+ const cardanoInfo = null;
1239
1273
  if (params.chainSpec.genesisHash !== '') {
1240
1274
  substrateInfo = {
1241
1275
  crowdloanFunds: params.chainSpec.crowdloanFunds || null,
@@ -1274,6 +1308,7 @@ class ChainService {
1274
1308
  evmInfo,
1275
1309
  bitcoinInfo: null,
1276
1310
  tonInfo,
1311
+ cardanoInfo,
1277
1312
  isTestnet: false,
1278
1313
  chainStatus: _types._ChainStatus.ACTIVE,
1279
1314
  icon: '',
@@ -1385,6 +1420,7 @@ class ChainService {
1385
1420
  // TODO: EVM chain might have WS provider
1386
1421
  if (provider.startsWith('http')) {
1387
1422
  // todo: handle validate ton provider
1423
+ // todo: handle validate cardano provider
1388
1424
 
1389
1425
  // HTTP provider is EVM by default
1390
1426
  api = await this.evmChainHandler.initApi('custom', provider);
@@ -1601,15 +1637,12 @@ class ChainService {
1601
1637
  refreshEvmApi(slug) {
1602
1638
  this.evmChainHandler.recoverApi(slug).catch(console.error);
1603
1639
  }
1604
- refreshTonApi(slug) {
1605
- this.tonChainHandler.recoverApi(slug).catch(console.error);
1606
- }
1607
1640
  async stopAllChainApis() {
1608
- await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep()]);
1641
+ await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep(), this.cardanoChainHandler.sleep()]);
1609
1642
  this.stopCheckLatestChainData();
1610
1643
  }
1611
1644
  async resumeAllChainApis() {
1612
- await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp()]);
1645
+ await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp(), this.cardanoChainHandler.wakeUp()]);
1613
1646
  this.checkLatestData();
1614
1647
  }
1615
1648
  async initAssetSettings() {
@@ -12,6 +12,7 @@ var _exportNames = {
12
12
  _isPureEvmChain: true,
13
13
  _isPureSubstrateChain: true,
14
14
  _isPureTonChain: true,
15
+ _isPureCardanoChain: true,
15
16
  _getOriginChainOfAsset: true,
16
17
  _getContractAddressOfToken: true,
17
18
  _isNativeTokenTransferredByEvm: true,
@@ -19,6 +20,7 @@ var _exportNames = {
19
20
  _checkSmartContractSupportByChain: true,
20
21
  _isJettonToken: true,
21
22
  _isTokenTransferredByTon: true,
23
+ _isTokenTransferredByCardano: true,
22
24
  _getTokenOnChainAssetId: true,
23
25
  _getTokenOnChainInfo: true,
24
26
  _isBridgedToken: true,
@@ -26,6 +28,7 @@ var _exportNames = {
26
28
  _isChainEvmCompatible: true,
27
29
  _isChainBitcoinCompatible: true,
28
30
  _isChainTonCompatible: true,
31
+ _isChainCardanoCompatible: true,
29
32
  _isNativeToken: true,
30
33
  _isNativeTokenBySlug: true,
31
34
  _isSmartContractToken: true,
@@ -54,6 +57,7 @@ var _exportNames = {
54
57
  _isLocalToken: true,
55
58
  _isTokenEvmSmartContract: true,
56
59
  _isTokenTonSmartContract: true,
60
+ _isCIP26Token: true,
57
61
  _isTokenWasmSmartContract: true,
58
62
  _isAssetSmartContractNft: true,
59
63
  _isTokenGearSmartContract: true,
@@ -140,7 +144,9 @@ exports._isAssetHubToken = _isAssetHubToken;
140
144
  exports._isAssetSmartContractNft = _isAssetSmartContractNft;
141
145
  exports._isAssetValuable = _isAssetValuable;
142
146
  exports._isBridgedToken = _isBridgedToken;
147
+ exports._isCIP26Token = _isCIP26Token;
143
148
  exports._isChainBitcoinCompatible = _isChainBitcoinCompatible;
149
+ exports._isChainCardanoCompatible = _isChainCardanoCompatible;
144
150
  exports._isChainEnabled = _isChainEnabled;
145
151
  exports._isChainEvmCompatible = _isChainEvmCompatible;
146
152
  exports._isChainSubstrateCompatible = _isChainSubstrateCompatible;
@@ -165,6 +171,7 @@ exports._isMantaZkAsset = _isMantaZkAsset;
165
171
  exports._isNativeToken = _isNativeToken;
166
172
  exports._isNativeTokenBySlug = _isNativeTokenBySlug;
167
173
  exports._isNativeTokenTransferredByEvm = _isNativeTokenTransferredByEvm;
174
+ exports._isPureCardanoChain = _isPureCardanoChain;
168
175
  exports._isPureEvmChain = _isPureEvmChain;
169
176
  exports._isPureSubstrateChain = _isPureSubstrateChain;
170
177
  exports._isPureTonChain = _isPureTonChain;
@@ -176,6 +183,7 @@ exports._isSupportOrdinal = void 0;
176
183
  exports._isTokenEvmSmartContract = _isTokenEvmSmartContract;
177
184
  exports._isTokenGearSmartContract = _isTokenGearSmartContract;
178
185
  exports._isTokenTonSmartContract = _isTokenTonSmartContract;
186
+ exports._isTokenTransferredByCardano = _isTokenTransferredByCardano;
179
187
  exports._isTokenTransferredByEvm = _isTokenTransferredByEvm;
180
188
  exports._isTokenTransferredByTon = _isTokenTransferredByTon;
181
189
  exports._isTokenWasmSmartContract = _isTokenWasmSmartContract;
@@ -248,13 +256,16 @@ function _isEqualSmartContractAsset(asset1, asset2) {
248
256
  return false;
249
257
  }
250
258
  function _isPureEvmChain(chainInfo) {
251
- return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo;
259
+ return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
252
260
  }
253
261
  function _isPureSubstrateChain(chainInfo) {
254
- return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo;
262
+ return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
255
263
  }
256
264
  function _isPureTonChain(chainInfo) {
257
- return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo;
265
+ return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo && !chainInfo.cardanoInfo;
266
+ }
267
+ function _isPureCardanoChain(chainInfo) {
268
+ return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !!chainInfo.cardanoInfo;
258
269
  }
259
270
  function _getOriginChainOfAsset(assetSlug) {
260
271
  if (assetSlug.startsWith(_types2._CUSTOM_PREFIX)) {
@@ -307,6 +318,9 @@ function _isJettonToken(tokenInfo) {
307
318
  function _isTokenTransferredByTon(tokenInfo) {
308
319
  return _isJettonToken(tokenInfo) || _isNativeToken(tokenInfo);
309
320
  }
321
+ function _isTokenTransferredByCardano(tokenInfo) {
322
+ return _isCIP26Token(tokenInfo) || _isNativeToken(tokenInfo);
323
+ }
310
324
 
311
325
  // Utils for balance functions
312
326
  function _getTokenOnChainAssetId(tokenInfo) {
@@ -333,6 +347,9 @@ function _isChainBitcoinCompatible(chainInfo) {
333
347
  function _isChainTonCompatible(chainInfo) {
334
348
  return !!chainInfo.tonInfo;
335
349
  }
350
+ function _isChainCardanoCompatible(chainInfo) {
351
+ return !!chainInfo.cardanoInfo;
352
+ }
336
353
  function _isNativeToken(tokenInfo) {
337
354
  return tokenInfo.assetType === _types._AssetType.NATIVE;
338
355
  }
@@ -453,11 +470,12 @@ function _getTokenTypesSupportedByChain(chainInfo) {
453
470
  return result;
454
471
  }
455
472
  function _getChainNativeTokenBasicInfo(chainInfo) {
473
+ const defaultTokenInfo = {
474
+ symbol: '',
475
+ decimals: -1
476
+ };
456
477
  if (!chainInfo) {
457
- return {
458
- symbol: '',
459
- decimals: -1
460
- };
478
+ return defaultTokenInfo;
461
479
  }
462
480
  if (chainInfo.substrateInfo) {
463
481
  // substrate by default
@@ -475,11 +493,13 @@ function _getChainNativeTokenBasicInfo(chainInfo) {
475
493
  symbol: chainInfo.tonInfo.symbol,
476
494
  decimals: chainInfo.tonInfo.decimals
477
495
  };
496
+ } else if (chainInfo.cardanoInfo) {
497
+ return {
498
+ symbol: chainInfo.cardanoInfo.symbol,
499
+ decimals: chainInfo.cardanoInfo.decimals
500
+ };
478
501
  }
479
- return {
480
- symbol: '',
481
- decimals: -1
482
- };
502
+ return defaultTokenInfo;
483
503
  }
484
504
  function _getChainNativeTokenSlug(chainInfo) {
485
505
  if (_isCustomChain(chainInfo.slug)) {
@@ -497,6 +517,9 @@ function _isTokenTonSmartContract(tokenInfo) {
497
517
  return [_types._AssetType.TEP74].includes(tokenInfo.assetType); // add TEP-62 when supporting
498
518
  }
499
519
 
520
+ function _isCIP26Token(tokenInfo) {
521
+ return [_types._AssetType.CIP26].includes(tokenInfo.assetType);
522
+ }
500
523
  function _isTokenWasmSmartContract(tokenInfo) {
501
524
  return [_types._AssetType.PSP22, _types._AssetType.PSP34].includes(tokenInfo.assetType);
502
525
  }
@@ -585,6 +608,9 @@ function _getBlockExplorerFromChain(chainInfo) {
585
608
  if (_isPureEvmChain(chainInfo)) {
586
609
  var _chainInfo$evmInfo5;
587
610
  blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$evmInfo5 = chainInfo.evmInfo) === null || _chainInfo$evmInfo5 === void 0 ? void 0 : _chainInfo$evmInfo5.blockExplorer;
611
+ } else if (_isPureCardanoChain(chainInfo)) {
612
+ var _chainInfo$cardanoInf;
613
+ blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$cardanoInf = chainInfo.cardanoInfo) === null || _chainInfo$cardanoInf === void 0 ? void 0 : _chainInfo$cardanoInf.blockExplorer;
588
614
  } else {
589
615
  var _chainInfo$substrateI18;
590
616
  blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
@@ -756,6 +782,9 @@ const _chainInfoToChainType = chainInfo => {
756
782
  if (_isChainTonCompatible(chainInfo)) {
757
783
  return _types3.AccountChainType.TON;
758
784
  }
785
+ if (_isChainCardanoCompatible(chainInfo)) {
786
+ return _types3.AccountChainType.CARDANO;
787
+ }
759
788
  if (_isChainBitcoinCompatible(chainInfo)) {
760
789
  return _types3.AccountChainType.BITCOIN;
761
790
  }
@@ -11,7 +11,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
11
11
  const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
12
12
  const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
13
13
  const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
14
- const ChainListVersion = '0.2.99'; // update this when build chainlist
14
+ const ChainListVersion = '0.2.101'; // update this when build chainlist
15
15
 
16
16
  // todo: move this interface to chainlist
17
17
 
@@ -131,7 +131,7 @@ class BifrostMantaLiquidStakingPoolHandler extends _bifrost.default {
131
131
  const chainApi = await this.substrateApi.isReady;
132
132
  const derivativeTokenSlug = this.derivativeAssets[0];
133
133
  const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
134
- const extrinsic = chainApi.api.tx.vtokenMinting.redeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
134
+ const extrinsic = chainApi.api.tx.vtokenMinting.redeem(null, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
135
135
  return [_KoniTypes.ExtrinsicType.UNSTAKE_VMANTA, extrinsic];
136
136
  }
137
137
 
@@ -296,7 +296,7 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
296
296
  const chainApi = await this.substrateApi.isReady;
297
297
  const derivativeTokenSlug = this.derivativeAssets[0];
298
298
  const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
299
- const extrinsic = chainApi.api.tx.vtokenMinting.redeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
299
+ const extrinsic = chainApi.api.tx.vtokenMinting.redeem(null, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
300
300
  return [_KoniTypes.ExtrinsicType.UNSTAKE_VDOT, extrinsic];
301
301
  }
302
302
 
@@ -387,10 +387,8 @@ class EarningService {
387
387
  async subscribePoolPositions(addresses, callback) {
388
388
  let cancel = false;
389
389
  await this.eventService.waitChainReady;
390
- const {
391
- evm: evmAddresses,
392
- substrate: substrateAddresses
393
- } = (0, _utils2.categoryAddresses)(addresses);
390
+ const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
391
+ const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
394
392
  const activeChains = this.state.activeChainSlugs;
395
393
  const unsubList = [];
396
394
  for (const handler of Object.values(this.handlers)) {
@@ -536,10 +534,8 @@ class EarningService {
536
534
  async getPoolReward(addresses, callback) {
537
535
  let cancel = false;
538
536
  await this.eventService.waitChainReady;
539
- const {
540
- evm: evmAddresses,
541
- substrate: substrateAddresses
542
- } = (0, _utils2.categoryAddresses)(addresses);
537
+ const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
538
+ const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
543
539
  const activeChains = this.state.activeChainSlugs;
544
540
  const unsubList = [];
545
541
  for (const handler of Object.values(this.handlers)) {
@@ -594,10 +590,8 @@ class EarningService {
594
590
  async fetchPoolRewardHistory(addresses, callback) {
595
591
  let cancel = false;
596
592
  await this.eventService.waitChainReady;
597
- const {
598
- evm: evmAddresses,
599
- substrate: substrateAddresses
600
- } = (0, _utils2.categoryAddresses)(addresses);
593
+ const evmAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.EVM]);
594
+ const substrateAddresses = (0, _utils2.getAddressesByChainType)(addresses, [_KoniTypes.ChainType.SUBSTRATE]);
601
595
  const activeChains = this.state.activeChainSlugs;
602
596
  const unsubList = [];
603
597
  for (const handler of Object.values(this.handlers)) {