@imtbl/sdk 0.24.0-alpha.3 → 0.24.1-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.
package/dist/index.cjs CHANGED
@@ -3085,7 +3085,7 @@ class MultiRollupApiClients {
3085
3085
  }
3086
3086
 
3087
3087
  // eslint-disable-next-line @typescript-eslint/naming-convention
3088
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.24.0-alpha.3' };
3088
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.24.1-alpha.1' };
3089
3089
  const createConfig = ({ basePath, headers, }) => {
3090
3090
  if (!basePath.trim()) {
3091
3091
  throw Error('basePath can not be empty');
@@ -3145,7 +3145,7 @@ class APIError extends Error {
3145
3145
 
3146
3146
  /* eslint-disable implicit-arrow-linebreak */
3147
3147
  const defaultHeaders = {
3148
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.24.0-alpha.3',
3148
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.24.1-alpha.1',
3149
3149
  };
3150
3150
  /**
3151
3151
  * createAPIConfiguration to create a custom Configuration
@@ -3479,7 +3479,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
3479
3479
  chainID,
3480
3480
  coreContractAddress,
3481
3481
  registrationContractAddress,
3482
- sdkVersion: 'ts-immutable-sdk-0.24.0-alpha.3',
3482
+ sdkVersion: 'ts-immutable-sdk-0.24.1-alpha.1',
3483
3483
  });
3484
3484
  /**
3485
3485
  * Sets `sdkVersion` at the time of build
@@ -11122,18 +11122,57 @@ class Seaport {
11122
11122
  buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
11123
11123
  purpose: TransactionPurpose.FULFILL_ORDER,
11124
11124
  });
11125
- // Expirtaion bytes in SIP7 extra data [21:29]
11126
- // In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
11127
- // In JS slice (start, end_inclusive), (44,60)
11128
- // 8 bytes uint64 epoch time in seconds
11129
- const expirationHex = extraData.slice(44, 60);
11130
- const expirationInSeconds = parseInt(expirationHex, 16);
11131
11125
  return {
11132
11126
  actions: fulfillmentActions,
11133
- expiration: (new Date(expirationInSeconds * 1000)).toISOString(),
11127
+ expiration: Seaport.getExpirationISOTimeFromExtraData(extraData),
11134
11128
  order: mapFromOpenApiOrder(order),
11135
11129
  };
11136
11130
  }
11131
+ async fulfillBulkOrders(fulfillingOrders, account) {
11132
+ // TODO: this function right now does not handle errors from the seaport.js
11133
+ // we should figure out why orders are rejected and return a submission
11134
+ // transaction on best efforts basis
11135
+ const fulfillOrderDetails = fulfillingOrders.map((o) => {
11136
+ const { orderComponents, tips } = this.mapImmutableOrderToSeaportOrderComponents(o.order);
11137
+ return {
11138
+ order: {
11139
+ parameters: orderComponents,
11140
+ signature: o.order.signature,
11141
+ },
11142
+ extraData: o.extra_data,
11143
+ tips,
11144
+ };
11145
+ });
11146
+ const { actions: seaportActions } = await this.getSeaportLib().fulfillOrders({
11147
+ fulfillOrderDetails,
11148
+ accountAddress: account,
11149
+ });
11150
+ const fulfillmentActions = [];
11151
+ const approvalAction = seaportActions.find((action) => action.type === 'approval');
11152
+ if (approvalAction) {
11153
+ fulfillmentActions.push({
11154
+ type: ActionType.TRANSACTION,
11155
+ buildTransaction: prepareTransaction(approvalAction.transactionMethods),
11156
+ purpose: TransactionPurpose.APPROVAL,
11157
+ });
11158
+ }
11159
+ const fulfilOrderAction = seaportActions.find((action) => action.type === 'exchange');
11160
+ if (!fulfilOrderAction) {
11161
+ throw new Error('No exchange action found');
11162
+ }
11163
+ fulfillmentActions.push({
11164
+ type: ActionType.TRANSACTION,
11165
+ buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
11166
+ purpose: TransactionPurpose.FULFILL_ORDER,
11167
+ });
11168
+ return {
11169
+ actions: fulfillmentActions,
11170
+ // return the shortest expiration out of all extraData - they should be very close
11171
+ expiration: fulfillOrderDetails
11172
+ .map((d) => Seaport.getExpirationISOTimeFromExtraData(d.extraData))
11173
+ .reduce((p, c) => (new Date(p) < new Date(c) ? p : c)),
11174
+ };
11175
+ }
11137
11176
  async cancelOrder(order, account) {
11138
11177
  const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
11139
11178
  const seaportLib = this.getSeaportLib(order);
@@ -11157,9 +11196,7 @@ class Seaport {
11157
11196
  ],
11158
11197
  consideration: [
11159
11198
  {
11160
- token: considerationItem.type === 'ERC20'
11161
- ? considerationItem.contractAddress
11162
- : undefined,
11199
+ token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
11163
11200
  amount: considerationItem.amount,
11164
11201
  recipient: offerer,
11165
11202
  },
@@ -11192,6 +11229,15 @@ class Seaport {
11192
11229
  // }
11193
11230
  return this.seaportLibFactory.create(seaportVersion, seaportAddress);
11194
11231
  }
11232
+ static getExpirationISOTimeFromExtraData(extraData) {
11233
+ // Expirtaion bytes in SIP7 extra data [21:29]
11234
+ // In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
11235
+ // In JS slice (start, end_inclusive), (44,60)
11236
+ // 8 bytes uint64 epoch time in seconds
11237
+ const expirationHex = extraData.slice(44, 60);
11238
+ const expirationInSeconds = parseInt(expirationHex, 16);
11239
+ return new Date(expirationInSeconds * 1000).toISOString();
11240
+ }
11195
11241
  }
11196
11242
 
11197
11243
  class ImmutableApiClient {
@@ -11495,6 +11541,24 @@ class Orderbook {
11495
11541
  }
11496
11542
  return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
11497
11543
  }
11544
+ async fulfillBulkOrders(listings, takerAddress) {
11545
+ const fulfillmentDataRes = await this.apiClient.fulfillmentData(listings.map((listingRequest) => ({
11546
+ order_id: listingRequest.listingId,
11547
+ fees: listingRequest.takerFees.map((fee) => ({
11548
+ amount: fee.amount,
11549
+ fee_type: FeeType.TAKER_ECOSYSTEM,
11550
+ recipient: fee.recipient,
11551
+ })),
11552
+ })));
11553
+ return {
11554
+ ...(await this.seaport.fulfillBulkOrders(fulfillmentDataRes.result.fulfillable_orders, takerAddress)),
11555
+ fulfillableOrders: fulfillmentDataRes.result.fulfillable_orders.map((o) => mapFromOpenApiOrder(o.order)),
11556
+ unfulfillableOrders: fulfillmentDataRes.result.unfulfillable_orders.map((o) => ({
11557
+ orderId: o.order_id,
11558
+ reason: o.reason,
11559
+ })),
11560
+ };
11561
+ }
11498
11562
  /**
11499
11563
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
11500
11564
  * the account that created them.
@@ -32307,7 +32371,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
32307
32371
  })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
32308
32372
 
32309
32373
 
32310
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.24.0-alpha.3";
32374
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.24.1-alpha.1";
32311
32375
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
32312
32376
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
32313
32377
 
package/dist/index.d.ts CHANGED
@@ -14148,7 +14148,7 @@ type TradeResult$1 = {
14148
14148
  result: Trade$1;
14149
14149
  };
14150
14150
 
14151
- type UnfulfillableOrder = {
14151
+ type UnfulfillableOrder$1 = {
14152
14152
  /**
14153
14153
  * OrderID for the requested but unfulfillable order
14154
14154
  */
@@ -14238,7 +14238,7 @@ declare class OrdersService {
14238
14238
  }): CancelablePromise<{
14239
14239
  result: {
14240
14240
  fulfillable_orders: Array<FulfillableOrder>;
14241
- unfulfillable_orders: Array<UnfulfillableOrder>;
14241
+ unfulfillable_orders: Array<UnfulfillableOrder$1>;
14242
14242
  };
14243
14243
  }>;
14244
14244
  /**
@@ -14359,6 +14359,20 @@ interface SignableAction {
14359
14359
  };
14360
14360
  }
14361
14361
  type Action = TransactionAction | SignableAction;
14362
+ interface FulfillmentListing {
14363
+ listingId: string;
14364
+ takerFees: Array<FeeValue>;
14365
+ }
14366
+ interface FulfillBulkOrdersResponse {
14367
+ actions: Action[];
14368
+ expiration: string;
14369
+ fulfillableOrders: Order[];
14370
+ unfulfillableOrders: UnfulfillableOrder[];
14371
+ }
14372
+ interface UnfulfillableOrder {
14373
+ orderId: string;
14374
+ reason: string;
14375
+ }
14362
14376
  interface FulfillOrderResponse {
14363
14377
  actions: Action[];
14364
14378
  /**
@@ -14529,6 +14543,7 @@ declare class Orderbook {
14529
14543
  * @return {FulfillOrderResponse} Approval and fulfilment transactions.
14530
14544
  */
14531
14545
  fulfillOrder(listingId: string, takerAddress: string, takerFees: FeeValue[]): Promise<FulfillOrderResponse>;
14546
+ fulfillBulkOrders(listings: Array<FulfillmentListing>, takerAddress: string): Promise<FulfillBulkOrdersResponse>;
14532
14547
  /**
14533
14548
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
14534
14549
  * the account that created them.
@@ -14553,7 +14568,9 @@ type orderbook_d_ERC721Item = ERC721Item;
14553
14568
  type orderbook_d_FeeType = FeeType;
14554
14569
  declare const orderbook_d_FeeType: typeof FeeType;
14555
14570
  type orderbook_d_FeeValue = FeeValue;
14571
+ type orderbook_d_FulfillBulkOrdersResponse = FulfillBulkOrdersResponse;
14556
14572
  type orderbook_d_FulfillOrderResponse = FulfillOrderResponse;
14573
+ type orderbook_d_FulfillmentListing = FulfillmentListing;
14557
14574
  type orderbook_d_ListListingsParams = ListListingsParams;
14558
14575
  type orderbook_d_ListListingsResult = ListListingsResult;
14559
14576
  type orderbook_d_ListTradesParams = ListTradesParams;
@@ -14578,6 +14595,7 @@ type orderbook_d_TransactionAction = TransactionAction;
14578
14595
  type orderbook_d_TransactionBuilder = TransactionBuilder;
14579
14596
  type orderbook_d_TransactionPurpose = TransactionPurpose;
14580
14597
  declare const orderbook_d_TransactionPurpose: typeof TransactionPurpose;
14598
+ type orderbook_d_UnfulfillableOrder = UnfulfillableOrder;
14581
14599
  declare const orderbook_d_constants: typeof constants;
14582
14600
  declare namespace orderbook_d {
14583
14601
  export {
@@ -14590,7 +14608,9 @@ declare namespace orderbook_d {
14590
14608
  Fee$1 as Fee,
14591
14609
  orderbook_d_FeeType as FeeType,
14592
14610
  orderbook_d_FeeValue as FeeValue,
14611
+ orderbook_d_FulfillBulkOrdersResponse as FulfillBulkOrdersResponse,
14593
14612
  orderbook_d_FulfillOrderResponse as FulfillOrderResponse,
14613
+ orderbook_d_FulfillmentListing as FulfillmentListing,
14594
14614
  orderbook_d_ListListingsParams as ListListingsParams,
14595
14615
  orderbook_d_ListListingsResult as ListListingsResult,
14596
14616
  orderbook_d_ListTradesParams as ListTradesParams,
@@ -14611,6 +14631,7 @@ declare namespace orderbook_d {
14611
14631
  orderbook_d_TransactionAction as TransactionAction,
14612
14632
  orderbook_d_TransactionBuilder as TransactionBuilder,
14613
14633
  orderbook_d_TransactionPurpose as TransactionPurpose,
14634
+ orderbook_d_UnfulfillableOrder as UnfulfillableOrder,
14614
14635
  orderbook_d_constants as constants,
14615
14636
  };
14616
14637
  }
package/dist/index.js CHANGED
@@ -3063,7 +3063,7 @@ class MultiRollupApiClients {
3063
3063
  }
3064
3064
 
3065
3065
  // eslint-disable-next-line @typescript-eslint/naming-convention
3066
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.24.0-alpha.3' };
3066
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.24.1-alpha.1' };
3067
3067
  const createConfig = ({ basePath, headers, }) => {
3068
3068
  if (!basePath.trim()) {
3069
3069
  throw Error('basePath can not be empty');
@@ -3123,7 +3123,7 @@ class APIError extends Error {
3123
3123
 
3124
3124
  /* eslint-disable implicit-arrow-linebreak */
3125
3125
  const defaultHeaders = {
3126
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.24.0-alpha.3',
3126
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.24.1-alpha.1',
3127
3127
  };
3128
3128
  /**
3129
3129
  * createAPIConfiguration to create a custom Configuration
@@ -3457,7 +3457,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
3457
3457
  chainID,
3458
3458
  coreContractAddress,
3459
3459
  registrationContractAddress,
3460
- sdkVersion: 'ts-immutable-sdk-0.24.0-alpha.3',
3460
+ sdkVersion: 'ts-immutable-sdk-0.24.1-alpha.1',
3461
3461
  });
3462
3462
  /**
3463
3463
  * Sets `sdkVersion` at the time of build
@@ -11100,18 +11100,57 @@ class Seaport {
11100
11100
  buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
11101
11101
  purpose: TransactionPurpose.FULFILL_ORDER,
11102
11102
  });
11103
- // Expirtaion bytes in SIP7 extra data [21:29]
11104
- // In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
11105
- // In JS slice (start, end_inclusive), (44,60)
11106
- // 8 bytes uint64 epoch time in seconds
11107
- const expirationHex = extraData.slice(44, 60);
11108
- const expirationInSeconds = parseInt(expirationHex, 16);
11109
11103
  return {
11110
11104
  actions: fulfillmentActions,
11111
- expiration: (new Date(expirationInSeconds * 1000)).toISOString(),
11105
+ expiration: Seaport.getExpirationISOTimeFromExtraData(extraData),
11112
11106
  order: mapFromOpenApiOrder(order),
11113
11107
  };
11114
11108
  }
11109
+ async fulfillBulkOrders(fulfillingOrders, account) {
11110
+ // TODO: this function right now does not handle errors from the seaport.js
11111
+ // we should figure out why orders are rejected and return a submission
11112
+ // transaction on best efforts basis
11113
+ const fulfillOrderDetails = fulfillingOrders.map((o) => {
11114
+ const { orderComponents, tips } = this.mapImmutableOrderToSeaportOrderComponents(o.order);
11115
+ return {
11116
+ order: {
11117
+ parameters: orderComponents,
11118
+ signature: o.order.signature,
11119
+ },
11120
+ extraData: o.extra_data,
11121
+ tips,
11122
+ };
11123
+ });
11124
+ const { actions: seaportActions } = await this.getSeaportLib().fulfillOrders({
11125
+ fulfillOrderDetails,
11126
+ accountAddress: account,
11127
+ });
11128
+ const fulfillmentActions = [];
11129
+ const approvalAction = seaportActions.find((action) => action.type === 'approval');
11130
+ if (approvalAction) {
11131
+ fulfillmentActions.push({
11132
+ type: ActionType.TRANSACTION,
11133
+ buildTransaction: prepareTransaction(approvalAction.transactionMethods),
11134
+ purpose: TransactionPurpose.APPROVAL,
11135
+ });
11136
+ }
11137
+ const fulfilOrderAction = seaportActions.find((action) => action.type === 'exchange');
11138
+ if (!fulfilOrderAction) {
11139
+ throw new Error('No exchange action found');
11140
+ }
11141
+ fulfillmentActions.push({
11142
+ type: ActionType.TRANSACTION,
11143
+ buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
11144
+ purpose: TransactionPurpose.FULFILL_ORDER,
11145
+ });
11146
+ return {
11147
+ actions: fulfillmentActions,
11148
+ // return the shortest expiration out of all extraData - they should be very close
11149
+ expiration: fulfillOrderDetails
11150
+ .map((d) => Seaport.getExpirationISOTimeFromExtraData(d.extraData))
11151
+ .reduce((p, c) => (new Date(p) < new Date(c) ? p : c)),
11152
+ };
11153
+ }
11115
11154
  async cancelOrder(order, account) {
11116
11155
  const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
11117
11156
  const seaportLib = this.getSeaportLib(order);
@@ -11135,9 +11174,7 @@ class Seaport {
11135
11174
  ],
11136
11175
  consideration: [
11137
11176
  {
11138
- token: considerationItem.type === 'ERC20'
11139
- ? considerationItem.contractAddress
11140
- : undefined,
11177
+ token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
11141
11178
  amount: considerationItem.amount,
11142
11179
  recipient: offerer,
11143
11180
  },
@@ -11170,6 +11207,15 @@ class Seaport {
11170
11207
  // }
11171
11208
  return this.seaportLibFactory.create(seaportVersion, seaportAddress);
11172
11209
  }
11210
+ static getExpirationISOTimeFromExtraData(extraData) {
11211
+ // Expirtaion bytes in SIP7 extra data [21:29]
11212
+ // In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
11213
+ // In JS slice (start, end_inclusive), (44,60)
11214
+ // 8 bytes uint64 epoch time in seconds
11215
+ const expirationHex = extraData.slice(44, 60);
11216
+ const expirationInSeconds = parseInt(expirationHex, 16);
11217
+ return new Date(expirationInSeconds * 1000).toISOString();
11218
+ }
11173
11219
  }
11174
11220
 
11175
11221
  class ImmutableApiClient {
@@ -11473,6 +11519,24 @@ class Orderbook {
11473
11519
  }
11474
11520
  return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
11475
11521
  }
11522
+ async fulfillBulkOrders(listings, takerAddress) {
11523
+ const fulfillmentDataRes = await this.apiClient.fulfillmentData(listings.map((listingRequest) => ({
11524
+ order_id: listingRequest.listingId,
11525
+ fees: listingRequest.takerFees.map((fee) => ({
11526
+ amount: fee.amount,
11527
+ fee_type: FeeType.TAKER_ECOSYSTEM,
11528
+ recipient: fee.recipient,
11529
+ })),
11530
+ })));
11531
+ return {
11532
+ ...(await this.seaport.fulfillBulkOrders(fulfillmentDataRes.result.fulfillable_orders, takerAddress)),
11533
+ fulfillableOrders: fulfillmentDataRes.result.fulfillable_orders.map((o) => mapFromOpenApiOrder(o.order)),
11534
+ unfulfillableOrders: fulfillmentDataRes.result.unfulfillable_orders.map((o) => ({
11535
+ orderId: o.order_id,
11536
+ reason: o.reason,
11537
+ })),
11538
+ };
11539
+ }
11476
11540
  /**
11477
11541
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
11478
11542
  * the account that created them.
@@ -32285,7 +32349,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
32285
32349
  })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
32286
32350
 
32287
32351
 
32288
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.24.0-alpha.3";
32352
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.24.1-alpha.1";
32289
32353
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
32290
32354
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
32291
32355
 
@@ -997,7 +997,7 @@ type TradeResult$1 = {
997
997
  result: Trade$1;
998
998
  };
999
999
 
1000
- type UnfulfillableOrder = {
1000
+ type UnfulfillableOrder$1 = {
1001
1001
  /**
1002
1002
  * OrderID for the requested but unfulfillable order
1003
1003
  */
@@ -1087,7 +1087,7 @@ declare class OrdersService {
1087
1087
  }): CancelablePromise<{
1088
1088
  result: {
1089
1089
  fulfillable_orders: Array<FulfillableOrder>;
1090
- unfulfillable_orders: Array<UnfulfillableOrder>;
1090
+ unfulfillable_orders: Array<UnfulfillableOrder$1>;
1091
1091
  };
1092
1092
  }>;
1093
1093
  /**
@@ -1208,6 +1208,20 @@ interface SignableAction {
1208
1208
  };
1209
1209
  }
1210
1210
  type Action = TransactionAction | SignableAction;
1211
+ interface FulfillmentListing {
1212
+ listingId: string;
1213
+ takerFees: Array<FeeValue>;
1214
+ }
1215
+ interface FulfillBulkOrdersResponse {
1216
+ actions: Action[];
1217
+ expiration: string;
1218
+ fulfillableOrders: Order[];
1219
+ unfulfillableOrders: UnfulfillableOrder[];
1220
+ }
1221
+ interface UnfulfillableOrder {
1222
+ orderId: string;
1223
+ reason: string;
1224
+ }
1211
1225
  interface FulfillOrderResponse {
1212
1226
  actions: Action[];
1213
1227
  /**
@@ -1378,6 +1392,7 @@ declare class Orderbook {
1378
1392
  * @return {FulfillOrderResponse} Approval and fulfilment transactions.
1379
1393
  */
1380
1394
  fulfillOrder(listingId: string, takerAddress: string, takerFees: FeeValue[]): Promise<FulfillOrderResponse>;
1395
+ fulfillBulkOrders(listings: Array<FulfillmentListing>, takerAddress: string): Promise<FulfillBulkOrdersResponse>;
1381
1396
  /**
1382
1397
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
1383
1398
  * the account that created them.
@@ -1392,4 +1407,4 @@ declare const constants: {
1392
1407
  estimatedFulfillmentGasGwei: number;
1393
1408
  };
1394
1409
 
1395
- export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillOrderResponse, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order, OrderStatus, Orderbook, Page, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, Trade, TradeResult, TransactionAction, TransactionBuilder, TransactionPurpose, constants };
1410
+ export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillBulkOrdersResponse, FulfillOrderResponse, FulfillmentListing, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order, OrderStatus, Orderbook, Page, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, Trade, TradeResult, TransactionAction, TransactionBuilder, TransactionPurpose, UnfulfillableOrder, constants };
package/dist/orderbook.js CHANGED
@@ -964,18 +964,57 @@ class Seaport {
964
964
  buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
965
965
  purpose: TransactionPurpose.FULFILL_ORDER,
966
966
  });
967
- // Expirtaion bytes in SIP7 extra data [21:29]
968
- // In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
969
- // In JS slice (start, end_inclusive), (44,60)
970
- // 8 bytes uint64 epoch time in seconds
971
- const expirationHex = extraData.slice(44, 60);
972
- const expirationInSeconds = parseInt(expirationHex, 16);
973
967
  return {
974
968
  actions: fulfillmentActions,
975
- expiration: (new Date(expirationInSeconds * 1000)).toISOString(),
969
+ expiration: Seaport.getExpirationISOTimeFromExtraData(extraData),
976
970
  order: mapFromOpenApiOrder(order),
977
971
  };
978
972
  }
973
+ async fulfillBulkOrders(fulfillingOrders, account) {
974
+ // TODO: this function right now does not handle errors from the seaport.js
975
+ // we should figure out why orders are rejected and return a submission
976
+ // transaction on best efforts basis
977
+ const fulfillOrderDetails = fulfillingOrders.map((o) => {
978
+ const { orderComponents, tips } = this.mapImmutableOrderToSeaportOrderComponents(o.order);
979
+ return {
980
+ order: {
981
+ parameters: orderComponents,
982
+ signature: o.order.signature,
983
+ },
984
+ extraData: o.extra_data,
985
+ tips,
986
+ };
987
+ });
988
+ const { actions: seaportActions } = await this.getSeaportLib().fulfillOrders({
989
+ fulfillOrderDetails,
990
+ accountAddress: account,
991
+ });
992
+ const fulfillmentActions = [];
993
+ const approvalAction = seaportActions.find((action) => action.type === 'approval');
994
+ if (approvalAction) {
995
+ fulfillmentActions.push({
996
+ type: ActionType.TRANSACTION,
997
+ buildTransaction: prepareTransaction(approvalAction.transactionMethods),
998
+ purpose: TransactionPurpose.APPROVAL,
999
+ });
1000
+ }
1001
+ const fulfilOrderAction = seaportActions.find((action) => action.type === 'exchange');
1002
+ if (!fulfilOrderAction) {
1003
+ throw new Error('No exchange action found');
1004
+ }
1005
+ fulfillmentActions.push({
1006
+ type: ActionType.TRANSACTION,
1007
+ buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
1008
+ purpose: TransactionPurpose.FULFILL_ORDER,
1009
+ });
1010
+ return {
1011
+ actions: fulfillmentActions,
1012
+ // return the shortest expiration out of all extraData - they should be very close
1013
+ expiration: fulfillOrderDetails
1014
+ .map((d) => Seaport.getExpirationISOTimeFromExtraData(d.extraData))
1015
+ .reduce((p, c) => (new Date(p) < new Date(c) ? p : c)),
1016
+ };
1017
+ }
979
1018
  async cancelOrder(order, account) {
980
1019
  const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
981
1020
  const seaportLib = this.getSeaportLib(order);
@@ -999,9 +1038,7 @@ class Seaport {
999
1038
  ],
1000
1039
  consideration: [
1001
1040
  {
1002
- token: considerationItem.type === 'ERC20'
1003
- ? considerationItem.contractAddress
1004
- : undefined,
1041
+ token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
1005
1042
  amount: considerationItem.amount,
1006
1043
  recipient: offerer,
1007
1044
  },
@@ -1034,6 +1071,15 @@ class Seaport {
1034
1071
  // }
1035
1072
  return this.seaportLibFactory.create(seaportVersion, seaportAddress);
1036
1073
  }
1074
+ static getExpirationISOTimeFromExtraData(extraData) {
1075
+ // Expirtaion bytes in SIP7 extra data [21:29]
1076
+ // In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
1077
+ // In JS slice (start, end_inclusive), (44,60)
1078
+ // 8 bytes uint64 epoch time in seconds
1079
+ const expirationHex = extraData.slice(44, 60);
1080
+ const expirationInSeconds = parseInt(expirationHex, 16);
1081
+ return new Date(expirationInSeconds * 1000).toISOString();
1082
+ }
1037
1083
  }
1038
1084
 
1039
1085
  class ImmutableApiClient {
@@ -1337,6 +1383,24 @@ class Orderbook {
1337
1383
  }
1338
1384
  return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
1339
1385
  }
1386
+ async fulfillBulkOrders(listings, takerAddress) {
1387
+ const fulfillmentDataRes = await this.apiClient.fulfillmentData(listings.map((listingRequest) => ({
1388
+ order_id: listingRequest.listingId,
1389
+ fees: listingRequest.takerFees.map((fee) => ({
1390
+ amount: fee.amount,
1391
+ fee_type: FeeType.TAKER_ECOSYSTEM,
1392
+ recipient: fee.recipient,
1393
+ })),
1394
+ })));
1395
+ return {
1396
+ ...(await this.seaport.fulfillBulkOrders(fulfillmentDataRes.result.fulfillable_orders, takerAddress)),
1397
+ fulfillableOrders: fulfillmentDataRes.result.fulfillable_orders.map((o) => mapFromOpenApiOrder(o.order)),
1398
+ unfulfillableOrders: fulfillmentDataRes.result.unfulfillable_orders.map((o) => ({
1399
+ orderId: o.order_id,
1400
+ reason: o.reason,
1401
+ })),
1402
+ };
1403
+ }
1340
1404
  /**
1341
1405
  * Get an unsigned cancel order transaction. Orders can only be cancelled by
1342
1406
  * the account that created them.
package/dist/passport.js CHANGED
@@ -1785,7 +1785,7 @@ class MultiRollupApiClients {
1785
1785
  }
1786
1786
 
1787
1787
  // eslint-disable-next-line @typescript-eslint/naming-convention
1788
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.24.0-alpha.3' };
1788
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.24.1-alpha.1' };
1789
1789
  const createConfig = ({ basePath, headers, }) => {
1790
1790
  if (!basePath.trim()) {
1791
1791
  throw Error('basePath can not be empty');
@@ -1841,7 +1841,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
1841
1841
  chainID,
1842
1842
  coreContractAddress,
1843
1843
  registrationContractAddress,
1844
- sdkVersion: 'ts-immutable-sdk-0.24.0-alpha.3',
1844
+ sdkVersion: 'ts-immutable-sdk-0.24.1-alpha.1',
1845
1845
  });
1846
1846
  /**
1847
1847
  * Sets `sdkVersion` at the time of build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.24.0-alpha.3",
4
+ "version": "0.24.1-alpha.1",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",