@imtbl/sdk 0.14.0-alpha → 0.14.0-alpha.1

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.
@@ -16525,7 +16525,7 @@ class ImmutableApiClient {
16525
16525
  ],
16526
16526
  fees: makerFee ? [{
16527
16527
  amount: makerFee.amount,
16528
- fee_type: makerFee.type,
16528
+ fee_type: FeeType.MAKER_MARKETPLACE,
16529
16529
  recipient: makerFee.recipient,
16530
16530
  }] : [],
16531
16531
  end_time: new Date(parseInt(`${orderComponents.endTime.toString()}000`, 10)).toISOString(),
@@ -16594,6 +16594,67 @@ function getOrderbookConfig(environment) {
16594
16594
  }
16595
16595
  }
16596
16596
 
16597
+ function mapFromOpenApiOrder(order) {
16598
+ const buyItems = order.buy.map((item) => {
16599
+ if (item.item_type === 'ERC20') {
16600
+ return {
16601
+ type: 'ERC20',
16602
+ contractAddress: item.contract_address,
16603
+ amount: item.start_amount,
16604
+ };
16605
+ }
16606
+ if (item.item_type === 'NATIVE') {
16607
+ return {
16608
+ type: 'NATIVE',
16609
+ amount: item.start_amount,
16610
+ };
16611
+ }
16612
+ throw new Error('Buy items must be either ERC20 or NATIVE');
16613
+ });
16614
+ const sellItems = order.sell.map((item) => {
16615
+ if (item.item_type === 'ERC721') {
16616
+ return {
16617
+ type: 'ERC721',
16618
+ contractAddress: item.contract_address,
16619
+ tokenId: item.token_id,
16620
+ };
16621
+ }
16622
+ throw new Error('Sell items must ERC721');
16623
+ });
16624
+ return {
16625
+ id: order.id,
16626
+ accountAddress: order.account_address,
16627
+ buy: buyItems,
16628
+ sell: sellItems,
16629
+ fees: order.fees.map((fee) => ({
16630
+ amount: fee.amount,
16631
+ recipient: fee.recipient,
16632
+ type: fee.fee_type,
16633
+ })),
16634
+ chain: order.chain,
16635
+ createTime: order.create_time,
16636
+ endTime: order.end_time,
16637
+ protocolData: {
16638
+ counter: order.protocol_data.counter,
16639
+ orderType: order.protocol_data.order_type,
16640
+ seaportAddress: order.protocol_data.seaport_address,
16641
+ seaportVersion: order.protocol_data.seaport_version,
16642
+ zoneAddress: order.protocol_data.zone_address,
16643
+ },
16644
+ salt: order.salt,
16645
+ signature: order.signature,
16646
+ startTime: order.start_time,
16647
+ status: order.status,
16648
+ updateTime: order.update_time,
16649
+ };
16650
+ }
16651
+ function mapFromOpenApiPage(page) {
16652
+ return {
16653
+ nextCursor: page.next_cursor,
16654
+ previousCursor: page.previous_cursor,
16655
+ };
16656
+ }
16657
+
16597
16658
  class SeaportLibFactory {
16598
16659
  defaultSeaportContractAddress;
16599
16660
  provider;
@@ -16653,8 +16714,11 @@ class Orderbook {
16653
16714
  * @param {string} listingId - The listingId to find.
16654
16715
  * @return {ListingResult} The returned order result.
16655
16716
  */
16656
- getListing(listingId) {
16657
- return this.apiClient.getListing(listingId);
16717
+ async getListing(listingId) {
16718
+ const apiListing = await this.apiClient.getListing(listingId);
16719
+ return {
16720
+ result: mapFromOpenApiOrder(apiListing.result),
16721
+ };
16658
16722
  }
16659
16723
  /**
16660
16724
  * List orders. This method is used to get a list of orders filtered by conditions specified
@@ -16662,8 +16726,12 @@ class Orderbook {
16662
16726
  * @param {ListListingsParams} listOrderParams - Filtering, ordering and page parameters.
16663
16727
  * @return {ListListingsResult} The paged orders.
16664
16728
  */
16665
- listListings(listOrderParams) {
16666
- return this.apiClient.listListings(listOrderParams);
16729
+ async listListings(listOrderParams) {
16730
+ const apiListings = await this.apiClient.listListings(listOrderParams);
16731
+ return {
16732
+ page: mapFromOpenApiPage(apiListings.page),
16733
+ result: apiListings.result.map(mapFromOpenApiOrder),
16734
+ };
16667
16735
  }
16668
16736
  /**
16669
16737
  * Get required transactions and messages for signing prior to creating a listing
@@ -16685,8 +16753,20 @@ class Orderbook {
16685
16753
  * @param {CreateListingParams} createListingParams - create an order with the given params.
16686
16754
  * @return {ListingResult} The result of the order created in the Immutable services.
16687
16755
  */
16688
- createListing(createListingParams) {
16689
- return this.apiClient.createListing(createListingParams);
16756
+ async createListing(createListingParams) {
16757
+ const makerFee = createListingParams.makerFee
16758
+ ? {
16759
+ ...createListingParams.makerFee,
16760
+ type: FeeType.MAKER_MARKETPLACE,
16761
+ }
16762
+ : undefined;
16763
+ const apiListingResponse = await this.apiClient.createListing({
16764
+ ...createListingParams,
16765
+ makerFee,
16766
+ });
16767
+ return {
16768
+ result: mapFromOpenApiOrder(apiListingResponse.result),
16769
+ };
16690
16770
  }
16691
16771
  /**
16692
16772
  * Get unsigned transactions that can be submitted to fulfil an open order. If the approval
@@ -16703,7 +16783,7 @@ class Orderbook {
16703
16783
  fee: takerFee
16704
16784
  ? {
16705
16785
  amount: takerFee.amount,
16706
- fee_type: takerFee.type,
16786
+ fee_type: FeeType.TAKER_MARKETPLACE,
16707
16787
  recipient: takerFee.recipient,
16708
16788
  }
16709
16789
  : undefined,
@@ -18356,13 +18436,13 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
18356
18436
  let type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
18357
18437
  let contractAddress = "";
18358
18438
  const buyArray = order.result.buy;
18359
- if (buyArray.length > 0) switch(buyArray[0].item_type){
18439
+ if (buyArray.length > 0) switch(buyArray[0].type){
18360
18440
  case "NATIVE":
18361
18441
  type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
18362
18442
  break;
18363
18443
  case "ERC20":
18364
18444
  type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20;
18365
- contractAddress = buyArray[0].contract_address;
18445
+ contractAddress = buyArray[0].contractAddress;
18366
18446
  break;
18367
18447
  default:
18368
18448
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Purchasing token type is unsupported", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).UNSUPPORTED_TOKEN_TYPE_ERROR, {
@@ -18370,7 +18450,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
18370
18450
  });
18371
18451
  }
18372
18452
  buyArray.forEach((item)=>{
18373
- if (item.item_type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) amount = amount.add((BigNumber$1).from(item.start_amount));
18453
+ if (item.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721) amount = amount.add((BigNumber$1).from(item.amount));
18374
18454
  });
18375
18455
  const feeArray = order.result.fees;
18376
18456
  feeArray.forEach((item)=>{
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
4
4
  function $parcel$export(e, n, v, s) {
5
5
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
6
  }
7
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha";
7
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.14.0-alpha.1";
8
8
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
9
9
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
10
10
 
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
16
16
  chainID,
17
17
  coreContractAddress,
18
18
  registrationContractAddress,
19
- sdkVersion: 'ts-immutable-sdk-0.14.0-alpha',
19
+ sdkVersion: 'ts-immutable-sdk-0.14.0-alpha.1',
20
20
  });
21
21
  /**
22
22
  * Sets `sdkVersion` at the time of build