@subwallet/extension-base 1.3.40-0 → 1.3.42-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 (232) hide show
  1. package/background/KoniTypes.d.ts +121 -4
  2. package/background/KoniTypes.js +18 -0
  3. package/background/errors/BitcoinProviderError.d.ts +6 -0
  4. package/background/errors/BitcoinProviderError.js +47 -0
  5. package/cjs/background/KoniTypes.js +20 -1
  6. package/cjs/background/errors/BitcoinProviderError.js +54 -0
  7. package/cjs/constants/bitcoin.js +22 -0
  8. package/cjs/constants/environment.js +4 -2
  9. package/cjs/constants/index.js +16 -1
  10. package/cjs/core/logic-validation/recipientAddress.js +9 -0
  11. package/cjs/core/logic-validation/transfer.js +25 -5
  12. package/cjs/core/types.js +1 -0
  13. package/cjs/core/utils.js +15 -1
  14. package/cjs/koni/background/handlers/Extension.js +96 -41
  15. package/cjs/koni/background/handlers/State.js +52 -11
  16. package/cjs/packageInfo.js +1 -1
  17. package/cjs/services/balance-service/helpers/subscribe/bitcoin.js +94 -0
  18. package/cjs/services/balance-service/helpers/subscribe/evm.js +6 -1
  19. package/cjs/services/balance-service/helpers/subscribe/index.js +19 -7
  20. package/cjs/services/balance-service/index.js +32 -4
  21. package/cjs/services/balance-service/transfer/bitcoin-transfer.js +119 -0
  22. package/cjs/services/balance-service/transfer/token.js +2 -0
  23. package/cjs/services/balance-service/transfer/xcm/index.js +15 -9
  24. package/cjs/services/balance-service/transfer/xcm/utils.js +12 -14
  25. package/cjs/services/base/types.js +2 -0
  26. package/cjs/services/chain-service/constants.js +18 -6
  27. package/cjs/services/chain-service/handler/CardanoApi.js +25 -35
  28. package/cjs/services/chain-service/handler/bitcoin/BitcoinApi.js +105 -0
  29. package/cjs/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +78 -0
  30. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +371 -0
  31. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +19 -0
  32. package/cjs/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +368 -0
  33. package/cjs/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +302 -0
  34. package/cjs/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
  35. package/cjs/services/chain-service/index.js +27 -3
  36. package/cjs/services/chain-service/utils/index.js +57 -4
  37. package/cjs/services/chain-service/utils/patch.js +1 -1
  38. package/cjs/services/earning-service/handlers/native-staking/tao.js +4 -38
  39. package/cjs/services/event-service/index.js +4 -0
  40. package/cjs/services/fee-service/service.js +8 -3
  41. package/cjs/services/hiro-service/index.js +96 -0
  42. package/cjs/services/hiro-service/utils/index.js +85 -0
  43. package/cjs/services/history-service/bitcoin-history.js +58 -0
  44. package/cjs/services/history-service/helpers/recoverHistoryStatus.js +96 -4
  45. package/cjs/services/history-service/index.js +41 -3
  46. package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
  47. package/cjs/services/keyring-service/context/handlers/Migration.js +2 -2
  48. package/cjs/services/keyring-service/context/handlers/Mnemonic.js +4 -3
  49. package/cjs/services/migration-service/scripts/MigrateNewUnifiedAccount.js +29 -0
  50. package/cjs/services/migration-service/scripts/index.js +3 -1
  51. package/cjs/services/request-service/handler/BitcoinRequestHandler.js +440 -0
  52. package/cjs/services/request-service/index.js +29 -3
  53. package/cjs/services/rune-service/index.js +105 -0
  54. package/cjs/services/swap-service/handler/chainflip-handler.js +29 -18
  55. package/cjs/services/swap-service/handler/kyber-handler.js +5 -9
  56. package/cjs/services/swap-service/handler/simpleswap-handler.js +4 -7
  57. package/cjs/services/swap-service/handler/uniswap-handler.js +5 -12
  58. package/cjs/services/swap-service/utils.js +46 -37
  59. package/cjs/services/transaction-service/helpers/index.js +7 -1
  60. package/cjs/services/transaction-service/index.js +136 -15
  61. package/cjs/services/transaction-service/utils.js +6 -3
  62. package/cjs/strategy/api-request-strategy/context/base.js +31 -0
  63. package/cjs/strategy/api-request-strategy/index.js +90 -0
  64. package/cjs/strategy/api-request-strategy/types.js +1 -0
  65. package/cjs/strategy/api-request-strategy/utils/index.js +33 -0
  66. package/cjs/types/account/info/keyring.js +1 -1
  67. package/cjs/types/bitcoin.js +24 -0
  68. package/cjs/types/environment.js +19 -0
  69. package/cjs/types/fee/bitcoin.js +1 -0
  70. package/cjs/types/fee/index.js +11 -0
  71. package/cjs/types/index.js +11 -0
  72. package/cjs/utils/account/analyze.js +3 -3
  73. package/cjs/utils/account/common.js +16 -6
  74. package/cjs/utils/account/derive/info/solo.js +68 -19
  75. package/cjs/utils/account/derive/info/unified.js +2 -0
  76. package/cjs/utils/account/derive/validate.js +70 -2
  77. package/cjs/utils/account/transform.js +11 -5
  78. package/cjs/utils/bitcoin/common.js +98 -0
  79. package/cjs/utils/bitcoin/fee.js +21 -0
  80. package/cjs/utils/bitcoin/index.js +38 -0
  81. package/cjs/utils/bitcoin/utxo-management.js +281 -0
  82. package/cjs/utils/environment.js +30 -2
  83. package/cjs/utils/fee/transfer.js +48 -0
  84. package/cjs/utils/index.js +15 -1
  85. package/constants/bitcoin.d.ts +3 -0
  86. package/constants/bitcoin.js +13 -0
  87. package/constants/environment.d.ts +1 -0
  88. package/constants/environment.js +2 -1
  89. package/constants/index.d.ts +2 -0
  90. package/constants/index.js +3 -1
  91. package/core/logic-validation/recipientAddress.js +10 -1
  92. package/core/logic-validation/transfer.d.ts +2 -2
  93. package/core/logic-validation/transfer.js +27 -7
  94. package/core/types.d.ts +1 -0
  95. package/core/types.js +1 -0
  96. package/core/utils.d.ts +1 -0
  97. package/core/utils.js +15 -2
  98. package/koni/background/handlers/Extension.d.ts +2 -0
  99. package/koni/background/handlers/Extension.js +95 -42
  100. package/koni/background/handlers/State.d.ts +7 -3
  101. package/koni/background/handlers/State.js +52 -12
  102. package/package.json +149 -8
  103. package/packageInfo.js +1 -1
  104. package/services/balance-service/helpers/subscribe/bitcoin.d.ts +2 -0
  105. package/services/balance-service/helpers/subscribe/bitcoin.js +87 -0
  106. package/services/balance-service/helpers/subscribe/evm.js +6 -1
  107. package/services/balance-service/helpers/subscribe/index.d.ts +2 -2
  108. package/services/balance-service/helpers/subscribe/index.js +20 -8
  109. package/services/balance-service/index.d.ts +2 -0
  110. package/services/balance-service/index.js +32 -4
  111. package/services/balance-service/transfer/bitcoin-transfer.d.ts +14 -0
  112. package/services/balance-service/transfer/bitcoin-transfer.js +112 -0
  113. package/services/balance-service/transfer/token.js +2 -0
  114. package/services/balance-service/transfer/xcm/index.js +15 -9
  115. package/services/balance-service/transfer/xcm/utils.d.ts +2 -0
  116. package/services/balance-service/transfer/xcm/utils.js +12 -14
  117. package/services/base/types.d.ts +2 -0
  118. package/services/base/types.js +2 -0
  119. package/services/chain-service/constants.d.ts +7 -0
  120. package/services/chain-service/constants.js +12 -5
  121. package/services/chain-service/handler/CardanoApi.d.ts +1 -5
  122. package/services/chain-service/handler/CardanoApi.js +26 -34
  123. package/services/chain-service/handler/bitcoin/BitcoinApi.d.ts +31 -0
  124. package/services/chain-service/handler/bitcoin/BitcoinApi.js +98 -0
  125. package/services/chain-service/handler/bitcoin/BitcoinChainHandler.d.ts +16 -0
  126. package/services/chain-service/handler/bitcoin/BitcoinChainHandler.js +70 -0
  127. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.d.ts +28 -0
  128. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/blockstream-testnet-strategy.js +362 -0
  129. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.d.ts +2 -0
  130. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/index.js +5 -0
  131. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.d.ts +28 -0
  132. package/services/chain-service/handler/bitcoin/strategy/BlockStreamTestnet/mempool-testnet-strategy.js +359 -0
  133. package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.d.ts +28 -0
  134. package/services/chain-service/handler/bitcoin/strategy/SubWalletMainnet/index.js +293 -0
  135. package/services/chain-service/handler/bitcoin/strategy/types.d.ts +291 -0
  136. package/services/chain-service/handler/bitcoin/strategy/types.js +1 -0
  137. package/services/chain-service/index.d.ts +3 -0
  138. package/services/chain-service/index.js +31 -5
  139. package/services/chain-service/types.d.ts +20 -0
  140. package/services/chain-service/utils/index.d.ts +4 -0
  141. package/services/chain-service/utils/index.js +50 -4
  142. package/services/chain-service/utils/patch.js +1 -1
  143. package/services/earning-service/handlers/native-staking/tao.d.ts +0 -11
  144. package/services/earning-service/handlers/native-staking/tao.js +4 -24
  145. package/services/event-service/index.d.ts +3 -0
  146. package/services/event-service/index.js +4 -0
  147. package/services/event-service/types.d.ts +3 -0
  148. package/services/fee-service/service.js +8 -3
  149. package/services/hiro-service/index.d.ts +17 -0
  150. package/services/hiro-service/index.js +88 -0
  151. package/services/hiro-service/utils/index.d.ts +6 -0
  152. package/services/hiro-service/utils/index.js +72 -0
  153. package/services/history-service/bitcoin-history.d.ts +4 -0
  154. package/services/history-service/bitcoin-history.js +52 -0
  155. package/services/history-service/helpers/recoverHistoryStatus.d.ts +3 -1
  156. package/services/history-service/helpers/recoverHistoryStatus.js +96 -4
  157. package/services/history-service/index.d.ts +1 -0
  158. package/services/history-service/index.js +42 -4
  159. package/services/keyring-service/context/handlers/Derive.js +2 -2
  160. package/services/keyring-service/context/handlers/Migration.js +2 -2
  161. package/services/keyring-service/context/handlers/Mnemonic.js +4 -3
  162. package/services/migration-service/scripts/MigrateNewUnifiedAccount.d.ts +4 -0
  163. package/services/migration-service/scripts/MigrateNewUnifiedAccount.js +21 -0
  164. package/services/migration-service/scripts/index.js +3 -1
  165. package/services/request-service/handler/BitcoinRequestHandler.d.ts +23 -0
  166. package/services/request-service/handler/BitcoinRequestHandler.js +427 -0
  167. package/services/request-service/index.d.ts +9 -2
  168. package/services/request-service/index.js +25 -3
  169. package/services/rune-service/index.d.ts +17 -0
  170. package/services/rune-service/index.js +97 -0
  171. package/services/swap-service/handler/chainflip-handler.d.ts +0 -2
  172. package/services/swap-service/handler/chainflip-handler.js +25 -13
  173. package/services/swap-service/handler/kyber-handler.d.ts +0 -1
  174. package/services/swap-service/handler/kyber-handler.js +5 -8
  175. package/services/swap-service/handler/simpleswap-handler.d.ts +0 -1
  176. package/services/swap-service/handler/simpleswap-handler.js +4 -6
  177. package/services/swap-service/handler/uniswap-handler.js +6 -13
  178. package/services/swap-service/utils.d.ts +0 -13
  179. package/services/swap-service/utils.js +46 -34
  180. package/services/transaction-service/helpers/index.d.ts +3 -1
  181. package/services/transaction-service/helpers/index.js +5 -0
  182. package/services/transaction-service/index.d.ts +3 -5
  183. package/services/transaction-service/index.js +135 -16
  184. package/services/transaction-service/types.d.ts +12 -2
  185. package/services/transaction-service/utils.js +7 -4
  186. package/strategy/api-request-strategy/context/base.d.ts +15 -0
  187. package/strategy/api-request-strategy/context/base.js +24 -0
  188. package/strategy/api-request-strategy/index.d.ts +15 -0
  189. package/strategy/api-request-strategy/index.js +83 -0
  190. package/strategy/api-request-strategy/types.d.ts +22 -0
  191. package/strategy/api-request-strategy/types.js +1 -0
  192. package/strategy/api-request-strategy/utils/index.d.ts +2 -0
  193. package/strategy/api-request-strategy/utils/index.js +23 -0
  194. package/types/account/info/keyring.d.ts +1 -1
  195. package/types/account/info/keyring.js +1 -1
  196. package/types/balance/index.d.ts +4 -1
  197. package/types/balance/transfer.d.ts +17 -0
  198. package/types/bitcoin.d.ts +93 -0
  199. package/types/bitcoin.js +17 -0
  200. package/types/environment.d.ts +9 -0
  201. package/types/environment.js +13 -0
  202. package/types/fee/base.d.ts +4 -1
  203. package/types/fee/bitcoin.d.ts +18 -0
  204. package/types/fee/bitcoin.js +1 -0
  205. package/types/fee/index.d.ts +1 -0
  206. package/types/fee/index.js +2 -1
  207. package/types/fee/subscription.d.ts +4 -3
  208. package/types/index.d.ts +1 -0
  209. package/types/index.js +1 -0
  210. package/utils/account/analyze.js +4 -4
  211. package/utils/account/common.d.ts +7 -8
  212. package/utils/account/common.js +16 -6
  213. package/utils/account/derive/info/solo.js +70 -21
  214. package/utils/account/derive/info/unified.js +2 -0
  215. package/utils/account/derive/validate.d.ts +1 -0
  216. package/utils/account/derive/validate.js +68 -1
  217. package/utils/account/transform.d.ts +1 -1
  218. package/utils/account/transform.js +11 -5
  219. package/utils/bitcoin/common.d.ts +22 -0
  220. package/utils/bitcoin/common.js +88 -0
  221. package/utils/bitcoin/fee.d.ts +2 -0
  222. package/utils/bitcoin/fee.js +14 -0
  223. package/utils/bitcoin/index.d.ts +3 -0
  224. package/utils/bitcoin/index.js +6 -0
  225. package/utils/bitcoin/utxo-management.d.ts +33 -0
  226. package/utils/bitcoin/utxo-management.js +266 -0
  227. package/utils/environment.d.ts +2 -0
  228. package/utils/environment.js +27 -1
  229. package/utils/fee/transfer.d.ts +3 -1
  230. package/utils/fee/transfer.js +47 -1
  231. package/utils/index.d.ts +1 -0
  232. package/utils/index.js +6 -3
@@ -0,0 +1,291 @@
1
+ import { ApiRequestStrategy } from '@subwallet/extension-base/strategy/api-request-strategy/types';
2
+ import { BitcoinFeeInfo, BitcoinTransactionStatus, BitcoinTx, UtxoResponseItem } from '@subwallet/extension-base/types';
3
+ import EventEmitter from 'eventemitter3';
4
+ export interface BitcoinApiStrategy extends Omit<ApiRequestStrategy, 'addRequest'> {
5
+ getBlockTime(): Promise<number>;
6
+ computeBlockTime(): Promise<number>;
7
+ getAddressSummaryInfo(address: string): Promise<BitcoinAddressSummaryInfo>;
8
+ getRunes(address: string): Promise<RunesInfoByAddress[]>;
9
+ getRuneUtxos(address: string): Promise<RuneUtxo[]>;
10
+ getAddressInscriptions(address: string): Promise<Inscription[]>;
11
+ getAddressTransaction(address: string, limit?: number): Promise<BitcoinTx[]>;
12
+ getTransactionStatus(txHash: string): Promise<BitcoinTransactionStatus>;
13
+ getTransactionDetail(txHash: string): Promise<BitcoinTx>;
14
+ getFeeRate(): Promise<BitcoinFeeInfo>;
15
+ getRecommendedFeeRate(): Promise<BitcoinFeeInfo>;
16
+ getUtxos(address: string): Promise<UtxoResponseItem[]>;
17
+ getTxHex(txHash: string): Promise<string>;
18
+ sendRawTransaction(rawTransaction: string): EventEmitter<BitcoinTransactionEventMap>;
19
+ simpleSendRawTransaction(rawTransaction: string): Promise<string>;
20
+ }
21
+ export interface BitcoinTransactionEventMap {
22
+ extrinsicHash: (txHash: string) => void;
23
+ error: (error: string) => void;
24
+ success: (data: BitcoinTransactionStatus) => void;
25
+ }
26
+ export interface BlockStreamBlock {
27
+ id: string;
28
+ height: number;
29
+ version: number;
30
+ timestamp: number;
31
+ tx_count: number;
32
+ size: number;
33
+ weight: number;
34
+ merkle_root: string;
35
+ previousblockhash: string;
36
+ mediantime: number;
37
+ nonce: number;
38
+ bits: number;
39
+ difficulty: number;
40
+ }
41
+ export interface BlockstreamAddressResponse {
42
+ address: string;
43
+ chain_stats: {
44
+ funded_txo_count: number;
45
+ funded_txo_sum: number;
46
+ spent_txo_count: number;
47
+ spent_txo_sum: number;
48
+ tx_count: number;
49
+ };
50
+ mempool_stats: {
51
+ funded_txo_count: number;
52
+ funded_txo_sum: number;
53
+ spent_txo_count: number;
54
+ spent_txo_sum: number;
55
+ tx_count: number;
56
+ };
57
+ }
58
+ export interface BitcoinAddressSummaryInfo extends BlockstreamAddressResponse {
59
+ balance: number;
60
+ total_inscription: number;
61
+ balance_rune: string;
62
+ balance_inscription: string;
63
+ }
64
+ export interface RunesInfoByAddressResponse {
65
+ statusCode: number;
66
+ data: RunesInfoByAddressFetchedData;
67
+ }
68
+ export interface RunesInfoByAddressFetchedData {
69
+ limit: number;
70
+ offset: number;
71
+ total: number;
72
+ runes: RunesInfoByAddress[];
73
+ }
74
+ export interface RunesInfoByAddress {
75
+ amount: string;
76
+ address: string;
77
+ rune_id: string;
78
+ rune: {
79
+ rune: string;
80
+ rune_name: string;
81
+ divisibility: number;
82
+ premine: string;
83
+ spacers: string;
84
+ symbol: string;
85
+ };
86
+ }
87
+ export interface RunesCollectionInfoResponse {
88
+ statusCode: number;
89
+ data: RunesCollectionInfoFetchedData;
90
+ }
91
+ interface RunesCollectionInfoFetchedData {
92
+ limit: number;
93
+ offset: number;
94
+ total: number;
95
+ runes: RunesCollectionInfo[];
96
+ }
97
+ export interface RunesCollectionInfo {
98
+ rune_id: string;
99
+ rune: string;
100
+ rune_name: string;
101
+ divisibility: string;
102
+ spacers: string;
103
+ }
104
+ export interface RuneTxsResponse {
105
+ statusCode: number;
106
+ data: RuneTxsFetchedData;
107
+ }
108
+ interface RuneTxsFetchedData {
109
+ limit: number;
110
+ offset: number;
111
+ total: number;
112
+ transactions: RuneTxs[];
113
+ }
114
+ export interface RuneTxs {
115
+ txid: string;
116
+ vout: RuneTxsUtxosVout[];
117
+ }
118
+ interface RuneTxsUtxosVout {
119
+ n: number;
120
+ value: number;
121
+ runeInject: any;
122
+ }
123
+ export interface Brc20MetadataFetchedData {
124
+ token: Brc20Metadata;
125
+ }
126
+ export interface Brc20Metadata {
127
+ ticker: string;
128
+ decimals: number;
129
+ }
130
+ export interface Brc20BalanceFetchedData {
131
+ limit: number;
132
+ offset: number;
133
+ total: number;
134
+ results: Brc20Balance[];
135
+ }
136
+ export interface Brc20Balance {
137
+ ticker: string;
138
+ available_balance: string;
139
+ transferrable_balance: string;
140
+ overall_balance: string;
141
+ }
142
+ export interface Brc20BalanceItem {
143
+ free: string;
144
+ locked: string;
145
+ }
146
+ export interface InscriptionFetchedData {
147
+ limit: number;
148
+ offset: number;
149
+ total: number;
150
+ results: Inscription[];
151
+ }
152
+ export interface Inscription {
153
+ id: string;
154
+ number: number;
155
+ address: string;
156
+ genesis_block_height: number;
157
+ genesis_block_hash: string;
158
+ genesis_timestamp: number;
159
+ tx_id: string;
160
+ location: string;
161
+ output: string;
162
+ value: string;
163
+ offset: string;
164
+ fee: number;
165
+ sat_ordinal: string;
166
+ sat_rarity: string;
167
+ content_type: string;
168
+ content_length: number;
169
+ }
170
+ export interface UpdateOpenBitUtxo {
171
+ totalUtxo: number;
172
+ utxoItems: BlockStreamUtxo[];
173
+ }
174
+ export interface BlockStreamUtxo {
175
+ txid: string;
176
+ vout: number;
177
+ status: {
178
+ confirmed: boolean;
179
+ block_height?: number;
180
+ block_hash: string;
181
+ block_time?: number;
182
+ };
183
+ value: number;
184
+ }
185
+ export interface BlockStreamTransactionStatus {
186
+ confirmed: boolean;
187
+ block_height: number;
188
+ block_hash: string;
189
+ block_time: number;
190
+ }
191
+ export interface BlockStreamFeeEstimates {
192
+ 1: number;
193
+ 2: number;
194
+ 3: number;
195
+ 4: number;
196
+ 5: number;
197
+ 6: number;
198
+ 7: number;
199
+ 8: number;
200
+ }
201
+ export interface RecommendedFeeEstimates {
202
+ fastestFee: number;
203
+ halfHourFee: number;
204
+ hourFee: number;
205
+ economyFee: number;
206
+ minimumFee: number;
207
+ }
208
+ export interface BlockStreamTransactionVectorOutput {
209
+ scriptpubkey: string;
210
+ scriptpubkey_asm: string;
211
+ scriptpubkey_type: string;
212
+ scriptpubkey_address: string;
213
+ value: number;
214
+ }
215
+ export interface BlockStreamTransactionVectorInput {
216
+ is_coinbase: boolean;
217
+ prevout: BlockStreamTransactionVectorOutput;
218
+ scriptsig: string;
219
+ scriptsig_asm: string;
220
+ sequence: number;
221
+ txid: string;
222
+ vout: number;
223
+ witness: string[];
224
+ }
225
+ export interface BlockStreamTransactionDetail {
226
+ txid: string;
227
+ version: number;
228
+ locktime: number;
229
+ totalVin: number;
230
+ totalVout: number;
231
+ size: number;
232
+ weight: number;
233
+ fee: number;
234
+ status: {
235
+ confirmed: boolean;
236
+ block_height?: number;
237
+ block_hash?: string;
238
+ block_time?: number;
239
+ };
240
+ vin: BlockStreamTransactionVectorInput[];
241
+ vout: BlockStreamTransactionVectorOutput[];
242
+ }
243
+ export interface RuneUtxoResponse {
244
+ total: number;
245
+ results: RuneUtxo[];
246
+ }
247
+ export interface RuneUtxo {
248
+ height: number;
249
+ confirmations: number;
250
+ address: string;
251
+ satoshi: number;
252
+ scriptPk: string;
253
+ txid: string;
254
+ vout: number;
255
+ runes: RuneInject[];
256
+ }
257
+ interface RuneInject {
258
+ rune: string;
259
+ runeid: string;
260
+ spacedRune: string;
261
+ amount: string;
262
+ symbol: string;
263
+ divisibility: number;
264
+ }
265
+ export interface RuneMetadata {
266
+ id: string;
267
+ mintable: boolean;
268
+ parent: string;
269
+ entry: RuneInfo;
270
+ }
271
+ interface RuneInfo {
272
+ block: number;
273
+ burned: string;
274
+ divisibility: number;
275
+ etching: string;
276
+ mints: string;
277
+ number: number;
278
+ premine: string;
279
+ spaced_rune: string;
280
+ symbol: string;
281
+ terms: RuneTerms;
282
+ timestamp: string;
283
+ turbo: boolean;
284
+ }
285
+ interface RuneTerms {
286
+ amount: string;
287
+ cap: string;
288
+ height: string[];
289
+ offset: string[];
290
+ }
291
+ export {};
@@ -18,6 +18,7 @@ export declare class ChainService {
18
18
  private lockChainInfoMap;
19
19
  private substrateChainHandler;
20
20
  private evmChainHandler;
21
+ private bitcoinChainHandler;
21
22
  private tonChainHandler;
22
23
  private cardanoChainHandler;
23
24
  private mantaChainHandler;
@@ -58,6 +59,8 @@ export declare class ChainService {
58
59
  getEvmApiMap(): Record<string, import("./handler/EvmApi").EvmApi>;
59
60
  getSubstrateApi(slug: string): _SubstrateApi;
60
61
  getSubstrateApiMap(): Record<string, _SubstrateApi>;
62
+ getBitcoinApi(slug: string): import("./handler/bitcoin/BitcoinApi").BitcoinApi;
63
+ getBitcoinApiMap(): Record<string, import("./handler/bitcoin/BitcoinApi").BitcoinApi>;
61
64
  getTonApi(slug: string): import("./handler/TonApi").TonApi;
62
65
  getTonApiMap(): Record<string, import("./handler/TonApi").TonApi>;
63
66
  getCardanoApi(slug: string): import("./handler/CardanoApi").CardanoApi;
@@ -4,6 +4,7 @@
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
6
  import { _DEFAULT_ACTIVE_CHAINS, _ZK_ASSET_PREFIX, LATEST_CHAIN_DATA_FETCHING_INTERVAL } from '@subwallet/extension-base/services/chain-service/constants';
7
+ import { BitcoinChainHandler } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/BitcoinChainHandler';
7
8
  import { CardanoChainHandler } from '@subwallet/extension-base/services/chain-service/handler/CardanoChainHandler';
8
9
  import { EvmChainHandler } from '@subwallet/extension-base/services/chain-service/handler/EvmChainHandler';
9
10
  import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
@@ -11,7 +12,7 @@ import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-
11
12
  import { TonChainHandler } from '@subwallet/extension-base/services/chain-service/handler/TonChainHandler';
12
13
  import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
13
14
  import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
14
- import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
15
+ import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainBitcoinCompatible, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isNativeToken, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
15
16
  import { MYTHOS_MIGRATION_KEY } from '@subwallet/extension-base/services/migration-service/scripts';
16
17
  import { convertUtxoRawToUtxo } from '@subwallet/extension-base/services/request-service/helper';
17
18
  import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
@@ -21,11 +22,19 @@ import Web3 from 'web3';
21
22
  import { isArray } from '@polkadot/util';
22
23
  import { logger as createLogger } from '@polkadot/util/logger';
23
24
  const filterChainInfoMap = (data, ignoredChains) => {
24
- return Object.fromEntries(Object.entries(data).filter(([slug, info]) => !info.bitcoinInfo && !ignoredChains.includes(slug)));
25
+ return Object.fromEntries(Object.entries(data).filter(([slug, info]) => !ignoredChains.includes(slug)));
25
26
  };
27
+ // .filter(([slug, info]) => !info.bitcoinInfo && !ignoredChains.includes(slug))
28
+
26
29
  const ignoredList = ['bevm', 'bevmTest', 'bevm_testnet', 'layerEdge_testnet', 'merlinEvm', 'botanixEvmTest', 'syscoin_evm', 'syscoin_evm_testnet', 'rollux_evm', 'rollux_testnet', 'boolAlpha', 'boolBeta_testnet', 'core', 'satoshivm', 'satoshivm_testnet', 'storyPartner_testnet'];
27
30
  export const filterAssetInfoMap = (chainInfo, assets, addedChains) => {
28
- return Object.fromEntries(Object.entries(assets).filter(([, info]) => chainInfo[info.originChain] || (addedChains === null || addedChains === void 0 ? void 0 : addedChains.includes(info.originChain))));
31
+ return Object.fromEntries(Object.entries(assets).filter(([, info]) => {
32
+ const isBitcoinChain = (chainInfo === null || chainInfo === void 0 ? void 0 : chainInfo[info.originChain]) && _isChainBitcoinCompatible(chainInfo[info.originChain]);
33
+ if (isBitcoinChain) {
34
+ return ![_AssetType.RUNE, _AssetType.BRC20].includes(info.assetType);
35
+ }
36
+ return chainInfo[info.originChain] || (addedChains === null || addedChains === void 0 ? void 0 : addedChains.includes(info.originChain));
37
+ }));
29
38
  };
30
39
  export class ChainService {
31
40
  dataMap = {
@@ -73,6 +82,7 @@ export class ChainService {
73
82
  this.evmChainHandler = new EvmChainHandler(this);
74
83
  this.tonChainHandler = new TonChainHandler(this);
75
84
  this.cardanoChainHandler = new CardanoChainHandler(this);
85
+ this.bitcoinChainHandler = new BitcoinChainHandler(this);
76
86
  this.logger = createLogger('chain-service');
77
87
  }
78
88
  get value() {
@@ -148,6 +158,12 @@ export class ChainService {
148
158
  getSubstrateApiMap() {
149
159
  return this.substrateChainHandler.getSubstrateApiMap();
150
160
  }
161
+ getBitcoinApi(slug) {
162
+ return this.bitcoinChainHandler.getApiByChain(slug);
163
+ }
164
+ getBitcoinApiMap() {
165
+ return this.bitcoinChainHandler.getApiMap();
166
+ }
151
167
  getTonApi(slug) {
152
168
  return this.tonChainHandler.getTonApiByChain(slug);
153
169
  }
@@ -823,6 +839,13 @@ export class ChainService {
823
839
  });
824
840
  this.cardanoChainHandler.setCardanoApi(chainInfo.slug, chainApi);
825
841
  }
842
+ if (chainInfo.bitcoinInfo !== null && chainInfo.bitcoinInfo !== undefined) {
843
+ const chainApi = await this.bitcoinChainHandler.initApi(chainInfo.slug, endpoint, {
844
+ providerName,
845
+ onUpdateStatus
846
+ });
847
+ this.bitcoinChainHandler.setApi(chainInfo.slug, chainApi);
848
+ }
826
849
  }
827
850
  destroyApiForChain(chainInfo) {
828
851
  if (chainInfo.substrateInfo !== null) {
@@ -837,6 +860,9 @@ export class ChainService {
837
860
  if (chainInfo.cardanoInfo !== null) {
838
861
  this.cardanoChainHandler.destroyCardanoApi(chainInfo.slug);
839
862
  }
863
+ if (chainInfo.bitcoinInfo !== null && chainInfo.bitcoinInfo !== undefined) {
864
+ this.bitcoinChainHandler.destroyApi(chainInfo.slug);
865
+ }
840
866
  }
841
867
  async enableChain(chainSlug) {
842
868
  const chainInfo = this.getChainInfoByKey(chainSlug);
@@ -1692,11 +1718,11 @@ export class ChainService {
1692
1718
  this.evmChainHandler.recoverApi(slug).catch(console.error);
1693
1719
  }
1694
1720
  async stopAllChainApis() {
1695
- await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep(), this.cardanoChainHandler.sleep()]);
1721
+ await Promise.all([this.substrateChainHandler.sleep(), this.evmChainHandler.sleep(), this.tonChainHandler.sleep(), this.cardanoChainHandler.sleep(), this.bitcoinChainHandler.sleep()]);
1696
1722
  this.stopCheckLatestChainData();
1697
1723
  }
1698
1724
  async resumeAllChainApis() {
1699
- await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp(), this.cardanoChainHandler.wakeUp()]);
1725
+ await Promise.all([this.substrateChainHandler.wakeUp(), this.evmChainHandler.wakeUp(), this.tonChainHandler.wakeUp(), this.cardanoChainHandler.wakeUp(), this.bitcoinChainHandler.wakeUp()]);
1700
1726
  this.checkLatestData();
1701
1727
  }
1702
1728
  initAssetSettings() {
@@ -2,6 +2,7 @@ import type { ApiInterfaceRx } from '@polkadot/api/types';
2
2
  import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _CrowdloanFund } from '@subwallet/chain-list/types';
3
3
  import { CardanoBalanceItem } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/cardano/types';
4
4
  import { AccountState, TxByMsgResponse } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/types';
5
+ import { BitcoinApiStrategy } from '@subwallet/extension-base/services/chain-service/handler/bitcoin/strategy/types';
5
6
  import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
6
7
  import { TonWalletContract } from '@subwallet/keyring/types';
7
8
  import { Cell } from '@ton/core';
@@ -186,4 +187,23 @@ export interface _ValidateCustomAssetResponse extends _SmartContractTokenInfo {
186
187
  export declare const _FUNGIBLE_CONTRACT_STANDARDS: _AssetType[];
187
188
  export declare const _NFT_CONTRACT_STANDARDS: _AssetType[];
188
189
  export declare const _SMART_CONTRACT_STANDARDS: _AssetType[];
190
+ export interface BitcoinApiProxy {
191
+ setBaseUrl: (baseUrl: string) => void;
192
+ getRequest: (urlPath: string, params?: Record<string, string>, headers?: Record<string, string>) => Promise<Response>;
193
+ postRequest: (urlPath: string, body?: BodyInit, headers?: Record<string, string>) => Promise<Response>;
194
+ }
195
+ export interface _BitcoinApi extends _ChainBaseApi {
196
+ isReady: Promise<_BitcoinApi>;
197
+ api: BitcoinApiStrategy;
198
+ }
199
+ export interface OBResponse<T> {
200
+ status_code: number;
201
+ message: string;
202
+ result: T;
203
+ }
204
+ export interface OBRuneResponse<T> {
205
+ status_code: number;
206
+ message: string;
207
+ result: T;
208
+ }
189
209
  export {};
@@ -3,6 +3,7 @@ import { BasicTokenInfo } from '@subwallet/extension-base/background/KoniTypes';
3
3
  import { _ChainState, _DataMap } from '@subwallet/extension-base/services/chain-service/types';
4
4
  import { IChain } from '@subwallet/extension-base/services/storage-service/databases';
5
5
  import { AccountChainType } from '@subwallet/extension-base/types';
6
+ import { KeypairType } from '@subwallet/keyring/types';
6
7
  export declare function _isCustomChain(slug: string): boolean;
7
8
  export declare function _isCustomAsset(slug: string): boolean;
8
9
  export declare function _getCustomAssets(assetRegistry: Record<string, _ChainAsset>): Record<string, _ChainAsset>;
@@ -12,6 +13,7 @@ export declare function _isPureEvmChain(chainInfo: _ChainInfo): boolean;
12
13
  export declare function _isPureSubstrateChain(chainInfo: _ChainInfo): boolean;
13
14
  export declare function _isPureTonChain(chainInfo: _ChainInfo): boolean;
14
15
  export declare function _isPureCardanoChain(chainInfo: _ChainInfo): boolean;
16
+ export declare function _isPureBitcoinChain(chainInfo: _ChainInfo): boolean;
15
17
  export declare function _getOriginChainOfAsset(assetSlug: string): string;
16
18
  export declare function _getContractAddressOfToken(tokenInfo: _ChainAsset): string;
17
19
  /**
@@ -32,6 +34,7 @@ export declare function _checkSmartContractSupportByChain(chainInfo: _ChainInfo,
32
34
  export declare function _isJettonToken(tokenInfo: _ChainAsset): boolean;
33
35
  export declare function _isTokenTransferredByTon(tokenInfo: _ChainAsset): boolean;
34
36
  export declare function _isTokenTransferredByCardano(tokenInfo: _ChainAsset): boolean;
37
+ export declare function _isTokenTransferredByBitcoin(tokenInfo: _ChainAsset): boolean;
35
38
  export declare function _getTokenOnChainAssetId(tokenInfo: _ChainAsset): string;
36
39
  export declare function _getTokenOnChainInfo(tokenInfo: _ChainAsset): Record<string, any>;
37
40
  export declare function _isBridgedToken(tokenInfo: _ChainAsset): boolean;
@@ -116,5 +119,6 @@ export declare function updateLatestChainInfo(currentDataMap: _DataMap, latestCh
116
119
  needUpdateChainApiList: _ChainInfo[];
117
120
  };
118
121
  export declare const _chainInfoToChainType: (chainInfo: _ChainInfo) => AccountChainType;
122
+ export declare const _isChainInfoCompatibleWithAccountInfo: (chainInfo: _ChainInfo, accountChainType: AccountChainType, accountType: KeypairType) => boolean;
119
123
  export declare const _getAssetNetuid: (assetInfo: _ChainAsset) => number;
120
124
  export * from './patch';
@@ -5,6 +5,7 @@ import { _AssetRefPath, _AssetType, _ChainStatus, _SubstrateChainType } from '@s
5
5
  import { _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
6
6
  import { _CUSTOM_PREFIX, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
7
7
  import { AccountChainType } from '@subwallet/extension-base/types';
8
+ import { BitcoinMainnetKeypairTypes, BitcoinTestnetKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
8
9
  import { isEthereumAddress } from '@polkadot/util-crypto';
9
10
  export function _isCustomChain(slug) {
10
11
  if (slug.length === 0) {
@@ -48,16 +49,19 @@ export function _isEqualSmartContractAsset(asset1, asset2) {
48
49
  return false;
49
50
  }
50
51
  export function _isPureEvmChain(chainInfo) {
51
- return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
52
+ return !!chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
52
53
  }
53
54
  export function _isPureSubstrateChain(chainInfo) {
54
- return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo;
55
+ return !chainInfo.evmInfo && !!chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
55
56
  }
56
57
  export function _isPureTonChain(chainInfo) {
57
- return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo && !chainInfo.cardanoInfo;
58
+ return !chainInfo.evmInfo && !chainInfo.substrateInfo && !!chainInfo.tonInfo && !chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
58
59
  }
59
60
  export function _isPureCardanoChain(chainInfo) {
60
- return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !!chainInfo.cardanoInfo;
61
+ return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !!chainInfo.cardanoInfo && !chainInfo.bitcoinInfo;
62
+ }
63
+ export function _isPureBitcoinChain(chainInfo) {
64
+ return !chainInfo.evmInfo && !chainInfo.substrateInfo && !chainInfo.tonInfo && !chainInfo.cardanoInfo && !!chainInfo.bitcoinInfo;
61
65
  }
62
66
  export function _getOriginChainOfAsset(assetSlug) {
63
67
  if (assetSlug.startsWith(_CUSTOM_PREFIX)) {
@@ -114,6 +118,11 @@ export function _isTokenTransferredByCardano(tokenInfo) {
114
118
  return _isCIP26Token(tokenInfo) || _isNativeToken(tokenInfo);
115
119
  }
116
120
 
121
+ // TODO [Review]: Currently supports transferring only the native token, Bitcoin.
122
+ export function _isTokenTransferredByBitcoin(tokenInfo) {
123
+ return _isNativeToken(tokenInfo);
124
+ }
125
+
117
126
  // Utils for balance functions
118
127
  export function _getTokenOnChainAssetId(tokenInfo) {
119
128
  var _tokenInfo$metadata5;
@@ -289,6 +298,11 @@ export function _getChainNativeTokenBasicInfo(chainInfo) {
289
298
  symbol: chainInfo.cardanoInfo.symbol,
290
299
  decimals: chainInfo.cardanoInfo.decimals
291
300
  };
301
+ } else if (chainInfo.bitcoinInfo) {
302
+ return {
303
+ symbol: chainInfo.bitcoinInfo.symbol,
304
+ decimals: chainInfo.bitcoinInfo.decimals
305
+ };
292
306
  }
293
307
  return defaultTokenInfo;
294
308
  }
@@ -402,6 +416,9 @@ export function _getBlockExplorerFromChain(chainInfo) {
402
416
  } else if (_isPureCardanoChain(chainInfo)) {
403
417
  var _chainInfo$cardanoInf;
404
418
  blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$cardanoInf = chainInfo.cardanoInfo) === null || _chainInfo$cardanoInf === void 0 ? void 0 : _chainInfo$cardanoInf.blockExplorer;
419
+ } else if (_isPureBitcoinChain(chainInfo)) {
420
+ var _chainInfo$bitcoinInf;
421
+ blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$bitcoinInf = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf === void 0 ? void 0 : _chainInfo$bitcoinInf.blockExplorer;
405
422
  } else {
406
423
  var _chainInfo$substrateI18;
407
424
  blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.blockExplorer;
@@ -577,6 +594,35 @@ export const _chainInfoToChainType = chainInfo => {
577
594
  }
578
595
  return AccountChainType.SUBSTRATE;
579
596
  };
597
+ export const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountChainType, accountType) => {
598
+ if (accountChainType === AccountChainType.SUBSTRATE) {
599
+ return _isPureSubstrateChain(chainInfo) && SubstrateKeypairTypes.includes(accountType);
600
+ }
601
+ if (accountChainType === AccountChainType.ETHEREUM) {
602
+ return _isChainEvmCompatible(chainInfo) && EthereumKeypairTypes.includes(accountType);
603
+ }
604
+ if (accountChainType === AccountChainType.TON) {
605
+ return _isChainTonCompatible(chainInfo) && TonKeypairTypes.includes(accountType);
606
+ }
607
+ if (accountChainType === AccountChainType.CARDANO) {
608
+ return _isChainCardanoCompatible(chainInfo) && CardanoKeypairTypes.includes(accountType);
609
+ }
610
+ if (accountChainType === AccountChainType.BITCOIN) {
611
+ var _chainInfo$bitcoinInf2;
612
+ if (!_isChainBitcoinCompatible(chainInfo) || ![...BitcoinMainnetKeypairTypes, ...BitcoinTestnetKeypairTypes].includes(accountType)) {
613
+ return false;
614
+ }
615
+ const network = (_chainInfo$bitcoinInf2 = chainInfo.bitcoinInfo) === null || _chainInfo$bitcoinInf2 === void 0 ? void 0 : _chainInfo$bitcoinInf2.bitcoinNetwork;
616
+ if (BitcoinMainnetKeypairTypes.includes(accountType)) {
617
+ return network === 'mainnet';
618
+ }
619
+ if (BitcoinTestnetKeypairTypes.includes(accountType)) {
620
+ return network === 'testnet';
621
+ }
622
+ return false;
623
+ }
624
+ return false;
625
+ };
580
626
  export const _getAssetNetuid = assetInfo => {
581
627
  var _assetInfo$metadata$n, _assetInfo$metadata;
582
628
  // @ts-ignore
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
5
5
  const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
6
6
  const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
7
7
  const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
8
- const ChainListVersion = '0.2.105'; // update this when build chainlist
8
+ const ChainListVersion = '0.2.107'; // update this when build chainlist
9
9
 
10
10
  // todo: move this interface to chainlist
11
11
 
@@ -37,17 +37,6 @@ interface Validator {
37
37
  take: string;
38
38
  apr: string;
39
39
  }
40
- export declare const BITTENSOR_API_KEY_1: string;
41
- export declare const BITTENSOR_API_KEY_2: string;
42
- export declare const BITTENSOR_API_KEY_3: string;
43
- export declare const BITTENSOR_API_KEY_4: string;
44
- export declare const BITTENSOR_API_KEY_5: string;
45
- export declare const BITTENSOR_API_KEY_6: string;
46
- export declare const BITTENSOR_API_KEY_7: string;
47
- export declare const BITTENSOR_API_KEY_8: string;
48
- export declare const BITTENSOR_API_KEY_9: string;
49
- export declare const BITTENSOR_API_KEY_10: string;
50
- export declare const bittensorApiKey: () => string;
51
40
  export declare class BittensorCache {
52
41
  private static instance;
53
42
  private cache;
@@ -8,31 +8,13 @@ import { getEarningStatusByNominations } from '@subwallet/extension-base/koni/ap
8
8
  import { _getAssetDecimals, _getAssetSymbol } from '@subwallet/extension-base/services/chain-service/utils';
9
9
  import BaseParaStakingPoolHandler from '@subwallet/extension-base/services/earning-service/handlers/native-staking/base-para';
10
10
  import { BasicTxErrorType, EarningStatus } from '@subwallet/extension-base/types';
11
- import { formatNumber, reformatAddress } from '@subwallet/extension-base/utils';
11
+ import { ProxyServiceRoute } from '@subwallet/extension-base/types/environment';
12
+ import { fetchFromProxyService, formatNumber, reformatAddress } from '@subwallet/extension-base/utils';
12
13
  import BigN from 'bignumber.js';
13
14
  import { t } from 'i18next';
14
15
  import { BN, BN_ZERO } from '@polkadot/util';
15
16
  import { calculateReward } from "../../utils/index.js";
16
17
  import { DEFAULT_DTAO_MINBOND } from "./dtao.js";
17
- export const BITTENSOR_API_KEY_1 = process.env.BITTENSOR_API_KEY_1 || '';
18
- export const BITTENSOR_API_KEY_2 = process.env.BITTENSOR_API_KEY_2 || '';
19
- export const BITTENSOR_API_KEY_3 = process.env.BITTENSOR_API_KEY_3 || '';
20
- export const BITTENSOR_API_KEY_4 = process.env.BITTENSOR_API_KEY_4 || '';
21
- export const BITTENSOR_API_KEY_5 = process.env.BITTENSOR_API_KEY_5 || '';
22
- export const BITTENSOR_API_KEY_6 = process.env.BITTENSOR_API_KEY_6 || '';
23
- export const BITTENSOR_API_KEY_7 = process.env.BITTENSOR_API_KEY_7 || '';
24
- export const BITTENSOR_API_KEY_8 = process.env.BITTENSOR_API_KEY_8 || '';
25
- export const BITTENSOR_API_KEY_9 = process.env.BITTENSOR_API_KEY_9 || '';
26
- export const BITTENSOR_API_KEY_10 = process.env.BITTENSOR_API_KEY_10 || '';
27
- function random(...keys) {
28
- const validKeys = keys.filter(key => key);
29
- const randomIndex = Math.floor(Math.random() * validKeys.length);
30
- return validKeys[randomIndex];
31
- }
32
- export const bittensorApiKey = () => {
33
- return random(BITTENSOR_API_KEY_1, BITTENSOR_API_KEY_2, BITTENSOR_API_KEY_3, BITTENSOR_API_KEY_4, BITTENSOR_API_KEY_5, BITTENSOR_API_KEY_6, BITTENSOR_API_KEY_7, BITTENSOR_API_KEY_8, BITTENSOR_API_KEY_9, BITTENSOR_API_KEY_10);
34
- };
35
-
36
18
  /* Fetch data */
37
19
  export class BittensorCache {
38
20
  static instance = null;
@@ -59,13 +41,11 @@ export class BittensorCache {
59
41
  return this.promise;
60
42
  }
61
43
  async fetchData() {
62
- const apiKey = bittensorApiKey();
63
44
  try {
64
- const resp = await fetch('https://api.taostats.io/api/validator/latest/v1?limit=50', {
45
+ const resp = await fetchFromProxyService(ProxyServiceRoute.BITTENSOR, '/validator/latest/v1?limit=50', {
65
46
  method: 'GET',
66
47
  headers: {
67
- 'Content-Type': 'application/json',
68
- Authorization: `${apiKey}`
48
+ 'Content-Type': 'application/json'
69
49
  }
70
50
  });
71
51
  if (!resp.ok) {
@@ -6,6 +6,9 @@ export declare class EventService extends EventEmitter<EventRegistry> {
6
6
  private lazyEmitter;
7
7
  readonly waitCryptoReady: Promise<boolean>;
8
8
  readonly waitDatabaseReady: Promise<boolean>;
9
+ readonly waitAppInitialized: Promise<boolean>;
10
+ readonly waitAppStart: Promise<boolean>;
11
+ readonly waitAppStartFull: Promise<boolean>;
9
12
  readonly waitKeyringReady: Promise<boolean>;
10
13
  readonly waitAccountReady: Promise<boolean>;
11
14
  readonly waitInjectReady: Promise<boolean>;
@@ -18,6 +18,10 @@ export class EventService extends EventEmitter {
18
18
  this.waitDatabaseReady = this.generateWaitPromise('database.ready');
19
19
  this.waitKeyringReady = this.generateWaitPromise('keyring.ready');
20
20
  this.waitAccountReady = this.generateWaitPromise('account.ready');
21
+ this.waitAppInitialized = this.generateWaitPromise('general.init');
22
+ this.waitAppStart = this.generateWaitPromise('general.start');
23
+ this.waitAppStartFull = this.generateWaitPromise('general.start_full');
24
+
21
25
  // TODO: Need to merge logic on web-runner file
22
26
  this.waitInjectReady = TARGET_ENV === 'webapp' ? this.generateWaitPromise('inject.ready') : Promise.resolve(true);
23
27
  this.waitChainReady = this.generateWaitPromise('chain.ready');