@0xsequence/api 1.9.23 → 1.9.25
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-api.cjs.dev.js +494 -97
- package/dist/0xsequence-api.cjs.prod.js +494 -97
- package/dist/0xsequence-api.esm.js +474 -98
- package/dist/declarations/src/api.gen.d.ts +202 -89
- package/package.json +1 -1
- package/src/api.gen.ts +1079 -410
|
@@ -14,11 +14,11 @@ function _extends() {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/* eslint-disable */
|
|
17
|
-
// sequence-api v0.4.0
|
|
17
|
+
// sequence-api v0.4.0 3c1782dee5a602d773450bdb42c84515771d30d1
|
|
18
18
|
// --
|
|
19
|
-
// Code generated by webrpc-gen@v0.18.
|
|
19
|
+
// Code generated by webrpc-gen@v0.18.6 with typescript generator. DO NOT EDIT.
|
|
20
20
|
//
|
|
21
|
-
// webrpc-gen -schema=api.ridl -target=typescript
|
|
21
|
+
// webrpc-gen -schema=api.ridl -target=typescript -client -out=./clients/api.gen.ts
|
|
22
22
|
|
|
23
23
|
// WebRPC description and code-gen version
|
|
24
24
|
const WebRPCVersion = 'v1';
|
|
@@ -27,7 +27,7 @@ const WebRPCVersion = 'v1';
|
|
|
27
27
|
const WebRPCSchemaVersion = 'v0.4.0';
|
|
28
28
|
|
|
29
29
|
// Schema hash generated from your RIDL schema
|
|
30
|
-
const WebRPCSchemaHash = '
|
|
30
|
+
const WebRPCSchemaHash = '3c1782dee5a602d773450bdb42c84515771d30d1';
|
|
31
31
|
|
|
32
32
|
//
|
|
33
33
|
// Types
|
|
@@ -46,53 +46,73 @@ class API {
|
|
|
46
46
|
this.hostname = void 0;
|
|
47
47
|
this.fetch = void 0;
|
|
48
48
|
this.path = '/rpc/API/';
|
|
49
|
-
this.ping = headers => {
|
|
50
|
-
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers)).then(res => {
|
|
49
|
+
this.ping = (headers, signal) => {
|
|
50
|
+
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
51
51
|
return buildResponse(res).then(_data => {
|
|
52
52
|
return {
|
|
53
53
|
status: _data.status
|
|
54
54
|
};
|
|
55
55
|
});
|
|
56
|
+
}, error => {
|
|
57
|
+
throw WebrpcRequestFailedError.new({
|
|
58
|
+
cause: `fetch(): ${error.message || ''}`
|
|
59
|
+
});
|
|
56
60
|
});
|
|
57
61
|
};
|
|
58
|
-
this.version = headers => {
|
|
59
|
-
return this.fetch(this.url('Version'), createHTTPRequest({}, headers)).then(res => {
|
|
62
|
+
this.version = (headers, signal) => {
|
|
63
|
+
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
60
64
|
return buildResponse(res).then(_data => {
|
|
61
65
|
return {
|
|
62
66
|
version: _data.version
|
|
63
67
|
};
|
|
64
68
|
});
|
|
69
|
+
}, error => {
|
|
70
|
+
throw WebrpcRequestFailedError.new({
|
|
71
|
+
cause: `fetch(): ${error.message || ''}`
|
|
72
|
+
});
|
|
65
73
|
});
|
|
66
74
|
};
|
|
67
|
-
this.runtimeStatus = headers => {
|
|
68
|
-
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers)).then(res => {
|
|
75
|
+
this.runtimeStatus = (headers, signal) => {
|
|
76
|
+
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
69
77
|
return buildResponse(res).then(_data => {
|
|
70
78
|
return {
|
|
71
79
|
status: _data.status
|
|
72
80
|
};
|
|
73
81
|
});
|
|
82
|
+
}, error => {
|
|
83
|
+
throw WebrpcRequestFailedError.new({
|
|
84
|
+
cause: `fetch(): ${error.message || ''}`
|
|
85
|
+
});
|
|
74
86
|
});
|
|
75
87
|
};
|
|
76
|
-
this.clock = headers => {
|
|
77
|
-
return this.fetch(this.url('Clock'), createHTTPRequest({}, headers)).then(res => {
|
|
88
|
+
this.clock = (headers, signal) => {
|
|
89
|
+
return this.fetch(this.url('Clock'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
78
90
|
return buildResponse(res).then(_data => {
|
|
79
91
|
return {
|
|
80
92
|
serverTime: _data.serverTime
|
|
81
93
|
};
|
|
82
94
|
});
|
|
95
|
+
}, error => {
|
|
96
|
+
throw WebrpcRequestFailedError.new({
|
|
97
|
+
cause: `fetch(): ${error.message || ''}`
|
|
98
|
+
});
|
|
83
99
|
});
|
|
84
100
|
};
|
|
85
|
-
this.getSequenceContext = headers => {
|
|
86
|
-
return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers)).then(res => {
|
|
101
|
+
this.getSequenceContext = (headers, signal) => {
|
|
102
|
+
return this.fetch(this.url('GetSequenceContext'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
87
103
|
return buildResponse(res).then(_data => {
|
|
88
104
|
return {
|
|
89
105
|
data: _data.data
|
|
90
106
|
};
|
|
91
107
|
});
|
|
108
|
+
}, error => {
|
|
109
|
+
throw WebrpcRequestFailedError.new({
|
|
110
|
+
cause: `fetch(): ${error.message || ''}`
|
|
111
|
+
});
|
|
92
112
|
});
|
|
93
113
|
};
|
|
94
|
-
this.getAuthToken = (args, headers) => {
|
|
95
|
-
return this.fetch(this.url('GetAuthToken'), createHTTPRequest(args, headers)).then(res => {
|
|
114
|
+
this.getAuthToken = (args, headers, signal) => {
|
|
115
|
+
return this.fetch(this.url('GetAuthToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
96
116
|
return buildResponse(res).then(_data => {
|
|
97
117
|
return {
|
|
98
118
|
status: _data.status,
|
|
@@ -101,10 +121,14 @@ class API {
|
|
|
101
121
|
user: _data.user
|
|
102
122
|
};
|
|
103
123
|
});
|
|
124
|
+
}, error => {
|
|
125
|
+
throw WebrpcRequestFailedError.new({
|
|
126
|
+
cause: `fetch(): ${error.message || ''}`
|
|
127
|
+
});
|
|
104
128
|
});
|
|
105
129
|
};
|
|
106
|
-
this.getAuthToken2 = (args, headers) => {
|
|
107
|
-
return this.fetch(this.url('GetAuthToken2'), createHTTPRequest(args, headers)).then(res => {
|
|
130
|
+
this.getAuthToken2 = (args, headers, signal) => {
|
|
131
|
+
return this.fetch(this.url('GetAuthToken2'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
108
132
|
return buildResponse(res).then(_data => {
|
|
109
133
|
return {
|
|
110
134
|
status: _data.status,
|
|
@@ -113,327 +137,484 @@ class API {
|
|
|
113
137
|
user: _data.user
|
|
114
138
|
};
|
|
115
139
|
});
|
|
140
|
+
}, error => {
|
|
141
|
+
throw WebrpcRequestFailedError.new({
|
|
142
|
+
cause: `fetch(): ${error.message || ''}`
|
|
143
|
+
});
|
|
116
144
|
});
|
|
117
145
|
};
|
|
118
|
-
this.sendPasswordlessLink = (args, headers) => {
|
|
119
|
-
return this.fetch(this.url('SendPasswordlessLink'), createHTTPRequest(args, headers)).then(res => {
|
|
146
|
+
this.sendPasswordlessLink = (args, headers, signal) => {
|
|
147
|
+
return this.fetch(this.url('SendPasswordlessLink'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
120
148
|
return buildResponse(res).then(_data => {
|
|
121
149
|
return {
|
|
122
150
|
status: _data.status
|
|
123
151
|
};
|
|
124
152
|
});
|
|
153
|
+
}, error => {
|
|
154
|
+
throw WebrpcRequestFailedError.new({
|
|
155
|
+
cause: `fetch(): ${error.message || ''}`
|
|
156
|
+
});
|
|
125
157
|
});
|
|
126
158
|
};
|
|
127
|
-
this.friendList = (args, headers) => {
|
|
128
|
-
return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers)).then(res => {
|
|
159
|
+
this.friendList = (args, headers, signal) => {
|
|
160
|
+
return this.fetch(this.url('FriendList'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
129
161
|
return buildResponse(res).then(_data => {
|
|
130
162
|
return {
|
|
131
163
|
page: _data.page,
|
|
132
164
|
friends: _data.friends
|
|
133
165
|
};
|
|
134
166
|
});
|
|
167
|
+
}, error => {
|
|
168
|
+
throw WebrpcRequestFailedError.new({
|
|
169
|
+
cause: `fetch(): ${error.message || ''}`
|
|
170
|
+
});
|
|
135
171
|
});
|
|
136
172
|
};
|
|
137
|
-
this.getFriendByAddress = (args, headers) => {
|
|
138
|
-
return this.fetch(this.url('GetFriendByAddress'), createHTTPRequest(args, headers)).then(res => {
|
|
173
|
+
this.getFriendByAddress = (args, headers, signal) => {
|
|
174
|
+
return this.fetch(this.url('GetFriendByAddress'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
139
175
|
return buildResponse(res).then(_data => {
|
|
140
176
|
return {
|
|
141
177
|
status: _data.status,
|
|
142
178
|
friend: _data.friend
|
|
143
179
|
};
|
|
144
180
|
});
|
|
181
|
+
}, error => {
|
|
182
|
+
throw WebrpcRequestFailedError.new({
|
|
183
|
+
cause: `fetch(): ${error.message || ''}`
|
|
184
|
+
});
|
|
145
185
|
});
|
|
146
186
|
};
|
|
147
|
-
this.searchFriends = (args, headers) => {
|
|
148
|
-
return this.fetch(this.url('SearchFriends'), createHTTPRequest(args, headers)).then(res => {
|
|
187
|
+
this.searchFriends = (args, headers, signal) => {
|
|
188
|
+
return this.fetch(this.url('SearchFriends'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
149
189
|
return buildResponse(res).then(_data => {
|
|
150
190
|
return {
|
|
151
191
|
friends: _data.friends
|
|
152
192
|
};
|
|
153
193
|
});
|
|
194
|
+
}, error => {
|
|
195
|
+
throw WebrpcRequestFailedError.new({
|
|
196
|
+
cause: `fetch(): ${error.message || ''}`
|
|
197
|
+
});
|
|
154
198
|
});
|
|
155
199
|
};
|
|
156
|
-
this.addFriend = (args, headers) => {
|
|
157
|
-
return this.fetch(this.url('AddFriend'), createHTTPRequest(args, headers)).then(res => {
|
|
200
|
+
this.addFriend = (args, headers, signal) => {
|
|
201
|
+
return this.fetch(this.url('AddFriend'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
158
202
|
return buildResponse(res).then(_data => {
|
|
159
203
|
return {
|
|
160
204
|
status: _data.status,
|
|
161
205
|
friend: _data.friend
|
|
162
206
|
};
|
|
163
207
|
});
|
|
208
|
+
}, error => {
|
|
209
|
+
throw WebrpcRequestFailedError.new({
|
|
210
|
+
cause: `fetch(): ${error.message || ''}`
|
|
211
|
+
});
|
|
164
212
|
});
|
|
165
213
|
};
|
|
166
|
-
this.updateFriendNickname = (args, headers) => {
|
|
167
|
-
return this.fetch(this.url('UpdateFriendNickname'), createHTTPRequest(args, headers)).then(res => {
|
|
214
|
+
this.updateFriendNickname = (args, headers, signal) => {
|
|
215
|
+
return this.fetch(this.url('UpdateFriendNickname'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
168
216
|
return buildResponse(res).then(_data => {
|
|
169
217
|
return {
|
|
170
218
|
status: _data.status,
|
|
171
219
|
friend: _data.friend
|
|
172
220
|
};
|
|
173
221
|
});
|
|
222
|
+
}, error => {
|
|
223
|
+
throw WebrpcRequestFailedError.new({
|
|
224
|
+
cause: `fetch(): ${error.message || ''}`
|
|
225
|
+
});
|
|
174
226
|
});
|
|
175
227
|
};
|
|
176
|
-
this.removeFriend = (args, headers) => {
|
|
177
|
-
return this.fetch(this.url('RemoveFriend'), createHTTPRequest(args, headers)).then(res => {
|
|
228
|
+
this.removeFriend = (args, headers, signal) => {
|
|
229
|
+
return this.fetch(this.url('RemoveFriend'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
178
230
|
return buildResponse(res).then(_data => {
|
|
179
231
|
return {
|
|
180
232
|
status: _data.status
|
|
181
233
|
};
|
|
182
234
|
});
|
|
235
|
+
}, error => {
|
|
236
|
+
throw WebrpcRequestFailedError.new({
|
|
237
|
+
cause: `fetch(): ${error.message || ''}`
|
|
238
|
+
});
|
|
183
239
|
});
|
|
184
240
|
};
|
|
185
|
-
this.contractCall = (args, headers) => {
|
|
186
|
-
return this.fetch(this.url('ContractCall'), createHTTPRequest(args, headers)).then(res => {
|
|
241
|
+
this.contractCall = (args, headers, signal) => {
|
|
242
|
+
return this.fetch(this.url('ContractCall'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
187
243
|
return buildResponse(res).then(_data => {
|
|
188
244
|
return {
|
|
189
245
|
returns: _data.returns
|
|
190
246
|
};
|
|
191
247
|
});
|
|
248
|
+
}, error => {
|
|
249
|
+
throw WebrpcRequestFailedError.new({
|
|
250
|
+
cause: `fetch(): ${error.message || ''}`
|
|
251
|
+
});
|
|
192
252
|
});
|
|
193
253
|
};
|
|
194
|
-
this.decodeContractCall = (args, headers) => {
|
|
195
|
-
return this.fetch(this.url('DecodeContractCall'), createHTTPRequest(args, headers)).then(res => {
|
|
254
|
+
this.decodeContractCall = (args, headers, signal) => {
|
|
255
|
+
return this.fetch(this.url('DecodeContractCall'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
196
256
|
return buildResponse(res).then(_data => {
|
|
197
257
|
return {
|
|
198
258
|
call: _data.call
|
|
199
259
|
};
|
|
200
260
|
});
|
|
261
|
+
}, error => {
|
|
262
|
+
throw WebrpcRequestFailedError.new({
|
|
263
|
+
cause: `fetch(): ${error.message || ''}`
|
|
264
|
+
});
|
|
201
265
|
});
|
|
202
266
|
};
|
|
203
|
-
this.lookupContractCallSelectors = (args, headers) => {
|
|
204
|
-
return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers)).then(res => {
|
|
267
|
+
this.lookupContractCallSelectors = (args, headers, signal) => {
|
|
268
|
+
return this.fetch(this.url('LookupContractCallSelectors'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
205
269
|
return buildResponse(res).then(_data => {
|
|
206
270
|
return {
|
|
207
271
|
signatures: _data.signatures
|
|
208
272
|
};
|
|
209
273
|
});
|
|
274
|
+
}, error => {
|
|
275
|
+
throw WebrpcRequestFailedError.new({
|
|
276
|
+
cause: `fetch(): ${error.message || ''}`
|
|
277
|
+
});
|
|
210
278
|
});
|
|
211
279
|
};
|
|
212
|
-
this.userStorageFetch = (args, headers) => {
|
|
213
|
-
return this.fetch(this.url('UserStorageFetch'), createHTTPRequest(args, headers)).then(res => {
|
|
280
|
+
this.userStorageFetch = (args, headers, signal) => {
|
|
281
|
+
return this.fetch(this.url('UserStorageFetch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
214
282
|
return buildResponse(res).then(_data => {
|
|
215
283
|
return {
|
|
216
284
|
object: _data.object
|
|
217
285
|
};
|
|
218
286
|
});
|
|
287
|
+
}, error => {
|
|
288
|
+
throw WebrpcRequestFailedError.new({
|
|
289
|
+
cause: `fetch(): ${error.message || ''}`
|
|
290
|
+
});
|
|
219
291
|
});
|
|
220
292
|
};
|
|
221
|
-
this.userStorageSave = (args, headers) => {
|
|
222
|
-
return this.fetch(this.url('UserStorageSave'), createHTTPRequest(args, headers)).then(res => {
|
|
293
|
+
this.userStorageSave = (args, headers, signal) => {
|
|
294
|
+
return this.fetch(this.url('UserStorageSave'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
223
295
|
return buildResponse(res).then(_data => {
|
|
224
296
|
return {
|
|
225
297
|
ok: _data.ok
|
|
226
298
|
};
|
|
227
299
|
});
|
|
300
|
+
}, error => {
|
|
301
|
+
throw WebrpcRequestFailedError.new({
|
|
302
|
+
cause: `fetch(): ${error.message || ''}`
|
|
303
|
+
});
|
|
228
304
|
});
|
|
229
305
|
};
|
|
230
|
-
this.userStorageDelete = (args, headers) => {
|
|
231
|
-
return this.fetch(this.url('UserStorageDelete'), createHTTPRequest(args, headers)).then(res => {
|
|
306
|
+
this.userStorageDelete = (args, headers, signal) => {
|
|
307
|
+
return this.fetch(this.url('UserStorageDelete'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
232
308
|
return buildResponse(res).then(_data => {
|
|
233
309
|
return {
|
|
234
310
|
ok: _data.ok
|
|
235
311
|
};
|
|
236
312
|
});
|
|
313
|
+
}, error => {
|
|
314
|
+
throw WebrpcRequestFailedError.new({
|
|
315
|
+
cause: `fetch(): ${error.message || ''}`
|
|
316
|
+
});
|
|
237
317
|
});
|
|
238
318
|
};
|
|
239
|
-
this.userStorageFetchAll = (args, headers) => {
|
|
240
|
-
return this.fetch(this.url('UserStorageFetchAll'), createHTTPRequest(args, headers)).then(res => {
|
|
319
|
+
this.userStorageFetchAll = (args, headers, signal) => {
|
|
320
|
+
return this.fetch(this.url('UserStorageFetchAll'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
241
321
|
return buildResponse(res).then(_data => {
|
|
242
322
|
return {
|
|
243
323
|
objects: _data.objects
|
|
244
324
|
};
|
|
245
325
|
});
|
|
326
|
+
}, error => {
|
|
327
|
+
throw WebrpcRequestFailedError.new({
|
|
328
|
+
cause: `fetch(): ${error.message || ''}`
|
|
329
|
+
});
|
|
246
330
|
});
|
|
247
331
|
};
|
|
248
|
-
this.getMoonpayLink = (args, headers) => {
|
|
249
|
-
return this.fetch(this.url('GetMoonpayLink'), createHTTPRequest(args, headers)).then(res => {
|
|
332
|
+
this.getMoonpayLink = (args, headers, signal) => {
|
|
333
|
+
return this.fetch(this.url('GetMoonpayLink'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
250
334
|
return buildResponse(res).then(_data => {
|
|
251
335
|
return {
|
|
252
336
|
signedUrl: _data.signedUrl
|
|
253
337
|
};
|
|
254
338
|
});
|
|
339
|
+
}, error => {
|
|
340
|
+
throw WebrpcRequestFailedError.new({
|
|
341
|
+
cause: `fetch(): ${error.message || ''}`
|
|
342
|
+
});
|
|
255
343
|
});
|
|
256
344
|
};
|
|
257
|
-
this.getSardineClientToken = headers => {
|
|
258
|
-
return this.fetch(this.url('GetSardineClientToken'), createHTTPRequest({}, headers)).then(res => {
|
|
345
|
+
this.getSardineClientToken = (headers, signal) => {
|
|
346
|
+
return this.fetch(this.url('GetSardineClientToken'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
259
347
|
return buildResponse(res).then(_data => {
|
|
260
348
|
return {
|
|
261
349
|
token: _data.token
|
|
262
350
|
};
|
|
263
351
|
});
|
|
352
|
+
}, error => {
|
|
353
|
+
throw WebrpcRequestFailedError.new({
|
|
354
|
+
cause: `fetch(): ${error.message || ''}`
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
};
|
|
358
|
+
this.getSardineNFTCheckoutToken = (args, headers, signal) => {
|
|
359
|
+
return this.fetch(this.url('GetSardineNFTCheckoutToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
360
|
+
return buildResponse(res).then(_data => {
|
|
361
|
+
return {
|
|
362
|
+
resp: _data.resp
|
|
363
|
+
};
|
|
364
|
+
});
|
|
365
|
+
}, error => {
|
|
366
|
+
throw WebrpcRequestFailedError.new({
|
|
367
|
+
cause: `fetch(): ${error.message || ''}`
|
|
368
|
+
});
|
|
264
369
|
});
|
|
265
370
|
};
|
|
266
|
-
this.
|
|
267
|
-
return this.fetch(this.url('
|
|
371
|
+
this.getSardineNFTCheckoutOrderStatus = (args, headers, signal) => {
|
|
372
|
+
return this.fetch(this.url('GetSardineNFTCheckoutOrderStatus'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
268
373
|
return buildResponse(res).then(_data => {
|
|
269
374
|
return {
|
|
270
375
|
resp: _data.resp
|
|
271
376
|
};
|
|
272
377
|
});
|
|
378
|
+
}, error => {
|
|
379
|
+
throw WebrpcRequestFailedError.new({
|
|
380
|
+
cause: `fetch(): ${error.message || ''}`
|
|
381
|
+
});
|
|
273
382
|
});
|
|
274
383
|
};
|
|
275
|
-
this.resolveENSAddress = (args, headers) => {
|
|
276
|
-
return this.fetch(this.url('ResolveENSAddress'), createHTTPRequest(args, headers)).then(res => {
|
|
384
|
+
this.resolveENSAddress = (args, headers, signal) => {
|
|
385
|
+
return this.fetch(this.url('ResolveENSAddress'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
277
386
|
return buildResponse(res).then(_data => {
|
|
278
387
|
return {
|
|
279
388
|
address: _data.address,
|
|
280
389
|
ok: _data.ok
|
|
281
390
|
};
|
|
282
391
|
});
|
|
392
|
+
}, error => {
|
|
393
|
+
throw WebrpcRequestFailedError.new({
|
|
394
|
+
cause: `fetch(): ${error.message || ''}`
|
|
395
|
+
});
|
|
283
396
|
});
|
|
284
397
|
};
|
|
285
|
-
this.isValidSignature = (args, headers) => {
|
|
286
|
-
return this.fetch(this.url('IsValidSignature'), createHTTPRequest(args, headers)).then(res => {
|
|
398
|
+
this.isValidSignature = (args, headers, signal) => {
|
|
399
|
+
return this.fetch(this.url('IsValidSignature'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
287
400
|
return buildResponse(res).then(_data => {
|
|
288
401
|
return {
|
|
289
402
|
isValid: _data.isValid
|
|
290
403
|
};
|
|
291
404
|
});
|
|
405
|
+
}, error => {
|
|
406
|
+
throw WebrpcRequestFailedError.new({
|
|
407
|
+
cause: `fetch(): ${error.message || ''}`
|
|
408
|
+
});
|
|
292
409
|
});
|
|
293
410
|
};
|
|
294
|
-
this.isValidMessageSignature = (args, headers) => {
|
|
295
|
-
return this.fetch(this.url('IsValidMessageSignature'), createHTTPRequest(args, headers)).then(res => {
|
|
411
|
+
this.isValidMessageSignature = (args, headers, signal) => {
|
|
412
|
+
return this.fetch(this.url('IsValidMessageSignature'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
296
413
|
return buildResponse(res).then(_data => {
|
|
297
414
|
return {
|
|
298
415
|
isValid: _data.isValid
|
|
299
416
|
};
|
|
300
417
|
});
|
|
418
|
+
}, error => {
|
|
419
|
+
throw WebrpcRequestFailedError.new({
|
|
420
|
+
cause: `fetch(): ${error.message || ''}`
|
|
421
|
+
});
|
|
301
422
|
});
|
|
302
423
|
};
|
|
303
|
-
this.isValidTypedDataSignature = (args, headers) => {
|
|
304
|
-
return this.fetch(this.url('IsValidTypedDataSignature'), createHTTPRequest(args, headers)).then(res => {
|
|
424
|
+
this.isValidTypedDataSignature = (args, headers, signal) => {
|
|
425
|
+
return this.fetch(this.url('IsValidTypedDataSignature'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
305
426
|
return buildResponse(res).then(_data => {
|
|
306
427
|
return {
|
|
307
428
|
isValid: _data.isValid
|
|
308
429
|
};
|
|
309
430
|
});
|
|
431
|
+
}, error => {
|
|
432
|
+
throw WebrpcRequestFailedError.new({
|
|
433
|
+
cause: `fetch(): ${error.message || ''}`
|
|
434
|
+
});
|
|
310
435
|
});
|
|
311
436
|
};
|
|
312
|
-
this.isValidETHAuthProof = (args, headers) => {
|
|
313
|
-
return this.fetch(this.url('IsValidETHAuthProof'), createHTTPRequest(args, headers)).then(res => {
|
|
437
|
+
this.isValidETHAuthProof = (args, headers, signal) => {
|
|
438
|
+
return this.fetch(this.url('IsValidETHAuthProof'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
314
439
|
return buildResponse(res).then(_data => {
|
|
315
440
|
return {
|
|
316
441
|
isValid: _data.isValid
|
|
317
442
|
};
|
|
318
443
|
});
|
|
444
|
+
}, error => {
|
|
445
|
+
throw WebrpcRequestFailedError.new({
|
|
446
|
+
cause: `fetch(): ${error.message || ''}`
|
|
447
|
+
});
|
|
319
448
|
});
|
|
320
449
|
};
|
|
321
|
-
this.getCoinPrices = (args, headers) => {
|
|
322
|
-
return this.fetch(this.url('GetCoinPrices'), createHTTPRequest(args, headers)).then(res => {
|
|
450
|
+
this.getCoinPrices = (args, headers, signal) => {
|
|
451
|
+
return this.fetch(this.url('GetCoinPrices'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
323
452
|
return buildResponse(res).then(_data => {
|
|
324
453
|
return {
|
|
325
454
|
tokenPrices: _data.tokenPrices
|
|
326
455
|
};
|
|
327
456
|
});
|
|
457
|
+
}, error => {
|
|
458
|
+
throw WebrpcRequestFailedError.new({
|
|
459
|
+
cause: `fetch(): ${error.message || ''}`
|
|
460
|
+
});
|
|
328
461
|
});
|
|
329
462
|
};
|
|
330
|
-
this.getCollectiblePrices = (args, headers) => {
|
|
331
|
-
return this.fetch(this.url('GetCollectiblePrices'), createHTTPRequest(args, headers)).then(res => {
|
|
463
|
+
this.getCollectiblePrices = (args, headers, signal) => {
|
|
464
|
+
return this.fetch(this.url('GetCollectiblePrices'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
332
465
|
return buildResponse(res).then(_data => {
|
|
333
466
|
return {
|
|
334
467
|
tokenPrices: _data.tokenPrices
|
|
335
468
|
};
|
|
336
469
|
});
|
|
470
|
+
}, error => {
|
|
471
|
+
throw WebrpcRequestFailedError.new({
|
|
472
|
+
cause: `fetch(): ${error.message || ''}`
|
|
473
|
+
});
|
|
337
474
|
});
|
|
338
475
|
};
|
|
339
|
-
this.getExchangeRate = (args, headers) => {
|
|
340
|
-
return this.fetch(this.url('GetExchangeRate'), createHTTPRequest(args, headers)).then(res => {
|
|
476
|
+
this.getExchangeRate = (args, headers, signal) => {
|
|
477
|
+
return this.fetch(this.url('GetExchangeRate'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
341
478
|
return buildResponse(res).then(_data => {
|
|
342
479
|
return {
|
|
343
480
|
exchangeRate: _data.exchangeRate
|
|
344
481
|
};
|
|
345
482
|
});
|
|
483
|
+
}, error => {
|
|
484
|
+
throw WebrpcRequestFailedError.new({
|
|
485
|
+
cause: `fetch(): ${error.message || ''}`
|
|
486
|
+
});
|
|
346
487
|
});
|
|
347
488
|
};
|
|
348
|
-
this.memoryStore = (args, headers) => {
|
|
349
|
-
return this.fetch(this.url('MemoryStore'), createHTTPRequest(args, headers)).then(res => {
|
|
489
|
+
this.memoryStore = (args, headers, signal) => {
|
|
490
|
+
return this.fetch(this.url('MemoryStore'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
350
491
|
return buildResponse(res).then(_data => {
|
|
351
492
|
return {
|
|
352
493
|
ok: _data.ok
|
|
353
494
|
};
|
|
354
495
|
});
|
|
496
|
+
}, error => {
|
|
497
|
+
throw WebrpcRequestFailedError.new({
|
|
498
|
+
cause: `fetch(): ${error.message || ''}`
|
|
499
|
+
});
|
|
355
500
|
});
|
|
356
501
|
};
|
|
357
|
-
this.memoryLoad = (args, headers) => {
|
|
358
|
-
return this.fetch(this.url('MemoryLoad'), createHTTPRequest(args, headers)).then(res => {
|
|
502
|
+
this.memoryLoad = (args, headers, signal) => {
|
|
503
|
+
return this.fetch(this.url('MemoryLoad'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
359
504
|
return buildResponse(res).then(_data => {
|
|
360
505
|
return {
|
|
361
506
|
value: _data.value
|
|
362
507
|
};
|
|
363
508
|
});
|
|
509
|
+
}, error => {
|
|
510
|
+
throw WebrpcRequestFailedError.new({
|
|
511
|
+
cause: `fetch(): ${error.message || ''}`
|
|
512
|
+
});
|
|
364
513
|
});
|
|
365
514
|
};
|
|
366
|
-
this.getInviteInfo = headers => {
|
|
367
|
-
return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers)).then(res => {
|
|
515
|
+
this.getInviteInfo = (headers, signal) => {
|
|
516
|
+
return this.fetch(this.url('GetInviteInfo'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
368
517
|
return buildResponse(res).then(_data => {
|
|
369
518
|
return {
|
|
370
519
|
inviteInfo: _data.inviteInfo
|
|
371
520
|
};
|
|
372
521
|
});
|
|
522
|
+
}, error => {
|
|
523
|
+
throw WebrpcRequestFailedError.new({
|
|
524
|
+
cause: `fetch(): ${error.message || ''}`
|
|
525
|
+
});
|
|
373
526
|
});
|
|
374
527
|
};
|
|
375
|
-
this.isValidAccessCode = (args, headers) => {
|
|
376
|
-
return this.fetch(this.url('IsValidAccessCode'), createHTTPRequest(args, headers)).then(res => {
|
|
528
|
+
this.isValidAccessCode = (args, headers, signal) => {
|
|
529
|
+
return this.fetch(this.url('IsValidAccessCode'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
377
530
|
return buildResponse(res).then(_data => {
|
|
378
531
|
return {
|
|
379
532
|
status: _data.status
|
|
380
533
|
};
|
|
381
534
|
});
|
|
535
|
+
}, error => {
|
|
536
|
+
throw WebrpcRequestFailedError.new({
|
|
537
|
+
cause: `fetch(): ${error.message || ''}`
|
|
538
|
+
});
|
|
382
539
|
});
|
|
383
540
|
};
|
|
384
|
-
this.internalClaimAccessCode = (args, headers) => {
|
|
385
|
-
return this.fetch(this.url('InternalClaimAccessCode'), createHTTPRequest(args, headers)).then(res => {
|
|
541
|
+
this.internalClaimAccessCode = (args, headers, signal) => {
|
|
542
|
+
return this.fetch(this.url('InternalClaimAccessCode'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
386
543
|
return buildResponse(res).then(_data => {
|
|
387
544
|
return {
|
|
388
545
|
status: _data.status
|
|
389
546
|
};
|
|
390
547
|
});
|
|
548
|
+
}, error => {
|
|
549
|
+
throw WebrpcRequestFailedError.new({
|
|
550
|
+
cause: `fetch(): ${error.message || ''}`
|
|
551
|
+
});
|
|
391
552
|
});
|
|
392
553
|
};
|
|
393
|
-
this.blockNumberAtTime = (args, headers) => {
|
|
394
|
-
return this.fetch(this.url('BlockNumberAtTime'), createHTTPRequest(args, headers)).then(res => {
|
|
554
|
+
this.blockNumberAtTime = (args, headers, signal) => {
|
|
555
|
+
return this.fetch(this.url('BlockNumberAtTime'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
395
556
|
return buildResponse(res).then(_data => {
|
|
396
557
|
return {
|
|
397
558
|
blocks: _data.blocks
|
|
398
559
|
};
|
|
399
560
|
});
|
|
561
|
+
}, error => {
|
|
562
|
+
throw WebrpcRequestFailedError.new({
|
|
563
|
+
cause: `fetch(): ${error.message || ''}`
|
|
564
|
+
});
|
|
400
565
|
});
|
|
401
566
|
};
|
|
402
|
-
this.paperSessionSecret = (args, headers) => {
|
|
403
|
-
return this.fetch(this.url('PaperSessionSecret'), createHTTPRequest(args, headers)).then(res => {
|
|
567
|
+
this.paperSessionSecret = (args, headers, signal) => {
|
|
568
|
+
return this.fetch(this.url('PaperSessionSecret'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
404
569
|
return buildResponse(res).then(_data => {
|
|
405
570
|
return {
|
|
406
571
|
secret: _data.secret
|
|
407
572
|
};
|
|
408
573
|
});
|
|
574
|
+
}, error => {
|
|
575
|
+
throw WebrpcRequestFailedError.new({
|
|
576
|
+
cause: `fetch(): ${error.message || ''}`
|
|
577
|
+
});
|
|
409
578
|
});
|
|
410
579
|
};
|
|
411
|
-
this.paperSessionSecret2 = (args, headers) => {
|
|
412
|
-
return this.fetch(this.url('PaperSessionSecret2'), createHTTPRequest(args, headers)).then(res => {
|
|
580
|
+
this.paperSessionSecret2 = (args, headers, signal) => {
|
|
581
|
+
return this.fetch(this.url('PaperSessionSecret2'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
413
582
|
return buildResponse(res).then(_data => {
|
|
414
583
|
return {
|
|
415
584
|
secret: _data.secret
|
|
416
585
|
};
|
|
417
586
|
});
|
|
587
|
+
}, error => {
|
|
588
|
+
throw WebrpcRequestFailedError.new({
|
|
589
|
+
cause: `fetch(): ${error.message || ''}`
|
|
590
|
+
});
|
|
418
591
|
});
|
|
419
592
|
};
|
|
420
|
-
this.linkWallet = (args, headers) => {
|
|
421
|
-
return this.fetch(this.url('LinkWallet'), createHTTPRequest(args, headers)).then(res => {
|
|
593
|
+
this.linkWallet = (args, headers, signal) => {
|
|
594
|
+
return this.fetch(this.url('LinkWallet'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
422
595
|
return buildResponse(res).then(_data => {
|
|
423
596
|
return {
|
|
424
597
|
status: _data.status,
|
|
425
598
|
linkedWalletAddress: _data.linkedWalletAddress
|
|
426
599
|
};
|
|
427
600
|
});
|
|
601
|
+
}, error => {
|
|
602
|
+
throw WebrpcRequestFailedError.new({
|
|
603
|
+
cause: `fetch(): ${error.message || ''}`
|
|
604
|
+
});
|
|
428
605
|
});
|
|
429
606
|
};
|
|
430
|
-
this.getLinkedWallets = (args, headers) => {
|
|
431
|
-
return this.fetch(this.url('GetLinkedWallets'), createHTTPRequest(args, headers)).then(res => {
|
|
607
|
+
this.getLinkedWallets = (args, headers, signal) => {
|
|
608
|
+
return this.fetch(this.url('GetLinkedWallets'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
432
609
|
return buildResponse(res).then(_data => {
|
|
433
610
|
return {
|
|
434
611
|
linkedWallets: _data.linkedWallets
|
|
435
612
|
};
|
|
436
613
|
});
|
|
614
|
+
}, error => {
|
|
615
|
+
throw WebrpcRequestFailedError.new({
|
|
616
|
+
cause: `fetch(): ${error.message || ''}`
|
|
617
|
+
});
|
|
437
618
|
});
|
|
438
619
|
};
|
|
439
620
|
this.hostname = hostname;
|
|
@@ -443,13 +624,14 @@ class API {
|
|
|
443
624
|
return this.hostname + this.path + name;
|
|
444
625
|
}
|
|
445
626
|
}
|
|
446
|
-
const createHTTPRequest = (body = {}, headers = {}) => {
|
|
627
|
+
const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
|
|
447
628
|
return {
|
|
448
629
|
method: 'POST',
|
|
449
630
|
headers: _extends({}, headers, {
|
|
450
631
|
'Content-Type': 'application/json'
|
|
451
632
|
}),
|
|
452
|
-
body: JSON.stringify(body || {})
|
|
633
|
+
body: JSON.stringify(body || {}),
|
|
634
|
+
signal
|
|
453
635
|
};
|
|
454
636
|
};
|
|
455
637
|
const buildResponse = res => {
|
|
@@ -457,20 +639,214 @@ const buildResponse = res => {
|
|
|
457
639
|
let data;
|
|
458
640
|
try {
|
|
459
641
|
data = JSON.parse(text);
|
|
460
|
-
} catch (
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
642
|
+
} catch (error) {
|
|
643
|
+
let message = '';
|
|
644
|
+
if (error instanceof Error) {
|
|
645
|
+
message = error.message;
|
|
646
|
+
}
|
|
647
|
+
throw WebrpcBadResponseError.new({
|
|
648
|
+
status: res.status,
|
|
649
|
+
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
650
|
+
});
|
|
466
651
|
}
|
|
467
652
|
if (!res.ok) {
|
|
468
|
-
|
|
653
|
+
const code = typeof data.code === 'number' ? data.code : 0;
|
|
654
|
+
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
469
655
|
}
|
|
470
656
|
return data;
|
|
471
657
|
});
|
|
472
658
|
};
|
|
473
659
|
|
|
660
|
+
//
|
|
661
|
+
// Errors
|
|
662
|
+
//
|
|
663
|
+
|
|
664
|
+
class WebrpcError extends Error {
|
|
665
|
+
constructor(name, code, message, status, cause) {
|
|
666
|
+
super(message);
|
|
667
|
+
this.name = void 0;
|
|
668
|
+
this.code = void 0;
|
|
669
|
+
this.message = void 0;
|
|
670
|
+
this.status = void 0;
|
|
671
|
+
this.cause = void 0;
|
|
672
|
+
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
673
|
+
this.msg = void 0;
|
|
674
|
+
this.name = name || 'WebrpcError';
|
|
675
|
+
this.code = typeof code === 'number' ? code : 0;
|
|
676
|
+
this.message = message || `endpoint error ${this.code}`;
|
|
677
|
+
this.msg = this.message;
|
|
678
|
+
this.status = typeof status === 'number' ? status : 0;
|
|
679
|
+
this.cause = cause;
|
|
680
|
+
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
681
|
+
}
|
|
682
|
+
static new(payload) {
|
|
683
|
+
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
// Webrpc errors
|
|
688
|
+
|
|
689
|
+
class WebrpcEndpointError extends WebrpcError {
|
|
690
|
+
constructor(name = 'WebrpcEndpoint', code = 0, message = 'endpoint error', status = 0, cause) {
|
|
691
|
+
super(name, code, message, status, cause);
|
|
692
|
+
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
class WebrpcRequestFailedError extends WebrpcError {
|
|
696
|
+
constructor(name = 'WebrpcRequestFailed', code = -1, message = 'request failed', status = 0, cause) {
|
|
697
|
+
super(name, code, message, status, cause);
|
|
698
|
+
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
class WebrpcBadRouteError extends WebrpcError {
|
|
702
|
+
constructor(name = 'WebrpcBadRoute', code = -2, message = 'bad route', status = 0, cause) {
|
|
703
|
+
super(name, code, message, status, cause);
|
|
704
|
+
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
class WebrpcBadMethodError extends WebrpcError {
|
|
708
|
+
constructor(name = 'WebrpcBadMethod', code = -3, message = 'bad method', status = 0, cause) {
|
|
709
|
+
super(name, code, message, status, cause);
|
|
710
|
+
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
class WebrpcBadRequestError extends WebrpcError {
|
|
714
|
+
constructor(name = 'WebrpcBadRequest', code = -4, message = 'bad request', status = 0, cause) {
|
|
715
|
+
super(name, code, message, status, cause);
|
|
716
|
+
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
class WebrpcBadResponseError extends WebrpcError {
|
|
720
|
+
constructor(name = 'WebrpcBadResponse', code = -5, message = 'bad response', status = 0, cause) {
|
|
721
|
+
super(name, code, message, status, cause);
|
|
722
|
+
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
class WebrpcServerPanicError extends WebrpcError {
|
|
726
|
+
constructor(name = 'WebrpcServerPanic', code = -6, message = 'server panic', status = 0, cause) {
|
|
727
|
+
super(name, code, message, status, cause);
|
|
728
|
+
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
class WebrpcInternalErrorError extends WebrpcError {
|
|
732
|
+
constructor(name = 'WebrpcInternalError', code = -7, message = 'internal error', status = 0, cause) {
|
|
733
|
+
super(name, code, message, status, cause);
|
|
734
|
+
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
class WebrpcClientDisconnectedError extends WebrpcError {
|
|
738
|
+
constructor(name = 'WebrpcClientDisconnected', code = -8, message = 'client disconnected', status = 0, cause) {
|
|
739
|
+
super(name, code, message, status, cause);
|
|
740
|
+
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype);
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
class WebrpcStreamLostError extends WebrpcError {
|
|
744
|
+
constructor(name = 'WebrpcStreamLost', code = -9, message = 'stream lost', status = 0, cause) {
|
|
745
|
+
super(name, code, message, status, cause);
|
|
746
|
+
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
class WebrpcStreamFinishedError extends WebrpcError {
|
|
750
|
+
constructor(name = 'WebrpcStreamFinished', code = -10, message = 'stream finished', status = 0, cause) {
|
|
751
|
+
super(name, code, message, status, cause);
|
|
752
|
+
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// Schema errors
|
|
757
|
+
|
|
758
|
+
class UnauthorizedError extends WebrpcError {
|
|
759
|
+
constructor(name = 'Unauthorized', code = 1000, message = 'Unauthorized access', status = 0, cause) {
|
|
760
|
+
super(name, code, message, status, cause);
|
|
761
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
class PermissionDeniedError extends WebrpcError {
|
|
765
|
+
constructor(name = 'PermissionDenied', code = 1001, message = 'Permission denied', status = 0, cause) {
|
|
766
|
+
super(name, code, message, status, cause);
|
|
767
|
+
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
class SessionExpiredError extends WebrpcError {
|
|
771
|
+
constructor(name = 'SessionExpired', code = 1002, message = 'Session expired', status = 0, cause) {
|
|
772
|
+
super(name, code, message, status, cause);
|
|
773
|
+
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
class AbortedError extends WebrpcError {
|
|
777
|
+
constructor(name = 'Aborted', code = 1005, message = 'Request aborted', status = 0, cause) {
|
|
778
|
+
super(name, code, message, status, cause);
|
|
779
|
+
Object.setPrototypeOf(this, AbortedError.prototype);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
class InvalidArgumentError extends WebrpcError {
|
|
783
|
+
constructor(name = 'InvalidArgument', code = 2000, message = 'Invalid argument', status = 0, cause) {
|
|
784
|
+
super(name, code, message, status, cause);
|
|
785
|
+
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
class UnavailableError extends WebrpcError {
|
|
789
|
+
constructor(name = 'Unavailable', code = 2002, message = 'Unavailable resource', status = 0, cause) {
|
|
790
|
+
super(name, code, message, status, cause);
|
|
791
|
+
Object.setPrototypeOf(this, UnavailableError.prototype);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
class QueryFailedError extends WebrpcError {
|
|
795
|
+
constructor(name = 'QueryFailed', code = 2003, message = 'Query failed', status = 0, cause) {
|
|
796
|
+
super(name, code, message, status, cause);
|
|
797
|
+
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
class NotFoundError extends WebrpcError {
|
|
801
|
+
constructor(name = 'NotFound', code = 3000, message = 'Resource not found', status = 0, cause) {
|
|
802
|
+
super(name, code, message, status, cause);
|
|
803
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
let errors = /*#__PURE__*/function (errors) {
|
|
807
|
+
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
808
|
+
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
809
|
+
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
810
|
+
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
811
|
+
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
812
|
+
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
813
|
+
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
814
|
+
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
815
|
+
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected";
|
|
816
|
+
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
817
|
+
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
818
|
+
errors["Unauthorized"] = "Unauthorized";
|
|
819
|
+
errors["PermissionDenied"] = "PermissionDenied";
|
|
820
|
+
errors["SessionExpired"] = "SessionExpired";
|
|
821
|
+
errors["Aborted"] = "Aborted";
|
|
822
|
+
errors["InvalidArgument"] = "InvalidArgument";
|
|
823
|
+
errors["Unavailable"] = "Unavailable";
|
|
824
|
+
errors["QueryFailed"] = "QueryFailed";
|
|
825
|
+
errors["NotFound"] = "NotFound";
|
|
826
|
+
return errors;
|
|
827
|
+
}({});
|
|
828
|
+
const webrpcErrorByCode = {
|
|
829
|
+
[0]: WebrpcEndpointError,
|
|
830
|
+
[-1]: WebrpcRequestFailedError,
|
|
831
|
+
[-2]: WebrpcBadRouteError,
|
|
832
|
+
[-3]: WebrpcBadMethodError,
|
|
833
|
+
[-4]: WebrpcBadRequestError,
|
|
834
|
+
[-5]: WebrpcBadResponseError,
|
|
835
|
+
[-6]: WebrpcServerPanicError,
|
|
836
|
+
[-7]: WebrpcInternalErrorError,
|
|
837
|
+
[-8]: WebrpcClientDisconnectedError,
|
|
838
|
+
[-9]: WebrpcStreamLostError,
|
|
839
|
+
[-10]: WebrpcStreamFinishedError,
|
|
840
|
+
[1000]: UnauthorizedError,
|
|
841
|
+
[1001]: PermissionDeniedError,
|
|
842
|
+
[1002]: SessionExpiredError,
|
|
843
|
+
[1005]: AbortedError,
|
|
844
|
+
[2000]: InvalidArgumentError,
|
|
845
|
+
[2002]: UnavailableError,
|
|
846
|
+
[2003]: QueryFailedError,
|
|
847
|
+
[3000]: NotFoundError
|
|
848
|
+
};
|
|
849
|
+
|
|
474
850
|
const fetch = typeof global === 'object' ? global.fetch : window.fetch;
|
|
475
851
|
class SequenceAPIClient extends API {
|
|
476
852
|
constructor(hostname, projectAccessKey, jwtAuth) {
|
|
@@ -498,4 +874,4 @@ class SequenceAPIClient extends API {
|
|
|
498
874
|
}
|
|
499
875
|
}
|
|
500
876
|
|
|
501
|
-
export { API, SequenceAPIClient, SortOrder, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion };
|
|
877
|
+
export { API, AbortedError, InvalidArgumentError, NotFoundError, PermissionDeniedError, QueryFailedError, SequenceAPIClient, SessionExpiredError, SortOrder, UnauthorizedError, UnavailableError, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion, WebrpcBadMethodError, WebrpcBadRequestError, WebrpcBadResponseError, WebrpcBadRouteError, WebrpcClientDisconnectedError, WebrpcEndpointError, WebrpcError, WebrpcInternalErrorError, WebrpcRequestFailedError, WebrpcServerPanicError, WebrpcStreamFinishedError, WebrpcStreamLostError, errors };
|