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