@rabby-wallet/rabby-api 0.7.9 → 0.7.11

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.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { AxiosAdapter, AxiosRequestConfig } from 'axios';
2
2
  import { RateLimitedAxiosInstance } from 'axios-rate-limit';
3
- import { AddrDescResponse, ApprovalStatus, AssetItem, BasicDappInfo, CEXQuote, Cex, ChainWithPendingCount, Collection, CollectionList, CollectionWithFloorPrice, ComplexProtocol, ContractCredit, ExplainTxResponse, ExplainTypedDataResponse, GasLevel, GetTxResponse, HistoryCurve, LatestExplainTxResponse, MempoolCheckDetail, NFTApprovalResponse, NFTItem, ParseTextResponse, ParseTxResponse, ParseTypedDataResponse, PendingTxItem, Protocol, SecurityCheckResponse, ServerChain, SlippageStatus, Summary, SupportedChain, SwapTradeList, TokenApproval, TokenItem, TotalBalanceResponse, Tx, TxAllHistoryResult, TxHistoryResult, TxPushType, TxRequest, UsedChain } from './types';
4
3
  import { InitOptions, RabbyApiPlugin } from './plugins/intf';
4
+ import { AddrDescResponse, ApprovalStatus, AssetItem, BasicDappInfo, CEXQuote, Cex, ChainListItem, ChainWithPendingCount, Collection, CollectionList, CollectionWithFloorPrice, ComplexProtocol, ContractCredit, ExplainTxResponse, ExplainTypedDataResponse, GasLevel, GetTxResponse, HistoryCurve, LatestExplainTxResponse, MempoolCheckDetail, NFTApprovalResponse, NFTItem, ParseTextResponse, ParseTxResponse, ParseTypedDataResponse, PendingTxItem, Protocol, SecurityCheckResponse, ServerChain, SlippageStatus, Summary, SupportedChain, SwapTradeList, TokenApproval, TokenItem, TotalBalanceResponse, Tx, TxAllHistoryResult, TxHistoryResult, TxPushType, TxRequest, UsedChain } from './types';
5
5
  interface OpenApiStore {
6
6
  host: string;
7
7
  testnetHost?: string;
@@ -33,7 +33,6 @@ export declare class OpenApiService {
33
33
  asyncJob: <T = any>(url: string, options?: AxiosRequestConfig & {
34
34
  retryDelay?: number;
35
35
  }) => Promise<T>;
36
- private _getRequestOptions;
37
36
  private _mountMethods;
38
37
  getRecommendChains: (address: string, origin: string) => Promise<ServerChain[]>;
39
38
  getTotalBalance: (address: string) => Promise<TotalBalanceResponse>;
@@ -80,7 +79,6 @@ export declare class OpenApiService {
80
79
  timeAt?: number;
81
80
  dateAt?: string;
82
81
  }) => Promise<TokenItem[]>;
83
- _customListToken: (uuids: string[], id: string, isTestnet?: boolean) => Promise<TokenItem[]>;
84
82
  customListToken: (uuids: string[], id: string) => Promise<TokenItem[]>;
85
83
  listChainAssets: (id: string) => Promise<AssetItem[]>;
86
84
  listNFT: (id: string, isAll?: boolean) => Promise<NFTItem[]>;
@@ -512,6 +510,21 @@ export declare class OpenApiService {
512
510
  error_code: number;
513
511
  }>;
514
512
  getSupportedChains: () => Promise<SupportedChain[]>;
513
+ searchChainList: (params?: {
514
+ limit?: number;
515
+ start?: number;
516
+ q?: string;
517
+ }) => Promise<{
518
+ page: {
519
+ start: number;
520
+ limit: number;
521
+ total: number;
522
+ };
523
+ chain_list: ChainListItem[];
524
+ }>;
525
+ getChainListByIds: (params: {
526
+ ids: string;
527
+ }) => Promise<ChainListItem[]>;
515
528
  getHistoryCurve: (addr: string) => Promise<HistoryCurve>;
516
529
  getHistoryCurveSupportedList: () => Promise<{
517
530
  supported_chains: string[];
package/dist/index.js CHANGED
@@ -22,9 +22,9 @@ var _OpenApiService_adapter, _OpenApiService_plugin, _OpenApiService_clientName,
22
22
  import axios from 'axios';
23
23
  import rateLimit from 'axios-rate-limit';
24
24
  import { ethErrors } from 'eth-rpc-errors';
25
- import { CHAINS, genSignParams, getChain, getChainByNetwork, sleep, } from './utils';
26
- import { ASYNC_JOB_RETRY_DELAY, ASYNC_JOB_TIMEOUT } from './const';
25
+ import { genSignParams, sleep } from './utils';
27
26
  import { omit } from 'lodash';
27
+ import { ASYNC_JOB_RETRY_DELAY, ASYNC_JOB_TIMEOUT } from './const';
28
28
  const maxRPS = 500;
29
29
  export class OpenApiService {
30
30
  constructor(_a) {
@@ -73,22 +73,6 @@ export class OpenApiService {
73
73
  return sleep(_option.retryDelay, _option.signal).then(() => this.asyncJob(url, _option));
74
74
  });
75
75
  };
76
- this._getRequestOptions = (chainId) => {
77
- if (!chainId) {
78
- return;
79
- }
80
- const testnetHost = this.getTestnetHost();
81
- if (!testnetHost) {
82
- return;
83
- }
84
- const chain = getChain(chainId);
85
- if (!(chain === null || chain === void 0 ? void 0 : chain.isTestnet)) {
86
- return;
87
- }
88
- return {
89
- baseURL: testnetHost,
90
- };
91
- };
92
76
  this._mountMethods = () => {
93
77
  this.ethRpc = (chain_id, { origin = 'rabby', method, params }) => {
94
78
  return this.request
@@ -96,7 +80,7 @@ export class OpenApiService {
96
80
  chain_id,
97
81
  method,
98
82
  params,
99
- }, this._getRequestOptions(chain_id))
83
+ })
100
84
  .then(({ data }) => {
101
85
  if (data === null || data === void 0 ? void 0 : data.error) {
102
86
  throw data.error;
@@ -120,7 +104,7 @@ export class OpenApiService {
120
104
  id: address,
121
105
  },
122
106
  });
123
- return Object.assign(Object.assign({}, data), { chain_list: data.chain_list.filter((item) => !!Object.values(CHAINS).find((chain) => chain.serverId === item.id)) });
107
+ return data;
124
108
  });
125
109
  this.getPendingCount = (address) => __awaiter(this, void 0, void 0, function* () {
126
110
  const { data } = yield this.request.get('/v1/wallet/pending_tx_count', {
@@ -146,39 +130,35 @@ export class OpenApiService {
146
130
  return data;
147
131
  });
148
132
  this.checkTx = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
149
- var _e;
150
133
  const { data } = yield this.request.post('/v1/wallet/check_tx', {
151
134
  user_addr: address,
152
135
  origin,
153
136
  tx,
154
137
  update_nonce,
155
- }, this._getRequestOptions((_e = getChainByNetwork(tx.chainId)) === null || _e === void 0 ? void 0 : _e.serverId));
138
+ });
156
139
  return data;
157
140
  });
158
141
  this.preExecTx = ({ tx, origin, address, updateNonce = false, pending_tx_list = [], }) => __awaiter(this, void 0, void 0, function* () {
159
- var _f;
160
142
  const { data } = yield this.request.post('/v1/wallet/pre_exec_tx', {
161
143
  tx,
162
144
  user_addr: address,
163
145
  origin,
164
146
  update_nonce: updateNonce,
165
147
  pending_tx_list,
166
- }, this._getRequestOptions((_f = getChainByNetwork(tx.chainId)) === null || _f === void 0 ? void 0 : _f.serverId));
148
+ });
167
149
  return data;
168
150
  });
169
151
  this.historyGasUsed = (params) => __awaiter(this, void 0, void 0, function* () {
170
- var _g, _h;
171
- const { data } = yield this.request.post('/v1/wallet/history_tx_used_gas', Object.assign({}, params), this._getRequestOptions((_h = getChainByNetwork((_g = params === null || params === void 0 ? void 0 : params.tx) === null || _g === void 0 ? void 0 : _g.chainId)) === null || _h === void 0 ? void 0 : _h.serverId));
152
+ const { data } = yield this.request.post('/v1/wallet/history_tx_used_gas', Object.assign({}, params));
172
153
  return data;
173
154
  });
174
155
  this.pendingTxList = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
175
- var _j;
176
156
  const { data } = yield this.request.post('/v1/wallet/pending_tx_list', {
177
157
  tx,
178
158
  user_addr: address,
179
159
  origin,
180
160
  update_nonce,
181
- }, this._getRequestOptions((_j = getChainByNetwork(tx.chainId)) === null || _j === void 0 ? void 0 : _j.serverId));
161
+ });
182
162
  return data;
183
163
  });
184
164
  this.traceTx = (txId, traceId, chainId) => __awaiter(this, void 0, void 0, function* () {
@@ -186,15 +166,14 @@ export class OpenApiService {
186
166
  tx_id: txId,
187
167
  trace_id: traceId,
188
168
  chain_id: chainId,
189
- }, this._getRequestOptions(chainId));
169
+ });
190
170
  return data;
191
171
  });
192
172
  this.pushTx = (tx, traceId) => __awaiter(this, void 0, void 0, function* () {
193
- var _k;
194
173
  const { data } = yield this.request.post('/v1/wallet/push_tx', {
195
174
  tx,
196
175
  trace_id: traceId,
197
- }, this._getRequestOptions((_k = getChainByNetwork(tx.chainId)) === null || _k === void 0 ? void 0 : _k.serverId));
176
+ });
198
177
  return data;
199
178
  });
200
179
  this.explainText = (origin, address, text) => __awaiter(this, void 0, void 0, function* () {
@@ -206,18 +185,22 @@ export class OpenApiService {
206
185
  return data;
207
186
  });
208
187
  this.gasMarket = (chainId, customGas) => __awaiter(this, void 0, void 0, function* () {
209
- const { data } = yield this.request.get('/v1/wallet/gas_market', Object.assign({ params: {
188
+ const { data } = yield this.request.get('/v1/wallet/gas_market', {
189
+ params: {
210
190
  chain_id: chainId,
211
191
  custom_price: customGas,
212
- } }, this._getRequestOptions(chainId)));
192
+ },
193
+ });
213
194
  return data;
214
195
  });
215
196
  this.getTx = (chainId, hash, gasPrice) => __awaiter(this, void 0, void 0, function* () {
216
- const { data } = yield this.request.get('/v1/wallet/get_tx', Object.assign({ params: {
197
+ const { data } = yield this.request.get('/v1/wallet/get_tx', {
198
+ params: {
217
199
  chain_id: chainId,
218
200
  gas_price: gasPrice,
219
201
  tx_id: hash,
220
- } }, this._getRequestOptions(chainId)));
202
+ },
203
+ });
221
204
  return data;
222
205
  });
223
206
  this.getEnsAddressByName = (name) => __awaiter(this, void 0, void 0, function* () {
@@ -229,30 +212,36 @@ export class OpenApiService {
229
212
  return data;
230
213
  });
231
214
  this.searchToken = (id, q, chainId, is_all = false) => __awaiter(this, void 0, void 0, function* () {
232
- const { data } = yield this.request.get('/v1/user/token_search', Object.assign({ params: {
215
+ const { data } = yield this.request.get('/v1/user/token_search', {
216
+ params: {
233
217
  id,
234
218
  q,
235
219
  has_balance: false,
236
220
  is_all,
237
221
  chain_id: chainId,
238
- } }, this._getRequestOptions(chainId)));
239
- return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
222
+ },
223
+ });
224
+ return data;
240
225
  });
241
226
  this.searchSwapToken = (id, chainId, q, is_all = false) => __awaiter(this, void 0, void 0, function* () {
242
- const { data } = yield this.request.get('/v1/user/token_search', Object.assign({ params: {
227
+ const { data } = yield this.request.get('/v1/user/token_search', {
228
+ params: {
243
229
  id,
244
230
  chain_id: chainId,
245
231
  q,
246
232
  is_all,
247
- } }, this._getRequestOptions(chainId)));
233
+ },
234
+ });
248
235
  return data;
249
236
  });
250
237
  this.getToken = (id, chainId, tokenId) => __awaiter(this, void 0, void 0, function* () {
251
- const { data } = yield this.request.get('/v1/user/token', Object.assign({ params: {
238
+ const { data } = yield this.request.get('/v1/user/token', {
239
+ params: {
252
240
  id,
253
241
  chain_id: chainId,
254
242
  token_id: tokenId,
255
- } }, this._getRequestOptions(chainId)));
243
+ },
244
+ });
256
245
  return data;
257
246
  });
258
247
  this.getCachedTokenList = (id) => __awaiter(this, void 0, void 0, function* () {
@@ -264,52 +253,35 @@ export class OpenApiService {
264
253
  return data;
265
254
  });
266
255
  this.listToken = (id, chainId, isAll = false) => __awaiter(this, void 0, void 0, function* () {
267
- const { data } = yield this.request.get('/v1/user/token_list', Object.assign({ params: {
256
+ const { data } = yield this.request.get('/v1/user/token_list', {
257
+ params: {
268
258
  id,
269
259
  is_all: isAll,
270
260
  chain_id: chainId,
271
- } }, this._getRequestOptions(chainId)));
272
- return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
261
+ },
262
+ });
263
+ return data;
273
264
  });
274
265
  this.getHistoryTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
275
- const { data } = yield this.request.get('/v1/user/history_token_list', Object.assign({ params: {
266
+ const { data } = yield this.request.get('/v1/user/history_token_list', {
267
+ params: {
276
268
  id: params.id,
277
269
  chain_id: params.chainId,
278
270
  time_at: params.timeAt,
279
271
  date_at: params.dateAt,
280
- } }, this._getRequestOptions(params.chainId)));
281
- return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
272
+ },
273
+ });
274
+ return data;
282
275
  });
283
- this._customListToken = (uuids, id, isTestnet = false) => __awaiter(this, void 0, void 0, function* () {
276
+ this.customListToken = (uuids, id) => __awaiter(this, void 0, void 0, function* () {
284
277
  if (!(uuids === null || uuids === void 0 ? void 0 : uuids.length) || !id) {
285
278
  return [];
286
279
  }
287
280
  const { data } = yield this.request.post('/v1/user/specific_token_list', {
288
281
  id,
289
282
  uuids,
290
- }, isTestnet && this.store.testnetHost
291
- ? { baseURL: this.store.testnetHost }
292
- : undefined);
293
- return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
294
- });
295
- this.customListToken = (uuids, id) => __awaiter(this, void 0, void 0, function* () {
296
- const mainnetIds = [];
297
- const testnetIds = [];
298
- uuids.forEach((uuid) => {
299
- const serverId = uuid.split(':')[0];
300
- const chain = getChain(serverId);
301
- if (chain === null || chain === void 0 ? void 0 : chain.isTestnet) {
302
- testnetIds.push(uuid);
303
- }
304
- else {
305
- mainnetIds.push(uuid);
306
- }
307
283
  });
308
- const res = yield Promise.all([
309
- this._customListToken(mainnetIds, id),
310
- this._customListToken(testnetIds, id, true),
311
- ]);
312
- return res.flat();
284
+ return data;
313
285
  });
314
286
  this.listChainAssets = (id) => __awaiter(this, void 0, void 0, function* () {
315
287
  const { data } = yield this.request.get('/v1/user/simple_protocol_list', {
@@ -326,7 +298,7 @@ export class OpenApiService {
326
298
  is_all: isAll,
327
299
  },
328
300
  });
329
- return data === null || data === void 0 ? void 0 : data.filter((nft) => getChain(nft.chain));
301
+ return data;
330
302
  });
331
303
  this.listCollection = (params) => __awaiter(this, void 0, void 0, function* () {
332
304
  const { data } = yield this.request.get('/v1/nft/collections', {
@@ -335,7 +307,9 @@ export class OpenApiService {
335
307
  return data;
336
308
  });
337
309
  this.listTxHisotry = (params) => __awaiter(this, void 0, void 0, function* () {
338
- const { data } = yield this.request.get('/v1/user/history_list', Object.assign({ params }, this._getRequestOptions(params.chain_id)));
310
+ const { data } = yield this.request.get('/v1/user/history_list', {
311
+ params,
312
+ });
339
313
  return data;
340
314
  });
341
315
  this.getAllTxHistory = (params, options) => __awaiter(this, void 0, void 0, function* () {
@@ -343,42 +317,53 @@ export class OpenApiService {
343
317
  return data;
344
318
  });
345
319
  this.tokenPrice = (tokenName) => __awaiter(this, void 0, void 0, function* () {
346
- var _l;
347
- const { data } = yield this.request.get('/v1/token/price_change', Object.assign({ params: {
320
+ const { data } = yield this.request.get('/v1/token/price_change', {
321
+ params: {
348
322
  token: tokenName,
349
- } }, this._getRequestOptions((_l = tokenName === null || tokenName === void 0 ? void 0 : tokenName.split(':')) === null || _l === void 0 ? void 0 : _l[0])));
323
+ },
324
+ });
350
325
  return data;
351
326
  });
352
327
  this.tokenAuthorizedList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
353
- const { data } = yield this.request.get('/v1/user/token_authorized_list', Object.assign({ params: {
328
+ const { data } = yield this.request.get('/v1/user/token_authorized_list', {
329
+ params: {
354
330
  id,
355
331
  chain_id,
356
- } }, this._getRequestOptions(chain_id)));
332
+ },
333
+ });
357
334
  return data;
358
335
  });
359
336
  this.userNFTAuthorizedList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
360
- const { data } = yield this.request.get('/v1/user/nft_authorized_list', Object.assign({ params: {
337
+ const { data } = yield this.request.get('/v1/user/nft_authorized_list', {
338
+ params: {
361
339
  id,
362
340
  chain_id,
363
- } }, this._getRequestOptions(chain_id)));
341
+ },
342
+ });
364
343
  return data;
365
344
  });
366
345
  this.getDEXList = (chain_id) => __awaiter(this, void 0, void 0, function* () {
367
- const { data } = yield this.request.get('/v1/wallet/swap_dex_list', Object.assign({ params: {
346
+ const { data } = yield this.request.get('/v1/wallet/swap_dex_list', {
347
+ params: {
368
348
  chain_id,
369
- } }, this._getRequestOptions(chain_id)));
349
+ },
350
+ });
370
351
  return data;
371
352
  });
372
353
  this.getSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
373
- const { data } = yield this.request.get('/v1/wallet/swap_quote', Object.assign({ params }, this._getRequestOptions(params === null || params === void 0 ? void 0 : params.chain_id)));
354
+ const { data } = yield this.request.get('/v1/wallet/swap_quote', {
355
+ params,
356
+ });
374
357
  return data;
375
358
  });
376
359
  this.getSwapTokenList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
377
- const { data } = yield this.request.get('/v1/wallet/swap_token_list', Object.assign({ params: {
360
+ const { data } = yield this.request.get('/v1/wallet/swap_token_list', {
361
+ params: {
378
362
  id,
379
363
  chain_id: chainId,
380
364
  is_all: false,
381
- } }, this._getRequestOptions(chainId)));
365
+ },
366
+ });
382
367
  return data;
383
368
  });
384
369
  this.postGasStationOrder = (params) => __awaiter(this, void 0, void 0, function* () {
@@ -393,14 +378,16 @@ export class OpenApiService {
393
378
  to_token_amount: params.toTokenAmount,
394
379
  from_usd_value: params.fromUsdValue,
395
380
  },
396
- }, this._getRequestOptions(params.fromChainId));
381
+ });
397
382
  return data;
398
383
  });
399
384
  this.getGasStationChainBalance = (chain_id, addr) => __awaiter(this, void 0, void 0, function* () {
400
- const { data } = yield this.request.get('/v1/wallet/gas_station_usd_value', Object.assign({ params: {
385
+ const { data } = yield this.request.get('/v1/wallet/gas_station_usd_value', {
386
+ params: {
401
387
  chain_id,
402
388
  addr,
403
- } }, this._getRequestOptions(chain_id)));
389
+ },
390
+ });
404
391
  return data;
405
392
  });
406
393
  this.getGasStationTokenList = () => __awaiter(this, void 0, void 0, function* () {
@@ -488,19 +475,23 @@ export class OpenApiService {
488
475
  return data;
489
476
  });
490
477
  this.getTokenHistoryPrice = ({ chainId, id, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
491
- const { data } = yield this.request.get('/v1/token/history_price', Object.assign({ params: {
478
+ const { data } = yield this.request.get('/v1/token/history_price', {
479
+ params: {
492
480
  chain_id: chainId,
493
481
  id,
494
482
  time_at: timeAt,
495
- } }, this._getRequestOptions(chainId)));
483
+ },
484
+ });
496
485
  return data;
497
486
  });
498
487
  this.getTokenHistoryDict = ({ chainId, ids, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
499
- const { data } = yield this.request.get('/v1/token/history_price_dict', Object.assign({ params: {
488
+ const { data } = yield this.request.get('/v1/token/history_price_dict', {
489
+ params: {
500
490
  chain_id: chainId,
501
491
  ids,
502
492
  time_at: timeAt,
503
- } }, this._getRequestOptions(chainId)));
493
+ },
494
+ });
504
495
  return data;
505
496
  });
506
497
  this.getNetCurve = (addr) => __awaiter(this, void 0, void 0, function* () {
@@ -516,7 +507,9 @@ export class OpenApiService {
516
507
  return data;
517
508
  });
518
509
  this.getCEXSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
519
- const { data } = yield this.request.get('/v1/wallet/cex_swap_quote', Object.assign({ params }, this._getRequestOptions(params === null || params === void 0 ? void 0 : params.chain_id)));
510
+ const { data } = yield this.request.get('/v1/wallet/cex_swap_quote', {
511
+ params,
512
+ });
520
513
  return data;
521
514
  });
522
515
  this.getSwapTradeList = (params) => __awaiter(this, void 0, void 0, function* () {
@@ -526,12 +519,13 @@ export class OpenApiService {
526
519
  return data;
527
520
  });
528
521
  this.postSwap = (params) => __awaiter(this, void 0, void 0, function* () {
529
- var _m, _o;
530
- const { data } = yield this.request.post('/v1/wallet/swap_trade', params, this._getRequestOptions((_o = getChainByNetwork((_m = params === null || params === void 0 ? void 0 : params.tx) === null || _m === void 0 ? void 0 : _m.chainId)) === null || _o === void 0 ? void 0 : _o.serverId));
522
+ const { data } = yield this.request.post('/v1/wallet/swap_trade', params);
531
523
  return data;
532
524
  });
533
525
  this.checkSlippage = (params) => __awaiter(this, void 0, void 0, function* () {
534
- const { data } = yield this.request.get('/v1/wallet/check_slippage', Object.assign({ params }, this._getRequestOptions(params === null || params === void 0 ? void 0 : params.chain_id)));
526
+ const { data } = yield this.request.get('/v1/wallet/check_slippage', {
527
+ params,
528
+ });
535
529
  return data;
536
530
  });
537
531
  this.getOriginPopularityLevel = (origin) => __awaiter(this, void 0, void 0, function* () {
@@ -560,10 +554,12 @@ export class OpenApiService {
560
554
  return data;
561
555
  });
562
556
  this.getSummarizedAssetList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
563
- const { data } = yield this.request.get('/v1/user/summarized_asset_list', Object.assign({ params: {
557
+ const { data } = yield this.request.get('/v1/user/summarized_asset_list', {
558
+ params: {
564
559
  id,
565
560
  chain_id,
566
- } }, this._getRequestOptions(chain_id)));
561
+ },
562
+ });
567
563
  return data;
568
564
  });
569
565
  this.unexpectedAddrList = ({ chainId, tx, origin, addr, }) => __awaiter(this, void 0, void 0, function* () {
@@ -572,7 +568,7 @@ export class OpenApiService {
572
568
  tx,
573
569
  origin,
574
570
  user_addr: addr,
575
- }, this._getRequestOptions(chainId));
571
+ });
576
572
  return data;
577
573
  });
578
574
  this.parseTx = ({ chainId, tx, origin, addr, }) => __awaiter(this, void 0, void 0, function* () {
@@ -581,55 +577,67 @@ export class OpenApiService {
581
577
  tx,
582
578
  origin,
583
579
  user_addr: addr,
584
- }, this._getRequestOptions(chainId));
580
+ });
585
581
  return data;
586
582
  });
587
583
  this.isSuspiciousToken = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
588
- const { data } = yield this.request.get('/v1/engine/token/is_suspicious', Object.assign({ params: {
584
+ const { data } = yield this.request.get('/v1/engine/token/is_suspicious', {
585
+ params: {
589
586
  chain_id: chainId,
590
587
  id,
591
- } }, this._getRequestOptions(chainId)));
588
+ },
589
+ });
592
590
  return data;
593
591
  });
594
592
  this.depositCexSupport = (id, chainId, cexId) => __awaiter(this, void 0, void 0, function* () {
595
- const { data } = yield this.request.get('/v1/engine/token/deposit_cex_support', Object.assign({ params: {
593
+ const { data } = yield this.request.get('/v1/engine/token/deposit_cex_support', {
594
+ params: {
596
595
  chain_id: chainId,
597
596
  id,
598
597
  cex_id: cexId,
599
- } }, this._getRequestOptions(chainId)));
598
+ },
599
+ });
600
600
  return data;
601
601
  });
602
602
  // Token 可充值的 CEX 列表
603
603
  this.depositCexList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
604
- const { data } = yield this.request.get('/v1/engine/token/deposit_cex_list', Object.assign({ params: {
604
+ const { data } = yield this.request.get('/v1/engine/token/deposit_cex_list', {
605
+ params: {
605
606
  chain_id: chainId,
606
607
  id,
607
- } }, this._getRequestOptions(chainId)));
608
+ },
609
+ });
608
610
  return data;
609
611
  });
610
612
  // 合约信用分
611
613
  this.getContractCredit = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
612
- const { data } = yield this.request.get('/v1/engine/contract/credit', Object.assign({ params: {
614
+ const { data } = yield this.request.get('/v1/engine/contract/credit', {
615
+ params: {
613
616
  chain_id: chainId,
614
617
  id,
615
- } }, this._getRequestOptions(chainId)));
618
+ },
619
+ });
616
620
  return data;
617
621
  });
618
622
  // 是否跟地址交互过
619
623
  this.hasInteraction = (addr, chainId, contractId) => __awaiter(this, void 0, void 0, function* () {
620
- const { data } = yield this.request.get('/v1/engine/contract/has_interaction', Object.assign({ params: {
624
+ const { data } = yield this.request.get('/v1/engine/contract/has_interaction', {
625
+ params: {
621
626
  chain_id: chainId,
622
627
  user_addr: addr,
623
628
  contract_id: contractId,
624
- } }, this._getRequestOptions(chainId)));
629
+ },
630
+ });
625
631
  return data;
626
632
  });
627
633
  // 授权风险敞口
628
634
  this.tokenApproveExposure = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
629
- const { data } = yield this.request.get('/v1/engine/contract/token_approval_exposure', Object.assign({ params: {
635
+ const { data } = yield this.request.get('/v1/engine/contract/token_approval_exposure', {
636
+ params: {
630
637
  chain_id: chainId,
631
638
  id,
632
- } }, this._getRequestOptions(chainId)));
639
+ },
640
+ });
633
641
  return data;
634
642
  });
635
643
  // 地址描述
@@ -643,18 +651,22 @@ export class OpenApiService {
643
651
  });
644
652
  // 两个地址是否发生过转账
645
653
  this.hasTransfer = (chainId, from, to) => __awaiter(this, void 0, void 0, function* () {
646
- const { data } = yield this.request.get('/v1/engine/addr/has_transfer', Object.assign({ params: {
654
+ const { data } = yield this.request.get('/v1/engine/addr/has_transfer', {
655
+ params: {
647
656
  chain_id: chainId,
648
657
  from_addr: from,
649
658
  to_addr: to,
650
- } }, this._getRequestOptions(chainId)));
659
+ },
660
+ });
651
661
  return data;
652
662
  });
653
663
  this.isTokenContract = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
654
- const { data } = yield this.request.get('/v1/engine/contract/is_token', Object.assign({ params: {
664
+ const { data } = yield this.request.get('/v1/engine/contract/is_token', {
665
+ params: {
655
666
  id,
656
667
  chain_id: chainId,
657
- } }, this._getRequestOptions(chainId)));
668
+ },
669
+ });
658
670
  return data;
659
671
  });
660
672
  this.addrUsedChainList = (id) => __awaiter(this, void 0, void 0, function* () {
@@ -664,15 +676,21 @@ export class OpenApiService {
664
676
  return data;
665
677
  });
666
678
  this.getTokenNFTExposure = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
667
- const { data } = yield this.request.get('/v1/engine/contract/top_nft_approval_exposure', Object.assign({ params: { chain_id: chainId, id } }, this._getRequestOptions(chainId)));
679
+ const { data } = yield this.request.get('/v1/engine/contract/top_nft_approval_exposure', {
680
+ params: { chain_id: chainId, id },
681
+ });
668
682
  return data;
669
683
  });
670
684
  this.getCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
671
- const { data } = yield this.request.get('/v1/engine/collection', Object.assign({ params: { chain_id: chainId, id } }, this._getRequestOptions(chainId)));
685
+ const { data } = yield this.request.get('/v1/engine/collection', {
686
+ params: { chain_id: chainId, id },
687
+ });
672
688
  return data;
673
689
  });
674
690
  this.isSuspiciousCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
675
- const { data } = yield this.request.get('/v1/engine/collection/is_suspicious', Object.assign({ params: { chain_id: chainId, id } }, this._getRequestOptions(chainId)));
691
+ const { data } = yield this.request.get('/v1/engine/collection/is_suspicious', {
692
+ params: { chain_id: chainId, id },
693
+ });
676
694
  return data;
677
695
  });
678
696
  this.isOriginVerified = (origin) => __awaiter(this, void 0, void 0, function* () {
@@ -698,17 +716,21 @@ export class OpenApiService {
698
716
  return data;
699
717
  });
700
718
  this.collectionList = ({ id, chainId, isAll, }) => __awaiter(this, void 0, void 0, function* () {
701
- const { data } = yield this.request.get('/v1/user/collection_list', Object.assign({ params: {
719
+ const { data } = yield this.request.get('/v1/user/collection_list', {
720
+ params: {
702
721
  id,
703
722
  chain_id: chainId,
704
723
  is_all: isAll,
705
- } }, this._getRequestOptions(chainId)));
724
+ },
725
+ });
706
726
  return data;
707
727
  });
708
728
  this.gasPriceStats = (chainId) => __awaiter(this, void 0, void 0, function* () {
709
- const { data } = yield this.request.get('/v1/wallet/gas_price_stats', Object.assign({ params: {
729
+ const { data } = yield this.request.get('/v1/wallet/gas_price_stats', {
730
+ params: {
710
731
  chain_id: chainId,
711
- } }, this._getRequestOptions(chainId)));
732
+ },
733
+ });
712
734
  return data;
713
735
  });
714
736
  this.badgeHasClaimed = (id) => __awaiter(this, void 0, void 0, function* () {
@@ -745,14 +767,15 @@ export class OpenApiService {
745
767
  return data;
746
768
  });
747
769
  this.gasSupportedPushType = (chainId) => __awaiter(this, void 0, void 0, function* () {
748
- const { data } = yield this.request.get('/v1/wallet/supported_push_type', Object.assign({ params: {
770
+ const { data } = yield this.request.get('/v1/wallet/supported_push_type', {
771
+ params: {
749
772
  chain_id: chainId,
750
- } }, this._getRequestOptions(chainId)));
773
+ },
774
+ });
751
775
  return data;
752
776
  });
753
777
  this.submitTx = (postData) => __awaiter(this, void 0, void 0, function* () {
754
- var _p;
755
- const { data } = yield this.request.post('/v1/wallet/submit_tx', Object.assign({}, postData), this._getRequestOptions((_p = getChainByNetwork(postData.tx.chainId)) === null || _p === void 0 ? void 0 : _p.serverId));
778
+ const { data } = yield this.request.post('/v1/wallet/submit_tx', Object.assign({}, postData));
756
779
  return data;
757
780
  });
758
781
  this.getTxRequests = (ids) => __awaiter(this, void 0, void 0, function* () {
@@ -784,17 +807,17 @@ export class OpenApiService {
784
807
  return data;
785
808
  });
786
809
  this.mempoolChecks = (txId, chainId, node_info) => __awaiter(this, void 0, void 0, function* () {
787
- var _q;
788
- const { data } = yield this.request.get('/v1/wallet/mempool_checks', Object.assign({ params: {
810
+ const { data } = yield this.request.get('/v1/wallet/mempool_checks', {
811
+ params: {
789
812
  tx_id: txId,
790
813
  chain_id: chainId,
791
814
  node_info: node_info ? 1 : 0,
792
- } }, this._getRequestOptions((_q = getChainByNetwork(chainId)) === null || _q === void 0 ? void 0 : _q.serverId)));
815
+ },
816
+ });
793
817
  return data;
794
818
  });
795
819
  this.getPendingTxList = (params, options) => __awaiter(this, void 0, void 0, function* () {
796
- var _r;
797
- const data = yield this.asyncJob('/v1/wallet/get_pending_tx_list', Object.assign(Object.assign({ params }, this._getRequestOptions((_r = getChainByNetwork(params.chain_id)) === null || _r === void 0 ? void 0 : _r.serverId)), options));
820
+ const data = yield this.asyncJob('/v1/wallet/get_pending_tx_list', Object.assign({ params }, options));
798
821
  return data;
799
822
  });
800
823
  this.getLatestPreExec = (params) => __awaiter(this, void 0, void 0, function* () {
@@ -820,10 +843,10 @@ export class OpenApiService {
820
843
  return data;
821
844
  });
822
845
  this.getDappsInfo = (params) => __awaiter(this, void 0, void 0, function* () {
823
- var _s;
846
+ var _e;
824
847
  const { data } = yield this.request.get('/v1/dapp/list', {
825
848
  params: {
826
- ids: (_s = params === null || params === void 0 ? void 0 : params.ids) === null || _s === void 0 ? void 0 : _s.join(','),
849
+ ids: (_e = params === null || params === void 0 ? void 0 : params.ids) === null || _e === void 0 ? void 0 : _e.join(','),
827
850
  },
828
851
  });
829
852
  return data;
@@ -894,6 +917,18 @@ export class OpenApiService {
894
917
  const { data } = yield this.request.get('/v1/wallet/supported_chains');
895
918
  return data;
896
919
  });
920
+ this.searchChainList = (params) => __awaiter(this, void 0, void 0, function* () {
921
+ const { data } = yield this.request.get('/v1/chain/total_list', {
922
+ params,
923
+ });
924
+ return data;
925
+ });
926
+ this.getChainListByIds = (params) => __awaiter(this, void 0, void 0, function* () {
927
+ const { data } = yield this.request.get('/v1/chain/get_list', {
928
+ params,
929
+ });
930
+ return data;
931
+ });
897
932
  this.getHistoryCurve = (addr) => __awaiter(this, void 0, void 0, function* () {
898
933
  const { data } = yield this.request.get('/v1/user/history_curve', {
899
934
  params: { id: addr },
package/dist/types.d.ts CHANGED
@@ -1148,6 +1148,18 @@ export interface SupportedChain {
1148
1148
  is_disabled: boolean;
1149
1149
  explorer_host: string;
1150
1150
  }
1151
+ export interface ChainListItem {
1152
+ chain_id: number;
1153
+ name: string;
1154
+ short_name: string;
1155
+ native_currency: {
1156
+ name: string;
1157
+ symbol: string;
1158
+ decimals: number;
1159
+ };
1160
+ explorer: string | null;
1161
+ rpc: null | string;
1162
+ }
1151
1163
  export interface HistoryCurve {
1152
1164
  create_at: number;
1153
1165
  executor_name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-api",
3
- "version": "0.7.9",
3
+ "version": "0.7.11",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [