@0xsequence/indexer 2.3.16 → 2.3.18
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/0xsequence-indexer.cjs.d.ts +2 -2
- package/dist/0xsequence-indexer.cjs.js +15 -6
- package/package.json +1 -1
- package/dist/0xsequence-indexer.cjs.dev.js +0 -1883
- package/dist/0xsequence-indexer.cjs.prod.js +0 -1883
- package/dist/0xsequence-indexer.esm.js +0 -1820
- package/dist/declarations/src/index.d.ts +0 -16
- package/dist/declarations/src/indexer.gen.d.ts +0 -994
- package/dist/declarations/src/indexergw.gen.d.ts +0 -773
|
@@ -1,1883 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _extends() {
|
|
6
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
7
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
8
|
-
var t = arguments[e];
|
|
9
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
10
|
-
}
|
|
11
|
-
return n;
|
|
12
|
-
}, _extends.apply(null, arguments);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* eslint-disable */
|
|
16
|
-
// sequence-indexer v0.4.0 f9220b18008af826218980db21a68ec39989fb80
|
|
17
|
-
// --
|
|
18
|
-
// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT.
|
|
19
|
-
//
|
|
20
|
-
// webrpc-gen -schema=indexer.ridl -service=Indexer -target=typescript -client -out=./clients/indexer.gen.ts
|
|
21
|
-
|
|
22
|
-
const WebrpcHeader$1 = 'Webrpc';
|
|
23
|
-
const WebrpcHeaderValue$1 = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0';
|
|
24
|
-
|
|
25
|
-
// WebRPC description and code-gen version
|
|
26
|
-
const WebRPCVersion$1 = 'v1';
|
|
27
|
-
|
|
28
|
-
// Schema version of your RIDL schema
|
|
29
|
-
const WebRPCSchemaVersion$1 = 'v0.4.0';
|
|
30
|
-
|
|
31
|
-
// Schema hash generated from your RIDL schema
|
|
32
|
-
const WebRPCSchemaHash$1 = 'f9220b18008af826218980db21a68ec39989fb80';
|
|
33
|
-
function VersionFromHeader$1(headers) {
|
|
34
|
-
const headerValue = headers.get(WebrpcHeader$1);
|
|
35
|
-
if (!headerValue) {
|
|
36
|
-
return {
|
|
37
|
-
webrpcGenVersion: '',
|
|
38
|
-
codeGenName: '',
|
|
39
|
-
codeGenVersion: '',
|
|
40
|
-
schemaName: '',
|
|
41
|
-
schemaVersion: ''
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return parseWebrpcGenVersions$1(headerValue);
|
|
45
|
-
}
|
|
46
|
-
function parseWebrpcGenVersions$1(header) {
|
|
47
|
-
const versions = header.split(';');
|
|
48
|
-
if (versions.length < 3) {
|
|
49
|
-
return {
|
|
50
|
-
webrpcGenVersion: '',
|
|
51
|
-
codeGenName: '',
|
|
52
|
-
codeGenVersion: '',
|
|
53
|
-
schemaName: '',
|
|
54
|
-
schemaVersion: ''
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const [_, webrpcGenVersion] = versions[0].split('@');
|
|
58
|
-
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
59
|
-
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
60
|
-
return {
|
|
61
|
-
webrpcGenVersion,
|
|
62
|
-
codeGenName,
|
|
63
|
-
codeGenVersion,
|
|
64
|
-
schemaName,
|
|
65
|
-
schemaVersion
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//
|
|
70
|
-
// Types
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
let ResourceStatus$1 = /*#__PURE__*/function (ResourceStatus) {
|
|
74
|
-
ResourceStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
|
|
75
|
-
ResourceStatus["REFRESHING"] = "REFRESHING";
|
|
76
|
-
ResourceStatus["AVAILABLE"] = "AVAILABLE";
|
|
77
|
-
return ResourceStatus;
|
|
78
|
-
}({});
|
|
79
|
-
let ContractType$1 = /*#__PURE__*/function (ContractType) {
|
|
80
|
-
ContractType["UNKNOWN"] = "UNKNOWN";
|
|
81
|
-
ContractType["NATIVE"] = "NATIVE";
|
|
82
|
-
ContractType["ERC20"] = "ERC20";
|
|
83
|
-
ContractType["ERC721"] = "ERC721";
|
|
84
|
-
ContractType["ERC1155"] = "ERC1155";
|
|
85
|
-
ContractType["SEQUENCE_WALLET"] = "SEQUENCE_WALLET";
|
|
86
|
-
ContractType["ERC20_BRIDGE"] = "ERC20_BRIDGE";
|
|
87
|
-
ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE";
|
|
88
|
-
ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE";
|
|
89
|
-
ContractType["SEQ_MARKETPLACE"] = "SEQ_MARKETPLACE";
|
|
90
|
-
return ContractType;
|
|
91
|
-
}({});
|
|
92
|
-
let EventLogType$1 = /*#__PURE__*/function (EventLogType) {
|
|
93
|
-
EventLogType["UNKNOWN"] = "UNKNOWN";
|
|
94
|
-
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
|
|
95
|
-
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
|
|
96
|
-
return EventLogType;
|
|
97
|
-
}({});
|
|
98
|
-
let EventLogDataType$1 = /*#__PURE__*/function (EventLogDataType) {
|
|
99
|
-
EventLogDataType["EVENT"] = "EVENT";
|
|
100
|
-
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
|
|
101
|
-
EventLogDataType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER";
|
|
102
|
-
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
|
|
103
|
-
return EventLogDataType;
|
|
104
|
-
}({});
|
|
105
|
-
let OrderStatus$1 = /*#__PURE__*/function (OrderStatus) {
|
|
106
|
-
OrderStatus["OPEN"] = "OPEN";
|
|
107
|
-
OrderStatus["CLOSED"] = "CLOSED";
|
|
108
|
-
OrderStatus["CANCELLED"] = "CANCELLED";
|
|
109
|
-
return OrderStatus;
|
|
110
|
-
}({});
|
|
111
|
-
let TxnTransferType$1 = /*#__PURE__*/function (TxnTransferType) {
|
|
112
|
-
TxnTransferType["UNKNOWN"] = "UNKNOWN";
|
|
113
|
-
TxnTransferType["SEND"] = "SEND";
|
|
114
|
-
TxnTransferType["RECEIVE"] = "RECEIVE";
|
|
115
|
-
return TxnTransferType;
|
|
116
|
-
}({});
|
|
117
|
-
let TransactionStatus$1 = /*#__PURE__*/function (TransactionStatus) {
|
|
118
|
-
TransactionStatus["FAILED"] = "FAILED";
|
|
119
|
-
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
|
120
|
-
return TransactionStatus;
|
|
121
|
-
}({});
|
|
122
|
-
let TransactionType$1 = /*#__PURE__*/function (TransactionType) {
|
|
123
|
-
TransactionType["LegacyTxnType"] = "LegacyTxnType";
|
|
124
|
-
TransactionType["AccessListTxnType"] = "AccessListTxnType";
|
|
125
|
-
TransactionType["DynamicFeeTxnType"] = "DynamicFeeTxnType";
|
|
126
|
-
return TransactionType;
|
|
127
|
-
}({});
|
|
128
|
-
let SortOrder$1 = /*#__PURE__*/function (SortOrder) {
|
|
129
|
-
SortOrder["DESC"] = "DESC";
|
|
130
|
-
SortOrder["ASC"] = "ASC";
|
|
131
|
-
return SortOrder;
|
|
132
|
-
}({});
|
|
133
|
-
let ContractVerificationStatus$1 = /*#__PURE__*/function (ContractVerificationStatus) {
|
|
134
|
-
ContractVerificationStatus["VERIFIED"] = "VERIFIED";
|
|
135
|
-
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED";
|
|
136
|
-
ContractVerificationStatus["ALL"] = "ALL";
|
|
137
|
-
return ContractVerificationStatus;
|
|
138
|
-
}({});
|
|
139
|
-
let NetworkType$1 = /*#__PURE__*/function (NetworkType) {
|
|
140
|
-
NetworkType["MAINNETS"] = "MAINNETS";
|
|
141
|
-
NetworkType["TESTNETS"] = "TESTNETS";
|
|
142
|
-
NetworkType["ALL"] = "ALL";
|
|
143
|
-
return NetworkType;
|
|
144
|
-
}({});
|
|
145
|
-
//
|
|
146
|
-
// Client
|
|
147
|
-
//
|
|
148
|
-
class Indexer {
|
|
149
|
-
constructor(hostname, fetch) {
|
|
150
|
-
this.hostname = void 0;
|
|
151
|
-
this.fetch = void 0;
|
|
152
|
-
this.path = '/rpc/Indexer/';
|
|
153
|
-
this.ping = (headers, signal) => {
|
|
154
|
-
return this.fetch(this.url('Ping'), createHTTPRequest$1({}, headers, signal)).then(res => {
|
|
155
|
-
return buildResponse$1(res).then(_data => {
|
|
156
|
-
return {
|
|
157
|
-
status: _data.status
|
|
158
|
-
};
|
|
159
|
-
});
|
|
160
|
-
}, error => {
|
|
161
|
-
throw WebrpcRequestFailedError$1.new({
|
|
162
|
-
cause: `fetch(): ${error.message || ''}`
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
this.version = (headers, signal) => {
|
|
167
|
-
return this.fetch(this.url('Version'), createHTTPRequest$1({}, headers, signal)).then(res => {
|
|
168
|
-
return buildResponse$1(res).then(_data => {
|
|
169
|
-
return {
|
|
170
|
-
version: _data.version
|
|
171
|
-
};
|
|
172
|
-
});
|
|
173
|
-
}, error => {
|
|
174
|
-
throw WebrpcRequestFailedError$1.new({
|
|
175
|
-
cause: `fetch(): ${error.message || ''}`
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
this.runtimeStatus = (headers, signal) => {
|
|
180
|
-
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest$1({}, headers, signal)).then(res => {
|
|
181
|
-
return buildResponse$1(res).then(_data => {
|
|
182
|
-
return {
|
|
183
|
-
status: _data.status
|
|
184
|
-
};
|
|
185
|
-
});
|
|
186
|
-
}, error => {
|
|
187
|
-
throw WebrpcRequestFailedError$1.new({
|
|
188
|
-
cause: `fetch(): ${error.message || ''}`
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
this.getChainID = (headers, signal) => {
|
|
193
|
-
return this.fetch(this.url('GetChainID'), createHTTPRequest$1({}, headers, signal)).then(res => {
|
|
194
|
-
return buildResponse$1(res).then(_data => {
|
|
195
|
-
return {
|
|
196
|
-
chainID: _data.chainID
|
|
197
|
-
};
|
|
198
|
-
});
|
|
199
|
-
}, error => {
|
|
200
|
-
throw WebrpcRequestFailedError$1.new({
|
|
201
|
-
cause: `fetch(): ${error.message || ''}`
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
};
|
|
205
|
-
this.getEtherBalance = (args, headers, signal) => {
|
|
206
|
-
return this.fetch(this.url('GetEtherBalance'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
207
|
-
return buildResponse$1(res).then(_data => {
|
|
208
|
-
return {
|
|
209
|
-
balance: _data.balance
|
|
210
|
-
};
|
|
211
|
-
});
|
|
212
|
-
}, error => {
|
|
213
|
-
throw WebrpcRequestFailedError$1.new({
|
|
214
|
-
cause: `fetch(): ${error.message || ''}`
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
this.getNativeTokenBalance = (args, headers, signal) => {
|
|
219
|
-
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
220
|
-
return buildResponse$1(res).then(_data => {
|
|
221
|
-
return {
|
|
222
|
-
balance: _data.balance
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
}, error => {
|
|
226
|
-
throw WebrpcRequestFailedError$1.new({
|
|
227
|
-
cause: `fetch(): ${error.message || ''}`
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
this.getTokenBalancesSummary = (args, headers, signal) => {
|
|
232
|
-
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
233
|
-
return buildResponse$1(res).then(_data => {
|
|
234
|
-
return {
|
|
235
|
-
page: _data.page,
|
|
236
|
-
nativeBalances: _data.nativeBalances,
|
|
237
|
-
balances: _data.balances
|
|
238
|
-
};
|
|
239
|
-
});
|
|
240
|
-
}, error => {
|
|
241
|
-
throw WebrpcRequestFailedError$1.new({
|
|
242
|
-
cause: `fetch(): ${error.message || ''}`
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
this.getTokenBalancesDetails = (args, headers, signal) => {
|
|
247
|
-
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
248
|
-
return buildResponse$1(res).then(_data => {
|
|
249
|
-
return {
|
|
250
|
-
page: _data.page,
|
|
251
|
-
nativeBalances: _data.nativeBalances,
|
|
252
|
-
balances: _data.balances
|
|
253
|
-
};
|
|
254
|
-
});
|
|
255
|
-
}, error => {
|
|
256
|
-
throw WebrpcRequestFailedError$1.new({
|
|
257
|
-
cause: `fetch(): ${error.message || ''}`
|
|
258
|
-
});
|
|
259
|
-
});
|
|
260
|
-
};
|
|
261
|
-
this.getTokenBalancesByContract = (args, headers, signal) => {
|
|
262
|
-
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
263
|
-
return buildResponse$1(res).then(_data => {
|
|
264
|
-
return {
|
|
265
|
-
page: _data.page,
|
|
266
|
-
balances: _data.balances
|
|
267
|
-
};
|
|
268
|
-
});
|
|
269
|
-
}, error => {
|
|
270
|
-
throw WebrpcRequestFailedError$1.new({
|
|
271
|
-
cause: `fetch(): ${error.message || ''}`
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
this.getTokenBalances = (args, headers, signal) => {
|
|
276
|
-
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
277
|
-
return buildResponse$1(res).then(_data => {
|
|
278
|
-
return {
|
|
279
|
-
page: _data.page,
|
|
280
|
-
balances: _data.balances
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
}, error => {
|
|
284
|
-
throw WebrpcRequestFailedError$1.new({
|
|
285
|
-
cause: `fetch(): ${error.message || ''}`
|
|
286
|
-
});
|
|
287
|
-
});
|
|
288
|
-
};
|
|
289
|
-
this.getTokenSupplies = (args, headers, signal) => {
|
|
290
|
-
return this.fetch(this.url('GetTokenSupplies'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
291
|
-
return buildResponse$1(res).then(_data => {
|
|
292
|
-
return {
|
|
293
|
-
page: _data.page,
|
|
294
|
-
contractType: _data.contractType,
|
|
295
|
-
tokenIDs: _data.tokenIDs
|
|
296
|
-
};
|
|
297
|
-
});
|
|
298
|
-
}, error => {
|
|
299
|
-
throw WebrpcRequestFailedError$1.new({
|
|
300
|
-
cause: `fetch(): ${error.message || ''}`
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
};
|
|
304
|
-
this.getTokenSuppliesMap = (args, headers, signal) => {
|
|
305
|
-
return this.fetch(this.url('GetTokenSuppliesMap'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
306
|
-
return buildResponse$1(res).then(_data => {
|
|
307
|
-
return {
|
|
308
|
-
supplies: _data.supplies
|
|
309
|
-
};
|
|
310
|
-
});
|
|
311
|
-
}, error => {
|
|
312
|
-
throw WebrpcRequestFailedError$1.new({
|
|
313
|
-
cause: `fetch(): ${error.message || ''}`
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
};
|
|
317
|
-
this.getTokenIDs = (args, headers, signal) => {
|
|
318
|
-
return this.fetch(this.url('GetTokenIDs'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
319
|
-
return buildResponse$1(res).then(_data => {
|
|
320
|
-
return {
|
|
321
|
-
page: _data.page,
|
|
322
|
-
contractType: _data.contractType,
|
|
323
|
-
tokenIDs: _data.tokenIDs
|
|
324
|
-
};
|
|
325
|
-
});
|
|
326
|
-
}, error => {
|
|
327
|
-
throw WebrpcRequestFailedError$1.new({
|
|
328
|
-
cause: `fetch(): ${error.message || ''}`
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
};
|
|
332
|
-
this.getTokenIDRanges = (args, headers, signal) => {
|
|
333
|
-
return this.fetch(this.url('GetTokenIDRanges'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
334
|
-
return buildResponse$1(res).then(_data => {
|
|
335
|
-
return {
|
|
336
|
-
contractType: _data.contractType,
|
|
337
|
-
tokenIDRanges: _data.tokenIDRanges,
|
|
338
|
-
moreRanges: _data.moreRanges
|
|
339
|
-
};
|
|
340
|
-
});
|
|
341
|
-
}, error => {
|
|
342
|
-
throw WebrpcRequestFailedError$1.new({
|
|
343
|
-
cause: `fetch(): ${error.message || ''}`
|
|
344
|
-
});
|
|
345
|
-
});
|
|
346
|
-
};
|
|
347
|
-
this.getBalanceUpdates = (args, headers, signal) => {
|
|
348
|
-
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
349
|
-
return buildResponse$1(res).then(_data => {
|
|
350
|
-
return {
|
|
351
|
-
page: _data.page,
|
|
352
|
-
balances: _data.balances
|
|
353
|
-
};
|
|
354
|
-
});
|
|
355
|
-
}, error => {
|
|
356
|
-
throw WebrpcRequestFailedError$1.new({
|
|
357
|
-
cause: `fetch(): ${error.message || ''}`
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
};
|
|
361
|
-
this.getTransactionHistory = (args, headers, signal) => {
|
|
362
|
-
return this.fetch(this.url('GetTransactionHistory'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
363
|
-
return buildResponse$1(res).then(_data => {
|
|
364
|
-
return {
|
|
365
|
-
page: _data.page,
|
|
366
|
-
transactions: _data.transactions
|
|
367
|
-
};
|
|
368
|
-
});
|
|
369
|
-
}, error => {
|
|
370
|
-
throw WebrpcRequestFailedError$1.new({
|
|
371
|
-
cause: `fetch(): ${error.message || ''}`
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
this.fetchTransactionReceipt = (args, headers, signal) => {
|
|
376
|
-
return this.fetch(this.url('FetchTransactionReceipt'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
377
|
-
return buildResponse$1(res).then(_data => {
|
|
378
|
-
return {
|
|
379
|
-
receipt: _data.receipt
|
|
380
|
-
};
|
|
381
|
-
});
|
|
382
|
-
}, error => {
|
|
383
|
-
throw WebrpcRequestFailedError$1.new({
|
|
384
|
-
cause: `fetch(): ${error.message || ''}`
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
};
|
|
388
|
-
this.fetchTransactionReceiptWithFilter = (args, headers, signal) => {
|
|
389
|
-
return this.fetch(this.url('FetchTransactionReceiptWithFilter'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
390
|
-
return buildResponse$1(res).then(_data => {
|
|
391
|
-
return {
|
|
392
|
-
receipt: _data.receipt
|
|
393
|
-
};
|
|
394
|
-
});
|
|
395
|
-
}, error => {
|
|
396
|
-
throw WebrpcRequestFailedError$1.new({
|
|
397
|
-
cause: `fetch(): ${error.message || ''}`
|
|
398
|
-
});
|
|
399
|
-
});
|
|
400
|
-
};
|
|
401
|
-
this.subscribeReceipts = (args, options) => {
|
|
402
|
-
const _fetch = () => this.fetch(this.url('SubscribeReceipts'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) {
|
|
403
|
-
await sseResponse(res, options, _fetch);
|
|
404
|
-
}, error => {
|
|
405
|
-
options.onError(error, _fetch);
|
|
406
|
-
});
|
|
407
|
-
return _fetch();
|
|
408
|
-
};
|
|
409
|
-
this.subscribeEvents = (args, options) => {
|
|
410
|
-
const _fetch = () => this.fetch(this.url('SubscribeEvents'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) {
|
|
411
|
-
await sseResponse(res, options, _fetch);
|
|
412
|
-
}, error => {
|
|
413
|
-
options.onError(error, _fetch);
|
|
414
|
-
});
|
|
415
|
-
return _fetch();
|
|
416
|
-
};
|
|
417
|
-
this.subscribeBalanceUpdates = (args, options) => {
|
|
418
|
-
const _fetch = () => this.fetch(this.url('SubscribeBalanceUpdates'), createHTTPRequest$1(args, options.headers, options.signal)).then(async function (res) {
|
|
419
|
-
await sseResponse(res, options, _fetch);
|
|
420
|
-
}, error => {
|
|
421
|
-
options.onError(error, _fetch);
|
|
422
|
-
});
|
|
423
|
-
return _fetch();
|
|
424
|
-
};
|
|
425
|
-
this.syncBalance = (args, headers, signal) => {
|
|
426
|
-
return this.fetch(this.url('SyncBalance'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
427
|
-
return buildResponse$1(res).then(_data => {
|
|
428
|
-
return {};
|
|
429
|
-
});
|
|
430
|
-
}, error => {
|
|
431
|
-
throw WebrpcRequestFailedError$1.new({
|
|
432
|
-
cause: `fetch(): ${error.message || ''}`
|
|
433
|
-
});
|
|
434
|
-
});
|
|
435
|
-
};
|
|
436
|
-
this.getAllWebhookListeners = (args, headers, signal) => {
|
|
437
|
-
return this.fetch(this.url('GetAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
438
|
-
return buildResponse$1(res).then(_data => {
|
|
439
|
-
return {
|
|
440
|
-
listeners: _data.listeners
|
|
441
|
-
};
|
|
442
|
-
});
|
|
443
|
-
}, error => {
|
|
444
|
-
throw WebrpcRequestFailedError$1.new({
|
|
445
|
-
cause: `fetch(): ${error.message || ''}`
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
};
|
|
449
|
-
this.getWebhookListener = (args, headers, signal) => {
|
|
450
|
-
return this.fetch(this.url('GetWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
451
|
-
return buildResponse$1(res).then(_data => {
|
|
452
|
-
return {
|
|
453
|
-
listener: _data.listener
|
|
454
|
-
};
|
|
455
|
-
});
|
|
456
|
-
}, error => {
|
|
457
|
-
throw WebrpcRequestFailedError$1.new({
|
|
458
|
-
cause: `fetch(): ${error.message || ''}`
|
|
459
|
-
});
|
|
460
|
-
});
|
|
461
|
-
};
|
|
462
|
-
this.addWebhookListener = (args, headers, signal) => {
|
|
463
|
-
return this.fetch(this.url('AddWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
464
|
-
return buildResponse$1(res).then(_data => {
|
|
465
|
-
return {
|
|
466
|
-
status: _data.status,
|
|
467
|
-
listener: _data.listener
|
|
468
|
-
};
|
|
469
|
-
});
|
|
470
|
-
}, error => {
|
|
471
|
-
throw WebrpcRequestFailedError$1.new({
|
|
472
|
-
cause: `fetch(): ${error.message || ''}`
|
|
473
|
-
});
|
|
474
|
-
});
|
|
475
|
-
};
|
|
476
|
-
this.updateWebhookListener = (args, headers, signal) => {
|
|
477
|
-
return this.fetch(this.url('UpdateWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
478
|
-
return buildResponse$1(res).then(_data => {
|
|
479
|
-
return {
|
|
480
|
-
status: _data.status
|
|
481
|
-
};
|
|
482
|
-
});
|
|
483
|
-
}, error => {
|
|
484
|
-
throw WebrpcRequestFailedError$1.new({
|
|
485
|
-
cause: `fetch(): ${error.message || ''}`
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
};
|
|
489
|
-
this.removeWebhookListener = (args, headers, signal) => {
|
|
490
|
-
return this.fetch(this.url('RemoveWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
491
|
-
return buildResponse$1(res).then(_data => {
|
|
492
|
-
return {
|
|
493
|
-
status: _data.status
|
|
494
|
-
};
|
|
495
|
-
});
|
|
496
|
-
}, error => {
|
|
497
|
-
throw WebrpcRequestFailedError$1.new({
|
|
498
|
-
cause: `fetch(): ${error.message || ''}`
|
|
499
|
-
});
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
this.removeAllWebhookListeners = (args, headers, signal) => {
|
|
503
|
-
return this.fetch(this.url('RemoveAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
504
|
-
return buildResponse$1(res).then(_data => {
|
|
505
|
-
return {
|
|
506
|
-
status: _data.status
|
|
507
|
-
};
|
|
508
|
-
});
|
|
509
|
-
}, error => {
|
|
510
|
-
throw WebrpcRequestFailedError$1.new({
|
|
511
|
-
cause: `fetch(): ${error.message || ''}`
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
};
|
|
515
|
-
this.toggleWebhookListener = (args, headers, signal) => {
|
|
516
|
-
return this.fetch(this.url('ToggleWebhookListener'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
517
|
-
return buildResponse$1(res).then(_data => {
|
|
518
|
-
return {
|
|
519
|
-
webhookListener: _data.webhookListener
|
|
520
|
-
};
|
|
521
|
-
});
|
|
522
|
-
}, error => {
|
|
523
|
-
throw WebrpcRequestFailedError$1.new({
|
|
524
|
-
cause: `fetch(): ${error.message || ''}`
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
};
|
|
528
|
-
this.pauseAllWebhookListeners = (args, headers, signal) => {
|
|
529
|
-
return this.fetch(this.url('PauseAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
530
|
-
return buildResponse$1(res).then(_data => {
|
|
531
|
-
return {
|
|
532
|
-
status: _data.status
|
|
533
|
-
};
|
|
534
|
-
});
|
|
535
|
-
}, error => {
|
|
536
|
-
throw WebrpcRequestFailedError$1.new({
|
|
537
|
-
cause: `fetch(): ${error.message || ''}`
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
};
|
|
541
|
-
this.resumeAllWebhookListeners = (args, headers, signal) => {
|
|
542
|
-
return this.fetch(this.url('ResumeAllWebhookListeners'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
543
|
-
return buildResponse$1(res).then(_data => {
|
|
544
|
-
return {
|
|
545
|
-
status: _data.status
|
|
546
|
-
};
|
|
547
|
-
});
|
|
548
|
-
}, error => {
|
|
549
|
-
throw WebrpcRequestFailedError$1.new({
|
|
550
|
-
cause: `fetch(): ${error.message || ''}`
|
|
551
|
-
});
|
|
552
|
-
});
|
|
553
|
-
};
|
|
554
|
-
this.getOrderbookOrders = (args, headers, signal) => {
|
|
555
|
-
return this.fetch(this.url('GetOrderbookOrders'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
556
|
-
return buildResponse$1(res).then(_data => {
|
|
557
|
-
return {
|
|
558
|
-
page: _data.page,
|
|
559
|
-
orders: _data.orders
|
|
560
|
-
};
|
|
561
|
-
});
|
|
562
|
-
}, error => {
|
|
563
|
-
throw WebrpcRequestFailedError$1.new({
|
|
564
|
-
cause: `fetch(): ${error.message || ''}`
|
|
565
|
-
});
|
|
566
|
-
});
|
|
567
|
-
};
|
|
568
|
-
this.getTopOrders = (args, headers, signal) => {
|
|
569
|
-
return this.fetch(this.url('GetTopOrders'), createHTTPRequest$1(args, headers, signal)).then(res => {
|
|
570
|
-
return buildResponse$1(res).then(_data => {
|
|
571
|
-
return {
|
|
572
|
-
orders: _data.orders
|
|
573
|
-
};
|
|
574
|
-
});
|
|
575
|
-
}, error => {
|
|
576
|
-
throw WebrpcRequestFailedError$1.new({
|
|
577
|
-
cause: `fetch(): ${error.message || ''}`
|
|
578
|
-
});
|
|
579
|
-
});
|
|
580
|
-
};
|
|
581
|
-
this.hostname = hostname.replace(/\/*$/, '');
|
|
582
|
-
this.fetch = (input, init) => fetch(input, init);
|
|
583
|
-
}
|
|
584
|
-
url(name) {
|
|
585
|
-
return this.hostname + this.path + name;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
const sseResponse = async (res, options, retryFetch) => {
|
|
589
|
-
const {
|
|
590
|
-
onMessage,
|
|
591
|
-
onOpen,
|
|
592
|
-
onClose,
|
|
593
|
-
onError
|
|
594
|
-
} = options;
|
|
595
|
-
if (!res.ok) {
|
|
596
|
-
try {
|
|
597
|
-
await buildResponse$1(res);
|
|
598
|
-
} catch (error) {
|
|
599
|
-
// @ts-ignore
|
|
600
|
-
onError(error, retryFetch);
|
|
601
|
-
}
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
if (!res.body) {
|
|
605
|
-
onError(WebrpcBadResponseError$1.new({
|
|
606
|
-
status: res.status,
|
|
607
|
-
cause: 'Invalid response, missing body'
|
|
608
|
-
}), retryFetch);
|
|
609
|
-
return;
|
|
610
|
-
}
|
|
611
|
-
onOpen && onOpen();
|
|
612
|
-
const reader = res.body.getReader();
|
|
613
|
-
const decoder = new TextDecoder();
|
|
614
|
-
let buffer = '';
|
|
615
|
-
let lastReadTime = Date.now();
|
|
616
|
-
const timeout = (10 + 1) * 1000;
|
|
617
|
-
let timeoutError = false;
|
|
618
|
-
const intervalId = setInterval(() => {
|
|
619
|
-
if (Date.now() - lastReadTime > timeout) {
|
|
620
|
-
timeoutError = true;
|
|
621
|
-
clearInterval(intervalId);
|
|
622
|
-
reader.releaseLock();
|
|
623
|
-
}
|
|
624
|
-
}, timeout);
|
|
625
|
-
while (true) {
|
|
626
|
-
let value;
|
|
627
|
-
let done;
|
|
628
|
-
try {
|
|
629
|
-
;
|
|
630
|
-
({
|
|
631
|
-
value,
|
|
632
|
-
done
|
|
633
|
-
} = await reader.read());
|
|
634
|
-
if (timeoutError) throw new Error('Timeout, no data or heartbeat received');
|
|
635
|
-
lastReadTime = Date.now();
|
|
636
|
-
buffer += decoder.decode(value, {
|
|
637
|
-
stream: true
|
|
638
|
-
});
|
|
639
|
-
} catch (error) {
|
|
640
|
-
let message = '';
|
|
641
|
-
if (error instanceof Error) {
|
|
642
|
-
message = error.message;
|
|
643
|
-
}
|
|
644
|
-
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
645
|
-
onError(WebrpcRequestFailedError$1.new({
|
|
646
|
-
message: 'AbortError',
|
|
647
|
-
cause: `AbortError: ${message}`
|
|
648
|
-
}), () => {
|
|
649
|
-
throw new Error('Abort signal cannot be used to reconnect');
|
|
650
|
-
});
|
|
651
|
-
} else {
|
|
652
|
-
onError(WebrpcStreamLostError$1.new({
|
|
653
|
-
cause: `reader.read(): ${message}`
|
|
654
|
-
}), retryFetch);
|
|
655
|
-
}
|
|
656
|
-
return;
|
|
657
|
-
}
|
|
658
|
-
let lines = buffer.split('\n');
|
|
659
|
-
for (let i = 0; i < lines.length - 1; i++) {
|
|
660
|
-
if (lines[i].length == 0) {
|
|
661
|
-
continue;
|
|
662
|
-
}
|
|
663
|
-
let data;
|
|
664
|
-
try {
|
|
665
|
-
data = JSON.parse(lines[i]);
|
|
666
|
-
if (data.hasOwnProperty('webrpcError')) {
|
|
667
|
-
const error = data.webrpcError;
|
|
668
|
-
const code = typeof error.code === 'number' ? error.code : 0;
|
|
669
|
-
onError((webrpcErrorByCode$1[code] || WebrpcError$1).new(error), retryFetch);
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
} catch (error) {
|
|
673
|
-
if (error instanceof Error && error.message === 'Abort signal cannot be used to reconnect') {
|
|
674
|
-
throw error;
|
|
675
|
-
}
|
|
676
|
-
onError(WebrpcBadResponseError$1.new({
|
|
677
|
-
status: res.status,
|
|
678
|
-
// @ts-ignore
|
|
679
|
-
cause: `JSON.parse(): ${error.message}`
|
|
680
|
-
}), retryFetch);
|
|
681
|
-
}
|
|
682
|
-
onMessage(data);
|
|
683
|
-
}
|
|
684
|
-
if (!done) {
|
|
685
|
-
buffer = lines[lines.length - 1];
|
|
686
|
-
continue;
|
|
687
|
-
}
|
|
688
|
-
onClose && onClose();
|
|
689
|
-
return;
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
const createHTTPRequest$1 = (body = {}, headers = {}, signal = null) => {
|
|
693
|
-
const reqHeaders = _extends({}, headers, {
|
|
694
|
-
'Content-Type': 'application/json'
|
|
695
|
-
});
|
|
696
|
-
reqHeaders[WebrpcHeader$1] = WebrpcHeaderValue$1;
|
|
697
|
-
return {
|
|
698
|
-
method: 'POST',
|
|
699
|
-
headers: reqHeaders,
|
|
700
|
-
body: JSON.stringify(body || {}),
|
|
701
|
-
signal
|
|
702
|
-
};
|
|
703
|
-
};
|
|
704
|
-
const buildResponse$1 = res => {
|
|
705
|
-
return res.text().then(text => {
|
|
706
|
-
let data;
|
|
707
|
-
try {
|
|
708
|
-
data = JSON.parse(text);
|
|
709
|
-
} catch (error) {
|
|
710
|
-
let message = '';
|
|
711
|
-
if (error instanceof Error) {
|
|
712
|
-
message = error.message;
|
|
713
|
-
}
|
|
714
|
-
throw WebrpcBadResponseError$1.new({
|
|
715
|
-
status: res.status,
|
|
716
|
-
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
717
|
-
});
|
|
718
|
-
}
|
|
719
|
-
if (!res.ok) {
|
|
720
|
-
const code = typeof data.code === 'number' ? data.code : 0;
|
|
721
|
-
throw (webrpcErrorByCode$1[code] || WebrpcError$1).new(data);
|
|
722
|
-
}
|
|
723
|
-
return data;
|
|
724
|
-
});
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
//
|
|
728
|
-
// Errors
|
|
729
|
-
//
|
|
730
|
-
|
|
731
|
-
class WebrpcError$1 extends Error {
|
|
732
|
-
constructor(name, code, message, status, cause) {
|
|
733
|
-
super(message);
|
|
734
|
-
this.name = void 0;
|
|
735
|
-
this.code = void 0;
|
|
736
|
-
this.message = void 0;
|
|
737
|
-
this.status = void 0;
|
|
738
|
-
this.cause = void 0;
|
|
739
|
-
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
740
|
-
this.msg = void 0;
|
|
741
|
-
this.name = name || 'WebrpcError';
|
|
742
|
-
this.code = typeof code === 'number' ? code : 0;
|
|
743
|
-
this.message = message || `endpoint error ${this.code}`;
|
|
744
|
-
this.msg = this.message;
|
|
745
|
-
this.status = typeof status === 'number' ? status : 0;
|
|
746
|
-
this.cause = cause;
|
|
747
|
-
Object.setPrototypeOf(this, WebrpcError$1.prototype);
|
|
748
|
-
}
|
|
749
|
-
static new(payload) {
|
|
750
|
-
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
// Webrpc errors
|
|
755
|
-
|
|
756
|
-
class WebrpcEndpointError$1 extends WebrpcError$1 {
|
|
757
|
-
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) {
|
|
758
|
-
super(name, code, message, status, cause);
|
|
759
|
-
Object.setPrototypeOf(this, WebrpcEndpointError$1.prototype);
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
class WebrpcRequestFailedError$1 extends WebrpcError$1 {
|
|
763
|
-
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) {
|
|
764
|
-
super(name, code, message, status, cause);
|
|
765
|
-
Object.setPrototypeOf(this, WebrpcRequestFailedError$1.prototype);
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
class WebrpcBadRouteError$1 extends WebrpcError$1 {
|
|
769
|
-
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) {
|
|
770
|
-
super(name, code, message, status, cause);
|
|
771
|
-
Object.setPrototypeOf(this, WebrpcBadRouteError$1.prototype);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
class WebrpcBadMethodError$1 extends WebrpcError$1 {
|
|
775
|
-
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) {
|
|
776
|
-
super(name, code, message, status, cause);
|
|
777
|
-
Object.setPrototypeOf(this, WebrpcBadMethodError$1.prototype);
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
class WebrpcBadRequestError$1 extends WebrpcError$1 {
|
|
781
|
-
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) {
|
|
782
|
-
super(name, code, message, status, cause);
|
|
783
|
-
Object.setPrototypeOf(this, WebrpcBadRequestError$1.prototype);
|
|
784
|
-
}
|
|
785
|
-
}
|
|
786
|
-
class WebrpcBadResponseError$1 extends WebrpcError$1 {
|
|
787
|
-
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) {
|
|
788
|
-
super(name, code, message, status, cause);
|
|
789
|
-
Object.setPrototypeOf(this, WebrpcBadResponseError$1.prototype);
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
class WebrpcServerPanicError$1 extends WebrpcError$1 {
|
|
793
|
-
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) {
|
|
794
|
-
super(name, code, message, status, cause);
|
|
795
|
-
Object.setPrototypeOf(this, WebrpcServerPanicError$1.prototype);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
class WebrpcInternalErrorError$1 extends WebrpcError$1 {
|
|
799
|
-
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) {
|
|
800
|
-
super(name, code, message, status, cause);
|
|
801
|
-
Object.setPrototypeOf(this, WebrpcInternalErrorError$1.prototype);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
class WebrpcClientDisconnectedError$1 extends WebrpcError$1 {
|
|
805
|
-
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) {
|
|
806
|
-
super(name, code, message, status, cause);
|
|
807
|
-
Object.setPrototypeOf(this, WebrpcClientDisconnectedError$1.prototype);
|
|
808
|
-
}
|
|
809
|
-
}
|
|
810
|
-
class WebrpcStreamLostError$1 extends WebrpcError$1 {
|
|
811
|
-
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) {
|
|
812
|
-
super(name, code, message, status, cause);
|
|
813
|
-
Object.setPrototypeOf(this, WebrpcStreamLostError$1.prototype);
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
class WebrpcStreamFinishedError$1 extends WebrpcError$1 {
|
|
817
|
-
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) {
|
|
818
|
-
super(name, code, message, status, cause);
|
|
819
|
-
Object.setPrototypeOf(this, WebrpcStreamFinishedError$1.prototype);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
// Schema errors
|
|
824
|
-
|
|
825
|
-
class UnauthorizedError$1 extends WebrpcError$1 {
|
|
826
|
-
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) {
|
|
827
|
-
super(name, code, message, status, cause);
|
|
828
|
-
Object.setPrototypeOf(this, UnauthorizedError$1.prototype);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
class PermissionDeniedError$1 extends WebrpcError$1 {
|
|
832
|
-
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) {
|
|
833
|
-
super(name, code, message, status, cause);
|
|
834
|
-
Object.setPrototypeOf(this, PermissionDeniedError$1.prototype);
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
class SessionExpiredError$1 extends WebrpcError$1 {
|
|
838
|
-
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) {
|
|
839
|
-
super(name, code, message, status, cause);
|
|
840
|
-
Object.setPrototypeOf(this, SessionExpiredError$1.prototype);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
class MethodNotFoundError$1 extends WebrpcError$1 {
|
|
844
|
-
constructor(name = 'MethodNotFound', code = 1003, message = 'Method not found', status = 0, cause) {
|
|
845
|
-
super(name, code, message, status, cause);
|
|
846
|
-
Object.setPrototypeOf(this, MethodNotFoundError$1.prototype);
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
class RequestConflictError$1 extends WebrpcError$1 {
|
|
850
|
-
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) {
|
|
851
|
-
super(name, code, message, status, cause);
|
|
852
|
-
Object.setPrototypeOf(this, RequestConflictError$1.prototype);
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
class AbortedError$1 extends WebrpcError$1 {
|
|
856
|
-
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) {
|
|
857
|
-
super(name, code, message, status, cause);
|
|
858
|
-
Object.setPrototypeOf(this, AbortedError$1.prototype);
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
class GeoblockedError$1 extends WebrpcError$1 {
|
|
862
|
-
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) {
|
|
863
|
-
super(name, code, message, status, cause);
|
|
864
|
-
Object.setPrototypeOf(this, GeoblockedError$1.prototype);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
class RateLimitedError$1 extends WebrpcError$1 {
|
|
868
|
-
constructor(name = 'RateLimited', code = 1007, message = 'Rate-limited. Please slow down.', status = 0, cause) {
|
|
869
|
-
super(name, code, message, status, cause);
|
|
870
|
-
Object.setPrototypeOf(this, RateLimitedError$1.prototype);
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
class ProjectNotFoundError$1 extends WebrpcError$1 {
|
|
874
|
-
constructor(name = 'ProjectNotFound', code = 1100, message = 'Project not found', status = 0, cause) {
|
|
875
|
-
super(name, code, message, status, cause);
|
|
876
|
-
Object.setPrototypeOf(this, ProjectNotFoundError$1.prototype);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
class AccessKeyNotFoundError$1 extends WebrpcError$1 {
|
|
880
|
-
constructor(name = 'AccessKeyNotFound', code = 1101, message = 'Access key not found', status = 0, cause) {
|
|
881
|
-
super(name, code, message, status, cause);
|
|
882
|
-
Object.setPrototypeOf(this, AccessKeyNotFoundError$1.prototype);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
class AccessKeyMismatchError$1 extends WebrpcError$1 {
|
|
886
|
-
constructor(name = 'AccessKeyMismatch', code = 1102, message = 'Access key mismatch', status = 0, cause) {
|
|
887
|
-
super(name, code, message, status, cause);
|
|
888
|
-
Object.setPrototypeOf(this, AccessKeyMismatchError$1.prototype);
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
class InvalidOriginError$1 extends WebrpcError$1 {
|
|
892
|
-
constructor(name = 'InvalidOrigin', code = 1103, message = 'Invalid origin for Access Key', status = 0, cause) {
|
|
893
|
-
super(name, code, message, status, cause);
|
|
894
|
-
Object.setPrototypeOf(this, InvalidOriginError$1.prototype);
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
class InvalidServiceError$1 extends WebrpcError$1 {
|
|
898
|
-
constructor(name = 'InvalidService', code = 1104, message = 'Service not enabled for Access key', status = 0, cause) {
|
|
899
|
-
super(name, code, message, status, cause);
|
|
900
|
-
Object.setPrototypeOf(this, InvalidServiceError$1.prototype);
|
|
901
|
-
}
|
|
902
|
-
}
|
|
903
|
-
class UnauthorizedUserError$1 extends WebrpcError$1 {
|
|
904
|
-
constructor(name = 'UnauthorizedUser', code = 1105, message = 'Unauthorized user', status = 0, cause) {
|
|
905
|
-
super(name, code, message, status, cause);
|
|
906
|
-
Object.setPrototypeOf(this, UnauthorizedUserError$1.prototype);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
class QuotaExceededError$1 extends WebrpcError$1 {
|
|
910
|
-
constructor(name = 'QuotaExceeded', code = 1200, message = 'Quota exceeded', status = 0, cause) {
|
|
911
|
-
super(name, code, message, status, cause);
|
|
912
|
-
Object.setPrototypeOf(this, QuotaExceededError$1.prototype);
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
class RateLimitError$1 extends WebrpcError$1 {
|
|
916
|
-
constructor(name = 'RateLimit', code = 1201, message = 'Rate limit exceeded', status = 0, cause) {
|
|
917
|
-
super(name, code, message, status, cause);
|
|
918
|
-
Object.setPrototypeOf(this, RateLimitError$1.prototype);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
class NoDefaultKeyError$1 extends WebrpcError$1 {
|
|
922
|
-
constructor(name = 'NoDefaultKey', code = 1300, message = 'No default access key found', status = 0, cause) {
|
|
923
|
-
super(name, code, message, status, cause);
|
|
924
|
-
Object.setPrototypeOf(this, NoDefaultKeyError$1.prototype);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
class MaxAccessKeysError$1 extends WebrpcError$1 {
|
|
928
|
-
constructor(name = 'MaxAccessKeys', code = 1301, message = 'Access keys limit reached', status = 0, cause) {
|
|
929
|
-
super(name, code, message, status, cause);
|
|
930
|
-
Object.setPrototypeOf(this, MaxAccessKeysError$1.prototype);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
class AtLeastOneKeyError$1 extends WebrpcError$1 {
|
|
934
|
-
constructor(name = 'AtLeastOneKey', code = 1302, message = 'You need at least one Access Key', status = 0, cause) {
|
|
935
|
-
super(name, code, message, status, cause);
|
|
936
|
-
Object.setPrototypeOf(this, AtLeastOneKeyError$1.prototype);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
class TimeoutError$1 extends WebrpcError$1 {
|
|
940
|
-
constructor(name = 'Timeout', code = 1900, message = 'Request timed out', status = 0, cause) {
|
|
941
|
-
super(name, code, message, status, cause);
|
|
942
|
-
Object.setPrototypeOf(this, TimeoutError$1.prototype);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
class InvalidArgumentError$1 extends WebrpcError$1 {
|
|
946
|
-
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
|
947
|
-
super(name, code, message, status, cause);
|
|
948
|
-
Object.setPrototypeOf(this, InvalidArgumentError$1.prototype);
|
|
949
|
-
}
|
|
950
|
-
}
|
|
951
|
-
class UnavailableError$1 extends WebrpcError$1 {
|
|
952
|
-
constructor(name = 'Unavailable', code = 2002, message = 'Unavailable resource', status = 0, cause) {
|
|
953
|
-
super(name, code, message, status, cause);
|
|
954
|
-
Object.setPrototypeOf(this, UnavailableError$1.prototype);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
class QueryFailedError$1 extends WebrpcError$1 {
|
|
958
|
-
constructor(name = 'QueryFailed', code = 2003, message = 'Query failed', status = 0, cause) {
|
|
959
|
-
super(name, code, message, status, cause);
|
|
960
|
-
Object.setPrototypeOf(this, QueryFailedError$1.prototype);
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
class ResourceExhaustedError$1 extends WebrpcError$1 {
|
|
964
|
-
constructor(name = 'ResourceExhausted', code = 2004, message = 'Resource exhausted', status = 0, cause) {
|
|
965
|
-
super(name, code, message, status, cause);
|
|
966
|
-
Object.setPrototypeOf(this, ResourceExhaustedError$1.prototype);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
class NotFoundError$1 extends WebrpcError$1 {
|
|
970
|
-
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) {
|
|
971
|
-
super(name, code, message, status, cause);
|
|
972
|
-
Object.setPrototypeOf(this, NotFoundError$1.prototype);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
975
|
-
class MetadataCallFailedError$1 extends WebrpcError$1 {
|
|
976
|
-
constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) {
|
|
977
|
-
super(name, code, message, status, cause);
|
|
978
|
-
Object.setPrototypeOf(this, MetadataCallFailedError$1.prototype);
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
let errors$1 = /*#__PURE__*/function (errors) {
|
|
982
|
-
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
983
|
-
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
984
|
-
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
985
|
-
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
986
|
-
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
987
|
-
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
988
|
-
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
989
|
-
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
990
|
-
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected";
|
|
991
|
-
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
992
|
-
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
993
|
-
errors["Unauthorized"] = "Unauthorized";
|
|
994
|
-
errors["PermissionDenied"] = "PermissionDenied";
|
|
995
|
-
errors["SessionExpired"] = "SessionExpired";
|
|
996
|
-
errors["MethodNotFound"] = "MethodNotFound";
|
|
997
|
-
errors["RequestConflict"] = "RequestConflict";
|
|
998
|
-
errors["Aborted"] = "Aborted";
|
|
999
|
-
errors["Geoblocked"] = "Geoblocked";
|
|
1000
|
-
errors["RateLimited"] = "RateLimited";
|
|
1001
|
-
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
1002
|
-
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
1003
|
-
errors["AccessKeyMismatch"] = "AccessKeyMismatch";
|
|
1004
|
-
errors["InvalidOrigin"] = "InvalidOrigin";
|
|
1005
|
-
errors["InvalidService"] = "InvalidService";
|
|
1006
|
-
errors["UnauthorizedUser"] = "UnauthorizedUser";
|
|
1007
|
-
errors["QuotaExceeded"] = "QuotaExceeded";
|
|
1008
|
-
errors["RateLimit"] = "RateLimit";
|
|
1009
|
-
errors["NoDefaultKey"] = "NoDefaultKey";
|
|
1010
|
-
errors["MaxAccessKeys"] = "MaxAccessKeys";
|
|
1011
|
-
errors["AtLeastOneKey"] = "AtLeastOneKey";
|
|
1012
|
-
errors["Timeout"] = "Timeout";
|
|
1013
|
-
errors["InvalidArgument"] = "InvalidArgument";
|
|
1014
|
-
errors["Unavailable"] = "Unavailable";
|
|
1015
|
-
errors["QueryFailed"] = "QueryFailed";
|
|
1016
|
-
errors["ResourceExhausted"] = "ResourceExhausted";
|
|
1017
|
-
errors["NotFound"] = "NotFound";
|
|
1018
|
-
errors["MetadataCallFailed"] = "MetadataCallFailed";
|
|
1019
|
-
return errors;
|
|
1020
|
-
}({});
|
|
1021
|
-
const webrpcErrorByCode$1 = {
|
|
1022
|
-
[0]: WebrpcEndpointError$1,
|
|
1023
|
-
[-1]: WebrpcRequestFailedError$1,
|
|
1024
|
-
[-2]: WebrpcBadRouteError$1,
|
|
1025
|
-
[-3]: WebrpcBadMethodError$1,
|
|
1026
|
-
[-4]: WebrpcBadRequestError$1,
|
|
1027
|
-
[-5]: WebrpcBadResponseError$1,
|
|
1028
|
-
[-6]: WebrpcServerPanicError$1,
|
|
1029
|
-
[-7]: WebrpcInternalErrorError$1,
|
|
1030
|
-
[-8]: WebrpcClientDisconnectedError$1,
|
|
1031
|
-
[-9]: WebrpcStreamLostError$1,
|
|
1032
|
-
[-10]: WebrpcStreamFinishedError$1,
|
|
1033
|
-
[1000]: UnauthorizedError$1,
|
|
1034
|
-
[1001]: PermissionDeniedError$1,
|
|
1035
|
-
[1002]: SessionExpiredError$1,
|
|
1036
|
-
[1003]: MethodNotFoundError$1,
|
|
1037
|
-
[1004]: RequestConflictError$1,
|
|
1038
|
-
[1005]: AbortedError$1,
|
|
1039
|
-
[1006]: GeoblockedError$1,
|
|
1040
|
-
[1007]: RateLimitedError$1,
|
|
1041
|
-
[1100]: ProjectNotFoundError$1,
|
|
1042
|
-
[1101]: AccessKeyNotFoundError$1,
|
|
1043
|
-
[1102]: AccessKeyMismatchError$1,
|
|
1044
|
-
[1103]: InvalidOriginError$1,
|
|
1045
|
-
[1104]: InvalidServiceError$1,
|
|
1046
|
-
[1105]: UnauthorizedUserError$1,
|
|
1047
|
-
[1200]: QuotaExceededError$1,
|
|
1048
|
-
[1201]: RateLimitError$1,
|
|
1049
|
-
[1300]: NoDefaultKeyError$1,
|
|
1050
|
-
[1301]: MaxAccessKeysError$1,
|
|
1051
|
-
[1302]: AtLeastOneKeyError$1,
|
|
1052
|
-
[1900]: TimeoutError$1,
|
|
1053
|
-
[2001]: InvalidArgumentError$1,
|
|
1054
|
-
[2002]: UnavailableError$1,
|
|
1055
|
-
[2003]: QueryFailedError$1,
|
|
1056
|
-
[2004]: ResourceExhaustedError$1,
|
|
1057
|
-
[3000]: NotFoundError$1,
|
|
1058
|
-
[3003]: MetadataCallFailedError$1
|
|
1059
|
-
};
|
|
1060
|
-
|
|
1061
|
-
/* eslint-disable */
|
|
1062
|
-
// sequence-indexer v0.4.0 399517e791d272fddd35b036260f7bbbe6cea0e5
|
|
1063
|
-
// --
|
|
1064
|
-
// Code generated by webrpc-gen@v0.21.1 with typescript generator. DO NOT EDIT.
|
|
1065
|
-
//
|
|
1066
|
-
// webrpc-gen -schema=indexer.ridl -service=IndexerGateway -target=typescript -client -out=./clients/indexergw.gen.ts
|
|
1067
|
-
|
|
1068
|
-
const WebrpcHeader = 'Webrpc';
|
|
1069
|
-
const WebrpcHeaderValue = 'webrpc@v0.21.1;gen-typescript@v0.15.1;sequence-indexer@v0.4.0';
|
|
1070
|
-
|
|
1071
|
-
// WebRPC description and code-gen version
|
|
1072
|
-
const WebRPCVersion = 'v1';
|
|
1073
|
-
|
|
1074
|
-
// Schema version of your RIDL schema
|
|
1075
|
-
const WebRPCSchemaVersion = 'v0.4.0';
|
|
1076
|
-
|
|
1077
|
-
// Schema hash generated from your RIDL schema
|
|
1078
|
-
const WebRPCSchemaHash = '399517e791d272fddd35b036260f7bbbe6cea0e5';
|
|
1079
|
-
function VersionFromHeader(headers) {
|
|
1080
|
-
const headerValue = headers.get(WebrpcHeader);
|
|
1081
|
-
if (!headerValue) {
|
|
1082
|
-
return {
|
|
1083
|
-
webrpcGenVersion: '',
|
|
1084
|
-
codeGenName: '',
|
|
1085
|
-
codeGenVersion: '',
|
|
1086
|
-
schemaName: '',
|
|
1087
|
-
schemaVersion: ''
|
|
1088
|
-
};
|
|
1089
|
-
}
|
|
1090
|
-
return parseWebrpcGenVersions(headerValue);
|
|
1091
|
-
}
|
|
1092
|
-
function parseWebrpcGenVersions(header) {
|
|
1093
|
-
const versions = header.split(';');
|
|
1094
|
-
if (versions.length < 3) {
|
|
1095
|
-
return {
|
|
1096
|
-
webrpcGenVersion: '',
|
|
1097
|
-
codeGenName: '',
|
|
1098
|
-
codeGenVersion: '',
|
|
1099
|
-
schemaName: '',
|
|
1100
|
-
schemaVersion: ''
|
|
1101
|
-
};
|
|
1102
|
-
}
|
|
1103
|
-
const [_, webrpcGenVersion] = versions[0].split('@');
|
|
1104
|
-
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
1105
|
-
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
1106
|
-
return {
|
|
1107
|
-
webrpcGenVersion,
|
|
1108
|
-
codeGenName,
|
|
1109
|
-
codeGenVersion,
|
|
1110
|
-
schemaName,
|
|
1111
|
-
schemaVersion
|
|
1112
|
-
};
|
|
1113
|
-
}
|
|
1114
|
-
|
|
1115
|
-
//
|
|
1116
|
-
// Types
|
|
1117
|
-
//
|
|
1118
|
-
|
|
1119
|
-
let ResourceStatus = /*#__PURE__*/function (ResourceStatus) {
|
|
1120
|
-
ResourceStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
|
|
1121
|
-
ResourceStatus["REFRESHING"] = "REFRESHING";
|
|
1122
|
-
ResourceStatus["AVAILABLE"] = "AVAILABLE";
|
|
1123
|
-
return ResourceStatus;
|
|
1124
|
-
}({});
|
|
1125
|
-
let ContractType = /*#__PURE__*/function (ContractType) {
|
|
1126
|
-
ContractType["UNKNOWN"] = "UNKNOWN";
|
|
1127
|
-
ContractType["NATIVE"] = "NATIVE";
|
|
1128
|
-
ContractType["ERC20"] = "ERC20";
|
|
1129
|
-
ContractType["ERC721"] = "ERC721";
|
|
1130
|
-
ContractType["ERC1155"] = "ERC1155";
|
|
1131
|
-
ContractType["SEQUENCE_WALLET"] = "SEQUENCE_WALLET";
|
|
1132
|
-
ContractType["ERC20_BRIDGE"] = "ERC20_BRIDGE";
|
|
1133
|
-
ContractType["ERC721_BRIDGE"] = "ERC721_BRIDGE";
|
|
1134
|
-
ContractType["ERC1155_BRIDGE"] = "ERC1155_BRIDGE";
|
|
1135
|
-
ContractType["SEQ_MARKETPLACE"] = "SEQ_MARKETPLACE";
|
|
1136
|
-
return ContractType;
|
|
1137
|
-
}({});
|
|
1138
|
-
let EventLogType = /*#__PURE__*/function (EventLogType) {
|
|
1139
|
-
EventLogType["UNKNOWN"] = "UNKNOWN";
|
|
1140
|
-
EventLogType["BLOCK_ADDED"] = "BLOCK_ADDED";
|
|
1141
|
-
EventLogType["BLOCK_REMOVED"] = "BLOCK_REMOVED";
|
|
1142
|
-
return EventLogType;
|
|
1143
|
-
}({});
|
|
1144
|
-
let EventLogDataType = /*#__PURE__*/function (EventLogDataType) {
|
|
1145
|
-
EventLogDataType["EVENT"] = "EVENT";
|
|
1146
|
-
EventLogDataType["TOKEN_TRANSFER"] = "TOKEN_TRANSFER";
|
|
1147
|
-
EventLogDataType["NATIVE_TOKEN_TRANSFER"] = "NATIVE_TOKEN_TRANSFER";
|
|
1148
|
-
EventLogDataType["SEQUENCE_TXN"] = "SEQUENCE_TXN";
|
|
1149
|
-
return EventLogDataType;
|
|
1150
|
-
}({});
|
|
1151
|
-
let OrderStatus = /*#__PURE__*/function (OrderStatus) {
|
|
1152
|
-
OrderStatus["OPEN"] = "OPEN";
|
|
1153
|
-
OrderStatus["CLOSED"] = "CLOSED";
|
|
1154
|
-
OrderStatus["CANCELLED"] = "CANCELLED";
|
|
1155
|
-
return OrderStatus;
|
|
1156
|
-
}({});
|
|
1157
|
-
let TxnTransferType = /*#__PURE__*/function (TxnTransferType) {
|
|
1158
|
-
TxnTransferType["UNKNOWN"] = "UNKNOWN";
|
|
1159
|
-
TxnTransferType["SEND"] = "SEND";
|
|
1160
|
-
TxnTransferType["RECEIVE"] = "RECEIVE";
|
|
1161
|
-
return TxnTransferType;
|
|
1162
|
-
}({});
|
|
1163
|
-
let TransactionStatus = /*#__PURE__*/function (TransactionStatus) {
|
|
1164
|
-
TransactionStatus["FAILED"] = "FAILED";
|
|
1165
|
-
TransactionStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
|
1166
|
-
return TransactionStatus;
|
|
1167
|
-
}({});
|
|
1168
|
-
let TransactionType = /*#__PURE__*/function (TransactionType) {
|
|
1169
|
-
TransactionType["LegacyTxnType"] = "LegacyTxnType";
|
|
1170
|
-
TransactionType["AccessListTxnType"] = "AccessListTxnType";
|
|
1171
|
-
TransactionType["DynamicFeeTxnType"] = "DynamicFeeTxnType";
|
|
1172
|
-
return TransactionType;
|
|
1173
|
-
}({});
|
|
1174
|
-
let SortOrder = /*#__PURE__*/function (SortOrder) {
|
|
1175
|
-
SortOrder["DESC"] = "DESC";
|
|
1176
|
-
SortOrder["ASC"] = "ASC";
|
|
1177
|
-
return SortOrder;
|
|
1178
|
-
}({});
|
|
1179
|
-
let ContractVerificationStatus = /*#__PURE__*/function (ContractVerificationStatus) {
|
|
1180
|
-
ContractVerificationStatus["VERIFIED"] = "VERIFIED";
|
|
1181
|
-
ContractVerificationStatus["UNVERIFIED"] = "UNVERIFIED";
|
|
1182
|
-
ContractVerificationStatus["ALL"] = "ALL";
|
|
1183
|
-
return ContractVerificationStatus;
|
|
1184
|
-
}({});
|
|
1185
|
-
let NetworkType = /*#__PURE__*/function (NetworkType) {
|
|
1186
|
-
NetworkType["MAINNETS"] = "MAINNETS";
|
|
1187
|
-
NetworkType["TESTNETS"] = "TESTNETS";
|
|
1188
|
-
NetworkType["ALL"] = "ALL";
|
|
1189
|
-
return NetworkType;
|
|
1190
|
-
}({});
|
|
1191
|
-
//
|
|
1192
|
-
// Client
|
|
1193
|
-
//
|
|
1194
|
-
class IndexerGateway {
|
|
1195
|
-
constructor(hostname, fetch) {
|
|
1196
|
-
this.hostname = void 0;
|
|
1197
|
-
this.fetch = void 0;
|
|
1198
|
-
this.path = '/rpc/IndexerGateway/';
|
|
1199
|
-
this.getNativeTokenBalance = (args, headers, signal) => {
|
|
1200
|
-
return this.fetch(this.url('GetNativeTokenBalance'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
1201
|
-
return buildResponse(res).then(_data => {
|
|
1202
|
-
return {
|
|
1203
|
-
balances: _data.balances
|
|
1204
|
-
};
|
|
1205
|
-
});
|
|
1206
|
-
}, error => {
|
|
1207
|
-
throw WebrpcRequestFailedError.new({
|
|
1208
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1209
|
-
});
|
|
1210
|
-
});
|
|
1211
|
-
};
|
|
1212
|
-
this.getTokenBalances = (args, headers, signal) => {
|
|
1213
|
-
return this.fetch(this.url('GetTokenBalances'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
1214
|
-
return buildResponse(res).then(_data => {
|
|
1215
|
-
return {
|
|
1216
|
-
page: _data.page,
|
|
1217
|
-
balances: _data.balances
|
|
1218
|
-
};
|
|
1219
|
-
});
|
|
1220
|
-
}, error => {
|
|
1221
|
-
throw WebrpcRequestFailedError.new({
|
|
1222
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1223
|
-
});
|
|
1224
|
-
});
|
|
1225
|
-
};
|
|
1226
|
-
this.getTokenBalancesSummary = (args, headers, signal) => {
|
|
1227
|
-
return this.fetch(this.url('GetTokenBalancesSummary'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
1228
|
-
return buildResponse(res).then(_data => {
|
|
1229
|
-
return {
|
|
1230
|
-
page: _data.page,
|
|
1231
|
-
nativeBalances: _data.nativeBalances,
|
|
1232
|
-
balances: _data.balances
|
|
1233
|
-
};
|
|
1234
|
-
});
|
|
1235
|
-
}, error => {
|
|
1236
|
-
throw WebrpcRequestFailedError.new({
|
|
1237
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1238
|
-
});
|
|
1239
|
-
});
|
|
1240
|
-
};
|
|
1241
|
-
this.getTokenBalancesDetails = (args, headers, signal) => {
|
|
1242
|
-
return this.fetch(this.url('GetTokenBalancesDetails'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
1243
|
-
return buildResponse(res).then(_data => {
|
|
1244
|
-
return {
|
|
1245
|
-
page: _data.page,
|
|
1246
|
-
nativeBalances: _data.nativeBalances,
|
|
1247
|
-
balances: _data.balances
|
|
1248
|
-
};
|
|
1249
|
-
});
|
|
1250
|
-
}, error => {
|
|
1251
|
-
throw WebrpcRequestFailedError.new({
|
|
1252
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1253
|
-
});
|
|
1254
|
-
});
|
|
1255
|
-
};
|
|
1256
|
-
this.getTokenBalancesByContract = (args, headers, signal) => {
|
|
1257
|
-
return this.fetch(this.url('GetTokenBalancesByContract'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
1258
|
-
return buildResponse(res).then(_data => {
|
|
1259
|
-
return {
|
|
1260
|
-
page: _data.page,
|
|
1261
|
-
balances: _data.balances
|
|
1262
|
-
};
|
|
1263
|
-
});
|
|
1264
|
-
}, error => {
|
|
1265
|
-
throw WebrpcRequestFailedError.new({
|
|
1266
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1267
|
-
});
|
|
1268
|
-
});
|
|
1269
|
-
};
|
|
1270
|
-
this.getBalanceUpdates = (args, headers, signal) => {
|
|
1271
|
-
return this.fetch(this.url('GetBalanceUpdates'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
1272
|
-
return buildResponse(res).then(_data => {
|
|
1273
|
-
return {
|
|
1274
|
-
page: _data.page,
|
|
1275
|
-
balances: _data.balances
|
|
1276
|
-
};
|
|
1277
|
-
});
|
|
1278
|
-
}, error => {
|
|
1279
|
-
throw WebrpcRequestFailedError.new({
|
|
1280
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1281
|
-
});
|
|
1282
|
-
});
|
|
1283
|
-
};
|
|
1284
|
-
this.getChains = (args, headers, signal) => {
|
|
1285
|
-
return this.fetch(this.url('GetChains'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
1286
|
-
return buildResponse(res).then(_data => {
|
|
1287
|
-
return {
|
|
1288
|
-
chains: _data.chains
|
|
1289
|
-
};
|
|
1290
|
-
});
|
|
1291
|
-
}, error => {
|
|
1292
|
-
throw WebrpcRequestFailedError.new({
|
|
1293
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1294
|
-
});
|
|
1295
|
-
});
|
|
1296
|
-
};
|
|
1297
|
-
this.ping = (headers, signal) => {
|
|
1298
|
-
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
1299
|
-
return buildResponse(res).then(_data => {
|
|
1300
|
-
return {
|
|
1301
|
-
status: _data.status
|
|
1302
|
-
};
|
|
1303
|
-
});
|
|
1304
|
-
}, error => {
|
|
1305
|
-
throw WebrpcRequestFailedError.new({
|
|
1306
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1307
|
-
});
|
|
1308
|
-
});
|
|
1309
|
-
};
|
|
1310
|
-
this.version = (headers, signal) => {
|
|
1311
|
-
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
1312
|
-
return buildResponse(res).then(_data => {
|
|
1313
|
-
return {
|
|
1314
|
-
version: _data.version
|
|
1315
|
-
};
|
|
1316
|
-
});
|
|
1317
|
-
}, error => {
|
|
1318
|
-
throw WebrpcRequestFailedError.new({
|
|
1319
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1320
|
-
});
|
|
1321
|
-
});
|
|
1322
|
-
};
|
|
1323
|
-
this.runtimeStatus = (headers, signal) => {
|
|
1324
|
-
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
1325
|
-
return buildResponse(res).then(_data => {
|
|
1326
|
-
return {
|
|
1327
|
-
status: _data.status
|
|
1328
|
-
};
|
|
1329
|
-
});
|
|
1330
|
-
}, error => {
|
|
1331
|
-
throw WebrpcRequestFailedError.new({
|
|
1332
|
-
cause: `fetch(): ${error.message || ''}`
|
|
1333
|
-
});
|
|
1334
|
-
});
|
|
1335
|
-
};
|
|
1336
|
-
this.hostname = hostname.replace(/\/*$/, '');
|
|
1337
|
-
this.fetch = (input, init) => fetch(input, init);
|
|
1338
|
-
}
|
|
1339
|
-
url(name) {
|
|
1340
|
-
return this.hostname + this.path + name;
|
|
1341
|
-
}
|
|
1342
|
-
}
|
|
1343
|
-
const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
|
|
1344
|
-
const reqHeaders = _extends({}, headers, {
|
|
1345
|
-
'Content-Type': 'application/json'
|
|
1346
|
-
});
|
|
1347
|
-
reqHeaders[WebrpcHeader] = WebrpcHeaderValue;
|
|
1348
|
-
return {
|
|
1349
|
-
method: 'POST',
|
|
1350
|
-
headers: reqHeaders,
|
|
1351
|
-
body: JSON.stringify(body || {}),
|
|
1352
|
-
signal
|
|
1353
|
-
};
|
|
1354
|
-
};
|
|
1355
|
-
const buildResponse = res => {
|
|
1356
|
-
return res.text().then(text => {
|
|
1357
|
-
let data;
|
|
1358
|
-
try {
|
|
1359
|
-
data = JSON.parse(text);
|
|
1360
|
-
} catch (error) {
|
|
1361
|
-
let message = '';
|
|
1362
|
-
if (error instanceof Error) {
|
|
1363
|
-
message = error.message;
|
|
1364
|
-
}
|
|
1365
|
-
throw WebrpcBadResponseError.new({
|
|
1366
|
-
status: res.status,
|
|
1367
|
-
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
1368
|
-
});
|
|
1369
|
-
}
|
|
1370
|
-
if (!res.ok) {
|
|
1371
|
-
const code = typeof data.code === 'number' ? data.code : 0;
|
|
1372
|
-
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
1373
|
-
}
|
|
1374
|
-
return data;
|
|
1375
|
-
});
|
|
1376
|
-
};
|
|
1377
|
-
|
|
1378
|
-
//
|
|
1379
|
-
// Errors
|
|
1380
|
-
//
|
|
1381
|
-
|
|
1382
|
-
class WebrpcError extends Error {
|
|
1383
|
-
constructor(name, code, message, status, cause) {
|
|
1384
|
-
super(message);
|
|
1385
|
-
this.name = void 0;
|
|
1386
|
-
this.code = void 0;
|
|
1387
|
-
this.message = void 0;
|
|
1388
|
-
this.status = void 0;
|
|
1389
|
-
this.cause = void 0;
|
|
1390
|
-
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
1391
|
-
this.msg = void 0;
|
|
1392
|
-
this.name = name || 'WebrpcError';
|
|
1393
|
-
this.code = typeof code === 'number' ? code : 0;
|
|
1394
|
-
this.message = message || `endpoint error ${this.code}`;
|
|
1395
|
-
this.msg = this.message;
|
|
1396
|
-
this.status = typeof status === 'number' ? status : 0;
|
|
1397
|
-
this.cause = cause;
|
|
1398
|
-
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
1399
|
-
}
|
|
1400
|
-
static new(payload) {
|
|
1401
|
-
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
// Webrpc errors
|
|
1406
|
-
|
|
1407
|
-
class WebrpcEndpointError extends WebrpcError {
|
|
1408
|
-
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) {
|
|
1409
|
-
super(name, code, message, status, cause);
|
|
1410
|
-
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
1411
|
-
}
|
|
1412
|
-
}
|
|
1413
|
-
class WebrpcRequestFailedError extends WebrpcError {
|
|
1414
|
-
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) {
|
|
1415
|
-
super(name, code, message, status, cause);
|
|
1416
|
-
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
class WebrpcBadRouteError extends WebrpcError {
|
|
1420
|
-
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) {
|
|
1421
|
-
super(name, code, message, status, cause);
|
|
1422
|
-
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
class WebrpcBadMethodError extends WebrpcError {
|
|
1426
|
-
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) {
|
|
1427
|
-
super(name, code, message, status, cause);
|
|
1428
|
-
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
1429
|
-
}
|
|
1430
|
-
}
|
|
1431
|
-
class WebrpcBadRequestError extends WebrpcError {
|
|
1432
|
-
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) {
|
|
1433
|
-
super(name, code, message, status, cause);
|
|
1434
|
-
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
class WebrpcBadResponseError extends WebrpcError {
|
|
1438
|
-
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) {
|
|
1439
|
-
super(name, code, message, status, cause);
|
|
1440
|
-
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
1441
|
-
}
|
|
1442
|
-
}
|
|
1443
|
-
class WebrpcServerPanicError extends WebrpcError {
|
|
1444
|
-
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) {
|
|
1445
|
-
super(name, code, message, status, cause);
|
|
1446
|
-
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
class WebrpcInternalErrorError extends WebrpcError {
|
|
1450
|
-
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) {
|
|
1451
|
-
super(name, code, message, status, cause);
|
|
1452
|
-
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
class WebrpcClientDisconnectedError extends WebrpcError {
|
|
1456
|
-
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) {
|
|
1457
|
-
super(name, code, message, status, cause);
|
|
1458
|
-
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype);
|
|
1459
|
-
}
|
|
1460
|
-
}
|
|
1461
|
-
class WebrpcStreamLostError extends WebrpcError {
|
|
1462
|
-
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) {
|
|
1463
|
-
super(name, code, message, status, cause);
|
|
1464
|
-
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
1465
|
-
}
|
|
1466
|
-
}
|
|
1467
|
-
class WebrpcStreamFinishedError extends WebrpcError {
|
|
1468
|
-
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) {
|
|
1469
|
-
super(name, code, message, status, cause);
|
|
1470
|
-
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
// Schema errors
|
|
1475
|
-
|
|
1476
|
-
class UnauthorizedError extends WebrpcError {
|
|
1477
|
-
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) {
|
|
1478
|
-
super(name, code, message, status, cause);
|
|
1479
|
-
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
class PermissionDeniedError extends WebrpcError {
|
|
1483
|
-
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) {
|
|
1484
|
-
super(name, code, message, status, cause);
|
|
1485
|
-
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
class SessionExpiredError extends WebrpcError {
|
|
1489
|
-
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) {
|
|
1490
|
-
super(name, code, message, status, cause);
|
|
1491
|
-
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
class MethodNotFoundError extends WebrpcError {
|
|
1495
|
-
constructor(name = 'MethodNotFound', code = 1003, message = 'Method not found', status = 0, cause) {
|
|
1496
|
-
super(name, code, message, status, cause);
|
|
1497
|
-
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
class RequestConflictError extends WebrpcError {
|
|
1501
|
-
constructor(name = 'RequestConflict', code = 1004, message = 'Conflict with target resource', status = 0, cause) {
|
|
1502
|
-
super(name, code, message, status, cause);
|
|
1503
|
-
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
class AbortedError extends WebrpcError {
|
|
1507
|
-
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) {
|
|
1508
|
-
super(name, code, message, status, cause);
|
|
1509
|
-
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
1510
|
-
}
|
|
1511
|
-
}
|
|
1512
|
-
class GeoblockedError extends WebrpcError {
|
|
1513
|
-
constructor(name = 'Geoblocked', code = 1006, message = 'Geoblocked region', status = 0, cause) {
|
|
1514
|
-
super(name, code, message, status, cause);
|
|
1515
|
-
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
class RateLimitedError extends WebrpcError {
|
|
1519
|
-
constructor(name = 'RateLimited', code = 1007, message = 'Rate-limited. Please slow down.', status = 0, cause) {
|
|
1520
|
-
super(name, code, message, status, cause);
|
|
1521
|
-
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
class ProjectNotFoundError extends WebrpcError {
|
|
1525
|
-
constructor(name = 'ProjectNotFound', code = 1100, message = 'Project not found', status = 0, cause) {
|
|
1526
|
-
super(name, code, message, status, cause);
|
|
1527
|
-
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
1528
|
-
}
|
|
1529
|
-
}
|
|
1530
|
-
class AccessKeyNotFoundError extends WebrpcError {
|
|
1531
|
-
constructor(name = 'AccessKeyNotFound', code = 1101, message = 'Access key not found', status = 0, cause) {
|
|
1532
|
-
super(name, code, message, status, cause);
|
|
1533
|
-
Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
|
|
1534
|
-
}
|
|
1535
|
-
}
|
|
1536
|
-
class AccessKeyMismatchError extends WebrpcError {
|
|
1537
|
-
constructor(name = 'AccessKeyMismatch', code = 1102, message = 'Access key mismatch', status = 0, cause) {
|
|
1538
|
-
super(name, code, message, status, cause);
|
|
1539
|
-
Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1542
|
-
class InvalidOriginError extends WebrpcError {
|
|
1543
|
-
constructor(name = 'InvalidOrigin', code = 1103, message = 'Invalid origin for Access Key', status = 0, cause) {
|
|
1544
|
-
super(name, code, message, status, cause);
|
|
1545
|
-
Object.setPrototypeOf(this, InvalidOriginError.prototype);
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
class InvalidServiceError extends WebrpcError {
|
|
1549
|
-
constructor(name = 'InvalidService', code = 1104, message = 'Service not enabled for Access key', status = 0, cause) {
|
|
1550
|
-
super(name, code, message, status, cause);
|
|
1551
|
-
Object.setPrototypeOf(this, InvalidServiceError.prototype);
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
class UnauthorizedUserError extends WebrpcError {
|
|
1555
|
-
constructor(name = 'UnauthorizedUser', code = 1105, message = 'Unauthorized user', status = 0, cause) {
|
|
1556
|
-
super(name, code, message, status, cause);
|
|
1557
|
-
Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
|
|
1558
|
-
}
|
|
1559
|
-
}
|
|
1560
|
-
class QuotaExceededError extends WebrpcError {
|
|
1561
|
-
constructor(name = 'QuotaExceeded', code = 1200, message = 'Quota exceeded', status = 0, cause) {
|
|
1562
|
-
super(name, code, message, status, cause);
|
|
1563
|
-
Object.setPrototypeOf(this, QuotaExceededError.prototype);
|
|
1564
|
-
}
|
|
1565
|
-
}
|
|
1566
|
-
class RateLimitError extends WebrpcError {
|
|
1567
|
-
constructor(name = 'RateLimit', code = 1201, message = 'Rate limit exceeded', status = 0, cause) {
|
|
1568
|
-
super(name, code, message, status, cause);
|
|
1569
|
-
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
class NoDefaultKeyError extends WebrpcError {
|
|
1573
|
-
constructor(name = 'NoDefaultKey', code = 1300, message = 'No default access key found', status = 0, cause) {
|
|
1574
|
-
super(name, code, message, status, cause);
|
|
1575
|
-
Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
class MaxAccessKeysError extends WebrpcError {
|
|
1579
|
-
constructor(name = 'MaxAccessKeys', code = 1301, message = 'Access keys limit reached', status = 0, cause) {
|
|
1580
|
-
super(name, code, message, status, cause);
|
|
1581
|
-
Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
class AtLeastOneKeyError extends WebrpcError {
|
|
1585
|
-
constructor(name = 'AtLeastOneKey', code = 1302, message = 'You need at least one Access Key', status = 0, cause) {
|
|
1586
|
-
super(name, code, message, status, cause);
|
|
1587
|
-
Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
class TimeoutError extends WebrpcError {
|
|
1591
|
-
constructor(name = 'Timeout', code = 1900, message = 'Request timed out', status = 0, cause) {
|
|
1592
|
-
super(name, code, message, status, cause);
|
|
1593
|
-
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
1594
|
-
}
|
|
1595
|
-
}
|
|
1596
|
-
class InvalidArgumentError extends WebrpcError {
|
|
1597
|
-
constructor(name = 'InvalidArgument', code = 2001, message = 'Invalid argument', status = 0, cause) {
|
|
1598
|
-
super(name, code, message, status, cause);
|
|
1599
|
-
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
class UnavailableError extends WebrpcError {
|
|
1603
|
-
constructor(name = 'Unavailable', code = 2002, message = 'Unavailable resource', status = 0, cause) {
|
|
1604
|
-
super(name, code, message, status, cause);
|
|
1605
|
-
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
1606
|
-
}
|
|
1607
|
-
}
|
|
1608
|
-
class QueryFailedError extends WebrpcError {
|
|
1609
|
-
constructor(name = 'QueryFailed', code = 2003, message = 'Query failed', status = 0, cause) {
|
|
1610
|
-
super(name, code, message, status, cause);
|
|
1611
|
-
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
class ResourceExhaustedError extends WebrpcError {
|
|
1615
|
-
constructor(name = 'ResourceExhausted', code = 2004, message = 'Resource exhausted', status = 0, cause) {
|
|
1616
|
-
super(name, code, message, status, cause);
|
|
1617
|
-
Object.setPrototypeOf(this, ResourceExhaustedError.prototype);
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
class NotFoundError extends WebrpcError {
|
|
1621
|
-
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) {
|
|
1622
|
-
super(name, code, message, status, cause);
|
|
1623
|
-
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
1624
|
-
}
|
|
1625
|
-
}
|
|
1626
|
-
class MetadataCallFailedError extends WebrpcError {
|
|
1627
|
-
constructor(name = 'MetadataCallFailed', code = 3003, message = 'Metadata service call failed', status = 0, cause) {
|
|
1628
|
-
super(name, code, message, status, cause);
|
|
1629
|
-
Object.setPrototypeOf(this, MetadataCallFailedError.prototype);
|
|
1630
|
-
}
|
|
1631
|
-
}
|
|
1632
|
-
let errors = /*#__PURE__*/function (errors) {
|
|
1633
|
-
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
1634
|
-
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
1635
|
-
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
1636
|
-
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
1637
|
-
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
1638
|
-
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
1639
|
-
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
1640
|
-
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
1641
|
-
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected";
|
|
1642
|
-
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
1643
|
-
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
1644
|
-
errors["Unauthorized"] = "Unauthorized";
|
|
1645
|
-
errors["PermissionDenied"] = "PermissionDenied";
|
|
1646
|
-
errors["SessionExpired"] = "SessionExpired";
|
|
1647
|
-
errors["MethodNotFound"] = "MethodNotFound";
|
|
1648
|
-
errors["RequestConflict"] = "RequestConflict";
|
|
1649
|
-
errors["Aborted"] = "Aborted";
|
|
1650
|
-
errors["Geoblocked"] = "Geoblocked";
|
|
1651
|
-
errors["RateLimited"] = "RateLimited";
|
|
1652
|
-
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
1653
|
-
errors["AccessKeyNotFound"] = "AccessKeyNotFound";
|
|
1654
|
-
errors["AccessKeyMismatch"] = "AccessKeyMismatch";
|
|
1655
|
-
errors["InvalidOrigin"] = "InvalidOrigin";
|
|
1656
|
-
errors["InvalidService"] = "InvalidService";
|
|
1657
|
-
errors["UnauthorizedUser"] = "UnauthorizedUser";
|
|
1658
|
-
errors["QuotaExceeded"] = "QuotaExceeded";
|
|
1659
|
-
errors["RateLimit"] = "RateLimit";
|
|
1660
|
-
errors["NoDefaultKey"] = "NoDefaultKey";
|
|
1661
|
-
errors["MaxAccessKeys"] = "MaxAccessKeys";
|
|
1662
|
-
errors["AtLeastOneKey"] = "AtLeastOneKey";
|
|
1663
|
-
errors["Timeout"] = "Timeout";
|
|
1664
|
-
errors["InvalidArgument"] = "InvalidArgument";
|
|
1665
|
-
errors["Unavailable"] = "Unavailable";
|
|
1666
|
-
errors["QueryFailed"] = "QueryFailed";
|
|
1667
|
-
errors["ResourceExhausted"] = "ResourceExhausted";
|
|
1668
|
-
errors["NotFound"] = "NotFound";
|
|
1669
|
-
errors["MetadataCallFailed"] = "MetadataCallFailed";
|
|
1670
|
-
return errors;
|
|
1671
|
-
}({});
|
|
1672
|
-
const webrpcErrorByCode = {
|
|
1673
|
-
[0]: WebrpcEndpointError,
|
|
1674
|
-
[-1]: WebrpcRequestFailedError,
|
|
1675
|
-
[-2]: WebrpcBadRouteError,
|
|
1676
|
-
[-3]: WebrpcBadMethodError,
|
|
1677
|
-
[-4]: WebrpcBadRequestError,
|
|
1678
|
-
[-5]: WebrpcBadResponseError,
|
|
1679
|
-
[-6]: WebrpcServerPanicError,
|
|
1680
|
-
[-7]: WebrpcInternalErrorError,
|
|
1681
|
-
[-8]: WebrpcClientDisconnectedError,
|
|
1682
|
-
[-9]: WebrpcStreamLostError,
|
|
1683
|
-
[-10]: WebrpcStreamFinishedError,
|
|
1684
|
-
[1000]: UnauthorizedError,
|
|
1685
|
-
[1001]: PermissionDeniedError,
|
|
1686
|
-
[1002]: SessionExpiredError,
|
|
1687
|
-
[1003]: MethodNotFoundError,
|
|
1688
|
-
[1004]: RequestConflictError,
|
|
1689
|
-
[1005]: AbortedError,
|
|
1690
|
-
[1006]: GeoblockedError,
|
|
1691
|
-
[1007]: RateLimitedError,
|
|
1692
|
-
[1100]: ProjectNotFoundError,
|
|
1693
|
-
[1101]: AccessKeyNotFoundError,
|
|
1694
|
-
[1102]: AccessKeyMismatchError,
|
|
1695
|
-
[1103]: InvalidOriginError,
|
|
1696
|
-
[1104]: InvalidServiceError,
|
|
1697
|
-
[1105]: UnauthorizedUserError,
|
|
1698
|
-
[1200]: QuotaExceededError,
|
|
1699
|
-
[1201]: RateLimitError,
|
|
1700
|
-
[1300]: NoDefaultKeyError,
|
|
1701
|
-
[1301]: MaxAccessKeysError,
|
|
1702
|
-
[1302]: AtLeastOneKeyError,
|
|
1703
|
-
[1900]: TimeoutError,
|
|
1704
|
-
[2001]: InvalidArgumentError,
|
|
1705
|
-
[2002]: UnavailableError,
|
|
1706
|
-
[2003]: QueryFailedError,
|
|
1707
|
-
[2004]: ResourceExhaustedError,
|
|
1708
|
-
[3000]: NotFoundError,
|
|
1709
|
-
[3003]: MetadataCallFailedError
|
|
1710
|
-
};
|
|
1711
|
-
|
|
1712
|
-
var indexergw_gen = /*#__PURE__*/Object.freeze({
|
|
1713
|
-
__proto__: null,
|
|
1714
|
-
WebrpcHeader: WebrpcHeader,
|
|
1715
|
-
WebrpcHeaderValue: WebrpcHeaderValue,
|
|
1716
|
-
WebRPCVersion: WebRPCVersion,
|
|
1717
|
-
WebRPCSchemaVersion: WebRPCSchemaVersion,
|
|
1718
|
-
WebRPCSchemaHash: WebRPCSchemaHash,
|
|
1719
|
-
VersionFromHeader: VersionFromHeader,
|
|
1720
|
-
ResourceStatus: ResourceStatus,
|
|
1721
|
-
ContractType: ContractType,
|
|
1722
|
-
EventLogType: EventLogType,
|
|
1723
|
-
EventLogDataType: EventLogDataType,
|
|
1724
|
-
OrderStatus: OrderStatus,
|
|
1725
|
-
TxnTransferType: TxnTransferType,
|
|
1726
|
-
TransactionStatus: TransactionStatus,
|
|
1727
|
-
TransactionType: TransactionType,
|
|
1728
|
-
SortOrder: SortOrder,
|
|
1729
|
-
ContractVerificationStatus: ContractVerificationStatus,
|
|
1730
|
-
NetworkType: NetworkType,
|
|
1731
|
-
IndexerGateway: IndexerGateway,
|
|
1732
|
-
WebrpcError: WebrpcError,
|
|
1733
|
-
WebrpcEndpointError: WebrpcEndpointError,
|
|
1734
|
-
WebrpcRequestFailedError: WebrpcRequestFailedError,
|
|
1735
|
-
WebrpcBadRouteError: WebrpcBadRouteError,
|
|
1736
|
-
WebrpcBadMethodError: WebrpcBadMethodError,
|
|
1737
|
-
WebrpcBadRequestError: WebrpcBadRequestError,
|
|
1738
|
-
WebrpcBadResponseError: WebrpcBadResponseError,
|
|
1739
|
-
WebrpcServerPanicError: WebrpcServerPanicError,
|
|
1740
|
-
WebrpcInternalErrorError: WebrpcInternalErrorError,
|
|
1741
|
-
WebrpcClientDisconnectedError: WebrpcClientDisconnectedError,
|
|
1742
|
-
WebrpcStreamLostError: WebrpcStreamLostError,
|
|
1743
|
-
WebrpcStreamFinishedError: WebrpcStreamFinishedError,
|
|
1744
|
-
UnauthorizedError: UnauthorizedError,
|
|
1745
|
-
PermissionDeniedError: PermissionDeniedError,
|
|
1746
|
-
SessionExpiredError: SessionExpiredError,
|
|
1747
|
-
MethodNotFoundError: MethodNotFoundError,
|
|
1748
|
-
RequestConflictError: RequestConflictError,
|
|
1749
|
-
AbortedError: AbortedError,
|
|
1750
|
-
GeoblockedError: GeoblockedError,
|
|
1751
|
-
RateLimitedError: RateLimitedError,
|
|
1752
|
-
ProjectNotFoundError: ProjectNotFoundError,
|
|
1753
|
-
AccessKeyNotFoundError: AccessKeyNotFoundError,
|
|
1754
|
-
AccessKeyMismatchError: AccessKeyMismatchError,
|
|
1755
|
-
InvalidOriginError: InvalidOriginError,
|
|
1756
|
-
InvalidServiceError: InvalidServiceError,
|
|
1757
|
-
UnauthorizedUserError: UnauthorizedUserError,
|
|
1758
|
-
QuotaExceededError: QuotaExceededError,
|
|
1759
|
-
RateLimitError: RateLimitError,
|
|
1760
|
-
NoDefaultKeyError: NoDefaultKeyError,
|
|
1761
|
-
MaxAccessKeysError: MaxAccessKeysError,
|
|
1762
|
-
AtLeastOneKeyError: AtLeastOneKeyError,
|
|
1763
|
-
TimeoutError: TimeoutError,
|
|
1764
|
-
InvalidArgumentError: InvalidArgumentError,
|
|
1765
|
-
UnavailableError: UnavailableError,
|
|
1766
|
-
QueryFailedError: QueryFailedError,
|
|
1767
|
-
ResourceExhaustedError: ResourceExhaustedError,
|
|
1768
|
-
NotFoundError: NotFoundError,
|
|
1769
|
-
MetadataCallFailedError: MetadataCallFailedError,
|
|
1770
|
-
errors: errors
|
|
1771
|
-
});
|
|
1772
|
-
|
|
1773
|
-
class SequenceIndexer extends Indexer {
|
|
1774
|
-
constructor(hostname, projectAccessKey, jwtAuth) {
|
|
1775
|
-
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
1776
|
-
this.projectAccessKey = projectAccessKey;
|
|
1777
|
-
this.jwtAuth = jwtAuth;
|
|
1778
|
-
this._fetch = (input, init) => {
|
|
1779
|
-
// automatically include jwt and access key auth header to requests
|
|
1780
|
-
// if its been set on the api client
|
|
1781
|
-
const headers = {};
|
|
1782
|
-
const jwtAuth = this.jwtAuth;
|
|
1783
|
-
const projectAccessKey = this.projectAccessKey;
|
|
1784
|
-
if (jwtAuth && jwtAuth.length > 0) {
|
|
1785
|
-
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
1786
|
-
}
|
|
1787
|
-
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
1788
|
-
headers['X-Access-Key'] = projectAccessKey;
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
// before the request is made
|
|
1792
|
-
init.headers = _extends({}, init.headers, headers);
|
|
1793
|
-
return fetch(input, init);
|
|
1794
|
-
};
|
|
1795
|
-
this.fetch = this._fetch;
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
class SequenceIndexerGateway extends IndexerGateway {
|
|
1799
|
-
constructor(hostname, projectAccessKey, jwtAuth) {
|
|
1800
|
-
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
1801
|
-
this.projectAccessKey = projectAccessKey;
|
|
1802
|
-
this.jwtAuth = jwtAuth;
|
|
1803
|
-
this._fetch = (input, init) => {
|
|
1804
|
-
// automatically include jwt and access key auth header to requests
|
|
1805
|
-
// if its been set on the api client
|
|
1806
|
-
const headers = {};
|
|
1807
|
-
const jwtAuth = this.jwtAuth;
|
|
1808
|
-
const projectAccessKey = this.projectAccessKey;
|
|
1809
|
-
if (jwtAuth && jwtAuth.length > 0) {
|
|
1810
|
-
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
1811
|
-
}
|
|
1812
|
-
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
1813
|
-
headers['X-Access-Key'] = projectAccessKey;
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
// before the request is made
|
|
1817
|
-
init.headers = _extends({}, init.headers, headers);
|
|
1818
|
-
return fetch(input, init);
|
|
1819
|
-
};
|
|
1820
|
-
this.fetch = this._fetch;
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
|
|
1824
|
-
exports.AbortedError = AbortedError$1;
|
|
1825
|
-
exports.AccessKeyMismatchError = AccessKeyMismatchError$1;
|
|
1826
|
-
exports.AccessKeyNotFoundError = AccessKeyNotFoundError$1;
|
|
1827
|
-
exports.AtLeastOneKeyError = AtLeastOneKeyError$1;
|
|
1828
|
-
exports.ContractType = ContractType$1;
|
|
1829
|
-
exports.ContractVerificationStatus = ContractVerificationStatus$1;
|
|
1830
|
-
exports.EventLogDataType = EventLogDataType$1;
|
|
1831
|
-
exports.EventLogType = EventLogType$1;
|
|
1832
|
-
exports.GeoblockedError = GeoblockedError$1;
|
|
1833
|
-
exports.Indexer = Indexer;
|
|
1834
|
-
exports.IndexerGateway = indexergw_gen;
|
|
1835
|
-
exports.InvalidArgumentError = InvalidArgumentError$1;
|
|
1836
|
-
exports.InvalidOriginError = InvalidOriginError$1;
|
|
1837
|
-
exports.InvalidServiceError = InvalidServiceError$1;
|
|
1838
|
-
exports.MaxAccessKeysError = MaxAccessKeysError$1;
|
|
1839
|
-
exports.MetadataCallFailedError = MetadataCallFailedError$1;
|
|
1840
|
-
exports.MethodNotFoundError = MethodNotFoundError$1;
|
|
1841
|
-
exports.NetworkType = NetworkType$1;
|
|
1842
|
-
exports.NoDefaultKeyError = NoDefaultKeyError$1;
|
|
1843
|
-
exports.NotFoundError = NotFoundError$1;
|
|
1844
|
-
exports.OrderStatus = OrderStatus$1;
|
|
1845
|
-
exports.PermissionDeniedError = PermissionDeniedError$1;
|
|
1846
|
-
exports.ProjectNotFoundError = ProjectNotFoundError$1;
|
|
1847
|
-
exports.QueryFailedError = QueryFailedError$1;
|
|
1848
|
-
exports.QuotaExceededError = QuotaExceededError$1;
|
|
1849
|
-
exports.RateLimitError = RateLimitError$1;
|
|
1850
|
-
exports.RateLimitedError = RateLimitedError$1;
|
|
1851
|
-
exports.RequestConflictError = RequestConflictError$1;
|
|
1852
|
-
exports.ResourceExhaustedError = ResourceExhaustedError$1;
|
|
1853
|
-
exports.ResourceStatus = ResourceStatus$1;
|
|
1854
|
-
exports.SequenceIndexer = SequenceIndexer;
|
|
1855
|
-
exports.SequenceIndexerGateway = SequenceIndexerGateway;
|
|
1856
|
-
exports.SessionExpiredError = SessionExpiredError$1;
|
|
1857
|
-
exports.SortOrder = SortOrder$1;
|
|
1858
|
-
exports.TimeoutError = TimeoutError$1;
|
|
1859
|
-
exports.TransactionStatus = TransactionStatus$1;
|
|
1860
|
-
exports.TransactionType = TransactionType$1;
|
|
1861
|
-
exports.TxnTransferType = TxnTransferType$1;
|
|
1862
|
-
exports.UnauthorizedError = UnauthorizedError$1;
|
|
1863
|
-
exports.UnauthorizedUserError = UnauthorizedUserError$1;
|
|
1864
|
-
exports.UnavailableError = UnavailableError$1;
|
|
1865
|
-
exports.VersionFromHeader = VersionFromHeader$1;
|
|
1866
|
-
exports.WebRPCSchemaHash = WebRPCSchemaHash$1;
|
|
1867
|
-
exports.WebRPCSchemaVersion = WebRPCSchemaVersion$1;
|
|
1868
|
-
exports.WebRPCVersion = WebRPCVersion$1;
|
|
1869
|
-
exports.WebrpcBadMethodError = WebrpcBadMethodError$1;
|
|
1870
|
-
exports.WebrpcBadRequestError = WebrpcBadRequestError$1;
|
|
1871
|
-
exports.WebrpcBadResponseError = WebrpcBadResponseError$1;
|
|
1872
|
-
exports.WebrpcBadRouteError = WebrpcBadRouteError$1;
|
|
1873
|
-
exports.WebrpcClientDisconnectedError = WebrpcClientDisconnectedError$1;
|
|
1874
|
-
exports.WebrpcEndpointError = WebrpcEndpointError$1;
|
|
1875
|
-
exports.WebrpcError = WebrpcError$1;
|
|
1876
|
-
exports.WebrpcHeader = WebrpcHeader$1;
|
|
1877
|
-
exports.WebrpcHeaderValue = WebrpcHeaderValue$1;
|
|
1878
|
-
exports.WebrpcInternalErrorError = WebrpcInternalErrorError$1;
|
|
1879
|
-
exports.WebrpcRequestFailedError = WebrpcRequestFailedError$1;
|
|
1880
|
-
exports.WebrpcServerPanicError = WebrpcServerPanicError$1;
|
|
1881
|
-
exports.WebrpcStreamFinishedError = WebrpcStreamFinishedError$1;
|
|
1882
|
-
exports.WebrpcStreamLostError = WebrpcStreamLostError$1;
|
|
1883
|
-
exports.errors = errors$1;
|