@rabby-wallet/rabby-api 0.6.15-alpha.1 → 0.6.15-alpha.2

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
@@ -71,6 +71,7 @@ export declare class OpenApiService {
71
71
  timeAt?: number;
72
72
  dateAt?: string;
73
73
  }) => Promise<TokenItem[]>;
74
+ _customListToken: (uuids: string[], id: string, isTestnet?: boolean) => Promise<TokenItem[]>;
74
75
  customListToken: (uuids: string[], id: string) => Promise<TokenItem[]>;
75
76
  listChainAssets: (id: string) => Promise<AssetItem[]>;
76
77
  listNFT: (id: string, isAll?: boolean) => Promise<NFTItem[]>;
package/dist/index.js CHANGED
@@ -12,7 +12,6 @@ import rateLimit from 'axios-rate-limit';
12
12
  import { ethErrors } from 'eth-rpc-errors';
13
13
  import { getChain, INITIAL_OPENAPI_URL, CHAINS, SIGN_HDS, genSignParams, INITIAL_TESTNET_OPENAPI_URL, getChainByNetwork, } from './utils';
14
14
  import * as sign from '@rabby-wallet/rabby-sign/umd/sign-wasm-rabby';
15
- import { TESTNET_CHAINS_LIST } from '@debank/common';
16
15
  const maxRPS = 500;
17
16
  export class OpenApiService {
18
17
  constructor({ store, adapter }) {
@@ -295,16 +294,37 @@ export class OpenApiService {
295
294
  } }, this._getRequestOptions(params.chainId)));
296
295
  return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
297
296
  });
298
- this.customListToken = (uuids, id) => __awaiter(this, void 0, void 0, function* () {
299
- const chain = TESTNET_CHAINS_LIST.find((item) => {
300
- return uuids === null || uuids === void 0 ? void 0 : uuids.find((uuid) => uuid.split(':')[0] === item.serverId);
301
- });
297
+ this._customListToken = (uuids, id, isTestnet = false) => __awaiter(this, void 0, void 0, function* () {
298
+ if ((uuids === null || uuids === void 0 ? void 0 : uuids.length) || !id) {
299
+ return [];
300
+ }
302
301
  const { data } = yield this.request.post('/v1/user/specific_token_list', {
303
302
  id,
304
303
  uuids,
305
- }, this._getRequestOptions(chain === null || chain === void 0 ? void 0 : chain.serverId));
304
+ }, isTestnet && this.store.testnetHost
305
+ ? { baseURL: this.store.testnetHost }
306
+ : undefined);
306
307
  return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
307
308
  });
309
+ this.customListToken = (uuids, id) => __awaiter(this, void 0, void 0, function* () {
310
+ const mainnetIds = [];
311
+ const testnetIds = [];
312
+ uuids.forEach((uuid) => {
313
+ const serverId = uuid.split(':')[0];
314
+ const chain = getChain(serverId);
315
+ if (chain === null || chain === void 0 ? void 0 : chain.isTestnet) {
316
+ testnetIds.push(uuid);
317
+ }
318
+ else {
319
+ mainnetIds.push(uuid);
320
+ }
321
+ });
322
+ const res = yield Promise.all([
323
+ this._customListToken(mainnetIds, id),
324
+ this._customListToken(testnetIds, id, true),
325
+ ]);
326
+ return res.flat();
327
+ });
308
328
  this.listChainAssets = (id) => __awaiter(this, void 0, void 0, function* () {
309
329
  const { data } = yield this.request.get('/v1/user/simple_protocol_list', {
310
330
  params: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-api",
3
- "version": "0.6.15-alpha.1",
3
+ "version": "0.6.15-alpha.2",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist"