@imtbl/sdk 0.28.3-alpha.1 → 0.28.4
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 +4 -0
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +7430 -8261
- package/dist/checkout_sdk.js +2725 -2994
- package/dist/checkout_widgets.d.ts +25583 -0
- package/dist/checkout_widgets.js +449 -0
- package/dist/config.d.ts +4 -0
- package/dist/config.js +22 -1
- package/dist/immutablex_client.d.ts +811 -1128
- package/dist/immutablex_client.js +5 -4
- package/dist/index.browser.js +51 -42
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3320 -3082
- package/dist/index.d.ts +16311 -2137
- package/dist/index.js +3321 -3084
- package/dist/orderbook.d.ts +113 -65
- package/dist/orderbook.js +101 -20
- package/dist/passport.d.ts +859 -1136
- package/dist/passport.js +96 -48
- package/dist/provider.d.ts +4 -0
- package/dist/provider.js +3 -0
- package/package.json +7 -18
- package/dist/browser/checkout/sdk.js +0 -35
- package/dist/browser/checkout/widgets.js +0 -890
package/dist/orderbook.d.ts
CHANGED
|
@@ -5,10 +5,14 @@ declare enum Environment {
|
|
|
5
5
|
}
|
|
6
6
|
declare class ImmutableConfiguration {
|
|
7
7
|
readonly environment: Environment;
|
|
8
|
+
readonly rateLimitingKey?: string;
|
|
8
9
|
readonly apiKey?: string;
|
|
10
|
+
readonly clientAppId?: string;
|
|
9
11
|
constructor(options: {
|
|
10
12
|
environment: Environment;
|
|
13
|
+
rateLimitingKey?: string;
|
|
11
14
|
apiKey?: string;
|
|
15
|
+
clientAppId?: string;
|
|
12
16
|
});
|
|
13
17
|
}
|
|
14
18
|
interface ModuleConfiguration<T> {
|
|
@@ -595,53 +599,6 @@ interface OrderbookModuleConfiguration {
|
|
|
595
599
|
provider: JsonRpcProvider | Web3Provider;
|
|
596
600
|
}
|
|
597
601
|
|
|
598
|
-
declare enum OrderType {
|
|
599
|
-
FULL_OPEN = 0,
|
|
600
|
-
PARTIAL_OPEN = 1,
|
|
601
|
-
FULL_RESTRICTED = 2,
|
|
602
|
-
PARTIAL_RESTRICTED = 3
|
|
603
|
-
}
|
|
604
|
-
declare enum ItemType {
|
|
605
|
-
NATIVE = 0,
|
|
606
|
-
ERC20 = 1,
|
|
607
|
-
ERC721 = 2,
|
|
608
|
-
ERC1155 = 3,
|
|
609
|
-
ERC721_WITH_CRITERIA = 4,
|
|
610
|
-
ERC1155_WITH_CRITERIA = 5
|
|
611
|
-
}
|
|
612
|
-
|
|
613
|
-
type OfferItem = {
|
|
614
|
-
itemType: ItemType;
|
|
615
|
-
token: string;
|
|
616
|
-
identifierOrCriteria: string;
|
|
617
|
-
startAmount: string;
|
|
618
|
-
endAmount: string;
|
|
619
|
-
};
|
|
620
|
-
type ConsiderationItem = {
|
|
621
|
-
itemType: ItemType;
|
|
622
|
-
token: string;
|
|
623
|
-
identifierOrCriteria: string;
|
|
624
|
-
startAmount: string;
|
|
625
|
-
endAmount: string;
|
|
626
|
-
recipient: string;
|
|
627
|
-
};
|
|
628
|
-
type OrderParameters = {
|
|
629
|
-
offerer: string;
|
|
630
|
-
zone: string;
|
|
631
|
-
orderType: OrderType;
|
|
632
|
-
startTime: BigNumberish;
|
|
633
|
-
endTime: BigNumberish;
|
|
634
|
-
zoneHash: string;
|
|
635
|
-
salt: string;
|
|
636
|
-
offer: OfferItem[];
|
|
637
|
-
consideration: ConsiderationItem[];
|
|
638
|
-
totalOriginalConsiderationItems: BigNumberish;
|
|
639
|
-
conduitKey: string;
|
|
640
|
-
};
|
|
641
|
-
type OrderComponents = OrderParameters & {
|
|
642
|
-
counter: BigNumberish;
|
|
643
|
-
};
|
|
644
|
-
|
|
645
602
|
type ApiRequestOptions = {
|
|
646
603
|
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
647
604
|
readonly url: string;
|
|
@@ -729,7 +686,7 @@ declare namespace FailedOrderCancellation {
|
|
|
729
686
|
* Reason code indicating why the order failed to be cancelled
|
|
730
687
|
*/
|
|
731
688
|
enum reason_code {
|
|
732
|
-
|
|
689
|
+
FILLED = "FILLED"
|
|
733
690
|
}
|
|
734
691
|
}
|
|
735
692
|
|
|
@@ -907,20 +864,20 @@ type Chain = {
|
|
|
907
864
|
|
|
908
865
|
type ActiveOrderStatus = {
|
|
909
866
|
/**
|
|
910
|
-
* The order status
|
|
867
|
+
* The order status that indicates an order can be fulfilled.
|
|
911
868
|
*/
|
|
912
869
|
name: 'ACTIVE';
|
|
913
870
|
};
|
|
914
871
|
|
|
915
872
|
type CancelledOrderStatus = {
|
|
916
873
|
/**
|
|
917
|
-
* The order status
|
|
874
|
+
* The order status indicating a order is has been cancelled or about to be cancelled.
|
|
918
875
|
*/
|
|
919
876
|
name: 'CANCELLED';
|
|
920
877
|
/**
|
|
921
878
|
* Whether the cancellation of the order is pending
|
|
922
879
|
*/
|
|
923
|
-
|
|
880
|
+
pending: boolean;
|
|
924
881
|
/**
|
|
925
882
|
* Whether the cancellation was done on-chain or off-chain
|
|
926
883
|
*/
|
|
@@ -938,30 +895,46 @@ declare namespace CancelledOrderStatus {
|
|
|
938
895
|
|
|
939
896
|
type ExpiredOrderStatus = {
|
|
940
897
|
/**
|
|
941
|
-
*
|
|
898
|
+
* A terminal order status indicating that an order cannot be fulfilled due to expiry.
|
|
942
899
|
*/
|
|
943
900
|
name: 'EXPIRED';
|
|
944
901
|
};
|
|
945
902
|
|
|
946
903
|
type FilledOrderStatus = {
|
|
947
904
|
/**
|
|
948
|
-
*
|
|
905
|
+
* A terminal order status indicating that an order has been fulfilled.
|
|
949
906
|
*/
|
|
950
907
|
name: 'FILLED';
|
|
951
908
|
};
|
|
952
909
|
|
|
953
910
|
type InactiveOrderStatus = {
|
|
954
911
|
/**
|
|
955
|
-
* The order status
|
|
912
|
+
* The order status that indicates an order cannot be fulfilled.
|
|
956
913
|
*/
|
|
957
914
|
name: 'INACTIVE';
|
|
915
|
+
/**
|
|
916
|
+
* Whether the order offerer has sufficient approvals
|
|
917
|
+
*/
|
|
918
|
+
sufficient_approvals: boolean;
|
|
919
|
+
/**
|
|
920
|
+
* Whether the order offerer still has sufficient balance to complete the order
|
|
921
|
+
*/
|
|
922
|
+
sufficient_balances: boolean;
|
|
958
923
|
};
|
|
959
924
|
|
|
960
925
|
type PendingOrderStatus = {
|
|
961
926
|
/**
|
|
962
|
-
* The order status
|
|
927
|
+
* The order status that indicates the order is yet to be active due to various reasons.
|
|
963
928
|
*/
|
|
964
929
|
name: 'PENDING';
|
|
930
|
+
/**
|
|
931
|
+
* Whether the order has been evaluated after its creation
|
|
932
|
+
*/
|
|
933
|
+
evaluated: boolean;
|
|
934
|
+
/**
|
|
935
|
+
* Whether the order has reached its specified start time
|
|
936
|
+
*/
|
|
937
|
+
started: boolean;
|
|
965
938
|
};
|
|
966
939
|
|
|
967
940
|
/**
|
|
@@ -1266,6 +1239,53 @@ declare class OrdersService {
|
|
|
1266
1239
|
}): CancelablePromise<TradeResult$1>;
|
|
1267
1240
|
}
|
|
1268
1241
|
|
|
1242
|
+
declare enum OrderType {
|
|
1243
|
+
FULL_OPEN = 0,
|
|
1244
|
+
PARTIAL_OPEN = 1,
|
|
1245
|
+
FULL_RESTRICTED = 2,
|
|
1246
|
+
PARTIAL_RESTRICTED = 3
|
|
1247
|
+
}
|
|
1248
|
+
declare enum ItemType {
|
|
1249
|
+
NATIVE = 0,
|
|
1250
|
+
ERC20 = 1,
|
|
1251
|
+
ERC721 = 2,
|
|
1252
|
+
ERC1155 = 3,
|
|
1253
|
+
ERC721_WITH_CRITERIA = 4,
|
|
1254
|
+
ERC1155_WITH_CRITERIA = 5
|
|
1255
|
+
}
|
|
1256
|
+
|
|
1257
|
+
type OfferItem = {
|
|
1258
|
+
itemType: ItemType;
|
|
1259
|
+
token: string;
|
|
1260
|
+
identifierOrCriteria: string;
|
|
1261
|
+
startAmount: string;
|
|
1262
|
+
endAmount: string;
|
|
1263
|
+
};
|
|
1264
|
+
type ConsiderationItem = {
|
|
1265
|
+
itemType: ItemType;
|
|
1266
|
+
token: string;
|
|
1267
|
+
identifierOrCriteria: string;
|
|
1268
|
+
startAmount: string;
|
|
1269
|
+
endAmount: string;
|
|
1270
|
+
recipient: string;
|
|
1271
|
+
};
|
|
1272
|
+
type OrderParameters = {
|
|
1273
|
+
offerer: string;
|
|
1274
|
+
zone: string;
|
|
1275
|
+
orderType: OrderType;
|
|
1276
|
+
startTime: BigNumberish;
|
|
1277
|
+
endTime: BigNumberish;
|
|
1278
|
+
zoneHash: string;
|
|
1279
|
+
salt: string;
|
|
1280
|
+
offer: OfferItem[];
|
|
1281
|
+
consideration: ConsiderationItem[];
|
|
1282
|
+
totalOriginalConsiderationItems: BigNumberish;
|
|
1283
|
+
conduitKey: string;
|
|
1284
|
+
};
|
|
1285
|
+
type OrderComponents = OrderParameters & {
|
|
1286
|
+
counter: BigNumberish;
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1269
1289
|
interface ERC721Item {
|
|
1270
1290
|
type: 'ERC721';
|
|
1271
1291
|
contractAddress: string;
|
|
@@ -1295,6 +1315,9 @@ interface PrepareListingResponse {
|
|
|
1295
1315
|
orderComponents: OrderComponents;
|
|
1296
1316
|
orderHash: string;
|
|
1297
1317
|
}
|
|
1318
|
+
interface PrepareCancelOrdersResponse {
|
|
1319
|
+
signableAction: SignableAction;
|
|
1320
|
+
}
|
|
1298
1321
|
interface CreateListingParams {
|
|
1299
1322
|
orderComponents: OrderComponents;
|
|
1300
1323
|
orderHash: string;
|
|
@@ -1318,10 +1341,12 @@ interface Fee extends FeeValue {
|
|
|
1318
1341
|
}
|
|
1319
1342
|
declare enum TransactionPurpose {
|
|
1320
1343
|
APPROVAL = "APPROVAL",
|
|
1321
|
-
FULFILL_ORDER = "FULFILL_ORDER"
|
|
1344
|
+
FULFILL_ORDER = "FULFILL_ORDER",
|
|
1345
|
+
CANCEL = "CANCEL"
|
|
1322
1346
|
}
|
|
1323
1347
|
declare enum SignablePurpose {
|
|
1324
|
-
CREATE_LISTING = "CREATE_LISTING"
|
|
1348
|
+
CREATE_LISTING = "CREATE_LISTING",
|
|
1349
|
+
OFF_CHAIN_CANCELLATION = "OFF_CHAIN_CANCELLATION"
|
|
1325
1350
|
}
|
|
1326
1351
|
declare enum ActionType {
|
|
1327
1352
|
TRANSACTION = "TRANSACTION",
|
|
@@ -1373,8 +1398,8 @@ interface FulfillOrderResponse {
|
|
|
1373
1398
|
expiration: string;
|
|
1374
1399
|
order: Order;
|
|
1375
1400
|
}
|
|
1376
|
-
interface
|
|
1377
|
-
|
|
1401
|
+
interface CancelOrdersOnChainResponse {
|
|
1402
|
+
cancellationAction: TransactionAction;
|
|
1378
1403
|
}
|
|
1379
1404
|
interface Order {
|
|
1380
1405
|
id: string;
|
|
@@ -1536,17 +1561,40 @@ declare class Orderbook {
|
|
|
1536
1561
|
fulfillOrder(listingId: string, takerAddress: string, takerFees: FeeValue[]): Promise<FulfillOrderResponse>;
|
|
1537
1562
|
fulfillBulkOrders(listings: Array<FulfillmentListing>, takerAddress: string): Promise<FulfillBulkOrdersResponse>;
|
|
1538
1563
|
/**
|
|
1539
|
-
*
|
|
1540
|
-
* the
|
|
1541
|
-
*
|
|
1564
|
+
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
1565
|
+
* `cancelOrdersOnChain`. For the orderbook to authenticate the cancellation, the creator
|
|
1566
|
+
* of the orders must sign an EIP712 message containing the orderIds
|
|
1567
|
+
* @param {string} orderIds - The orderIds to attempt to cancel.
|
|
1568
|
+
* @return {PrepareCancelOrdersResponse} The signable action to cancel the orders.
|
|
1569
|
+
*/
|
|
1570
|
+
prepareOrderCancellations(orderIds: string[]): Promise<PrepareCancelOrdersResponse>;
|
|
1571
|
+
/**
|
|
1572
|
+
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
1573
|
+
* `cancelOrdersOnChain`. Orders cancelled this way cannot be fulfilled and will be removed
|
|
1574
|
+
* from the orderbook. If there is pending fulfillment data outstanding for the order, its
|
|
1575
|
+
* cancellation will be pending until the fulfillment window has passed.
|
|
1576
|
+
* `prepareOffchainOrderCancellations` can be used to get the signable action that is signed
|
|
1577
|
+
* to get the signature required for this call.
|
|
1578
|
+
* @param {string[]} orderIds - The orderIds to attempt to cancel.
|
|
1579
|
+
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
1580
|
+
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
1581
|
+
* @return {CancelOrdersResult} The result of the off-chain cancellation request
|
|
1582
|
+
*/
|
|
1583
|
+
cancelOrders(orderIds: string[], accountAddress: string, signature: string): Promise<CancelOrdersResult>;
|
|
1584
|
+
/**
|
|
1585
|
+
* Get an unsigned order cancellation transaction. Orders can only be cancelled by
|
|
1586
|
+
* the account that created them. All of the orders must be from the same seaport contract.
|
|
1587
|
+
* If trying to cancel orders from multiple seaport contracts, group the orderIds by seaport
|
|
1588
|
+
* contract and call this method for each group.
|
|
1589
|
+
* @param {string[]} orderIds - The orderIds to cancel.
|
|
1542
1590
|
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
1543
|
-
* @return {
|
|
1591
|
+
* @return {CancelOrdersOnChainResponse} The unsigned cancel order action
|
|
1544
1592
|
*/
|
|
1545
|
-
|
|
1593
|
+
cancelOrdersOnChain(orderIds: string[], accountAddress: string): Promise<CancelOrdersOnChainResponse>;
|
|
1546
1594
|
}
|
|
1547
1595
|
|
|
1548
1596
|
declare const constants: {
|
|
1549
1597
|
estimatedFulfillmentGasGwei: number;
|
|
1550
1598
|
};
|
|
1551
1599
|
|
|
1552
|
-
export { Action, ActionType,
|
|
1600
|
+
export { Action, ActionType, CancelOrdersOnChainResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillBulkOrdersInsufficientBalanceResponse, FulfillBulkOrdersResponse, FulfillBulkOrdersSufficientBalanceResponse, FulfillOrderResponse, FulfillmentListing, ListListingsParams, ListListingsResult, ListTradesParams, ListTradesResult, ListingResult, NativeItem, Order, OrderStatusName, Orderbook, Page, PrepareCancelOrdersResponse, PrepareListingParams, PrepareListingResponse, RoyaltyInfo, SignableAction, SignablePurpose, Trade, TradeResult, TransactionAction, TransactionBuilder, TransactionPurpose, UnfulfillableOrder, constants };
|
package/dist/orderbook.js
CHANGED
|
@@ -606,7 +606,7 @@ var CancelledOrderStatus;
|
|
|
606
606
|
var FailedOrderCancellation;
|
|
607
607
|
(function (FailedOrderCancellation) {
|
|
608
608
|
(function (reason_code) {
|
|
609
|
-
reason_code["
|
|
609
|
+
reason_code["FILLED"] = "FILLED";
|
|
610
610
|
})(FailedOrderCancellation.reason_code || (FailedOrderCancellation.reason_code = {}));
|
|
611
611
|
})(FailedOrderCancellation || (FailedOrderCancellation = {}));
|
|
612
612
|
|
|
@@ -660,10 +660,12 @@ var TransactionPurpose;
|
|
|
660
660
|
(function (TransactionPurpose) {
|
|
661
661
|
TransactionPurpose["APPROVAL"] = "APPROVAL";
|
|
662
662
|
TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
|
|
663
|
+
TransactionPurpose["CANCEL"] = "CANCEL";
|
|
663
664
|
})(TransactionPurpose || (TransactionPurpose = {}));
|
|
664
665
|
var SignablePurpose;
|
|
665
666
|
(function (SignablePurpose) {
|
|
666
667
|
SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
|
|
668
|
+
SignablePurpose["OFF_CHAIN_CANCELLATION"] = "OFF_CHAIN_CANCELLATION";
|
|
667
669
|
})(SignablePurpose || (SignablePurpose = {}));
|
|
668
670
|
var ActionType;
|
|
669
671
|
(function (ActionType) {
|
|
@@ -1060,11 +1062,15 @@ class Seaport {
|
|
|
1060
1062
|
.reduce((p, c) => (new Date(p) < new Date(c) ? p : c)),
|
|
1061
1063
|
};
|
|
1062
1064
|
}
|
|
1063
|
-
async
|
|
1064
|
-
const
|
|
1065
|
-
const seaportLib = this.getSeaportLib(
|
|
1066
|
-
const cancellationTransaction = await seaportLib.cancelOrders(
|
|
1067
|
-
return
|
|
1065
|
+
async cancelOrders(orders, account) {
|
|
1066
|
+
const orderComponents = orders.map((order) => this.mapImmutableOrderToSeaportOrderComponents(order).orderComponents);
|
|
1067
|
+
const seaportLib = this.getSeaportLib(orders[0]);
|
|
1068
|
+
const cancellationTransaction = await seaportLib.cancelOrders(orderComponents, account);
|
|
1069
|
+
return {
|
|
1070
|
+
type: ActionType.TRANSACTION,
|
|
1071
|
+
buildTransaction: prepareTransaction(cancellationTransaction),
|
|
1072
|
+
purpose: TransactionPurpose.CANCEL,
|
|
1073
|
+
};
|
|
1068
1074
|
}
|
|
1069
1075
|
mapImmutableOrderToSeaportOrderComponents(order) {
|
|
1070
1076
|
const orderCounter = order.protocol_data.counter;
|
|
@@ -1166,6 +1172,16 @@ class ImmutableApiClient {
|
|
|
1166
1172
|
...listTradesParams,
|
|
1167
1173
|
});
|
|
1168
1174
|
}
|
|
1175
|
+
async cancelOrders(orderIds, accountAddress, signature) {
|
|
1176
|
+
return this.orderbookService.cancelOrders({
|
|
1177
|
+
chainName: this.chainName,
|
|
1178
|
+
requestBody: {
|
|
1179
|
+
account_address: accountAddress,
|
|
1180
|
+
orders: orderIds,
|
|
1181
|
+
signature,
|
|
1182
|
+
},
|
|
1183
|
+
});
|
|
1184
|
+
}
|
|
1169
1185
|
async createListing({ orderHash, orderComponents, orderSignature, makerFees, }) {
|
|
1170
1186
|
if (orderComponents.offer.length !== 1) {
|
|
1171
1187
|
throw new Error('Only one item can be listed at a time');
|
|
@@ -1467,24 +1483,89 @@ class Orderbook {
|
|
|
1467
1483
|
}
|
|
1468
1484
|
}
|
|
1469
1485
|
/**
|
|
1470
|
-
*
|
|
1471
|
-
* the
|
|
1472
|
-
*
|
|
1486
|
+
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
1487
|
+
* `cancelOrdersOnChain`. For the orderbook to authenticate the cancellation, the creator
|
|
1488
|
+
* of the orders must sign an EIP712 message containing the orderIds
|
|
1489
|
+
* @param {string} orderIds - The orderIds to attempt to cancel.
|
|
1490
|
+
* @return {PrepareCancelOrdersResponse} The signable action to cancel the orders.
|
|
1491
|
+
*/
|
|
1492
|
+
async prepareOrderCancellations(orderIds) {
|
|
1493
|
+
const network = await this.orderbookConfig.provider.getNetwork();
|
|
1494
|
+
const domain = {
|
|
1495
|
+
name: 'imtbl-order-book',
|
|
1496
|
+
chainId: network.chainId,
|
|
1497
|
+
verifyingContract: this.orderbookConfig.seaportContractAddress,
|
|
1498
|
+
};
|
|
1499
|
+
const types = {
|
|
1500
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1501
|
+
CancelPayload: [
|
|
1502
|
+
{ name: 'orders', type: 'Order[]' },
|
|
1503
|
+
],
|
|
1504
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1505
|
+
Order: [
|
|
1506
|
+
{ name: 'id', type: 'string' },
|
|
1507
|
+
],
|
|
1508
|
+
};
|
|
1509
|
+
const cancelMessage = {
|
|
1510
|
+
orders: orderIds.map((id) => ({ id })),
|
|
1511
|
+
};
|
|
1512
|
+
return {
|
|
1513
|
+
signableAction: {
|
|
1514
|
+
purpose: SignablePurpose.OFF_CHAIN_CANCELLATION,
|
|
1515
|
+
type: ActionType.SIGNABLE,
|
|
1516
|
+
message: {
|
|
1517
|
+
domain,
|
|
1518
|
+
types,
|
|
1519
|
+
value: cancelMessage,
|
|
1520
|
+
},
|
|
1521
|
+
},
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
1526
|
+
* `cancelOrdersOnChain`. Orders cancelled this way cannot be fulfilled and will be removed
|
|
1527
|
+
* from the orderbook. If there is pending fulfillment data outstanding for the order, its
|
|
1528
|
+
* cancellation will be pending until the fulfillment window has passed.
|
|
1529
|
+
* `prepareOffchainOrderCancellations` can be used to get the signable action that is signed
|
|
1530
|
+
* to get the signature required for this call.
|
|
1531
|
+
* @param {string[]} orderIds - The orderIds to attempt to cancel.
|
|
1532
|
+
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
1533
|
+
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
1534
|
+
* @return {CancelOrdersResult} The result of the off-chain cancellation request
|
|
1535
|
+
*/
|
|
1536
|
+
async cancelOrders(orderIds, accountAddress, signature) {
|
|
1537
|
+
return this.apiClient.cancelOrders(orderIds, accountAddress, signature);
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Get an unsigned order cancellation transaction. Orders can only be cancelled by
|
|
1541
|
+
* the account that created them. All of the orders must be from the same seaport contract.
|
|
1542
|
+
* If trying to cancel orders from multiple seaport contracts, group the orderIds by seaport
|
|
1543
|
+
* contract and call this method for each group.
|
|
1544
|
+
* @param {string[]} orderIds - The orderIds to cancel.
|
|
1473
1545
|
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
1474
|
-
* @return {
|
|
1546
|
+
* @return {CancelOrdersOnChainResponse} The unsigned cancel order action
|
|
1475
1547
|
*/
|
|
1476
|
-
async
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1548
|
+
async cancelOrdersOnChain(orderIds, accountAddress) {
|
|
1549
|
+
const orderResults = await Promise.all(orderIds.map((id) => this.apiClient.getListing(id)));
|
|
1550
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
1551
|
+
for (const orderResult of orderResults) {
|
|
1552
|
+
if (orderResult.result.status.name !== OrderStatusName.ACTIVE
|
|
1553
|
+
&& orderResult.result.status.name !== OrderStatusName.INACTIVE
|
|
1554
|
+
&& orderResult.result.status.name !== OrderStatusName.PENDING) {
|
|
1555
|
+
throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
|
|
1556
|
+
}
|
|
1557
|
+
if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
|
|
1558
|
+
throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${orderResult.result.id}`);
|
|
1559
|
+
}
|
|
1482
1560
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1561
|
+
const orders = orderResults.map((orderResult) => orderResult.result);
|
|
1562
|
+
const seaportAddresses = orders.map((o) => o.protocol_data.seaport_address);
|
|
1563
|
+
const distinctSeaportAddresses = new Set(...[seaportAddresses]);
|
|
1564
|
+
if (distinctSeaportAddresses.size !== 1) {
|
|
1565
|
+
throw new Error('Cannot cancel multiple orders from different seaport contracts. Please group your orderIds accordingly');
|
|
1485
1566
|
}
|
|
1486
|
-
const
|
|
1487
|
-
return {
|
|
1567
|
+
const cancellationAction = await this.seaport.cancelOrders(orders, accountAddress);
|
|
1568
|
+
return { cancellationAction };
|
|
1488
1569
|
}
|
|
1489
1570
|
}
|
|
1490
1571
|
|