@rabby-wallet/rabby-api 0.9.60-beta.2 → 0.9.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2024 +1,2024 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11
- if (kind === "m") throw new TypeError("Private method is not writable");
12
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
- };
16
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
- };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
- var _OpenApiService_adapter, _OpenApiService_plugin, _OpenApiService_clientName, _OpenApiService_clientVersion;
33
- import axios from 'axios';
34
- import rateLimit from 'axios-rate-limit';
35
- import { ethErrors } from 'eth-rpc-errors';
36
- import { genSignParams, sleep } from './utils';
37
- import { omit } from 'lodash';
38
- import { ASYNC_JOB_RETRY_DELAY, ASYNC_JOB_TIMEOUT } from './const';
39
- var CurveDayType;
40
- (function (CurveDayType) {
41
- CurveDayType[CurveDayType["DAY"] = 1] = "DAY";
42
- CurveDayType[CurveDayType["WEEK"] = 7] = "WEEK";
43
- })(CurveDayType || (CurveDayType = {}));
44
- const maxRPS = 500;
45
- export class OpenApiService {
46
- constructor(_a) {
47
- var _b;
48
- var { store, plugin, adapter, clientName = 'Rabby', clientVersion = (_b = process.env.release) !== null && _b !== void 0 ? _b : '0.0.0', } = _a;
49
- _OpenApiService_adapter.set(this, void 0);
50
- _OpenApiService_plugin.set(this, void 0);
51
- _OpenApiService_clientName.set(this, void 0);
52
- _OpenApiService_clientVersion.set(this, void 0);
53
- this.setHost = (host) => __awaiter(this, void 0, void 0, function* () {
54
- this.store.host = host;
55
- yield this.init();
56
- });
57
- this.setHostSync = (host) => {
58
- this.store.host = host;
59
- this.initSync();
60
- };
61
- this.setAPIKey = (apiKey) => __awaiter(this, void 0, void 0, function* () {
62
- this.store.apiKey = apiKey;
63
- yield this.init();
64
- });
65
- this.setAPITime = (apiTime) => __awaiter(this, void 0, void 0, function* () {
66
- this.store.apiTime = apiTime;
67
- yield this.init();
68
- });
69
- this.removeAPIKey = () => __awaiter(this, void 0, void 0, function* () {
70
- this.store.apiKey = null;
71
- this.store.apiTime = null;
72
- yield this.init();
73
- });
74
- this.getHost = () => {
75
- return this.store.host;
76
- };
77
- this.setTestnetHost = (host) => __awaiter(this, void 0, void 0, function* () {
78
- this.store.testnetHost = host;
79
- });
80
- this.getTestnetHost = () => {
81
- return this.store.testnetHost;
82
- };
83
- this.ethRpc = () => __awaiter(this, void 0, void 0, function* () {
84
- throw ethErrors.provider.disconnected();
85
- });
86
- this.init = (options) => __awaiter(this, void 0, void 0, function* () {
87
- var _c, _d;
88
- options = typeof options === 'string' ? { webHf: options } : options;
89
- yield ((_d = (_c = __classPrivateFieldGet(this, _OpenApiService_plugin, "f")).onInitiateAsync) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign({}, options)));
90
- this.initSync(Object.assign({}, options));
91
- });
92
- this.getSafePendingTransactions = ({ txServiceUrl, safeAddress, nonce, }) => __awaiter(this, void 0, void 0, function* () {
93
- const { data } = yield this.request.get(`${txServiceUrl}/v1/safes/${safeAddress}/multisig-transactions/`, {
94
- params: {
95
- executed: false,
96
- nonce__gte: nonce,
97
- },
98
- });
99
- return data;
100
- });
101
- this.postSafeTransactions = ({ txServiceUrl, safeAddress, data, }) => __awaiter(this, void 0, void 0, function* () {
102
- yield this.request.post(`${txServiceUrl}/v1/safes/${safeAddress}/multisig-transactions/`, data);
103
- });
104
- this.getSafeInfo = ({ txServiceUrl, safeAddress, }) => __awaiter(this, void 0, void 0, function* () {
105
- const { data } = yield this.request.get(`${txServiceUrl}/v1/safes/${safeAddress}/`);
106
- return data;
107
- });
108
- this.confirmSafeTransaction = ({ txServiceUrl, safeTransactionHash, data, }) => __awaiter(this, void 0, void 0, function* () {
109
- yield this.request.post(`${txServiceUrl}/v1/multisig-transactions/${safeTransactionHash}/confirmations/`, data);
110
- });
111
- this.getSafeTxGas = ({ txServiceUrl, safeAddress, safeTxData, }) => __awaiter(this, void 0, void 0, function* () {
112
- const { data } = yield this.request.post(`${txServiceUrl}/v1/safes/${safeAddress}/multisig-transactions/estimations/`, {
113
- to: safeTxData.to,
114
- value: safeTxData.value || '0',
115
- data: safeTxData.data,
116
- operation: safeTxData.operation,
117
- });
118
- return data === null || data === void 0 ? void 0 : data.safeTxGas;
119
- });
120
- this.getSafeMessages = ({ txServiceUrl, safeAddress, options, }) => __awaiter(this, void 0, void 0, function* () {
121
- const { data } = yield this.request.get(`${txServiceUrl}/v1/safes/${safeAddress}/messages/`, {
122
- params: options,
123
- });
124
- return data;
125
- });
126
- this.addSafeMessage = ({ txServiceUrl, safeAddress, data, }) => __awaiter(this, void 0, void 0, function* () {
127
- yield this.request.post(`${txServiceUrl}/v1/safes/${safeAddress}/messages/`, data);
128
- });
129
- this.getSafeMessage = ({ txServiceUrl, messageHash, }) => __awaiter(this, void 0, void 0, function* () {
130
- const { data } = yield this.request.get(`${txServiceUrl}/v1/messages/${messageHash}/`);
131
- return data;
132
- });
133
- this.addSafeMessageSignature = ({ txServiceUrl, messageHash, signature, }) => __awaiter(this, void 0, void 0, function* () {
134
- yield this.request.post(`${txServiceUrl}/v1/messages/${messageHash}/signatures/`, {
135
- signature,
136
- });
137
- });
138
- this.asyncJob = (url, options) => {
139
- const _option = Object.assign({ timeout: ASYNC_JOB_TIMEOUT, retryDelay: ASYNC_JOB_RETRY_DELAY }, options);
140
- const startTime = +new Date();
141
- return this.request(url, omit(Object.assign({ method: 'GET' }, _option), 'retryDelay')).then((res) => {
142
- const data = res.data;
143
- if (data.result) {
144
- return data.result.data;
145
- }
146
- const deltaTime = +new Date() - startTime;
147
- _option.timeout = _option.timeout - deltaTime - _option.retryDelay;
148
- return sleep(_option.retryDelay, _option.signal).then(() => this.asyncJob(url, _option));
149
- });
150
- };
151
- this._mountMethods = () => {
152
- this.ethRpc = (chain_id, { origin = 'rabby', method, params }) => {
153
- return this.request
154
- .post(`/v1/wallet/eth_rpc?origin=${origin}&method=${method}`, {
155
- chain_id,
156
- method,
157
- params,
158
- })
159
- .then(({ data }) => {
160
- if (data === null || data === void 0 ? void 0 : data.error) {
161
- throw data.error;
162
- }
163
- return data === null || data === void 0 ? void 0 : data.result;
164
- });
165
- };
166
- };
167
- this.getRecommendChains = (address, origin) => __awaiter(this, void 0, void 0, function* () {
168
- const { data } = yield this.request.get('/v1/wallet/recommend_chains', {
169
- params: {
170
- user_addr: address,
171
- origin,
172
- },
173
- });
174
- return data;
175
- });
176
- this.getTotalBalance = (address, isCore = false) => __awaiter(this, void 0, void 0, function* () {
177
- const { data } = yield this.request.get('/v1/user/total_balance', {
178
- params: {
179
- id: address,
180
- is_core: isCore,
181
- },
182
- });
183
- return data;
184
- });
185
- this.getTotalBalanceV2 = ({ address, isCore = false, included_token_uuids = [], excluded_token_uuids = [], excluded_protocol_ids = [], excluded_chain_ids = [], }) => __awaiter(this, void 0, void 0, function* () {
186
- const { data } = yield this.request.post('/v2/user/total_balance', {
187
- id: address,
188
- is_core: isCore,
189
- included_token_uuids: included_token_uuids,
190
- excluded_token_uuids: excluded_token_uuids,
191
- excluded_protocol_ids: excluded_protocol_ids,
192
- excluded_chain_ids: excluded_chain_ids,
193
- });
194
- return data;
195
- });
196
- this.get24hTotalBalance = (address) => __awaiter(this, void 0, void 0, function* () {
197
- const { data } = yield this.request.get('/v1/user/total_balance_24h', {
198
- params: {
199
- id: address,
200
- },
201
- });
202
- return data;
203
- });
204
- this.getPendingCount = (address) => __awaiter(this, void 0, void 0, function* () {
205
- const { data } = yield this.request.get('/v1/wallet/pending_tx_count', {
206
- params: {
207
- user_addr: address,
208
- },
209
- });
210
- return data;
211
- });
212
- this.checkOrigin = (address, origin) => __awaiter(this, void 0, void 0, function* () {
213
- const { data } = yield this.request.post('/v1/wallet/check_origin', {
214
- user_addr: address,
215
- origin,
216
- });
217
- return data;
218
- });
219
- this.checkText = (address, origin, text) => __awaiter(this, void 0, void 0, function* () {
220
- const { data } = yield this.request.post('/v1/wallet/check_text', {
221
- user_addr: address,
222
- origin,
223
- text,
224
- });
225
- return data;
226
- });
227
- this.checkTx = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
228
- const { data } = yield this.request.post('/v1/wallet/check_tx', {
229
- user_addr: address,
230
- origin,
231
- tx,
232
- update_nonce,
233
- });
234
- return data;
235
- });
236
- this.preExecTx = ({ tx, origin, address, updateNonce = false, pending_tx_list = [], delegate_call, }) => __awaiter(this, void 0, void 0, function* () {
237
- const { data } = yield this.request.post('/v1/wallet/pre_exec_tx', {
238
- tx,
239
- user_addr: address,
240
- origin,
241
- update_nonce: updateNonce,
242
- pending_tx_list,
243
- delegate_call,
244
- });
245
- return data;
246
- });
247
- this.historyGasUsed = (params) => __awaiter(this, void 0, void 0, function* () {
248
- const { data } = yield this.request.post('/v1/wallet/history_tx_used_gas', Object.assign({}, params));
249
- return data;
250
- });
251
- this.pendingTxList = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
252
- const { data } = yield this.request.post('/v1/wallet/pending_tx_list', {
253
- tx,
254
- user_addr: address,
255
- origin,
256
- update_nonce,
257
- });
258
- return data;
259
- });
260
- this.traceTx = (txId, traceId, chainId) => __awaiter(this, void 0, void 0, function* () {
261
- const { data } = yield this.request.post('/v1/wallet/trace_tx', {
262
- tx_id: txId,
263
- trace_id: traceId,
264
- chain_id: chainId,
265
- });
266
- return data;
267
- });
268
- this.pushTx = (tx, traceId) => __awaiter(this, void 0, void 0, function* () {
269
- const { data } = yield this.request.post('/v1/wallet/push_tx', {
270
- tx,
271
- trace_id: traceId,
272
- });
273
- return data;
274
- });
275
- this.explainText = (origin, address, text) => __awaiter(this, void 0, void 0, function* () {
276
- const { data } = yield this.request.post('/v1/wallet/explain_text', {
277
- user_addr: address,
278
- origin,
279
- text,
280
- });
281
- return data;
282
- });
283
- this.gasMarket = (chainId, customGas) => __awaiter(this, void 0, void 0, function* () {
284
- const { data } = yield this.request.get('/v1/wallet/gas_market', {
285
- params: {
286
- chain_id: chainId,
287
- custom_price: customGas,
288
- },
289
- });
290
- return data;
291
- });
292
- this.gasMarketV2 = (options) => __awaiter(this, void 0, void 0, function* () {
293
- const { data } = yield this.request.post('/v2/wallet/gas_market', {
294
- chain_id: options.chainId,
295
- custom_price: options.customGas,
296
- tx: options.tx,
297
- });
298
- return data;
299
- });
300
- this.getTx = (chainId, hash, gasPrice) => __awaiter(this, void 0, void 0, function* () {
301
- const { data } = yield this.request.get('/v1/wallet/get_tx', {
302
- params: {
303
- chain_id: chainId,
304
- gas_price: gasPrice,
305
- tx_id: hash,
306
- },
307
- });
308
- return data;
309
- });
310
- this.getEnsAddressByName = (name) => __awaiter(this, void 0, void 0, function* () {
311
- const { data } = yield this.request.get('/v1/wallet/ens', {
312
- params: {
313
- text: name,
314
- },
315
- });
316
- return data;
317
- });
318
- this.searchToken = (id, q, chainId, is_all = false) => __awaiter(this, void 0, void 0, function* () {
319
- const { data } = yield this.request.get('/v1/user/token_search', {
320
- params: {
321
- id,
322
- q,
323
- has_balance: false,
324
- is_all,
325
- chain_id: chainId,
326
- },
327
- });
328
- return data;
329
- });
330
- this.searchSwapToken = (id, chainId, q, is_all = false) => __awaiter(this, void 0, void 0, function* () {
331
- const { data } = yield this.request.get('/v1/user/token_search', {
332
- params: {
333
- id,
334
- chain_id: chainId,
335
- q,
336
- is_all,
337
- },
338
- });
339
- return data;
340
- });
341
- this.getToken = (id, chainId, tokenId) => __awaiter(this, void 0, void 0, function* () {
342
- const { data } = yield this.request.get('/v1/user/token', {
343
- params: {
344
- id,
345
- chain_id: chainId,
346
- token_id: tokenId,
347
- },
348
- });
349
- return data;
350
- });
351
- this.getCachedTokenList = (id) => __awaiter(this, void 0, void 0, function* () {
352
- const { data } = yield this.request.get('/v1/user/cache_token_list', {
353
- params: {
354
- id,
355
- },
356
- });
357
- return data;
358
- });
359
- this.listToken = (id, chainId, isAll = false) => __awaiter(this, void 0, void 0, function* () {
360
- const { data } = yield this.request.get('/v1/user/token_list', {
361
- params: {
362
- id,
363
- is_all: isAll,
364
- chain_id: chainId,
365
- },
366
- });
367
- return data;
368
- });
369
- this.getTokenEntity = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
370
- const { data } = yield this.request.get('/v1/token/identity', {
371
- params: {
372
- id,
373
- chain_id: chainId,
374
- },
375
- });
376
- return data;
377
- });
378
- this.getHistoryTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
379
- const { data } = yield this.request.get('/v1/user/history_token_list', {
380
- params: {
381
- id: params.id,
382
- chain_id: params.chainId,
383
- time_at: params.timeAt,
384
- date_at: params.dateAt,
385
- },
386
- });
387
- return data;
388
- });
389
- this.customListToken = (uuids, id) => __awaiter(this, void 0, void 0, function* () {
390
- if (!(uuids === null || uuids === void 0 ? void 0 : uuids.length) || !id) {
391
- return [];
392
- }
393
- const { data } = yield this.request.post('/v1/user/specific_token_list', {
394
- id,
395
- uuids,
396
- });
397
- return data;
398
- });
399
- this.listChainAssets = (id) => __awaiter(this, void 0, void 0, function* () {
400
- const { data } = yield this.request.get('/v1/user/simple_protocol_list', {
401
- params: {
402
- id,
403
- },
404
- });
405
- return data;
406
- });
407
- this.listNFT = (id, isAll = true, sortByCredit) => __awaiter(this, void 0, void 0, function* () {
408
- const { data } = yield this.request.get('/v1/user/nft_list', {
409
- params: Object.assign({
410
- id,
411
- is_all: isAll,
412
- }, sortByCredit
413
- ? {
414
- sort_by: 'credit_score',
415
- }
416
- : {}),
417
- });
418
- return data;
419
- });
420
- this.listCollection = (params) => __awaiter(this, void 0, void 0, function* () {
421
- const { data } = yield this.request.get('/v1/nft/collections', {
422
- params,
423
- });
424
- return data;
425
- });
426
- this.hasNewTxFrom = (params) => __awaiter(this, void 0, void 0, function* () {
427
- const { data } = yield this.request.get('/v1/user/has_new_tx', {
428
- params: {
429
- id: params.address,
430
- start_time: params.startTime,
431
- },
432
- });
433
- return data;
434
- });
435
- this.listTxHisotry = (params) => __awaiter(this, void 0, void 0, function* () {
436
- const { data } = yield this.request.get('/v1/user/history_list', {
437
- params,
438
- });
439
- return data;
440
- });
441
- this.getAllTxHistory = (params, options) => __awaiter(this, void 0, void 0, function* () {
442
- const data = yield this.asyncJob('/v1/user/history_all_list', Object.assign({ method: 'GET', params }, options));
443
- return data;
444
- });
445
- this.tokenPrice = (tokenName) => __awaiter(this, void 0, void 0, function* () {
446
- const { data } = yield this.request.get('/v1/token/price_change', {
447
- params: {
448
- token: tokenName,
449
- },
450
- });
451
- return data;
452
- });
453
- this.getTokenPriceList = (params) => __awaiter(this, void 0, void 0, function* () {
454
- const { data } = yield this.request.post('/v1/token/price_list', params);
455
- return data;
456
- });
457
- this.tokenAuthorizedList = (id, chain_id, options) => __awaiter(this, void 0, void 0, function* () {
458
- const { restfulPrefix = 'v1' } = options || {};
459
- const { data } = yield this.request.get(`/${restfulPrefix}/user/token_authorized_list`, {
460
- params: {
461
- id,
462
- chain_id,
463
- },
464
- });
465
- return data;
466
- });
467
- this.userNFTAuthorizedList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
468
- const { data } = yield this.request.get('/v1/user/nft_authorized_list', {
469
- params: {
470
- id,
471
- chain_id,
472
- },
473
- });
474
- return data;
475
- });
476
- this.getDEXList = (chain_id) => __awaiter(this, void 0, void 0, function* () {
477
- const { data } = yield this.request.get('/v1/wallet/swap_dex_list', {
478
- params: {
479
- chain_id,
480
- },
481
- });
482
- return data;
483
- });
484
- this.getSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
485
- const { data } = yield this.request.get('/v1/wallet/swap_quote', {
486
- params,
487
- timeout: 5000,
488
- });
489
- return data;
490
- });
491
- this.getSwapTokenList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
492
- const params = {
493
- id,
494
- is_all: false,
495
- };
496
- if (chainId) {
497
- params.chain_id = chainId;
498
- }
499
- const { data } = yield this.request.get('/v1/wallet/swap_token_list', {
500
- params,
501
- });
502
- return data;
503
- });
504
- this.postGasStationOrder = (params) => __awaiter(this, void 0, void 0, function* () {
505
- const { data } = yield this.request.post('/v1/wallet/gas_station_order', {
506
- order: {
507
- user_addr: params.userAddr,
508
- from_chain_id: params.fromChainId,
509
- from_tx_id: params.fromTxId,
510
- from_token_id: params.fromTokenId,
511
- from_token_amount: params.fromTokenAmount,
512
- to_chain_id: params.toChainId,
513
- to_token_amount: params.toTokenAmount,
514
- from_usd_value: params.fromUsdValue,
515
- },
516
- });
517
- return data;
518
- });
519
- this.getGasStationChainBalance = (chain_id, addr) => __awaiter(this, void 0, void 0, function* () {
520
- const { data } = yield this.request.get('/v1/wallet/gas_station_usd_value', {
521
- params: {
522
- chain_id,
523
- addr,
524
- },
525
- });
526
- return data;
527
- });
528
- this.getApprovalCount = (address) => __awaiter(this, void 0, void 0, function* () {
529
- const { data } = yield this.request.get('/v1/user/total_approval_asset_cnt', {
530
- params: {
531
- id: address,
532
- },
533
- });
534
- return data;
535
- });
536
- this.getGasStationTokenList = () => __awaiter(this, void 0, void 0, function* () {
537
- const { data } = yield this.request.get('/v1/wallet/gas_station_token_list');
538
- return data;
539
- });
540
- this.explainTypedData = (user_addr, origin, data) => __awaiter(this, void 0, void 0, function* () {
541
- const { data: resData } = yield this.request.post('/v1/wallet/explain_typed_data', {
542
- user_addr,
543
- origin,
544
- data,
545
- });
546
- return resData;
547
- });
548
- this.checkTypedData = (user_addr, origin, data) => __awaiter(this, void 0, void 0, function* () {
549
- const { data: resData } = yield this.request.post('/v1/wallet/check_typed_data', {
550
- user_addr,
551
- origin,
552
- data,
553
- });
554
- return resData;
555
- });
556
- this.approvalStatus = (id, options) => __awaiter(this, void 0, void 0, function* () {
557
- const { restfulPrefix = 'v1' } = options || {};
558
- const { data } = yield this.request.get(`/${restfulPrefix}/user/approval_status`, {
559
- params: {
560
- id,
561
- },
562
- });
563
- return data;
564
- });
565
- this.usedChainList = (id) => __awaiter(this, void 0, void 0, function* () {
566
- const { data } = yield this.request.get('/v1/user/used_chain_list', {
567
- params: {
568
- id,
569
- },
570
- });
571
- return data;
572
- });
573
- this.getLatestVersion = () => __awaiter(this, void 0, void 0, function* () {
574
- const { data } = yield this.request.get('/v1/wallet/version');
575
- return data;
576
- });
577
- this.addOriginFeedback = (params) => __awaiter(this, void 0, void 0, function* () {
578
- const { data } = yield this.request.post('/v1/wallet/add_origin_feedback', {
579
- user_addr: params.user_addr,
580
- origin: params.origin,
581
- is_safe: params.is_safe,
582
- });
583
- return data;
584
- });
585
- this.getProtocolList = (addr) => __awaiter(this, void 0, void 0, function* () {
586
- const { data } = yield this.request.get('/v1/user/protocol_list', {
587
- params: {
588
- id: addr,
589
- },
590
- });
591
- return data;
592
- });
593
- this.getComplexProtocolList = (addr) => __awaiter(this, void 0, void 0, function* () {
594
- const { data } = yield this.request.get('/v1/user/complex_protocol_list', {
595
- params: {
596
- id: addr,
597
- },
598
- });
599
- return data;
600
- });
601
- this.getProtocol = ({ addr, id, }) => __awaiter(this, void 0, void 0, function* () {
602
- const { data } = yield this.request.get('/v1/user/protocol', {
603
- params: {
604
- id: addr,
605
- protocol_id: id,
606
- },
607
- });
608
- return data;
609
- });
610
- this.getHistoryProtocol = ({ addr, id, timeAt, dateAt, }) => __awaiter(this, void 0, void 0, function* () {
611
- const { data } = yield this.request.get('/v1/user/history_protocol', {
612
- params: {
613
- id: addr,
614
- protocol_id: id,
615
- time_at: timeAt,
616
- date_at: dateAt,
617
- },
618
- });
619
- return data;
620
- });
621
- this.getTokenHistoryPrice = ({ chainId, id, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
622
- const { data } = yield this.request.get('/v1/token/history_price', {
623
- params: {
624
- chain_id: chainId,
625
- id,
626
- time_at: timeAt,
627
- },
628
- });
629
- return data;
630
- });
631
- this.getTokenHistoryDict = ({ chainId, ids, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
632
- const { data } = yield this.request.get('/v1/token/history_price_dict', {
633
- params: {
634
- chain_id: chainId,
635
- ids,
636
- time_at: timeAt,
637
- },
638
- });
639
- return data;
640
- });
641
- this.getNetCurve = (addr, days = CurveDayType.DAY) => __awaiter(this, void 0, void 0, function* () {
642
- const { data } = yield this.request.get('/v1/user/total_net_curve', {
643
- params: {
644
- id: addr,
645
- days,
646
- },
647
- });
648
- return data;
649
- });
650
- this.getChainList = () => __awaiter(this, void 0, void 0, function* () {
651
- const { data } = yield this.request.get('/v1/chain/list');
652
- return data;
653
- });
654
- this.getCEXSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
655
- const { data } = yield this.request.get('/v1/wallet/cex_swap_quote', {
656
- params,
657
- });
658
- return data;
659
- });
660
- this.getSwapTradeList = (params) => __awaiter(this, void 0, void 0, function* () {
661
- const { data } = yield this.request.get('/v1/wallet/swap_trade_list', {
662
- params,
663
- });
664
- return data;
665
- });
666
- this.getSwapTradeListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
667
- const { data } = yield this.request.get('/v2/wallet/swap_trade_list', {
668
- params,
669
- });
670
- return data;
671
- });
672
- this.postSwap = (params) => __awaiter(this, void 0, void 0, function* () {
673
- const { data } = yield this.request.post('/v1/wallet/swap_trade', params);
674
- return data;
675
- });
676
- this.checkSlippage = (params) => __awaiter(this, void 0, void 0, function* () {
677
- const { data } = yield this.request.get('/v1/wallet/check_slippage', {
678
- params,
679
- });
680
- return data;
681
- });
682
- this.suggestSlippage = (params) => __awaiter(this, void 0, void 0, function* () {
683
- const { data } = yield this.request.get('v1/wallet/suggest_slippage', {
684
- params,
685
- });
686
- return data;
687
- });
688
- this.getOriginPopularityLevel = (origin) => __awaiter(this, void 0, void 0, function* () {
689
- const { data } = yield this.request.get('/v1/engine/origin/popularity_level', {
690
- params: {
691
- origin,
692
- },
693
- });
694
- return data;
695
- });
696
- this.getOriginIsScam = (origin, source) => __awaiter(this, void 0, void 0, function* () {
697
- const { data } = yield this.request.get('/v1/engine/origin/is_scam', {
698
- params: {
699
- origin,
700
- source,
701
- },
702
- });
703
- return data;
704
- });
705
- this.getOriginThirdPartyCollectList = (origin) => __awaiter(this, void 0, void 0, function* () {
706
- const { data } = yield this.request.get('/v1/engine/origin/third_party_collect_list', {
707
- params: {
708
- origin,
709
- },
710
- });
711
- return data;
712
- });
713
- this.getSummarizedAssetList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
714
- const { data } = yield this.request.get('/v1/user/summarized_asset_list', {
715
- params: {
716
- id,
717
- chain_id,
718
- },
719
- });
720
- return data;
721
- });
722
- this.unexpectedAddrList = ({ chainId, tx, origin, addr, }) => __awaiter(this, void 0, void 0, function* () {
723
- const { data } = yield this.request.post('/v1/engine/addr/unexpected_list', {
724
- chain_id: chainId,
725
- tx,
726
- origin,
727
- user_addr: addr,
728
- });
729
- return data;
730
- });
731
- this.gasLessTxCheck = ({ tx, usdValue, preExecSuccess, gasUsed, }) => __awaiter(this, void 0, void 0, function* () {
732
- const { data } = yield this.request.post('/v1/wallet/tx_is_gasless', {
733
- gas_used: gasUsed,
734
- pre_exec_success: preExecSuccess,
735
- tx,
736
- usd_value: usdValue,
737
- });
738
- return data;
739
- });
740
- this.gasLessTxsCheck = (postData) => __awaiter(this, void 0, void 0, function* () {
741
- const { data } = yield this.request.post('/v1/wallet/txs_is_gasless', postData);
742
- return data;
743
- });
744
- this.parseTx = ({ chainId, tx, origin, addr, }) => __awaiter(this, void 0, void 0, function* () {
745
- const { data } = yield this.request.post('/v1/engine/action/parse_tx', {
746
- chain_id: chainId,
747
- tx,
748
- origin,
749
- user_addr: addr,
750
- });
751
- return data;
752
- });
753
- this.isSuspiciousToken = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
754
- const { data } = yield this.request.get('/v1/engine/token/is_suspicious', {
755
- params: {
756
- chain_id: chainId,
757
- id,
758
- },
759
- });
760
- return data;
761
- });
762
- this.depositCexSupport = (id, chainId, cexId) => __awaiter(this, void 0, void 0, function* () {
763
- const { data } = yield this.request.get('/v1/engine/token/deposit_cex_support', {
764
- params: {
765
- chain_id: chainId,
766
- id,
767
- cex_id: cexId,
768
- },
769
- });
770
- return data;
771
- });
772
- // Token 可充值的 CEX 列表
773
- this.depositCexList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
774
- const { data } = yield this.request.get('/v1/engine/token/deposit_cex_list', {
775
- params: {
776
- chain_id: chainId,
777
- id,
778
- },
779
- });
780
- return data;
781
- });
782
- // 合约信用分
783
- this.getContractCredit = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
784
- const { data } = yield this.request.get('/v1/engine/contract/credit', {
785
- params: {
786
- chain_id: chainId,
787
- id,
788
- },
789
- });
790
- return data;
791
- });
792
- // 是否跟地址交互过
793
- this.hasInteraction = (addr, chainId, contractId) => __awaiter(this, void 0, void 0, function* () {
794
- const { data } = yield this.request.get('/v1/engine/contract/has_interaction', {
795
- params: {
796
- chain_id: chainId,
797
- user_addr: addr,
798
- contract_id: contractId,
799
- },
800
- });
801
- return data;
802
- });
803
- /**
804
- * @deprecated
805
- * 授权风险敞口
806
- */
807
- this.tokenApproveExposure = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
808
- const { data } = yield this.request.get('/v1/engine/contract/token_approval_exposure', {
809
- params: {
810
- chain_id: chainId,
811
- id,
812
- },
813
- });
814
- return data;
815
- });
816
- this.tokenApproveTrustValue = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
817
- const { data } = yield this.request.get('/v1/engine/contract/spend_usd_value', {
818
- params: {
819
- chain_id: chainId,
820
- id,
821
- },
822
- });
823
- return data;
824
- });
825
- this.getContractInfo = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
826
- const { data } = yield this.request.get('/v1/contract', {
827
- params: {
828
- chain_id: chainId,
829
- id,
830
- },
831
- });
832
- return data.contract;
833
- });
834
- // 地址描述
835
- this.addrDesc = (id) => __awaiter(this, void 0, void 0, function* () {
836
- const { data } = yield this.request.get('/v1/engine/addr/desc', {
837
- params: {
838
- id,
839
- },
840
- });
841
- return data;
842
- });
843
- // 两个地址是否发生过转账
844
- this.hasTransfer = (chainId, from, to) => __awaiter(this, void 0, void 0, function* () {
845
- const { data } = yield this.request.get('/v1/engine/addr/has_transfer', {
846
- params: {
847
- chain_id: chainId,
848
- from_addr: from,
849
- to_addr: to,
850
- },
851
- timeout: 2000,
852
- });
853
- return data;
854
- });
855
- // 全链两个地址是否发生过转账
856
- this.hasTransferAllChain = (from, to) => __awaiter(this, void 0, void 0, function* () {
857
- const { data } = yield this.request.get('/v2/engine/addr/has_transfer', {
858
- params: {
859
- from_addr: from,
860
- to_addr: to,
861
- },
862
- timeout: 2000,
863
- });
864
- return data;
865
- });
866
- this.isTokenContract = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
867
- const { data } = yield this.request.get('/v1/engine/contract/is_token', {
868
- params: {
869
- id,
870
- chain_id: chainId,
871
- },
872
- });
873
- return data;
874
- });
875
- this.addrUsedChainList = (id) => __awaiter(this, void 0, void 0, function* () {
876
- const { data } = yield this.request.get('/v1/engine/addr/used_chain_list', {
877
- params: { id },
878
- });
879
- return data;
880
- });
881
- /**
882
- * @deprecated
883
- */
884
- this.getTokenNFTExposure = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
885
- const { data } = yield this.request.get('/v1/engine/contract/top_nft_approval_exposure', {
886
- params: { chain_id: chainId, id },
887
- });
888
- return data;
889
- });
890
- this.getTokenNFTTrustValue = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
891
- const { data } = yield this.request.get('/v1/engine/contract/top_nft_spend_usd_value', {
892
- params: { chain_id: chainId, id },
893
- });
894
- return data;
895
- });
896
- this.getCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
897
- const { data } = yield this.request.get('/v1/engine/collection', {
898
- params: { chain_id: chainId, id },
899
- });
900
- return data;
901
- });
902
- this.isSuspiciousCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
903
- const { data } = yield this.request.get('/v1/engine/collection/is_suspicious', {
904
- params: { chain_id: chainId, id },
905
- });
906
- return data;
907
- });
908
- this.isOriginVerified = (origin) => __awaiter(this, void 0, void 0, function* () {
909
- const { data } = yield this.request.get('/v1/engine/origin/is_verified', {
910
- params: { origin },
911
- });
912
- return data;
913
- });
914
- this.parseTypedData = ({ typedData, origin, address, }) => __awaiter(this, void 0, void 0, function* () {
915
- const { data } = yield this.request.post('/v1/engine/action/parse_typed_data', {
916
- typed_data: typedData,
917
- origin,
918
- user_addr: address,
919
- });
920
- return data;
921
- });
922
- this.parseText = ({ text, origin, address, }) => __awaiter(this, void 0, void 0, function* () {
923
- const { data } = yield this.request.post('/v1/engine/action/parse_text', {
924
- text,
925
- origin,
926
- user_addr: address,
927
- });
928
- return data;
929
- });
930
- this.collectionList = ({ id, chainId, isAll, }) => __awaiter(this, void 0, void 0, function* () {
931
- const { data } = yield this.request.get('/v1/user/collection_list', {
932
- params: {
933
- id,
934
- chain_id: chainId,
935
- is_all: isAll,
936
- },
937
- });
938
- return data;
939
- });
940
- this.gasPriceStats = (chainId) => __awaiter(this, void 0, void 0, function* () {
941
- const { data } = yield this.request.get('/v1/wallet/gas_price_stats', {
942
- params: {
943
- chain_id: chainId,
944
- },
945
- });
946
- return data;
947
- });
948
- this.badgeHasClaimed = (id) => __awaiter(this, void 0, void 0, function* () {
949
- const { data } = yield this.request.get('/v1/badge/code/user_has_claimed', {
950
- params: {
951
- user_id: id,
952
- },
953
- });
954
- return data;
955
- });
956
- this.badgeHasMinted = (id) => __awaiter(this, void 0, void 0, function* () {
957
- const { data } = yield this.request.get('/v1/badge/user_has_minted', {
958
- params: {
959
- user_id: id,
960
- },
961
- });
962
- return data;
963
- });
964
- this.mintBadge = (params) => __awaiter(this, void 0, void 0, function* () {
965
- const { data } = yield this.request.post('/v1/badge/mint', {
966
- code: params.code,
967
- user_id: params.userAddr,
968
- });
969
- return data;
970
- });
971
- this.badgeHasClaimedByName = ({ id, name, }) => __awaiter(this, void 0, void 0, function* () {
972
- const { data } = yield this.request.get(`/v1/badge/code/user_has_claimed/${name}`, {
973
- params: {
974
- user_id: id,
975
- },
976
- });
977
- return data;
978
- });
979
- this.badgeHasMintedByName = ({ id, name, }) => __awaiter(this, void 0, void 0, function* () {
980
- const { data } = yield this.request.get(`/v1/badge/user_has_minted/${name}`, {
981
- params: {
982
- user_id: id,
983
- },
984
- });
985
- return data;
986
- });
987
- this.mintBadgeByName = (params) => __awaiter(this, void 0, void 0, function* () {
988
- const { data } = yield this.request.post(`/v1/badge/mint/${params.name}`, {
989
- code: params.code,
990
- user_id: params.userAddr,
991
- });
992
- return data;
993
- });
994
- this.userHasRequestedFaucet = (params) => __awaiter(this, void 0, void 0, function* () {
995
- const { data } = yield this.request.get('/v1/faucet/user_has_requested', {
996
- params,
997
- });
998
- return data;
999
- });
1000
- this.requestFaucet = (params) => __awaiter(this, void 0, void 0, function* () {
1001
- const { data } = yield this.request.post('/v1/faucet/request', Object.assign({}, params));
1002
- return data;
1003
- });
1004
- this.gasSupportedPushType = (chainId) => __awaiter(this, void 0, void 0, function* () {
1005
- const { data } = yield this.request.get('/v1/wallet/supported_push_type', {
1006
- params: {
1007
- chain_id: chainId,
1008
- },
1009
- });
1010
- return data;
1011
- });
1012
- this.submitTx = (postData) => __awaiter(this, void 0, void 0, function* () {
1013
- const { sig } = postData, rest = __rest(postData, ["sig"]);
1014
- const { data } = yield this.request.post('/v1/wallet/submit_tx', Object.assign({}, rest), {
1015
- headers: sig ? { sig } : undefined,
1016
- });
1017
- return data;
1018
- });
1019
- this.submitTxV2 = (postData) => __awaiter(this, void 0, void 0, function* () {
1020
- const { sig } = postData, rest = __rest(postData, ["sig"]);
1021
- const { data } = yield this.request.post('/v2/wallet/submit_tx', Object.assign({}, rest), {
1022
- headers: sig ? { sig } : undefined,
1023
- });
1024
- return data;
1025
- });
1026
- this.getDefaultRPCs = () => __awaiter(this, void 0, void 0, function* () {
1027
- const { data } = yield this.request.get('/v1/chainrpc');
1028
- return data;
1029
- });
1030
- this.getTxRequests = (ids) => __awaiter(this, void 0, void 0, function* () {
1031
- const { data } = yield this.request.get('/v1/wallet/get_tx_requests', {
1032
- params: {
1033
- ids: Array.isArray(ids) ? ids.join(',') : ids,
1034
- },
1035
- });
1036
- return data;
1037
- });
1038
- this.getTxRequest = (id) => __awaiter(this, void 0, void 0, function* () {
1039
- const { data } = yield this.request.get('/v1/wallet/get_tx_request', {
1040
- params: {
1041
- id,
1042
- },
1043
- });
1044
- return data;
1045
- });
1046
- this.withdrawTx = (reqId) => __awaiter(this, void 0, void 0, function* () {
1047
- const { data } = yield this.request.post('/v1/wallet/withdraw_tx', {
1048
- id: reqId,
1049
- });
1050
- return data;
1051
- });
1052
- this.retryPushTx = (reqId) => __awaiter(this, void 0, void 0, function* () {
1053
- const { data } = yield this.request.post('/v1/wallet/retry_push_tx', {
1054
- id: reqId,
1055
- });
1056
- return data;
1057
- });
1058
- this.mempoolChecks = (txId, chainId, node_info) => __awaiter(this, void 0, void 0, function* () {
1059
- const { data } = yield this.request.get('/v1/wallet/mempool_checks', {
1060
- params: {
1061
- tx_id: txId,
1062
- chain_id: chainId,
1063
- node_info: node_info ? 1 : 0,
1064
- },
1065
- });
1066
- return data;
1067
- });
1068
- this.getPendingTxList = (params, options) => __awaiter(this, void 0, void 0, function* () {
1069
- const data = yield this.asyncJob('/v1/wallet/get_pending_tx_list', Object.assign({ params }, options));
1070
- return data;
1071
- });
1072
- this.getLatestPreExec = (params) => __awaiter(this, void 0, void 0, function* () {
1073
- const { data } = yield this.request.get('/v1/wallet/get_latest_pre_exec', {
1074
- params,
1075
- });
1076
- return data;
1077
- });
1078
- this.walletSupportChain = (params) => __awaiter(this, void 0, void 0, function* () {
1079
- const { data } = yield this.request.post('/v1/wallet/support_chain', params);
1080
- return data;
1081
- });
1082
- this.walletSupportOrigin = (params) => __awaiter(this, void 0, void 0, function* () {
1083
- const { data } = yield this.request.post('/v1/wallet/support_origin', params);
1084
- return data;
1085
- });
1086
- this.walletSupportSelector = (params) => __awaiter(this, void 0, void 0, function* () {
1087
- const { data } = yield this.request.post('/v1/wallet/support_selector', params);
1088
- return data;
1089
- });
1090
- this.searchDapp = (params) => __awaiter(this, void 0, void 0, function* () {
1091
- const { data } = yield this.request.get('/v1/dapp/search', { params });
1092
- return data;
1093
- });
1094
- this.getDappsInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1095
- var _e;
1096
- const { data } = yield this.request.get('/v1/dapp/list', {
1097
- params: {
1098
- ids: (_e = params === null || params === void 0 ? void 0 : params.ids) === null || _e === void 0 ? void 0 : _e.join(','),
1099
- },
1100
- });
1101
- return data;
1102
- });
1103
- this.getDappHotTags = (params) => __awaiter(this, void 0, void 0, function* () {
1104
- const { data } = yield this.request.get('/v1/dapp/hot_tags', {
1105
- params,
1106
- });
1107
- return data;
1108
- });
1109
- this.getHotDapps = (params) => __awaiter(this, void 0, void 0, function* () {
1110
- const { data } = yield this.request.get('/v1/dapp/hot_list', { params });
1111
- return data;
1112
- });
1113
- this.getRabbyClaimText = (params) => __awaiter(this, void 0, void 0, function* () {
1114
- const { data } = yield this.request.get('/v1/points/user/claim_text', {
1115
- params,
1116
- });
1117
- return data;
1118
- });
1119
- this.getRabbySignatureText = (params) => __awaiter(this, void 0, void 0, function* () {
1120
- const { data } = yield this.request.get('/v1/points/user/sign_text', {
1121
- params,
1122
- });
1123
- return data;
1124
- });
1125
- this.getRabbyPoints = (params) => __awaiter(this, void 0, void 0, function* () {
1126
- const { data } = yield this.request.get('/v1/points/user', { params });
1127
- return data;
1128
- });
1129
- this.checkRabbyPointsInviteCode = (params) => __awaiter(this, void 0, void 0, function* () {
1130
- const { data } = yield this.request.get('/v1/points/user/invite_code_exist', { params });
1131
- return data;
1132
- });
1133
- this.setRabbyPointsInviteCode = (params) => __awaiter(this, void 0, void 0, function* () {
1134
- const { data } = yield this.request.post('/v1/points/user/invite_code', params);
1135
- return data;
1136
- });
1137
- this.checkRabbyPointClaimable = (params) => __awaiter(this, void 0, void 0, function* () {
1138
- const { data } = yield this.request.get('/v1/points/user/claimable', {
1139
- params,
1140
- });
1141
- return data;
1142
- });
1143
- this.getRabbyPointsSnapshot = (params) => __awaiter(this, void 0, void 0, function* () {
1144
- const { data } = yield this.request.get('/v1/points/snapshot', { params });
1145
- return data;
1146
- });
1147
- this.claimRabbyPointsSnapshot = (params) => __awaiter(this, void 0, void 0, function* () {
1148
- const { data } = yield this.request.post('/v1/points/claim_snapshot', params);
1149
- return data;
1150
- });
1151
- this.getRabbyPointsTopUsers = (params) => __awaiter(this, void 0, void 0, function* () {
1152
- const { data } = yield this.request.get('/v1/points/top_user', { params });
1153
- return data;
1154
- });
1155
- this.getRabbyPointsList = (params) => __awaiter(this, void 0, void 0, function* () {
1156
- const { data } = yield this.request.get('/v1/points/campaign_list', {
1157
- params,
1158
- });
1159
- return data;
1160
- });
1161
- this.getRabbyPointsCampaignIsEnded = () => __awaiter(this, void 0, void 0, function* () {
1162
- const { data } = yield this.request.get('v1/points/campaign');
1163
- return data;
1164
- });
1165
- this.claimRabbyPointsById = (params) => __awaiter(this, void 0, void 0, function* () {
1166
- const { data } = yield this.request.post('/v1/points/claim_campaign', params);
1167
- return data;
1168
- });
1169
- this.getRabbyPointsV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1170
- const { data } = yield this.request.get('/v2/points/user', { params });
1171
- return data;
1172
- });
1173
- this.getRabbySignatureTextV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1174
- const { data } = yield this.request.get('/v2/points/user/sign_text', {
1175
- params,
1176
- });
1177
- return data;
1178
- });
1179
- this.getRabbyClaimTextV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1180
- const { data } = yield this.request.get('/v2/points/user/claim_text', {
1181
- params,
1182
- });
1183
- return data;
1184
- });
1185
- this.setRabbyPointsInviteCodeV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1186
- const { data } = yield this.request.post('/v2/points/user/invite_code', params);
1187
- return data;
1188
- });
1189
- this.checkRabbyPointsInviteCodeV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1190
- const { data } = yield this.request.get('/v2/points/user/invite_code_exist', {
1191
- params,
1192
- });
1193
- return data;
1194
- });
1195
- this.claimRabbyPointsSnapshotV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1196
- const { data } = yield this.request.post('/v2/points/claim_snapshot', params);
1197
- return data;
1198
- });
1199
- this.getRabbyPointsTopUsersV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1200
- const { data } = yield this.request.get('/v2/points/top_user', {
1201
- params,
1202
- });
1203
- return data;
1204
- });
1205
- this.getRabbyPointsListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1206
- const { data } = yield this.request.get('/v2/points/campaign_list', {
1207
- params,
1208
- });
1209
- return data;
1210
- });
1211
- this.claimRabbyPointsByIdV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1212
- const { data } = yield this.request.post('/v2/points/claim_campaign', params);
1213
- return data;
1214
- });
1215
- this.getRabbyPointsSnapshotV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1216
- const { data } = yield this.request.get('/v2/points/snapshot', {
1217
- params,
1218
- });
1219
- return data;
1220
- });
1221
- this.checkRabbyPointClaimableV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1222
- const { data } = yield this.request.get('/v2/points/user/claimable', {
1223
- params,
1224
- });
1225
- return data;
1226
- });
1227
- this.checkClaimInfoV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1228
- const { data } = yield this.request.get('/v2/points/user/claim_info', {
1229
- params,
1230
- });
1231
- return data;
1232
- });
1233
- this.getRabbyPointsCampaignIsEndedV2 = () => __awaiter(this, void 0, void 0, function* () {
1234
- const { data } = yield this.request.get('v2/points/campaign');
1235
- return data;
1236
- });
1237
- this.getSupportedChains = () => __awaiter(this, void 0, void 0, function* () {
1238
- const { data } = yield this.request.get('/v1/wallet/supported_chains');
1239
- return data;
1240
- });
1241
- this.searchChainList = (params) => __awaiter(this, void 0, void 0, function* () {
1242
- const { data } = yield this.request.get('/v1/chain/total_list', {
1243
- params,
1244
- });
1245
- return data;
1246
- });
1247
- this.getChainListByIds = (params) => __awaiter(this, void 0, void 0, function* () {
1248
- const { data } = yield this.request.get('/v1/chain/get_list', {
1249
- params,
1250
- });
1251
- return data;
1252
- });
1253
- this.getHistoryCurve = (addr) => __awaiter(this, void 0, void 0, function* () {
1254
- const { data } = yield this.request.get('/v1/user/history_curve', {
1255
- params: { id: addr },
1256
- });
1257
- return data;
1258
- });
1259
- this.getHistoryCurveSupportedList = () => __awaiter(this, void 0, void 0, function* () {
1260
- const { data } = yield this.request.get('/v1/chain/classify_supported_list');
1261
- return data;
1262
- });
1263
- this.getHistoryCurveStatus = (params) => __awaiter(this, void 0, void 0, function* () {
1264
- const { data } = yield this.request.get('/v1/user/history_curve/status', {
1265
- params,
1266
- });
1267
- return data;
1268
- });
1269
- this.initHistoryCurve = (params) => __awaiter(this, void 0, void 0, function* () {
1270
- const { data } = yield this.request.post('/v1/user/history_curve/init', params);
1271
- return data;
1272
- });
1273
- this.getNodeStatusList = () => __awaiter(this, void 0, void 0, function* () {
1274
- const { data } = yield this.request.get('/v1/node/list');
1275
- return data;
1276
- });
1277
- this.getNodeStatusDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1278
- const { data } = yield this.request.get('/v1/node', { params });
1279
- return data;
1280
- });
1281
- this.postActionLog = (body) => __awaiter(this, void 0, void 0, function* () {
1282
- const { data } = yield this.request.post('/v1/engine/action/log', body);
1283
- return data;
1284
- });
1285
- this.checkSpoofing = ({ from, to, }) => __awaiter(this, void 0, void 0, function* () {
1286
- const { data } = yield this.request.get('/v1/engine/addr/is_spoofing', {
1287
- params: { user_addr: from, dest_addr: to },
1288
- });
1289
- return data;
1290
- });
1291
- this.getAddressByDeBankId = (name) => __awaiter(this, void 0, void 0, function* () {
1292
- const { data } = yield this.request.get('/v1/user/web3_id', {
1293
- params: {
1294
- text: name,
1295
- },
1296
- });
1297
- return data;
1298
- });
1299
- this.getBridgeSupportChain = () => __awaiter(this, void 0, void 0, function* () {
1300
- const { data } = yield this.request.get('/v1/bridge/supported_chains');
1301
- return data;
1302
- });
1303
- this.getBridgeAggregatorList = () => __awaiter(this, void 0, void 0, function* () {
1304
- const { data } = yield this.request.get('/v1/bridge/list');
1305
- return data;
1306
- });
1307
- this.getBridgePairList = (params) => __awaiter(this, void 0, void 0, function* () {
1308
- const { data } = yield this.request.get('/v1/bridge/pair_list', {
1309
- params: Object.assign(Object.assign({}, params), { aggregator_ids: params.aggregator_ids.join(',') }),
1310
- });
1311
- return data;
1312
- });
1313
- this.getBridgeQuoteList = (params) => __awaiter(this, void 0, void 0, function* () {
1314
- const { data } = yield this.request.get('/v1/bridge/quote_list', {
1315
- params,
1316
- });
1317
- return data;
1318
- });
1319
- this.getBridgeQuoteListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1320
- const { data } = yield this.request.get('/v2/bridge/quote_list', {
1321
- params,
1322
- });
1323
- return data;
1324
- });
1325
- this.getBridgeQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1326
- const { data } = yield this.request.get('/v1/bridge/quote', {
1327
- params,
1328
- });
1329
- return data;
1330
- });
1331
- this.getBridgeHistoryList = (params) => __awaiter(this, void 0, void 0, function* () {
1332
- const { data } = yield this.request.get('/v1/bridge/history_list', {
1333
- params,
1334
- });
1335
- return data;
1336
- });
1337
- this.buildBridgeTx = (params) => __awaiter(this, void 0, void 0, function* () {
1338
- const { data } = yield this.request.get('/v2/bridge/build_tx', {
1339
- params,
1340
- });
1341
- return data;
1342
- });
1343
- this.postBridgeHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1344
- const { data } = yield this.request.post('/v1/bridge/history', params);
1345
- return data;
1346
- });
1347
- /**
1348
- * no id just no check address
1349
- */
1350
- this.getPerpPermission = (params) => __awaiter(this, void 0, void 0, function* () {
1351
- const { data } = yield this.request.get('/v1/user/has_hyperliquid_permission', {
1352
- params,
1353
- });
1354
- return data;
1355
- });
1356
- /**
1357
- * @param params.dex_id - The ID of the DEX to get the top tokens for. If not provided, hyperliquid default DEXs will be included. if all is provided, all DEXs will be included. and xyz is xyz dex tokens
1358
- * @returns A list of top tokens for the given DEX.
1359
- */
1360
- this.getPerpTopTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1361
- const { data } = yield this.request.get('/v1/token/hyperliquid_top', {
1362
- params,
1363
- });
1364
- return data;
1365
- });
1366
- /**
1367
- * @param params.dex_id - The ID of the DEX to get the top tokens for. If not provided, hyperliquid default DEXs will be included. if all is provided, all DEXs will be included. and xyz is xyz dex tokens
1368
- * @param params.lang - The translations in item.category
1369
- * @returns A list of top tokens for the given DEX.
1370
- */
1371
- this.getPerpTopTokenListV3 = (params) => __awaiter(this, void 0, void 0, function* () {
1372
- const { data } = yield this.request.get('/v1/token/hyperliquid_top_v3', {
1373
- params,
1374
- });
1375
- return data;
1376
- });
1377
- this.getPerpTokenDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1378
- const { data } = yield this.request.get('/v1/token/hyperliquid_token_detail_v3', {
1379
- params,
1380
- });
1381
- return data;
1382
- });
1383
- this.getPerpTokenCategories = (params) => __awaiter(this, void 0, void 0, function* () {
1384
- const { data } = yield this.request.get('/v1/token/hyperliquid_categories_v3', {
1385
- params,
1386
- });
1387
- return data;
1388
- });
1389
- this.getPerpsBridgeIsSupportToken = (params) => __awaiter(this, void 0, void 0, function* () {
1390
- const { data } = yield this.request.get('/v2/bridge/hyperliquid/support_token', {
1391
- params,
1392
- });
1393
- return data;
1394
- });
1395
- this.getPerpBridgeQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1396
- const { data } = yield this.request.get('/v2/bridge/hyperliquid/quote', {
1397
- params,
1398
- });
1399
- return data;
1400
- });
1401
- this.postPerpBridgeHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1402
- const { data } = yield this.request.post('/v2/bridge/hyperliquid', params);
1403
- return data;
1404
- });
1405
- this.getSupportedDEXList = () => __awaiter(this, void 0, void 0, function* () {
1406
- const { data } = yield this.request.get('/v1/wallet/supported_dex_list');
1407
- return data;
1408
- });
1409
- this.createDbkBridgeHistory = (postData) => __awaiter(this, void 0, void 0, function* () {
1410
- const { data } = yield this.request.post('/v1/user/dbk/bridge_history', postData);
1411
- return data;
1412
- });
1413
- this.getDbkBridgeHistoryList = (params) => __awaiter(this, void 0, void 0, function* () {
1414
- const { data } = yield this.request.get('/v1/user/dbk/bridge_history_list', {
1415
- params,
1416
- });
1417
- return data;
1418
- });
1419
- this.getGasAccountSignText = (account_id) => __awaiter(this, void 0, void 0, function* () {
1420
- const { data } = yield this.request.get('/v1/gas_account/sign_text', {
1421
- params: {
1422
- account_id,
1423
- },
1424
- });
1425
- return data;
1426
- });
1427
- this.getGasAccountInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1428
- const { sig } = params, others = __rest(params, ["sig"]);
1429
- const { data } = yield this.request.get('/v1/gas_account', {
1430
- params: Object.assign({}, others),
1431
- headers: {
1432
- sig,
1433
- },
1434
- });
1435
- return data;
1436
- });
1437
- this.getGasAccountInfoV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1438
- const { data } = yield this.request.get('/v2/gas_account', {
1439
- params,
1440
- });
1441
- return data;
1442
- });
1443
- this.createGasAccountPayInfo = (postData) => __awaiter(this, void 0, void 0, function* () {
1444
- const { data } = yield this.request.post('/v2/gas_account/pay_info', postData);
1445
- return data;
1446
- });
1447
- this.checkGasAccountGiftEligibility = (params) => __awaiter(this, void 0, void 0, function* () {
1448
- const { data } = yield this.request.get('/v1/gas_account/check_eligibility', {
1449
- params,
1450
- });
1451
- return data;
1452
- });
1453
- this.checkGasAccountGiftEligibilityBatch = (params) => __awaiter(this, void 0, void 0, function* () {
1454
- const { data } = yield this.request.post('/v1/gas_account/check_eligibility/batch', params);
1455
- return data;
1456
- });
1457
- this.confirmIapOrder = (postData) => __awaiter(this, void 0, void 0, function* () {
1458
- const { data } = yield this.request.post('/v1/gas_account/confirm_iap_order', postData);
1459
- return data;
1460
- });
1461
- this.claimGasAccountGift = (params) => __awaiter(this, void 0, void 0, function* () {
1462
- const { sig } = params, others = __rest(params, ["sig"]);
1463
- const { data } = yield this.request.post('/v1/gas_account/claim', Object.assign({}, others), {
1464
- headers: {
1465
- sig,
1466
- },
1467
- });
1468
- return data;
1469
- });
1470
- this.loginGasAccount = (params) => __awaiter(this, void 0, void 0, function* () {
1471
- const { sig } = params, others = __rest(params, ["sig"]);
1472
- const { data } = yield this.request.post('/v1/gas_account/login', Object.assign({}, others), {
1473
- headers: {
1474
- sig,
1475
- },
1476
- });
1477
- return data;
1478
- });
1479
- this.logoutGasAccount = (params) => __awaiter(this, void 0, void 0, function* () {
1480
- const { sig } = params, others = __rest(params, ["sig"]);
1481
- const { data } = yield this.request.post('/v1/gas_account/logout', Object.assign({}, others), {
1482
- headers: {
1483
- sig,
1484
- },
1485
- });
1486
- return data;
1487
- });
1488
- this.getGasAccountTokenList = (id) => __awaiter(this, void 0, void 0, function* () {
1489
- const { data } = yield this.request.get('/v1/user/recharge_token_list', {
1490
- params: {
1491
- id,
1492
- },
1493
- });
1494
- return data;
1495
- });
1496
- this.getGasAccountBridgeSupportTokenList = () => __awaiter(this, void 0, void 0, function* () {
1497
- const { data } = yield this.request.get('/v1/gas_account/bridge/support_token');
1498
- return data;
1499
- });
1500
- this.getGasAccountBridgeQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1501
- const { data } = yield this.request.get('/v1/gas_account/bridge/quote', {
1502
- params,
1503
- });
1504
- return data;
1505
- });
1506
- this.createGasAccountBridgeRecharge = (p) => __awaiter(this, void 0, void 0, function* () {
1507
- const { sig } = p, params = __rest(p, ["sig"]);
1508
- const { data } = yield this.request.post('/v1/gas_account/bridge/create', params, {
1509
- headers: {
1510
- sig,
1511
- },
1512
- });
1513
- return data;
1514
- });
1515
- this.getGasAccountBridgeStatus = (params) => __awaiter(this, void 0, void 0, function* () {
1516
- const { data } = yield this.request.post('/v1/gas_account/recharge/status', params);
1517
- return data;
1518
- });
1519
- this.rechargeGasAccount = (p) => __awaiter(this, void 0, void 0, function* () {
1520
- const { sig } = p, params = __rest(p, ["sig"]);
1521
- const { data } = yield this.request.post('/v1/gas_account/recharge', params, {
1522
- headers: {
1523
- sig,
1524
- },
1525
- });
1526
- return data;
1527
- });
1528
- this.withdrawGasAccount = (p) => __awaiter(this, void 0, void 0, function* () {
1529
- const { sig } = p, params = __rest(p, ["sig"]);
1530
- const { data } = yield this.request.post('/v1/gas_account/withdraw', params, {
1531
- headers: {
1532
- sig,
1533
- },
1534
- });
1535
- return data;
1536
- });
1537
- this.getWithdrawList = (p) => __awaiter(this, void 0, void 0, function* () {
1538
- const { sig } = p, params = __rest(p, ["sig"]);
1539
- const { data } = yield this.request.get('/v1/gas_account/withdraw_list', {
1540
- params,
1541
- headers: {
1542
- sig,
1543
- },
1544
- });
1545
- return data;
1546
- });
1547
- this.getGasAccountHistory = (p) => __awaiter(this, void 0, void 0, function* () {
1548
- const { sig } = p, params = __rest(p, ["sig"]);
1549
- const { data } = yield this.request.get('/v1/gas_account/history', {
1550
- params,
1551
- headers: {
1552
- sig,
1553
- },
1554
- });
1555
- return data;
1556
- });
1557
- this.checkGasAccountTxs = (p) => __awaiter(this, void 0, void 0, function* () {
1558
- const { sig } = p, params = __rest(p, ["sig"]);
1559
- const { data } = yield this.request.post('/v1/gas_account/check_txs', params, {
1560
- headers: sig
1561
- ? {
1562
- sig,
1563
- }
1564
- : undefined,
1565
- });
1566
- return data;
1567
- });
1568
- this.getGasAccountAml = (id) => __awaiter(this, void 0, void 0, function* () {
1569
- const { data } = yield this.request.get('/v1/gas_account/aml', {
1570
- params: {
1571
- id,
1572
- },
1573
- });
1574
- return data;
1575
- });
1576
- this.parseCommon = (params) => __awaiter(this, void 0, void 0, function* () {
1577
- const { data } = yield this.request.post('/v1/engine/action/parse_common', params);
1578
- return data;
1579
- });
1580
- this.getRecommendBridgeToChain = (params) => __awaiter(this, void 0, void 0, function* () {
1581
- const { data } = yield this.request.get('/v2/bridge/recommend/to_chain', {
1582
- params,
1583
- });
1584
- return data;
1585
- });
1586
- this.getRecommendFromToken = (params) => __awaiter(this, void 0, void 0, function* () {
1587
- const { data } = yield this.request.get('/v2/bridge/recommend/from_token_list', {
1588
- params,
1589
- });
1590
- return data;
1591
- });
1592
- this.getBridgeToTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1593
- const { data } = yield this.request.get('/v2/bridge/recommend/to_token_list', {
1594
- params,
1595
- });
1596
- return data;
1597
- });
1598
- this.getBridgeQuoteV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1599
- const { data } = yield this.request.get('/v2/bridge/quote_list', {
1600
- params,
1601
- });
1602
- return data;
1603
- });
1604
- this.getBridgeQuoteTxV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1605
- const { data } = yield this.request.get('/v2/bridge/quote', {
1606
- params,
1607
- });
1608
- return data;
1609
- });
1610
- this.isSameBridgeToken = (params) => __awaiter(this, void 0, void 0, function* () {
1611
- const { data } = yield this.request.get('/v2/bridge/same_token', {
1612
- params,
1613
- });
1614
- return data;
1615
- });
1616
- this.getBridgeSupportChainV2 = () => __awaiter(this, void 0, void 0, function* () {
1617
- const { data } = yield this.request.get('/v2/bridge/supported_chains');
1618
- return data;
1619
- });
1620
- this.submitFeedback = ({ text, usage, }) => __awaiter(this, void 0, void 0, function* () {
1621
- const { data } = yield this.request.post('v1/feedback', Object.assign({ text }, (usage && { usage })));
1622
- return data;
1623
- });
1624
- this.uninstalledFeedback = ({ text, }) => __awaiter(this, void 0, void 0, function* () {
1625
- return this.submitFeedback({
1626
- text,
1627
- });
1628
- });
1629
- /**
1630
- * @deprecated
1631
- */
1632
- this.getToken24hPrice = (params) => __awaiter(this, void 0, void 0, function* () {
1633
- const { data } = yield this.request.get('/v1/token/24h_price', {
1634
- params,
1635
- });
1636
- return data;
1637
- });
1638
- this.getTokenPriceCurve = (params) => __awaiter(this, void 0, void 0, function* () {
1639
- const { data } = yield this.request.get('/v1/token/price_curve', {
1640
- params,
1641
- });
1642
- return data;
1643
- });
1644
- this.getTokenDatePrice = (params) => __awaiter(this, void 0, void 0, function* () {
1645
- const { data } = yield this.request.get('/v1/token/date_price', {
1646
- params,
1647
- });
1648
- return data;
1649
- });
1650
- this.searchTokens = (params) => __awaiter(this, void 0, void 0, function* () {
1651
- const { data } = yield this.request.get('/v1/token/search', {
1652
- params,
1653
- });
1654
- return data;
1655
- });
1656
- this.searchTokensV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1657
- const { data } = yield this.request.get('/v2/token/search', {
1658
- params,
1659
- });
1660
- return data;
1661
- });
1662
- // resp arr of chain_id
1663
- this.getCopyTradingChainList = () => __awaiter(this, void 0, void 0, function* () {
1664
- const { data } = yield this.request.get('/v1/copytrading/chain_list');
1665
- return data;
1666
- });
1667
- this.getCopyTradingTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1668
- const { data } = yield this.request.get('/v1/copytrading/token/list', {
1669
- params,
1670
- });
1671
- return data;
1672
- });
1673
- this.getCopyTradingTokenListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1674
- const { data } = yield this.request.get('/v2/copytrading/token/list', {
1675
- params,
1676
- });
1677
- return data;
1678
- });
1679
- this.getCopyTradingRecentBuyList = (params) => __awaiter(this, void 0, void 0, function* () {
1680
- const { data } = yield this.request.get('/v1/copytrading/recent_buy/list', {
1681
- params,
1682
- });
1683
- return data;
1684
- });
1685
- this.getCopyTradingRecentBuyListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1686
- const { data } = yield this.request.get('/v2/copytrading/recent_buy/list', {
1687
- params,
1688
- });
1689
- return data;
1690
- });
1691
- this.getCopyTradingDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1692
- const { data } = yield this.request.get('/v2/copytrading/token/detail', {
1693
- params,
1694
- });
1695
- return data;
1696
- });
1697
- this.getCopyTradingSameName = (params) => __awaiter(this, void 0, void 0, function* () {
1698
- const { data } = yield this.request.get('/v1/token/same_name', {
1699
- params,
1700
- });
1701
- return data;
1702
- });
1703
- this.getCopyTradingPnlList = (params) => __awaiter(this, void 0, void 0, function* () {
1704
- const { data } = yield this.request.get('/v1/copytrading/smart_money/pnl/list', {
1705
- params,
1706
- });
1707
- return data;
1708
- });
1709
- this.batchQueryTokens = (uuids) => __awaiter(this, void 0, void 0, function* () {
1710
- const { data } = yield this.request.get('/v1/token/list_by_uuids', {
1711
- params: {
1712
- uuids: Array.isArray(uuids) ? uuids.join(',') : uuids,
1713
- },
1714
- });
1715
- return data;
1716
- });
1717
- this.getBuySupportedCountryList = () => __awaiter(this, void 0, void 0, function* () {
1718
- const { data } = yield this.request.get('/v1/buy/supported_country_list');
1719
- return data;
1720
- });
1721
- this.getBuySupportedTokenList = () => __awaiter(this, void 0, void 0, function* () {
1722
- const { data } = yield this.request.get('/v1/buy/supported_token_list');
1723
- return data;
1724
- });
1725
- this.getBuyQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1726
- const { data } = yield this.request.get('/v1/buy/quote', {
1727
- params,
1728
- });
1729
- return data;
1730
- });
1731
- this.getBuyWidgetUrl = (params) => __awaiter(this, void 0, void 0, function* () {
1732
- const { data } = yield this.request.get('/v1/buy/get_widget_url', { params });
1733
- return data;
1734
- });
1735
- this.getBuyHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1736
- const { data } = yield this.request.get('/v1/buy/history', {
1737
- params: Object.assign(Object.assign({}, params), { start: params.start || 0, limit: params.limit || 20 }),
1738
- });
1739
- return data;
1740
- });
1741
- this.getBuyPaymentMethods = (params) => __awaiter(this, void 0, void 0, function* () {
1742
- const { data } = yield this.request.get('/v1/buy/get_payment_method', {
1743
- params,
1744
- });
1745
- return data;
1746
- });
1747
- this.getBuyCurrencyList = () => __awaiter(this, void 0, void 0, function* () {
1748
- const { data } = yield this.request.get('/v1/buy/supported_currency_list');
1749
- return data;
1750
- });
1751
- this.getOfflineChainList = () => __awaiter(this, void 0, void 0, function* () {
1752
- const { data } = yield this.request.get('/v1/chain/offline_list');
1753
- return data;
1754
- });
1755
- this.isBlockedAddress = (id) => __awaiter(this, void 0, void 0, function* () {
1756
- const { data } = yield this.request.get('/v1/engine/addr/is_blocked', {
1757
- params: { id },
1758
- });
1759
- return data;
1760
- });
1761
- this.estimateGasUsd = ({ tx, origin, address, updateNonce = false, pending_tx_list = [], }) => __awaiter(this, void 0, void 0, function* () {
1762
- const { data } = yield this.request.post('/v1/wallet/estimate_gas', {
1763
- tx,
1764
- user_addr: address,
1765
- origin,
1766
- update_nonce: updateNonce,
1767
- pending_tx_list,
1768
- });
1769
- return data;
1770
- });
1771
- this.getCexSupportList = () => __awaiter(this, void 0, void 0, function* () {
1772
- const { data } = yield this.request.get('/v1/cex/supported_list');
1773
- return data;
1774
- });
1775
- this.getAppChainList = (id) => __awaiter(this, void 0, void 0, function* () {
1776
- const { data } = yield this.request.get('/v1/user/complex_app_list', {
1777
- params: { id },
1778
- });
1779
- return data;
1780
- });
1781
- this.checkCex = (postData) => __awaiter(this, void 0, void 0, function* () {
1782
- const { data } = yield this.request.post('/v1/token/check_cex', postData);
1783
- return data;
1784
- });
1785
- // top 20 tokens
1786
- this.getHotTokenList = () => __awaiter(this, void 0, void 0, function* () {
1787
- const { data } = yield this.request.get('/v1/token/hot_list');
1788
- return data;
1789
- });
1790
- // uuid: 'chain:token_id'
1791
- this.getTokensDetailByUuids = (uuids) => __awaiter(this, void 0, void 0, function* () {
1792
- const { data } = yield this.request.get('/v1/token/list_by_uuids', {
1793
- params: {
1794
- uuids: uuids.join(','),
1795
- },
1796
- });
1797
- return data;
1798
- });
1799
- this.getTokenKlineData = (params) => __awaiter(this, void 0, void 0, function* () {
1800
- const { data } = yield this.request.get('/v1/token/market/kline', {
1801
- params,
1802
- });
1803
- return data;
1804
- });
1805
- this.getTokenMarketInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1806
- const { data } = yield this.request.get('/v1/token/market/info', {
1807
- params,
1808
- });
1809
- return data;
1810
- });
1811
- this.getTokenHolderInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1812
- const { data } = yield this.request.get('/v1/token/market/info/holders', {
1813
- params,
1814
- });
1815
- return data;
1816
- });
1817
- this.getTokenSupplyInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1818
- const { data } = yield this.request.get('/v1/token/market/info/supply', {
1819
- params,
1820
- });
1821
- return data;
1822
- });
1823
- this.postUserFeedback = (data) => __awaiter(this, void 0, void 0, function* () {
1824
- const { data: response } = yield this.request.post('/v1/feedback/app', data);
1825
- return response;
1826
- });
1827
- this.getUserFeedback = (id) => __awaiter(this, void 0, void 0, function* () {
1828
- const { data } = yield this.request.get('/v1/feedback/app', {
1829
- params: { id },
1830
- });
1831
- return data;
1832
- });
1833
- this.getUserFeedbackList = (id) => __awaiter(this, void 0, void 0, function* () {
1834
- const ids = Array.isArray(id) ? id : [id];
1835
- const { data } = yield this.request.post('/v1/feedback/app/list', {
1836
- ids,
1837
- });
1838
- return data;
1839
- });
1840
- this.getCurrencyList = () => __awaiter(this, void 0, void 0, function* () {
1841
- const { data } = yield this.request.get('/v1/currency/exchange_list');
1842
- return data;
1843
- });
1844
- this.getMarketSummary = ({ token_id, chain_id, }) => __awaiter(this, void 0, void 0, function* () {
1845
- const { data } = yield this.request.get('/v1/token/market/summary', {
1846
- params: {
1847
- token_id,
1848
- chain_id,
1849
- },
1850
- });
1851
- return data;
1852
- });
1853
- this.getMarketTradingHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1854
- const { data } = yield this.request.get('/v1/token/market/trading_history/list', {
1855
- params,
1856
- });
1857
- return data;
1858
- });
1859
- this.getTokenHolderSummary = (params) => __awaiter(this, void 0, void 0, function* () {
1860
- const { data } = yield this.request.get('/v1/token/market/holders/summary', {
1861
- params,
1862
- });
1863
- return data;
1864
- });
1865
- // top 10 holders
1866
- this.getTokenHolderList = (params) => __awaiter(this, void 0, void 0, function* () {
1867
- const { data } = yield this.request.get('/v1/token/market/holders/list', {
1868
- params,
1869
- });
1870
- return data;
1871
- });
1872
- // top 5
1873
- this.getLiquidityPoolList = (params) => __awaiter(this, void 0, void 0, function* () {
1874
- const { data } = yield this.request.get('/v1/token/market/liquidity_pool/list', {
1875
- params,
1876
- });
1877
- return data;
1878
- });
1879
- this.getLiquidityPoolHistoryList = (params) => __awaiter(this, void 0, void 0, function* () {
1880
- const { data } = yield this.request.get('/v1/token/market/liquidity_pool/history/list', {
1881
- params,
1882
- });
1883
- return data;
1884
- });
1885
- this.getTokenMarketCategoryList = () => __awaiter(this, void 0, void 0, function* () {
1886
- const { data } = yield this.request.get('/v1/token/market/category_list');
1887
- return data;
1888
- });
1889
- this.getNFTTradingConfig = () => __awaiter(this, void 0, void 0, function* () {
1890
- const { data } = yield this.request.get('/v1/nft/trading_config');
1891
- return data;
1892
- });
1893
- this.getNFTDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1894
- const { data } = yield this.request.get('/v1/nft', {
1895
- params,
1896
- });
1897
- return data;
1898
- });
1899
- this.getNFTListingOrders = (params) => __awaiter(this, void 0, void 0, function* () {
1900
- const { data } = yield this.request.get('/v1/nft/order/listing', {
1901
- params,
1902
- });
1903
- return data;
1904
- });
1905
- this.getNFTFees = (params) => __awaiter(this, void 0, void 0, function* () {
1906
- const { data } = yield this.request.get('/v1/nft/fee', {
1907
- params,
1908
- });
1909
- return data;
1910
- });
1911
- this.prepareListingNFT = (postData) => __awaiter(this, void 0, void 0, function* () {
1912
- const { data } = yield this.request.post('/v1/nft/order/listing/prepare', postData);
1913
- return data;
1914
- });
1915
- this.createListingNFT = (postData) => __awaiter(this, void 0, void 0, function* () {
1916
- const { data } = yield this.request.post('/v1/nft/order/listing/post', postData);
1917
- return data;
1918
- });
1919
- this.prepareAcceptNFTOffer = (postData) => __awaiter(this, void 0, void 0, function* () {
1920
- const { data } = yield this.request.post('/v1/nft/order/offer/accept/prepare', postData);
1921
- return data;
1922
- });
1923
- this.submitAcceptNFTOfferTx = (postData) => __awaiter(this, void 0, void 0, function* () {
1924
- const { data } = yield this.request.post('/v1/nft/order/offer/accept/tx', postData);
1925
- return data;
1926
- });
1927
- this.checkTokenDepositForbidden = (params) => __awaiter(this, void 0, void 0, function* () {
1928
- const { data } = yield this.request.get('/v1/engine/token/deposit_forbidden', {
1929
- params,
1930
- });
1931
- return data;
1932
- });
1933
- this.getPolyMarketPermission = (params) => __awaiter(this, void 0, void 0, function* () {
1934
- const { data } = yield this.request.get('v1/user/has_polymarket_permission', {
1935
- params,
1936
- });
1937
- return data;
1938
- });
1939
- this.getDappPermission = (params) => __awaiter(this, void 0, void 0, function* () {
1940
- const { data } = yield this.request.get('v1/user/has_dapp_permission', {
1941
- params,
1942
- });
1943
- return data;
1944
- });
1945
- this.getMemeList = (params) => __awaiter(this, void 0, void 0, function* () {
1946
- const { data } = yield this.request.get('/v1/token/meme_list', {
1947
- params,
1948
- });
1949
- return data;
1950
- });
1951
- this.getTokenMarketTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1952
- const { data } = yield this.request.get('/v1/token/market/token_list', {
1953
- params,
1954
- });
1955
- return data;
1956
- });
1957
- if (store instanceof Promise) {
1958
- store.then((resolvedStore) => {
1959
- this.store = resolvedStore;
1960
- });
1961
- }
1962
- else {
1963
- this.store = store;
1964
- }
1965
- __classPrivateFieldSet(this, _OpenApiService_plugin, plugin, "f");
1966
- __classPrivateFieldSet(this, _OpenApiService_adapter, adapter, "f");
1967
- __classPrivateFieldSet(this, _OpenApiService_clientName, clientName, "f");
1968
- __classPrivateFieldSet(this, _OpenApiService_clientVersion, clientVersion, "f");
1969
- }
1970
- initSync(options) {
1971
- var _a, _b;
1972
- (_b = (_a = __classPrivateFieldGet(this, _OpenApiService_plugin, "f")).onInitiate) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign({}, options));
1973
- const headers = {
1974
- 'X-Client': __classPrivateFieldGet(this, _OpenApiService_clientName, "f"),
1975
- 'X-Version': __classPrivateFieldGet(this, _OpenApiService_clientVersion, "f"),
1976
- };
1977
- if (this.store.apiKey && this.store.apiTime) {
1978
- headers['X-API-Key'] = this.store.apiKey;
1979
- headers['X-API-Time'] = this.store.apiTime;
1980
- }
1981
- const request = axios.create({
1982
- baseURL: this.store.host,
1983
- adapter: __classPrivateFieldGet(this, _OpenApiService_adapter, "f"),
1984
- headers,
1985
- });
1986
- // sign after rateLimit, timestamp is the latest
1987
- request.interceptors.request.use((config) => __awaiter(this, void 0, void 0, function* () {
1988
- const { method, url, params } = genSignParams(config);
1989
- yield __classPrivateFieldGet(this, _OpenApiService_plugin, "f").onSignRequest({
1990
- axiosRequestConfig: config,
1991
- parsed: { method, url, params },
1992
- });
1993
- return config;
1994
- }));
1995
- this.request = rateLimit(request, { maxRPS });
1996
- this.request.interceptors.response.use((response) => {
1997
- var _a, _b, _c, _d, _e;
1998
- const newAPIKey = (_a = response.headers) === null || _a === void 0 ? void 0 : _a['x-set-api-key'];
1999
- if (newAPIKey) {
2000
- this.setAPIKey(newAPIKey);
2001
- }
2002
- const code = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.err_code) || ((_c = response.data) === null || _c === void 0 ? void 0 : _c.error_code);
2003
- const msg = ((_d = response.data) === null || _d === void 0 ? void 0 : _d.err_msg) || ((_e = response.data) === null || _e === void 0 ? void 0 : _e.error_msg);
2004
- if (code && code !== 200) {
2005
- if (msg) {
2006
- let err;
2007
- try {
2008
- err = new Error(JSON.parse(msg));
2009
- }
2010
- catch (e) {
2011
- err = new Error(msg);
2012
- }
2013
- throw err;
2014
- }
2015
- throw new Error(typeof response.data === 'string'
2016
- ? response.data
2017
- : JSON.stringify(response.data));
2018
- }
2019
- return response;
2020
- });
2021
- this._mountMethods();
2022
- }
2023
- }
2024
- _OpenApiService_adapter = new WeakMap(), _OpenApiService_plugin = new WeakMap(), _OpenApiService_clientName = new WeakMap(), _OpenApiService_clientVersion = new WeakMap();
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
11
+ if (kind === "m") throw new TypeError("Private method is not writable");
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
13
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
14
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
15
+ };
16
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
17
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
+ };
21
+ var __rest = (this && this.__rest) || function (s, e) {
22
+ var t = {};
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
+ t[p] = s[p];
25
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
+ t[p[i]] = s[p[i]];
29
+ }
30
+ return t;
31
+ };
32
+ var _OpenApiService_adapter, _OpenApiService_plugin, _OpenApiService_clientName, _OpenApiService_clientVersion;
33
+ import axios from 'axios';
34
+ import rateLimit from 'axios-rate-limit';
35
+ import { ethErrors } from 'eth-rpc-errors';
36
+ import { genSignParams, sleep } from './utils';
37
+ import { omit } from 'lodash';
38
+ import { ASYNC_JOB_RETRY_DELAY, ASYNC_JOB_TIMEOUT } from './const';
39
+ var CurveDayType;
40
+ (function (CurveDayType) {
41
+ CurveDayType[CurveDayType["DAY"] = 1] = "DAY";
42
+ CurveDayType[CurveDayType["WEEK"] = 7] = "WEEK";
43
+ })(CurveDayType || (CurveDayType = {}));
44
+ const maxRPS = 500;
45
+ export class OpenApiService {
46
+ constructor(_a) {
47
+ var _b;
48
+ var { store, plugin, adapter, clientName = 'Rabby', clientVersion = (_b = process.env.release) !== null && _b !== void 0 ? _b : '0.0.0', } = _a;
49
+ _OpenApiService_adapter.set(this, void 0);
50
+ _OpenApiService_plugin.set(this, void 0);
51
+ _OpenApiService_clientName.set(this, void 0);
52
+ _OpenApiService_clientVersion.set(this, void 0);
53
+ this.setHost = (host) => __awaiter(this, void 0, void 0, function* () {
54
+ this.store.host = host;
55
+ yield this.init();
56
+ });
57
+ this.setHostSync = (host) => {
58
+ this.store.host = host;
59
+ this.initSync();
60
+ };
61
+ this.setAPIKey = (apiKey) => __awaiter(this, void 0, void 0, function* () {
62
+ this.store.apiKey = apiKey;
63
+ yield this.init();
64
+ });
65
+ this.setAPITime = (apiTime) => __awaiter(this, void 0, void 0, function* () {
66
+ this.store.apiTime = apiTime;
67
+ yield this.init();
68
+ });
69
+ this.removeAPIKey = () => __awaiter(this, void 0, void 0, function* () {
70
+ this.store.apiKey = null;
71
+ this.store.apiTime = null;
72
+ yield this.init();
73
+ });
74
+ this.getHost = () => {
75
+ return this.store.host;
76
+ };
77
+ this.setTestnetHost = (host) => __awaiter(this, void 0, void 0, function* () {
78
+ this.store.testnetHost = host;
79
+ });
80
+ this.getTestnetHost = () => {
81
+ return this.store.testnetHost;
82
+ };
83
+ this.ethRpc = () => __awaiter(this, void 0, void 0, function* () {
84
+ throw ethErrors.provider.disconnected();
85
+ });
86
+ this.init = (options) => __awaiter(this, void 0, void 0, function* () {
87
+ var _c, _d;
88
+ options = typeof options === 'string' ? { webHf: options } : options;
89
+ yield ((_d = (_c = __classPrivateFieldGet(this, _OpenApiService_plugin, "f")).onInitiateAsync) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign({}, options)));
90
+ this.initSync(Object.assign({}, options));
91
+ });
92
+ this.getSafePendingTransactions = ({ txServiceUrl, safeAddress, nonce, }) => __awaiter(this, void 0, void 0, function* () {
93
+ const { data } = yield this.request.get(`${txServiceUrl}/v1/safes/${safeAddress}/multisig-transactions/`, {
94
+ params: {
95
+ executed: false,
96
+ nonce__gte: nonce,
97
+ },
98
+ });
99
+ return data;
100
+ });
101
+ this.postSafeTransactions = ({ txServiceUrl, safeAddress, data, }) => __awaiter(this, void 0, void 0, function* () {
102
+ yield this.request.post(`${txServiceUrl}/v1/safes/${safeAddress}/multisig-transactions/`, data);
103
+ });
104
+ this.getSafeInfo = ({ txServiceUrl, safeAddress, }) => __awaiter(this, void 0, void 0, function* () {
105
+ const { data } = yield this.request.get(`${txServiceUrl}/v1/safes/${safeAddress}/`);
106
+ return data;
107
+ });
108
+ this.confirmSafeTransaction = ({ txServiceUrl, safeTransactionHash, data, }) => __awaiter(this, void 0, void 0, function* () {
109
+ yield this.request.post(`${txServiceUrl}/v1/multisig-transactions/${safeTransactionHash}/confirmations/`, data);
110
+ });
111
+ this.getSafeTxGas = ({ txServiceUrl, safeAddress, safeTxData, }) => __awaiter(this, void 0, void 0, function* () {
112
+ const { data } = yield this.request.post(`${txServiceUrl}/v1/safes/${safeAddress}/multisig-transactions/estimations/`, {
113
+ to: safeTxData.to,
114
+ value: safeTxData.value || '0',
115
+ data: safeTxData.data,
116
+ operation: safeTxData.operation,
117
+ });
118
+ return data === null || data === void 0 ? void 0 : data.safeTxGas;
119
+ });
120
+ this.getSafeMessages = ({ txServiceUrl, safeAddress, options, }) => __awaiter(this, void 0, void 0, function* () {
121
+ const { data } = yield this.request.get(`${txServiceUrl}/v1/safes/${safeAddress}/messages/`, {
122
+ params: options,
123
+ });
124
+ return data;
125
+ });
126
+ this.addSafeMessage = ({ txServiceUrl, safeAddress, data, }) => __awaiter(this, void 0, void 0, function* () {
127
+ yield this.request.post(`${txServiceUrl}/v1/safes/${safeAddress}/messages/`, data);
128
+ });
129
+ this.getSafeMessage = ({ txServiceUrl, messageHash, }) => __awaiter(this, void 0, void 0, function* () {
130
+ const { data } = yield this.request.get(`${txServiceUrl}/v1/messages/${messageHash}/`);
131
+ return data;
132
+ });
133
+ this.addSafeMessageSignature = ({ txServiceUrl, messageHash, signature, }) => __awaiter(this, void 0, void 0, function* () {
134
+ yield this.request.post(`${txServiceUrl}/v1/messages/${messageHash}/signatures/`, {
135
+ signature,
136
+ });
137
+ });
138
+ this.asyncJob = (url, options) => {
139
+ const _option = Object.assign({ timeout: ASYNC_JOB_TIMEOUT, retryDelay: ASYNC_JOB_RETRY_DELAY }, options);
140
+ const startTime = +new Date();
141
+ return this.request(url, omit(Object.assign({ method: 'GET' }, _option), 'retryDelay')).then((res) => {
142
+ const data = res.data;
143
+ if (data.result) {
144
+ return data.result.data;
145
+ }
146
+ const deltaTime = +new Date() - startTime;
147
+ _option.timeout = _option.timeout - deltaTime - _option.retryDelay;
148
+ return sleep(_option.retryDelay, _option.signal).then(() => this.asyncJob(url, _option));
149
+ });
150
+ };
151
+ this._mountMethods = () => {
152
+ this.ethRpc = (chain_id, { origin = 'rabby', method, params }) => {
153
+ return this.request
154
+ .post(`/v1/wallet/eth_rpc?origin=${origin}&method=${method}`, {
155
+ chain_id,
156
+ method,
157
+ params,
158
+ })
159
+ .then(({ data }) => {
160
+ if (data === null || data === void 0 ? void 0 : data.error) {
161
+ throw data.error;
162
+ }
163
+ return data === null || data === void 0 ? void 0 : data.result;
164
+ });
165
+ };
166
+ };
167
+ this.getRecommendChains = (address, origin) => __awaiter(this, void 0, void 0, function* () {
168
+ const { data } = yield this.request.get('/v1/wallet/recommend_chains', {
169
+ params: {
170
+ user_addr: address,
171
+ origin,
172
+ },
173
+ });
174
+ return data;
175
+ });
176
+ this.getTotalBalance = (address, isCore = false) => __awaiter(this, void 0, void 0, function* () {
177
+ const { data } = yield this.request.get('/v1/user/total_balance', {
178
+ params: {
179
+ id: address,
180
+ is_core: isCore,
181
+ },
182
+ });
183
+ return data;
184
+ });
185
+ this.getTotalBalanceV2 = ({ address, isCore = false, included_token_uuids = [], excluded_token_uuids = [], excluded_protocol_ids = [], excluded_chain_ids = [], }) => __awaiter(this, void 0, void 0, function* () {
186
+ const { data } = yield this.request.post('/v2/user/total_balance', {
187
+ id: address,
188
+ is_core: isCore,
189
+ included_token_uuids: included_token_uuids,
190
+ excluded_token_uuids: excluded_token_uuids,
191
+ excluded_protocol_ids: excluded_protocol_ids,
192
+ excluded_chain_ids: excluded_chain_ids,
193
+ });
194
+ return data;
195
+ });
196
+ this.get24hTotalBalance = (address) => __awaiter(this, void 0, void 0, function* () {
197
+ const { data } = yield this.request.get('/v1/user/total_balance_24h', {
198
+ params: {
199
+ id: address,
200
+ },
201
+ });
202
+ return data;
203
+ });
204
+ this.getPendingCount = (address) => __awaiter(this, void 0, void 0, function* () {
205
+ const { data } = yield this.request.get('/v1/wallet/pending_tx_count', {
206
+ params: {
207
+ user_addr: address,
208
+ },
209
+ });
210
+ return data;
211
+ });
212
+ this.checkOrigin = (address, origin) => __awaiter(this, void 0, void 0, function* () {
213
+ const { data } = yield this.request.post('/v1/wallet/check_origin', {
214
+ user_addr: address,
215
+ origin,
216
+ });
217
+ return data;
218
+ });
219
+ this.checkText = (address, origin, text) => __awaiter(this, void 0, void 0, function* () {
220
+ const { data } = yield this.request.post('/v1/wallet/check_text', {
221
+ user_addr: address,
222
+ origin,
223
+ text,
224
+ });
225
+ return data;
226
+ });
227
+ this.checkTx = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
228
+ const { data } = yield this.request.post('/v1/wallet/check_tx', {
229
+ user_addr: address,
230
+ origin,
231
+ tx,
232
+ update_nonce,
233
+ });
234
+ return data;
235
+ });
236
+ this.preExecTx = ({ tx, origin, address, updateNonce = false, pending_tx_list = [], delegate_call, }) => __awaiter(this, void 0, void 0, function* () {
237
+ const { data } = yield this.request.post('/v1/wallet/pre_exec_tx', {
238
+ tx,
239
+ user_addr: address,
240
+ origin,
241
+ update_nonce: updateNonce,
242
+ pending_tx_list,
243
+ delegate_call,
244
+ });
245
+ return data;
246
+ });
247
+ this.historyGasUsed = (params) => __awaiter(this, void 0, void 0, function* () {
248
+ const { data } = yield this.request.post('/v1/wallet/history_tx_used_gas', Object.assign({}, params));
249
+ return data;
250
+ });
251
+ this.pendingTxList = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
252
+ const { data } = yield this.request.post('/v1/wallet/pending_tx_list', {
253
+ tx,
254
+ user_addr: address,
255
+ origin,
256
+ update_nonce,
257
+ });
258
+ return data;
259
+ });
260
+ this.traceTx = (txId, traceId, chainId) => __awaiter(this, void 0, void 0, function* () {
261
+ const { data } = yield this.request.post('/v1/wallet/trace_tx', {
262
+ tx_id: txId,
263
+ trace_id: traceId,
264
+ chain_id: chainId,
265
+ });
266
+ return data;
267
+ });
268
+ this.pushTx = (tx, traceId) => __awaiter(this, void 0, void 0, function* () {
269
+ const { data } = yield this.request.post('/v1/wallet/push_tx', {
270
+ tx,
271
+ trace_id: traceId,
272
+ });
273
+ return data;
274
+ });
275
+ this.explainText = (origin, address, text) => __awaiter(this, void 0, void 0, function* () {
276
+ const { data } = yield this.request.post('/v1/wallet/explain_text', {
277
+ user_addr: address,
278
+ origin,
279
+ text,
280
+ });
281
+ return data;
282
+ });
283
+ this.gasMarket = (chainId, customGas) => __awaiter(this, void 0, void 0, function* () {
284
+ const { data } = yield this.request.get('/v1/wallet/gas_market', {
285
+ params: {
286
+ chain_id: chainId,
287
+ custom_price: customGas,
288
+ },
289
+ });
290
+ return data;
291
+ });
292
+ this.gasMarketV2 = (options) => __awaiter(this, void 0, void 0, function* () {
293
+ const { data } = yield this.request.post('/v2/wallet/gas_market', {
294
+ chain_id: options.chainId,
295
+ custom_price: options.customGas,
296
+ tx: options.tx,
297
+ });
298
+ return data;
299
+ });
300
+ this.getTx = (chainId, hash, gasPrice) => __awaiter(this, void 0, void 0, function* () {
301
+ const { data } = yield this.request.get('/v1/wallet/get_tx', {
302
+ params: {
303
+ chain_id: chainId,
304
+ gas_price: gasPrice,
305
+ tx_id: hash,
306
+ },
307
+ });
308
+ return data;
309
+ });
310
+ this.getEnsAddressByName = (name) => __awaiter(this, void 0, void 0, function* () {
311
+ const { data } = yield this.request.get('/v1/wallet/ens', {
312
+ params: {
313
+ text: name,
314
+ },
315
+ });
316
+ return data;
317
+ });
318
+ this.searchToken = (id, q, chainId, is_all = false) => __awaiter(this, void 0, void 0, function* () {
319
+ const { data } = yield this.request.get('/v1/user/token_search', {
320
+ params: {
321
+ id,
322
+ q,
323
+ has_balance: false,
324
+ is_all,
325
+ chain_id: chainId,
326
+ },
327
+ });
328
+ return data;
329
+ });
330
+ this.searchSwapToken = (id, chainId, q, is_all = false) => __awaiter(this, void 0, void 0, function* () {
331
+ const { data } = yield this.request.get('/v1/user/token_search', {
332
+ params: {
333
+ id,
334
+ chain_id: chainId,
335
+ q,
336
+ is_all,
337
+ },
338
+ });
339
+ return data;
340
+ });
341
+ this.getToken = (id, chainId, tokenId) => __awaiter(this, void 0, void 0, function* () {
342
+ const { data } = yield this.request.get('/v1/user/token', {
343
+ params: {
344
+ id,
345
+ chain_id: chainId,
346
+ token_id: tokenId,
347
+ },
348
+ });
349
+ return data;
350
+ });
351
+ this.getCachedTokenList = (id) => __awaiter(this, void 0, void 0, function* () {
352
+ const { data } = yield this.request.get('/v1/user/cache_token_list', {
353
+ params: {
354
+ id,
355
+ },
356
+ });
357
+ return data;
358
+ });
359
+ this.listToken = (id, chainId, isAll = false) => __awaiter(this, void 0, void 0, function* () {
360
+ const { data } = yield this.request.get('/v1/user/token_list', {
361
+ params: {
362
+ id,
363
+ is_all: isAll,
364
+ chain_id: chainId,
365
+ },
366
+ });
367
+ return data;
368
+ });
369
+ this.getTokenEntity = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
370
+ const { data } = yield this.request.get('/v1/token/identity', {
371
+ params: {
372
+ id,
373
+ chain_id: chainId,
374
+ },
375
+ });
376
+ return data;
377
+ });
378
+ this.getHistoryTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
379
+ const { data } = yield this.request.get('/v1/user/history_token_list', {
380
+ params: {
381
+ id: params.id,
382
+ chain_id: params.chainId,
383
+ time_at: params.timeAt,
384
+ date_at: params.dateAt,
385
+ },
386
+ });
387
+ return data;
388
+ });
389
+ this.customListToken = (uuids, id) => __awaiter(this, void 0, void 0, function* () {
390
+ if (!(uuids === null || uuids === void 0 ? void 0 : uuids.length) || !id) {
391
+ return [];
392
+ }
393
+ const { data } = yield this.request.post('/v1/user/specific_token_list', {
394
+ id,
395
+ uuids,
396
+ });
397
+ return data;
398
+ });
399
+ this.listChainAssets = (id) => __awaiter(this, void 0, void 0, function* () {
400
+ const { data } = yield this.request.get('/v1/user/simple_protocol_list', {
401
+ params: {
402
+ id,
403
+ },
404
+ });
405
+ return data;
406
+ });
407
+ this.listNFT = (id, isAll = true, sortByCredit) => __awaiter(this, void 0, void 0, function* () {
408
+ const { data } = yield this.request.get('/v1/user/nft_list', {
409
+ params: Object.assign({
410
+ id,
411
+ is_all: isAll,
412
+ }, sortByCredit
413
+ ? {
414
+ sort_by: 'credit_score',
415
+ }
416
+ : {}),
417
+ });
418
+ return data;
419
+ });
420
+ this.listCollection = (params) => __awaiter(this, void 0, void 0, function* () {
421
+ const { data } = yield this.request.get('/v1/nft/collections', {
422
+ params,
423
+ });
424
+ return data;
425
+ });
426
+ this.hasNewTxFrom = (params) => __awaiter(this, void 0, void 0, function* () {
427
+ const { data } = yield this.request.get('/v1/user/has_new_tx', {
428
+ params: {
429
+ id: params.address,
430
+ start_time: params.startTime,
431
+ },
432
+ });
433
+ return data;
434
+ });
435
+ this.listTxHisotry = (params) => __awaiter(this, void 0, void 0, function* () {
436
+ const { data } = yield this.request.get('/v1/user/history_list', {
437
+ params,
438
+ });
439
+ return data;
440
+ });
441
+ this.getAllTxHistory = (params, options) => __awaiter(this, void 0, void 0, function* () {
442
+ const data = yield this.asyncJob('/v1/user/history_all_list', Object.assign({ method: 'GET', params }, options));
443
+ return data;
444
+ });
445
+ this.tokenPrice = (tokenName) => __awaiter(this, void 0, void 0, function* () {
446
+ const { data } = yield this.request.get('/v1/token/price_change', {
447
+ params: {
448
+ token: tokenName,
449
+ },
450
+ });
451
+ return data;
452
+ });
453
+ this.getTokenPriceList = (params) => __awaiter(this, void 0, void 0, function* () {
454
+ const { data } = yield this.request.post('/v1/token/price_list', params);
455
+ return data;
456
+ });
457
+ this.tokenAuthorizedList = (id, chain_id, options) => __awaiter(this, void 0, void 0, function* () {
458
+ const { restfulPrefix = 'v1' } = options || {};
459
+ const { data } = yield this.request.get(`/${restfulPrefix}/user/token_authorized_list`, {
460
+ params: {
461
+ id,
462
+ chain_id,
463
+ },
464
+ });
465
+ return data;
466
+ });
467
+ this.userNFTAuthorizedList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
468
+ const { data } = yield this.request.get('/v1/user/nft_authorized_list', {
469
+ params: {
470
+ id,
471
+ chain_id,
472
+ },
473
+ });
474
+ return data;
475
+ });
476
+ this.getDEXList = (chain_id) => __awaiter(this, void 0, void 0, function* () {
477
+ const { data } = yield this.request.get('/v1/wallet/swap_dex_list', {
478
+ params: {
479
+ chain_id,
480
+ },
481
+ });
482
+ return data;
483
+ });
484
+ this.getSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
485
+ const { data } = yield this.request.get('/v1/wallet/swap_quote', {
486
+ params,
487
+ timeout: 5000,
488
+ });
489
+ return data;
490
+ });
491
+ this.getSwapTokenList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
492
+ const params = {
493
+ id,
494
+ is_all: false,
495
+ };
496
+ if (chainId) {
497
+ params.chain_id = chainId;
498
+ }
499
+ const { data } = yield this.request.get('/v1/wallet/swap_token_list', {
500
+ params,
501
+ });
502
+ return data;
503
+ });
504
+ this.postGasStationOrder = (params) => __awaiter(this, void 0, void 0, function* () {
505
+ const { data } = yield this.request.post('/v1/wallet/gas_station_order', {
506
+ order: {
507
+ user_addr: params.userAddr,
508
+ from_chain_id: params.fromChainId,
509
+ from_tx_id: params.fromTxId,
510
+ from_token_id: params.fromTokenId,
511
+ from_token_amount: params.fromTokenAmount,
512
+ to_chain_id: params.toChainId,
513
+ to_token_amount: params.toTokenAmount,
514
+ from_usd_value: params.fromUsdValue,
515
+ },
516
+ });
517
+ return data;
518
+ });
519
+ this.getGasStationChainBalance = (chain_id, addr) => __awaiter(this, void 0, void 0, function* () {
520
+ const { data } = yield this.request.get('/v1/wallet/gas_station_usd_value', {
521
+ params: {
522
+ chain_id,
523
+ addr,
524
+ },
525
+ });
526
+ return data;
527
+ });
528
+ this.getApprovalCount = (address) => __awaiter(this, void 0, void 0, function* () {
529
+ const { data } = yield this.request.get('/v1/user/total_approval_asset_cnt', {
530
+ params: {
531
+ id: address,
532
+ },
533
+ });
534
+ return data;
535
+ });
536
+ this.getGasStationTokenList = () => __awaiter(this, void 0, void 0, function* () {
537
+ const { data } = yield this.request.get('/v1/wallet/gas_station_token_list');
538
+ return data;
539
+ });
540
+ this.explainTypedData = (user_addr, origin, data) => __awaiter(this, void 0, void 0, function* () {
541
+ const { data: resData } = yield this.request.post('/v1/wallet/explain_typed_data', {
542
+ user_addr,
543
+ origin,
544
+ data,
545
+ });
546
+ return resData;
547
+ });
548
+ this.checkTypedData = (user_addr, origin, data) => __awaiter(this, void 0, void 0, function* () {
549
+ const { data: resData } = yield this.request.post('/v1/wallet/check_typed_data', {
550
+ user_addr,
551
+ origin,
552
+ data,
553
+ });
554
+ return resData;
555
+ });
556
+ this.approvalStatus = (id, options) => __awaiter(this, void 0, void 0, function* () {
557
+ const { restfulPrefix = 'v1' } = options || {};
558
+ const { data } = yield this.request.get(`/${restfulPrefix}/user/approval_status`, {
559
+ params: {
560
+ id,
561
+ },
562
+ });
563
+ return data;
564
+ });
565
+ this.usedChainList = (id) => __awaiter(this, void 0, void 0, function* () {
566
+ const { data } = yield this.request.get('/v1/user/used_chain_list', {
567
+ params: {
568
+ id,
569
+ },
570
+ });
571
+ return data;
572
+ });
573
+ this.getLatestVersion = () => __awaiter(this, void 0, void 0, function* () {
574
+ const { data } = yield this.request.get('/v1/wallet/version');
575
+ return data;
576
+ });
577
+ this.addOriginFeedback = (params) => __awaiter(this, void 0, void 0, function* () {
578
+ const { data } = yield this.request.post('/v1/wallet/add_origin_feedback', {
579
+ user_addr: params.user_addr,
580
+ origin: params.origin,
581
+ is_safe: params.is_safe,
582
+ });
583
+ return data;
584
+ });
585
+ this.getProtocolList = (addr) => __awaiter(this, void 0, void 0, function* () {
586
+ const { data } = yield this.request.get('/v1/user/protocol_list', {
587
+ params: {
588
+ id: addr,
589
+ },
590
+ });
591
+ return data;
592
+ });
593
+ this.getComplexProtocolList = (addr) => __awaiter(this, void 0, void 0, function* () {
594
+ const { data } = yield this.request.get('/v1/user/complex_protocol_list', {
595
+ params: {
596
+ id: addr,
597
+ },
598
+ });
599
+ return data;
600
+ });
601
+ this.getProtocol = ({ addr, id, }) => __awaiter(this, void 0, void 0, function* () {
602
+ const { data } = yield this.request.get('/v1/user/protocol', {
603
+ params: {
604
+ id: addr,
605
+ protocol_id: id,
606
+ },
607
+ });
608
+ return data;
609
+ });
610
+ this.getHistoryProtocol = ({ addr, id, timeAt, dateAt, }) => __awaiter(this, void 0, void 0, function* () {
611
+ const { data } = yield this.request.get('/v1/user/history_protocol', {
612
+ params: {
613
+ id: addr,
614
+ protocol_id: id,
615
+ time_at: timeAt,
616
+ date_at: dateAt,
617
+ },
618
+ });
619
+ return data;
620
+ });
621
+ this.getTokenHistoryPrice = ({ chainId, id, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
622
+ const { data } = yield this.request.get('/v1/token/history_price', {
623
+ params: {
624
+ chain_id: chainId,
625
+ id,
626
+ time_at: timeAt,
627
+ },
628
+ });
629
+ return data;
630
+ });
631
+ this.getTokenHistoryDict = ({ chainId, ids, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
632
+ const { data } = yield this.request.get('/v1/token/history_price_dict', {
633
+ params: {
634
+ chain_id: chainId,
635
+ ids,
636
+ time_at: timeAt,
637
+ },
638
+ });
639
+ return data;
640
+ });
641
+ this.getNetCurve = (addr, days = CurveDayType.DAY) => __awaiter(this, void 0, void 0, function* () {
642
+ const { data } = yield this.request.get('/v1/user/total_net_curve', {
643
+ params: {
644
+ id: addr,
645
+ days,
646
+ },
647
+ });
648
+ return data;
649
+ });
650
+ this.getChainList = () => __awaiter(this, void 0, void 0, function* () {
651
+ const { data } = yield this.request.get('/v1/chain/list');
652
+ return data;
653
+ });
654
+ this.getCEXSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
655
+ const { data } = yield this.request.get('/v1/wallet/cex_swap_quote', {
656
+ params,
657
+ });
658
+ return data;
659
+ });
660
+ this.getSwapTradeList = (params) => __awaiter(this, void 0, void 0, function* () {
661
+ const { data } = yield this.request.get('/v1/wallet/swap_trade_list', {
662
+ params,
663
+ });
664
+ return data;
665
+ });
666
+ this.getSwapTradeListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
667
+ const { data } = yield this.request.get('/v2/wallet/swap_trade_list', {
668
+ params,
669
+ });
670
+ return data;
671
+ });
672
+ this.postSwap = (params) => __awaiter(this, void 0, void 0, function* () {
673
+ const { data } = yield this.request.post('/v1/wallet/swap_trade', params);
674
+ return data;
675
+ });
676
+ this.checkSlippage = (params) => __awaiter(this, void 0, void 0, function* () {
677
+ const { data } = yield this.request.get('/v1/wallet/check_slippage', {
678
+ params,
679
+ });
680
+ return data;
681
+ });
682
+ this.suggestSlippage = (params) => __awaiter(this, void 0, void 0, function* () {
683
+ const { data } = yield this.request.get('v1/wallet/suggest_slippage', {
684
+ params,
685
+ });
686
+ return data;
687
+ });
688
+ this.getOriginPopularityLevel = (origin) => __awaiter(this, void 0, void 0, function* () {
689
+ const { data } = yield this.request.get('/v1/engine/origin/popularity_level', {
690
+ params: {
691
+ origin,
692
+ },
693
+ });
694
+ return data;
695
+ });
696
+ this.getOriginIsScam = (origin, source) => __awaiter(this, void 0, void 0, function* () {
697
+ const { data } = yield this.request.get('/v1/engine/origin/is_scam', {
698
+ params: {
699
+ origin,
700
+ source,
701
+ },
702
+ });
703
+ return data;
704
+ });
705
+ this.getOriginThirdPartyCollectList = (origin) => __awaiter(this, void 0, void 0, function* () {
706
+ const { data } = yield this.request.get('/v1/engine/origin/third_party_collect_list', {
707
+ params: {
708
+ origin,
709
+ },
710
+ });
711
+ return data;
712
+ });
713
+ this.getSummarizedAssetList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
714
+ const { data } = yield this.request.get('/v1/user/summarized_asset_list', {
715
+ params: {
716
+ id,
717
+ chain_id,
718
+ },
719
+ });
720
+ return data;
721
+ });
722
+ this.unexpectedAddrList = ({ chainId, tx, origin, addr, }) => __awaiter(this, void 0, void 0, function* () {
723
+ const { data } = yield this.request.post('/v1/engine/addr/unexpected_list', {
724
+ chain_id: chainId,
725
+ tx,
726
+ origin,
727
+ user_addr: addr,
728
+ });
729
+ return data;
730
+ });
731
+ this.gasLessTxCheck = ({ tx, usdValue, preExecSuccess, gasUsed, }) => __awaiter(this, void 0, void 0, function* () {
732
+ const { data } = yield this.request.post('/v1/wallet/tx_is_gasless', {
733
+ gas_used: gasUsed,
734
+ pre_exec_success: preExecSuccess,
735
+ tx,
736
+ usd_value: usdValue,
737
+ });
738
+ return data;
739
+ });
740
+ this.gasLessTxsCheck = (postData) => __awaiter(this, void 0, void 0, function* () {
741
+ const { data } = yield this.request.post('/v1/wallet/txs_is_gasless', postData);
742
+ return data;
743
+ });
744
+ this.parseTx = ({ chainId, tx, origin, addr, }) => __awaiter(this, void 0, void 0, function* () {
745
+ const { data } = yield this.request.post('/v1/engine/action/parse_tx', {
746
+ chain_id: chainId,
747
+ tx,
748
+ origin,
749
+ user_addr: addr,
750
+ });
751
+ return data;
752
+ });
753
+ this.isSuspiciousToken = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
754
+ const { data } = yield this.request.get('/v1/engine/token/is_suspicious', {
755
+ params: {
756
+ chain_id: chainId,
757
+ id,
758
+ },
759
+ });
760
+ return data;
761
+ });
762
+ this.depositCexSupport = (id, chainId, cexId) => __awaiter(this, void 0, void 0, function* () {
763
+ const { data } = yield this.request.get('/v1/engine/token/deposit_cex_support', {
764
+ params: {
765
+ chain_id: chainId,
766
+ id,
767
+ cex_id: cexId,
768
+ },
769
+ });
770
+ return data;
771
+ });
772
+ // Token 可充值的 CEX 列表
773
+ this.depositCexList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
774
+ const { data } = yield this.request.get('/v1/engine/token/deposit_cex_list', {
775
+ params: {
776
+ chain_id: chainId,
777
+ id,
778
+ },
779
+ });
780
+ return data;
781
+ });
782
+ // 合约信用分
783
+ this.getContractCredit = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
784
+ const { data } = yield this.request.get('/v1/engine/contract/credit', {
785
+ params: {
786
+ chain_id: chainId,
787
+ id,
788
+ },
789
+ });
790
+ return data;
791
+ });
792
+ // 是否跟地址交互过
793
+ this.hasInteraction = (addr, chainId, contractId) => __awaiter(this, void 0, void 0, function* () {
794
+ const { data } = yield this.request.get('/v1/engine/contract/has_interaction', {
795
+ params: {
796
+ chain_id: chainId,
797
+ user_addr: addr,
798
+ contract_id: contractId,
799
+ },
800
+ });
801
+ return data;
802
+ });
803
+ /**
804
+ * @deprecated
805
+ * 授权风险敞口
806
+ */
807
+ this.tokenApproveExposure = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
808
+ const { data } = yield this.request.get('/v1/engine/contract/token_approval_exposure', {
809
+ params: {
810
+ chain_id: chainId,
811
+ id,
812
+ },
813
+ });
814
+ return data;
815
+ });
816
+ this.tokenApproveTrustValue = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
817
+ const { data } = yield this.request.get('/v1/engine/contract/spend_usd_value', {
818
+ params: {
819
+ chain_id: chainId,
820
+ id,
821
+ },
822
+ });
823
+ return data;
824
+ });
825
+ this.getContractInfo = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
826
+ const { data } = yield this.request.get('/v1/contract', {
827
+ params: {
828
+ chain_id: chainId,
829
+ id,
830
+ },
831
+ });
832
+ return data.contract;
833
+ });
834
+ // 地址描述
835
+ this.addrDesc = (id) => __awaiter(this, void 0, void 0, function* () {
836
+ const { data } = yield this.request.get('/v1/engine/addr/desc', {
837
+ params: {
838
+ id,
839
+ },
840
+ });
841
+ return data;
842
+ });
843
+ // 两个地址是否发生过转账
844
+ this.hasTransfer = (chainId, from, to) => __awaiter(this, void 0, void 0, function* () {
845
+ const { data } = yield this.request.get('/v1/engine/addr/has_transfer', {
846
+ params: {
847
+ chain_id: chainId,
848
+ from_addr: from,
849
+ to_addr: to,
850
+ },
851
+ timeout: 2000,
852
+ });
853
+ return data;
854
+ });
855
+ // 全链两个地址是否发生过转账
856
+ this.hasTransferAllChain = (from, to) => __awaiter(this, void 0, void 0, function* () {
857
+ const { data } = yield this.request.get('/v2/engine/addr/has_transfer', {
858
+ params: {
859
+ from_addr: from,
860
+ to_addr: to,
861
+ },
862
+ timeout: 2000,
863
+ });
864
+ return data;
865
+ });
866
+ this.isTokenContract = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
867
+ const { data } = yield this.request.get('/v1/engine/contract/is_token', {
868
+ params: {
869
+ id,
870
+ chain_id: chainId,
871
+ },
872
+ });
873
+ return data;
874
+ });
875
+ this.addrUsedChainList = (id) => __awaiter(this, void 0, void 0, function* () {
876
+ const { data } = yield this.request.get('/v1/engine/addr/used_chain_list', {
877
+ params: { id },
878
+ });
879
+ return data;
880
+ });
881
+ /**
882
+ * @deprecated
883
+ */
884
+ this.getTokenNFTExposure = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
885
+ const { data } = yield this.request.get('/v1/engine/contract/top_nft_approval_exposure', {
886
+ params: { chain_id: chainId, id },
887
+ });
888
+ return data;
889
+ });
890
+ this.getTokenNFTTrustValue = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
891
+ const { data } = yield this.request.get('/v1/engine/contract/top_nft_spend_usd_value', {
892
+ params: { chain_id: chainId, id },
893
+ });
894
+ return data;
895
+ });
896
+ this.getCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
897
+ const { data } = yield this.request.get('/v1/engine/collection', {
898
+ params: { chain_id: chainId, id },
899
+ });
900
+ return data;
901
+ });
902
+ this.isSuspiciousCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
903
+ const { data } = yield this.request.get('/v1/engine/collection/is_suspicious', {
904
+ params: { chain_id: chainId, id },
905
+ });
906
+ return data;
907
+ });
908
+ this.isOriginVerified = (origin) => __awaiter(this, void 0, void 0, function* () {
909
+ const { data } = yield this.request.get('/v1/engine/origin/is_verified', {
910
+ params: { origin },
911
+ });
912
+ return data;
913
+ });
914
+ this.parseTypedData = ({ typedData, origin, address, }) => __awaiter(this, void 0, void 0, function* () {
915
+ const { data } = yield this.request.post('/v1/engine/action/parse_typed_data', {
916
+ typed_data: typedData,
917
+ origin,
918
+ user_addr: address,
919
+ });
920
+ return data;
921
+ });
922
+ this.parseText = ({ text, origin, address, }) => __awaiter(this, void 0, void 0, function* () {
923
+ const { data } = yield this.request.post('/v1/engine/action/parse_text', {
924
+ text,
925
+ origin,
926
+ user_addr: address,
927
+ });
928
+ return data;
929
+ });
930
+ this.collectionList = ({ id, chainId, isAll, }) => __awaiter(this, void 0, void 0, function* () {
931
+ const { data } = yield this.request.get('/v1/user/collection_list', {
932
+ params: {
933
+ id,
934
+ chain_id: chainId,
935
+ is_all: isAll,
936
+ },
937
+ });
938
+ return data;
939
+ });
940
+ this.gasPriceStats = (chainId) => __awaiter(this, void 0, void 0, function* () {
941
+ const { data } = yield this.request.get('/v1/wallet/gas_price_stats', {
942
+ params: {
943
+ chain_id: chainId,
944
+ },
945
+ });
946
+ return data;
947
+ });
948
+ this.badgeHasClaimed = (id) => __awaiter(this, void 0, void 0, function* () {
949
+ const { data } = yield this.request.get('/v1/badge/code/user_has_claimed', {
950
+ params: {
951
+ user_id: id,
952
+ },
953
+ });
954
+ return data;
955
+ });
956
+ this.badgeHasMinted = (id) => __awaiter(this, void 0, void 0, function* () {
957
+ const { data } = yield this.request.get('/v1/badge/user_has_minted', {
958
+ params: {
959
+ user_id: id,
960
+ },
961
+ });
962
+ return data;
963
+ });
964
+ this.mintBadge = (params) => __awaiter(this, void 0, void 0, function* () {
965
+ const { data } = yield this.request.post('/v1/badge/mint', {
966
+ code: params.code,
967
+ user_id: params.userAddr,
968
+ });
969
+ return data;
970
+ });
971
+ this.badgeHasClaimedByName = ({ id, name, }) => __awaiter(this, void 0, void 0, function* () {
972
+ const { data } = yield this.request.get(`/v1/badge/code/user_has_claimed/${name}`, {
973
+ params: {
974
+ user_id: id,
975
+ },
976
+ });
977
+ return data;
978
+ });
979
+ this.badgeHasMintedByName = ({ id, name, }) => __awaiter(this, void 0, void 0, function* () {
980
+ const { data } = yield this.request.get(`/v1/badge/user_has_minted/${name}`, {
981
+ params: {
982
+ user_id: id,
983
+ },
984
+ });
985
+ return data;
986
+ });
987
+ this.mintBadgeByName = (params) => __awaiter(this, void 0, void 0, function* () {
988
+ const { data } = yield this.request.post(`/v1/badge/mint/${params.name}`, {
989
+ code: params.code,
990
+ user_id: params.userAddr,
991
+ });
992
+ return data;
993
+ });
994
+ this.userHasRequestedFaucet = (params) => __awaiter(this, void 0, void 0, function* () {
995
+ const { data } = yield this.request.get('/v1/faucet/user_has_requested', {
996
+ params,
997
+ });
998
+ return data;
999
+ });
1000
+ this.requestFaucet = (params) => __awaiter(this, void 0, void 0, function* () {
1001
+ const { data } = yield this.request.post('/v1/faucet/request', Object.assign({}, params));
1002
+ return data;
1003
+ });
1004
+ this.gasSupportedPushType = (chainId) => __awaiter(this, void 0, void 0, function* () {
1005
+ const { data } = yield this.request.get('/v1/wallet/supported_push_type', {
1006
+ params: {
1007
+ chain_id: chainId,
1008
+ },
1009
+ });
1010
+ return data;
1011
+ });
1012
+ this.submitTx = (postData) => __awaiter(this, void 0, void 0, function* () {
1013
+ const { sig } = postData, rest = __rest(postData, ["sig"]);
1014
+ const { data } = yield this.request.post('/v1/wallet/submit_tx', Object.assign({}, rest), {
1015
+ headers: sig ? { sig } : undefined,
1016
+ });
1017
+ return data;
1018
+ });
1019
+ this.submitTxV2 = (postData) => __awaiter(this, void 0, void 0, function* () {
1020
+ const { sig } = postData, rest = __rest(postData, ["sig"]);
1021
+ const { data } = yield this.request.post('/v2/wallet/submit_tx', Object.assign({}, rest), {
1022
+ headers: sig ? { sig } : undefined,
1023
+ });
1024
+ return data;
1025
+ });
1026
+ this.getDefaultRPCs = () => __awaiter(this, void 0, void 0, function* () {
1027
+ const { data } = yield this.request.get('/v1/chainrpc');
1028
+ return data;
1029
+ });
1030
+ this.getTxRequests = (ids) => __awaiter(this, void 0, void 0, function* () {
1031
+ const { data } = yield this.request.get('/v1/wallet/get_tx_requests', {
1032
+ params: {
1033
+ ids: Array.isArray(ids) ? ids.join(',') : ids,
1034
+ },
1035
+ });
1036
+ return data;
1037
+ });
1038
+ this.getTxRequest = (id) => __awaiter(this, void 0, void 0, function* () {
1039
+ const { data } = yield this.request.get('/v1/wallet/get_tx_request', {
1040
+ params: {
1041
+ id,
1042
+ },
1043
+ });
1044
+ return data;
1045
+ });
1046
+ this.withdrawTx = (reqId) => __awaiter(this, void 0, void 0, function* () {
1047
+ const { data } = yield this.request.post('/v1/wallet/withdraw_tx', {
1048
+ id: reqId,
1049
+ });
1050
+ return data;
1051
+ });
1052
+ this.retryPushTx = (reqId) => __awaiter(this, void 0, void 0, function* () {
1053
+ const { data } = yield this.request.post('/v1/wallet/retry_push_tx', {
1054
+ id: reqId,
1055
+ });
1056
+ return data;
1057
+ });
1058
+ this.mempoolChecks = (txId, chainId, node_info) => __awaiter(this, void 0, void 0, function* () {
1059
+ const { data } = yield this.request.get('/v1/wallet/mempool_checks', {
1060
+ params: {
1061
+ tx_id: txId,
1062
+ chain_id: chainId,
1063
+ node_info: node_info ? 1 : 0,
1064
+ },
1065
+ });
1066
+ return data;
1067
+ });
1068
+ this.getPendingTxList = (params, options) => __awaiter(this, void 0, void 0, function* () {
1069
+ const data = yield this.asyncJob('/v1/wallet/get_pending_tx_list', Object.assign({ params }, options));
1070
+ return data;
1071
+ });
1072
+ this.getLatestPreExec = (params) => __awaiter(this, void 0, void 0, function* () {
1073
+ const { data } = yield this.request.get('/v1/wallet/get_latest_pre_exec', {
1074
+ params,
1075
+ });
1076
+ return data;
1077
+ });
1078
+ this.walletSupportChain = (params) => __awaiter(this, void 0, void 0, function* () {
1079
+ const { data } = yield this.request.post('/v1/wallet/support_chain', params);
1080
+ return data;
1081
+ });
1082
+ this.walletSupportOrigin = (params) => __awaiter(this, void 0, void 0, function* () {
1083
+ const { data } = yield this.request.post('/v1/wallet/support_origin', params);
1084
+ return data;
1085
+ });
1086
+ this.walletSupportSelector = (params) => __awaiter(this, void 0, void 0, function* () {
1087
+ const { data } = yield this.request.post('/v1/wallet/support_selector', params);
1088
+ return data;
1089
+ });
1090
+ this.searchDapp = (params) => __awaiter(this, void 0, void 0, function* () {
1091
+ const { data } = yield this.request.get('/v1/dapp/search', { params });
1092
+ return data;
1093
+ });
1094
+ this.getDappsInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1095
+ var _e;
1096
+ const { data } = yield this.request.get('/v1/dapp/list', {
1097
+ params: {
1098
+ ids: (_e = params === null || params === void 0 ? void 0 : params.ids) === null || _e === void 0 ? void 0 : _e.join(','),
1099
+ },
1100
+ });
1101
+ return data;
1102
+ });
1103
+ this.getDappHotTags = (params) => __awaiter(this, void 0, void 0, function* () {
1104
+ const { data } = yield this.request.get('/v1/dapp/hot_tags', {
1105
+ params,
1106
+ });
1107
+ return data;
1108
+ });
1109
+ this.getHotDapps = (params) => __awaiter(this, void 0, void 0, function* () {
1110
+ const { data } = yield this.request.get('/v1/dapp/hot_list', { params });
1111
+ return data;
1112
+ });
1113
+ this.getRabbyClaimText = (params) => __awaiter(this, void 0, void 0, function* () {
1114
+ const { data } = yield this.request.get('/v1/points/user/claim_text', {
1115
+ params,
1116
+ });
1117
+ return data;
1118
+ });
1119
+ this.getRabbySignatureText = (params) => __awaiter(this, void 0, void 0, function* () {
1120
+ const { data } = yield this.request.get('/v1/points/user/sign_text', {
1121
+ params,
1122
+ });
1123
+ return data;
1124
+ });
1125
+ this.getRabbyPoints = (params) => __awaiter(this, void 0, void 0, function* () {
1126
+ const { data } = yield this.request.get('/v1/points/user', { params });
1127
+ return data;
1128
+ });
1129
+ this.checkRabbyPointsInviteCode = (params) => __awaiter(this, void 0, void 0, function* () {
1130
+ const { data } = yield this.request.get('/v1/points/user/invite_code_exist', { params });
1131
+ return data;
1132
+ });
1133
+ this.setRabbyPointsInviteCode = (params) => __awaiter(this, void 0, void 0, function* () {
1134
+ const { data } = yield this.request.post('/v1/points/user/invite_code', params);
1135
+ return data;
1136
+ });
1137
+ this.checkRabbyPointClaimable = (params) => __awaiter(this, void 0, void 0, function* () {
1138
+ const { data } = yield this.request.get('/v1/points/user/claimable', {
1139
+ params,
1140
+ });
1141
+ return data;
1142
+ });
1143
+ this.getRabbyPointsSnapshot = (params) => __awaiter(this, void 0, void 0, function* () {
1144
+ const { data } = yield this.request.get('/v1/points/snapshot', { params });
1145
+ return data;
1146
+ });
1147
+ this.claimRabbyPointsSnapshot = (params) => __awaiter(this, void 0, void 0, function* () {
1148
+ const { data } = yield this.request.post('/v1/points/claim_snapshot', params);
1149
+ return data;
1150
+ });
1151
+ this.getRabbyPointsTopUsers = (params) => __awaiter(this, void 0, void 0, function* () {
1152
+ const { data } = yield this.request.get('/v1/points/top_user', { params });
1153
+ return data;
1154
+ });
1155
+ this.getRabbyPointsList = (params) => __awaiter(this, void 0, void 0, function* () {
1156
+ const { data } = yield this.request.get('/v1/points/campaign_list', {
1157
+ params,
1158
+ });
1159
+ return data;
1160
+ });
1161
+ this.getRabbyPointsCampaignIsEnded = () => __awaiter(this, void 0, void 0, function* () {
1162
+ const { data } = yield this.request.get('v1/points/campaign');
1163
+ return data;
1164
+ });
1165
+ this.claimRabbyPointsById = (params) => __awaiter(this, void 0, void 0, function* () {
1166
+ const { data } = yield this.request.post('/v1/points/claim_campaign', params);
1167
+ return data;
1168
+ });
1169
+ this.getRabbyPointsV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1170
+ const { data } = yield this.request.get('/v2/points/user', { params });
1171
+ return data;
1172
+ });
1173
+ this.getRabbySignatureTextV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1174
+ const { data } = yield this.request.get('/v2/points/user/sign_text', {
1175
+ params,
1176
+ });
1177
+ return data;
1178
+ });
1179
+ this.getRabbyClaimTextV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1180
+ const { data } = yield this.request.get('/v2/points/user/claim_text', {
1181
+ params,
1182
+ });
1183
+ return data;
1184
+ });
1185
+ this.setRabbyPointsInviteCodeV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1186
+ const { data } = yield this.request.post('/v2/points/user/invite_code', params);
1187
+ return data;
1188
+ });
1189
+ this.checkRabbyPointsInviteCodeV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1190
+ const { data } = yield this.request.get('/v2/points/user/invite_code_exist', {
1191
+ params,
1192
+ });
1193
+ return data;
1194
+ });
1195
+ this.claimRabbyPointsSnapshotV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1196
+ const { data } = yield this.request.post('/v2/points/claim_snapshot', params);
1197
+ return data;
1198
+ });
1199
+ this.getRabbyPointsTopUsersV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1200
+ const { data } = yield this.request.get('/v2/points/top_user', {
1201
+ params,
1202
+ });
1203
+ return data;
1204
+ });
1205
+ this.getRabbyPointsListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1206
+ const { data } = yield this.request.get('/v2/points/campaign_list', {
1207
+ params,
1208
+ });
1209
+ return data;
1210
+ });
1211
+ this.claimRabbyPointsByIdV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1212
+ const { data } = yield this.request.post('/v2/points/claim_campaign', params);
1213
+ return data;
1214
+ });
1215
+ this.getRabbyPointsSnapshotV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1216
+ const { data } = yield this.request.get('/v2/points/snapshot', {
1217
+ params,
1218
+ });
1219
+ return data;
1220
+ });
1221
+ this.checkRabbyPointClaimableV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1222
+ const { data } = yield this.request.get('/v2/points/user/claimable', {
1223
+ params,
1224
+ });
1225
+ return data;
1226
+ });
1227
+ this.checkClaimInfoV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1228
+ const { data } = yield this.request.get('/v2/points/user/claim_info', {
1229
+ params,
1230
+ });
1231
+ return data;
1232
+ });
1233
+ this.getRabbyPointsCampaignIsEndedV2 = () => __awaiter(this, void 0, void 0, function* () {
1234
+ const { data } = yield this.request.get('v2/points/campaign');
1235
+ return data;
1236
+ });
1237
+ this.getSupportedChains = () => __awaiter(this, void 0, void 0, function* () {
1238
+ const { data } = yield this.request.get('/v1/wallet/supported_chains');
1239
+ return data;
1240
+ });
1241
+ this.searchChainList = (params) => __awaiter(this, void 0, void 0, function* () {
1242
+ const { data } = yield this.request.get('/v1/chain/total_list', {
1243
+ params,
1244
+ });
1245
+ return data;
1246
+ });
1247
+ this.getChainListByIds = (params) => __awaiter(this, void 0, void 0, function* () {
1248
+ const { data } = yield this.request.get('/v1/chain/get_list', {
1249
+ params,
1250
+ });
1251
+ return data;
1252
+ });
1253
+ this.getHistoryCurve = (addr) => __awaiter(this, void 0, void 0, function* () {
1254
+ const { data } = yield this.request.get('/v1/user/history_curve', {
1255
+ params: { id: addr },
1256
+ });
1257
+ return data;
1258
+ });
1259
+ this.getHistoryCurveSupportedList = () => __awaiter(this, void 0, void 0, function* () {
1260
+ const { data } = yield this.request.get('/v1/chain/classify_supported_list');
1261
+ return data;
1262
+ });
1263
+ this.getHistoryCurveStatus = (params) => __awaiter(this, void 0, void 0, function* () {
1264
+ const { data } = yield this.request.get('/v1/user/history_curve/status', {
1265
+ params,
1266
+ });
1267
+ return data;
1268
+ });
1269
+ this.initHistoryCurve = (params) => __awaiter(this, void 0, void 0, function* () {
1270
+ const { data } = yield this.request.post('/v1/user/history_curve/init', params);
1271
+ return data;
1272
+ });
1273
+ this.getNodeStatusList = () => __awaiter(this, void 0, void 0, function* () {
1274
+ const { data } = yield this.request.get('/v1/node/list');
1275
+ return data;
1276
+ });
1277
+ this.getNodeStatusDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1278
+ const { data } = yield this.request.get('/v1/node', { params });
1279
+ return data;
1280
+ });
1281
+ this.postActionLog = (body) => __awaiter(this, void 0, void 0, function* () {
1282
+ const { data } = yield this.request.post('/v1/engine/action/log', body);
1283
+ return data;
1284
+ });
1285
+ this.checkSpoofing = ({ from, to, }) => __awaiter(this, void 0, void 0, function* () {
1286
+ const { data } = yield this.request.get('/v1/engine/addr/is_spoofing', {
1287
+ params: { user_addr: from, dest_addr: to },
1288
+ });
1289
+ return data;
1290
+ });
1291
+ this.getAddressByDeBankId = (name) => __awaiter(this, void 0, void 0, function* () {
1292
+ const { data } = yield this.request.get('/v1/user/web3_id', {
1293
+ params: {
1294
+ text: name,
1295
+ },
1296
+ });
1297
+ return data;
1298
+ });
1299
+ this.getBridgeSupportChain = () => __awaiter(this, void 0, void 0, function* () {
1300
+ const { data } = yield this.request.get('/v1/bridge/supported_chains');
1301
+ return data;
1302
+ });
1303
+ this.getBridgeAggregatorList = () => __awaiter(this, void 0, void 0, function* () {
1304
+ const { data } = yield this.request.get('/v1/bridge/list');
1305
+ return data;
1306
+ });
1307
+ this.getBridgePairList = (params) => __awaiter(this, void 0, void 0, function* () {
1308
+ const { data } = yield this.request.get('/v1/bridge/pair_list', {
1309
+ params: Object.assign(Object.assign({}, params), { aggregator_ids: params.aggregator_ids.join(',') }),
1310
+ });
1311
+ return data;
1312
+ });
1313
+ this.getBridgeQuoteList = (params) => __awaiter(this, void 0, void 0, function* () {
1314
+ const { data } = yield this.request.get('/v1/bridge/quote_list', {
1315
+ params,
1316
+ });
1317
+ return data;
1318
+ });
1319
+ this.getBridgeQuoteListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1320
+ const { data } = yield this.request.get('/v2/bridge/quote_list', {
1321
+ params,
1322
+ });
1323
+ return data;
1324
+ });
1325
+ this.getBridgeQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1326
+ const { data } = yield this.request.get('/v1/bridge/quote', {
1327
+ params,
1328
+ });
1329
+ return data;
1330
+ });
1331
+ this.getBridgeHistoryList = (params) => __awaiter(this, void 0, void 0, function* () {
1332
+ const { data } = yield this.request.get('/v1/bridge/history_list', {
1333
+ params,
1334
+ });
1335
+ return data;
1336
+ });
1337
+ this.buildBridgeTx = (params) => __awaiter(this, void 0, void 0, function* () {
1338
+ const { data } = yield this.request.get('/v2/bridge/build_tx', {
1339
+ params,
1340
+ });
1341
+ return data;
1342
+ });
1343
+ this.postBridgeHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1344
+ const { data } = yield this.request.post('/v1/bridge/history', params);
1345
+ return data;
1346
+ });
1347
+ /**
1348
+ * no id just no check address
1349
+ */
1350
+ this.getPerpPermission = (params) => __awaiter(this, void 0, void 0, function* () {
1351
+ const { data } = yield this.request.get('/v1/user/has_hyperliquid_permission', {
1352
+ params,
1353
+ });
1354
+ return data;
1355
+ });
1356
+ /**
1357
+ * @param params.dex_id - The ID of the DEX to get the top tokens for. If not provided, hyperliquid default DEXs will be included. if all is provided, all DEXs will be included. and xyz is xyz dex tokens
1358
+ * @returns A list of top tokens for the given DEX.
1359
+ */
1360
+ this.getPerpTopTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1361
+ const { data } = yield this.request.get('/v1/token/hyperliquid_top', {
1362
+ params,
1363
+ });
1364
+ return data;
1365
+ });
1366
+ /**
1367
+ * @param params.dex_id - The ID of the DEX to get the top tokens for. If not provided, hyperliquid default DEXs will be included. if all is provided, all DEXs will be included. and xyz is xyz dex tokens
1368
+ * @param params.lang - The translations in item.category
1369
+ * @returns A list of top tokens for the given DEX.
1370
+ */
1371
+ this.getPerpTopTokenListV3 = (params) => __awaiter(this, void 0, void 0, function* () {
1372
+ const { data } = yield this.request.get('/v1/token/hyperliquid_top_v3', {
1373
+ params,
1374
+ });
1375
+ return data;
1376
+ });
1377
+ this.getPerpTokenDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1378
+ const { data } = yield this.request.get('/v1/token/hyperliquid_token_detail_v3', {
1379
+ params,
1380
+ });
1381
+ return data;
1382
+ });
1383
+ this.getPerpTokenCategories = (params) => __awaiter(this, void 0, void 0, function* () {
1384
+ const { data } = yield this.request.get('/v1/token/hyperliquid_categories_v3', {
1385
+ params,
1386
+ });
1387
+ return data;
1388
+ });
1389
+ this.getPerpsBridgeIsSupportToken = (params) => __awaiter(this, void 0, void 0, function* () {
1390
+ const { data } = yield this.request.get('/v2/bridge/hyperliquid/support_token', {
1391
+ params,
1392
+ });
1393
+ return data;
1394
+ });
1395
+ this.getPerpBridgeQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1396
+ const { data } = yield this.request.get('/v2/bridge/hyperliquid/quote', {
1397
+ params,
1398
+ });
1399
+ return data;
1400
+ });
1401
+ this.postPerpBridgeHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1402
+ const { data } = yield this.request.post('/v2/bridge/hyperliquid', params);
1403
+ return data;
1404
+ });
1405
+ this.getSupportedDEXList = () => __awaiter(this, void 0, void 0, function* () {
1406
+ const { data } = yield this.request.get('/v1/wallet/supported_dex_list');
1407
+ return data;
1408
+ });
1409
+ this.createDbkBridgeHistory = (postData) => __awaiter(this, void 0, void 0, function* () {
1410
+ const { data } = yield this.request.post('/v1/user/dbk/bridge_history', postData);
1411
+ return data;
1412
+ });
1413
+ this.getDbkBridgeHistoryList = (params) => __awaiter(this, void 0, void 0, function* () {
1414
+ const { data } = yield this.request.get('/v1/user/dbk/bridge_history_list', {
1415
+ params,
1416
+ });
1417
+ return data;
1418
+ });
1419
+ this.getGasAccountSignText = (account_id) => __awaiter(this, void 0, void 0, function* () {
1420
+ const { data } = yield this.request.get('/v1/gas_account/sign_text', {
1421
+ params: {
1422
+ account_id,
1423
+ },
1424
+ });
1425
+ return data;
1426
+ });
1427
+ this.getGasAccountInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1428
+ const { sig } = params, others = __rest(params, ["sig"]);
1429
+ const { data } = yield this.request.get('/v1/gas_account', {
1430
+ params: Object.assign({}, others),
1431
+ headers: {
1432
+ sig,
1433
+ },
1434
+ });
1435
+ return data;
1436
+ });
1437
+ this.getGasAccountInfoV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1438
+ const { data } = yield this.request.get('/v2/gas_account', {
1439
+ params,
1440
+ });
1441
+ return data;
1442
+ });
1443
+ this.createGasAccountPayInfo = (postData) => __awaiter(this, void 0, void 0, function* () {
1444
+ const { data } = yield this.request.post('/v2/gas_account/pay_info', postData);
1445
+ return data;
1446
+ });
1447
+ this.checkGasAccountGiftEligibility = (params) => __awaiter(this, void 0, void 0, function* () {
1448
+ const { data } = yield this.request.get('/v1/gas_account/check_eligibility', {
1449
+ params,
1450
+ });
1451
+ return data;
1452
+ });
1453
+ this.checkGasAccountGiftEligibilityBatch = (params) => __awaiter(this, void 0, void 0, function* () {
1454
+ const { data } = yield this.request.post('/v1/gas_account/check_eligibility/batch', params);
1455
+ return data;
1456
+ });
1457
+ this.confirmIapOrder = (postData) => __awaiter(this, void 0, void 0, function* () {
1458
+ const { data } = yield this.request.post('/v1/gas_account/confirm_iap_order', postData);
1459
+ return data;
1460
+ });
1461
+ this.claimGasAccountGift = (params) => __awaiter(this, void 0, void 0, function* () {
1462
+ const { sig } = params, others = __rest(params, ["sig"]);
1463
+ const { data } = yield this.request.post('/v1/gas_account/claim', Object.assign({}, others), {
1464
+ headers: {
1465
+ sig,
1466
+ },
1467
+ });
1468
+ return data;
1469
+ });
1470
+ this.loginGasAccount = (params) => __awaiter(this, void 0, void 0, function* () {
1471
+ const { sig } = params, others = __rest(params, ["sig"]);
1472
+ const { data } = yield this.request.post('/v1/gas_account/login', Object.assign({}, others), {
1473
+ headers: {
1474
+ sig,
1475
+ },
1476
+ });
1477
+ return data;
1478
+ });
1479
+ this.logoutGasAccount = (params) => __awaiter(this, void 0, void 0, function* () {
1480
+ const { sig } = params, others = __rest(params, ["sig"]);
1481
+ const { data } = yield this.request.post('/v1/gas_account/logout', Object.assign({}, others), {
1482
+ headers: {
1483
+ sig,
1484
+ },
1485
+ });
1486
+ return data;
1487
+ });
1488
+ this.getGasAccountTokenList = (id) => __awaiter(this, void 0, void 0, function* () {
1489
+ const { data } = yield this.request.get('/v1/user/recharge_token_list', {
1490
+ params: {
1491
+ id,
1492
+ },
1493
+ });
1494
+ return data;
1495
+ });
1496
+ this.getGasAccountBridgeSupportTokenList = () => __awaiter(this, void 0, void 0, function* () {
1497
+ const { data } = yield this.request.get('/v1/gas_account/bridge/support_token');
1498
+ return data;
1499
+ });
1500
+ this.getGasAccountBridgeQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1501
+ const { data } = yield this.request.get('/v1/gas_account/bridge/quote', {
1502
+ params,
1503
+ });
1504
+ return data;
1505
+ });
1506
+ this.createGasAccountBridgeRecharge = (p) => __awaiter(this, void 0, void 0, function* () {
1507
+ const { sig } = p, params = __rest(p, ["sig"]);
1508
+ const { data } = yield this.request.post('/v1/gas_account/bridge/create', params, {
1509
+ headers: {
1510
+ sig,
1511
+ },
1512
+ });
1513
+ return data;
1514
+ });
1515
+ this.getGasAccountBridgeStatus = (params) => __awaiter(this, void 0, void 0, function* () {
1516
+ const { data } = yield this.request.post('/v1/gas_account/recharge/status', params);
1517
+ return data;
1518
+ });
1519
+ this.rechargeGasAccount = (p) => __awaiter(this, void 0, void 0, function* () {
1520
+ const { sig } = p, params = __rest(p, ["sig"]);
1521
+ const { data } = yield this.request.post('/v1/gas_account/recharge', params, {
1522
+ headers: {
1523
+ sig,
1524
+ },
1525
+ });
1526
+ return data;
1527
+ });
1528
+ this.withdrawGasAccount = (p) => __awaiter(this, void 0, void 0, function* () {
1529
+ const { sig } = p, params = __rest(p, ["sig"]);
1530
+ const { data } = yield this.request.post('/v1/gas_account/withdraw', params, {
1531
+ headers: {
1532
+ sig,
1533
+ },
1534
+ });
1535
+ return data;
1536
+ });
1537
+ this.getWithdrawList = (p) => __awaiter(this, void 0, void 0, function* () {
1538
+ const { sig } = p, params = __rest(p, ["sig"]);
1539
+ const { data } = yield this.request.get('/v1/gas_account/withdraw_list', {
1540
+ params,
1541
+ headers: {
1542
+ sig,
1543
+ },
1544
+ });
1545
+ return data;
1546
+ });
1547
+ this.getGasAccountHistory = (p) => __awaiter(this, void 0, void 0, function* () {
1548
+ const { sig } = p, params = __rest(p, ["sig"]);
1549
+ const { data } = yield this.request.get('/v1/gas_account/history', {
1550
+ params,
1551
+ headers: {
1552
+ sig,
1553
+ },
1554
+ });
1555
+ return data;
1556
+ });
1557
+ this.checkGasAccountTxs = (p) => __awaiter(this, void 0, void 0, function* () {
1558
+ const { sig } = p, params = __rest(p, ["sig"]);
1559
+ const { data } = yield this.request.post('/v1/gas_account/check_txs', params, {
1560
+ headers: sig
1561
+ ? {
1562
+ sig,
1563
+ }
1564
+ : undefined,
1565
+ });
1566
+ return data;
1567
+ });
1568
+ this.getGasAccountAml = (id) => __awaiter(this, void 0, void 0, function* () {
1569
+ const { data } = yield this.request.get('/v1/gas_account/aml', {
1570
+ params: {
1571
+ id,
1572
+ },
1573
+ });
1574
+ return data;
1575
+ });
1576
+ this.parseCommon = (params) => __awaiter(this, void 0, void 0, function* () {
1577
+ const { data } = yield this.request.post('/v1/engine/action/parse_common', params);
1578
+ return data;
1579
+ });
1580
+ this.getRecommendBridgeToChain = (params) => __awaiter(this, void 0, void 0, function* () {
1581
+ const { data } = yield this.request.get('/v2/bridge/recommend/to_chain', {
1582
+ params,
1583
+ });
1584
+ return data;
1585
+ });
1586
+ this.getRecommendFromToken = (params) => __awaiter(this, void 0, void 0, function* () {
1587
+ const { data } = yield this.request.get('/v2/bridge/recommend/from_token_list', {
1588
+ params,
1589
+ });
1590
+ return data;
1591
+ });
1592
+ this.getBridgeToTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1593
+ const { data } = yield this.request.get('/v2/bridge/recommend/to_token_list', {
1594
+ params,
1595
+ });
1596
+ return data;
1597
+ });
1598
+ this.getBridgeQuoteV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1599
+ const { data } = yield this.request.get('/v2/bridge/quote_list', {
1600
+ params,
1601
+ });
1602
+ return data;
1603
+ });
1604
+ this.getBridgeQuoteTxV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1605
+ const { data } = yield this.request.get('/v2/bridge/quote', {
1606
+ params,
1607
+ });
1608
+ return data;
1609
+ });
1610
+ this.isSameBridgeToken = (params) => __awaiter(this, void 0, void 0, function* () {
1611
+ const { data } = yield this.request.get('/v2/bridge/same_token', {
1612
+ params,
1613
+ });
1614
+ return data;
1615
+ });
1616
+ this.getBridgeSupportChainV2 = () => __awaiter(this, void 0, void 0, function* () {
1617
+ const { data } = yield this.request.get('/v2/bridge/supported_chains');
1618
+ return data;
1619
+ });
1620
+ this.submitFeedback = ({ text, usage, }) => __awaiter(this, void 0, void 0, function* () {
1621
+ const { data } = yield this.request.post('v1/feedback', Object.assign({ text }, (usage && { usage })));
1622
+ return data;
1623
+ });
1624
+ this.uninstalledFeedback = ({ text, }) => __awaiter(this, void 0, void 0, function* () {
1625
+ return this.submitFeedback({
1626
+ text,
1627
+ });
1628
+ });
1629
+ /**
1630
+ * @deprecated
1631
+ */
1632
+ this.getToken24hPrice = (params) => __awaiter(this, void 0, void 0, function* () {
1633
+ const { data } = yield this.request.get('/v1/token/24h_price', {
1634
+ params,
1635
+ });
1636
+ return data;
1637
+ });
1638
+ this.getTokenPriceCurve = (params) => __awaiter(this, void 0, void 0, function* () {
1639
+ const { data } = yield this.request.get('/v1/token/price_curve', {
1640
+ params,
1641
+ });
1642
+ return data;
1643
+ });
1644
+ this.getTokenDatePrice = (params) => __awaiter(this, void 0, void 0, function* () {
1645
+ const { data } = yield this.request.get('/v1/token/date_price', {
1646
+ params,
1647
+ });
1648
+ return data;
1649
+ });
1650
+ this.searchTokens = (params) => __awaiter(this, void 0, void 0, function* () {
1651
+ const { data } = yield this.request.get('/v1/token/search', {
1652
+ params,
1653
+ });
1654
+ return data;
1655
+ });
1656
+ this.searchTokensV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1657
+ const { data } = yield this.request.get('/v2/token/search', {
1658
+ params,
1659
+ });
1660
+ return data;
1661
+ });
1662
+ // resp arr of chain_id
1663
+ this.getCopyTradingChainList = () => __awaiter(this, void 0, void 0, function* () {
1664
+ const { data } = yield this.request.get('/v1/copytrading/chain_list');
1665
+ return data;
1666
+ });
1667
+ this.getCopyTradingTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1668
+ const { data } = yield this.request.get('/v1/copytrading/token/list', {
1669
+ params,
1670
+ });
1671
+ return data;
1672
+ });
1673
+ this.getCopyTradingTokenListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1674
+ const { data } = yield this.request.get('/v2/copytrading/token/list', {
1675
+ params,
1676
+ });
1677
+ return data;
1678
+ });
1679
+ this.getCopyTradingRecentBuyList = (params) => __awaiter(this, void 0, void 0, function* () {
1680
+ const { data } = yield this.request.get('/v1/copytrading/recent_buy/list', {
1681
+ params,
1682
+ });
1683
+ return data;
1684
+ });
1685
+ this.getCopyTradingRecentBuyListV2 = (params) => __awaiter(this, void 0, void 0, function* () {
1686
+ const { data } = yield this.request.get('/v2/copytrading/recent_buy/list', {
1687
+ params,
1688
+ });
1689
+ return data;
1690
+ });
1691
+ this.getCopyTradingDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1692
+ const { data } = yield this.request.get('/v2/copytrading/token/detail', {
1693
+ params,
1694
+ });
1695
+ return data;
1696
+ });
1697
+ this.getCopyTradingSameName = (params) => __awaiter(this, void 0, void 0, function* () {
1698
+ const { data } = yield this.request.get('/v1/token/same_name', {
1699
+ params,
1700
+ });
1701
+ return data;
1702
+ });
1703
+ this.getCopyTradingPnlList = (params) => __awaiter(this, void 0, void 0, function* () {
1704
+ const { data } = yield this.request.get('/v1/copytrading/smart_money/pnl/list', {
1705
+ params,
1706
+ });
1707
+ return data;
1708
+ });
1709
+ this.batchQueryTokens = (uuids) => __awaiter(this, void 0, void 0, function* () {
1710
+ const { data } = yield this.request.get('/v1/token/list_by_uuids', {
1711
+ params: {
1712
+ uuids: Array.isArray(uuids) ? uuids.join(',') : uuids,
1713
+ },
1714
+ });
1715
+ return data;
1716
+ });
1717
+ this.getBuySupportedCountryList = () => __awaiter(this, void 0, void 0, function* () {
1718
+ const { data } = yield this.request.get('/v1/buy/supported_country_list');
1719
+ return data;
1720
+ });
1721
+ this.getBuySupportedTokenList = () => __awaiter(this, void 0, void 0, function* () {
1722
+ const { data } = yield this.request.get('/v1/buy/supported_token_list');
1723
+ return data;
1724
+ });
1725
+ this.getBuyQuote = (params) => __awaiter(this, void 0, void 0, function* () {
1726
+ const { data } = yield this.request.get('/v1/buy/quote', {
1727
+ params,
1728
+ });
1729
+ return data;
1730
+ });
1731
+ this.getBuyWidgetUrl = (params) => __awaiter(this, void 0, void 0, function* () {
1732
+ const { data } = yield this.request.get('/v1/buy/get_widget_url', { params });
1733
+ return data;
1734
+ });
1735
+ this.getBuyHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1736
+ const { data } = yield this.request.get('/v1/buy/history', {
1737
+ params: Object.assign(Object.assign({}, params), { start: params.start || 0, limit: params.limit || 20 }),
1738
+ });
1739
+ return data;
1740
+ });
1741
+ this.getBuyPaymentMethods = (params) => __awaiter(this, void 0, void 0, function* () {
1742
+ const { data } = yield this.request.get('/v1/buy/get_payment_method', {
1743
+ params,
1744
+ });
1745
+ return data;
1746
+ });
1747
+ this.getBuyCurrencyList = () => __awaiter(this, void 0, void 0, function* () {
1748
+ const { data } = yield this.request.get('/v1/buy/supported_currency_list');
1749
+ return data;
1750
+ });
1751
+ this.getOfflineChainList = () => __awaiter(this, void 0, void 0, function* () {
1752
+ const { data } = yield this.request.get('/v1/chain/offline_list');
1753
+ return data;
1754
+ });
1755
+ this.isBlockedAddress = (id) => __awaiter(this, void 0, void 0, function* () {
1756
+ const { data } = yield this.request.get('/v1/engine/addr/is_blocked', {
1757
+ params: { id },
1758
+ });
1759
+ return data;
1760
+ });
1761
+ this.estimateGasUsd = ({ tx, origin, address, updateNonce = false, pending_tx_list = [], }) => __awaiter(this, void 0, void 0, function* () {
1762
+ const { data } = yield this.request.post('/v1/wallet/estimate_gas', {
1763
+ tx,
1764
+ user_addr: address,
1765
+ origin,
1766
+ update_nonce: updateNonce,
1767
+ pending_tx_list,
1768
+ });
1769
+ return data;
1770
+ });
1771
+ this.getCexSupportList = () => __awaiter(this, void 0, void 0, function* () {
1772
+ const { data } = yield this.request.get('/v1/cex/supported_list');
1773
+ return data;
1774
+ });
1775
+ this.getAppChainList = (id) => __awaiter(this, void 0, void 0, function* () {
1776
+ const { data } = yield this.request.get('/v1/user/complex_app_list', {
1777
+ params: { id },
1778
+ });
1779
+ return data;
1780
+ });
1781
+ this.checkCex = (postData) => __awaiter(this, void 0, void 0, function* () {
1782
+ const { data } = yield this.request.post('/v1/token/check_cex', postData);
1783
+ return data;
1784
+ });
1785
+ // top 20 tokens
1786
+ this.getHotTokenList = () => __awaiter(this, void 0, void 0, function* () {
1787
+ const { data } = yield this.request.get('/v1/token/hot_list');
1788
+ return data;
1789
+ });
1790
+ // uuid: 'chain:token_id'
1791
+ this.getTokensDetailByUuids = (uuids) => __awaiter(this, void 0, void 0, function* () {
1792
+ const { data } = yield this.request.get('/v1/token/list_by_uuids', {
1793
+ params: {
1794
+ uuids: uuids.join(','),
1795
+ },
1796
+ });
1797
+ return data;
1798
+ });
1799
+ this.getTokenKlineData = (params) => __awaiter(this, void 0, void 0, function* () {
1800
+ const { data } = yield this.request.get('/v1/token/market/kline', {
1801
+ params,
1802
+ });
1803
+ return data;
1804
+ });
1805
+ this.getTokenMarketInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1806
+ const { data } = yield this.request.get('/v1/token/market/info', {
1807
+ params,
1808
+ });
1809
+ return data;
1810
+ });
1811
+ this.getTokenHolderInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1812
+ const { data } = yield this.request.get('/v1/token/market/info/holders', {
1813
+ params,
1814
+ });
1815
+ return data;
1816
+ });
1817
+ this.getTokenSupplyInfo = (params) => __awaiter(this, void 0, void 0, function* () {
1818
+ const { data } = yield this.request.get('/v1/token/market/info/supply', {
1819
+ params,
1820
+ });
1821
+ return data;
1822
+ });
1823
+ this.postUserFeedback = (data) => __awaiter(this, void 0, void 0, function* () {
1824
+ const { data: response } = yield this.request.post('/v1/feedback/app', data);
1825
+ return response;
1826
+ });
1827
+ this.getUserFeedback = (id) => __awaiter(this, void 0, void 0, function* () {
1828
+ const { data } = yield this.request.get('/v1/feedback/app', {
1829
+ params: { id },
1830
+ });
1831
+ return data;
1832
+ });
1833
+ this.getUserFeedbackList = (id) => __awaiter(this, void 0, void 0, function* () {
1834
+ const ids = Array.isArray(id) ? id : [id];
1835
+ const { data } = yield this.request.post('/v1/feedback/app/list', {
1836
+ ids,
1837
+ });
1838
+ return data;
1839
+ });
1840
+ this.getCurrencyList = () => __awaiter(this, void 0, void 0, function* () {
1841
+ const { data } = yield this.request.get('/v1/currency/exchange_list');
1842
+ return data;
1843
+ });
1844
+ this.getMarketSummary = ({ token_id, chain_id, }) => __awaiter(this, void 0, void 0, function* () {
1845
+ const { data } = yield this.request.get('/v1/token/market/summary', {
1846
+ params: {
1847
+ token_id,
1848
+ chain_id,
1849
+ },
1850
+ });
1851
+ return data;
1852
+ });
1853
+ this.getMarketTradingHistory = (params) => __awaiter(this, void 0, void 0, function* () {
1854
+ const { data } = yield this.request.get('/v1/token/market/trading_history/list', {
1855
+ params,
1856
+ });
1857
+ return data;
1858
+ });
1859
+ this.getTokenHolderSummary = (params) => __awaiter(this, void 0, void 0, function* () {
1860
+ const { data } = yield this.request.get('/v1/token/market/holders/summary', {
1861
+ params,
1862
+ });
1863
+ return data;
1864
+ });
1865
+ // top 10 holders
1866
+ this.getTokenHolderList = (params) => __awaiter(this, void 0, void 0, function* () {
1867
+ const { data } = yield this.request.get('/v1/token/market/holders/list', {
1868
+ params,
1869
+ });
1870
+ return data;
1871
+ });
1872
+ // top 5
1873
+ this.getLiquidityPoolList = (params) => __awaiter(this, void 0, void 0, function* () {
1874
+ const { data } = yield this.request.get('/v1/token/market/liquidity_pool/list', {
1875
+ params,
1876
+ });
1877
+ return data;
1878
+ });
1879
+ this.getLiquidityPoolHistoryList = (params) => __awaiter(this, void 0, void 0, function* () {
1880
+ const { data } = yield this.request.get('/v1/token/market/liquidity_pool/history/list', {
1881
+ params,
1882
+ });
1883
+ return data;
1884
+ });
1885
+ this.getTokenMarketCategoryList = () => __awaiter(this, void 0, void 0, function* () {
1886
+ const { data } = yield this.request.get('/v1/token/market/category_list');
1887
+ return data;
1888
+ });
1889
+ this.getNFTTradingConfig = () => __awaiter(this, void 0, void 0, function* () {
1890
+ const { data } = yield this.request.get('/v1/nft/trading_config');
1891
+ return data;
1892
+ });
1893
+ this.getNFTDetail = (params) => __awaiter(this, void 0, void 0, function* () {
1894
+ const { data } = yield this.request.get('/v1/nft', {
1895
+ params,
1896
+ });
1897
+ return data;
1898
+ });
1899
+ this.getNFTListingOrders = (params) => __awaiter(this, void 0, void 0, function* () {
1900
+ const { data } = yield this.request.get('/v1/nft/order/listing', {
1901
+ params,
1902
+ });
1903
+ return data;
1904
+ });
1905
+ this.getNFTFees = (params) => __awaiter(this, void 0, void 0, function* () {
1906
+ const { data } = yield this.request.get('/v1/nft/fee', {
1907
+ params,
1908
+ });
1909
+ return data;
1910
+ });
1911
+ this.prepareListingNFT = (postData) => __awaiter(this, void 0, void 0, function* () {
1912
+ const { data } = yield this.request.post('/v1/nft/order/listing/prepare', postData);
1913
+ return data;
1914
+ });
1915
+ this.createListingNFT = (postData) => __awaiter(this, void 0, void 0, function* () {
1916
+ const { data } = yield this.request.post('/v1/nft/order/listing/post', postData);
1917
+ return data;
1918
+ });
1919
+ this.prepareAcceptNFTOffer = (postData) => __awaiter(this, void 0, void 0, function* () {
1920
+ const { data } = yield this.request.post('/v1/nft/order/offer/accept/prepare', postData);
1921
+ return data;
1922
+ });
1923
+ this.submitAcceptNFTOfferTx = (postData) => __awaiter(this, void 0, void 0, function* () {
1924
+ const { data } = yield this.request.post('/v1/nft/order/offer/accept/tx', postData);
1925
+ return data;
1926
+ });
1927
+ this.checkTokenDepositForbidden = (params) => __awaiter(this, void 0, void 0, function* () {
1928
+ const { data } = yield this.request.get('/v1/engine/token/deposit_forbidden', {
1929
+ params,
1930
+ });
1931
+ return data;
1932
+ });
1933
+ this.getPolyMarketPermission = (params) => __awaiter(this, void 0, void 0, function* () {
1934
+ const { data } = yield this.request.get('v1/user/has_polymarket_permission', {
1935
+ params,
1936
+ });
1937
+ return data;
1938
+ });
1939
+ this.getDappPermission = (params) => __awaiter(this, void 0, void 0, function* () {
1940
+ const { data } = yield this.request.get('v1/user/has_dapp_permission', {
1941
+ params,
1942
+ });
1943
+ return data;
1944
+ });
1945
+ this.getMemeList = (params) => __awaiter(this, void 0, void 0, function* () {
1946
+ const { data } = yield this.request.get('/v1/token/meme_list', {
1947
+ params,
1948
+ });
1949
+ return data;
1950
+ });
1951
+ this.getTokenMarketTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
1952
+ const { data } = yield this.request.get('/v1/token/market/token_list', {
1953
+ params,
1954
+ });
1955
+ return data;
1956
+ });
1957
+ if (store instanceof Promise) {
1958
+ store.then((resolvedStore) => {
1959
+ this.store = resolvedStore;
1960
+ });
1961
+ }
1962
+ else {
1963
+ this.store = store;
1964
+ }
1965
+ __classPrivateFieldSet(this, _OpenApiService_plugin, plugin, "f");
1966
+ __classPrivateFieldSet(this, _OpenApiService_adapter, adapter, "f");
1967
+ __classPrivateFieldSet(this, _OpenApiService_clientName, clientName, "f");
1968
+ __classPrivateFieldSet(this, _OpenApiService_clientVersion, clientVersion, "f");
1969
+ }
1970
+ initSync(options) {
1971
+ var _a, _b;
1972
+ (_b = (_a = __classPrivateFieldGet(this, _OpenApiService_plugin, "f")).onInitiate) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign({}, options));
1973
+ const headers = {
1974
+ 'X-Client': __classPrivateFieldGet(this, _OpenApiService_clientName, "f"),
1975
+ 'X-Version': __classPrivateFieldGet(this, _OpenApiService_clientVersion, "f"),
1976
+ };
1977
+ if (this.store.apiKey && this.store.apiTime) {
1978
+ headers['X-API-Key'] = this.store.apiKey;
1979
+ headers['X-API-Time'] = this.store.apiTime;
1980
+ }
1981
+ const request = axios.create({
1982
+ baseURL: this.store.host,
1983
+ adapter: __classPrivateFieldGet(this, _OpenApiService_adapter, "f"),
1984
+ headers,
1985
+ });
1986
+ // sign after rateLimit, timestamp is the latest
1987
+ request.interceptors.request.use((config) => __awaiter(this, void 0, void 0, function* () {
1988
+ const { method, url, params } = genSignParams(config);
1989
+ yield __classPrivateFieldGet(this, _OpenApiService_plugin, "f").onSignRequest({
1990
+ axiosRequestConfig: config,
1991
+ parsed: { method, url, params },
1992
+ });
1993
+ return config;
1994
+ }));
1995
+ this.request = rateLimit(request, { maxRPS });
1996
+ this.request.interceptors.response.use((response) => {
1997
+ var _a, _b, _c, _d, _e;
1998
+ const newAPIKey = (_a = response.headers) === null || _a === void 0 ? void 0 : _a['x-set-api-key'];
1999
+ if (newAPIKey) {
2000
+ this.setAPIKey(newAPIKey);
2001
+ }
2002
+ const code = ((_b = response.data) === null || _b === void 0 ? void 0 : _b.err_code) || ((_c = response.data) === null || _c === void 0 ? void 0 : _c.error_code);
2003
+ const msg = ((_d = response.data) === null || _d === void 0 ? void 0 : _d.err_msg) || ((_e = response.data) === null || _e === void 0 ? void 0 : _e.error_msg);
2004
+ if (code && code !== 200) {
2005
+ if (msg) {
2006
+ let err;
2007
+ try {
2008
+ err = new Error(JSON.parse(msg));
2009
+ }
2010
+ catch (e) {
2011
+ err = new Error(msg);
2012
+ }
2013
+ throw err;
2014
+ }
2015
+ throw new Error(typeof response.data === 'string'
2016
+ ? response.data
2017
+ : JSON.stringify(response.data));
2018
+ }
2019
+ return response;
2020
+ });
2021
+ this._mountMethods();
2022
+ }
2023
+ }
2024
+ _OpenApiService_adapter = new WeakMap(), _OpenApiService_plugin = new WeakMap(), _OpenApiService_clientName = new WeakMap(), _OpenApiService_clientVersion = new WeakMap();