@imtbl/sdk 0.24.1-alpha.1 → 0.25.0

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.
@@ -699,6 +699,47 @@ declare abstract class BaseHttpRequest {
699
699
  abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
700
700
  }
701
701
 
702
+ type CancelOrdersRequestBody = {
703
+ /**
704
+ * Address of the user initiating the cancel request
705
+ */
706
+ account_address: string;
707
+ /**
708
+ * List of order ids proposed for cancellation
709
+ */
710
+ orders: Array<string>;
711
+ /**
712
+ * Signature generated by the user for the specific cancellation request
713
+ */
714
+ signature: string;
715
+ };
716
+
717
+ type CancelOrdersResult = {
718
+ result: {
719
+ /**
720
+ * Orders which were successfully cancelled
721
+ */
722
+ successful_cancellations: Array<string>;
723
+ /**
724
+ * Orders which are marked for cancellation but the cancellation cannot be guaranteed
725
+ */
726
+ pending_cancellations: Array<string>;
727
+ /**
728
+ * Orders which failed to be cancelled
729
+ */
730
+ failed_cancellations: Array<{
731
+ /**
732
+ * ID of the order which failed to be cancelled
733
+ */
734
+ order: string;
735
+ /**
736
+ * Reason code indicating why the order failed to be cancelled
737
+ */
738
+ reason_code: 'ALREADY_FILLED';
739
+ }>;
740
+ };
741
+ };
742
+
702
743
  /**
703
744
  * The name of chain
704
745
  */
@@ -852,17 +893,69 @@ type Chain = {
852
893
  name: string;
853
894
  };
854
895
 
896
+ type ActiveOrderStatus = {
897
+ /**
898
+ * The order status
899
+ */
900
+ name: 'ACTIVE';
901
+ };
902
+
903
+ type CancelledOrderStatus = {
904
+ /**
905
+ * The order status
906
+ */
907
+ name: 'CANCELLED';
908
+ /**
909
+ * Whether the cancellation of the order is pending
910
+ */
911
+ is_pending: boolean;
912
+ /**
913
+ * Whether the cancellation was done on-chain or off-chain
914
+ */
915
+ cancellation_type: CancelledOrderStatus.cancellation_type;
916
+ };
917
+ declare namespace CancelledOrderStatus {
918
+ /**
919
+ * Whether the cancellation was done on-chain or off-chain
920
+ */
921
+ enum cancellation_type {
922
+ ON_CHAIN = "ON_CHAIN",
923
+ OFF_CHAIN = "OFF_CHAIN"
924
+ }
925
+ }
926
+
927
+ type ExpiredOrderStatus = {
928
+ /**
929
+ * The order status
930
+ */
931
+ name: 'EXPIRED';
932
+ };
933
+
934
+ type FilledOrderStatus = {
935
+ /**
936
+ * The order status
937
+ */
938
+ name: 'FILLED';
939
+ };
940
+
941
+ type InactiveOrderStatus = {
942
+ /**
943
+ * The order status
944
+ */
945
+ name: 'INACTIVE';
946
+ };
947
+
948
+ type PendingOrderStatus = {
949
+ /**
950
+ * The order status
951
+ */
952
+ name: 'PENDING';
953
+ };
954
+
855
955
  /**
856
956
  * The Order status
857
957
  */
858
- declare enum OrderStatus {
859
- PENDING = "PENDING",
860
- ACTIVE = "ACTIVE",
861
- INACTIVE = "INACTIVE",
862
- FILLED = "FILLED",
863
- CANCELLED = "CANCELLED",
864
- EXPIRED = "EXPIRED"
865
- }
958
+ type OrderStatus = (CancelledOrderStatus | PendingOrderStatus | ActiveOrderStatus | InactiveOrderStatus | FilledOrderStatus | ExpiredOrderStatus);
866
959
 
867
960
  type Order$1 = {
868
961
  account_address: string;
@@ -983,6 +1076,18 @@ type ListTradeResult = {
983
1076
  result: Array<Trade$1>;
984
1077
  };
985
1078
 
1079
+ /**
1080
+ * The Order status
1081
+ */
1082
+ declare enum OrderStatusName {
1083
+ PENDING = "PENDING",
1084
+ ACTIVE = "ACTIVE",
1085
+ INACTIVE = "INACTIVE",
1086
+ FILLED = "FILLED",
1087
+ EXPIRED = "EXPIRED",
1088
+ CANCELLED = "CANCELLED"
1089
+ }
1090
+
986
1091
  /**
987
1092
  * Encoded page cursor to retrieve previous or next page. Use the value returned in the response.
988
1093
  */
@@ -1011,6 +1116,16 @@ type UnfulfillableOrder$1 = {
1011
1116
  declare class OrdersService {
1012
1117
  readonly httpRequest: BaseHttpRequest;
1013
1118
  constructor(httpRequest: BaseHttpRequest);
1119
+ /**
1120
+ * Cancel one or more orders
1121
+ * Cancel one or more orders
1122
+ * @returns CancelOrdersResult Orders cancellation response.
1123
+ * @throws ApiError
1124
+ */
1125
+ cancelOrders({ chainName, requestBody, }: {
1126
+ chainName: ChainName;
1127
+ requestBody: CancelOrdersRequestBody;
1128
+ }): CancelablePromise<CancelOrdersResult>;
1014
1129
  /**
1015
1130
  * List all listings
1016
1131
  * List all listings
@@ -1022,7 +1137,7 @@ declare class OrdersService {
1022
1137
  /**
1023
1138
  * Order status to filter by
1024
1139
  */
1025
- status?: OrderStatus;
1140
+ status?: OrderStatusName;
1026
1141
  /**
1027
1142
  * Sell item contract address to filter by
1028
1143
  */
@@ -1407,4 +1522,4 @@ declare const constants: {
1407
1522
  estimatedFulfillmentGasGwei: number;
1408
1523
  };
1409
1524
 
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 };
1525
+ export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillBulkOrdersResponse, FulfillOrderResponse, FulfillmentListing, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order, OrderStatusName, Orderbook, Page, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, Trade, TradeResult, TransactionAction, TransactionBuilder, TransactionPurpose, UnfulfillableOrder, constants };
package/dist/orderbook.js CHANGED
@@ -398,6 +398,31 @@ class OrdersService {
398
398
  constructor(httpRequest) {
399
399
  this.httpRequest = httpRequest;
400
400
  }
401
+ /**
402
+ * Cancel one or more orders
403
+ * Cancel one or more orders
404
+ * @returns CancelOrdersResult Orders cancellation response.
405
+ * @throws ApiError
406
+ */
407
+ cancelOrders({ chainName, requestBody, }) {
408
+ return this.httpRequest.request({
409
+ method: 'POST',
410
+ url: '/v1/chains/{chain_name}/orders/cancel',
411
+ path: {
412
+ 'chain_name': chainName,
413
+ },
414
+ body: requestBody,
415
+ mediaType: 'application/json',
416
+ errors: {
417
+ 400: `Bad Request (400)`,
418
+ 401: `Unauthorised Request (401)`,
419
+ 404: `The specified resource was not found (404)`,
420
+ 429: `Too Many Requests (429)`,
421
+ 500: `Internal Server Error (500)`,
422
+ 501: `Not Implemented Error (501)`,
423
+ },
424
+ });
425
+ }
401
426
  /**
402
427
  * List all listings
403
428
  * List all listings
@@ -562,6 +587,17 @@ class OrderBookClient {
562
587
  }
563
588
  }
564
589
 
590
+ /* istanbul ignore file */
591
+ /* tslint:disable */
592
+ /* eslint-disable */
593
+ var CancelledOrderStatus;
594
+ (function (CancelledOrderStatus) {
595
+ (function (cancellation_type) {
596
+ cancellation_type["ON_CHAIN"] = "ON_CHAIN";
597
+ cancellation_type["OFF_CHAIN"] = "OFF_CHAIN";
598
+ })(CancelledOrderStatus.cancellation_type || (CancelledOrderStatus.cancellation_type = {}));
599
+ })(CancelledOrderStatus || (CancelledOrderStatus = {}));
600
+
565
601
  /* istanbul ignore file */
566
602
  /* tslint:disable */
567
603
  /* eslint-disable */
@@ -581,15 +617,15 @@ var Fee;
581
617
  /**
582
618
  * The Order status
583
619
  */
584
- var OrderStatus;
585
- (function (OrderStatus) {
586
- OrderStatus["PENDING"] = "PENDING";
587
- OrderStatus["ACTIVE"] = "ACTIVE";
588
- OrderStatus["INACTIVE"] = "INACTIVE";
589
- OrderStatus["FILLED"] = "FILLED";
590
- OrderStatus["CANCELLED"] = "CANCELLED";
591
- OrderStatus["EXPIRED"] = "EXPIRED";
592
- })(OrderStatus || (OrderStatus = {}));
620
+ var OrderStatusName;
621
+ (function (OrderStatusName) {
622
+ OrderStatusName["PENDING"] = "PENDING";
623
+ OrderStatusName["ACTIVE"] = "ACTIVE";
624
+ OrderStatusName["INACTIVE"] = "INACTIVE";
625
+ OrderStatusName["FILLED"] = "FILLED";
626
+ OrderStatusName["EXPIRED"] = "EXPIRED";
627
+ OrderStatusName["CANCELLED"] = "CANCELLED";
628
+ })(OrderStatusName || (OrderStatusName = {}));
593
629
 
594
630
  /* istanbul ignore file */
595
631
  /* tslint:disable */
@@ -1378,7 +1414,7 @@ class Orderbook {
1378
1414
  }
1379
1415
  const extraData = fulfillmentDataRes.result.fulfillable_orders[0].extra_data;
1380
1416
  const orderResult = fulfillmentDataRes.result.fulfillable_orders[0].order;
1381
- if (orderResult.status !== OrderStatus.ACTIVE) {
1417
+ if (orderResult.status.name !== OrderStatusName.ACTIVE) {
1382
1418
  throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.status}`);
1383
1419
  }
1384
1420
  return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
@@ -1410,9 +1446,9 @@ class Orderbook {
1410
1446
  */
1411
1447
  async cancelOrder(listingId, accountAddress) {
1412
1448
  const orderResult = await this.apiClient.getListing(listingId);
1413
- if (orderResult.result.status !== OrderStatus.ACTIVE
1414
- && orderResult.result.status !== OrderStatus.INACTIVE
1415
- && orderResult.result.status !== OrderStatus.PENDING) {
1449
+ if (orderResult.result.status.name !== OrderStatusName.ACTIVE
1450
+ && orderResult.result.status.name !== OrderStatusName.INACTIVE
1451
+ && orderResult.result.status.name !== OrderStatusName.PENDING) {
1416
1452
  throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
1417
1453
  }
1418
1454
  if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
@@ -1431,4 +1467,4 @@ const constants = {
1431
1467
  estimatedFulfillmentGasGwei: ESTIMATED_FULFILLMENT_GAS_GWEI,
1432
1468
  };
1433
1469
 
1434
- export { ActionType, FeeType, OrderStatus, Orderbook, SignablePurpose, TransactionPurpose, constants };
1470
+ export { ActionType, FeeType, OrderStatusName, Orderbook, SignablePurpose, TransactionPurpose, constants };