@rabby-wallet/rabby-api 0.7.25 → 0.7.27-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 +6 -2
- package/dist/index.js +19 -27
- package/dist/types.d.ts +20 -1
- package/package.json +1 -1
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 } 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 } from './types';
|
|
5
5
|
interface OpenApiStore {
|
|
6
6
|
host: string;
|
|
7
7
|
testnetHost?: string;
|
|
@@ -18,9 +18,12 @@ declare type ApiOptions<V extends VersionPrefix | void = VersionPrefix> = {
|
|
|
18
18
|
restfulPrefix?: V;
|
|
19
19
|
};
|
|
20
20
|
export declare class OpenApiService {
|
|
21
|
-
#private;
|
|
22
21
|
store: OpenApiStore;
|
|
23
22
|
request: RateLimitedAxiosInstance;
|
|
23
|
+
private _adapter?;
|
|
24
|
+
private _plugin;
|
|
25
|
+
private _clientName;
|
|
26
|
+
private _clientVersion;
|
|
24
27
|
constructor({ store, plugin, adapter, clientName, clientVersion, }: Options);
|
|
25
28
|
setHost: (host: string) => Promise<void>;
|
|
26
29
|
setHostSync: (host: string) => void;
|
|
@@ -299,6 +302,7 @@ export declare class OpenApiService {
|
|
|
299
302
|
tokenApproveTrustValue: (id: string, chainId: string) => Promise<{
|
|
300
303
|
usd_value: number;
|
|
301
304
|
}>;
|
|
305
|
+
getContractInfo: (id: string, chainId: string) => Promise<ContractInfo | null>;
|
|
302
306
|
addrDesc: (id: string) => Promise<AddrDescResponse>;
|
|
303
307
|
hasTransfer: (chainId: string, from: string, to: string) => Promise<{
|
|
304
308
|
has_transfer: boolean;
|
package/dist/index.js
CHANGED
|
@@ -7,18 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
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 _OpenApiService_adapter, _OpenApiService_plugin, _OpenApiService_clientName, _OpenApiService_clientVersion;
|
|
22
10
|
import axios from 'axios';
|
|
23
11
|
import rateLimit from 'axios-rate-limit';
|
|
24
12
|
import { ethErrors } from 'eth-rpc-errors';
|
|
@@ -30,10 +18,6 @@ export class OpenApiService {
|
|
|
30
18
|
constructor(_a) {
|
|
31
19
|
var _b;
|
|
32
20
|
var { store, plugin, adapter, clientName = 'Rabby', clientVersion = (_b = process.env.release) !== null && _b !== void 0 ? _b : '0.0.0', } = _a;
|
|
33
|
-
_OpenApiService_adapter.set(this, void 0);
|
|
34
|
-
_OpenApiService_plugin.set(this, void 0);
|
|
35
|
-
_OpenApiService_clientName.set(this, void 0);
|
|
36
|
-
_OpenApiService_clientVersion.set(this, void 0);
|
|
37
21
|
this.setHost = (host) => __awaiter(this, void 0, void 0, function* () {
|
|
38
22
|
this.store.host = host;
|
|
39
23
|
yield this.init();
|
|
@@ -57,7 +41,7 @@ export class OpenApiService {
|
|
|
57
41
|
this.init = (options) => __awaiter(this, void 0, void 0, function* () {
|
|
58
42
|
var _c, _d;
|
|
59
43
|
options = typeof options === 'string' ? { webHf: options } : options;
|
|
60
|
-
yield ((_d = (_c =
|
|
44
|
+
yield ((_d = (_c = this._plugin).onInitiateAsync) === null || _d === void 0 ? void 0 : _d.call(_c, Object.assign({}, options)));
|
|
61
45
|
this.initSync(Object.assign({}, options));
|
|
62
46
|
});
|
|
63
47
|
this.asyncJob = (url, options) => {
|
|
@@ -663,6 +647,15 @@ export class OpenApiService {
|
|
|
663
647
|
});
|
|
664
648
|
return data;
|
|
665
649
|
});
|
|
650
|
+
this.getContractInfo = (id, chainId) => __awaiter(this, void 0, void 0, function* () {
|
|
651
|
+
const { data } = yield this.request.get('/v1/contract', {
|
|
652
|
+
params: {
|
|
653
|
+
chain_id: chainId,
|
|
654
|
+
id,
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
return data.contract;
|
|
658
|
+
});
|
|
666
659
|
// 地址描述
|
|
667
660
|
this.addrDesc = (id) => __awaiter(this, void 0, void 0, function* () {
|
|
668
661
|
const { data } = yield this.request.get('/v1/engine/addr/desc', {
|
|
@@ -1160,26 +1153,26 @@ export class OpenApiService {
|
|
|
1160
1153
|
else {
|
|
1161
1154
|
this.store = store;
|
|
1162
1155
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1156
|
+
this._plugin = plugin;
|
|
1157
|
+
this._adapter = adapter;
|
|
1158
|
+
this._clientName = clientName;
|
|
1159
|
+
this._clientVersion = clientVersion;
|
|
1167
1160
|
}
|
|
1168
1161
|
initSync(options) {
|
|
1169
1162
|
var _a, _b;
|
|
1170
|
-
(_b = (_a =
|
|
1163
|
+
(_b = (_a = this._plugin).onInitiate) === null || _b === void 0 ? void 0 : _b.call(_a, Object.assign({}, options));
|
|
1171
1164
|
const request = axios.create({
|
|
1172
1165
|
baseURL: this.store.host,
|
|
1173
|
-
adapter:
|
|
1166
|
+
adapter: this._adapter,
|
|
1174
1167
|
headers: {
|
|
1175
|
-
'X-Client':
|
|
1176
|
-
'X-Version':
|
|
1168
|
+
'X-Client': this._clientName,
|
|
1169
|
+
'X-Version': this._clientVersion,
|
|
1177
1170
|
},
|
|
1178
1171
|
});
|
|
1179
1172
|
// sign after rateLimit, timestamp is the latest
|
|
1180
1173
|
request.interceptors.request.use((config) => __awaiter(this, void 0, void 0, function* () {
|
|
1181
1174
|
const { method, url, params } = genSignParams(config);
|
|
1182
|
-
yield
|
|
1175
|
+
yield this._plugin.onSignRequest({
|
|
1183
1176
|
axiosRequestConfig: config,
|
|
1184
1177
|
parsed: { method, url, params },
|
|
1185
1178
|
});
|
|
@@ -1210,4 +1203,3 @@ export class OpenApiService {
|
|
|
1210
1203
|
this._mountMethods();
|
|
1211
1204
|
}
|
|
1212
1205
|
}
|
|
1213
|
-
_OpenApiService_adapter = new WeakMap(), _OpenApiService_plugin = new WeakMap(), _OpenApiService_clientName = new WeakMap(), _OpenApiService_clientVersion = new WeakMap();
|
package/dist/types.d.ts
CHANGED
|
@@ -796,7 +796,6 @@ export interface Cex {
|
|
|
796
796
|
}
|
|
797
797
|
export interface ContractCredit {
|
|
798
798
|
value: null | number;
|
|
799
|
-
popularity_level: 'very_low' | 'low' | 'medium' | 'high';
|
|
800
799
|
rank_at: number | null;
|
|
801
800
|
}
|
|
802
801
|
export interface ContractDesc {
|
|
@@ -1320,4 +1319,24 @@ export interface DbkBridgeHistoryItem {
|
|
|
1320
1319
|
from_token_amount: number;
|
|
1321
1320
|
from_token_id: string;
|
|
1322
1321
|
}
|
|
1322
|
+
export interface ContractInfo {
|
|
1323
|
+
id: string;
|
|
1324
|
+
credit: ContractCredit;
|
|
1325
|
+
is_token: boolean;
|
|
1326
|
+
token_approval_exposure: number;
|
|
1327
|
+
top_nft_approval_exposure: number;
|
|
1328
|
+
spend_usd_value: number;
|
|
1329
|
+
top_nft_spend_usd_value: number;
|
|
1330
|
+
create_at: number;
|
|
1331
|
+
name: string | null;
|
|
1332
|
+
protocol: {
|
|
1333
|
+
id: string;
|
|
1334
|
+
logo_url: string;
|
|
1335
|
+
name: string;
|
|
1336
|
+
} | null;
|
|
1337
|
+
is_danger: {
|
|
1338
|
+
auto: null | boolean;
|
|
1339
|
+
edit: null | boolean;
|
|
1340
|
+
};
|
|
1341
|
+
}
|
|
1323
1342
|
export {};
|