@imtbl/sdk 0.24.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.
- package/dist/blockchain_data.d.ts +324 -0
- package/dist/blockchain_data.js +570 -44
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.js +693 -67
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +6 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +699 -73
- package/dist/index.d.ts +474 -14
- package/dist/index.js +699 -73
- package/dist/orderbook.d.ts +142 -12
- package/dist/orderbook.js +124 -24
- package/dist/passport.js +293 -11
- package/package.json +1 -1
package/dist/orderbook.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
*/
|
|
@@ -997,7 +1102,7 @@ type TradeResult$1 = {
|
|
|
997
1102
|
result: Trade$1;
|
|
998
1103
|
};
|
|
999
1104
|
|
|
1000
|
-
type UnfulfillableOrder = {
|
|
1105
|
+
type UnfulfillableOrder$1 = {
|
|
1001
1106
|
/**
|
|
1002
1107
|
* OrderID for the requested but unfulfillable order
|
|
1003
1108
|
*/
|
|
@@ -1011,6 +1116,16 @@ type UnfulfillableOrder = {
|
|
|
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?:
|
|
1140
|
+
status?: OrderStatusName;
|
|
1026
1141
|
/**
|
|
1027
1142
|
* Sell item contract address to filter by
|
|
1028
1143
|
*/
|
|
@@ -1087,7 +1202,7 @@ declare class OrdersService {
|
|
|
1087
1202
|
}): CancelablePromise<{
|
|
1088
1203
|
result: {
|
|
1089
1204
|
fulfillable_orders: Array<FulfillableOrder>;
|
|
1090
|
-
unfulfillable_orders: Array<UnfulfillableOrder>;
|
|
1205
|
+
unfulfillable_orders: Array<UnfulfillableOrder$1>;
|
|
1091
1206
|
};
|
|
1092
1207
|
}>;
|
|
1093
1208
|
/**
|
|
@@ -1208,6 +1323,20 @@ interface SignableAction {
|
|
|
1208
1323
|
};
|
|
1209
1324
|
}
|
|
1210
1325
|
type Action = TransactionAction | SignableAction;
|
|
1326
|
+
interface FulfillmentListing {
|
|
1327
|
+
listingId: string;
|
|
1328
|
+
takerFees: Array<FeeValue>;
|
|
1329
|
+
}
|
|
1330
|
+
interface FulfillBulkOrdersResponse {
|
|
1331
|
+
actions: Action[];
|
|
1332
|
+
expiration: string;
|
|
1333
|
+
fulfillableOrders: Order[];
|
|
1334
|
+
unfulfillableOrders: UnfulfillableOrder[];
|
|
1335
|
+
}
|
|
1336
|
+
interface UnfulfillableOrder {
|
|
1337
|
+
orderId: string;
|
|
1338
|
+
reason: string;
|
|
1339
|
+
}
|
|
1211
1340
|
interface FulfillOrderResponse {
|
|
1212
1341
|
actions: Action[];
|
|
1213
1342
|
/**
|
|
@@ -1378,6 +1507,7 @@ declare class Orderbook {
|
|
|
1378
1507
|
* @return {FulfillOrderResponse} Approval and fulfilment transactions.
|
|
1379
1508
|
*/
|
|
1380
1509
|
fulfillOrder(listingId: string, takerAddress: string, takerFees: FeeValue[]): Promise<FulfillOrderResponse>;
|
|
1510
|
+
fulfillBulkOrders(listings: Array<FulfillmentListing>, takerAddress: string): Promise<FulfillBulkOrdersResponse>;
|
|
1381
1511
|
/**
|
|
1382
1512
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
1383
1513
|
* the account that created them.
|
|
@@ -1392,4 +1522,4 @@ declare const constants: {
|
|
|
1392
1522
|
estimatedFulfillmentGasGwei: number;
|
|
1393
1523
|
};
|
|
1394
1524
|
|
|
1395
|
-
export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillOrderResponse, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order,
|
|
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
|
|
585
|
-
(function (
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
})(
|
|
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 */
|
|
@@ -964,18 +1000,57 @@ class Seaport {
|
|
|
964
1000
|
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
965
1001
|
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
966
1002
|
});
|
|
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
1003
|
return {
|
|
974
1004
|
actions: fulfillmentActions,
|
|
975
|
-
expiration:
|
|
1005
|
+
expiration: Seaport.getExpirationISOTimeFromExtraData(extraData),
|
|
976
1006
|
order: mapFromOpenApiOrder(order),
|
|
977
1007
|
};
|
|
978
1008
|
}
|
|
1009
|
+
async fulfillBulkOrders(fulfillingOrders, account) {
|
|
1010
|
+
// TODO: this function right now does not handle errors from the seaport.js
|
|
1011
|
+
// we should figure out why orders are rejected and return a submission
|
|
1012
|
+
// transaction on best efforts basis
|
|
1013
|
+
const fulfillOrderDetails = fulfillingOrders.map((o) => {
|
|
1014
|
+
const { orderComponents, tips } = this.mapImmutableOrderToSeaportOrderComponents(o.order);
|
|
1015
|
+
return {
|
|
1016
|
+
order: {
|
|
1017
|
+
parameters: orderComponents,
|
|
1018
|
+
signature: o.order.signature,
|
|
1019
|
+
},
|
|
1020
|
+
extraData: o.extra_data,
|
|
1021
|
+
tips,
|
|
1022
|
+
};
|
|
1023
|
+
});
|
|
1024
|
+
const { actions: seaportActions } = await this.getSeaportLib().fulfillOrders({
|
|
1025
|
+
fulfillOrderDetails,
|
|
1026
|
+
accountAddress: account,
|
|
1027
|
+
});
|
|
1028
|
+
const fulfillmentActions = [];
|
|
1029
|
+
const approvalAction = seaportActions.find((action) => action.type === 'approval');
|
|
1030
|
+
if (approvalAction) {
|
|
1031
|
+
fulfillmentActions.push({
|
|
1032
|
+
type: ActionType.TRANSACTION,
|
|
1033
|
+
buildTransaction: prepareTransaction(approvalAction.transactionMethods),
|
|
1034
|
+
purpose: TransactionPurpose.APPROVAL,
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
const fulfilOrderAction = seaportActions.find((action) => action.type === 'exchange');
|
|
1038
|
+
if (!fulfilOrderAction) {
|
|
1039
|
+
throw new Error('No exchange action found');
|
|
1040
|
+
}
|
|
1041
|
+
fulfillmentActions.push({
|
|
1042
|
+
type: ActionType.TRANSACTION,
|
|
1043
|
+
buildTransaction: prepareTransaction(fulfilOrderAction.transactionMethods),
|
|
1044
|
+
purpose: TransactionPurpose.FULFILL_ORDER,
|
|
1045
|
+
});
|
|
1046
|
+
return {
|
|
1047
|
+
actions: fulfillmentActions,
|
|
1048
|
+
// return the shortest expiration out of all extraData - they should be very close
|
|
1049
|
+
expiration: fulfillOrderDetails
|
|
1050
|
+
.map((d) => Seaport.getExpirationISOTimeFromExtraData(d.extraData))
|
|
1051
|
+
.reduce((p, c) => (new Date(p) < new Date(c) ? p : c)),
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
979
1054
|
async cancelOrder(order, account) {
|
|
980
1055
|
const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
|
|
981
1056
|
const seaportLib = this.getSeaportLib(order);
|
|
@@ -999,9 +1074,7 @@ class Seaport {
|
|
|
999
1074
|
],
|
|
1000
1075
|
consideration: [
|
|
1001
1076
|
{
|
|
1002
|
-
token: considerationItem.type === 'ERC20'
|
|
1003
|
-
? considerationItem.contractAddress
|
|
1004
|
-
: undefined,
|
|
1077
|
+
token: considerationItem.type === 'ERC20' ? considerationItem.contractAddress : undefined,
|
|
1005
1078
|
amount: considerationItem.amount,
|
|
1006
1079
|
recipient: offerer,
|
|
1007
1080
|
},
|
|
@@ -1034,6 +1107,15 @@ class Seaport {
|
|
|
1034
1107
|
// }
|
|
1035
1108
|
return this.seaportLibFactory.create(seaportVersion, seaportAddress);
|
|
1036
1109
|
}
|
|
1110
|
+
static getExpirationISOTimeFromExtraData(extraData) {
|
|
1111
|
+
// Expirtaion bytes in SIP7 extra data [21:29]
|
|
1112
|
+
// In hex string -> [21 * 2 + 2 (0x) : 29 * 2]
|
|
1113
|
+
// In JS slice (start, end_inclusive), (44,60)
|
|
1114
|
+
// 8 bytes uint64 epoch time in seconds
|
|
1115
|
+
const expirationHex = extraData.slice(44, 60);
|
|
1116
|
+
const expirationInSeconds = parseInt(expirationHex, 16);
|
|
1117
|
+
return new Date(expirationInSeconds * 1000).toISOString();
|
|
1118
|
+
}
|
|
1037
1119
|
}
|
|
1038
1120
|
|
|
1039
1121
|
class ImmutableApiClient {
|
|
@@ -1332,11 +1414,29 @@ class Orderbook {
|
|
|
1332
1414
|
}
|
|
1333
1415
|
const extraData = fulfillmentDataRes.result.fulfillable_orders[0].extra_data;
|
|
1334
1416
|
const orderResult = fulfillmentDataRes.result.fulfillable_orders[0].order;
|
|
1335
|
-
if (orderResult.status !==
|
|
1417
|
+
if (orderResult.status.name !== OrderStatusName.ACTIVE) {
|
|
1336
1418
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.status}`);
|
|
1337
1419
|
}
|
|
1338
1420
|
return this.seaport.fulfillOrder(orderResult, takerAddress, extraData);
|
|
1339
1421
|
}
|
|
1422
|
+
async fulfillBulkOrders(listings, takerAddress) {
|
|
1423
|
+
const fulfillmentDataRes = await this.apiClient.fulfillmentData(listings.map((listingRequest) => ({
|
|
1424
|
+
order_id: listingRequest.listingId,
|
|
1425
|
+
fees: listingRequest.takerFees.map((fee) => ({
|
|
1426
|
+
amount: fee.amount,
|
|
1427
|
+
fee_type: FeeType.TAKER_ECOSYSTEM,
|
|
1428
|
+
recipient: fee.recipient,
|
|
1429
|
+
})),
|
|
1430
|
+
})));
|
|
1431
|
+
return {
|
|
1432
|
+
...(await this.seaport.fulfillBulkOrders(fulfillmentDataRes.result.fulfillable_orders, takerAddress)),
|
|
1433
|
+
fulfillableOrders: fulfillmentDataRes.result.fulfillable_orders.map((o) => mapFromOpenApiOrder(o.order)),
|
|
1434
|
+
unfulfillableOrders: fulfillmentDataRes.result.unfulfillable_orders.map((o) => ({
|
|
1435
|
+
orderId: o.order_id,
|
|
1436
|
+
reason: o.reason,
|
|
1437
|
+
})),
|
|
1438
|
+
};
|
|
1439
|
+
}
|
|
1340
1440
|
/**
|
|
1341
1441
|
* Get an unsigned cancel order transaction. Orders can only be cancelled by
|
|
1342
1442
|
* the account that created them.
|
|
@@ -1346,9 +1446,9 @@ class Orderbook {
|
|
|
1346
1446
|
*/
|
|
1347
1447
|
async cancelOrder(listingId, accountAddress) {
|
|
1348
1448
|
const orderResult = await this.apiClient.getListing(listingId);
|
|
1349
|
-
if (orderResult.result.status !==
|
|
1350
|
-
&& orderResult.result.status !==
|
|
1351
|
-
&& orderResult.result.status !==
|
|
1449
|
+
if (orderResult.result.status.name !== OrderStatusName.ACTIVE
|
|
1450
|
+
&& orderResult.result.status.name !== OrderStatusName.INACTIVE
|
|
1451
|
+
&& orderResult.result.status.name !== OrderStatusName.PENDING) {
|
|
1352
1452
|
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
1353
1453
|
}
|
|
1354
1454
|
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
@@ -1367,4 +1467,4 @@ const constants = {
|
|
|
1367
1467
|
estimatedFulfillmentGasGwei: ESTIMATED_FULFILLMENT_GAS_GWEI,
|
|
1368
1468
|
};
|
|
1369
1469
|
|
|
1370
|
-
export { ActionType, FeeType,
|
|
1470
|
+
export { ActionType, FeeType, OrderStatusName, Orderbook, SignablePurpose, TransactionPurpose, constants };
|