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