@0xsequence/marketplace 2.3.39 → 3.0.0-beta.10

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.
@@ -1,1508 +0,0 @@
1
- function _extends() {
2
- return _extends = Object.assign ? Object.assign.bind() : function (n) {
3
- for (var e = 1; e < arguments.length; e++) {
4
- var t = arguments[e];
5
- for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
6
- }
7
- return n;
8
- }, _extends.apply(null, arguments);
9
- }
10
-
11
- /* eslint-disable */
12
- // marketplace-api v0-25.12.1+61b56ff 695923688f38cbb56ca3bab78e75d9a0f48c10e2
13
- // --
14
- // Code generated by webrpc-gen@v0.31.2 with github.com/webrpc/gen-typescript@v0.19.0 generator. DO NOT EDIT.
15
- //
16
- // webrpc-gen -schema=./schema_old/schema.ridl -target=github.com/webrpc/gen-typescript@v0.19.0 -client -out=./clients/marketplace.gen.ts
17
-
18
- const WebrpcHeader = 'Webrpc';
19
- const WebrpcHeaderValue = 'webrpc@v0.31.2;gen-typescript@v0.19.0;marketplace-api@v0-25.12.1+61b56ff';
20
-
21
- // WebRPC description and code-gen version
22
- const WebRPCVersion = 'v1';
23
-
24
- // Schema version of your RIDL schema
25
- const WebRPCSchemaVersion = 'v0-25.12.1+61b56ff';
26
-
27
- // Schema hash generated from your RIDL schema
28
- const WebRPCSchemaHash = '695923688f38cbb56ca3bab78e75d9a0f48c10e2';
29
- function VersionFromHeader(headers) {
30
- const headerValue = headers.get(WebrpcHeader);
31
- if (!headerValue) {
32
- return {
33
- webrpcGenVersion: '',
34
- codeGenName: '',
35
- codeGenVersion: '',
36
- schemaName: '',
37
- schemaVersion: ''
38
- };
39
- }
40
- return parseWebrpcGenVersions(headerValue);
41
- }
42
- function parseWebrpcGenVersions(header) {
43
- const versions = header.split(';');
44
- if (versions.length < 3) {
45
- return {
46
- webrpcGenVersion: '',
47
- codeGenName: '',
48
- codeGenVersion: '',
49
- schemaName: '',
50
- schemaVersion: ''
51
- };
52
- }
53
- const [_, webrpcGenVersion] = versions[0].split('@');
54
- const [codeGenName, codeGenVersion] = versions[1].split('@');
55
- const [schemaName, schemaVersion] = versions[2].split('@');
56
- return {
57
- webrpcGenVersion: webrpcGenVersion != null ? webrpcGenVersion : '',
58
- codeGenName: codeGenName != null ? codeGenName : '',
59
- codeGenVersion: codeGenVersion != null ? codeGenVersion : '',
60
- schemaName: schemaName != null ? schemaName : '',
61
- schemaVersion: schemaVersion != null ? schemaVersion : ''
62
- };
63
- }
64
-
65
- //
66
- // Types
67
- //
68
-
69
- let SortOrder = /*#__PURE__*/function (SortOrder) {
70
- SortOrder["ASC"] = "ASC";
71
- SortOrder["DESC"] = "DESC";
72
- return SortOrder;
73
- }({});
74
- let PropertyType = /*#__PURE__*/function (PropertyType) {
75
- PropertyType["INT"] = "INT";
76
- PropertyType["STRING"] = "STRING";
77
- PropertyType["ARRAY"] = "ARRAY";
78
- PropertyType["GENERIC"] = "GENERIC";
79
- return PropertyType;
80
- }({});
81
- let MarketplaceKind = /*#__PURE__*/function (MarketplaceKind) {
82
- MarketplaceKind["unknown"] = "unknown";
83
- MarketplaceKind["sequence_marketplace_v1"] = "sequence_marketplace_v1";
84
- MarketplaceKind["sequence_marketplace_v2"] = "sequence_marketplace_v2";
85
- MarketplaceKind["blur"] = "blur";
86
- MarketplaceKind["zerox"] = "zerox";
87
- MarketplaceKind["opensea"] = "opensea";
88
- MarketplaceKind["looks_rare"] = "looks_rare";
89
- MarketplaceKind["x2y2"] = "x2y2";
90
- MarketplaceKind["alienswap"] = "alienswap";
91
- MarketplaceKind["payment_processor"] = "payment_processor";
92
- MarketplaceKind["mintify"] = "mintify";
93
- MarketplaceKind["magic_eden"] = "magic_eden";
94
- return MarketplaceKind;
95
- }({});
96
- let OrderbookKind = /*#__PURE__*/function (OrderbookKind) {
97
- OrderbookKind["unknown"] = "unknown";
98
- OrderbookKind["sequence_marketplace_v1"] = "sequence_marketplace_v1";
99
- OrderbookKind["sequence_marketplace_v2"] = "sequence_marketplace_v2";
100
- OrderbookKind["blur"] = "blur";
101
- OrderbookKind["opensea"] = "opensea";
102
- OrderbookKind["looks_rare"] = "looks_rare";
103
- OrderbookKind["reservoir"] = "reservoir";
104
- OrderbookKind["x2y2"] = "x2y2";
105
- OrderbookKind["magic_eden"] = "magic_eden";
106
- return OrderbookKind;
107
- }({});
108
- let SourceKind = /*#__PURE__*/function (SourceKind) {
109
- SourceKind["unknown"] = "unknown";
110
- SourceKind["external"] = "external";
111
- SourceKind["sequence_marketplace_v1"] = "sequence_marketplace_v1";
112
- SourceKind["sequence_marketplace_v2"] = "sequence_marketplace_v2";
113
- SourceKind["opensea"] = "opensea";
114
- SourceKind["magic_eden"] = "magic_eden";
115
- return SourceKind;
116
- }({});
117
- let OrderSide = /*#__PURE__*/function (OrderSide) {
118
- OrderSide["unknown"] = "unknown";
119
- OrderSide["listing"] = "listing";
120
- OrderSide["offer"] = "offer";
121
- return OrderSide;
122
- }({});
123
- let OfferType = /*#__PURE__*/function (OfferType) {
124
- OfferType["unknown"] = "unknown";
125
- OfferType["item"] = "item";
126
- OfferType["collection"] = "collection";
127
- return OfferType;
128
- }({});
129
- let OrderStatus = /*#__PURE__*/function (OrderStatus) {
130
- OrderStatus["unknown"] = "unknown";
131
- OrderStatus["active"] = "active";
132
- OrderStatus["inactive"] = "inactive";
133
- OrderStatus["expired"] = "expired";
134
- OrderStatus["cancelled"] = "cancelled";
135
- OrderStatus["filled"] = "filled";
136
- OrderStatus["decimals_missing"] = "decimals_missing";
137
- return OrderStatus;
138
- }({});
139
- let ContractType = /*#__PURE__*/function (ContractType) {
140
- ContractType["UNKNOWN"] = "UNKNOWN";
141
- ContractType["ERC20"] = "ERC20";
142
- ContractType["ERC721"] = "ERC721";
143
- ContractType["ERC1155"] = "ERC1155";
144
- return ContractType;
145
- }({});
146
- let CollectionPriority = /*#__PURE__*/function (CollectionPriority) {
147
- CollectionPriority["unknown"] = "unknown";
148
- CollectionPriority["low"] = "low";
149
- CollectionPriority["normal"] = "normal";
150
- CollectionPriority["high"] = "high";
151
- return CollectionPriority;
152
- }({});
153
- let CollectionStatus = /*#__PURE__*/function (CollectionStatus) {
154
- CollectionStatus["unknown"] = "unknown";
155
- CollectionStatus["created"] = "created";
156
- CollectionStatus["syncing_orders"] = "syncing_orders";
157
- CollectionStatus["active"] = "active";
158
- CollectionStatus["failed"] = "failed";
159
- CollectionStatus["inactive"] = "inactive";
160
- CollectionStatus["incompatible_type"] = "incompatible_type";
161
- return CollectionStatus;
162
- }({});
163
- let ProjectStatus = /*#__PURE__*/function (ProjectStatus) {
164
- ProjectStatus["unknown"] = "unknown";
165
- ProjectStatus["active"] = "active";
166
- ProjectStatus["inactive"] = "inactive";
167
- return ProjectStatus;
168
- }({});
169
- let ItemsContractStatus = /*#__PURE__*/function (ItemsContractStatus) {
170
- ItemsContractStatus["unknown"] = "unknown";
171
- ItemsContractStatus["created"] = "created";
172
- ItemsContractStatus["syncing_contract_metadata"] = "syncing_contract_metadata";
173
- ItemsContractStatus["synced_contract_metadata"] = "synced_contract_metadata";
174
- ItemsContractStatus["syncing_tokens"] = "syncing_tokens";
175
- ItemsContractStatus["synced_tokens"] = "synced_tokens";
176
- ItemsContractStatus["active"] = "active";
177
- ItemsContractStatus["inactive"] = "inactive";
178
- ItemsContractStatus["incompatible_type"] = "incompatible_type";
179
- return ItemsContractStatus;
180
- }({});
181
- let CollectibleStatus = /*#__PURE__*/function (CollectibleStatus) {
182
- CollectibleStatus["unknown"] = "unknown";
183
- CollectibleStatus["active"] = "active";
184
- CollectibleStatus["inactive"] = "inactive";
185
- return CollectibleStatus;
186
- }({});
187
- let CollectibleSource = /*#__PURE__*/function (CollectibleSource) {
188
- CollectibleSource["unknown"] = "unknown";
189
- CollectibleSource["indexer"] = "indexer";
190
- CollectibleSource["manual"] = "manual";
191
- return CollectibleSource;
192
- }({});
193
- let CurrencyStatus = /*#__PURE__*/function (CurrencyStatus) {
194
- CurrencyStatus["unknown"] = "unknown";
195
- CurrencyStatus["created"] = "created";
196
- CurrencyStatus["syncing_metadata"] = "syncing_metadata";
197
- CurrencyStatus["active"] = "active";
198
- CurrencyStatus["failed"] = "failed";
199
- return CurrencyStatus;
200
- }({});
201
- let WalletKind = /*#__PURE__*/function (WalletKind) {
202
- WalletKind["unknown"] = "unknown";
203
- WalletKind["sequence"] = "sequence";
204
- return WalletKind;
205
- }({});
206
- let StepType = /*#__PURE__*/function (StepType) {
207
- StepType["unknown"] = "unknown";
208
- StepType["tokenApproval"] = "tokenApproval";
209
- StepType["buy"] = "buy";
210
- StepType["sell"] = "sell";
211
- StepType["createListing"] = "createListing";
212
- StepType["createOffer"] = "createOffer";
213
- StepType["signEIP712"] = "signEIP712";
214
- StepType["signEIP191"] = "signEIP191";
215
- StepType["cancel"] = "cancel";
216
- return StepType;
217
- }({});
218
- let TransactionCrypto = /*#__PURE__*/function (TransactionCrypto) {
219
- TransactionCrypto["none"] = "none";
220
- TransactionCrypto["partially"] = "partially";
221
- TransactionCrypto["all"] = "all";
222
- return TransactionCrypto;
223
- }({});
224
- let TransactionNFTCheckoutProvider = /*#__PURE__*/function (TransactionNFTCheckoutProvider) {
225
- TransactionNFTCheckoutProvider["unknown"] = "unknown";
226
- TransactionNFTCheckoutProvider["transak"] = "transak";
227
- TransactionNFTCheckoutProvider["sardine"] = "sardine";
228
- return TransactionNFTCheckoutProvider;
229
- }({});
230
- let TransactionOnRampProvider = /*#__PURE__*/function (TransactionOnRampProvider) {
231
- TransactionOnRampProvider["unknown"] = "unknown";
232
- TransactionOnRampProvider["transak"] = "transak";
233
- TransactionOnRampProvider["sardine"] = "sardine";
234
- return TransactionOnRampProvider;
235
- }({});
236
- let TransactionSwapProvider = /*#__PURE__*/function (TransactionSwapProvider) {
237
- TransactionSwapProvider["unknown"] = "unknown";
238
- TransactionSwapProvider["lifi"] = "lifi";
239
- return TransactionSwapProvider;
240
- }({});
241
- let ExecuteType = /*#__PURE__*/function (ExecuteType) {
242
- ExecuteType["unknown"] = "unknown";
243
- ExecuteType["order"] = "order";
244
- ExecuteType["createListing"] = "createListing";
245
- ExecuteType["createItemOffer"] = "createItemOffer";
246
- ExecuteType["createTraitOffer"] = "createTraitOffer";
247
- return ExecuteType;
248
- }({});
249
- let ActivityAction = /*#__PURE__*/function (ActivityAction) {
250
- ActivityAction["unknown"] = "unknown";
251
- ActivityAction["listing"] = "listing";
252
- ActivityAction["offer"] = "offer";
253
- ActivityAction["mint"] = "mint";
254
- ActivityAction["sale"] = "sale";
255
- ActivityAction["listingCancel"] = "listingCancel";
256
- ActivityAction["offerCancel"] = "offerCancel";
257
- ActivityAction["transfer"] = "transfer";
258
- return ActivityAction;
259
- }({});
260
- let PrimarySaleContractStatus = /*#__PURE__*/function (PrimarySaleContractStatus) {
261
- PrimarySaleContractStatus["unknown"] = "unknown";
262
- PrimarySaleContractStatus["created"] = "created";
263
- PrimarySaleContractStatus["syncing_items"] = "syncing_items";
264
- PrimarySaleContractStatus["active"] = "active";
265
- PrimarySaleContractStatus["inactive"] = "inactive";
266
- PrimarySaleContractStatus["incompatible_type"] = "incompatible_type";
267
- PrimarySaleContractStatus["failed"] = "failed";
268
- return PrimarySaleContractStatus;
269
- }({});
270
- let PrimarySaleVersion = /*#__PURE__*/function (PrimarySaleVersion) {
271
- PrimarySaleVersion["v0"] = "v0";
272
- PrimarySaleVersion["v1"] = "v1";
273
- return PrimarySaleVersion;
274
- }({});
275
- let PrimarySaleItemDetailType = /*#__PURE__*/function (PrimarySaleItemDetailType) {
276
- PrimarySaleItemDetailType["unknown"] = "unknown";
277
- PrimarySaleItemDetailType["global"] = "global";
278
- PrimarySaleItemDetailType["individual"] = "individual";
279
- return PrimarySaleItemDetailType;
280
- }({});
281
- let MetadataStatus = /*#__PURE__*/function (MetadataStatus) {
282
- MetadataStatus["NOT_AVAILABLE"] = "NOT_AVAILABLE";
283
- MetadataStatus["REFRESHING"] = "REFRESHING";
284
- MetadataStatus["AVAILABLE"] = "AVAILABLE";
285
- return MetadataStatus;
286
- }({});
287
- //
288
- // Client
289
- //
290
- class Admin {
291
- constructor(hostname, fetch) {
292
- this.hostname = void 0;
293
- this.fetch = void 0;
294
- this.path = '/rpc/Admin/';
295
- this.createCollection = (args, headers, signal) => {
296
- return this.fetch(this.url('CreateCollection'), createHTTPRequest(args, headers, signal)).then(res => {
297
- return buildResponse(res).then(_data => {
298
- return {
299
- collection: _data.collection
300
- };
301
- });
302
- }, error => {
303
- throw WebrpcRequestFailedError.new({
304
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
305
- });
306
- });
307
- };
308
- this.getCollection = (args, headers, signal) => {
309
- return this.fetch(this.url('GetCollection'), createHTTPRequest(args, headers, signal)).then(res => {
310
- return buildResponse(res).then(_data => {
311
- return {
312
- collection: _data.collection
313
- };
314
- });
315
- }, error => {
316
- throw WebrpcRequestFailedError.new({
317
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
318
- });
319
- });
320
- };
321
- this.updateCollection = (args, headers, signal) => {
322
- return this.fetch(this.url('UpdateCollection'), createHTTPRequest(args, headers, signal)).then(res => {
323
- return buildResponse(res).then(_data => {
324
- return {
325
- collection: _data.collection
326
- };
327
- });
328
- }, error => {
329
- throw WebrpcRequestFailedError.new({
330
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
331
- });
332
- });
333
- };
334
- this.listCollections = (args, headers, signal) => {
335
- return this.fetch(this.url('ListCollections'), createHTTPRequest(args, headers, signal)).then(res => {
336
- return buildResponse(res).then(_data => {
337
- return {
338
- collections: _data.collections,
339
- page: _data.page
340
- };
341
- });
342
- }, error => {
343
- throw WebrpcRequestFailedError.new({
344
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
345
- });
346
- });
347
- };
348
- this.deleteCollection = (args, headers, signal) => {
349
- return this.fetch(this.url('DeleteCollection'), createHTTPRequest(args, headers, signal)).then(res => {
350
- return buildResponse(res).then(_data => {
351
- return {
352
- collection: _data.collection
353
- };
354
- });
355
- }, error => {
356
- throw WebrpcRequestFailedError.new({
357
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
358
- });
359
- });
360
- };
361
- this.syncCollection = (args, headers, signal) => {
362
- return this.fetch(this.url('SyncCollection'), createHTTPRequest(args, headers, signal)).then(res => {
363
- return buildResponse(res).then(_data => {
364
- return {};
365
- });
366
- }, error => {
367
- throw WebrpcRequestFailedError.new({
368
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
369
- });
370
- });
371
- };
372
- this.createPrimarySaleContract = (args, headers, signal) => {
373
- return this.fetch(this.url('CreatePrimarySaleContract'), createHTTPRequest(args, headers, signal)).then(res => {
374
- return buildResponse(res).then(_data => {
375
- return {
376
- primarySaleContract: _data.primarySaleContract
377
- };
378
- });
379
- }, error => {
380
- throw WebrpcRequestFailedError.new({
381
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
382
- });
383
- });
384
- };
385
- this.deletePrimarySaleContract = (args, headers, signal) => {
386
- return this.fetch(this.url('DeletePrimarySaleContract'), createHTTPRequest(args, headers, signal)).then(res => {
387
- return buildResponse(res).then(_data => {
388
- return {};
389
- });
390
- }, error => {
391
- throw WebrpcRequestFailedError.new({
392
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
393
- });
394
- });
395
- };
396
- this.createCurrency = (args, headers, signal) => {
397
- return this.fetch(this.url('CreateCurrency'), createHTTPRequest(args, headers, signal)).then(res => {
398
- return buildResponse(res).then(_data => {
399
- return {
400
- currency: _data.currency
401
- };
402
- });
403
- }, error => {
404
- throw WebrpcRequestFailedError.new({
405
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
406
- });
407
- });
408
- };
409
- this.createCurrencies = (args, headers, signal) => {
410
- return this.fetch(this.url('CreateCurrencies'), createHTTPRequest(args, headers, signal)).then(res => {
411
- return buildResponse(res).then(_data => {
412
- return {
413
- currency: _data.currency
414
- };
415
- });
416
- }, error => {
417
- throw WebrpcRequestFailedError.new({
418
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
419
- });
420
- });
421
- };
422
- this.updateCurrency = (args, headers, signal) => {
423
- return this.fetch(this.url('UpdateCurrency'), createHTTPRequest(args, headers, signal)).then(res => {
424
- return buildResponse(res).then(_data => {
425
- return {
426
- currency: _data.currency
427
- };
428
- });
429
- }, error => {
430
- throw WebrpcRequestFailedError.new({
431
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
432
- });
433
- });
434
- };
435
- this.listCurrencies = (args, headers, signal) => {
436
- return this.fetch(this.url('ListCurrencies'), createHTTPRequest(args, headers, signal)).then(res => {
437
- return buildResponse(res).then(_data => {
438
- return {
439
- currencies: _data.currencies
440
- };
441
- });
442
- }, error => {
443
- throw WebrpcRequestFailedError.new({
444
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
445
- });
446
- });
447
- };
448
- this.deleteCurrency = (args, headers, signal) => {
449
- return this.fetch(this.url('DeleteCurrency'), createHTTPRequest(args, headers, signal)).then(res => {
450
- return buildResponse(res).then(_data => {
451
- return {
452
- currency: _data.currency
453
- };
454
- });
455
- }, error => {
456
- throw WebrpcRequestFailedError.new({
457
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
458
- });
459
- });
460
- };
461
- this.addCollectibles = (args, headers, signal) => {
462
- return this.fetch(this.url('AddCollectibles'), createHTTPRequest(args, headers, signal)).then(res => {
463
- return buildResponse(res).then(_data => {
464
- return {};
465
- });
466
- }, error => {
467
- throw WebrpcRequestFailedError.new({
468
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
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 Marketplace {
480
- constructor(hostname, fetch) {
481
- this.hostname = void 0;
482
- this.fetch = void 0;
483
- this.path = '/rpc/Marketplace/';
484
- this.listCurrencies = (args, headers, signal) => {
485
- return this.fetch(this.url('ListCurrencies'), createHTTPRequest(args, headers, signal)).then(res => {
486
- return buildResponse(res).then(_data => {
487
- return {
488
- currencies: _data.currencies
489
- };
490
- });
491
- }, error => {
492
- throw WebrpcRequestFailedError.new({
493
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
494
- });
495
- });
496
- };
497
- this.getCollectionDetail = (args, headers, signal) => {
498
- return this.fetch(this.url('GetCollectionDetail'), 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 instanceof Error ? error.message : String(error)}`
507
- });
508
- });
509
- };
510
- this.getCollectionActiveListingsCurrencies = (args, headers, signal) => {
511
- return this.fetch(this.url('GetCollectionActiveListingsCurrencies'), createHTTPRequest(args, headers, signal)).then(res => {
512
- return buildResponse(res).then(_data => {
513
- return {
514
- currencies: _data.currencies
515
- };
516
- });
517
- }, error => {
518
- throw WebrpcRequestFailedError.new({
519
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
520
- });
521
- });
522
- };
523
- this.getCollectionActiveOffersCurrencies = (args, headers, signal) => {
524
- return this.fetch(this.url('GetCollectionActiveOffersCurrencies'), createHTTPRequest(args, headers, signal)).then(res => {
525
- return buildResponse(res).then(_data => {
526
- return {
527
- currencies: _data.currencies
528
- };
529
- });
530
- }, error => {
531
- throw WebrpcRequestFailedError.new({
532
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
533
- });
534
- });
535
- };
536
- this.getCollectible = (args, headers, signal) => {
537
- return this.fetch(this.url('GetCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
538
- return buildResponse(res).then(_data => {
539
- return {
540
- metadata: _data.metadata
541
- };
542
- });
543
- }, error => {
544
- throw WebrpcRequestFailedError.new({
545
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
546
- });
547
- });
548
- };
549
- this.getLowestPriceOfferForCollectible = (args, headers, signal) => {
550
- return this.fetch(this.url('GetLowestPriceOfferForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
551
- return buildResponse(res).then(_data => {
552
- return {
553
- order: _data.order
554
- };
555
- });
556
- }, error => {
557
- throw WebrpcRequestFailedError.new({
558
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
559
- });
560
- });
561
- };
562
- this.getHighestPriceOfferForCollectible = (args, headers, signal) => {
563
- return this.fetch(this.url('GetHighestPriceOfferForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
564
- return buildResponse(res).then(_data => {
565
- return {
566
- order: _data.order
567
- };
568
- });
569
- }, error => {
570
- throw WebrpcRequestFailedError.new({
571
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
572
- });
573
- });
574
- };
575
- this.getLowestPriceListingForCollectible = (args, headers, signal) => {
576
- return this.fetch(this.url('GetLowestPriceListingForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
577
- return buildResponse(res).then(_data => {
578
- return {
579
- order: _data.order
580
- };
581
- });
582
- }, error => {
583
- throw WebrpcRequestFailedError.new({
584
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
585
- });
586
- });
587
- };
588
- this.getHighestPriceListingForCollectible = (args, headers, signal) => {
589
- return this.fetch(this.url('GetHighestPriceListingForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
590
- return buildResponse(res).then(_data => {
591
- return {
592
- order: _data.order
593
- };
594
- });
595
- }, error => {
596
- throw WebrpcRequestFailedError.new({
597
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
598
- });
599
- });
600
- };
601
- this.listListingsForCollectible = (args, headers, signal) => {
602
- return this.fetch(this.url('ListListingsForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
603
- return buildResponse(res).then(_data => {
604
- return {
605
- listings: _data.listings,
606
- page: _data.page
607
- };
608
- });
609
- }, error => {
610
- throw WebrpcRequestFailedError.new({
611
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
612
- });
613
- });
614
- };
615
- this.listOffersForCollectible = (args, headers, signal) => {
616
- return this.fetch(this.url('ListOffersForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
617
- return buildResponse(res).then(_data => {
618
- return {
619
- offers: _data.offers,
620
- page: _data.page
621
- };
622
- });
623
- }, error => {
624
- throw WebrpcRequestFailedError.new({
625
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
626
- });
627
- });
628
- };
629
- this.listOrdersWithCollectibles = (args, headers, signal) => {
630
- return this.fetch(this.url('ListOrdersWithCollectibles'), createHTTPRequest(args, headers, signal)).then(res => {
631
- return buildResponse(res).then(_data => {
632
- return {
633
- collectibles: _data.collectibles,
634
- page: _data.page
635
- };
636
- });
637
- }, error => {
638
- throw WebrpcRequestFailedError.new({
639
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
640
- });
641
- });
642
- };
643
- this.getCountOfAllOrders = (args, headers, signal) => {
644
- return this.fetch(this.url('GetCountOfAllOrders'), createHTTPRequest(args, headers, signal)).then(res => {
645
- return buildResponse(res).then(_data => {
646
- return {
647
- count: _data.count
648
- };
649
- });
650
- }, error => {
651
- throw WebrpcRequestFailedError.new({
652
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
653
- });
654
- });
655
- };
656
- this.getCountOfFilteredOrders = (args, headers, signal) => {
657
- return this.fetch(this.url('GetCountOfFilteredOrders'), createHTTPRequest(args, headers, signal)).then(res => {
658
- return buildResponse(res).then(_data => {
659
- return {
660
- count: _data.count
661
- };
662
- });
663
- }, error => {
664
- throw WebrpcRequestFailedError.new({
665
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
666
- });
667
- });
668
- };
669
- this.listListings = (args, headers, signal) => {
670
- return this.fetch(this.url('ListListings'), createHTTPRequest(args, headers, signal)).then(res => {
671
- return buildResponse(res).then(_data => {
672
- return {
673
- listings: _data.listings,
674
- page: _data.page
675
- };
676
- });
677
- }, error => {
678
- throw WebrpcRequestFailedError.new({
679
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
680
- });
681
- });
682
- };
683
- this.listOffers = (args, headers, signal) => {
684
- return this.fetch(this.url('ListOffers'), createHTTPRequest(args, headers, signal)).then(res => {
685
- return buildResponse(res).then(_data => {
686
- return {
687
- offers: _data.offers,
688
- page: _data.page
689
- };
690
- });
691
- }, error => {
692
- throw WebrpcRequestFailedError.new({
693
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
694
- });
695
- });
696
- };
697
- this.getCountOfListingsForCollectible = (args, headers, signal) => {
698
- return this.fetch(this.url('GetCountOfListingsForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
699
- return buildResponse(res).then(_data => {
700
- return {
701
- count: _data.count
702
- };
703
- });
704
- }, error => {
705
- throw WebrpcRequestFailedError.new({
706
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
707
- });
708
- });
709
- };
710
- this.getCountOfOffersForCollectible = (args, headers, signal) => {
711
- return this.fetch(this.url('GetCountOfOffersForCollectible'), createHTTPRequest(args, headers, signal)).then(res => {
712
- return buildResponse(res).then(_data => {
713
- return {
714
- count: _data.count
715
- };
716
- });
717
- }, error => {
718
- throw WebrpcRequestFailedError.new({
719
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
720
- });
721
- });
722
- };
723
- this.getCollectibleLowestOffer = (args, headers, signal) => {
724
- return this.fetch(this.url('GetCollectibleLowestOffer'), createHTTPRequest(args, headers, signal)).then(res => {
725
- return buildResponse(res).then(_data => {
726
- return {
727
- order: _data.order
728
- };
729
- });
730
- }, error => {
731
- throw WebrpcRequestFailedError.new({
732
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
733
- });
734
- });
735
- };
736
- this.getCollectibleHighestOffer = (args, headers, signal) => {
737
- return this.fetch(this.url('GetCollectibleHighestOffer'), createHTTPRequest(args, headers, signal)).then(res => {
738
- return buildResponse(res).then(_data => {
739
- return {
740
- order: _data.order
741
- };
742
- });
743
- }, error => {
744
- throw WebrpcRequestFailedError.new({
745
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
746
- });
747
- });
748
- };
749
- this.getCollectibleLowestListing = (args, headers, signal) => {
750
- return this.fetch(this.url('GetCollectibleLowestListing'), createHTTPRequest(args, headers, signal)).then(res => {
751
- return buildResponse(res).then(_data => {
752
- return {
753
- order: _data.order
754
- };
755
- });
756
- }, error => {
757
- throw WebrpcRequestFailedError.new({
758
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
759
- });
760
- });
761
- };
762
- this.getCollectibleHighestListing = (args, headers, signal) => {
763
- return this.fetch(this.url('GetCollectibleHighestListing'), createHTTPRequest(args, headers, signal)).then(res => {
764
- return buildResponse(res).then(_data => {
765
- return {
766
- order: _data.order
767
- };
768
- });
769
- }, error => {
770
- throw WebrpcRequestFailedError.new({
771
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
772
- });
773
- });
774
- };
775
- this.listCollectibleListings = (args, headers, signal) => {
776
- return this.fetch(this.url('ListCollectibleListings'), createHTTPRequest(args, headers, signal)).then(res => {
777
- return buildResponse(res).then(_data => {
778
- return {
779
- listings: _data.listings,
780
- page: _data.page
781
- };
782
- });
783
- }, error => {
784
- throw WebrpcRequestFailedError.new({
785
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
786
- });
787
- });
788
- };
789
- this.listCollectibleOffers = (args, headers, signal) => {
790
- return this.fetch(this.url('ListCollectibleOffers'), createHTTPRequest(args, headers, signal)).then(res => {
791
- return buildResponse(res).then(_data => {
792
- return {
793
- offers: _data.offers,
794
- page: _data.page
795
- };
796
- });
797
- }, error => {
798
- throw WebrpcRequestFailedError.new({
799
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
800
- });
801
- });
802
- };
803
- this.generateBuyTransaction = (args, headers, signal) => {
804
- return this.fetch(this.url('GenerateBuyTransaction'), createHTTPRequest(args, headers, signal)).then(res => {
805
- return buildResponse(res).then(_data => {
806
- return {
807
- resp: _data.resp,
808
- steps: _data.steps
809
- };
810
- });
811
- }, error => {
812
- throw WebrpcRequestFailedError.new({
813
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
814
- });
815
- });
816
- };
817
- this.generateSellTransaction = (args, headers, signal) => {
818
- return this.fetch(this.url('GenerateSellTransaction'), createHTTPRequest(args, headers, signal)).then(res => {
819
- return buildResponse(res).then(_data => {
820
- return {
821
- resp: _data.resp,
822
- steps: _data.steps
823
- };
824
- });
825
- }, error => {
826
- throw WebrpcRequestFailedError.new({
827
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
828
- });
829
- });
830
- };
831
- this.generateListingTransaction = (args, headers, signal) => {
832
- return this.fetch(this.url('GenerateListingTransaction'), createHTTPRequest(args, headers, signal)).then(res => {
833
- return buildResponse(res).then(_data => {
834
- return {
835
- steps: _data.steps
836
- };
837
- });
838
- }, error => {
839
- throw WebrpcRequestFailedError.new({
840
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
841
- });
842
- });
843
- };
844
- this.generateOfferTransaction = (args, headers, signal) => {
845
- return this.fetch(this.url('GenerateOfferTransaction'), createHTTPRequest(args, headers, signal)).then(res => {
846
- return buildResponse(res).then(_data => {
847
- return {
848
- steps: _data.steps
849
- };
850
- });
851
- }, error => {
852
- throw WebrpcRequestFailedError.new({
853
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
854
- });
855
- });
856
- };
857
- this.generateCancelTransaction = (args, headers, signal) => {
858
- return this.fetch(this.url('GenerateCancelTransaction'), createHTTPRequest(args, headers, signal)).then(res => {
859
- return buildResponse(res).then(_data => {
860
- return {
861
- steps: _data.steps
862
- };
863
- });
864
- }, error => {
865
- throw WebrpcRequestFailedError.new({
866
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
867
- });
868
- });
869
- };
870
- this.execute = (args, headers, signal) => {
871
- return this.fetch(this.url('Execute'), createHTTPRequest(args, headers, signal)).then(res => {
872
- return buildResponse(res).then(_data => {
873
- return {
874
- orderId: _data.orderId
875
- };
876
- });
877
- }, error => {
878
- throw WebrpcRequestFailedError.new({
879
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
880
- });
881
- });
882
- };
883
- this.listCollectibles = (args, headers, signal) => {
884
- return this.fetch(this.url('ListCollectibles'), createHTTPRequest(args, headers, signal)).then(res => {
885
- return buildResponse(res).then(_data => {
886
- return {
887
- collectibles: _data.collectibles,
888
- page: _data.page
889
- };
890
- });
891
- }, error => {
892
- throw WebrpcRequestFailedError.new({
893
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
894
- });
895
- });
896
- };
897
- this.getCountOfAllCollectibles = (args, headers, signal) => {
898
- return this.fetch(this.url('GetCountOfAllCollectibles'), createHTTPRequest(args, headers, signal)).then(res => {
899
- return buildResponse(res).then(_data => {
900
- return {
901
- count: _data.count
902
- };
903
- });
904
- }, error => {
905
- throw WebrpcRequestFailedError.new({
906
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
907
- });
908
- });
909
- };
910
- this.getCountOfFilteredCollectibles = (args, headers, signal) => {
911
- return this.fetch(this.url('GetCountOfFilteredCollectibles'), createHTTPRequest(args, headers, signal)).then(res => {
912
- return buildResponse(res).then(_data => {
913
- return {
914
- count: _data.count
915
- };
916
- });
917
- }, error => {
918
- throw WebrpcRequestFailedError.new({
919
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
920
- });
921
- });
922
- };
923
- this.getFloorOrder = (args, headers, signal) => {
924
- return this.fetch(this.url('GetFloorOrder'), createHTTPRequest(args, headers, signal)).then(res => {
925
- return buildResponse(res).then(_data => {
926
- return {
927
- collectible: _data.collectible
928
- };
929
- });
930
- }, error => {
931
- throw WebrpcRequestFailedError.new({
932
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
933
- });
934
- });
935
- };
936
- this.listCollectiblesWithLowestListing = (args, headers, signal) => {
937
- return this.fetch(this.url('ListCollectiblesWithLowestListing'), createHTTPRequest(args, headers, signal)).then(res => {
938
- return buildResponse(res).then(_data => {
939
- return {
940
- collectibles: _data.collectibles,
941
- page: _data.page
942
- };
943
- });
944
- }, error => {
945
- throw WebrpcRequestFailedError.new({
946
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
947
- });
948
- });
949
- };
950
- this.listCollectiblesWithHighestOffer = (args, headers, signal) => {
951
- return this.fetch(this.url('ListCollectiblesWithHighestOffer'), createHTTPRequest(args, headers, signal)).then(res => {
952
- return buildResponse(res).then(_data => {
953
- return {
954
- collectibles: _data.collectibles,
955
- page: _data.page
956
- };
957
- });
958
- }, error => {
959
- throw WebrpcRequestFailedError.new({
960
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
961
- });
962
- });
963
- };
964
- this.syncOrder = (args, headers, signal) => {
965
- return this.fetch(this.url('SyncOrder'), createHTTPRequest(args, headers, signal)).then(res => {
966
- return buildResponse(res).then(_data => {
967
- return {};
968
- });
969
- }, error => {
970
- throw WebrpcRequestFailedError.new({
971
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
972
- });
973
- });
974
- };
975
- this.syncOrders = (args, headers, signal) => {
976
- return this.fetch(this.url('SyncOrders'), createHTTPRequest(args, headers, signal)).then(res => {
977
- return buildResponse(res).then(_data => {
978
- return {};
979
- });
980
- }, error => {
981
- throw WebrpcRequestFailedError.new({
982
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
983
- });
984
- });
985
- };
986
- this.getOrders = (args, headers, signal) => {
987
- return this.fetch(this.url('GetOrders'), createHTTPRequest(args, headers, signal)).then(res => {
988
- return buildResponse(res).then(_data => {
989
- return {
990
- orders: _data.orders,
991
- page: _data.page
992
- };
993
- });
994
- }, error => {
995
- throw WebrpcRequestFailedError.new({
996
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
997
- });
998
- });
999
- };
1000
- this.checkoutOptionsMarketplace = (args, headers, signal) => {
1001
- return this.fetch(this.url('CheckoutOptionsMarketplace'), createHTTPRequest(args, headers, signal)).then(res => {
1002
- return buildResponse(res).then(_data => {
1003
- return {
1004
- options: _data.options
1005
- };
1006
- });
1007
- }, error => {
1008
- throw WebrpcRequestFailedError.new({
1009
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
1010
- });
1011
- });
1012
- };
1013
- this.checkoutOptionsSalesContract = (args, headers, signal) => {
1014
- return this.fetch(this.url('CheckoutOptionsSalesContract'), createHTTPRequest(args, headers, signal)).then(res => {
1015
- return buildResponse(res).then(_data => {
1016
- return {
1017
- options: _data.options
1018
- };
1019
- });
1020
- }, error => {
1021
- throw WebrpcRequestFailedError.new({
1022
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
1023
- });
1024
- });
1025
- };
1026
- this.supportedMarketplaces = (args, headers, signal) => {
1027
- return this.fetch(this.url('SupportedMarketplaces'), createHTTPRequest(args, headers, signal)).then(res => {
1028
- return buildResponse(res).then(_data => {
1029
- return {
1030
- marketplaces: _data.marketplaces
1031
- };
1032
- });
1033
- }, error => {
1034
- throw WebrpcRequestFailedError.new({
1035
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
1036
- });
1037
- });
1038
- };
1039
- this.getPrimarySaleItem = (args, headers, signal) => {
1040
- return this.fetch(this.url('GetPrimarySaleItem'), createHTTPRequest(args, headers, signal)).then(res => {
1041
- return buildResponse(res).then(_data => {
1042
- return {
1043
- item: _data.item
1044
- };
1045
- });
1046
- }, error => {
1047
- throw WebrpcRequestFailedError.new({
1048
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
1049
- });
1050
- });
1051
- };
1052
- this.listPrimarySaleItems = (args, headers, signal) => {
1053
- return this.fetch(this.url('ListPrimarySaleItems'), createHTTPRequest(args, headers, signal)).then(res => {
1054
- return buildResponse(res).then(_data => {
1055
- return {
1056
- primarySaleItems: _data.primarySaleItems,
1057
- page: _data.page
1058
- };
1059
- });
1060
- }, error => {
1061
- throw WebrpcRequestFailedError.new({
1062
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
1063
- });
1064
- });
1065
- };
1066
- this.getCountOfPrimarySaleItems = (args, headers, signal) => {
1067
- return this.fetch(this.url('GetCountOfPrimarySaleItems'), createHTTPRequest(args, headers, signal)).then(res => {
1068
- return buildResponse(res).then(_data => {
1069
- return {
1070
- count: _data.count
1071
- };
1072
- });
1073
- }, error => {
1074
- throw WebrpcRequestFailedError.new({
1075
- cause: `fetch(): ${error instanceof Error ? error.message : String(error)}`
1076
- });
1077
- });
1078
- };
1079
- this.hostname = hostname.replace(/\/*$/, '');
1080
- this.fetch = (input, init) => fetch(input, init);
1081
- }
1082
- url(name) {
1083
- return this.hostname + this.path + name;
1084
- }
1085
- }
1086
- const createHTTPRequest = (body = {}, headers = {}, signal = null) => {
1087
- const reqHeaders = _extends({}, headers, {
1088
- 'Content-Type': 'application/json'
1089
- });
1090
- reqHeaders[WebrpcHeader] = WebrpcHeaderValue;
1091
- return {
1092
- method: 'POST',
1093
- headers: reqHeaders,
1094
- body: JSON.stringify(body || {}),
1095
- signal
1096
- };
1097
- };
1098
- const buildResponse = res => {
1099
- return res.text().then(text => {
1100
- let data;
1101
- try {
1102
- data = JSON.parse(text);
1103
- } catch (error) {
1104
- throw WebrpcBadResponseError.new({
1105
- status: res.status,
1106
- cause: `JSON.parse(): ${error instanceof Error ? error.message : String(error)}: response text: ${text}`
1107
- });
1108
- }
1109
- if (!res.ok) {
1110
- const code = typeof data.code === 'number' ? data.code : 0;
1111
- throw (webrpcErrorByCode[code] || WebrpcError).new(data);
1112
- }
1113
- return data;
1114
- });
1115
- };
1116
-
1117
- //
1118
- // Errors
1119
- //
1120
-
1121
- class WebrpcError extends Error {
1122
- constructor(name, code, message, status, cause) {
1123
- super(message);
1124
- this.name = void 0;
1125
- this.code = void 0;
1126
- this.message = void 0;
1127
- this.status = void 0;
1128
- this.cause = void 0;
1129
- /** @deprecated Use message instead of msg. Deprecated in webrpc v0.11.0. */
1130
- this.msg = void 0;
1131
- this.name = name || 'WebrpcError';
1132
- this.code = typeof code === 'number' ? code : 0;
1133
- this.message = message || `endpoint error ${this.code}`;
1134
- this.msg = this.message;
1135
- this.status = typeof status === 'number' ? status : 0;
1136
- this.cause = cause;
1137
- Object.setPrototypeOf(this, WebrpcError.prototype);
1138
- }
1139
- static new(payload) {
1140
- return new this(payload.error, payload.code, payload.message || payload.msg, payload.status, payload.cause);
1141
- }
1142
- }
1143
-
1144
- // Webrpc errors
1145
-
1146
- class WebrpcEndpointError extends WebrpcError {
1147
- constructor(name = 'WebrpcEndpoint', code = 0, message = `endpoint error`, status = 400, cause) {
1148
- super(name, code, message, status, cause);
1149
- Object.setPrototypeOf(this, WebrpcEndpointError.prototype);
1150
- }
1151
- }
1152
- class WebrpcRequestFailedError extends WebrpcError {
1153
- constructor(name = 'WebrpcRequestFailed', code = -1, message = `request failed`, status = 400, cause) {
1154
- super(name, code, message, status, cause);
1155
- Object.setPrototypeOf(this, WebrpcRequestFailedError.prototype);
1156
- }
1157
- }
1158
- class WebrpcBadRouteError extends WebrpcError {
1159
- constructor(name = 'WebrpcBadRoute', code = -2, message = `bad route`, status = 404, cause) {
1160
- super(name, code, message, status, cause);
1161
- Object.setPrototypeOf(this, WebrpcBadRouteError.prototype);
1162
- }
1163
- }
1164
- class WebrpcBadMethodError extends WebrpcError {
1165
- constructor(name = 'WebrpcBadMethod', code = -3, message = `bad method`, status = 405, cause) {
1166
- super(name, code, message, status, cause);
1167
- Object.setPrototypeOf(this, WebrpcBadMethodError.prototype);
1168
- }
1169
- }
1170
- class WebrpcBadRequestError extends WebrpcError {
1171
- constructor(name = 'WebrpcBadRequest', code = -4, message = `bad request`, status = 400, cause) {
1172
- super(name, code, message, status, cause);
1173
- Object.setPrototypeOf(this, WebrpcBadRequestError.prototype);
1174
- }
1175
- }
1176
- class WebrpcBadResponseError extends WebrpcError {
1177
- constructor(name = 'WebrpcBadResponse', code = -5, message = `bad response`, status = 500, cause) {
1178
- super(name, code, message, status, cause);
1179
- Object.setPrototypeOf(this, WebrpcBadResponseError.prototype);
1180
- }
1181
- }
1182
- class WebrpcServerPanicError extends WebrpcError {
1183
- constructor(name = 'WebrpcServerPanic', code = -6, message = `server panic`, status = 500, cause) {
1184
- super(name, code, message, status, cause);
1185
- Object.setPrototypeOf(this, WebrpcServerPanicError.prototype);
1186
- }
1187
- }
1188
- class WebrpcInternalErrorError extends WebrpcError {
1189
- constructor(name = 'WebrpcInternalError', code = -7, message = `internal error`, status = 500, cause) {
1190
- super(name, code, message, status, cause);
1191
- Object.setPrototypeOf(this, WebrpcInternalErrorError.prototype);
1192
- }
1193
- }
1194
- class WebrpcClientAbortedError extends WebrpcError {
1195
- constructor(name = 'WebrpcClientAborted', code = -8, message = `request aborted by client`, status = 400, cause) {
1196
- super(name, code, message, status, cause);
1197
- Object.setPrototypeOf(this, WebrpcClientAbortedError.prototype);
1198
- }
1199
- }
1200
- class WebrpcStreamLostError extends WebrpcError {
1201
- constructor(name = 'WebrpcStreamLost', code = -9, message = `stream lost`, status = 400, cause) {
1202
- super(name, code, message, status, cause);
1203
- Object.setPrototypeOf(this, WebrpcStreamLostError.prototype);
1204
- }
1205
- }
1206
- class WebrpcStreamFinishedError extends WebrpcError {
1207
- constructor(name = 'WebrpcStreamFinished', code = -10, message = `stream finished`, status = 200, cause) {
1208
- super(name, code, message, status, cause);
1209
- Object.setPrototypeOf(this, WebrpcStreamFinishedError.prototype);
1210
- }
1211
- }
1212
-
1213
- // Schema errors
1214
-
1215
- class UnauthorizedError extends WebrpcError {
1216
- constructor(name = 'Unauthorized', code = 1000, message = `Unauthorized access`, status = 401, cause) {
1217
- super(name, code, message, status, cause);
1218
- Object.setPrototypeOf(this, UnauthorizedError.prototype);
1219
- }
1220
- }
1221
- class PermissionDeniedError extends WebrpcError {
1222
- constructor(name = 'PermissionDenied', code = 1001, message = `Permission denied`, status = 403, cause) {
1223
- super(name, code, message, status, cause);
1224
- Object.setPrototypeOf(this, PermissionDeniedError.prototype);
1225
- }
1226
- }
1227
- class SessionExpiredError extends WebrpcError {
1228
- constructor(name = 'SessionExpired', code = 1002, message = `Session expired`, status = 403, cause) {
1229
- super(name, code, message, status, cause);
1230
- Object.setPrototypeOf(this, SessionExpiredError.prototype);
1231
- }
1232
- }
1233
- class MethodNotFoundError extends WebrpcError {
1234
- constructor(name = 'MethodNotFound', code = 1003, message = `Method not found`, status = 404, cause) {
1235
- super(name, code, message, status, cause);
1236
- Object.setPrototypeOf(this, MethodNotFoundError.prototype);
1237
- }
1238
- }
1239
- class RequestConflictError extends WebrpcError {
1240
- constructor(name = 'RequestConflict', code = 1004, message = `Conflict with target resource`, status = 409, cause) {
1241
- super(name, code, message, status, cause);
1242
- Object.setPrototypeOf(this, RequestConflictError.prototype);
1243
- }
1244
- }
1245
- class AbortedError extends WebrpcError {
1246
- constructor(name = 'Aborted', code = 1005, message = `Request aborted`, status = 400, cause) {
1247
- super(name, code, message, status, cause);
1248
- Object.setPrototypeOf(this, AbortedError.prototype);
1249
- }
1250
- }
1251
- class GeoblockedError extends WebrpcError {
1252
- constructor(name = 'Geoblocked', code = 1006, message = `Geoblocked region`, status = 451, cause) {
1253
- super(name, code, message, status, cause);
1254
- Object.setPrototypeOf(this, GeoblockedError.prototype);
1255
- }
1256
- }
1257
- class RateLimitedError extends WebrpcError {
1258
- constructor(name = 'RateLimited', code = 1007, message = `Rate-limited. Please slow down.`, status = 429, cause) {
1259
- super(name, code, message, status, cause);
1260
- Object.setPrototypeOf(this, RateLimitedError.prototype);
1261
- }
1262
- }
1263
- class ProjectNotFoundError extends WebrpcError {
1264
- constructor(name = 'ProjectNotFound', code = 1008, message = `Project not found`, status = 401, cause) {
1265
- super(name, code, message, status, cause);
1266
- Object.setPrototypeOf(this, ProjectNotFoundError.prototype);
1267
- }
1268
- }
1269
- class SecretKeyCorsDisallowedError extends WebrpcError {
1270
- constructor(name = 'SecretKeyCorsDisallowed', code = 1009, message = `CORS disallowed. Admin API Secret Key can't be used from a web app.`, status = 403, cause) {
1271
- super(name, code, message, status, cause);
1272
- Object.setPrototypeOf(this, SecretKeyCorsDisallowedError.prototype);
1273
- }
1274
- }
1275
- class AccessKeyNotFoundError extends WebrpcError {
1276
- constructor(name = 'AccessKeyNotFound', code = 1101, message = `Access key not found`, status = 401, cause) {
1277
- super(name, code, message, status, cause);
1278
- Object.setPrototypeOf(this, AccessKeyNotFoundError.prototype);
1279
- }
1280
- }
1281
- class AccessKeyMismatchError extends WebrpcError {
1282
- constructor(name = 'AccessKeyMismatch', code = 1102, message = `Access key mismatch`, status = 403, cause) {
1283
- super(name, code, message, status, cause);
1284
- Object.setPrototypeOf(this, AccessKeyMismatchError.prototype);
1285
- }
1286
- }
1287
- class InvalidOriginError extends WebrpcError {
1288
- constructor(name = 'InvalidOrigin', code = 1103, message = `Invalid origin for Access Key`, status = 403, cause) {
1289
- super(name, code, message, status, cause);
1290
- Object.setPrototypeOf(this, InvalidOriginError.prototype);
1291
- }
1292
- }
1293
- class InvalidServiceError extends WebrpcError {
1294
- constructor(name = 'InvalidService', code = 1104, message = `Service not enabled for Access key`, status = 403, cause) {
1295
- super(name, code, message, status, cause);
1296
- Object.setPrototypeOf(this, InvalidServiceError.prototype);
1297
- }
1298
- }
1299
- class UnauthorizedUserError extends WebrpcError {
1300
- constructor(name = 'UnauthorizedUser', code = 1105, message = `Unauthorized user`, status = 403, cause) {
1301
- super(name, code, message, status, cause);
1302
- Object.setPrototypeOf(this, UnauthorizedUserError.prototype);
1303
- }
1304
- }
1305
- class InvalidChainError extends WebrpcError {
1306
- constructor(name = 'InvalidChain', code = 1106, message = `Network not enabled for Access key`, status = 403, cause) {
1307
- super(name, code, message, status, cause);
1308
- Object.setPrototypeOf(this, InvalidChainError.prototype);
1309
- }
1310
- }
1311
- class QuotaExceededError extends WebrpcError {
1312
- constructor(name = 'QuotaExceeded', code = 1200, message = `Quota request exceeded`, status = 429, cause) {
1313
- super(name, code, message, status, cause);
1314
- Object.setPrototypeOf(this, QuotaExceededError.prototype);
1315
- }
1316
- }
1317
- class QuotaRateLimitError extends WebrpcError {
1318
- constructor(name = 'QuotaRateLimit', code = 1201, message = `Quota rate limit exceeded`, status = 429, cause) {
1319
- super(name, code, message, status, cause);
1320
- Object.setPrototypeOf(this, QuotaRateLimitError.prototype);
1321
- }
1322
- }
1323
- class NoDefaultKeyError extends WebrpcError {
1324
- constructor(name = 'NoDefaultKey', code = 1300, message = `No default access key found`, status = 403, cause) {
1325
- super(name, code, message, status, cause);
1326
- Object.setPrototypeOf(this, NoDefaultKeyError.prototype);
1327
- }
1328
- }
1329
- class MaxAccessKeysError extends WebrpcError {
1330
- constructor(name = 'MaxAccessKeys', code = 1301, message = `Access keys limit reached`, status = 403, cause) {
1331
- super(name, code, message, status, cause);
1332
- Object.setPrototypeOf(this, MaxAccessKeysError.prototype);
1333
- }
1334
- }
1335
- class AtLeastOneKeyError extends WebrpcError {
1336
- constructor(name = 'AtLeastOneKey', code = 1302, message = `You need at least one Access Key`, status = 403, cause) {
1337
- super(name, code, message, status, cause);
1338
- Object.setPrototypeOf(this, AtLeastOneKeyError.prototype);
1339
- }
1340
- }
1341
- class TimeoutError extends WebrpcError {
1342
- constructor(name = 'Timeout', code = 1900, message = `Request timed out`, status = 408, cause) {
1343
- super(name, code, message, status, cause);
1344
- Object.setPrototypeOf(this, TimeoutError.prototype);
1345
- }
1346
- }
1347
- class NotFoundError extends WebrpcError {
1348
- constructor(name = 'NotFound', code = 2000, message = `Resource not found`, status = 400, cause) {
1349
- super(name, code, message, status, cause);
1350
- Object.setPrototypeOf(this, NotFoundError.prototype);
1351
- }
1352
- }
1353
- class InvalidArgumentError extends WebrpcError {
1354
- constructor(name = 'InvalidArgument', code = 2001, message = `Invalid argument`, status = 400, cause) {
1355
- super(name, code, message, status, cause);
1356
- Object.setPrototypeOf(this, InvalidArgumentError.prototype);
1357
- }
1358
- }
1359
- class NotImplementedError extends WebrpcError {
1360
- constructor(name = 'NotImplemented', code = 9999, message = `Not Implemented`, status = 500, cause) {
1361
- super(name, code, message, status, cause);
1362
- Object.setPrototypeOf(this, NotImplementedError.prototype);
1363
- }
1364
- }
1365
- let errors = /*#__PURE__*/function (errors) {
1366
- errors["WebrpcEndpoint"] = "WebrpcEndpoint";
1367
- errors["WebrpcRequestFailed"] = "WebrpcRequestFailed";
1368
- errors["WebrpcBadRoute"] = "WebrpcBadRoute";
1369
- errors["WebrpcBadMethod"] = "WebrpcBadMethod";
1370
- errors["WebrpcBadRequest"] = "WebrpcBadRequest";
1371
- errors["WebrpcBadResponse"] = "WebrpcBadResponse";
1372
- errors["WebrpcServerPanic"] = "WebrpcServerPanic";
1373
- errors["WebrpcInternalError"] = "WebrpcInternalError";
1374
- errors["WebrpcClientAborted"] = "WebrpcClientAborted";
1375
- errors["WebrpcStreamLost"] = "WebrpcStreamLost";
1376
- errors["WebrpcStreamFinished"] = "WebrpcStreamFinished";
1377
- errors["Unauthorized"] = "Unauthorized";
1378
- errors["PermissionDenied"] = "PermissionDenied";
1379
- errors["SessionExpired"] = "SessionExpired";
1380
- errors["MethodNotFound"] = "MethodNotFound";
1381
- errors["RequestConflict"] = "RequestConflict";
1382
- errors["Aborted"] = "Aborted";
1383
- errors["Geoblocked"] = "Geoblocked";
1384
- errors["RateLimited"] = "RateLimited";
1385
- errors["ProjectNotFound"] = "ProjectNotFound";
1386
- errors["SecretKeyCorsDisallowed"] = "SecretKeyCorsDisallowed";
1387
- errors["AccessKeyNotFound"] = "AccessKeyNotFound";
1388
- errors["AccessKeyMismatch"] = "AccessKeyMismatch";
1389
- errors["InvalidOrigin"] = "InvalidOrigin";
1390
- errors["InvalidService"] = "InvalidService";
1391
- errors["UnauthorizedUser"] = "UnauthorizedUser";
1392
- errors["InvalidChain"] = "InvalidChain";
1393
- errors["QuotaExceeded"] = "QuotaExceeded";
1394
- errors["QuotaRateLimit"] = "QuotaRateLimit";
1395
- errors["NoDefaultKey"] = "NoDefaultKey";
1396
- errors["MaxAccessKeys"] = "MaxAccessKeys";
1397
- errors["AtLeastOneKey"] = "AtLeastOneKey";
1398
- errors["Timeout"] = "Timeout";
1399
- errors["NotFound"] = "NotFound";
1400
- errors["InvalidArgument"] = "InvalidArgument";
1401
- errors["NotImplemented"] = "NotImplemented";
1402
- return errors;
1403
- }({});
1404
- let WebrpcErrorCodes = /*#__PURE__*/function (WebrpcErrorCodes) {
1405
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcEndpoint"] = 0] = "WebrpcEndpoint";
1406
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcRequestFailed"] = -1] = "WebrpcRequestFailed";
1407
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRoute"] = -2] = "WebrpcBadRoute";
1408
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadMethod"] = -3] = "WebrpcBadMethod";
1409
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadRequest"] = -4] = "WebrpcBadRequest";
1410
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcBadResponse"] = -5] = "WebrpcBadResponse";
1411
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcServerPanic"] = -6] = "WebrpcServerPanic";
1412
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcInternalError"] = -7] = "WebrpcInternalError";
1413
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcClientAborted"] = -8] = "WebrpcClientAborted";
1414
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamLost"] = -9] = "WebrpcStreamLost";
1415
- WebrpcErrorCodes[WebrpcErrorCodes["WebrpcStreamFinished"] = -10] = "WebrpcStreamFinished";
1416
- WebrpcErrorCodes[WebrpcErrorCodes["Unauthorized"] = 1000] = "Unauthorized";
1417
- WebrpcErrorCodes[WebrpcErrorCodes["PermissionDenied"] = 1001] = "PermissionDenied";
1418
- WebrpcErrorCodes[WebrpcErrorCodes["SessionExpired"] = 1002] = "SessionExpired";
1419
- WebrpcErrorCodes[WebrpcErrorCodes["MethodNotFound"] = 1003] = "MethodNotFound";
1420
- WebrpcErrorCodes[WebrpcErrorCodes["RequestConflict"] = 1004] = "RequestConflict";
1421
- WebrpcErrorCodes[WebrpcErrorCodes["Aborted"] = 1005] = "Aborted";
1422
- WebrpcErrorCodes[WebrpcErrorCodes["Geoblocked"] = 1006] = "Geoblocked";
1423
- WebrpcErrorCodes[WebrpcErrorCodes["RateLimited"] = 1007] = "RateLimited";
1424
- WebrpcErrorCodes[WebrpcErrorCodes["ProjectNotFound"] = 1008] = "ProjectNotFound";
1425
- WebrpcErrorCodes[WebrpcErrorCodes["SecretKeyCorsDisallowed"] = 1009] = "SecretKeyCorsDisallowed";
1426
- WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyNotFound"] = 1101] = "AccessKeyNotFound";
1427
- WebrpcErrorCodes[WebrpcErrorCodes["AccessKeyMismatch"] = 1102] = "AccessKeyMismatch";
1428
- WebrpcErrorCodes[WebrpcErrorCodes["InvalidOrigin"] = 1103] = "InvalidOrigin";
1429
- WebrpcErrorCodes[WebrpcErrorCodes["InvalidService"] = 1104] = "InvalidService";
1430
- WebrpcErrorCodes[WebrpcErrorCodes["UnauthorizedUser"] = 1105] = "UnauthorizedUser";
1431
- WebrpcErrorCodes[WebrpcErrorCodes["InvalidChain"] = 1106] = "InvalidChain";
1432
- WebrpcErrorCodes[WebrpcErrorCodes["QuotaExceeded"] = 1200] = "QuotaExceeded";
1433
- WebrpcErrorCodes[WebrpcErrorCodes["QuotaRateLimit"] = 1201] = "QuotaRateLimit";
1434
- WebrpcErrorCodes[WebrpcErrorCodes["NoDefaultKey"] = 1300] = "NoDefaultKey";
1435
- WebrpcErrorCodes[WebrpcErrorCodes["MaxAccessKeys"] = 1301] = "MaxAccessKeys";
1436
- WebrpcErrorCodes[WebrpcErrorCodes["AtLeastOneKey"] = 1302] = "AtLeastOneKey";
1437
- WebrpcErrorCodes[WebrpcErrorCodes["Timeout"] = 1900] = "Timeout";
1438
- WebrpcErrorCodes[WebrpcErrorCodes["NotFound"] = 2000] = "NotFound";
1439
- WebrpcErrorCodes[WebrpcErrorCodes["InvalidArgument"] = 2001] = "InvalidArgument";
1440
- WebrpcErrorCodes[WebrpcErrorCodes["NotImplemented"] = 9999] = "NotImplemented";
1441
- return WebrpcErrorCodes;
1442
- }({});
1443
- const webrpcErrorByCode = {
1444
- [0]: WebrpcEndpointError,
1445
- [-1]: WebrpcRequestFailedError,
1446
- [-2]: WebrpcBadRouteError,
1447
- [-3]: WebrpcBadMethodError,
1448
- [-4]: WebrpcBadRequestError,
1449
- [-5]: WebrpcBadResponseError,
1450
- [-6]: WebrpcServerPanicError,
1451
- [-7]: WebrpcInternalErrorError,
1452
- [-8]: WebrpcClientAbortedError,
1453
- [-9]: WebrpcStreamLostError,
1454
- [-10]: WebrpcStreamFinishedError,
1455
- [1000]: UnauthorizedError,
1456
- [1001]: PermissionDeniedError,
1457
- [1002]: SessionExpiredError,
1458
- [1003]: MethodNotFoundError,
1459
- [1004]: RequestConflictError,
1460
- [1005]: AbortedError,
1461
- [1006]: GeoblockedError,
1462
- [1007]: RateLimitedError,
1463
- [1008]: ProjectNotFoundError,
1464
- [1009]: SecretKeyCorsDisallowedError,
1465
- [1101]: AccessKeyNotFoundError,
1466
- [1102]: AccessKeyMismatchError,
1467
- [1103]: InvalidOriginError,
1468
- [1104]: InvalidServiceError,
1469
- [1105]: UnauthorizedUserError,
1470
- [1106]: InvalidChainError,
1471
- [1200]: QuotaExceededError,
1472
- [1201]: QuotaRateLimitError,
1473
- [1300]: NoDefaultKeyError,
1474
- [1301]: MaxAccessKeysError,
1475
- [1302]: AtLeastOneKeyError,
1476
- [1900]: TimeoutError,
1477
- [2000]: NotFoundError,
1478
- [2001]: InvalidArgumentError,
1479
- [9999]: NotImplementedError
1480
- };
1481
-
1482
- class MarketplaceIndexer extends Marketplace {
1483
- constructor(hostname, projectAccessKey, jwtAuth) {
1484
- super(hostname.endsWith('/') ? hostname.slice(0, -1) : hostname, fetch);
1485
- this.projectAccessKey = projectAccessKey;
1486
- this.jwtAuth = jwtAuth;
1487
- this._fetch = (input, init) => {
1488
- // automatically include jwt and access key auth header to requests
1489
- // if its been set on the api client
1490
- const headers = {};
1491
- const jwtAuth = this.jwtAuth;
1492
- const projectAccessKey = this.projectAccessKey;
1493
- if (jwtAuth && jwtAuth.length > 0) {
1494
- headers['Authorization'] = `BEARER ${jwtAuth}`;
1495
- }
1496
- if (projectAccessKey && projectAccessKey.length > 0) {
1497
- headers['X-Access-Key'] = projectAccessKey;
1498
- }
1499
-
1500
- // before the request is made
1501
- init.headers = _extends({}, init.headers, headers);
1502
- return fetch(input, init);
1503
- };
1504
- this.fetch = this._fetch;
1505
- }
1506
- }
1507
-
1508
- export { AbortedError, AccessKeyMismatchError, AccessKeyNotFoundError, ActivityAction, Admin, AtLeastOneKeyError, CollectibleSource, CollectibleStatus, CollectionPriority, CollectionStatus, ContractType, CurrencyStatus, ExecuteType, GeoblockedError, InvalidArgumentError, InvalidChainError, InvalidOriginError, InvalidServiceError, ItemsContractStatus, Marketplace, MarketplaceIndexer, MarketplaceKind, MaxAccessKeysError, MetadataStatus, MethodNotFoundError, NoDefaultKeyError, NotFoundError, NotImplementedError, OfferType, OrderSide, OrderStatus, OrderbookKind, PermissionDeniedError, PrimarySaleContractStatus, PrimarySaleItemDetailType, PrimarySaleVersion, ProjectNotFoundError, ProjectStatus, PropertyType, QuotaExceededError, QuotaRateLimitError, RateLimitedError, RequestConflictError, SecretKeyCorsDisallowedError, SessionExpiredError, SortOrder, SourceKind, StepType, TimeoutError, TransactionCrypto, TransactionNFTCheckoutProvider, TransactionOnRampProvider, TransactionSwapProvider, UnauthorizedError, UnauthorizedUserError, VersionFromHeader, WalletKind, WebRPCSchemaHash, WebRPCSchemaVersion, WebRPCVersion, WebrpcBadMethodError, WebrpcBadRequestError, WebrpcBadResponseError, WebrpcBadRouteError, WebrpcClientAbortedError, WebrpcEndpointError, WebrpcError, WebrpcErrorCodes, WebrpcHeader, WebrpcHeaderValue, WebrpcInternalErrorError, WebrpcRequestFailedError, WebrpcServerPanicError, WebrpcStreamFinishedError, WebrpcStreamLostError, errors, webrpcErrorByCode };