@0xsequence/metadata 0.0.0-20240321190537 → 0.0.0-20240402220106
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-metadata.cjs.dev.js +197 -18
- package/dist/0xsequence-metadata.cjs.prod.js +197 -18
- package/dist/0xsequence-metadata.esm.js +196 -18
- package/dist/declarations/src/index.d.ts +6 -1
- package/dist/declarations/src/metadata.gen.d.ts +242 -32
- package/package.json +1 -1
- package/src/index.ts +32 -2
- package/src/metadata.gen.ts +429 -44
|
@@ -18,7 +18,7 @@ function _extends() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/* eslint-disable */
|
|
21
|
-
// sequence-metadata v0.4.0
|
|
21
|
+
// sequence-metadata v0.4.0 0c2b6c9b82e849f907ee6eccf2ecffa81449cc47
|
|
22
22
|
// --
|
|
23
23
|
// Code generated by webrpc-gen@v0.14.0-dev with typescript@v0.10.0 generator. DO NOT EDIT.
|
|
24
24
|
//
|
|
@@ -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 = '0c2b6c9b82e849f907ee6eccf2ecffa81449cc47';
|
|
35
35
|
|
|
36
36
|
//
|
|
37
37
|
// Types
|
|
@@ -57,11 +57,6 @@ let SwapType = /*#__PURE__*/function (SwapType) {
|
|
|
57
57
|
SwapType["SELL"] = "SELL";
|
|
58
58
|
return SwapType;
|
|
59
59
|
}({});
|
|
60
|
-
let SortOrder = /*#__PURE__*/function (SortOrder) {
|
|
61
|
-
SortOrder["DESC"] = "DESC";
|
|
62
|
-
SortOrder["ASC"] = "ASC";
|
|
63
|
-
return SortOrder;
|
|
64
|
-
}({});
|
|
65
60
|
let TaskStatus = /*#__PURE__*/function (TaskStatus) {
|
|
66
61
|
TaskStatus["PENDING"] = "PENDING";
|
|
67
62
|
TaskStatus["PAUSED"] = "PAUSED";
|
|
@@ -114,6 +109,15 @@ class Metadata {
|
|
|
114
109
|
});
|
|
115
110
|
});
|
|
116
111
|
};
|
|
112
|
+
this.refreshTokenMetadata = (args, headers) => {
|
|
113
|
+
return this.fetch(this.url('RefreshTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
114
|
+
return buildResponse(res).then(_data => {
|
|
115
|
+
return {
|
|
116
|
+
taskId: _data.taskId
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
117
121
|
this.enqueueTokensForRefresh = (args, headers) => {
|
|
118
122
|
return this.fetch(this.url('EnqueueTokensForRefresh'), createHTTPRequest(args, headers)).then(res => {
|
|
119
123
|
return buildResponse(res).then(_data => {
|
|
@@ -236,15 +240,6 @@ class Metadata {
|
|
|
236
240
|
});
|
|
237
241
|
});
|
|
238
242
|
};
|
|
239
|
-
this.projectSetTokenMetadata = (args, headers) => {
|
|
240
|
-
return this.fetch(this.url('ProjectSetTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
241
|
-
return buildResponse(res).then(_data => {
|
|
242
|
-
return {
|
|
243
|
-
ok: _data.ok
|
|
244
|
-
};
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
};
|
|
248
243
|
this.getNiftyswapTokenQuantity = (args, headers) => {
|
|
249
244
|
return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers)).then(res => {
|
|
250
245
|
return buildResponse(res).then(_data => {
|
|
@@ -315,6 +310,166 @@ class Metadata {
|
|
|
315
310
|
return this.hostname + this.path + name;
|
|
316
311
|
}
|
|
317
312
|
}
|
|
313
|
+
class Collections {
|
|
314
|
+
constructor(hostname, fetch) {
|
|
315
|
+
this.hostname = void 0;
|
|
316
|
+
this.fetch = void 0;
|
|
317
|
+
this.path = '/rpc/Collections/';
|
|
318
|
+
this.createCollection = (args, headers) => {
|
|
319
|
+
return this.fetch(this.url('CreateCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
320
|
+
return buildResponse(res).then(_data => {
|
|
321
|
+
return {
|
|
322
|
+
collection: _data.collection
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
this.getCollection = (args, headers) => {
|
|
328
|
+
return this.fetch(this.url('GetCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
329
|
+
return buildResponse(res).then(_data => {
|
|
330
|
+
return {
|
|
331
|
+
collection: _data.collection
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
this.listCollections = (args, headers) => {
|
|
337
|
+
return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers)).then(res => {
|
|
338
|
+
return buildResponse(res).then(_data => {
|
|
339
|
+
return {
|
|
340
|
+
page: _data.page,
|
|
341
|
+
collections: _data.collections
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
this.updateCollection = (args, headers) => {
|
|
347
|
+
return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
348
|
+
return buildResponse(res).then(_data => {
|
|
349
|
+
return {
|
|
350
|
+
collection: _data.collection
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
this.deleteCollection = (args, headers) => {
|
|
356
|
+
return this.fetch(this.url('DeleteCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
357
|
+
return buildResponse(res).then(_data => {
|
|
358
|
+
return {
|
|
359
|
+
status: _data.status
|
|
360
|
+
};
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
this.publishCollection = (args, headers) => {
|
|
365
|
+
return this.fetch(this.url('PublishCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
366
|
+
return buildResponse(res).then(_data => {
|
|
367
|
+
return {
|
|
368
|
+
collection: _data.collection
|
|
369
|
+
};
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
this.unpublishCollection = (args, headers) => {
|
|
374
|
+
return this.fetch(this.url('UnpublishCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
375
|
+
return buildResponse(res).then(_data => {
|
|
376
|
+
return {
|
|
377
|
+
collection: _data.collection
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
this.createToken = (args, headers) => {
|
|
383
|
+
return this.fetch(this.url('CreateToken'), createHTTPRequest(args, headers)).then(res => {
|
|
384
|
+
return buildResponse(res).then(_data => {
|
|
385
|
+
return {
|
|
386
|
+
token: _data.token,
|
|
387
|
+
assets: _data.assets
|
|
388
|
+
};
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
this.getToken = (args, headers) => {
|
|
393
|
+
return this.fetch(this.url('GetToken'), createHTTPRequest(args, headers)).then(res => {
|
|
394
|
+
return buildResponse(res).then(_data => {
|
|
395
|
+
return {
|
|
396
|
+
token: _data.token,
|
|
397
|
+
assets: _data.assets
|
|
398
|
+
};
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
this.listTokens = (args, headers) => {
|
|
403
|
+
return this.fetch(this.url('ListTokens'), createHTTPRequest(args, headers)).then(res => {
|
|
404
|
+
return buildResponse(res).then(_data => {
|
|
405
|
+
return {
|
|
406
|
+
page: _data.page,
|
|
407
|
+
tokens: _data.tokens
|
|
408
|
+
};
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
this.updateToken = (args, headers) => {
|
|
413
|
+
return this.fetch(this.url('UpdateToken'), createHTTPRequest(args, headers)).then(res => {
|
|
414
|
+
return buildResponse(res).then(_data => {
|
|
415
|
+
return {
|
|
416
|
+
token: _data.token
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
};
|
|
421
|
+
this.deleteToken = (args, headers) => {
|
|
422
|
+
return this.fetch(this.url('DeleteToken'), createHTTPRequest(args, headers)).then(res => {
|
|
423
|
+
return buildResponse(res).then(_data => {
|
|
424
|
+
return {
|
|
425
|
+
status: _data.status
|
|
426
|
+
};
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
this.createAsset = (args, headers) => {
|
|
431
|
+
return this.fetch(this.url('CreateAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
432
|
+
return buildResponse(res).then(_data => {
|
|
433
|
+
return {
|
|
434
|
+
asset: _data.asset
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
this.getAsset = (args, headers) => {
|
|
440
|
+
return this.fetch(this.url('GetAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
441
|
+
return buildResponse(res).then(_data => {
|
|
442
|
+
return {
|
|
443
|
+
asset: _data.asset
|
|
444
|
+
};
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
this.updateAsset = (args, headers) => {
|
|
449
|
+
return this.fetch(this.url('UpdateAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
450
|
+
return buildResponse(res).then(_data => {
|
|
451
|
+
return {
|
|
452
|
+
asset: _data.asset
|
|
453
|
+
};
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
};
|
|
457
|
+
this.deleteAsset = (args, headers) => {
|
|
458
|
+
return this.fetch(this.url('DeleteAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
459
|
+
return buildResponse(res).then(_data => {
|
|
460
|
+
return {
|
|
461
|
+
status: _data.status
|
|
462
|
+
};
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
};
|
|
466
|
+
this.hostname = hostname;
|
|
467
|
+
this.fetch = (input, init) => fetch(input, init);
|
|
468
|
+
}
|
|
469
|
+
url(name) {
|
|
470
|
+
return this.hostname + this.path + name;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
318
473
|
const createHTTPRequest = (body = {}, headers = {}) => {
|
|
319
474
|
return {
|
|
320
475
|
method: 'POST',
|
|
@@ -351,7 +506,7 @@ class SequenceMetadata extends Metadata {
|
|
|
351
506
|
this.jwtAuth = jwtAuth;
|
|
352
507
|
this._fetch = (input, init) => {
|
|
353
508
|
// automatically include jwt and access key auth header to requests
|
|
354
|
-
// if its been set on the
|
|
509
|
+
// if its been set on the client
|
|
355
510
|
const headers = {};
|
|
356
511
|
const jwtAuth = this.jwtAuth;
|
|
357
512
|
const projectAccessKey = this.projectAccessKey;
|
|
@@ -369,12 +524,36 @@ class SequenceMetadata extends Metadata {
|
|
|
369
524
|
this.fetch = this._fetch;
|
|
370
525
|
}
|
|
371
526
|
}
|
|
527
|
+
class SequenceCollections extends Collections {
|
|
528
|
+
constructor(hostname = 'https://metadata.sequence.app', jwtAuth) {
|
|
529
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
530
|
+
this.jwtAuth = jwtAuth;
|
|
531
|
+
this._fetch = (input, init) => {
|
|
532
|
+
// automatically include jwt auth header to requests
|
|
533
|
+
// if its been set on the client
|
|
534
|
+
const headers = {};
|
|
535
|
+
const jwtAuth = this.jwtAuth;
|
|
536
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
537
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// before the request is made
|
|
541
|
+
init.headers = _extends({}, init.headers, headers);
|
|
542
|
+
return fetch(input, init);
|
|
543
|
+
};
|
|
544
|
+
this.fetch = this._fetch;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// TODO: add uploadAsset() method similar to,
|
|
548
|
+
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
549
|
+
}
|
|
372
550
|
|
|
551
|
+
exports.Collections = Collections;
|
|
373
552
|
exports.ContractType = ContractType;
|
|
374
553
|
exports.Metadata = Metadata;
|
|
375
554
|
exports.PropertyType = PropertyType;
|
|
555
|
+
exports.SequenceCollections = SequenceCollections;
|
|
376
556
|
exports.SequenceMetadata = SequenceMetadata;
|
|
377
|
-
exports.SortOrder = SortOrder;
|
|
378
557
|
exports.SwapType = SwapType;
|
|
379
558
|
exports.TaskStatus = TaskStatus;
|
|
380
559
|
exports.WebRPCSchemaHash = WebRPCSchemaHash;
|
|
@@ -18,7 +18,7 @@ function _extends() {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/* eslint-disable */
|
|
21
|
-
// sequence-metadata v0.4.0
|
|
21
|
+
// sequence-metadata v0.4.0 0c2b6c9b82e849f907ee6eccf2ecffa81449cc47
|
|
22
22
|
// --
|
|
23
23
|
// Code generated by webrpc-gen@v0.14.0-dev with typescript@v0.10.0 generator. DO NOT EDIT.
|
|
24
24
|
//
|
|
@@ -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 = '0c2b6c9b82e849f907ee6eccf2ecffa81449cc47';
|
|
35
35
|
|
|
36
36
|
//
|
|
37
37
|
// Types
|
|
@@ -57,11 +57,6 @@ let SwapType = /*#__PURE__*/function (SwapType) {
|
|
|
57
57
|
SwapType["SELL"] = "SELL";
|
|
58
58
|
return SwapType;
|
|
59
59
|
}({});
|
|
60
|
-
let SortOrder = /*#__PURE__*/function (SortOrder) {
|
|
61
|
-
SortOrder["DESC"] = "DESC";
|
|
62
|
-
SortOrder["ASC"] = "ASC";
|
|
63
|
-
return SortOrder;
|
|
64
|
-
}({});
|
|
65
60
|
let TaskStatus = /*#__PURE__*/function (TaskStatus) {
|
|
66
61
|
TaskStatus["PENDING"] = "PENDING";
|
|
67
62
|
TaskStatus["PAUSED"] = "PAUSED";
|
|
@@ -114,6 +109,15 @@ class Metadata {
|
|
|
114
109
|
});
|
|
115
110
|
});
|
|
116
111
|
};
|
|
112
|
+
this.refreshTokenMetadata = (args, headers) => {
|
|
113
|
+
return this.fetch(this.url('RefreshTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
114
|
+
return buildResponse(res).then(_data => {
|
|
115
|
+
return {
|
|
116
|
+
taskId: _data.taskId
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
117
121
|
this.enqueueTokensForRefresh = (args, headers) => {
|
|
118
122
|
return this.fetch(this.url('EnqueueTokensForRefresh'), createHTTPRequest(args, headers)).then(res => {
|
|
119
123
|
return buildResponse(res).then(_data => {
|
|
@@ -236,15 +240,6 @@ class Metadata {
|
|
|
236
240
|
});
|
|
237
241
|
});
|
|
238
242
|
};
|
|
239
|
-
this.projectSetTokenMetadata = (args, headers) => {
|
|
240
|
-
return this.fetch(this.url('ProjectSetTokenMetadata'), createHTTPRequest(args, headers)).then(res => {
|
|
241
|
-
return buildResponse(res).then(_data => {
|
|
242
|
-
return {
|
|
243
|
-
ok: _data.ok
|
|
244
|
-
};
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
};
|
|
248
243
|
this.getNiftyswapTokenQuantity = (args, headers) => {
|
|
249
244
|
return this.fetch(this.url('GetNiftyswapTokenQuantity'), createHTTPRequest(args, headers)).then(res => {
|
|
250
245
|
return buildResponse(res).then(_data => {
|
|
@@ -315,6 +310,166 @@ class Metadata {
|
|
|
315
310
|
return this.hostname + this.path + name;
|
|
316
311
|
}
|
|
317
312
|
}
|
|
313
|
+
class Collections {
|
|
314
|
+
constructor(hostname, fetch) {
|
|
315
|
+
this.hostname = void 0;
|
|
316
|
+
this.fetch = void 0;
|
|
317
|
+
this.path = '/rpc/Collections/';
|
|
318
|
+
this.createCollection = (args, headers) => {
|
|
319
|
+
return this.fetch(this.url('CreateCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
320
|
+
return buildResponse(res).then(_data => {
|
|
321
|
+
return {
|
|
322
|
+
collection: _data.collection
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
this.getCollection = (args, headers) => {
|
|
328
|
+
return this.fetch(this.url('GetCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
329
|
+
return buildResponse(res).then(_data => {
|
|
330
|
+
return {
|
|
331
|
+
collection: _data.collection
|
|
332
|
+
};
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
};
|
|
336
|
+
this.listCollections = (args, headers) => {
|
|
337
|
+
return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers)).then(res => {
|
|
338
|
+
return buildResponse(res).then(_data => {
|
|
339
|
+
return {
|
|
340
|
+
page: _data.page,
|
|
341
|
+
collections: _data.collections
|
|
342
|
+
};
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
};
|
|
346
|
+
this.updateCollection = (args, headers) => {
|
|
347
|
+
return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
348
|
+
return buildResponse(res).then(_data => {
|
|
349
|
+
return {
|
|
350
|
+
collection: _data.collection
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
};
|
|
355
|
+
this.deleteCollection = (args, headers) => {
|
|
356
|
+
return this.fetch(this.url('DeleteCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
357
|
+
return buildResponse(res).then(_data => {
|
|
358
|
+
return {
|
|
359
|
+
status: _data.status
|
|
360
|
+
};
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
this.publishCollection = (args, headers) => {
|
|
365
|
+
return this.fetch(this.url('PublishCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
366
|
+
return buildResponse(res).then(_data => {
|
|
367
|
+
return {
|
|
368
|
+
collection: _data.collection
|
|
369
|
+
};
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
};
|
|
373
|
+
this.unpublishCollection = (args, headers) => {
|
|
374
|
+
return this.fetch(this.url('UnpublishCollection'), createHTTPRequest(args, headers)).then(res => {
|
|
375
|
+
return buildResponse(res).then(_data => {
|
|
376
|
+
return {
|
|
377
|
+
collection: _data.collection
|
|
378
|
+
};
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
this.createToken = (args, headers) => {
|
|
383
|
+
return this.fetch(this.url('CreateToken'), createHTTPRequest(args, headers)).then(res => {
|
|
384
|
+
return buildResponse(res).then(_data => {
|
|
385
|
+
return {
|
|
386
|
+
token: _data.token,
|
|
387
|
+
assets: _data.assets
|
|
388
|
+
};
|
|
389
|
+
});
|
|
390
|
+
});
|
|
391
|
+
};
|
|
392
|
+
this.getToken = (args, headers) => {
|
|
393
|
+
return this.fetch(this.url('GetToken'), createHTTPRequest(args, headers)).then(res => {
|
|
394
|
+
return buildResponse(res).then(_data => {
|
|
395
|
+
return {
|
|
396
|
+
token: _data.token,
|
|
397
|
+
assets: _data.assets
|
|
398
|
+
};
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
};
|
|
402
|
+
this.listTokens = (args, headers) => {
|
|
403
|
+
return this.fetch(this.url('ListTokens'), createHTTPRequest(args, headers)).then(res => {
|
|
404
|
+
return buildResponse(res).then(_data => {
|
|
405
|
+
return {
|
|
406
|
+
page: _data.page,
|
|
407
|
+
tokens: _data.tokens
|
|
408
|
+
};
|
|
409
|
+
});
|
|
410
|
+
});
|
|
411
|
+
};
|
|
412
|
+
this.updateToken = (args, headers) => {
|
|
413
|
+
return this.fetch(this.url('UpdateToken'), createHTTPRequest(args, headers)).then(res => {
|
|
414
|
+
return buildResponse(res).then(_data => {
|
|
415
|
+
return {
|
|
416
|
+
token: _data.token
|
|
417
|
+
};
|
|
418
|
+
});
|
|
419
|
+
});
|
|
420
|
+
};
|
|
421
|
+
this.deleteToken = (args, headers) => {
|
|
422
|
+
return this.fetch(this.url('DeleteToken'), createHTTPRequest(args, headers)).then(res => {
|
|
423
|
+
return buildResponse(res).then(_data => {
|
|
424
|
+
return {
|
|
425
|
+
status: _data.status
|
|
426
|
+
};
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
this.createAsset = (args, headers) => {
|
|
431
|
+
return this.fetch(this.url('CreateAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
432
|
+
return buildResponse(res).then(_data => {
|
|
433
|
+
return {
|
|
434
|
+
asset: _data.asset
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
};
|
|
439
|
+
this.getAsset = (args, headers) => {
|
|
440
|
+
return this.fetch(this.url('GetAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
441
|
+
return buildResponse(res).then(_data => {
|
|
442
|
+
return {
|
|
443
|
+
asset: _data.asset
|
|
444
|
+
};
|
|
445
|
+
});
|
|
446
|
+
});
|
|
447
|
+
};
|
|
448
|
+
this.updateAsset = (args, headers) => {
|
|
449
|
+
return this.fetch(this.url('UpdateAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
450
|
+
return buildResponse(res).then(_data => {
|
|
451
|
+
return {
|
|
452
|
+
asset: _data.asset
|
|
453
|
+
};
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
};
|
|
457
|
+
this.deleteAsset = (args, headers) => {
|
|
458
|
+
return this.fetch(this.url('DeleteAsset'), createHTTPRequest(args, headers)).then(res => {
|
|
459
|
+
return buildResponse(res).then(_data => {
|
|
460
|
+
return {
|
|
461
|
+
status: _data.status
|
|
462
|
+
};
|
|
463
|
+
});
|
|
464
|
+
});
|
|
465
|
+
};
|
|
466
|
+
this.hostname = hostname;
|
|
467
|
+
this.fetch = (input, init) => fetch(input, init);
|
|
468
|
+
}
|
|
469
|
+
url(name) {
|
|
470
|
+
return this.hostname + this.path + name;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
318
473
|
const createHTTPRequest = (body = {}, headers = {}) => {
|
|
319
474
|
return {
|
|
320
475
|
method: 'POST',
|
|
@@ -351,7 +506,7 @@ class SequenceMetadata extends Metadata {
|
|
|
351
506
|
this.jwtAuth = jwtAuth;
|
|
352
507
|
this._fetch = (input, init) => {
|
|
353
508
|
// automatically include jwt and access key auth header to requests
|
|
354
|
-
// if its been set on the
|
|
509
|
+
// if its been set on the client
|
|
355
510
|
const headers = {};
|
|
356
511
|
const jwtAuth = this.jwtAuth;
|
|
357
512
|
const projectAccessKey = this.projectAccessKey;
|
|
@@ -369,12 +524,36 @@ class SequenceMetadata extends Metadata {
|
|
|
369
524
|
this.fetch = this._fetch;
|
|
370
525
|
}
|
|
371
526
|
}
|
|
527
|
+
class SequenceCollections extends Collections {
|
|
528
|
+
constructor(hostname = 'https://metadata.sequence.app', jwtAuth) {
|
|
529
|
+
super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
|
|
530
|
+
this.jwtAuth = jwtAuth;
|
|
531
|
+
this._fetch = (input, init) => {
|
|
532
|
+
// automatically include jwt auth header to requests
|
|
533
|
+
// if its been set on the client
|
|
534
|
+
const headers = {};
|
|
535
|
+
const jwtAuth = this.jwtAuth;
|
|
536
|
+
if (jwtAuth && jwtAuth.length > 0) {
|
|
537
|
+
headers['Authorization'] = `BEARER ${jwtAuth}`;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// before the request is made
|
|
541
|
+
init.headers = _extends({}, init.headers, headers);
|
|
542
|
+
return fetch(input, init);
|
|
543
|
+
};
|
|
544
|
+
this.fetch = this._fetch;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// TODO: add uploadAsset() method similar to,
|
|
548
|
+
// https://github.com/0xsequence/go-sequence/blob/master/metadata/collections.go#L52
|
|
549
|
+
}
|
|
372
550
|
|
|
551
|
+
exports.Collections = Collections;
|
|
373
552
|
exports.ContractType = ContractType;
|
|
374
553
|
exports.Metadata = Metadata;
|
|
375
554
|
exports.PropertyType = PropertyType;
|
|
555
|
+
exports.SequenceCollections = SequenceCollections;
|
|
376
556
|
exports.SequenceMetadata = SequenceMetadata;
|
|
377
|
-
exports.SortOrder = SortOrder;
|
|
378
557
|
exports.SwapType = SwapType;
|
|
379
558
|
exports.TaskStatus = TaskStatus;
|
|
380
559
|
exports.WebRPCSchemaHash = WebRPCSchemaHash;
|