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