@rabby-wallet/rabby-api 0.6.15-alpha.3 → 0.6.16
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 +4 -5
- package/dist/index.js +138 -121
- package/dist/types.d.ts +1 -0
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -9
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { RateLimitedAxiosInstance } from 'axios-rate-limit';
|
|
|
3
3
|
import { ServerChain, TotalBalanceResponse, ChainWithPendingCount, SecurityCheckResponse, Tx, ExplainTxResponse, GasLevel, GetTxResponse, TokenItem, AssetItem, NFTItem, Collection, TxHistoryResult, TokenApproval, NFTApprovalResponse, ApprovalStatus, UsedChain, Protocol, ComplexProtocol, ExplainTypedDataResponse, SwapTradeList, SlippageStatus, CEXQuote, Summary, Cex, ContractCredit, AddrDescResponse, ParseTxResponse, CollectionWithFloorPrice, ParseTypedDataResponse, ParseTextResponse, CollectionList } from './types';
|
|
4
4
|
interface OpenApiStore {
|
|
5
5
|
host: string;
|
|
6
|
-
testnetHost?: string;
|
|
7
6
|
}
|
|
8
7
|
interface Options {
|
|
9
8
|
store: OpenApiStore;
|
|
@@ -14,8 +13,6 @@ export declare class OpenApiService {
|
|
|
14
13
|
request: RateLimitedAxiosInstance;
|
|
15
14
|
setHost: (host: string) => Promise<void>;
|
|
16
15
|
getHost: () => string;
|
|
17
|
-
setTestnetHost: (host: string) => Promise<void>;
|
|
18
|
-
getTestnetHost: () => string | undefined;
|
|
19
16
|
ethRpc: ((chainId: string, arg: {
|
|
20
17
|
method: string;
|
|
21
18
|
params: Array<any>;
|
|
@@ -24,7 +21,6 @@ export declare class OpenApiService {
|
|
|
24
21
|
adapter?: AxiosAdapter;
|
|
25
22
|
constructor({ store, adapter }: Options);
|
|
26
23
|
init: (hf?: string) => Promise<void>;
|
|
27
|
-
private _getRequestOptions;
|
|
28
24
|
private _mountMethods;
|
|
29
25
|
getRecommendChains: (address: string, origin: string) => Promise<ServerChain[]>;
|
|
30
26
|
getTotalBalance: (address: string) => Promise<TotalBalanceResponse>;
|
|
@@ -71,7 +67,6 @@ export declare class OpenApiService {
|
|
|
71
67
|
timeAt?: number;
|
|
72
68
|
dateAt?: string;
|
|
73
69
|
}) => Promise<TokenItem[]>;
|
|
74
|
-
_customListToken: (uuids: string[], id: string, isTestnet?: boolean) => Promise<TokenItem[]>;
|
|
75
70
|
customListToken: (uuids: string[], id: string) => Promise<TokenItem[]>;
|
|
76
71
|
listChainAssets: (id: string) => Promise<AssetItem[]>;
|
|
77
72
|
listNFT: (id: string, isAll?: boolean) => Promise<NFTItem[]>;
|
|
@@ -106,6 +101,7 @@ export declare class OpenApiService {
|
|
|
106
101
|
pay_token_id: string;
|
|
107
102
|
pay_token_raw_amount: string;
|
|
108
103
|
receive_token_id: string;
|
|
104
|
+
slippage?: string | number;
|
|
109
105
|
}) => Promise<{
|
|
110
106
|
receive_token_raw_amount: number;
|
|
111
107
|
dex_approve_to: string;
|
|
@@ -279,5 +275,8 @@ export declare class OpenApiService {
|
|
|
279
275
|
chainId?: string | undefined;
|
|
280
276
|
isAll: boolean;
|
|
281
277
|
}) => Promise<CollectionList[]>;
|
|
278
|
+
gasPriceStats: (chainId: string) => Promise<{
|
|
279
|
+
median: number;
|
|
280
|
+
}>;
|
|
282
281
|
}
|
|
283
282
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import axios from 'axios';
|
|
11
11
|
import rateLimit from 'axios-rate-limit';
|
|
12
12
|
import { ethErrors } from 'eth-rpc-errors';
|
|
13
|
-
import { getChain, INITIAL_OPENAPI_URL, CHAINS, SIGN_HDS, genSignParams,
|
|
13
|
+
import { getChain, INITIAL_OPENAPI_URL, CHAINS, SIGN_HDS, genSignParams, } from './utils';
|
|
14
14
|
import * as sign from '@rabby-wallet/rabby-sign/umd/sign-wasm-rabby';
|
|
15
15
|
const maxRPS = 500;
|
|
16
16
|
export class OpenApiService {
|
|
@@ -30,12 +30,6 @@ export class OpenApiService {
|
|
|
30
30
|
this.getHost = () => {
|
|
31
31
|
return this.store.host;
|
|
32
32
|
};
|
|
33
|
-
this.setTestnetHost = (host) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
this.store.testnetHost = host;
|
|
35
|
-
});
|
|
36
|
-
this.getTestnetHost = () => {
|
|
37
|
-
return this.store.testnetHost;
|
|
38
|
-
};
|
|
39
33
|
this.ethRpc = () => __awaiter(this, void 0, void 0, function* () {
|
|
40
34
|
throw ethErrors.provider.disconnected();
|
|
41
35
|
});
|
|
@@ -44,7 +38,6 @@ export class OpenApiService {
|
|
|
44
38
|
yield sign.lW(hf);
|
|
45
39
|
if (!process.env.DEBUG) {
|
|
46
40
|
this.store.host = INITIAL_OPENAPI_URL;
|
|
47
|
-
this.store.testnetHost = INITIAL_TESTNET_OPENAPI_URL;
|
|
48
41
|
}
|
|
49
42
|
const request = axios.create({
|
|
50
43
|
baseURL: this.store.host,
|
|
@@ -87,22 +80,6 @@ export class OpenApiService {
|
|
|
87
80
|
});
|
|
88
81
|
this._mountMethods();
|
|
89
82
|
});
|
|
90
|
-
this._getRequestOptions = (chainId) => {
|
|
91
|
-
if (!chainId) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
const testnetHost = this.getTestnetHost();
|
|
95
|
-
if (!testnetHost) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const chain = getChain(chainId);
|
|
99
|
-
if (!(chain === null || chain === void 0 ? void 0 : chain.isTestnet)) {
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
baseURL: testnetHost,
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
83
|
this._mountMethods = () => {
|
|
107
84
|
this.ethRpc = (chain_id, { origin = 'rabby', method, params }) => {
|
|
108
85
|
return this.request
|
|
@@ -110,7 +87,7 @@ export class OpenApiService {
|
|
|
110
87
|
chain_id,
|
|
111
88
|
method,
|
|
112
89
|
params,
|
|
113
|
-
}
|
|
90
|
+
})
|
|
114
91
|
.then(({ data }) => {
|
|
115
92
|
if (data === null || data === void 0 ? void 0 : data.error) {
|
|
116
93
|
throw data.error;
|
|
@@ -160,39 +137,35 @@ export class OpenApiService {
|
|
|
160
137
|
return data;
|
|
161
138
|
});
|
|
162
139
|
this.checkTx = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
|
|
163
|
-
var _f;
|
|
164
140
|
const { data } = yield this.request.post('/v1/wallet/check_tx', {
|
|
165
141
|
user_addr: address,
|
|
166
142
|
origin,
|
|
167
143
|
tx,
|
|
168
144
|
update_nonce,
|
|
169
|
-
}
|
|
145
|
+
});
|
|
170
146
|
return data;
|
|
171
147
|
});
|
|
172
148
|
this.preExecTx = ({ tx, origin, address, updateNonce = false, pending_tx_list = [], }) => __awaiter(this, void 0, void 0, function* () {
|
|
173
|
-
var _g;
|
|
174
149
|
const { data } = yield this.request.post('/v1/wallet/pre_exec_tx', {
|
|
175
150
|
tx,
|
|
176
151
|
user_addr: address,
|
|
177
152
|
origin,
|
|
178
153
|
update_nonce: updateNonce,
|
|
179
154
|
pending_tx_list,
|
|
180
|
-
}
|
|
155
|
+
});
|
|
181
156
|
return data;
|
|
182
157
|
});
|
|
183
158
|
this.historyGasUsed = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
184
|
-
|
|
185
|
-
const { data } = yield this.request.post('/v1/wallet/history_tx_used_gas', Object.assign({}, params), this._getRequestOptions((_j = getChainByNetwork((_h = params === null || params === void 0 ? void 0 : params.tx) === null || _h === void 0 ? void 0 : _h.chainId)) === null || _j === void 0 ? void 0 : _j.serverId));
|
|
159
|
+
const { data } = yield this.request.post('/v1/wallet/history_tx_used_gas', Object.assign({}, params));
|
|
186
160
|
return data;
|
|
187
161
|
});
|
|
188
162
|
this.pendingTxList = (tx, origin, address, update_nonce = false) => __awaiter(this, void 0, void 0, function* () {
|
|
189
|
-
var _k;
|
|
190
163
|
const { data } = yield this.request.post('/v1/wallet/pending_tx_list', {
|
|
191
164
|
tx,
|
|
192
165
|
user_addr: address,
|
|
193
166
|
origin,
|
|
194
167
|
update_nonce,
|
|
195
|
-
}
|
|
168
|
+
});
|
|
196
169
|
return data;
|
|
197
170
|
});
|
|
198
171
|
this.traceTx = (txId, traceId, chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -200,15 +173,14 @@ export class OpenApiService {
|
|
|
200
173
|
tx_id: txId,
|
|
201
174
|
trace_id: traceId,
|
|
202
175
|
chain_id: chainId,
|
|
203
|
-
}
|
|
176
|
+
});
|
|
204
177
|
return data;
|
|
205
178
|
});
|
|
206
179
|
this.pushTx = (tx, traceId) => __awaiter(this, void 0, void 0, function* () {
|
|
207
|
-
var _l;
|
|
208
180
|
const { data } = yield this.request.post('/v1/wallet/push_tx', {
|
|
209
181
|
tx,
|
|
210
182
|
trace_id: traceId,
|
|
211
|
-
}
|
|
183
|
+
});
|
|
212
184
|
return data;
|
|
213
185
|
});
|
|
214
186
|
this.explainText = (origin, address, text) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -220,18 +192,22 @@ export class OpenApiService {
|
|
|
220
192
|
return data;
|
|
221
193
|
});
|
|
222
194
|
this.gasMarket = (chainId, customGas) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
-
const { data } = yield this.request.get('/v1/wallet/gas_market',
|
|
195
|
+
const { data } = yield this.request.get('/v1/wallet/gas_market', {
|
|
196
|
+
params: {
|
|
224
197
|
chain_id: chainId,
|
|
225
198
|
custom_price: customGas,
|
|
226
|
-
}
|
|
199
|
+
},
|
|
200
|
+
});
|
|
227
201
|
return data;
|
|
228
202
|
});
|
|
229
203
|
this.getTx = (chainId, hash, gasPrice) => __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
const { data } = yield this.request.get('/v1/wallet/get_tx',
|
|
204
|
+
const { data } = yield this.request.get('/v1/wallet/get_tx', {
|
|
205
|
+
params: {
|
|
231
206
|
chain_id: chainId,
|
|
232
207
|
gas_price: gasPrice,
|
|
233
208
|
tx_id: hash,
|
|
234
|
-
}
|
|
209
|
+
},
|
|
210
|
+
});
|
|
235
211
|
return data;
|
|
236
212
|
});
|
|
237
213
|
this.getEnsAddressByName = (name) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -243,30 +219,36 @@ export class OpenApiService {
|
|
|
243
219
|
return data;
|
|
244
220
|
});
|
|
245
221
|
this.searchToken = (id, q, chainId, is_all = false) => __awaiter(this, void 0, void 0, function* () {
|
|
246
|
-
const { data } = yield this.request.get('/v1/user/token_search',
|
|
222
|
+
const { data } = yield this.request.get('/v1/user/token_search', {
|
|
223
|
+
params: {
|
|
247
224
|
id,
|
|
248
225
|
q,
|
|
249
226
|
has_balance: false,
|
|
250
227
|
is_all,
|
|
251
228
|
chain_id: chainId,
|
|
252
|
-
}
|
|
229
|
+
},
|
|
230
|
+
});
|
|
253
231
|
return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
|
|
254
232
|
});
|
|
255
233
|
this.searchSwapToken = (id, chainId, q, is_all = false) => __awaiter(this, void 0, void 0, function* () {
|
|
256
|
-
const { data } = yield this.request.get('/v1/user/token_search',
|
|
234
|
+
const { data } = yield this.request.get('/v1/user/token_search', {
|
|
235
|
+
params: {
|
|
257
236
|
id,
|
|
258
237
|
chain_id: chainId,
|
|
259
238
|
q,
|
|
260
239
|
is_all,
|
|
261
|
-
}
|
|
240
|
+
},
|
|
241
|
+
});
|
|
262
242
|
return data;
|
|
263
243
|
});
|
|
264
244
|
this.getToken = (id, chainId, tokenId) => __awaiter(this, void 0, void 0, function* () {
|
|
265
|
-
const { data } = yield this.request.get('/v1/user/token',
|
|
245
|
+
const { data } = yield this.request.get('/v1/user/token', {
|
|
246
|
+
params: {
|
|
266
247
|
id,
|
|
267
248
|
chain_id: chainId,
|
|
268
249
|
token_id: tokenId,
|
|
269
|
-
}
|
|
250
|
+
},
|
|
251
|
+
});
|
|
270
252
|
return data;
|
|
271
253
|
});
|
|
272
254
|
this.getCachedTokenList = (id) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -278,52 +260,32 @@ export class OpenApiService {
|
|
|
278
260
|
return data;
|
|
279
261
|
});
|
|
280
262
|
this.listToken = (id, chainId, isAll = false) => __awaiter(this, void 0, void 0, function* () {
|
|
281
|
-
const { data } = yield this.request.get('/v1/user/token_list',
|
|
263
|
+
const { data } = yield this.request.get('/v1/user/token_list', {
|
|
264
|
+
params: {
|
|
282
265
|
id,
|
|
283
266
|
is_all: isAll,
|
|
284
267
|
chain_id: chainId,
|
|
285
|
-
}
|
|
268
|
+
},
|
|
269
|
+
});
|
|
286
270
|
return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
|
|
287
271
|
});
|
|
288
272
|
this.getHistoryTokenList = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
289
|
-
const { data } = yield this.request.get('/v1/user/history_token_list',
|
|
273
|
+
const { data } = yield this.request.get('/v1/user/history_token_list', {
|
|
274
|
+
params: {
|
|
290
275
|
id: params.id,
|
|
291
276
|
chain_id: params.chainId,
|
|
292
277
|
time_at: params.timeAt,
|
|
293
278
|
date_at: params.dateAt,
|
|
294
|
-
}
|
|
279
|
+
},
|
|
280
|
+
});
|
|
295
281
|
return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
|
|
296
282
|
});
|
|
297
|
-
this.
|
|
298
|
-
if (!(uuids === null || uuids === void 0 ? void 0 : uuids.length) || !id) {
|
|
299
|
-
return [];
|
|
300
|
-
}
|
|
283
|
+
this.customListToken = (uuids, id) => __awaiter(this, void 0, void 0, function* () {
|
|
301
284
|
const { data } = yield this.request.post('/v1/user/specific_token_list', {
|
|
302
285
|
id,
|
|
303
286
|
uuids,
|
|
304
|
-
}, isTestnet && this.store.testnetHost
|
|
305
|
-
? { baseURL: this.store.testnetHost }
|
|
306
|
-
: undefined);
|
|
307
|
-
return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
|
|
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
287
|
});
|
|
322
|
-
|
|
323
|
-
this._customListToken(mainnetIds, id),
|
|
324
|
-
this._customListToken(testnetIds, id, true),
|
|
325
|
-
]);
|
|
326
|
-
return res.flat();
|
|
288
|
+
return data === null || data === void 0 ? void 0 : data.filter((token) => getChain(token.chain));
|
|
327
289
|
});
|
|
328
290
|
this.listChainAssets = (id) => __awaiter(this, void 0, void 0, function* () {
|
|
329
291
|
const { data } = yield this.request.get('/v1/user/simple_protocol_list', {
|
|
@@ -349,7 +311,9 @@ export class OpenApiService {
|
|
|
349
311
|
return data;
|
|
350
312
|
});
|
|
351
313
|
this.listTxHisotry = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
352
|
-
const { data } = yield this.request.get('/v1/user/history_list',
|
|
314
|
+
const { data } = yield this.request.get('/v1/user/history_list', {
|
|
315
|
+
params,
|
|
316
|
+
});
|
|
353
317
|
return data;
|
|
354
318
|
});
|
|
355
319
|
this.tokenPrice = (tokenName) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -361,35 +325,45 @@ export class OpenApiService {
|
|
|
361
325
|
return data;
|
|
362
326
|
});
|
|
363
327
|
this.tokenAuthorizedList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
|
|
364
|
-
const { data } = yield this.request.get('/v1/user/token_authorized_list',
|
|
328
|
+
const { data } = yield this.request.get('/v1/user/token_authorized_list', {
|
|
329
|
+
params: {
|
|
365
330
|
id,
|
|
366
331
|
chain_id,
|
|
367
|
-
}
|
|
332
|
+
},
|
|
333
|
+
});
|
|
368
334
|
return data;
|
|
369
335
|
});
|
|
370
336
|
this.userNFTAuthorizedList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
|
|
371
|
-
const { data } = yield this.request.get('/v1/user/nft_authorized_list',
|
|
337
|
+
const { data } = yield this.request.get('/v1/user/nft_authorized_list', {
|
|
338
|
+
params: {
|
|
372
339
|
id,
|
|
373
340
|
chain_id,
|
|
374
|
-
}
|
|
341
|
+
},
|
|
342
|
+
});
|
|
375
343
|
return data;
|
|
376
344
|
});
|
|
377
345
|
this.getDEXList = (chain_id) => __awaiter(this, void 0, void 0, function* () {
|
|
378
|
-
const { data } = yield this.request.get('/v1/wallet/swap_dex_list',
|
|
346
|
+
const { data } = yield this.request.get('/v1/wallet/swap_dex_list', {
|
|
347
|
+
params: {
|
|
379
348
|
chain_id,
|
|
380
|
-
}
|
|
349
|
+
},
|
|
350
|
+
});
|
|
381
351
|
return data;
|
|
382
352
|
});
|
|
383
353
|
this.getSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
384
|
-
const { data } = yield this.request.get('/v1/wallet/swap_quote',
|
|
354
|
+
const { data } = yield this.request.get('/v1/wallet/swap_quote', {
|
|
355
|
+
params,
|
|
356
|
+
});
|
|
385
357
|
return data;
|
|
386
358
|
});
|
|
387
359
|
this.getSwapTokenList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
388
|
-
const { data } = yield this.request.get('/v1/wallet/swap_token_list',
|
|
360
|
+
const { data } = yield this.request.get('/v1/wallet/swap_token_list', {
|
|
361
|
+
params: {
|
|
389
362
|
id,
|
|
390
363
|
chain_id: chainId,
|
|
391
364
|
is_all: false,
|
|
392
|
-
}
|
|
365
|
+
},
|
|
366
|
+
});
|
|
393
367
|
return data;
|
|
394
368
|
});
|
|
395
369
|
this.postGasStationOrder = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -404,14 +378,16 @@ export class OpenApiService {
|
|
|
404
378
|
to_token_amount: params.toTokenAmount,
|
|
405
379
|
from_usd_value: params.fromUsdValue,
|
|
406
380
|
},
|
|
407
|
-
}
|
|
381
|
+
});
|
|
408
382
|
return data;
|
|
409
383
|
});
|
|
410
384
|
this.getGasStationChainBalance = (chain_id, addr) => __awaiter(this, void 0, void 0, function* () {
|
|
411
|
-
const { data } = yield this.request.get('/v1/wallet/gas_station_usd_value',
|
|
385
|
+
const { data } = yield this.request.get('/v1/wallet/gas_station_usd_value', {
|
|
386
|
+
params: {
|
|
412
387
|
chain_id,
|
|
413
388
|
addr,
|
|
414
|
-
}
|
|
389
|
+
},
|
|
390
|
+
});
|
|
415
391
|
return data;
|
|
416
392
|
});
|
|
417
393
|
this.getGasStationTokenList = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -499,19 +475,23 @@ export class OpenApiService {
|
|
|
499
475
|
return data;
|
|
500
476
|
});
|
|
501
477
|
this.getTokenHistoryPrice = ({ chainId, id, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
|
|
502
|
-
const { data } = yield this.request.get('/v1/token/history_price',
|
|
478
|
+
const { data } = yield this.request.get('/v1/token/history_price', {
|
|
479
|
+
params: {
|
|
503
480
|
chain_id: chainId,
|
|
504
481
|
id,
|
|
505
482
|
time_at: timeAt,
|
|
506
|
-
}
|
|
483
|
+
},
|
|
484
|
+
});
|
|
507
485
|
return data;
|
|
508
486
|
});
|
|
509
487
|
this.getTokenHistoryDict = ({ chainId, ids, timeAt, }) => __awaiter(this, void 0, void 0, function* () {
|
|
510
|
-
const { data } = yield this.request.get('/v1/token/history_price_dict',
|
|
488
|
+
const { data } = yield this.request.get('/v1/token/history_price_dict', {
|
|
489
|
+
params: {
|
|
511
490
|
chain_id: chainId,
|
|
512
491
|
ids,
|
|
513
492
|
time_at: timeAt,
|
|
514
|
-
}
|
|
493
|
+
},
|
|
494
|
+
});
|
|
515
495
|
return data;
|
|
516
496
|
});
|
|
517
497
|
this.getNetCurve = (addr) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -527,7 +507,9 @@ export class OpenApiService {
|
|
|
527
507
|
return data;
|
|
528
508
|
});
|
|
529
509
|
this.getCEXSwapQuote = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
530
|
-
const { data } = yield this.request.get('/v1/wallet/cex_swap_quote',
|
|
510
|
+
const { data } = yield this.request.get('/v1/wallet/cex_swap_quote', {
|
|
511
|
+
params,
|
|
512
|
+
});
|
|
531
513
|
return data;
|
|
532
514
|
});
|
|
533
515
|
this.getSwapTradeList = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -537,12 +519,13 @@ export class OpenApiService {
|
|
|
537
519
|
return data;
|
|
538
520
|
});
|
|
539
521
|
this.postSwap = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
540
|
-
|
|
541
|
-
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);
|
|
542
523
|
return data;
|
|
543
524
|
});
|
|
544
525
|
this.checkSlippage = (params) => __awaiter(this, void 0, void 0, function* () {
|
|
545
|
-
const { data } = yield this.request.get('/v1/wallet/check_slippage',
|
|
526
|
+
const { data } = yield this.request.get('/v1/wallet/check_slippage', {
|
|
527
|
+
params,
|
|
528
|
+
});
|
|
546
529
|
return data;
|
|
547
530
|
});
|
|
548
531
|
this.getOriginPopularityLevel = (origin) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -571,10 +554,12 @@ export class OpenApiService {
|
|
|
571
554
|
return data;
|
|
572
555
|
});
|
|
573
556
|
this.getSummarizedAssetList = (id, chain_id) => __awaiter(this, void 0, void 0, function* () {
|
|
574
|
-
const { data } = yield this.request.get('/v1/user/summarized_asset_list',
|
|
557
|
+
const { data } = yield this.request.get('/v1/user/summarized_asset_list', {
|
|
558
|
+
params: {
|
|
575
559
|
id,
|
|
576
560
|
chain_id,
|
|
577
|
-
}
|
|
561
|
+
},
|
|
562
|
+
});
|
|
578
563
|
return data;
|
|
579
564
|
});
|
|
580
565
|
this.parseTx = ({ chainId, tx, origin, addr, }) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -583,55 +568,67 @@ export class OpenApiService {
|
|
|
583
568
|
tx,
|
|
584
569
|
origin,
|
|
585
570
|
user_addr: addr,
|
|
586
|
-
}
|
|
571
|
+
});
|
|
587
572
|
return data;
|
|
588
573
|
});
|
|
589
574
|
this.isSuspiciousToken = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
590
|
-
const { data } = yield this.request.get('/v1/engine/token/is_suspicious',
|
|
575
|
+
const { data } = yield this.request.get('/v1/engine/token/is_suspicious', {
|
|
576
|
+
params: {
|
|
591
577
|
chain_id: chainId,
|
|
592
578
|
id,
|
|
593
|
-
}
|
|
579
|
+
},
|
|
580
|
+
});
|
|
594
581
|
return data;
|
|
595
582
|
});
|
|
596
583
|
this.depositCexSupport = (id, chainId, cexId) => __awaiter(this, void 0, void 0, function* () {
|
|
597
|
-
const { data } = yield this.request.get('/v1/engine/token/deposit_cex_support',
|
|
584
|
+
const { data } = yield this.request.get('/v1/engine/token/deposit_cex_support', {
|
|
585
|
+
params: {
|
|
598
586
|
chain_id: chainId,
|
|
599
587
|
id,
|
|
600
588
|
cex_id: cexId,
|
|
601
|
-
}
|
|
589
|
+
},
|
|
590
|
+
});
|
|
602
591
|
return data;
|
|
603
592
|
});
|
|
604
593
|
// Token 可充值的 CEX 列表
|
|
605
594
|
this.depositCexList = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
606
|
-
const { data } = yield this.request.get('/v1/engine/token/deposit_cex_list',
|
|
595
|
+
const { data } = yield this.request.get('/v1/engine/token/deposit_cex_list', {
|
|
596
|
+
params: {
|
|
607
597
|
chain_id: chainId,
|
|
608
598
|
id,
|
|
609
|
-
}
|
|
599
|
+
},
|
|
600
|
+
});
|
|
610
601
|
return data;
|
|
611
602
|
});
|
|
612
603
|
// 合约信用分
|
|
613
604
|
this.getContractCredit = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
614
|
-
const { data } = yield this.request.get('/v1/engine/contract/credit',
|
|
605
|
+
const { data } = yield this.request.get('/v1/engine/contract/credit', {
|
|
606
|
+
params: {
|
|
615
607
|
chain_id: chainId,
|
|
616
608
|
id,
|
|
617
|
-
}
|
|
609
|
+
},
|
|
610
|
+
});
|
|
618
611
|
return data;
|
|
619
612
|
});
|
|
620
613
|
// 是否跟地址交互过
|
|
621
614
|
this.hasInteraction = (addr, chainId, contractId) => __awaiter(this, void 0, void 0, function* () {
|
|
622
|
-
const { data } = yield this.request.get('/v1/engine/contract/has_interaction',
|
|
615
|
+
const { data } = yield this.request.get('/v1/engine/contract/has_interaction', {
|
|
616
|
+
params: {
|
|
623
617
|
chain_id: chainId,
|
|
624
618
|
user_addr: addr,
|
|
625
619
|
contract_id: contractId,
|
|
626
|
-
}
|
|
620
|
+
},
|
|
621
|
+
});
|
|
627
622
|
return data;
|
|
628
623
|
});
|
|
629
624
|
// 授权风险敞口
|
|
630
625
|
this.tokenApproveExposure = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
631
|
-
const { data } = yield this.request.get('/v1/engine/contract/token_approval_exposure',
|
|
626
|
+
const { data } = yield this.request.get('/v1/engine/contract/token_approval_exposure', {
|
|
627
|
+
params: {
|
|
632
628
|
chain_id: chainId,
|
|
633
629
|
id,
|
|
634
|
-
}
|
|
630
|
+
},
|
|
631
|
+
});
|
|
635
632
|
return data;
|
|
636
633
|
});
|
|
637
634
|
// 地址描述
|
|
@@ -645,18 +642,22 @@ export class OpenApiService {
|
|
|
645
642
|
});
|
|
646
643
|
// 两个地址是否发生过转账
|
|
647
644
|
this.hasTransfer = (chainId, from, to) => __awaiter(this, void 0, void 0, function* () {
|
|
648
|
-
const { data } = yield this.request.get('/v1/engine/addr/has_transfer',
|
|
645
|
+
const { data } = yield this.request.get('/v1/engine/addr/has_transfer', {
|
|
646
|
+
params: {
|
|
649
647
|
chain_id: chainId,
|
|
650
648
|
from_addr: from,
|
|
651
649
|
to_addr: to,
|
|
652
|
-
}
|
|
650
|
+
},
|
|
651
|
+
});
|
|
653
652
|
return data;
|
|
654
653
|
});
|
|
655
654
|
this.isTokenContract = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
|
|
656
|
-
const { data } = yield this.request.get('/v1/engine/contract/is_token',
|
|
655
|
+
const { data } = yield this.request.get('/v1/engine/contract/is_token', {
|
|
656
|
+
params: {
|
|
657
657
|
id,
|
|
658
658
|
chain_id: chainId,
|
|
659
|
-
}
|
|
659
|
+
},
|
|
660
|
+
});
|
|
660
661
|
return data;
|
|
661
662
|
});
|
|
662
663
|
this.addrUsedChainList = (id) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -666,15 +667,21 @@ export class OpenApiService {
|
|
|
666
667
|
return data;
|
|
667
668
|
});
|
|
668
669
|
this.getTokenNFTExposure = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
|
|
669
|
-
const { data } = yield this.request.get('/v1/engine/contract/top_nft_approval_exposure',
|
|
670
|
+
const { data } = yield this.request.get('/v1/engine/contract/top_nft_approval_exposure', {
|
|
671
|
+
params: { chain_id: chainId, id },
|
|
672
|
+
});
|
|
670
673
|
return data;
|
|
671
674
|
});
|
|
672
675
|
this.getCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
|
|
673
|
-
const { data } = yield this.request.get('/v1/engine/collection',
|
|
676
|
+
const { data } = yield this.request.get('/v1/engine/collection', {
|
|
677
|
+
params: { chain_id: chainId, id },
|
|
678
|
+
});
|
|
674
679
|
return data;
|
|
675
680
|
});
|
|
676
681
|
this.isSuspiciousCollection = (chainId, id) => __awaiter(this, void 0, void 0, function* () {
|
|
677
|
-
const { data } = yield this.request.get('/v1/engine/collection/is_suspicious',
|
|
682
|
+
const { data } = yield this.request.get('/v1/engine/collection/is_suspicious', {
|
|
683
|
+
params: { chain_id: chainId, id },
|
|
684
|
+
});
|
|
678
685
|
return data;
|
|
679
686
|
});
|
|
680
687
|
this.isOriginVerified = (origin) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -700,11 +707,21 @@ export class OpenApiService {
|
|
|
700
707
|
return data;
|
|
701
708
|
});
|
|
702
709
|
this.collectionList = ({ id, chainId, isAll, }) => __awaiter(this, void 0, void 0, function* () {
|
|
703
|
-
const { data } = yield this.request.get('/v1/user/collection_list',
|
|
710
|
+
const { data } = yield this.request.get('/v1/user/collection_list', {
|
|
711
|
+
params: {
|
|
704
712
|
id,
|
|
705
713
|
chain_id: chainId,
|
|
706
714
|
is_all: isAll,
|
|
707
|
-
}
|
|
715
|
+
},
|
|
716
|
+
});
|
|
717
|
+
return data;
|
|
718
|
+
});
|
|
719
|
+
this.gasPriceStats = (chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
720
|
+
const { data } = yield this.request.get('/v1/wallet/gas_price_stats', {
|
|
721
|
+
params: {
|
|
722
|
+
chain_id: chainId,
|
|
723
|
+
},
|
|
724
|
+
});
|
|
708
725
|
return data;
|
|
709
726
|
});
|
|
710
727
|
this.store = store;
|
package/dist/types.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { CHAINS } from '@debank/common';
|
|
2
2
|
import { AxiosRequestConfig } from 'axios';
|
|
3
3
|
export declare const getChain: (chainId?: string) => import("@debank/common").Chain | null;
|
|
4
|
-
export declare const getChainByNetwork: (network?: string | number) => import("@debank/common").Chain | null;
|
|
5
4
|
export declare const INITIAL_OPENAPI_URL = "https://api.rabby.io";
|
|
6
|
-
export declare const INITIAL_TESTNET_OPENAPI_URL = "https://api.testnet.rabby.io/";
|
|
7
5
|
export { CHAINS };
|
|
8
6
|
export declare const SIGN_HDS: readonly ["x-api-ts", "x-api-nonce", "x-api-ver", "x-api-sign"];
|
|
9
7
|
export declare function genSignParams(config: AxiosRequestConfig): {
|
package/dist/utils.js
CHANGED
|
@@ -8,16 +8,7 @@ export const getChain = (chainId) => {
|
|
|
8
8
|
}
|
|
9
9
|
return chainsDict[chainId];
|
|
10
10
|
};
|
|
11
|
-
const chainNetworkDict = keyBy(CHAINS, 'network');
|
|
12
|
-
export const getChainByNetwork = (network) => {
|
|
13
|
-
if (!network) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
network = network.toString();
|
|
17
|
-
return chainNetworkDict[network.startsWith('0x') ? +network : network];
|
|
18
|
-
};
|
|
19
11
|
export const INITIAL_OPENAPI_URL = 'https://api.rabby.io';
|
|
20
|
-
export const INITIAL_TESTNET_OPENAPI_URL = 'https://api.testnet.rabby.io/';
|
|
21
12
|
export { CHAINS };
|
|
22
13
|
export const SIGN_HDS = [
|
|
23
14
|
'x-api-ts',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rabby-wallet/rabby-api",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@babel/preset-env": "^7.19.1",
|
|
21
|
-
"@debank/common": "^0.3.
|
|
21
|
+
"@debank/common": "^0.3.5",
|
|
22
22
|
"@types/jest": "^29.0.3",
|
|
23
23
|
"@types/lodash": "^4.14.185",
|
|
24
24
|
"@types/node": "^18.7.18",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"prepare": "husky install"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@debank/common": "^0.3.
|
|
46
|
+
"@debank/common": "^0.3.5"
|
|
47
47
|
},
|
|
48
48
|
"author": "",
|
|
49
49
|
"description": "",
|