@rabby-wallet/rabby-api 0.9.0 → 0.9.1-1.beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
3
  import { InitOptions, RabbyApiPlugin } from './plugins/intf';
4
- import { AddrDescResponse, BridgeAggregator, ApprovalStatus, AssetItem, BasicDappInfo, CEXQuote, Cex, ChainListItem, ChainWithPendingCount, Collection, CollectionList, CollectionWithFloorPrice, ComplexProtocol, ContractCredit, DbkBridgeHistoryItem, ExplainTxResponse, ExplainTypedDataResponse, GasLevel, GetTxResponse, HistoryCurve, LatestExplainTxResponse, MempoolCheckDetail, NFTApprovalResponse, NFTItem, NodeStatus, NodeStatusDetail, ParseTextResponse, ParseTxResponse, ParseTypedDataResponse, PendingTxItem, Protocol, SecurityCheckResponse, ServerChain, SlippageStatus, Summary, SupportedChain, SwapTradeList, TokenApproval, TokenItem, TotalBalanceResponse, Tx, TxAllHistoryResult, TxHistoryResult, TxPushType, TxRequest, UsedChain, BridgeTokenPair, BridgeQuote, BridgeHistory, ContractInfo, GasAccountCheckResult, ParseCommonResponse } from './types';
4
+ import { AddrDescResponse, BridgeAggregator, ApprovalStatus, AssetItem, BasicDappInfo, CEXQuote, Cex, ChainListItem, ChainWithPendingCount, Collection, CollectionList, CollectionWithFloorPrice, ComplexProtocol, ContractCredit, DbkBridgeHistoryItem, ExplainTxResponse, ExplainTypedDataResponse, GasLevel, GetTxResponse, HistoryCurve, LatestExplainTxResponse, MempoolCheckDetail, NFTApprovalResponse, NFTItem, NodeStatus, NodeStatusDetail, ParseTextResponse, ParseTxResponse, ParseTypedDataResponse, PendingTxItem, Protocol, SecurityCheckResponse, ServerChain, SlippageStatus, Summary, SupportedChain, SwapTradeList, TokenApproval, TokenItem, TotalBalanceResponse, Tx, TxAllHistoryResult, TxHistoryResult, TxPushType, TxRequest, UsedChain, BridgeTokenPair, BridgeQuote, BridgeHistory, ContractInfo, GasAccountCheckResult, ParseCommonResponse, WithdrawListAddressItem } from './types';
5
5
  interface OpenApiStore {
6
6
  host: string;
7
7
  testnetHost?: string;
@@ -44,6 +44,14 @@ export declare class OpenApiService {
44
44
  private _mountMethods;
45
45
  getRecommendChains: (address: string, origin: string) => Promise<ServerChain[]>;
46
46
  getTotalBalance: (address: string, isCore?: boolean) => Promise<TotalBalanceResponse>;
47
+ getTotalBalanceV2: ({ address, isCore, included_token_uuids, excluded_token_uuids, excluded_protocol_ids, excluded_chain_ids, }: {
48
+ address: string;
49
+ isCore: boolean;
50
+ included_token_uuids: string[];
51
+ excluded_token_uuids: string[];
52
+ excluded_protocol_ids: string[];
53
+ excluded_chain_ids: string[];
54
+ }) => Promise<TotalBalanceResponse>;
47
55
  getPendingCount: (address: string) => Promise<{
48
56
  total_count: number;
49
57
  chains: ChainWithPendingCount[];
@@ -70,10 +78,7 @@ export declare class OpenApiService {
70
78
  explainText: (origin: string, address: string, text: string) => Promise<{
71
79
  comment: string;
72
80
  }>;
73
- gasMarket: (options: {
74
- chainId: string;
75
- customGas?: number;
76
- }) => Promise<GasLevel[]>;
81
+ gasMarket: (chainId: string, customGas?: number) => Promise<GasLevel[]>;
77
82
  gasMarketV2: (options: {
78
83
  chainId: string;
79
84
  tx?: Tx;
@@ -97,7 +102,7 @@ export declare class OpenApiService {
97
102
  }) => Promise<TokenItem[]>;
98
103
  customListToken: (uuids: string[], id: string) => Promise<TokenItem[]>;
99
104
  listChainAssets: (id: string) => Promise<AssetItem[]>;
100
- listNFT: (id: string, isAll?: boolean) => Promise<NFTItem[]>;
105
+ listNFT: (id: string, isAll?: boolean, sortByCredit?: boolean) => Promise<NFTItem[]>;
101
106
  listCollection: (params: {
102
107
  collection_ids: string;
103
108
  }) => Promise<Collection[]>;
@@ -165,6 +170,9 @@ export declare class OpenApiService {
165
170
  getGasStationChainBalance: (chain_id: string, addr: string) => Promise<{
166
171
  usd_value: number;
167
172
  }>;
173
+ getApprovalCount: (address: string) => Promise<{
174
+ total_asset_cnt: number;
175
+ }>;
168
176
  getGasStationTokenList: () => Promise<TokenItem[]>;
169
177
  explainTypedData: (user_addr: string, origin: string, data: any) => Promise<ExplainTypedDataResponse>;
170
178
  checkTypedData: (user_addr: string, origin: string, data: any) => Promise<SecurityCheckResponse>;
@@ -893,9 +901,16 @@ export declare class OpenApiService {
893
901
  sig: string;
894
902
  amount: number;
895
903
  account_id: string;
904
+ user_addr: string;
905
+ chain_id: string;
906
+ fee: number;
896
907
  }) => Promise<{
897
908
  success: boolean;
898
909
  }>;
910
+ getWithdrawList: (p: {
911
+ sig: string;
912
+ id: string;
913
+ }) => Promise<WithdrawListAddressItem[]>;
899
914
  getGasAccountHistory: (p: {
900
915
  sig: string;
901
916
  account_id: string;
@@ -910,6 +925,14 @@ export declare class OpenApiService {
910
925
  tx_id: string;
911
926
  user_addr: string;
912
927
  }[];
928
+ withdraw_list: {
929
+ amount: number;
930
+ chain_id: string;
931
+ create_at: number;
932
+ gas_account_id: string;
933
+ tx_id: string;
934
+ user_addr: string;
935
+ }[];
913
936
  history_list: {
914
937
  id: string;
915
938
  chain_id: string;
@@ -1001,5 +1024,34 @@ export declare class OpenApiService {
1001
1024
  }) => Promise<{
1002
1025
  success: boolean;
1003
1026
  }>;
1027
+ /**
1028
+ * @deprecated
1029
+ */
1030
+ getToken24hPrice: (params: {
1031
+ chain_id: string;
1032
+ id: string;
1033
+ }) => Promise<{
1034
+ time_at: number;
1035
+ price: number;
1036
+ }[]>;
1037
+ getTokenPriceCurve: (params: {
1038
+ chain_id: string;
1039
+ id: string;
1040
+ days: number | 1 | 7;
1041
+ }) => Promise<{
1042
+ time_at: number;
1043
+ price: number;
1044
+ }[]>;
1045
+ getTokenDatePrice: (params: {
1046
+ chain_id: string;
1047
+ id: string;
1048
+ }) => Promise<{
1049
+ date_at: string;
1050
+ price: number;
1051
+ }[]>;
1052
+ searchTokens: (params: {
1053
+ q: string;
1054
+ }) => Promise<TokenItem[]>;
1055
+ batchQueryTokens: (uuids: string | string[]) => Promise<TokenItem[]>;
1004
1056
  }
1005
1057
  export {};
package/dist/index.js CHANGED
@@ -123,6 +123,17 @@ export class OpenApiService {
123
123
  });
124
124
  return data;
125
125
  });
126
+ this.getTotalBalanceV2 = ({ address, isCore = false, included_token_uuids = [], excluded_token_uuids = [], excluded_protocol_ids = [], excluded_chain_ids = [], }) => __awaiter(this, void 0, void 0, function* () {
127
+ const { data } = yield this.request.post('/v2/user/total_balance', {
128
+ id: address,
129
+ is_core: isCore,
130
+ included_token_uuids: included_token_uuids,
131
+ excluded_token_uuids: excluded_token_uuids,
132
+ excluded_protocol_ids: excluded_protocol_ids,
133
+ excluded_chain_ids: excluded_chain_ids,
134
+ });
135
+ return data;
136
+ });
126
137
  this.getPendingCount = (address) => __awaiter(this, void 0, void 0, function* () {
127
138
  const { data } = yield this.request.get('/v1/wallet/pending_tx_count', {
128
139
  params: {
@@ -201,22 +212,20 @@ export class OpenApiService {
201
212
  });
202
213
  return data;
203
214
  });
204
- this.gasMarket = (options) => __awaiter(this, void 0, void 0, function* () {
215
+ this.gasMarket = (chainId, customGas) => __awaiter(this, void 0, void 0, function* () {
205
216
  const { data } = yield this.request.get('/v1/wallet/gas_market', {
206
217
  params: {
207
- chain_id: options.chainId,
208
- custom_price: options.customGas,
218
+ chain_id: chainId,
219
+ custom_price: customGas,
209
220
  },
210
221
  });
211
222
  return data;
212
223
  });
213
224
  this.gasMarketV2 = (options) => __awaiter(this, void 0, void 0, function* () {
214
225
  const { data } = yield this.request.post('/v2/wallet/gas_market', {
215
- params: {
216
- chain_id: options.chainId,
217
- custom_price: options.customGas,
218
- tx: options.tx,
219
- },
226
+ chain_id: options.chainId,
227
+ custom_price: options.customGas,
228
+ tx: options.tx,
220
229
  });
221
230
  return data;
222
231
  });
@@ -318,12 +327,16 @@ export class OpenApiService {
318
327
  });
319
328
  return data;
320
329
  });
321
- this.listNFT = (id, isAll = true) => __awaiter(this, void 0, void 0, function* () {
330
+ this.listNFT = (id, isAll = true, sortByCredit) => __awaiter(this, void 0, void 0, function* () {
322
331
  const { data } = yield this.request.get('/v1/user/nft_list', {
323
- params: {
332
+ params: Object.assign({
324
333
  id,
325
334
  is_all: isAll,
326
- },
335
+ }, sortByCredit
336
+ ? {
337
+ sort_by: 'credit_score',
338
+ }
339
+ : {}),
327
340
  });
328
341
  return data;
329
342
  });
@@ -381,6 +394,7 @@ export class OpenApiService {
381
394
  this.getSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
382
395
  const { data } = yield this.request.get('/v1/wallet/swap_quote', {
383
396
  params,
397
+ timeout: 5000,
384
398
  });
385
399
  return data;
386
400
  });
@@ -418,6 +432,14 @@ export class OpenApiService {
418
432
  });
419
433
  return data;
420
434
  });
435
+ this.getApprovalCount = (address) => __awaiter(this, void 0, void 0, function* () {
436
+ const { data } = yield this.request.get('/v1/user/total_approval_asset_cnt', {
437
+ params: {
438
+ id: address,
439
+ },
440
+ });
441
+ return data;
442
+ });
421
443
  this.getGasStationTokenList = () => __awaiter(this, void 0, void 0, function* () {
422
444
  const { data } = yield this.request.get('/v1/wallet/gas_station_token_list');
423
445
  return data;
@@ -1261,6 +1283,16 @@ export class OpenApiService {
1261
1283
  });
1262
1284
  return data;
1263
1285
  });
1286
+ this.getWithdrawList = (p) => __awaiter(this, void 0, void 0, function* () {
1287
+ const { sig } = p, params = __rest(p, ["sig"]);
1288
+ const { data } = yield this.request.get('/v1/gas_account/withdraw_list', {
1289
+ params,
1290
+ headers: {
1291
+ sig,
1292
+ },
1293
+ });
1294
+ return data;
1295
+ });
1264
1296
  this.getGasAccountHistory = (p) => __awaiter(this, void 0, void 0, function* () {
1265
1297
  const { sig } = p, params = __rest(p, ["sig"]);
1266
1298
  const { data } = yield this.request.get('/v1/gas_account/history', {
@@ -1338,6 +1370,41 @@ export class OpenApiService {
1338
1370
  });
1339
1371
  return data;
1340
1372
  });
1373
+ /**
1374
+ * @deprecated
1375
+ */
1376
+ this.getToken24hPrice = (params) => __awaiter(this, void 0, void 0, function* () {
1377
+ const { data } = yield this.request.get('/v1/token/24h_price', {
1378
+ params,
1379
+ });
1380
+ return data;
1381
+ });
1382
+ this.getTokenPriceCurve = (params) => __awaiter(this, void 0, void 0, function* () {
1383
+ const { data } = yield this.request.get('/v1/token/price_curve', {
1384
+ params,
1385
+ });
1386
+ return data;
1387
+ });
1388
+ this.getTokenDatePrice = (params) => __awaiter(this, void 0, void 0, function* () {
1389
+ const { data } = yield this.request.get('/v1/token/date_price', {
1390
+ params,
1391
+ });
1392
+ return data;
1393
+ });
1394
+ this.searchTokens = (params) => __awaiter(this, void 0, void 0, function* () {
1395
+ const { data } = yield this.request.get('/v1/token/search', {
1396
+ params,
1397
+ });
1398
+ return data;
1399
+ });
1400
+ this.batchQueryTokens = (uuids) => __awaiter(this, void 0, void 0, function* () {
1401
+ const { data } = yield this.request.get('/v1/token/list_by_uuids', {
1402
+ params: {
1403
+ uuids: Array.isArray(uuids) ? uuids.join(',') : uuids,
1404
+ },
1405
+ });
1406
+ return data;
1407
+ });
1341
1408
  if (store instanceof Promise) {
1342
1409
  store.then((resolvedStore) => {
1343
1410
  this.store = resolvedStore;
package/dist/types.d.ts CHANGED
@@ -258,14 +258,16 @@ export interface NFTItem {
258
258
  id: string;
259
259
  contract_id: string;
260
260
  inner_id: string;
261
- token_id: string;
261
+ token_id?: string;
262
262
  name: string;
263
263
  contract_name: string;
264
264
  description: string;
265
- usd_price: number;
265
+ usd_price?: number;
266
266
  amount: number;
267
267
  collection_id?: string;
268
- pay_token: {
268
+ collection_name?: string;
269
+ is_core?: boolean;
270
+ pay_token?: {
269
271
  id: string;
270
272
  name: string;
271
273
  symbol: string;
@@ -282,6 +284,7 @@ export interface NFTItem {
282
284
  collection?: Collection | null;
283
285
  is_erc1155?: boolean;
284
286
  is_erc721: boolean;
287
+ thumbnail_url?: string;
285
288
  }
286
289
  export interface Collection {
287
290
  id: string;
@@ -1380,4 +1383,15 @@ export interface ParseCommonResponse {
1380
1383
  contract_call_data: ParseTxResponse['contract_call'] | null;
1381
1384
  pre_exec?: PreExecResult['pre_exec'];
1382
1385
  }
1386
+ export interface RechargeChainItem {
1387
+ chain_id: string;
1388
+ withdraw_limit: number;
1389
+ withdraw_fee: number;
1390
+ l1_balance: number;
1391
+ }
1392
+ export interface WithdrawListAddressItem {
1393
+ recharge_addr: string;
1394
+ total_withdraw_limit: number;
1395
+ recharge_chain_list: RechargeChainItem[];
1396
+ }
1383
1397
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabby-wallet/rabby-api",
3
- "version": "0.9.0",
3
+ "version": "0.9.11.beta.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [