@imtbl/sdk 0.27.15-alpha.5 → 0.27.15-alpha.6
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.js +1 -1
- package/dist/browser/checkout.js +2 -0
- package/dist/checkout_sdk.d.ts +7897 -8395
- package/dist/checkout_sdk.js +2698 -2964
- package/dist/checkout_widgets.d.ts +25860 -0
- package/dist/checkout_widgets.js +449 -0
- package/dist/immutablex_client.js +4 -4
- package/dist/index.browser.js +18 -9
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +3229 -3016
- package/dist/index.d.ts +15515 -1002
- package/dist/index.js +3230 -3018
- package/dist/orderbook.d.ts +109 -65
- package/dist/orderbook.js +101 -20
- package/dist/passport.js +39 -17
- package/package.json +6 -17
- package/dist/browser/checkout/sdk.js +0 -35
- package/dist/browser/checkout/widgets.js +0 -890
package/dist/orderbook.d.ts
CHANGED
|
@@ -595,53 +595,6 @@ interface OrderbookModuleConfiguration {
|
|
|
595
595
|
provider: JsonRpcProvider | Web3Provider;
|
|
596
596
|
}
|
|
597
597
|
|
|
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
598
|
type ApiRequestOptions = {
|
|
646
599
|
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
|
|
647
600
|
readonly url: string;
|
|
@@ -729,7 +682,7 @@ declare namespace FailedOrderCancellation {
|
|
|
729
682
|
* Reason code indicating why the order failed to be cancelled
|
|
730
683
|
*/
|
|
731
684
|
enum reason_code {
|
|
732
|
-
|
|
685
|
+
FILLED = "FILLED"
|
|
733
686
|
}
|
|
734
687
|
}
|
|
735
688
|
|
|
@@ -907,20 +860,20 @@ type Chain = {
|
|
|
907
860
|
|
|
908
861
|
type ActiveOrderStatus = {
|
|
909
862
|
/**
|
|
910
|
-
* The order status
|
|
863
|
+
* The order status that indicates an order can be fulfilled.
|
|
911
864
|
*/
|
|
912
865
|
name: 'ACTIVE';
|
|
913
866
|
};
|
|
914
867
|
|
|
915
868
|
type CancelledOrderStatus = {
|
|
916
869
|
/**
|
|
917
|
-
* The order status
|
|
870
|
+
* The order status indicating a order is has been cancelled or about to be cancelled.
|
|
918
871
|
*/
|
|
919
872
|
name: 'CANCELLED';
|
|
920
873
|
/**
|
|
921
874
|
* Whether the cancellation of the order is pending
|
|
922
875
|
*/
|
|
923
|
-
|
|
876
|
+
pending: boolean;
|
|
924
877
|
/**
|
|
925
878
|
* Whether the cancellation was done on-chain or off-chain
|
|
926
879
|
*/
|
|
@@ -938,30 +891,46 @@ declare namespace CancelledOrderStatus {
|
|
|
938
891
|
|
|
939
892
|
type ExpiredOrderStatus = {
|
|
940
893
|
/**
|
|
941
|
-
*
|
|
894
|
+
* A terminal order status indicating that an order cannot be fulfilled due to expiry.
|
|
942
895
|
*/
|
|
943
896
|
name: 'EXPIRED';
|
|
944
897
|
};
|
|
945
898
|
|
|
946
899
|
type FilledOrderStatus = {
|
|
947
900
|
/**
|
|
948
|
-
*
|
|
901
|
+
* A terminal order status indicating that an order has been fulfilled.
|
|
949
902
|
*/
|
|
950
903
|
name: 'FILLED';
|
|
951
904
|
};
|
|
952
905
|
|
|
953
906
|
type InactiveOrderStatus = {
|
|
954
907
|
/**
|
|
955
|
-
* The order status
|
|
908
|
+
* The order status that indicates an order cannot be fulfilled.
|
|
956
909
|
*/
|
|
957
910
|
name: 'INACTIVE';
|
|
911
|
+
/**
|
|
912
|
+
* Whether the order offerer has sufficient approvals
|
|
913
|
+
*/
|
|
914
|
+
sufficient_approvals: boolean;
|
|
915
|
+
/**
|
|
916
|
+
* Whether the order offerer still has sufficient balance to complete the order
|
|
917
|
+
*/
|
|
918
|
+
sufficient_balances: boolean;
|
|
958
919
|
};
|
|
959
920
|
|
|
960
921
|
type PendingOrderStatus = {
|
|
961
922
|
/**
|
|
962
|
-
* The order status
|
|
923
|
+
* The order status that indicates the order is yet to be active due to various reasons.
|
|
963
924
|
*/
|
|
964
925
|
name: 'PENDING';
|
|
926
|
+
/**
|
|
927
|
+
* Whether the order has been evaluated after its creation
|
|
928
|
+
*/
|
|
929
|
+
evaluated: boolean;
|
|
930
|
+
/**
|
|
931
|
+
* Whether the order has reached its specified start time
|
|
932
|
+
*/
|
|
933
|
+
started: boolean;
|
|
965
934
|
};
|
|
966
935
|
|
|
967
936
|
/**
|
|
@@ -1266,6 +1235,53 @@ declare class OrdersService {
|
|
|
1266
1235
|
}): CancelablePromise<TradeResult$1>;
|
|
1267
1236
|
}
|
|
1268
1237
|
|
|
1238
|
+
declare enum OrderType {
|
|
1239
|
+
FULL_OPEN = 0,
|
|
1240
|
+
PARTIAL_OPEN = 1,
|
|
1241
|
+
FULL_RESTRICTED = 2,
|
|
1242
|
+
PARTIAL_RESTRICTED = 3
|
|
1243
|
+
}
|
|
1244
|
+
declare enum ItemType {
|
|
1245
|
+
NATIVE = 0,
|
|
1246
|
+
ERC20 = 1,
|
|
1247
|
+
ERC721 = 2,
|
|
1248
|
+
ERC1155 = 3,
|
|
1249
|
+
ERC721_WITH_CRITERIA = 4,
|
|
1250
|
+
ERC1155_WITH_CRITERIA = 5
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
type OfferItem = {
|
|
1254
|
+
itemType: ItemType;
|
|
1255
|
+
token: string;
|
|
1256
|
+
identifierOrCriteria: string;
|
|
1257
|
+
startAmount: string;
|
|
1258
|
+
endAmount: string;
|
|
1259
|
+
};
|
|
1260
|
+
type ConsiderationItem = {
|
|
1261
|
+
itemType: ItemType;
|
|
1262
|
+
token: string;
|
|
1263
|
+
identifierOrCriteria: string;
|
|
1264
|
+
startAmount: string;
|
|
1265
|
+
endAmount: string;
|
|
1266
|
+
recipient: string;
|
|
1267
|
+
};
|
|
1268
|
+
type OrderParameters = {
|
|
1269
|
+
offerer: string;
|
|
1270
|
+
zone: string;
|
|
1271
|
+
orderType: OrderType;
|
|
1272
|
+
startTime: BigNumberish;
|
|
1273
|
+
endTime: BigNumberish;
|
|
1274
|
+
zoneHash: string;
|
|
1275
|
+
salt: string;
|
|
1276
|
+
offer: OfferItem[];
|
|
1277
|
+
consideration: ConsiderationItem[];
|
|
1278
|
+
totalOriginalConsiderationItems: BigNumberish;
|
|
1279
|
+
conduitKey: string;
|
|
1280
|
+
};
|
|
1281
|
+
type OrderComponents = OrderParameters & {
|
|
1282
|
+
counter: BigNumberish;
|
|
1283
|
+
};
|
|
1284
|
+
|
|
1269
1285
|
interface ERC721Item {
|
|
1270
1286
|
type: 'ERC721';
|
|
1271
1287
|
contractAddress: string;
|
|
@@ -1295,6 +1311,9 @@ interface PrepareListingResponse {
|
|
|
1295
1311
|
orderComponents: OrderComponents;
|
|
1296
1312
|
orderHash: string;
|
|
1297
1313
|
}
|
|
1314
|
+
interface PrepareCancelOrdersResponse {
|
|
1315
|
+
signableAction: SignableAction;
|
|
1316
|
+
}
|
|
1298
1317
|
interface CreateListingParams {
|
|
1299
1318
|
orderComponents: OrderComponents;
|
|
1300
1319
|
orderHash: string;
|
|
@@ -1318,10 +1337,12 @@ interface Fee extends FeeValue {
|
|
|
1318
1337
|
}
|
|
1319
1338
|
declare enum TransactionPurpose {
|
|
1320
1339
|
APPROVAL = "APPROVAL",
|
|
1321
|
-
FULFILL_ORDER = "FULFILL_ORDER"
|
|
1340
|
+
FULFILL_ORDER = "FULFILL_ORDER",
|
|
1341
|
+
CANCEL = "CANCEL"
|
|
1322
1342
|
}
|
|
1323
1343
|
declare enum SignablePurpose {
|
|
1324
|
-
CREATE_LISTING = "CREATE_LISTING"
|
|
1344
|
+
CREATE_LISTING = "CREATE_LISTING",
|
|
1345
|
+
OFF_CHAIN_CANCELLATION = "OFF_CHAIN_CANCELLATION"
|
|
1325
1346
|
}
|
|
1326
1347
|
declare enum ActionType {
|
|
1327
1348
|
TRANSACTION = "TRANSACTION",
|
|
@@ -1373,8 +1394,8 @@ interface FulfillOrderResponse {
|
|
|
1373
1394
|
expiration: string;
|
|
1374
1395
|
order: Order;
|
|
1375
1396
|
}
|
|
1376
|
-
interface
|
|
1377
|
-
|
|
1397
|
+
interface CancelOrdersOnChainResponse {
|
|
1398
|
+
cancellationAction: TransactionAction;
|
|
1378
1399
|
}
|
|
1379
1400
|
interface Order {
|
|
1380
1401
|
id: string;
|
|
@@ -1536,17 +1557,40 @@ declare class Orderbook {
|
|
|
1536
1557
|
fulfillOrder(listingId: string, takerAddress: string, takerFees: FeeValue[]): Promise<FulfillOrderResponse>;
|
|
1537
1558
|
fulfillBulkOrders(listings: Array<FulfillmentListing>, takerAddress: string): Promise<FulfillBulkOrdersResponse>;
|
|
1538
1559
|
/**
|
|
1539
|
-
*
|
|
1540
|
-
* the
|
|
1541
|
-
*
|
|
1560
|
+
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
1561
|
+
* `cancelOrdersOnChain`. For the orderbook to authenticate the cancellation, the creator
|
|
1562
|
+
* of the orders must sign an EIP712 message containing the orderIds
|
|
1563
|
+
* @param {string} orderIds - The orderIds to attempt to cancel.
|
|
1564
|
+
* @return {PrepareCancelOrdersResponse} The signable action to cancel the orders.
|
|
1565
|
+
*/
|
|
1566
|
+
prepareOrderCancellations(orderIds: string[]): Promise<PrepareCancelOrdersResponse>;
|
|
1567
|
+
/**
|
|
1568
|
+
* Cancelling orders is a gasless alternative to on-chain cancellation exposed with
|
|
1569
|
+
* `cancelOrdersOnChain`. Orders cancelled this way cannot be fulfilled and will be removed
|
|
1570
|
+
* from the orderbook. If there is pending fulfillment data outstanding for the order, its
|
|
1571
|
+
* cancellation will be pending until the fulfillment window has passed.
|
|
1572
|
+
* `prepareOffchainOrderCancellations` can be used to get the signable action that is signed
|
|
1573
|
+
* to get the signature required for this call.
|
|
1574
|
+
* @param {string[]} orderIds - The orderIds to attempt to cancel.
|
|
1575
|
+
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
1576
|
+
* @param {string} accountAddress - The address of the account cancelling the orders.
|
|
1577
|
+
* @return {CancelOrdersResult} The result of the off-chain cancellation request
|
|
1578
|
+
*/
|
|
1579
|
+
cancelOrders(orderIds: string[], accountAddress: string, signature: string): Promise<CancelOrdersResult>;
|
|
1580
|
+
/**
|
|
1581
|
+
* Get an unsigned order cancellation transaction. Orders can only be cancelled by
|
|
1582
|
+
* the account that created them. All of the orders must be from the same seaport contract.
|
|
1583
|
+
* If trying to cancel orders from multiple seaport contracts, group the orderIds by seaport
|
|
1584
|
+
* contract and call this method for each group.
|
|
1585
|
+
* @param {string[]} orderIds - The orderIds to cancel.
|
|
1542
1586
|
* @param {string} accountAddress - The address of the account cancelling the order.
|
|
1543
|
-
* @return {
|
|
1587
|
+
* @return {CancelOrdersOnChainResponse} The unsigned cancel order action
|
|
1544
1588
|
*/
|
|
1545
|
-
|
|
1589
|
+
cancelOrdersOnChain(orderIds: string[], accountAddress: string): Promise<CancelOrdersOnChainResponse>;
|
|
1546
1590
|
}
|
|
1547
1591
|
|
|
1548
1592
|
declare const constants: {
|
|
1549
1593
|
estimatedFulfillmentGasGwei: number;
|
|
1550
1594
|
};
|
|
1551
1595
|
|
|
1552
|
-
export { Action, ActionType,
|
|
1596
|
+
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
|
|
package/dist/passport.js
CHANGED
|
@@ -2072,7 +2072,7 @@ class MultiRollupApiClients {
|
|
|
2072
2072
|
}
|
|
2073
2073
|
|
|
2074
2074
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2075
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.27.15-alpha.
|
|
2075
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.27.15-alpha.6' };
|
|
2076
2076
|
const createConfig = ({ basePath, headers, }) => {
|
|
2077
2077
|
if (!basePath.trim()) {
|
|
2078
2078
|
throw Error('basePath can not be empty');
|
|
@@ -2128,7 +2128,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2128
2128
|
chainID,
|
|
2129
2129
|
coreContractAddress,
|
|
2130
2130
|
registrationContractAddress,
|
|
2131
|
-
sdkVersion: 'ts-immutable-sdk-0.27.15-alpha.
|
|
2131
|
+
sdkVersion: 'ts-immutable-sdk-0.27.15-alpha.6',
|
|
2132
2132
|
});
|
|
2133
2133
|
/**
|
|
2134
2134
|
* Sets `sdkVersion` at the time of build
|
|
@@ -2144,9 +2144,9 @@ const production = () => createImmutableXConfiguration({
|
|
|
2144
2144
|
*/
|
|
2145
2145
|
const sandbox = () => createImmutableXConfiguration({
|
|
2146
2146
|
basePath: 'https://api.sandbox.x.immutable.com',
|
|
2147
|
-
chainID:
|
|
2148
|
-
coreContractAddress: '
|
|
2149
|
-
registrationContractAddress: '
|
|
2147
|
+
chainID: 11155111,
|
|
2148
|
+
coreContractAddress: '0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98',
|
|
2149
|
+
registrationContractAddress: '0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97',
|
|
2150
2150
|
});
|
|
2151
2151
|
class ImxConfiguration {
|
|
2152
2152
|
immutableXConfig;
|
|
@@ -7061,7 +7061,7 @@ class MagicAdapter {
|
|
|
7061
7061
|
magicClient;
|
|
7062
7062
|
constructor(config) {
|
|
7063
7063
|
this.config = config;
|
|
7064
|
-
if (window) {
|
|
7064
|
+
if (typeof window !== 'undefined') {
|
|
7065
7065
|
this.magicClient = this.initMagicClient();
|
|
7066
7066
|
this.magicClient.preload();
|
|
7067
7067
|
}
|
|
@@ -7297,7 +7297,7 @@ class GuardianClient {
|
|
|
7297
7297
|
throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, transactionRejectedCrossSdkBridgeError);
|
|
7298
7298
|
}
|
|
7299
7299
|
if (confirmationRequired && !!messageId) {
|
|
7300
|
-
const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId);
|
|
7300
|
+
const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId, user.zkEvm.ethAddress);
|
|
7301
7301
|
if (!confirmationResult.confirmed) {
|
|
7302
7302
|
throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Signature rejected by user');
|
|
7303
7303
|
}
|
|
@@ -7972,7 +7972,19 @@ class ConfirmationScreen {
|
|
|
7972
7972
|
constructor(config) {
|
|
7973
7973
|
this.config = config;
|
|
7974
7974
|
}
|
|
7975
|
-
|
|
7975
|
+
getHref(relativePath, queryStringParams) {
|
|
7976
|
+
let href = `${this.config.passportDomain}/transaction-confirmation/${relativePath}`;
|
|
7977
|
+
if (queryStringParams) {
|
|
7978
|
+
const queryString = queryStringParams
|
|
7979
|
+
? Object.keys(queryStringParams)
|
|
7980
|
+
.map((key) => `${key}=${queryStringParams[key]}`)
|
|
7981
|
+
.join('&')
|
|
7982
|
+
: '';
|
|
7983
|
+
href = `${href}?${queryString}`;
|
|
7984
|
+
}
|
|
7985
|
+
return href;
|
|
7986
|
+
}
|
|
7987
|
+
requestConfirmation(transactionId, etherAddress, chainType, chainId) {
|
|
7976
7988
|
return new Promise((resolve, reject) => {
|
|
7977
7989
|
const messageHandler = ({ data, origin }) => {
|
|
7978
7990
|
if (origin !== this.config.passportDomain
|
|
@@ -8002,17 +8014,17 @@ class ConfirmationScreen {
|
|
|
8002
8014
|
window.addEventListener('message', messageHandler);
|
|
8003
8015
|
let href = '';
|
|
8004
8016
|
if (chainType === TransactionApprovalRequestChainTypeEnum.Starkex) {
|
|
8005
|
-
|
|
8006
|
-
href = `${this.config.passportDomain}/transaction-confirmation/transaction?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=starkex`;
|
|
8017
|
+
href = this.getHref('transaction', { transactionId, etherAddress, chainType });
|
|
8007
8018
|
}
|
|
8008
8019
|
else {
|
|
8009
|
-
|
|
8010
|
-
|
|
8020
|
+
href = this.getHref('zkevm', {
|
|
8021
|
+
transactionId, etherAddress, chainType, chainId,
|
|
8022
|
+
});
|
|
8011
8023
|
}
|
|
8012
8024
|
this.showConfirmationScreen(href, messageHandler, resolve);
|
|
8013
8025
|
});
|
|
8014
8026
|
}
|
|
8015
|
-
requestMessageConfirmation(
|
|
8027
|
+
requestMessageConfirmation(messageID, etherAddress) {
|
|
8016
8028
|
return new Promise((resolve, reject) => {
|
|
8017
8029
|
const messageHandler = ({ data, origin }) => {
|
|
8018
8030
|
if (origin !== this.config.passportDomain
|
|
@@ -8040,7 +8052,7 @@ class ConfirmationScreen {
|
|
|
8040
8052
|
return;
|
|
8041
8053
|
}
|
|
8042
8054
|
window.addEventListener('message', messageHandler);
|
|
8043
|
-
const href =
|
|
8055
|
+
const href = this.getHref('zkevm/message', { messageID, etherAddress });
|
|
8044
8056
|
this.showConfirmationScreen(href, messageHandler, resolve);
|
|
8045
8057
|
});
|
|
8046
8058
|
}
|
|
@@ -8050,7 +8062,7 @@ class ConfirmationScreen {
|
|
|
8050
8062
|
return;
|
|
8051
8063
|
}
|
|
8052
8064
|
this.confirmationWindow = openPopupCenter({
|
|
8053
|
-
url:
|
|
8065
|
+
url: this.getHref('loading'),
|
|
8054
8066
|
title: CONFIRMATION_WINDOW_TITLE,
|
|
8055
8067
|
width: popupOptions?.width || CONFIRMATION_WINDOW_WIDTH,
|
|
8056
8068
|
height: popupOptions?.height || CONFIRMATION_WINDOW_HEIGHT,
|
|
@@ -8063,7 +8075,7 @@ class ConfirmationScreen {
|
|
|
8063
8075
|
return new Promise((resolve, rejects) => {
|
|
8064
8076
|
const iframe = document.createElement('iframe');
|
|
8065
8077
|
iframe.setAttribute('id', CONFIRMATION_IFRAME_ID);
|
|
8066
|
-
iframe.setAttribute('src',
|
|
8078
|
+
iframe.setAttribute('src', this.getHref('logout'));
|
|
8067
8079
|
iframe.setAttribute('style', CONFIRMATION_IFRAME_STYLE);
|
|
8068
8080
|
const logoutHandler = ({ data, origin }) => {
|
|
8069
8081
|
if (origin !== this.config.passportDomain
|
|
@@ -8507,7 +8519,17 @@ class ZkEvmProvider {
|
|
|
8507
8519
|
this.magicAdapter = magicAdapter;
|
|
8508
8520
|
this.config = config;
|
|
8509
8521
|
this.confirmationScreen = confirmationScreen;
|
|
8510
|
-
|
|
8522
|
+
if (config.crossSdkBridgeEnabled) {
|
|
8523
|
+
// JsonRpcProvider by default sets the referrer as "client".
|
|
8524
|
+
// On Unreal 4 this errors as the browser used is expecting a valid URL.
|
|
8525
|
+
this.jsonRpcProvider = new JsonRpcProvider({
|
|
8526
|
+
url: this.config.zkEvmRpcUrl,
|
|
8527
|
+
fetchOptions: { referrer: 'http://imtblgamesdk.local' },
|
|
8528
|
+
});
|
|
8529
|
+
}
|
|
8530
|
+
else {
|
|
8531
|
+
this.jsonRpcProvider = new JsonRpcProvider(this.config.zkEvmRpcUrl);
|
|
8532
|
+
}
|
|
8511
8533
|
this.multiRollupApiClients = multiRollupApiClients;
|
|
8512
8534
|
this.eventEmitter = new TypedEventEmitter();
|
|
8513
8535
|
passportEventEmitter.on(PassportEvents.LOGGED_OUT, this.handleLogout);
|
package/package.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@imtbl/sdk",
|
|
3
3
|
"description": "Immutable Unified SDK",
|
|
4
|
-
"version": "0.27.15-alpha.
|
|
4
|
+
"version": "0.27.15-alpha.6",
|
|
5
5
|
"author": "Immutable",
|
|
6
6
|
"browser": "./dist/index.browser.js",
|
|
7
7
|
"bugs": "https://github.com/immutable/ts-immutable-sdk/issues",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@0xsequence/abi": "^0.43.34",
|
|
10
10
|
"@0xsequence/config": "^0.43.34",
|
|
11
|
-
"@biom3/design-tokens": "0.2.4-beta",
|
|
12
|
-
"@biom3/react": "^0.10.12",
|
|
13
11
|
"@ethersproject/abi": "^5.7.0",
|
|
14
12
|
"@ethersproject/abstract-signer": "^5.7.0",
|
|
15
13
|
"@ethersproject/providers": "^5.7.2",
|
|
16
14
|
"@ethersproject/wallet": "^5.7.0",
|
|
17
15
|
"@imtbl/core-sdk": "^2.0.2",
|
|
18
|
-
"@imtbl/react-analytics": "0.0.5-alpha",
|
|
19
16
|
"@jest/globals": "^29.5.0",
|
|
20
17
|
"@magic-ext/oidc": "^1.0.1",
|
|
21
18
|
"@metamask/detect-provider": "^2.0.0",
|
|
@@ -23,25 +20,13 @@
|
|
|
23
20
|
"@uniswap/router-sdk": "^1.4.0",
|
|
24
21
|
"@uniswap/sdk-core": "^3.0.1",
|
|
25
22
|
"@uniswap/v3-sdk": "^3.9.0",
|
|
26
|
-
"assert": "^2.0.0",
|
|
27
23
|
"axios": "^1.3.5",
|
|
28
24
|
"bn.js": "^5.2.1",
|
|
29
|
-
"buffer": "^6.0.3",
|
|
30
|
-
"crypto-browserify": "^3.12.0",
|
|
31
25
|
"enc-utils": "^3.0.0",
|
|
32
26
|
"ethers": "^5.7.2",
|
|
33
|
-
"https-browserify": "^1.0.0",
|
|
34
27
|
"jwt-decode": "^3.1.2",
|
|
35
28
|
"magic-sdk": "^13.3.1",
|
|
36
|
-
"oidc-client-ts": "^2.2.1"
|
|
37
|
-
"os-browserify": "^0.3.0",
|
|
38
|
-
"pako": "^2.1.0",
|
|
39
|
-
"react": "^18.2.0",
|
|
40
|
-
"react-dom": "^18.2.0",
|
|
41
|
-
"react-router-dom": "^6.11.0",
|
|
42
|
-
"stream-browserify": "^3.0.0",
|
|
43
|
-
"stream-http": "^3.2.0",
|
|
44
|
-
"url": "^0.11.0"
|
|
29
|
+
"oidc-client-ts": "^2.2.1"
|
|
45
30
|
},
|
|
46
31
|
"devDependencies": {
|
|
47
32
|
"@imtbl/blockchain-data": "0.0.0",
|
|
@@ -109,6 +94,10 @@
|
|
|
109
94
|
"./checkout_sdk": {
|
|
110
95
|
"types": "./dist/checkout_sdk.d.ts",
|
|
111
96
|
"import": "./dist/checkout_sdk.js"
|
|
97
|
+
},
|
|
98
|
+
"./checkout_widgets": {
|
|
99
|
+
"types": "./dist/checkout_widgets.d.ts",
|
|
100
|
+
"import": "./dist/checkout_widgets.js"
|
|
112
101
|
}
|
|
113
102
|
},
|
|
114
103
|
"files": [
|