@0xsequence/metadata 2.3.35 → 3.0.0-beta.2
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/.turbo/turbo-build.log +5 -0
- package/CHANGELOG.md +1799 -0
- package/LICENSE +0 -17
- package/README.md +1 -2
- package/dist/{declarations/src/index.d.ts → index.d.ts} +3 -2
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/{declarations/src/metadata.gen.d.ts → metadata.gen.d.ts} +318 -249
- package/dist/metadata.gen.d.ts.map +1 -0
- package/dist/metadata.gen.js +1411 -0
- package/package.json +19 -13
- package/src/index.ts +2 -2
- package/src/metadata.gen.ts +1649 -1275
- package/tsconfig.json +10 -0
- package/dist/0xsequence-metadata.cjs.d.ts +0 -2
- package/dist/0xsequence-metadata.cjs.dev.js +0 -1385
- package/dist/0xsequence-metadata.cjs.js +0 -7
- package/dist/0xsequence-metadata.cjs.prod.js +0 -1385
- package/dist/0xsequence-metadata.esm.js +0 -1331
|
@@ -1,1385 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function _extends() {
|
|
6
|
-
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
7
|
-
for (var e = 1; e < arguments.length; e++) {
|
|
8
|
-
var t = arguments[e];
|
|
9
|
-
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
10
|
-
}
|
|
11
|
-
return n;
|
|
12
|
-
}, _extends.apply(null, arguments);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* eslint-disable */
|
|
16
|
-
// sequence-metadata v0.4.0 5cb74ff169ce80c2e42e65d6bbc98b1daaa0945f
|
|
17
|
-
// --
|
|
18
|
-
// Code generated by webrpc-gen@v0.25.3 with typescript generator. DO NOT EDIT.
|
|
19
|
-
//
|
|
20
|
-
// webrpc-gen -schema=metadata.ridl -target=typescript -client -ignore=@deprecated -out=./clients/metadata.gen.ts
|
|
21
|
-
|
|
22
|
-
const WebrpcHeader = 'Webrpc';
|
|
23
|
-
const WebrpcHeaderValue = 'webrpc@v0.25.3;gen-typescript@v0.17.0;sequence-metadata@v0.4.0';
|
|
24
|
-
|
|
25
|
-
// WebRPC description and code-gen version
|
|
26
|
-
const WebRPCVersion = 'v1';
|
|
27
|
-
|
|
28
|
-
// Schema version of your RIDL schema
|
|
29
|
-
const WebRPCSchemaVersion = 'v0.4.0';
|
|
30
|
-
|
|
31
|
-
// Schema hash generated from your RIDL schema
|
|
32
|
-
const WebRPCSchemaHash = '5cb74ff169ce80c2e42e65d6bbc98b1daaa0945f';
|
|
33
|
-
function VersionFromHeader(headers) {
|
|
34
|
-
const headerValue = headers.get(WebrpcHeader);
|
|
35
|
-
if (!headerValue) {
|
|
36
|
-
return {
|
|
37
|
-
webrpcGenVersion: '',
|
|
38
|
-
codeGenName: '',
|
|
39
|
-
codeGenVersion: '',
|
|
40
|
-
schemaName: '',
|
|
41
|
-
schemaVersion: ''
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return parseWebrpcGenVersions(headerValue);
|
|
45
|
-
}
|
|
46
|
-
function parseWebrpcGenVersions(header) {
|
|
47
|
-
const versions = header.split(';');
|
|
48
|
-
if (versions.length < 3) {
|
|
49
|
-
return {
|
|
50
|
-
webrpcGenVersion: '',
|
|
51
|
-
codeGenName: '',
|
|
52
|
-
codeGenVersion: '',
|
|
53
|
-
schemaName: '',
|
|
54
|
-
schemaVersion: ''
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
const [_, webrpcGenVersion] = versions[0].split('@');
|
|
58
|
-
const [codeGenName, codeGenVersion] = versions[1].split('@');
|
|
59
|
-
const [schemaName, schemaVersion] = versions[2].split('@');
|
|
60
|
-
return {
|
|
61
|
-
webrpcGenVersion: webrpcGenVersion != null ? webrpcGenVersion : '',
|
|
62
|
-
codeGenName: codeGenName != null ? codeGenName : '',
|
|
63
|
-
codeGenVersion: codeGenVersion != null ? codeGenVersion : '',
|
|
64
|
-
schemaName: schemaName != null ? schemaName : '',
|
|
65
|
-
schemaVersion: schemaVersion != null ? schemaVersion : ''
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
//
|
|
70
|
-
// Types
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
let ContractType = /*#__PURE__*/function (ContractType) {
|
|
74
|
-
ContractType["UNKNOWN"] = "UNKNOWN";
|
|
75
|
-
ContractType["ERC20"] = "ERC20";
|
|
76
|
-
ContractType["ERC721"] = "ERC721";
|
|
77
|
-
ContractType["ERC1155"] = "ERC1155";
|
|
78
|
-
ContractType["ERC6909"] = "ERC6909";
|
|
79
|
-
ContractType["MISC"] = "MISC";
|
|
80
|
-
return ContractType;
|
|
81
|
-
}({});
|
|
82
|
-
let Source = /*#__PURE__*/function (Source) {
|
|
83
|
-
Source["UNKNOWN"] = "UNKNOWN";
|
|
84
|
-
Source["FETCHER"] = "FETCHER";
|
|
85
|
-
Source["FETCHER_OPENSEA_API"] = "FETCHER_OPENSEA_API";
|
|
86
|
-
Source["FETCHER_ENS_API"] = "FETCHER_ENS_API";
|
|
87
|
-
Source["FETCHER_ON_CHAIN_ERC20_INTERFACE"] = "FETCHER_ON_CHAIN_ERC20_INTERFACE";
|
|
88
|
-
Source["FETCHER_ON_CHAIN_TOKEN_URI"] = "FETCHER_ON_CHAIN_TOKEN_URI";
|
|
89
|
-
Source["FETCHER_ON_CHAIN_CONTRACT_URI"] = "FETCHER_ON_CHAIN_CONTRACT_URI";
|
|
90
|
-
Source["FETCHER_TOKEN_DIRECTORY_ADMIN"] = "FETCHER_TOKEN_DIRECTORY_ADMIN";
|
|
91
|
-
Source["TOKEN_DIRECTORY"] = "TOKEN_DIRECTORY";
|
|
92
|
-
Source["TOKEN_DIRECTORY_PUBLIC_TOKEN_LIST"] = "TOKEN_DIRECTORY_PUBLIC_TOKEN_LIST";
|
|
93
|
-
Source["TOKEN_DIRECTORY_3RD_PARTY"] = "TOKEN_DIRECTORY_3RD_PARTY";
|
|
94
|
-
Source["TOKEN_DIRECTORY_SEQUENCE_GITHUB"] = "TOKEN_DIRECTORY_SEQUENCE_GITHUB";
|
|
95
|
-
Source["TOKEN_DIRECTORY_SEQUENCE_BUILDER"] = "TOKEN_DIRECTORY_SEQUENCE_BUILDER";
|
|
96
|
-
Source["SEQUENCE_BUILDER"] = "SEQUENCE_BUILDER";
|
|
97
|
-
Source["SEQUENCE_BUILDER_DEPLOYED"] = "SEQUENCE_BUILDER_DEPLOYED";
|
|
98
|
-
Source["SEQUENCE_BUILDER_COLLECTIONS"] = "SEQUENCE_BUILDER_COLLECTIONS";
|
|
99
|
-
Source["SEQUENCE_BUILDER_ADMIN"] = "SEQUENCE_BUILDER_ADMIN";
|
|
100
|
-
return Source;
|
|
101
|
-
}({});
|
|
102
|
-
let ResourceStatus = /*#__PURE__*/function (ResourceStatus) {
|
|
103
|
-
ResourceStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
|
|
104
|
-
ResourceStatus["REFRESHING"] = "REFRESHING";
|
|
105
|
-
ResourceStatus["AVAILABLE"] = "AVAILABLE";
|
|
106
|
-
return ResourceStatus;
|
|
107
|
-
}({});
|
|
108
|
-
let PropertyType = /*#__PURE__*/function (PropertyType) {
|
|
109
|
-
PropertyType["INT"] = "INT";
|
|
110
|
-
PropertyType["STRING"] = "STRING";
|
|
111
|
-
PropertyType["ARRAY"] = "ARRAY";
|
|
112
|
-
PropertyType["GENERIC"] = "GENERIC";
|
|
113
|
-
return PropertyType;
|
|
114
|
-
}({});
|
|
115
|
-
let SwapType = /*#__PURE__*/function (SwapType) {
|
|
116
|
-
SwapType["UNKNOWN"] = "UNKNOWN";
|
|
117
|
-
SwapType["BUY"] = "BUY";
|
|
118
|
-
SwapType["SELL"] = "SELL";
|
|
119
|
-
return SwapType;
|
|
120
|
-
}({});
|
|
121
|
-
let TaskStatus = /*#__PURE__*/function (TaskStatus) {
|
|
122
|
-
TaskStatus["QUEUED"] = "QUEUED";
|
|
123
|
-
TaskStatus["PAUSED"] = "PAUSED";
|
|
124
|
-
TaskStatus["FAILED"] = "FAILED";
|
|
125
|
-
TaskStatus["DONE"] = "DONE";
|
|
126
|
-
return TaskStatus;
|
|
127
|
-
}({});
|
|
128
|
-
//
|
|
129
|
-
// Client
|
|
130
|
-
//
|
|
131
|
-
class Metadata {
|
|
132
|
-
constructor(hostname, fetch) {
|
|
133
|
-
this.hostname = void 0;
|
|
134
|
-
this.fetch = void 0;
|
|
135
|
-
this.path = '/rpc/Metadata/';
|
|
136
|
-
this.ping = (headers, signal) => {
|
|
137
|
-
return this.fetch(this.url('Ping'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
138
|
-
return buildResponse(res).then(_data => {
|
|
139
|
-
return {
|
|
140
|
-
status: _data.status
|
|
141
|
-
};
|
|
142
|
-
});
|
|
143
|
-
}, error => {
|
|
144
|
-
throw WebrpcRequestFailedError.new({
|
|
145
|
-
cause: `fetch(): ${error.message || ''}`
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
this.version = (headers, signal) => {
|
|
150
|
-
return this.fetch(this.url('Version'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
151
|
-
return buildResponse(res).then(_data => {
|
|
152
|
-
return {
|
|
153
|
-
version: _data.version
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
}, error => {
|
|
157
|
-
throw WebrpcRequestFailedError.new({
|
|
158
|
-
cause: `fetch(): ${error.message || ''}`
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
};
|
|
162
|
-
this.runtimeStatus = (headers, signal) => {
|
|
163
|
-
return this.fetch(this.url('RuntimeStatus'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
164
|
-
return buildResponse(res).then(_data => {
|
|
165
|
-
return {
|
|
166
|
-
status: _data.status
|
|
167
|
-
};
|
|
168
|
-
});
|
|
169
|
-
}, error => {
|
|
170
|
-
throw WebrpcRequestFailedError.new({
|
|
171
|
-
cause: `fetch(): ${error.message || ''}`
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
this.getTask = (args, headers, signal) => {
|
|
176
|
-
return this.fetch(this.url('GetTask'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
177
|
-
return buildResponse(res).then(_data => {
|
|
178
|
-
return {
|
|
179
|
-
task: _data.task
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
}, error => {
|
|
183
|
-
throw WebrpcRequestFailedError.new({
|
|
184
|
-
cause: `fetch(): ${error.message || ''}`
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
};
|
|
188
|
-
this.getTaskStatus = (args, headers, signal) => {
|
|
189
|
-
return this.fetch(this.url('GetTaskStatus'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
190
|
-
return buildResponse(res).then(_data => {
|
|
191
|
-
return {
|
|
192
|
-
status: _data.status
|
|
193
|
-
};
|
|
194
|
-
});
|
|
195
|
-
}, error => {
|
|
196
|
-
throw WebrpcRequestFailedError.new({
|
|
197
|
-
cause: `fetch(): ${error.message || ''}`
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
this.getContractInfo = (args, headers, signal) => {
|
|
202
|
-
return this.fetch(this.url('GetContractInfo'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
203
|
-
return buildResponse(res).then(_data => {
|
|
204
|
-
return {
|
|
205
|
-
contractInfo: _data.contractInfo,
|
|
206
|
-
taskID: _data.taskID
|
|
207
|
-
};
|
|
208
|
-
});
|
|
209
|
-
}, error => {
|
|
210
|
-
throw WebrpcRequestFailedError.new({
|
|
211
|
-
cause: `fetch(): ${error.message || ''}`
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
};
|
|
215
|
-
this.getContractInfoBatch = (args, headers, signal) => {
|
|
216
|
-
return this.fetch(this.url('GetContractInfoBatch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
217
|
-
return buildResponse(res).then(_data => {
|
|
218
|
-
return {
|
|
219
|
-
contractInfoMap: _data.contractInfoMap,
|
|
220
|
-
taskID: _data.taskID
|
|
221
|
-
};
|
|
222
|
-
});
|
|
223
|
-
}, error => {
|
|
224
|
-
throw WebrpcRequestFailedError.new({
|
|
225
|
-
cause: `fetch(): ${error.message || ''}`
|
|
226
|
-
});
|
|
227
|
-
});
|
|
228
|
-
};
|
|
229
|
-
this.findContractInfo = (args, headers, signal) => {
|
|
230
|
-
return this.fetch(this.url('FindContractInfo'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
231
|
-
return buildResponse(res).then(_data => {
|
|
232
|
-
return {
|
|
233
|
-
contractInfoList: _data.contractInfoList
|
|
234
|
-
};
|
|
235
|
-
});
|
|
236
|
-
}, error => {
|
|
237
|
-
throw WebrpcRequestFailedError.new({
|
|
238
|
-
cause: `fetch(): ${error.message || ''}`
|
|
239
|
-
});
|
|
240
|
-
});
|
|
241
|
-
};
|
|
242
|
-
this.findContractInfoBatch = (args, headers, signal) => {
|
|
243
|
-
return this.fetch(this.url('FindContractInfoBatch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
244
|
-
return buildResponse(res).then(_data => {
|
|
245
|
-
return {
|
|
246
|
-
contractInfoByChain: _data.contractInfoByChain
|
|
247
|
-
};
|
|
248
|
-
});
|
|
249
|
-
}, error => {
|
|
250
|
-
throw WebrpcRequestFailedError.new({
|
|
251
|
-
cause: `fetch(): ${error.message || ''}`
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
this.refreshContractInfo = (args, headers, signal) => {
|
|
256
|
-
return this.fetch(this.url('RefreshContractInfo'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
257
|
-
return buildResponse(res).then(_data => {
|
|
258
|
-
return {
|
|
259
|
-
taskID: _data.taskID
|
|
260
|
-
};
|
|
261
|
-
});
|
|
262
|
-
}, error => {
|
|
263
|
-
throw WebrpcRequestFailedError.new({
|
|
264
|
-
cause: `fetch(): ${error.message || ''}`
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
this.refreshContractInfoBatch = (args, headers, signal) => {
|
|
269
|
-
return this.fetch(this.url('RefreshContractInfoBatch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
270
|
-
return buildResponse(res).then(_data => {
|
|
271
|
-
return {
|
|
272
|
-
taskID: _data.taskID
|
|
273
|
-
};
|
|
274
|
-
});
|
|
275
|
-
}, error => {
|
|
276
|
-
throw WebrpcRequestFailedError.new({
|
|
277
|
-
cause: `fetch(): ${error.message || ''}`
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
this.searchContractsByQuery = (args, headers, signal) => {
|
|
282
|
-
return this.fetch(this.url('SearchContractsByQuery'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
283
|
-
return buildResponse(res).then(_data => {
|
|
284
|
-
return {
|
|
285
|
-
contractInfo: _data.contractInfo,
|
|
286
|
-
nextPage: _data.nextPage
|
|
287
|
-
};
|
|
288
|
-
});
|
|
289
|
-
}, error => {
|
|
290
|
-
throw WebrpcRequestFailedError.new({
|
|
291
|
-
cause: `fetch(): ${error.message || ''}`
|
|
292
|
-
});
|
|
293
|
-
});
|
|
294
|
-
};
|
|
295
|
-
this.getTokenMetadata = (args, headers, signal) => {
|
|
296
|
-
return this.fetch(this.url('GetTokenMetadata'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
297
|
-
return buildResponse(res).then(_data => {
|
|
298
|
-
return {
|
|
299
|
-
tokenMetadata: _data.tokenMetadata,
|
|
300
|
-
taskID: _data.taskID
|
|
301
|
-
};
|
|
302
|
-
});
|
|
303
|
-
}, error => {
|
|
304
|
-
throw WebrpcRequestFailedError.new({
|
|
305
|
-
cause: `fetch(): ${error.message || ''}`
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
};
|
|
309
|
-
this.getTokenMetadataBatch = (args, headers, signal) => {
|
|
310
|
-
return this.fetch(this.url('GetTokenMetadataBatch'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
311
|
-
return buildResponse(res).then(_data => {
|
|
312
|
-
return {
|
|
313
|
-
contractTokenMetadata: _data.contractTokenMetadata,
|
|
314
|
-
taskID: _data.taskID
|
|
315
|
-
};
|
|
316
|
-
});
|
|
317
|
-
}, error => {
|
|
318
|
-
throw WebrpcRequestFailedError.new({
|
|
319
|
-
cause: `fetch(): ${error.message || ''}`
|
|
320
|
-
});
|
|
321
|
-
});
|
|
322
|
-
};
|
|
323
|
-
this.refreshTokenMetadata = (args, headers, signal) => {
|
|
324
|
-
return this.fetch(this.url('RefreshTokenMetadata'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
325
|
-
return buildResponse(res).then(_data => {
|
|
326
|
-
return {
|
|
327
|
-
taskID: _data.taskID
|
|
328
|
-
};
|
|
329
|
-
});
|
|
330
|
-
}, error => {
|
|
331
|
-
throw WebrpcRequestFailedError.new({
|
|
332
|
-
cause: `fetch(): ${error.message || ''}`
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
};
|
|
336
|
-
this.searchTokenMetadataByQuery = (args, headers, signal) => {
|
|
337
|
-
return this.fetch(this.url('SearchTokenMetadataByQuery'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
338
|
-
return buildResponse(res).then(_data => {
|
|
339
|
-
return {
|
|
340
|
-
tokenMetadata: _data.tokenMetadata,
|
|
341
|
-
nextPage: _data.nextPage
|
|
342
|
-
};
|
|
343
|
-
});
|
|
344
|
-
}, error => {
|
|
345
|
-
throw WebrpcRequestFailedError.new({
|
|
346
|
-
cause: `fetch(): ${error.message || ''}`
|
|
347
|
-
});
|
|
348
|
-
});
|
|
349
|
-
};
|
|
350
|
-
this.searchTokenMetadata = (args, headers, signal) => {
|
|
351
|
-
return this.fetch(this.url('SearchTokenMetadata'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
352
|
-
return buildResponse(res).then(_data => {
|
|
353
|
-
return {
|
|
354
|
-
page: _data.page,
|
|
355
|
-
tokenMetadata: _data.tokenMetadata
|
|
356
|
-
};
|
|
357
|
-
});
|
|
358
|
-
}, error => {
|
|
359
|
-
throw WebrpcRequestFailedError.new({
|
|
360
|
-
cause: `fetch(): ${error.message || ''}`
|
|
361
|
-
});
|
|
362
|
-
});
|
|
363
|
-
};
|
|
364
|
-
this.searchTokenMetadataTokenIDs = (args, headers, signal) => {
|
|
365
|
-
return this.fetch(this.url('SearchTokenMetadataTokenIDs'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
366
|
-
return buildResponse(res).then(_data => {
|
|
367
|
-
return {
|
|
368
|
-
page: _data.page,
|
|
369
|
-
tokenIDs: _data.tokenIDs
|
|
370
|
-
};
|
|
371
|
-
});
|
|
372
|
-
}, error => {
|
|
373
|
-
throw WebrpcRequestFailedError.new({
|
|
374
|
-
cause: `fetch(): ${error.message || ''}`
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
};
|
|
378
|
-
this.getTokenMetadataPropertyFilters = (args, headers, signal) => {
|
|
379
|
-
return this.fetch(this.url('GetTokenMetadataPropertyFilters'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
380
|
-
return buildResponse(res).then(_data => {
|
|
381
|
-
return {
|
|
382
|
-
filters: _data.filters
|
|
383
|
-
};
|
|
384
|
-
});
|
|
385
|
-
}, error => {
|
|
386
|
-
throw WebrpcRequestFailedError.new({
|
|
387
|
-
cause: `fetch(): ${error.message || ''}`
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
|
-
};
|
|
391
|
-
this.getTokenDirectoryNetworks = (args, headers, signal) => {
|
|
392
|
-
return this.fetch(this.url('GetTokenDirectoryNetworks'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
393
|
-
return buildResponse(res).then(_data => {
|
|
394
|
-
return {
|
|
395
|
-
chainIDs: _data.chainIDs,
|
|
396
|
-
networks: _data.networks
|
|
397
|
-
};
|
|
398
|
-
});
|
|
399
|
-
}, error => {
|
|
400
|
-
throw WebrpcRequestFailedError.new({
|
|
401
|
-
cause: `fetch(): ${error.message || ''}`
|
|
402
|
-
});
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
|
-
this.getTokenDirectory = (args, headers, signal) => {
|
|
406
|
-
return this.fetch(this.url('GetTokenDirectory'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
407
|
-
return buildResponse(res).then(_data => {
|
|
408
|
-
return {
|
|
409
|
-
contracts: _data.contracts,
|
|
410
|
-
page: _data.page
|
|
411
|
-
};
|
|
412
|
-
});
|
|
413
|
-
}, error => {
|
|
414
|
-
throw WebrpcRequestFailedError.new({
|
|
415
|
-
cause: `fetch(): ${error.message || ''}`
|
|
416
|
-
});
|
|
417
|
-
});
|
|
418
|
-
};
|
|
419
|
-
this.searchTokenDirectory = (args, headers, signal) => {
|
|
420
|
-
return this.fetch(this.url('SearchTokenDirectory'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
421
|
-
return buildResponse(res).then(_data => {
|
|
422
|
-
return {
|
|
423
|
-
contracts: _data.contracts,
|
|
424
|
-
page: _data.page
|
|
425
|
-
};
|
|
426
|
-
});
|
|
427
|
-
}, error => {
|
|
428
|
-
throw WebrpcRequestFailedError.new({
|
|
429
|
-
cause: `fetch(): ${error.message || ''}`
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
};
|
|
433
|
-
this.getNiftyswapTokenQuantity = (args, headers, signal) => {
|
|
434
|
-
return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
435
|
-
return buildResponse(res).then(_data => {
|
|
436
|
-
return {
|
|
437
|
-
quantity: _data.quantity
|
|
438
|
-
};
|
|
439
|
-
});
|
|
440
|
-
}, error => {
|
|
441
|
-
throw WebrpcRequestFailedError.new({
|
|
442
|
-
cause: `fetch(): ${error.message || ''}`
|
|
443
|
-
});
|
|
444
|
-
});
|
|
445
|
-
};
|
|
446
|
-
this.getNiftyswapUnitPrices = (args, headers, signal) => {
|
|
447
|
-
return this.fetch(this.url('GetNiftyswapUnitPrices'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
448
|
-
return buildResponse(res).then(_data => {
|
|
449
|
-
return {
|
|
450
|
-
prices: _data.prices
|
|
451
|
-
};
|
|
452
|
-
});
|
|
453
|
-
}, error => {
|
|
454
|
-
throw WebrpcRequestFailedError.new({
|
|
455
|
-
cause: `fetch(): ${error.message || ''}`
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
};
|
|
459
|
-
this.getNiftyswapUnitPricesWithQuantities = (args, headers, signal) => {
|
|
460
|
-
return this.fetch(this.url('GetNiftyswapUnitPricesWithQuantities'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
461
|
-
return buildResponse(res).then(_data => {
|
|
462
|
-
return {
|
|
463
|
-
prices: _data.prices
|
|
464
|
-
};
|
|
465
|
-
});
|
|
466
|
-
}, error => {
|
|
467
|
-
throw WebrpcRequestFailedError.new({
|
|
468
|
-
cause: `fetch(): ${error.message || ''}`
|
|
469
|
-
});
|
|
470
|
-
});
|
|
471
|
-
};
|
|
472
|
-
this.hostname = hostname.replace(/\/*$/, '');
|
|
473
|
-
this.fetch = (input, init) => fetch(input, init);
|
|
474
|
-
}
|
|
475
|
-
url(name) {
|
|
476
|
-
return this.hostname + this.path + name;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
class Collections {
|
|
480
|
-
constructor(hostname, fetch) {
|
|
481
|
-
this.hostname = void 0;
|
|
482
|
-
this.fetch = void 0;
|
|
483
|
-
this.path = '/rpc/Collections/';
|
|
484
|
-
this.createCollection = (args, headers, signal) => {
|
|
485
|
-
return this.fetch(this.url('CreateCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
486
|
-
return buildResponse(res).then(_data => {
|
|
487
|
-
return {
|
|
488
|
-
collection: _data.collection
|
|
489
|
-
};
|
|
490
|
-
});
|
|
491
|
-
}, error => {
|
|
492
|
-
throw WebrpcRequestFailedError.new({
|
|
493
|
-
cause: `fetch(): ${error.message || ''}`
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
};
|
|
497
|
-
this.getCollection = (args, headers, signal) => {
|
|
498
|
-
return this.fetch(this.url('GetCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
499
|
-
return buildResponse(res).then(_data => {
|
|
500
|
-
return {
|
|
501
|
-
collection: _data.collection
|
|
502
|
-
};
|
|
503
|
-
});
|
|
504
|
-
}, error => {
|
|
505
|
-
throw WebrpcRequestFailedError.new({
|
|
506
|
-
cause: `fetch(): ${error.message || ''}`
|
|
507
|
-
});
|
|
508
|
-
});
|
|
509
|
-
};
|
|
510
|
-
this.listCollections = (args, headers, signal) => {
|
|
511
|
-
return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
512
|
-
return buildResponse(res).then(_data => {
|
|
513
|
-
return {
|
|
514
|
-
page: _data.page,
|
|
515
|
-
collections: _data.collections
|
|
516
|
-
};
|
|
517
|
-
});
|
|
518
|
-
}, error => {
|
|
519
|
-
throw WebrpcRequestFailedError.new({
|
|
520
|
-
cause: `fetch(): ${error.message || ''}`
|
|
521
|
-
});
|
|
522
|
-
});
|
|
523
|
-
};
|
|
524
|
-
this.updateCollection = (args, headers, signal) => {
|
|
525
|
-
return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
526
|
-
return buildResponse(res).then(_data => {
|
|
527
|
-
return {
|
|
528
|
-
collection: _data.collection
|
|
529
|
-
};
|
|
530
|
-
});
|
|
531
|
-
}, error => {
|
|
532
|
-
throw WebrpcRequestFailedError.new({
|
|
533
|
-
cause: `fetch(): ${error.message || ''}`
|
|
534
|
-
});
|
|
535
|
-
});
|
|
536
|
-
};
|
|
537
|
-
this.deleteCollection = (args, headers, signal) => {
|
|
538
|
-
return this.fetch(this.url('DeleteCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
539
|
-
return buildResponse(res).then(_data => {
|
|
540
|
-
return {
|
|
541
|
-
status: _data.status
|
|
542
|
-
};
|
|
543
|
-
});
|
|
544
|
-
}, error => {
|
|
545
|
-
throw WebrpcRequestFailedError.new({
|
|
546
|
-
cause: `fetch(): ${error.message || ''}`
|
|
547
|
-
});
|
|
548
|
-
});
|
|
549
|
-
};
|
|
550
|
-
this.publishCollection = (args, headers, signal) => {
|
|
551
|
-
return this.fetch(this.url('PublishCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
552
|
-
return buildResponse(res).then(_data => {
|
|
553
|
-
return {
|
|
554
|
-
collection: _data.collection
|
|
555
|
-
};
|
|
556
|
-
});
|
|
557
|
-
}, error => {
|
|
558
|
-
throw WebrpcRequestFailedError.new({
|
|
559
|
-
cause: `fetch(): ${error.message || ''}`
|
|
560
|
-
});
|
|
561
|
-
});
|
|
562
|
-
};
|
|
563
|
-
this.unpublishCollection = (args, headers, signal) => {
|
|
564
|
-
return this.fetch(this.url('UnpublishCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
565
|
-
return buildResponse(res).then(_data => {
|
|
566
|
-
return {
|
|
567
|
-
collection: _data.collection
|
|
568
|
-
};
|
|
569
|
-
});
|
|
570
|
-
}, error => {
|
|
571
|
-
throw WebrpcRequestFailedError.new({
|
|
572
|
-
cause: `fetch(): ${error.message || ''}`
|
|
573
|
-
});
|
|
574
|
-
});
|
|
575
|
-
};
|
|
576
|
-
this.createContractCollection = (args, headers, signal) => {
|
|
577
|
-
return this.fetch(this.url('CreateContractCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
578
|
-
return buildResponse(res).then(_data => {
|
|
579
|
-
return {
|
|
580
|
-
contractCollection: _data.contractCollection
|
|
581
|
-
};
|
|
582
|
-
});
|
|
583
|
-
}, error => {
|
|
584
|
-
throw WebrpcRequestFailedError.new({
|
|
585
|
-
cause: `fetch(): ${error.message || ''}`
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
};
|
|
589
|
-
this.getContractCollection = (args, headers, signal) => {
|
|
590
|
-
return this.fetch(this.url('GetContractCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
591
|
-
return buildResponse(res).then(_data => {
|
|
592
|
-
return {
|
|
593
|
-
contractCollection: _data.contractCollection
|
|
594
|
-
};
|
|
595
|
-
});
|
|
596
|
-
}, error => {
|
|
597
|
-
throw WebrpcRequestFailedError.new({
|
|
598
|
-
cause: `fetch(): ${error.message || ''}`
|
|
599
|
-
});
|
|
600
|
-
});
|
|
601
|
-
};
|
|
602
|
-
this.listContractCollections = (args, headers, signal) => {
|
|
603
|
-
return this.fetch(this.url('ListContractCollections'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
604
|
-
return buildResponse(res).then(_data => {
|
|
605
|
-
return {
|
|
606
|
-
contractCollections: _data.contractCollections,
|
|
607
|
-
collections: _data.collections,
|
|
608
|
-
page: _data.page
|
|
609
|
-
};
|
|
610
|
-
});
|
|
611
|
-
}, error => {
|
|
612
|
-
throw WebrpcRequestFailedError.new({
|
|
613
|
-
cause: `fetch(): ${error.message || ''}`
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
this.updateContractCollection = (args, headers, signal) => {
|
|
618
|
-
return this.fetch(this.url('UpdateContractCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
619
|
-
return buildResponse(res).then(_data => {
|
|
620
|
-
return {
|
|
621
|
-
ok: _data.ok
|
|
622
|
-
};
|
|
623
|
-
});
|
|
624
|
-
}, error => {
|
|
625
|
-
throw WebrpcRequestFailedError.new({
|
|
626
|
-
cause: `fetch(): ${error.message || ''}`
|
|
627
|
-
});
|
|
628
|
-
});
|
|
629
|
-
};
|
|
630
|
-
this.deleteContractCollection = (args, headers, signal) => {
|
|
631
|
-
return this.fetch(this.url('DeleteContractCollection'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
632
|
-
return buildResponse(res).then(_data => {
|
|
633
|
-
return {
|
|
634
|
-
ok: _data.ok
|
|
635
|
-
};
|
|
636
|
-
});
|
|
637
|
-
}, error => {
|
|
638
|
-
throw WebrpcRequestFailedError.new({
|
|
639
|
-
cause: `fetch(): ${error.message || ''}`
|
|
640
|
-
});
|
|
641
|
-
});
|
|
642
|
-
};
|
|
643
|
-
this.createToken = (args, headers, signal) => {
|
|
644
|
-
return this.fetch(this.url('CreateToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
645
|
-
return buildResponse(res).then(_data => {
|
|
646
|
-
return {
|
|
647
|
-
token: _data.token,
|
|
648
|
-
assets: _data.assets
|
|
649
|
-
};
|
|
650
|
-
});
|
|
651
|
-
}, error => {
|
|
652
|
-
throw WebrpcRequestFailedError.new({
|
|
653
|
-
cause: `fetch(): ${error.message || ''}`
|
|
654
|
-
});
|
|
655
|
-
});
|
|
656
|
-
};
|
|
657
|
-
this.getToken = (args, headers, signal) => {
|
|
658
|
-
return this.fetch(this.url('GetToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
659
|
-
return buildResponse(res).then(_data => {
|
|
660
|
-
return {
|
|
661
|
-
token: _data.token,
|
|
662
|
-
assets: _data.assets
|
|
663
|
-
};
|
|
664
|
-
});
|
|
665
|
-
}, error => {
|
|
666
|
-
throw WebrpcRequestFailedError.new({
|
|
667
|
-
cause: `fetch(): ${error.message || ''}`
|
|
668
|
-
});
|
|
669
|
-
});
|
|
670
|
-
};
|
|
671
|
-
this.listTokens = (args, headers, signal) => {
|
|
672
|
-
return this.fetch(this.url('ListTokens'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
673
|
-
return buildResponse(res).then(_data => {
|
|
674
|
-
return {
|
|
675
|
-
page: _data.page,
|
|
676
|
-
tokens: _data.tokens
|
|
677
|
-
};
|
|
678
|
-
});
|
|
679
|
-
}, error => {
|
|
680
|
-
throw WebrpcRequestFailedError.new({
|
|
681
|
-
cause: `fetch(): ${error.message || ''}`
|
|
682
|
-
});
|
|
683
|
-
});
|
|
684
|
-
};
|
|
685
|
-
this.updateToken = (args, headers, signal) => {
|
|
686
|
-
return this.fetch(this.url('UpdateToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
687
|
-
return buildResponse(res).then(_data => {
|
|
688
|
-
return {
|
|
689
|
-
token: _data.token
|
|
690
|
-
};
|
|
691
|
-
});
|
|
692
|
-
}, error => {
|
|
693
|
-
throw WebrpcRequestFailedError.new({
|
|
694
|
-
cause: `fetch(): ${error.message || ''}`
|
|
695
|
-
});
|
|
696
|
-
});
|
|
697
|
-
};
|
|
698
|
-
this.deleteToken = (args, headers, signal) => {
|
|
699
|
-
return this.fetch(this.url('DeleteToken'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
700
|
-
return buildResponse(res).then(_data => {
|
|
701
|
-
return {
|
|
702
|
-
status: _data.status
|
|
703
|
-
};
|
|
704
|
-
});
|
|
705
|
-
}, error => {
|
|
706
|
-
throw WebrpcRequestFailedError.new({
|
|
707
|
-
cause: `fetch(): ${error.message || ''}`
|
|
708
|
-
});
|
|
709
|
-
});
|
|
710
|
-
};
|
|
711
|
-
this.createAsset = (args, headers, signal) => {
|
|
712
|
-
return this.fetch(this.url('CreateAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
713
|
-
return buildResponse(res).then(_data => {
|
|
714
|
-
return {
|
|
715
|
-
asset: _data.asset
|
|
716
|
-
};
|
|
717
|
-
});
|
|
718
|
-
}, error => {
|
|
719
|
-
throw WebrpcRequestFailedError.new({
|
|
720
|
-
cause: `fetch(): ${error.message || ''}`
|
|
721
|
-
});
|
|
722
|
-
});
|
|
723
|
-
};
|
|
724
|
-
this.getAsset = (args, headers, signal) => {
|
|
725
|
-
return this.fetch(this.url('GetAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
726
|
-
return buildResponse(res).then(_data => {
|
|
727
|
-
return {
|
|
728
|
-
asset: _data.asset
|
|
729
|
-
};
|
|
730
|
-
});
|
|
731
|
-
}, error => {
|
|
732
|
-
throw WebrpcRequestFailedError.new({
|
|
733
|
-
cause: `fetch(): ${error.message || ''}`
|
|
734
|
-
});
|
|
735
|
-
});
|
|
736
|
-
};
|
|
737
|
-
this.updateAsset = (args, headers, signal) => {
|
|
738
|
-
return this.fetch(this.url('UpdateAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
739
|
-
return buildResponse(res).then(_data => {
|
|
740
|
-
return {
|
|
741
|
-
asset: _data.asset
|
|
742
|
-
};
|
|
743
|
-
});
|
|
744
|
-
}, error => {
|
|
745
|
-
throw WebrpcRequestFailedError.new({
|
|
746
|
-
cause: `fetch(): ${error.message || ''}`
|
|
747
|
-
});
|
|
748
|
-
});
|
|
749
|
-
};
|
|
750
|
-
this.deleteAsset = (args, headers, signal) => {
|
|
751
|
-
return this.fetch(this.url('DeleteAsset'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
752
|
-
return buildResponse(res).then(_data => {
|
|
753
|
-
return {
|
|
754
|
-
status: _data.status
|
|
755
|
-
};
|
|
756
|
-
});
|
|
757
|
-
}, error => {
|
|
758
|
-
throw WebrpcRequestFailedError.new({
|
|
759
|
-
cause: `fetch(): ${error.message || ''}`
|
|
760
|
-
});
|
|
761
|
-
});
|
|
762
|
-
};
|
|
763
|
-
this.hostname = hostname.replace(/\/*$/, '');
|
|
764
|
-
this.fetch = (input, init) => fetch(input, init);
|
|
765
|
-
}
|
|
766
|
-
url(name) {
|
|
767
|
-
return this.hostname + this.path + name;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
class Admin {
|
|
771
|
-
constructor(hostname, fetch) {
|
|
772
|
-
this.hostname = void 0;
|
|
773
|
-
this.fetch = void 0;
|
|
774
|
-
this.path = '/rpc/Admin/';
|
|
775
|
-
this.refreshContractInfoUpdatedBefore = (args, headers, signal) => {
|
|
776
|
-
return this.fetch(this.url('RefreshContractInfoUpdatedBefore'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
777
|
-
return buildResponse(res).then(_data => {
|
|
778
|
-
return {
|
|
779
|
-
taskIDs: _data.taskIDs
|
|
780
|
-
};
|
|
781
|
-
});
|
|
782
|
-
}, error => {
|
|
783
|
-
throw WebrpcRequestFailedError.new({
|
|
784
|
-
cause: `fetch(): ${error.message || ''}`
|
|
785
|
-
});
|
|
786
|
-
});
|
|
787
|
-
};
|
|
788
|
-
this.refreshTokenMetadataUpdatedBefore = (args, headers, signal) => {
|
|
789
|
-
return this.fetch(this.url('RefreshTokenMetadataUpdatedBefore'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
790
|
-
return buildResponse(res).then(_data => {
|
|
791
|
-
return {
|
|
792
|
-
taskIDs: _data.taskIDs
|
|
793
|
-
};
|
|
794
|
-
});
|
|
795
|
-
}, error => {
|
|
796
|
-
throw WebrpcRequestFailedError.new({
|
|
797
|
-
cause: `fetch(): ${error.message || ''}`
|
|
798
|
-
});
|
|
799
|
-
});
|
|
800
|
-
};
|
|
801
|
-
this.getContractInfoOverride = (args, headers, signal) => {
|
|
802
|
-
return this.fetch(this.url('GetContractInfoOverride'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
803
|
-
return buildResponse(res).then(_data => {
|
|
804
|
-
return {
|
|
805
|
-
contractInfoOverride: _data.contractInfoOverride
|
|
806
|
-
};
|
|
807
|
-
});
|
|
808
|
-
}, error => {
|
|
809
|
-
throw WebrpcRequestFailedError.new({
|
|
810
|
-
cause: `fetch(): ${error.message || ''}`
|
|
811
|
-
});
|
|
812
|
-
});
|
|
813
|
-
};
|
|
814
|
-
this.getContractInfoOverrides = (args, headers, signal) => {
|
|
815
|
-
return this.fetch(this.url('GetContractInfoOverrides'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
816
|
-
return buildResponse(res).then(_data => {
|
|
817
|
-
return {
|
|
818
|
-
contractInfoOverrides: _data.contractInfoOverrides,
|
|
819
|
-
page: _data.page
|
|
820
|
-
};
|
|
821
|
-
});
|
|
822
|
-
}, error => {
|
|
823
|
-
throw WebrpcRequestFailedError.new({
|
|
824
|
-
cause: `fetch(): ${error.message || ''}`
|
|
825
|
-
});
|
|
826
|
-
});
|
|
827
|
-
};
|
|
828
|
-
this.addContractInfoOverride = (args, headers, signal) => {
|
|
829
|
-
return this.fetch(this.url('AddContractInfoOverride'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
830
|
-
return buildResponse(res).then(_data => {
|
|
831
|
-
return {
|
|
832
|
-
ok: _data.ok
|
|
833
|
-
};
|
|
834
|
-
});
|
|
835
|
-
}, error => {
|
|
836
|
-
throw WebrpcRequestFailedError.new({
|
|
837
|
-
cause: `fetch(): ${error.message || ''}`
|
|
838
|
-
});
|
|
839
|
-
});
|
|
840
|
-
};
|
|
841
|
-
this.updateContractInfoOverride = (args, headers, signal) => {
|
|
842
|
-
return this.fetch(this.url('UpdateContractInfoOverride'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
843
|
-
return buildResponse(res).then(_data => {
|
|
844
|
-
return {
|
|
845
|
-
ok: _data.ok
|
|
846
|
-
};
|
|
847
|
-
});
|
|
848
|
-
}, error => {
|
|
849
|
-
throw WebrpcRequestFailedError.new({
|
|
850
|
-
cause: `fetch(): ${error.message || ''}`
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
};
|
|
854
|
-
this.removeContractInfoOverride = (args, headers, signal) => {
|
|
855
|
-
return this.fetch(this.url('RemoveContractInfoOverride'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
856
|
-
return buildResponse(res).then(_data => {
|
|
857
|
-
return {
|
|
858
|
-
ok: _data.ok
|
|
859
|
-
};
|
|
860
|
-
});
|
|
861
|
-
}, error => {
|
|
862
|
-
throw WebrpcRequestFailedError.new({
|
|
863
|
-
cause: `fetch(): ${error.message || ''}`
|
|
864
|
-
});
|
|
865
|
-
});
|
|
866
|
-
};
|
|
867
|
-
this.isInTokenDirectory = (args, headers, signal) => {
|
|
868
|
-
return this.fetch(this.url('IsInTokenDirectory'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
869
|
-
return buildResponse(res).then(_data => {
|
|
870
|
-
return {
|
|
871
|
-
ok: _data.ok,
|
|
872
|
-
featureIndex: _data.featureIndex
|
|
873
|
-
};
|
|
874
|
-
});
|
|
875
|
-
}, error => {
|
|
876
|
-
throw WebrpcRequestFailedError.new({
|
|
877
|
-
cause: `fetch(): ${error.message || ''}`
|
|
878
|
-
});
|
|
879
|
-
});
|
|
880
|
-
};
|
|
881
|
-
this.setTokenDirectoryFeatureIndex = (args, headers, signal) => {
|
|
882
|
-
return this.fetch(this.url('SetTokenDirectoryFeatureIndex'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
883
|
-
return buildResponse(res).then(_data => {
|
|
884
|
-
return {
|
|
885
|
-
ok: _data.ok
|
|
886
|
-
};
|
|
887
|
-
});
|
|
888
|
-
}, error => {
|
|
889
|
-
throw WebrpcRequestFailedError.new({
|
|
890
|
-
cause: `fetch(): ${error.message || ''}`
|
|
891
|
-
});
|
|
892
|
-
});
|
|
893
|
-
};
|
|
894
|
-
this.addContractToTokenDirectory = (args, headers, signal) => {
|
|
895
|
-
return this.fetch(this.url('AddContractToTokenDirectory'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
896
|
-
return buildResponse(res).then(_data => {
|
|
897
|
-
return {
|
|
898
|
-
ok: _data.ok
|
|
899
|
-
};
|
|
900
|
-
});
|
|
901
|
-
}, error => {
|
|
902
|
-
throw WebrpcRequestFailedError.new({
|
|
903
|
-
cause: `fetch(): ${error.message || ''}`
|
|
904
|
-
});
|
|
905
|
-
});
|
|
906
|
-
};
|
|
907
|
-
this.removeContractFromTokenDirectory = (args, headers, signal) => {
|
|
908
|
-
return this.fetch(this.url('RemoveContractFromTokenDirectory'), createHTTPRequest(args, headers, signal)).then(res => {
|
|
909
|
-
return buildResponse(res).then(_data => {
|
|
910
|
-
return {
|
|
911
|
-
ok: _data.ok
|
|
912
|
-
};
|
|
913
|
-
});
|
|
914
|
-
}, error => {
|
|
915
|
-
throw WebrpcRequestFailedError.new({
|
|
916
|
-
cause: `fetch(): ${error.message || ''}`
|
|
917
|
-
});
|
|
918
|
-
});
|
|
919
|
-
};
|
|
920
|
-
this.refreshTokenDirectory = (headers, signal) => {
|
|
921
|
-
return this.fetch(this.url('RefreshTokenDirectory'), createHTTPRequest({}, headers, signal)).then(res => {
|
|
922
|
-
return buildResponse(res).then(_data => {
|
|
923
|
-
return {
|
|
924
|
-
taskID: _data.taskID
|
|
925
|
-
};
|
|
926
|
-
});
|
|
927
|
-
}, error => {
|
|
928
|
-
throw WebrpcRequestFailedError.new({
|
|
929
|
-
cause: `fetch(): ${error.message || ''}`
|
|
930
|
-
});
|
|
931
|
-
});
|
|
932
|
-
};
|
|
933
|
-
this.hostname = hostname.replace(/\/*$/, '');
|
|
934
|
-
this.fetch = (input, init) => fetch(input, init);
|
|
935
|
-
}
|
|
936
|
-
url(name) {
|
|
937
|
-
return this.hostname + this.path + name;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
|
|
941
|
-
const reqHeaders = _extends({}, headers, {
|
|
942
|
-
'Content-Type': 'application/json'
|
|
943
|
-
});
|
|
944
|
-
reqHeaders[WebrpcHeader] = WebrpcHeaderValue;
|
|
945
|
-
return {
|
|
946
|
-
method: 'POST',
|
|
947
|
-
headers: reqHeaders,
|
|
948
|
-
body: JSON.stringify(body || {}),
|
|
949
|
-
signal
|
|
950
|
-
};
|
|
951
|
-
};
|
|
952
|
-
const buildResponse = res => {
|
|
953
|
-
return res.text().then(text => {
|
|
954
|
-
let data;
|
|
955
|
-
try {
|
|
956
|
-
data = JSON.parse(text);
|
|
957
|
-
} catch (error) {
|
|
958
|
-
let message = '';
|
|
959
|
-
if (error instanceof Error) {
|
|
960
|
-
message = error.message;
|
|
961
|
-
}
|
|
962
|
-
throw WebrpcBadResponseError.new({
|
|
963
|
-
status: res.status,
|
|
964
|
-
cause: `JSON.parse(): ${message}: response text: ${text}`
|
|
965
|
-
});
|
|
966
|
-
}
|
|
967
|
-
if (!res.ok) {
|
|
968
|
-
const code = typeof data.code === 'number' ? data.code : 0;
|
|
969
|
-
throw (webrpcErrorByCode[code] || WebrpcError).new(data);
|
|
970
|
-
}
|
|
971
|
-
return data;
|
|
972
|
-
});
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
//
|
|
976
|
-
// Errors
|
|
977
|
-
//
|
|
978
|
-
|
|
979
|
-
class WebrpcError extends Error {
|
|
980
|
-
constructor(name, code, message, status, cause) {
|
|
981
|
-
super(message);
|
|
982
|
-
this.name = void 0;
|
|
983
|
-
this.code = void 0;
|
|
984
|
-
this.message = void 0;
|
|
985
|
-
this.status = void 0;
|
|
986
|
-
this.cause = void 0;
|
|
987
|
-
/** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
|
|
988
|
-
this.msg = void 0;
|
|
989
|
-
this.name = name || 'WebrpcError';
|
|
990
|
-
this.code = typeof code === 'number' ? code : 0;
|
|
991
|
-
this.message = message || `endpoint error ${this.code}`;
|
|
992
|
-
this.msg = this.message;
|
|
993
|
-
this.status = typeof status === 'number' ? status : 0;
|
|
994
|
-
this.cause = cause;
|
|
995
|
-
Object.setPrototypeOf(this, WebrpcError.prototype);
|
|
996
|
-
}
|
|
997
|
-
static new(payload) {
|
|
998
|
-
return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
// Webrpc errors
|
|
1003
|
-
|
|
1004
|
-
class WebrpcEndpointError extends WebrpcError {
|
|
1005
|
-
constructor(name = 'WebrpcEndpoint', code = 0, message = `endpoint error`, status = 0, cause) {
|
|
1006
|
-
super(name, code, message, status, cause);
|
|
1007
|
-
Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
class WebrpcRequestFailedError extends WebrpcError {
|
|
1011
|
-
constructor(name = 'WebrpcRequestFailed', code = -1, message = `request failed`, status = 0, cause) {
|
|
1012
|
-
super(name, code, message, status, cause);
|
|
1013
|
-
Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
class WebrpcBadRouteError extends WebrpcError {
|
|
1017
|
-
constructor(name = 'WebrpcBadRoute', code = -2, message = `bad route`, status = 0, cause) {
|
|
1018
|
-
super(name, code, message, status, cause);
|
|
1019
|
-
Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
class WebrpcBadMethodError extends WebrpcError {
|
|
1023
|
-
constructor(name = 'WebrpcBadMethod', code = -3, message = `bad method`, status = 0, cause) {
|
|
1024
|
-
super(name, code, message, status, cause);
|
|
1025
|
-
Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
class WebrpcBadRequestError extends WebrpcError {
|
|
1029
|
-
constructor(name = 'WebrpcBadRequest', code = -4, message = `bad request`, status = 0, cause) {
|
|
1030
|
-
super(name, code, message, status, cause);
|
|
1031
|
-
Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
class WebrpcBadResponseError extends WebrpcError {
|
|
1035
|
-
constructor(name = 'WebrpcBadResponse', code = -5, message = `bad response`, status = 0, cause) {
|
|
1036
|
-
super(name, code, message, status, cause);
|
|
1037
|
-
Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
class WebrpcServerPanicError extends WebrpcError {
|
|
1041
|
-
constructor(name = 'WebrpcServerPanic', code = -6, message = `server panic`, status = 0, cause) {
|
|
1042
|
-
super(name, code, message, status, cause);
|
|
1043
|
-
Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
class WebrpcInternalErrorError extends WebrpcError {
|
|
1047
|
-
constructor(name = 'WebrpcInternalError', code = -7, message = `internal error`, status = 0, cause) {
|
|
1048
|
-
super(name, code, message, status, cause);
|
|
1049
|
-
Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
|
|
1050
|
-
}
|
|
1051
|
-
}
|
|
1052
|
-
class WebrpcClientDisconnectedError extends WebrpcError {
|
|
1053
|
-
constructor(name = 'WebrpcClientDisconnected', code = -8, message = `client disconnected`, status = 0, cause) {
|
|
1054
|
-
super(name, code, message, status, cause);
|
|
1055
|
-
Object.setPrototypeOf(this, WebrpcClientDisconnectedError.prototype);
|
|
1056
|
-
}
|
|
1057
|
-
}
|
|
1058
|
-
class WebrpcStreamLostError extends WebrpcError {
|
|
1059
|
-
constructor(name = 'WebrpcStreamLost', code = -9, message = `stream lost`, status = 0, cause) {
|
|
1060
|
-
super(name, code, message, status, cause);
|
|
1061
|
-
Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
class WebrpcStreamFinishedError extends WebrpcError {
|
|
1065
|
-
constructor(name = 'WebrpcStreamFinished', code = -10, message = `stream finished`, status = 0, cause) {
|
|
1066
|
-
super(name, code, message, status, cause);
|
|
1067
|
-
Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
|
|
1068
|
-
}
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
// Schema errors
|
|
1072
|
-
|
|
1073
|
-
class UnauthorizedError extends WebrpcError {
|
|
1074
|
-
constructor(name = 'Unauthorized', code = 1000, message = `Unauthorized access`, status = 0, cause) {
|
|
1075
|
-
super(name, code, message, status, cause);
|
|
1076
|
-
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
class PermissionDeniedError extends WebrpcError {
|
|
1080
|
-
constructor(name = 'PermissionDenied', code = 1001, message = `Permission denied`, status = 0, cause) {
|
|
1081
|
-
super(name, code, message, status, cause);
|
|
1082
|
-
Object.setPrototypeOf(this, PermissionDeniedError.prototype);
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
class SessionExpiredError extends WebrpcError {
|
|
1086
|
-
constructor(name = 'SessionExpired', code = 1002, message = `Session expired`, status = 0, cause) {
|
|
1087
|
-
super(name, code, message, status, cause);
|
|
1088
|
-
Object.setPrototypeOf(this, SessionExpiredError.prototype);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
class MethodNotFoundError extends WebrpcError {
|
|
1092
|
-
constructor(name = 'MethodNotFound', code = 1003, message = `Method not found`, status = 0, cause) {
|
|
1093
|
-
super(name, code, message, status, cause);
|
|
1094
|
-
Object.setPrototypeOf(this, MethodNotFoundError.prototype);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
class RequestConflictError extends WebrpcError {
|
|
1098
|
-
constructor(name = 'RequestConflict', code = 1004, message = `Conflict with target resource`, status = 0, cause) {
|
|
1099
|
-
super(name, code, message, status, cause);
|
|
1100
|
-
Object.setPrototypeOf(this, RequestConflictError.prototype);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
class FailError extends WebrpcError {
|
|
1104
|
-
constructor(name = 'Fail', code = 1005, message = `Request Failed`, status = 0, cause) {
|
|
1105
|
-
super(name, code, message, status, cause);
|
|
1106
|
-
Object.setPrototypeOf(this, FailError.prototype);
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
class GeoblockedError extends WebrpcError {
|
|
1110
|
-
constructor(name = 'Geoblocked', code = 1006, message = `Geoblocked region`, status = 0, cause) {
|
|
1111
|
-
super(name, code, message, status, cause);
|
|
1112
|
-
Object.setPrototypeOf(this, GeoblockedError.prototype);
|
|
1113
|
-
}
|
|
1114
|
-
}
|
|
1115
|
-
class TaskFailedError extends WebrpcError {
|
|
1116
|
-
constructor(name = 'TaskFailed', code = 1007, message = `Task failed`, status = 0, cause) {
|
|
1117
|
-
super(name, code, message, status, cause);
|
|
1118
|
-
Object.setPrototypeOf(this, TaskFailedError.prototype);
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
class DeprecatedError extends WebrpcError {
|
|
1122
|
-
constructor(name = 'Deprecated', code = 1008, message = `RPC method is deprecated`, status = 0, cause) {
|
|
1123
|
-
super(name, code, message, status, cause);
|
|
1124
|
-
Object.setPrototypeOf(this, DeprecatedError.prototype);
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
class TimeoutError extends WebrpcError {
|
|
1128
|
-
constructor(name = 'Timeout', code = 2000, message = `Request timed out`, status = 0, cause) {
|
|
1129
|
-
super(name, code, message, status, cause);
|
|
1130
|
-
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
class InvalidArgumentError extends WebrpcError {
|
|
1134
|
-
constructor(name = 'InvalidArgument', code = 2001, message = `Invalid argument`, status = 0, cause) {
|
|
1135
|
-
super(name, code, message, status, cause);
|
|
1136
|
-
Object.setPrototypeOf(this, InvalidArgumentError.prototype);
|
|
1137
|
-
}
|
|
1138
|
-
}
|
|
1139
|
-
class RequiredArgumentError extends WebrpcError {
|
|
1140
|
-
constructor(name = 'RequiredArgument', code = 2002, message = `Required argument missing`, status = 0, cause) {
|
|
1141
|
-
super(name, code, message, status, cause);
|
|
1142
|
-
Object.setPrototypeOf(this, RequiredArgumentError.prototype);
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
class QueryFailedError extends WebrpcError {
|
|
1146
|
-
constructor(name = 'QueryFailed', code = 2003, message = `Query failed`, status = 0, cause) {
|
|
1147
|
-
super(name, code, message, status, cause);
|
|
1148
|
-
Object.setPrototypeOf(this, QueryFailedError.prototype);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
class ValidationFailedError extends WebrpcError {
|
|
1152
|
-
constructor(name = 'ValidationFailed', code = 2004, message = `Validation failed`, status = 0, cause) {
|
|
1153
|
-
super(name, code, message, status, cause);
|
|
1154
|
-
Object.setPrototypeOf(this, ValidationFailedError.prototype);
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
class RateLimitedError extends WebrpcError {
|
|
1158
|
-
constructor(name = 'RateLimited', code = 2005, message = `Rate limited`, status = 0, cause) {
|
|
1159
|
-
super(name, code, message, status, cause);
|
|
1160
|
-
Object.setPrototypeOf(this, RateLimitedError.prototype);
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
class NotFoundError extends WebrpcError {
|
|
1164
|
-
constructor(name = 'NotFound', code = 3000, message = `Resource not found`, status = 0, cause) {
|
|
1165
|
-
super(name, code, message, status, cause);
|
|
1166
|
-
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
class ProjectNotFoundError extends WebrpcError {
|
|
1170
|
-
constructor(name = 'ProjectNotFound', code = 3002, message = `Project not found`, status = 0, cause) {
|
|
1171
|
-
super(name, code, message, status, cause);
|
|
1172
|
-
Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
class ChainNotFoundError extends WebrpcError {
|
|
1176
|
-
constructor(name = 'ChainNotFound', code = 3003, message = `Chain not found`, status = 0, cause) {
|
|
1177
|
-
super(name, code, message, status, cause);
|
|
1178
|
-
Object.setPrototypeOf(this, ChainNotFoundError.prototype);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
class TokenDirectoryDisabledError extends WebrpcError {
|
|
1182
|
-
constructor(name = 'TokenDirectoryDisabled', code = 4001, message = `Token Directory is disabled`, status = 0, cause) {
|
|
1183
|
-
super(name, code, message, status, cause);
|
|
1184
|
-
Object.setPrototypeOf(this, TokenDirectoryDisabledError.prototype);
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1187
|
-
let errors = /*#__PURE__*/function (errors) {
|
|
1188
|
-
errors["WebrpcEndpoint"] = "WebrpcEndpoint";
|
|
1189
|
-
errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
|
|
1190
|
-
errors["WebrpcBadRoute"] = "WebrpcBadRoute";
|
|
1191
|
-
errors["WebrpcBadMethod"] = "WebrpcBadMethod";
|
|
1192
|
-
errors["WebrpcBadRequest"] = "WebrpcBadRequest";
|
|
1193
|
-
errors["WebrpcBadResponse"] = "WebrpcBadResponse";
|
|
1194
|
-
errors["WebrpcServerPanic"] = "WebrpcServerPanic";
|
|
1195
|
-
errors["WebrpcInternalError"] = "WebrpcInternalError";
|
|
1196
|
-
errors["WebrpcClientDisconnected"] = "WebrpcClientDisconnected";
|
|
1197
|
-
errors["WebrpcStreamLost"] = "WebrpcStreamLost";
|
|
1198
|
-
errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
|
|
1199
|
-
errors["Unauthorized"] = "Unauthorized";
|
|
1200
|
-
errors["PermissionDenied"] = "PermissionDenied";
|
|
1201
|
-
errors["SessionExpired"] = "SessionExpired";
|
|
1202
|
-
errors["MethodNotFound"] = "MethodNotFound";
|
|
1203
|
-
errors["RequestConflict"] = "RequestConflict";
|
|
1204
|
-
errors["Fail"] = "Fail";
|
|
1205
|
-
errors["Geoblocked"] = "Geoblocked";
|
|
1206
|
-
errors["TaskFailed"] = "TaskFailed";
|
|
1207
|
-
errors["Deprecated"] = "Deprecated";
|
|
1208
|
-
errors["Timeout"] = "Timeout";
|
|
1209
|
-
errors["InvalidArgument"] = "InvalidArgument";
|
|
1210
|
-
errors["RequiredArgument"] = "RequiredArgument";
|
|
1211
|
-
errors["QueryFailed"] = "QueryFailed";
|
|
1212
|
-
errors["ValidationFailed"] = "ValidationFailed";
|
|
1213
|
-
errors["RateLimited"] = "RateLimited";
|
|
1214
|
-
errors["NotFound"] = "NotFound";
|
|
1215
|
-
errors["ProjectNotFound"] = "ProjectNotFound";
|
|
1216
|
-
errors["ChainNotFound"] = "ChainNotFound";
|
|
1217
|
-
errors["TokenDirectoryDisabled"] = "TokenDirectoryDisabled";
|
|
1218
|
-
return errors;
|
|
1219
|
-
}({});
|
|
1220
|
-
let WebrpcErrorCodes = /*#__PURE__*/function (WebrpcErrorCodes) {
|
|
1221
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
|
|
1222
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
|
|
1223
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
|
|
1224
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
|
|
1225
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
|
|
1226
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
|
|
1227
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
|
|
1228
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
|
|
1229
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientDisconnected"] = -8] = "WebrpcClientDisconnected";
|
|
1230
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
|
|
1231
|
-
WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
|
|
1232
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
|
|
1233
|
-
WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
|
|
1234
|
-
WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
|
|
1235
|
-
WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
|
|
1236
|
-
WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
|
|
1237
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Fail"] = 1005] = "Fail";
|
|
1238
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Geoblocked"] = 1006] = "Geoblocked";
|
|
1239
|
-
WebrpcErrorCodes[WebrpcErrorCodes["TaskFailed"] = 1007] = "TaskFailed";
|
|
1240
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Deprecated"] = 1008] = "Deprecated";
|
|
1241
|
-
WebrpcErrorCodes[WebrpcErrorCodes["Timeout"] = 2000] = "Timeout";
|
|
1242
|
-
WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2001] = "InvalidArgument";
|
|
1243
|
-
WebrpcErrorCodes[WebrpcErrorCodes["RequiredArgument"] = 2002] = "RequiredArgument";
|
|
1244
|
-
WebrpcErrorCodes[WebrpcErrorCodes["QueryFailed"] = 2003] = "QueryFailed";
|
|
1245
|
-
WebrpcErrorCodes[WebrpcErrorCodes["ValidationFailed"] = 2004] = "ValidationFailed";
|
|
1246
|
-
WebrpcErrorCodes[WebrpcErrorCodes["RateLimited"] = 2005] = "RateLimited";
|
|
1247
|
-
WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 3000] = "NotFound";
|
|
1248
|
-
WebrpcErrorCodes[WebrpcErrorCodes["ProjectNotFound"] = 3002] = "ProjectNotFound";
|
|
1249
|
-
WebrpcErrorCodes[WebrpcErrorCodes["ChainNotFound"] = 3003] = "ChainNotFound";
|
|
1250
|
-
WebrpcErrorCodes[WebrpcErrorCodes["TokenDirectoryDisabled"] = 4001] = "TokenDirectoryDisabled";
|
|
1251
|
-
return WebrpcErrorCodes;
|
|
1252
|
-
}({});
|
|
1253
|
-
const webrpcErrorByCode = {
|
|
1254
|
-
[0]: WebrpcEndpointError,
|
|
1255
|
-
[-1]: WebrpcRequestFailedError,
|
|
1256
|
-
[-2]: WebrpcBadRouteError,
|
|
1257
|
-
[-3]: WebrpcBadMethodError,
|
|
1258
|
-
[-4]: WebrpcBadRequestError,
|
|
1259
|
-
[-5]: WebrpcBadResponseError,
|
|
1260
|
-
[-6]: WebrpcServerPanicError,
|
|
1261
|
-
[-7]: WebrpcInternalErrorError,
|
|
1262
|
-
[-8]: WebrpcClientDisconnectedError,
|
|
1263
|
-
[-9]: WebrpcStreamLostError,
|
|
1264
|
-
[-10]: WebrpcStreamFinishedError,
|
|
1265
|
-
[1000]: UnauthorizedError,
|
|
1266
|
-
[1001]: PermissionDeniedError,
|
|
1267
|
-
[1002]: SessionExpiredError,
|
|
1268
|
-
[1003]: MethodNotFoundError,
|
|
1269
|
-
[1004]: RequestConflictError,
|
|
1270
|
-
[1005]: FailError,
|
|
1271
|
-
[1006]: GeoblockedError,
|
|
1272
|
-
[1007]: TaskFailedError,
|
|
1273
|
-
[1008]: DeprecatedError,
|
|
1274
|
-
[2000]: TimeoutError,
|
|
1275
|
-
[2001]: InvalidArgumentError,
|
|
1276
|
-
[2002]: RequiredArgumentError,
|
|
1277
|
-
[2003]: QueryFailedError,
|
|
1278
|
-
[2004]: ValidationFailedError,
|
|
1279
|
-
[2005]: RateLimitedError,
|
|
1280
|
-
[3000]: NotFoundError,
|
|
1281
|
-
[3002]: ProjectNotFoundError,
|
|
1282
|
-
[3003]: ChainNotFoundError,
|
|
1283
|
-
[4001]: TokenDirectoryDisabledError
|
|
1284
|
-
};
|
|
1285
|
-
|
|
1286
|
-
class SequenceMetadata extends Metadata {
|
|
1287
|
-
constructor(hostname = 'https://metadata.sequence.app', projectAccessKey, jwtAuth) {
|
|
1288
|
-
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
1289
|
-
this.projectAccessKey = projectAccessKey;
|
|
1290
|
-
this.jwtAuth = jwtAuth;
|
|
1291
|
-
this._fetch = (input, init) => {
|
|
1292
|
-
// automatically include jwt and access key auth header to requests
|
|
1293
|
-
// if its been set on the client
|
|
1294
|
-
const headers = {};
|
|
1295
|
-
const jwtAuth = this.jwtAuth;
|
|
1296
|
-
const projectAccessKey = this.projectAccessKey;
|
|
1297
|
-
if (jwtAuth && jwtAuth.length > 0) {
|
|
1298
|
-
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
1299
|
-
}
|
|
1300
|
-
if (projectAccessKey && projectAccessKey.length > 0) {
|
|
1301
|
-
headers['X-Access-Key'] = projectAccessKey;
|
|
1302
|
-
}
|
|
1303
|
-
|
|
1304
|
-
// before the request is made
|
|
1305
|
-
init.headers = _extends({}, init.headers, headers);
|
|
1306
|
-
return fetch(input, init);
|
|
1307
|
-
};
|
|
1308
|
-
this.fetch = this._fetch;
|
|
1309
|
-
}
|
|
1310
|
-
}
|
|
1311
|
-
class SequenceCollections extends Collections {
|
|
1312
|
-
constructor(hostname = 'https://metadata.sequence.app', jwtAuth) {
|
|
1313
|
-
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
1314
|
-
this.jwtAuth = jwtAuth;
|
|
1315
|
-
this._fetch = (input, init) => {
|
|
1316
|
-
// automatically include jwt auth header to requests
|
|
1317
|
-
// if its been set on the client
|
|
1318
|
-
const headers = {};
|
|
1319
|
-
const jwtAuth = this.jwtAuth;
|
|
1320
|
-
if (jwtAuth && jwtAuth.length > 0) {
|
|
1321
|
-
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
1322
|
-
}
|
|
1323
|
-
|
|
1324
|
-
// before the request is made
|
|
1325
|
-
init.headers = _extends({}, init.headers, headers);
|
|
1326
|
-
return fetch(input, init);
|
|
1327
|
-
};
|
|
1328
|
-
this.fetch = this._fetch;
|
|
1329
|
-
}
|
|
1330
|
-
|
|
1331
|
-
// TODO: add uploadAsset() method similar to,
|
|
1332
|
-
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
1333
|
-
}
|
|
1334
|
-
|
|
1335
|
-
exports.Admin = Admin;
|
|
1336
|
-
exports.ChainNotFoundError = ChainNotFoundError;
|
|
1337
|
-
exports.Collections = Collections;
|
|
1338
|
-
exports.ContractType = ContractType;
|
|
1339
|
-
exports.DeprecatedError = DeprecatedError;
|
|
1340
|
-
exports.FailError = FailError;
|
|
1341
|
-
exports.GeoblockedError = GeoblockedError;
|
|
1342
|
-
exports.InvalidArgumentError = InvalidArgumentError;
|
|
1343
|
-
exports.Metadata = Metadata;
|
|
1344
|
-
exports.MethodNotFoundError = MethodNotFoundError;
|
|
1345
|
-
exports.NotFoundError = NotFoundError;
|
|
1346
|
-
exports.PermissionDeniedError = PermissionDeniedError;
|
|
1347
|
-
exports.ProjectNotFoundError = ProjectNotFoundError;
|
|
1348
|
-
exports.PropertyType = PropertyType;
|
|
1349
|
-
exports.QueryFailedError = QueryFailedError;
|
|
1350
|
-
exports.RateLimitedError = RateLimitedError;
|
|
1351
|
-
exports.RequestConflictError = RequestConflictError;
|
|
1352
|
-
exports.RequiredArgumentError = RequiredArgumentError;
|
|
1353
|
-
exports.ResourceStatus = ResourceStatus;
|
|
1354
|
-
exports.SequenceCollections = SequenceCollections;
|
|
1355
|
-
exports.SequenceMetadata = SequenceMetadata;
|
|
1356
|
-
exports.SessionExpiredError = SessionExpiredError;
|
|
1357
|
-
exports.Source = Source;
|
|
1358
|
-
exports.SwapType = SwapType;
|
|
1359
|
-
exports.TaskFailedError = TaskFailedError;
|
|
1360
|
-
exports.TaskStatus = TaskStatus;
|
|
1361
|
-
exports.TimeoutError = TimeoutError;
|
|
1362
|
-
exports.TokenDirectoryDisabledError = TokenDirectoryDisabledError;
|
|
1363
|
-
exports.UnauthorizedError = UnauthorizedError;
|
|
1364
|
-
exports.ValidationFailedError = ValidationFailedError;
|
|
1365
|
-
exports.VersionFromHeader = VersionFromHeader;
|
|
1366
|
-
exports.WebRPCSchemaHash = WebRPCSchemaHash;
|
|
1367
|
-
exports.WebRPCSchemaVersion = WebRPCSchemaVersion;
|
|
1368
|
-
exports.WebRPCVersion = WebRPCVersion;
|
|
1369
|
-
exports.WebrpcBadMethodError = WebrpcBadMethodError;
|
|
1370
|
-
exports.WebrpcBadRequestError = WebrpcBadRequestError;
|
|
1371
|
-
exports.WebrpcBadResponseError = WebrpcBadResponseError;
|
|
1372
|
-
exports.WebrpcBadRouteError = WebrpcBadRouteError;
|
|
1373
|
-
exports.WebrpcClientDisconnectedError = WebrpcClientDisconnectedError;
|
|
1374
|
-
exports.WebrpcEndpointError = WebrpcEndpointError;
|
|
1375
|
-
exports.WebrpcError = WebrpcError;
|
|
1376
|
-
exports.WebrpcErrorCodes = WebrpcErrorCodes;
|
|
1377
|
-
exports.WebrpcHeader = WebrpcHeader;
|
|
1378
|
-
exports.WebrpcHeaderValue = WebrpcHeaderValue;
|
|
1379
|
-
exports.WebrpcInternalErrorError = WebrpcInternalErrorError;
|
|
1380
|
-
exports.WebrpcRequestFailedError = WebrpcRequestFailedError;
|
|
1381
|
-
exports.WebrpcServerPanicError = WebrpcServerPanicError;
|
|
1382
|
-
exports.WebrpcStreamFinishedError = WebrpcStreamFinishedError;
|
|
1383
|
-
exports.WebrpcStreamLostError = WebrpcStreamLostError;
|
|
1384
|
-
exports.errors = errors;
|
|
1385
|
-
exports.webrpcErrorByCode = webrpcErrorByCode;
|