@imtbl/sdk 0.1.8-alpha.2 → 0.1.9-alpha
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/blockchain-data.d.ts +402 -110
- package/dist/blockchain-data.js +1699 -232
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +163 -68
- package/dist/checkout_sdk.js +570 -215
- package/dist/checkout_widgets.d.ts +63 -156
- package/dist/checkout_widgets.js +20 -80
- package/dist/erc20.d.ts +180 -11
- package/dist/erc20.js +22 -22
- package/dist/erc721-permissioned-mintable.d.ts +258 -84
- package/dist/erc721-permissioned-mintable.js +134 -114
- package/dist/immutablex_client.js +1 -1
- package/dist/index.cjs +6966 -1834
- package/dist/index.d.ts +712 -413
- package/dist/index.js +6988 -1855
- package/dist/orderbook.d.ts +16 -16
- package/dist/orderbook.js +221 -114
- package/dist/passport.d.ts +3 -4
- package/dist/passport.js +3681 -436
- package/package.json +6 -1
package/dist/orderbook.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OrderbookModuleConfiguration } from 'config/config';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ListingResult, ListListingsResult } from 'openapi/sdk';
|
|
3
|
+
import { ListListingsParams, PrepareListingParams, PrepareListingResponse, CreateListingParams, FulfillOrderResponse, CancelOrderResponse } from 'types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* zkEVM orderbook SDK
|
|
@@ -14,49 +14,49 @@ declare class Orderbook {
|
|
|
14
14
|
constructor(config: OrderbookModuleConfiguration);
|
|
15
15
|
/**
|
|
16
16
|
* Get an order by ID
|
|
17
|
-
* @param {string}
|
|
18
|
-
* @return {
|
|
17
|
+
* @param {string} listingId - The listingId to find.
|
|
18
|
+
* @return {ListingResult} The returned order result.
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
getListing(listingId: string): Promise<ListingResult>;
|
|
21
21
|
/**
|
|
22
22
|
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
23
23
|
* in the params object.
|
|
24
24
|
* @param {ListOrderParams} listOrderParams - Filtering, ordering and page parameters.
|
|
25
25
|
* @return {Orders} The paged orders.
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
listListings(listOrderParams: ListListingsParams): Promise<ListListingsResult>;
|
|
28
28
|
/**
|
|
29
29
|
* Get required transactions and messages for signing prior to creating a listing
|
|
30
|
-
* through the
|
|
30
|
+
* through the createListing method
|
|
31
31
|
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
32
32
|
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
33
33
|
* the unsigned approval transaction, the typed order message for signing and
|
|
34
|
-
* the order components that can be submitted to `
|
|
34
|
+
* the order components that can be submitted to `createListing` with a signature.
|
|
35
35
|
*/
|
|
36
36
|
prepareListing({ offerer, listingItem, considerationItem, orderExpiry, }: PrepareListingParams): Promise<PrepareListingResponse>;
|
|
37
37
|
/**
|
|
38
38
|
* Create an order
|
|
39
|
-
* @param {
|
|
40
|
-
* @return {
|
|
39
|
+
* @param {CreateListingParams} createListingParams - create an order with the given params.
|
|
40
|
+
* @return {ListingResult} The result of the order created in the Immutable services.
|
|
41
41
|
*/
|
|
42
|
-
|
|
42
|
+
createListing(createListingParams: CreateListingParams): Promise<ListingResult>;
|
|
43
43
|
/**
|
|
44
44
|
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
45
45
|
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
46
46
|
* transaction can be submitted or it will be reverted.
|
|
47
|
-
* @param {string}
|
|
47
|
+
* @param {string} listingId - The listingId to fulfil.
|
|
48
48
|
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
49
|
-
* @return {
|
|
49
|
+
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
50
50
|
*/
|
|
51
|
-
fulfillOrder(
|
|
51
|
+
fulfillOrder(listingId: string, fulfillerAddress: string): Promise<FulfillOrderResponse>;
|
|
52
52
|
/**
|
|
53
53
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
54
54
|
* the account that created them.
|
|
55
|
-
* @param {string}
|
|
55
|
+
* @param {string} listingId - The listingId to cancel.
|
|
56
56
|
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
57
57
|
* @return {CancelOrderResponse} The unsigned cancel order transaction
|
|
58
58
|
*/
|
|
59
|
-
cancelOrder(
|
|
59
|
+
cancelOrder(listingId: string, accountAddress: string): Promise<CancelOrderResponse>;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
declare const module = "orderbook";
|
package/dist/orderbook.js
CHANGED
|
@@ -387,27 +387,108 @@ class AxiosHttpRequest extends BaseHttpRequest {
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
|
|
390
|
+
class ListingsService {
|
|
391
|
+
httpRequest;
|
|
392
|
+
constructor(httpRequest) {
|
|
393
|
+
this.httpRequest = httpRequest;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* List all listings
|
|
397
|
+
* List all listings
|
|
398
|
+
* @returns ListListingsResult OK response.
|
|
399
|
+
* @throws ApiError
|
|
400
|
+
*/
|
|
401
|
+
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
402
|
+
return this.httpRequest.request({
|
|
403
|
+
method: 'GET',
|
|
404
|
+
url: '/v1/chains/{chain_name}/orders/listings',
|
|
405
|
+
path: {
|
|
406
|
+
'chain_name': chainName,
|
|
407
|
+
},
|
|
408
|
+
query: {
|
|
409
|
+
'status': status,
|
|
410
|
+
'sell_item_contract_address': sellItemContractAddress,
|
|
411
|
+
'buy_item_contract_address': buyItemContractAddress,
|
|
412
|
+
'sell_item_token_id': sellItemTokenId,
|
|
413
|
+
'page_size': pageSize,
|
|
414
|
+
'sort_by': sortBy,
|
|
415
|
+
'sort_direction': sortDirection,
|
|
416
|
+
'page_cursor': pageCursor,
|
|
417
|
+
},
|
|
418
|
+
errors: {
|
|
419
|
+
400: `Bad Request (400)`,
|
|
420
|
+
404: `The specified resource was not found (404)`,
|
|
421
|
+
500: `Internal Server Error (500)`,
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Create a listing
|
|
427
|
+
* Create a listing
|
|
428
|
+
* @returns ListingResult Created response.
|
|
429
|
+
* @throws ApiError
|
|
430
|
+
*/
|
|
431
|
+
createListing({ chainName, requestBody, }) {
|
|
432
|
+
return this.httpRequest.request({
|
|
433
|
+
method: 'POST',
|
|
434
|
+
url: '/v1/chains/{chain_name}/orders/listings',
|
|
435
|
+
path: {
|
|
436
|
+
'chain_name': chainName,
|
|
437
|
+
},
|
|
438
|
+
body: requestBody,
|
|
439
|
+
mediaType: 'application/json',
|
|
440
|
+
errors: {
|
|
441
|
+
400: `Bad Request (400)`,
|
|
442
|
+
404: `The specified resource was not found (404)`,
|
|
443
|
+
500: `Internal Server Error (500)`,
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Get a single listing by ID
|
|
449
|
+
* Get a single listing by ID
|
|
450
|
+
* @returns ListingResult OK response.
|
|
451
|
+
* @throws ApiError
|
|
452
|
+
*/
|
|
453
|
+
getListing({ chainName, listingId, }) {
|
|
454
|
+
return this.httpRequest.request({
|
|
455
|
+
method: 'GET',
|
|
456
|
+
url: '/v1/chains/{chain_name}/orders/listings/{listing_id}',
|
|
457
|
+
path: {
|
|
458
|
+
'chain_name': chainName,
|
|
459
|
+
'listing_id': listingId,
|
|
460
|
+
},
|
|
461
|
+
errors: {
|
|
462
|
+
400: `Bad Request (400)`,
|
|
463
|
+
404: `The specified resource was not found (404)`,
|
|
464
|
+
500: `Internal Server Error (500)`,
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
390
470
|
class OrdersService {
|
|
391
471
|
httpRequest;
|
|
392
472
|
constructor(httpRequest) {
|
|
393
473
|
this.httpRequest = httpRequest;
|
|
394
474
|
}
|
|
395
475
|
/**
|
|
396
|
-
* List all
|
|
397
|
-
* List all
|
|
398
|
-
* @returns
|
|
476
|
+
* List all listings
|
|
477
|
+
* List all listings
|
|
478
|
+
* @returns ListListingsResult OK response.
|
|
399
479
|
* @throws ApiError
|
|
400
480
|
*/
|
|
401
|
-
|
|
481
|
+
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
402
482
|
return this.httpRequest.request({
|
|
403
483
|
method: 'GET',
|
|
404
|
-
url: '/v1/chains/{
|
|
484
|
+
url: '/v1/chains/{chain_name}/orders/listings',
|
|
405
485
|
path: {
|
|
406
|
-
'
|
|
486
|
+
'chain_name': chainName,
|
|
407
487
|
},
|
|
408
488
|
query: {
|
|
409
489
|
'status': status,
|
|
410
490
|
'sell_item_contract_address': sellItemContractAddress,
|
|
491
|
+
'buy_item_contract_address': buyItemContractAddress,
|
|
411
492
|
'sell_item_token_id': sellItemTokenId,
|
|
412
493
|
'page_size': pageSize,
|
|
413
494
|
'sort_by': sortBy,
|
|
@@ -415,58 +496,59 @@ class OrdersService {
|
|
|
415
496
|
'page_cursor': pageCursor,
|
|
416
497
|
},
|
|
417
498
|
errors: {
|
|
418
|
-
400: `
|
|
419
|
-
404: `The specified resource was not found`,
|
|
420
|
-
500: `Internal
|
|
499
|
+
400: `Bad Request (400)`,
|
|
500
|
+
404: `The specified resource was not found (404)`,
|
|
501
|
+
500: `Internal Server Error (500)`,
|
|
421
502
|
},
|
|
422
503
|
});
|
|
423
504
|
}
|
|
424
505
|
/**
|
|
425
|
-
* Create
|
|
426
|
-
* Create
|
|
427
|
-
* @returns
|
|
506
|
+
* Create a listing
|
|
507
|
+
* Create a listing
|
|
508
|
+
* @returns ListingResult Created response.
|
|
428
509
|
* @throws ApiError
|
|
429
510
|
*/
|
|
430
|
-
|
|
511
|
+
createListing({ chainName, requestBody, }) {
|
|
431
512
|
return this.httpRequest.request({
|
|
432
513
|
method: 'POST',
|
|
433
|
-
url: '/v1/chains/{
|
|
514
|
+
url: '/v1/chains/{chain_name}/orders/listings',
|
|
434
515
|
path: {
|
|
435
|
-
'
|
|
516
|
+
'chain_name': chainName,
|
|
436
517
|
},
|
|
437
518
|
body: requestBody,
|
|
438
519
|
mediaType: 'application/json',
|
|
439
520
|
errors: {
|
|
440
|
-
400: `
|
|
441
|
-
404: `The specified resource was not found`,
|
|
442
|
-
500: `Internal
|
|
521
|
+
400: `Bad Request (400)`,
|
|
522
|
+
404: `The specified resource was not found (404)`,
|
|
523
|
+
500: `Internal Server Error (500)`,
|
|
443
524
|
},
|
|
444
525
|
});
|
|
445
526
|
}
|
|
446
527
|
/**
|
|
447
|
-
* Get a single
|
|
448
|
-
* Get a single
|
|
449
|
-
* @returns
|
|
528
|
+
* Get a single listing by ID
|
|
529
|
+
* Get a single listing by ID
|
|
530
|
+
* @returns ListingResult OK response.
|
|
450
531
|
* @throws ApiError
|
|
451
532
|
*/
|
|
452
|
-
|
|
533
|
+
getListing({ chainName, listingId, }) {
|
|
453
534
|
return this.httpRequest.request({
|
|
454
535
|
method: 'GET',
|
|
455
|
-
url: '/v1/chains/{
|
|
536
|
+
url: '/v1/chains/{chain_name}/orders/listings/{listing_id}',
|
|
456
537
|
path: {
|
|
457
|
-
'
|
|
458
|
-
'
|
|
538
|
+
'chain_name': chainName,
|
|
539
|
+
'listing_id': listingId,
|
|
459
540
|
},
|
|
460
541
|
errors: {
|
|
461
|
-
400: `
|
|
462
|
-
404: `The specified resource was not found`,
|
|
463
|
-
500: `Internal
|
|
542
|
+
400: `Bad Request (400)`,
|
|
543
|
+
404: `The specified resource was not found (404)`,
|
|
544
|
+
500: `Internal Server Error (500)`,
|
|
464
545
|
},
|
|
465
546
|
});
|
|
466
547
|
}
|
|
467
548
|
}
|
|
468
549
|
|
|
469
550
|
class OrderBookClient {
|
|
551
|
+
listings;
|
|
470
552
|
orders;
|
|
471
553
|
request;
|
|
472
554
|
constructor(config, HttpRequest = AxiosHttpRequest) {
|
|
@@ -481,21 +563,11 @@ class OrderBookClient {
|
|
|
481
563
|
HEADERS: config?.HEADERS,
|
|
482
564
|
ENCODE_PATH: config?.ENCODE_PATH,
|
|
483
565
|
});
|
|
566
|
+
this.listings = new ListingsService(this.request);
|
|
484
567
|
this.orders = new OrdersService(this.request);
|
|
485
568
|
}
|
|
486
569
|
}
|
|
487
570
|
|
|
488
|
-
/* istanbul ignore file */
|
|
489
|
-
/* tslint:disable */
|
|
490
|
-
/* eslint-disable */
|
|
491
|
-
var BuyItem;
|
|
492
|
-
(function (BuyItem) {
|
|
493
|
-
(function (item_type) {
|
|
494
|
-
item_type["NATIVE"] = "NATIVE";
|
|
495
|
-
item_type["ERC20"] = "ERC20";
|
|
496
|
-
})(BuyItem.item_type || (BuyItem.item_type = {}));
|
|
497
|
-
})(BuyItem || (BuyItem = {}));
|
|
498
|
-
|
|
499
571
|
/* istanbul ignore file */
|
|
500
572
|
/* tslint:disable */
|
|
501
573
|
/* eslint-disable */
|
|
@@ -532,20 +604,10 @@ var OrderStatus;
|
|
|
532
604
|
OrderStatus["EXPIRED"] = "EXPIRED";
|
|
533
605
|
})(OrderStatus || (OrderStatus = {}));
|
|
534
606
|
|
|
535
|
-
/* istanbul ignore file */
|
|
536
|
-
/* tslint:disable */
|
|
537
|
-
/* eslint-disable */
|
|
538
|
-
var SellItem;
|
|
539
|
-
(function (SellItem) {
|
|
540
|
-
(function (item_type) {
|
|
541
|
-
item_type["ERC721"] = "ERC721";
|
|
542
|
-
})(SellItem.item_type || (SellItem.item_type = {}));
|
|
543
|
-
})(SellItem || (SellItem = {}));
|
|
544
|
-
|
|
545
607
|
/* eslint-disable */
|
|
546
608
|
// TODO: Resolve these from seaport-js.
|
|
547
609
|
// There is some bundling issue that is preventing this from working
|
|
548
|
-
const SEAPORT_CONTRACT_NAME = '
|
|
610
|
+
const SEAPORT_CONTRACT_NAME = 'ImmutableSeaport';
|
|
549
611
|
const SEAPORT_CONTRACT_VERSION_V1_4 = '1.4';
|
|
550
612
|
const EIP_712_ORDER_TYPE = {
|
|
551
613
|
OrderComponents: [
|
|
@@ -626,32 +688,60 @@ async function prepareTransaction(transactionMethods) {
|
|
|
626
688
|
}
|
|
627
689
|
|
|
628
690
|
function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress) {
|
|
629
|
-
const considerationItems = order.buy.map((buyItem) =>
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
691
|
+
const considerationItems = order.buy.map((buyItem) => {
|
|
692
|
+
switch (buyItem.item_type) {
|
|
693
|
+
case 'NATIVE':
|
|
694
|
+
return {
|
|
695
|
+
startAmount: buyItem.start_amount,
|
|
696
|
+
endAmount: buyItem.start_amount,
|
|
697
|
+
itemType: ItemType.NATIVE,
|
|
698
|
+
recipient: order.account_address,
|
|
699
|
+
token: constants.AddressZero,
|
|
700
|
+
identifierOrCriteria: '0',
|
|
701
|
+
};
|
|
702
|
+
case 'ERC20':
|
|
703
|
+
return {
|
|
704
|
+
startAmount: buyItem.start_amount,
|
|
705
|
+
endAmount: buyItem.start_amount,
|
|
706
|
+
itemType: ItemType.ERC20,
|
|
707
|
+
recipient: order.account_address,
|
|
708
|
+
token: buyItem.contract_address || constants.AddressZero,
|
|
709
|
+
identifierOrCriteria: '0',
|
|
710
|
+
};
|
|
711
|
+
default: // ERC721
|
|
712
|
+
return {
|
|
713
|
+
startAmount: '1',
|
|
714
|
+
endAmount: '1',
|
|
715
|
+
itemType: ItemType.ERC721,
|
|
716
|
+
recipient: order.account_address,
|
|
717
|
+
token: buyItem.contract_address || constants.AddressZero,
|
|
718
|
+
identifierOrCriteria: '0',
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
});
|
|
637
722
|
const fees = order.buy_fees.map((fee) => ({
|
|
638
723
|
startAmount: fee.amount,
|
|
639
724
|
endAmount: fee.amount,
|
|
640
725
|
itemType: order.buy[0].item_type === 'ERC20' ? ItemType.ERC20 : ItemType.NATIVE,
|
|
641
726
|
recipient: fee.recipient,
|
|
642
|
-
token: order.buy[0].
|
|
727
|
+
token: order.buy[0].item_type === 'ERC20'
|
|
728
|
+
? order.buy[0].contract_address
|
|
729
|
+
: constants.AddressZero,
|
|
643
730
|
identifierOrCriteria: '0',
|
|
644
731
|
}));
|
|
645
732
|
return {
|
|
646
733
|
conduitKey: constants.HashZero,
|
|
647
734
|
consideration: [...considerationItems, ...fees],
|
|
648
|
-
offer: order.sell.map((sellItem) =>
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
735
|
+
offer: order.sell.map((sellItem) => {
|
|
736
|
+
const erc721Item = sellItem;
|
|
737
|
+
return {
|
|
738
|
+
startAmount: '1',
|
|
739
|
+
endAmount: '1',
|
|
740
|
+
itemType: ItemType.ERC721,
|
|
741
|
+
token: erc721Item.contract_address,
|
|
742
|
+
identifierOrCriteria: erc721Item.token_id,
|
|
743
|
+
};
|
|
744
|
+
}),
|
|
655
745
|
counter,
|
|
656
746
|
endTime: Math.round(new Date(order.end_time).getTime() / 1000).toString(),
|
|
657
747
|
startTime: Math.round(new Date(order.start_time).getTime() / 1000).toString(),
|
|
@@ -803,43 +893,53 @@ class SeaportFactory {
|
|
|
803
893
|
|
|
804
894
|
class ImmutableApiClient {
|
|
805
895
|
orderbookService;
|
|
806
|
-
|
|
807
|
-
|
|
896
|
+
chainName;
|
|
897
|
+
seaportAddress;
|
|
898
|
+
constructor(orderbookService, chainName, seaportAddress) {
|
|
808
899
|
this.orderbookService = orderbookService;
|
|
809
|
-
this.
|
|
900
|
+
this.chainName = chainName;
|
|
901
|
+
this.seaportAddress = seaportAddress;
|
|
810
902
|
}
|
|
811
|
-
async
|
|
812
|
-
return this.orderbookService.
|
|
903
|
+
async getListing(listingId) {
|
|
904
|
+
return this.orderbookService.getListing({
|
|
905
|
+
chainName: this.chainName,
|
|
906
|
+
listingId,
|
|
907
|
+
});
|
|
813
908
|
}
|
|
814
|
-
async
|
|
815
|
-
return this.orderbookService.
|
|
816
|
-
|
|
909
|
+
async listListings(listOrderParams) {
|
|
910
|
+
return this.orderbookService.listListings({
|
|
911
|
+
chainName: this.chainName,
|
|
817
912
|
...listOrderParams,
|
|
818
913
|
});
|
|
819
914
|
}
|
|
820
|
-
async
|
|
915
|
+
async createListing({ orderHash, orderComponents, offerer, orderSignature, }) {
|
|
821
916
|
if (orderComponents.offer.length !== 1) {
|
|
822
917
|
throw new Error('Only one item can be listed at a time');
|
|
823
918
|
}
|
|
824
919
|
if (Number(orderComponents.offer[0].itemType) !== ItemType.ERC721) {
|
|
825
920
|
throw new Error('Only ERC721 tokens can be listed');
|
|
826
921
|
}
|
|
827
|
-
const
|
|
828
|
-
|
|
922
|
+
const orderTypes = [
|
|
923
|
+
...orderComponents.consideration.map((c) => c.itemType),
|
|
924
|
+
];
|
|
925
|
+
const isSameConsiderationType = new Set(orderTypes).size === 1;
|
|
926
|
+
if (!isSameConsiderationType) {
|
|
829
927
|
throw new Error('All consideration items must be of the same type');
|
|
830
928
|
}
|
|
831
|
-
return this.orderbookService.
|
|
832
|
-
|
|
929
|
+
return this.orderbookService.createListing({
|
|
930
|
+
chainName: this.chainName,
|
|
833
931
|
requestBody: {
|
|
834
932
|
order_hash: orderHash,
|
|
835
933
|
account_address: offerer,
|
|
836
934
|
buy: [
|
|
837
935
|
{
|
|
838
|
-
item_type: Number(orderComponents.consideration[0].itemType)
|
|
839
|
-
|
|
840
|
-
|
|
936
|
+
item_type: Number(orderComponents.consideration[0].itemType)
|
|
937
|
+
=== ItemType.NATIVE
|
|
938
|
+
? 'NATIVE'
|
|
939
|
+
: 'ERC20',
|
|
841
940
|
start_amount: orderComponents.consideration[0].startAmount,
|
|
842
|
-
|
|
941
|
+
contract_address: orderComponents.consideration[0].token,
|
|
942
|
+
},
|
|
843
943
|
],
|
|
844
944
|
buy_fees: orderComponents.consideration.length > 1
|
|
845
945
|
? [
|
|
@@ -854,13 +954,18 @@ class ImmutableApiClient {
|
|
|
854
954
|
protocol_data: {
|
|
855
955
|
order_type: CreateOrderProtocolData.order_type.FULL_RESTRICTED,
|
|
856
956
|
zone_address: orderComponents.zone,
|
|
957
|
+
seaport_address: this.seaportAddress,
|
|
958
|
+
seaport_version: SEAPORT_CONTRACT_VERSION_V1_4,
|
|
959
|
+
counter: orderComponents.counter.toString(),
|
|
857
960
|
},
|
|
858
961
|
salt: orderComponents.salt,
|
|
859
|
-
sell: [
|
|
962
|
+
sell: [
|
|
963
|
+
{
|
|
860
964
|
contract_address: orderComponents.offer[0].token,
|
|
861
965
|
token_id: orderComponents.offer[0].identifierOrCriteria,
|
|
862
|
-
item_type:
|
|
863
|
-
}
|
|
966
|
+
item_type: 'ERC721',
|
|
967
|
+
},
|
|
968
|
+
],
|
|
864
969
|
signature: orderSignature,
|
|
865
970
|
start_time: new Date(parseInt(`${orderComponents.startTime.toString()}000`, 10)).toISOString(),
|
|
866
971
|
},
|
|
@@ -869,17 +974,19 @@ class ImmutableApiClient {
|
|
|
869
974
|
}
|
|
870
975
|
|
|
871
976
|
class ImmutableApiClientFactory {
|
|
872
|
-
|
|
977
|
+
chainName;
|
|
978
|
+
seaportAddress;
|
|
873
979
|
orderbookClient;
|
|
874
|
-
constructor(apiEndpoint,
|
|
875
|
-
this.
|
|
980
|
+
constructor(apiEndpoint, chainName, seaportAddress) {
|
|
981
|
+
this.chainName = chainName;
|
|
982
|
+
this.seaportAddress = seaportAddress;
|
|
876
983
|
this.orderbookClient = new OrderBookClient({
|
|
877
984
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
878
985
|
BASE: apiEndpoint,
|
|
879
986
|
});
|
|
880
987
|
}
|
|
881
988
|
create() {
|
|
882
|
-
return new ImmutableApiClient(this.orderbookClient.orders, this.
|
|
989
|
+
return new ImmutableApiClient(this.orderbookClient.orders, this.chainName, this.seaportAddress);
|
|
883
990
|
}
|
|
884
991
|
}
|
|
885
992
|
|
|
@@ -1822,20 +1929,20 @@ class Orderbook {
|
|
|
1822
1929
|
throw new Error('API endpoint must be provided as an override');
|
|
1823
1930
|
}
|
|
1824
1931
|
// TODO: Move chainId lookup to a map based on env. Just using override to get dev started
|
|
1825
|
-
const
|
|
1826
|
-
if (!
|
|
1827
|
-
throw new Error('
|
|
1932
|
+
const chainName = config.overrides?.chainName;
|
|
1933
|
+
if (!chainName) {
|
|
1934
|
+
throw new Error('chainName must be provided as an override');
|
|
1828
1935
|
}
|
|
1829
|
-
this.apiClient = new ImmutableApiClientFactory(apiEndpoint,
|
|
1936
|
+
this.apiClient = new ImmutableApiClientFactory(apiEndpoint, chainName, this.config.seaportContractAddress).create();
|
|
1830
1937
|
this.seaport = new SeaportFactory(this.config.seaportContractAddress, this.config.zoneContractAddress, this.config.provider).create();
|
|
1831
1938
|
}
|
|
1832
1939
|
/**
|
|
1833
1940
|
* Get an order by ID
|
|
1834
|
-
* @param {string}
|
|
1835
|
-
* @return {
|
|
1941
|
+
* @param {string} listingId - The listingId to find.
|
|
1942
|
+
* @return {ListingResult} The returned order result.
|
|
1836
1943
|
*/
|
|
1837
|
-
|
|
1838
|
-
return this.apiClient.
|
|
1944
|
+
getListing(listingId) {
|
|
1945
|
+
return this.apiClient.getListing(listingId);
|
|
1839
1946
|
}
|
|
1840
1947
|
/**
|
|
1841
1948
|
* List orders. This method is used to get a list of orders filtered by conditions specified
|
|
@@ -1843,16 +1950,16 @@ class Orderbook {
|
|
|
1843
1950
|
* @param {ListOrderParams} listOrderParams - Filtering, ordering and page parameters.
|
|
1844
1951
|
* @return {Orders} The paged orders.
|
|
1845
1952
|
*/
|
|
1846
|
-
|
|
1847
|
-
return this.apiClient.
|
|
1953
|
+
listListings(listOrderParams) {
|
|
1954
|
+
return this.apiClient.listListings(listOrderParams);
|
|
1848
1955
|
}
|
|
1849
1956
|
/**
|
|
1850
1957
|
* Get required transactions and messages for signing prior to creating a listing
|
|
1851
|
-
* through the
|
|
1958
|
+
* through the createListing method
|
|
1852
1959
|
* @param {PrepareListingParams} prepareListingParams - Details about the listing to be created.
|
|
1853
1960
|
* @return {PrepareListingResponse} PrepareListingResponse includes
|
|
1854
1961
|
* the unsigned approval transaction, the typed order message for signing and
|
|
1855
|
-
* the order components that can be submitted to `
|
|
1962
|
+
* the order components that can be submitted to `createListing` with a signature.
|
|
1856
1963
|
*/
|
|
1857
1964
|
async prepareListing({ offerer, listingItem, considerationItem, orderExpiry, }) {
|
|
1858
1965
|
const erc721 = new ERC721Factory(listingItem.contractAddress, this.config.provider).create();
|
|
@@ -1865,22 +1972,22 @@ class Orderbook {
|
|
|
1865
1972
|
}
|
|
1866
1973
|
/**
|
|
1867
1974
|
* Create an order
|
|
1868
|
-
* @param {
|
|
1869
|
-
* @return {
|
|
1975
|
+
* @param {CreateListingParams} createListingParams - create an order with the given params.
|
|
1976
|
+
* @return {ListingResult} The result of the order created in the Immutable services.
|
|
1870
1977
|
*/
|
|
1871
|
-
|
|
1872
|
-
return this.apiClient.
|
|
1978
|
+
createListing(createListingParams) {
|
|
1979
|
+
return this.apiClient.createListing(createListingParams);
|
|
1873
1980
|
}
|
|
1874
1981
|
/**
|
|
1875
1982
|
* Get unsigned transactions that can be submitted to fulfil an open order. If the approval
|
|
1876
1983
|
* transaction exists it must be signed and submitted to the chain before the fulfilment
|
|
1877
1984
|
* transaction can be submitted or it will be reverted.
|
|
1878
|
-
* @param {string}
|
|
1985
|
+
* @param {string} listingId - The listingId to fulfil.
|
|
1879
1986
|
* @param {string} fulfillerAddress - The address of the account fulfilling the order.
|
|
1880
|
-
* @return {
|
|
1987
|
+
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
1881
1988
|
*/
|
|
1882
|
-
async fulfillOrder(
|
|
1883
|
-
const orderResult = await this.apiClient.
|
|
1989
|
+
async fulfillOrder(listingId, fulfillerAddress) {
|
|
1990
|
+
const orderResult = await this.apiClient.getListing(listingId);
|
|
1884
1991
|
if (orderResult.result.status !== OrderStatus.ACTIVE) {
|
|
1885
1992
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.result.status}`);
|
|
1886
1993
|
}
|
|
@@ -1889,19 +1996,19 @@ class Orderbook {
|
|
|
1889
1996
|
/**
|
|
1890
1997
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
1891
1998
|
* the account that created them.
|
|
1892
|
-
* @param {string}
|
|
1999
|
+
* @param {string} listingId - The listingId to cancel.
|
|
1893
2000
|
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
1894
2001
|
* @return {CancelOrderResponse} The unsigned cancel order transaction
|
|
1895
2002
|
*/
|
|
1896
|
-
async cancelOrder(
|
|
1897
|
-
const orderResult = await this.apiClient.
|
|
2003
|
+
async cancelOrder(listingId, accountAddress) {
|
|
2004
|
+
const orderResult = await this.apiClient.getListing(listingId);
|
|
1898
2005
|
if (orderResult.result.status !== OrderStatus.ACTIVE
|
|
1899
2006
|
&& orderResult.result.status !== OrderStatus.INACTIVE
|
|
1900
2007
|
&& orderResult.result.status !== OrderStatus.PENDING) {
|
|
1901
2008
|
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
1902
2009
|
}
|
|
1903
2010
|
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
1904
|
-
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${
|
|
2011
|
+
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${listingId}`);
|
|
1905
2012
|
}
|
|
1906
2013
|
const cancelOrderTransaction = await this.seaport.cancelOrder(orderResult.result, accountAddress);
|
|
1907
2014
|
return { unsignedCancelOrderTransaction: cancelOrderTransaction };
|
package/dist/passport.d.ts
CHANGED
|
@@ -10491,12 +10491,12 @@ interface PassportModuleConfiguration extends ModuleConfiguration<PassportOverri
|
|
|
10491
10491
|
|
|
10492
10492
|
declare class Passport {
|
|
10493
10493
|
private readonly authManager;
|
|
10494
|
-
private readonly magicAdapter;
|
|
10495
10494
|
private readonly config;
|
|
10496
|
-
private readonly immutableXClient;
|
|
10497
10495
|
private readonly confirmationScreen;
|
|
10496
|
+
private readonly immutableXClient;
|
|
10497
|
+
private readonly magicAdapter;
|
|
10498
|
+
private readonly passportImxProviderFactory;
|
|
10498
10499
|
constructor(passportModuleConfiguration: PassportModuleConfiguration);
|
|
10499
|
-
private getImxProvider;
|
|
10500
10500
|
connectImxSilent(): Promise<IMXProvider | null>;
|
|
10501
10501
|
connectImx(): Promise<IMXProvider>;
|
|
10502
10502
|
loginCallback(): Promise<void>;
|
|
@@ -10504,7 +10504,6 @@ declare class Passport {
|
|
|
10504
10504
|
getUserInfo(): Promise<UserProfile | undefined>;
|
|
10505
10505
|
getIdToken(): Promise<string | undefined>;
|
|
10506
10506
|
getAccessToken(): Promise<string | undefined>;
|
|
10507
|
-
private registerUser;
|
|
10508
10507
|
}
|
|
10509
10508
|
|
|
10510
10509
|
export { Passport, PassportError, PassportModuleConfiguration };
|