@imtbl/sdk 0.28.2 → 0.28.3-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.
@@ -595,6 +595,53 @@ 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
+
598
645
  type ApiRequestOptions = {
599
646
  readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
600
647
  readonly url: string;
@@ -682,7 +729,7 @@ declare namespace FailedOrderCancellation {
682
729
  * Reason code indicating why the order failed to be cancelled
683
730
  */
684
731
  enum reason_code {
685
- FILLED = "FILLED"
732
+ ALREADY_FILLED = "ALREADY_FILLED"
686
733
  }
687
734
  }
688
735
 
@@ -860,20 +907,20 @@ type Chain = {
860
907
 
861
908
  type ActiveOrderStatus = {
862
909
  /**
863
- * The order status that indicates an order can be fulfilled.
910
+ * The order status
864
911
  */
865
912
  name: 'ACTIVE';
866
913
  };
867
914
 
868
915
  type CancelledOrderStatus = {
869
916
  /**
870
- * The order status indicating a order is has been cancelled or about to be cancelled.
917
+ * The order status
871
918
  */
872
919
  name: 'CANCELLED';
873
920
  /**
874
921
  * Whether the cancellation of the order is pending
875
922
  */
876
- pending: boolean;
923
+ is_pending: boolean;
877
924
  /**
878
925
  * Whether the cancellation was done on-chain or off-chain
879
926
  */
@@ -891,46 +938,30 @@ declare namespace CancelledOrderStatus {
891
938
 
892
939
  type ExpiredOrderStatus = {
893
940
  /**
894
- * A terminal order status indicating that an order cannot be fulfilled due to expiry.
941
+ * The order status
895
942
  */
896
943
  name: 'EXPIRED';
897
944
  };
898
945
 
899
946
  type FilledOrderStatus = {
900
947
  /**
901
- * A terminal order status indicating that an order has been fulfilled.
948
+ * The order status
902
949
  */
903
950
  name: 'FILLED';
904
951
  };
905
952
 
906
953
  type InactiveOrderStatus = {
907
954
  /**
908
- * The order status that indicates an order cannot be fulfilled.
955
+ * The order status
909
956
  */
910
957
  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;
919
958
  };
920
959
 
921
960
  type PendingOrderStatus = {
922
961
  /**
923
- * The order status that indicates the order is yet to be active due to various reasons.
962
+ * The order status
924
963
  */
925
964
  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;
934
965
  };
935
966
 
936
967
  /**
@@ -1235,53 +1266,6 @@ declare class OrdersService {
1235
1266
  }): CancelablePromise<TradeResult$1>;
1236
1267
  }
1237
1268
 
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
-
1285
1269
  interface ERC721Item {
1286
1270
  type: 'ERC721';
1287
1271
  contractAddress: string;
@@ -1311,9 +1295,6 @@ interface PrepareListingResponse {
1311
1295
  orderComponents: OrderComponents;
1312
1296
  orderHash: string;
1313
1297
  }
1314
- interface PrepareCancelOrdersResponse {
1315
- signableAction: SignableAction;
1316
- }
1317
1298
  interface CreateListingParams {
1318
1299
  orderComponents: OrderComponents;
1319
1300
  orderHash: string;
@@ -1337,12 +1318,10 @@ interface Fee extends FeeValue {
1337
1318
  }
1338
1319
  declare enum TransactionPurpose {
1339
1320
  APPROVAL = "APPROVAL",
1340
- FULFILL_ORDER = "FULFILL_ORDER",
1341
- CANCEL = "CANCEL"
1321
+ FULFILL_ORDER = "FULFILL_ORDER"
1342
1322
  }
1343
1323
  declare enum SignablePurpose {
1344
- CREATE_LISTING = "CREATE_LISTING",
1345
- OFF_CHAIN_CANCELLATION = "OFF_CHAIN_CANCELLATION"
1324
+ CREATE_LISTING = "CREATE_LISTING"
1346
1325
  }
1347
1326
  declare enum ActionType {
1348
1327
  TRANSACTION = "TRANSACTION",
@@ -1394,8 +1373,8 @@ interface FulfillOrderResponse {
1394
1373
  expiration: string;
1395
1374
  order: Order;
1396
1375
  }
1397
- interface CancelOrdersOnChainResponse {
1398
- cancellationAction: TransactionAction;
1376
+ interface CancelOrderResponse {
1377
+ unsignedCancelOrderTransaction: PopulatedTransaction;
1399
1378
  }
1400
1379
  interface Order {
1401
1380
  id: string;
@@ -1557,40 +1536,17 @@ declare class Orderbook {
1557
1536
  fulfillOrder(listingId: string, takerAddress: string, takerFees: FeeValue[]): Promise<FulfillOrderResponse>;
1558
1537
  fulfillBulkOrders(listings: Array<FulfillmentListing>, takerAddress: string): Promise<FulfillBulkOrdersResponse>;
1559
1538
  /**
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.
1539
+ * Get an unsigned cancel order transaction. Orders can only be cancelled by
1540
+ * the account that created them.
1541
+ * @param {string} listingId - The listingId to cancel.
1586
1542
  * @param {string} accountAddress - The address of the account cancelling the order.
1587
- * @return {CancelOrdersOnChainResponse} The unsigned cancel order action
1543
+ * @return {CancelOrderResponse} The unsigned cancel order transaction
1588
1544
  */
1589
- cancelOrdersOnChain(orderIds: string[], accountAddress: string): Promise<CancelOrdersOnChainResponse>;
1545
+ cancelOrder(listingId: string, accountAddress: string): Promise<CancelOrderResponse>;
1590
1546
  }
1591
1547
 
1592
1548
  declare const constants: {
1593
1549
  estimatedFulfillmentGasGwei: number;
1594
1550
  };
1595
1551
 
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 };
1552
+ export { Action, ActionType, CancelOrderResponse, CreateListingParams, ERC20Item, ERC721Item, Fee, FeeType, FeeValue, FulfillBulkOrdersInsufficientBalanceResponse, FulfillBulkOrdersResponse, FulfillBulkOrdersSufficientBalanceResponse, 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
@@ -606,7 +606,7 @@ var CancelledOrderStatus;
606
606
  var FailedOrderCancellation;
607
607
  (function (FailedOrderCancellation) {
608
608
  (function (reason_code) {
609
- reason_code["FILLED"] = "FILLED";
609
+ reason_code["ALREADY_FILLED"] = "ALREADY_FILLED";
610
610
  })(FailedOrderCancellation.reason_code || (FailedOrderCancellation.reason_code = {}));
611
611
  })(FailedOrderCancellation || (FailedOrderCancellation = {}));
612
612
 
@@ -660,12 +660,10 @@ var TransactionPurpose;
660
660
  (function (TransactionPurpose) {
661
661
  TransactionPurpose["APPROVAL"] = "APPROVAL";
662
662
  TransactionPurpose["FULFILL_ORDER"] = "FULFILL_ORDER";
663
- TransactionPurpose["CANCEL"] = "CANCEL";
664
663
  })(TransactionPurpose || (TransactionPurpose = {}));
665
664
  var SignablePurpose;
666
665
  (function (SignablePurpose) {
667
666
  SignablePurpose["CREATE_LISTING"] = "CREATE_LISTING";
668
- SignablePurpose["OFF_CHAIN_CANCELLATION"] = "OFF_CHAIN_CANCELLATION";
669
667
  })(SignablePurpose || (SignablePurpose = {}));
670
668
  var ActionType;
671
669
  (function (ActionType) {
@@ -1062,15 +1060,11 @@ class Seaport {
1062
1060
  .reduce((p, c) => (new Date(p) < new Date(c) ? p : c)),
1063
1061
  };
1064
1062
  }
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
- };
1063
+ async cancelOrder(order, account) {
1064
+ const { orderComponents } = this.mapImmutableOrderToSeaportOrderComponents(order);
1065
+ const seaportLib = this.getSeaportLib(order);
1066
+ const cancellationTransaction = await seaportLib.cancelOrders([orderComponents], account);
1067
+ return prepareTransaction(cancellationTransaction)();
1074
1068
  }
1075
1069
  mapImmutableOrderToSeaportOrderComponents(order) {
1076
1070
  const orderCounter = order.protocol_data.counter;
@@ -1172,16 +1166,6 @@ class ImmutableApiClient {
1172
1166
  ...listTradesParams,
1173
1167
  });
1174
1168
  }
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
- }
1185
1169
  async createListing({ orderHash, orderComponents, orderSignature, makerFees, }) {
1186
1170
  if (orderComponents.offer.length !== 1) {
1187
1171
  throw new Error('Only one item can be listed at a time');
@@ -1483,89 +1467,24 @@ class Orderbook {
1483
1467
  }
1484
1468
  }
1485
1469
  /**
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.
1470
+ * Get an unsigned cancel order transaction. Orders can only be cancelled by
1471
+ * the account that created them.
1472
+ * @param {string} listingId - The listingId to cancel.
1545
1473
  * @param {string} accountAddress - The address of the account cancelling the order.
1546
- * @return {CancelOrdersOnChainResponse} The unsigned cancel order action
1474
+ * @return {CancelOrderResponse} The unsigned cancel order transaction
1547
1475
  */
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
- }
1476
+ async cancelOrder(listingId, accountAddress) {
1477
+ const orderResult = await this.apiClient.getListing(listingId);
1478
+ if (orderResult.result.status.name !== OrderStatusName.ACTIVE
1479
+ && orderResult.result.status.name !== OrderStatusName.INACTIVE
1480
+ && orderResult.result.status.name !== OrderStatusName.PENDING) {
1481
+ throw new Error(`Cannot cancel order with status ${orderResult.result.status}`);
1560
1482
  }
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');
1483
+ if (orderResult.result.account_address !== accountAddress.toLowerCase()) {
1484
+ throw new Error(`Only account ${orderResult.result.account_address} can cancel order ${listingId}`);
1566
1485
  }
1567
- const cancellationAction = await this.seaport.cancelOrders(orders, accountAddress);
1568
- return { cancellationAction };
1486
+ const cancelOrderTransaction = await this.seaport.cancelOrder(orderResult.result, accountAddress);
1487
+ return { unsignedCancelOrderTransaction: cancelOrderTransaction };
1569
1488
  }
1570
1489
  }
1571
1490
 
@@ -10608,12 +10608,6 @@ declare class Passport {
10608
10608
  private readonly passportImxProviderFactory;
10609
10609
  private readonly passportEventEmitter;
10610
10610
  constructor(passportModuleConfiguration: PassportModuleConfiguration);
10611
- signIn(options?: {
10612
- useCachedSession: boolean;
10613
- }): Promise<UserProfile | null>;
10614
- /**
10615
- * @deprecated The method connectImx(useCachedSession) should be used instead
10616
- */
10617
10611
  connectImxSilent(): Promise<IMXProvider | null>;
10618
10612
  connectImx(): Promise<IMXProvider>;
10619
10613
  loginWithDeviceFlow(): Promise<DeviceConnectResponse>;
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.28.2' };
2075
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.28.3-alpha.1' };
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.28.2',
2131
+ sdkVersion: 'ts-immutable-sdk-0.28.3-alpha.1',
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: 11155111,
2148
- coreContractAddress: '0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98',
2149
- registrationContractAddress: '0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97',
2147
+ chainID: 5,
2148
+ coreContractAddress: '0x7917eDb51ecD6CdB3F9854c3cc593F33de10c623',
2149
+ registrationContractAddress: '0x1C97Ada273C9A52253f463042f29117090Cd7D83',
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 (typeof window !== 'undefined') {
7064
+ if (window) {
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, user.zkEvm.ethAddress);
7300
+ const confirmationResult = await this.confirmationScreen.requestMessageConfirmation(messageId);
7301
7301
  if (!confirmationResult.confirmed) {
7302
7302
  throw new JsonRpcError(RpcErrorCode.TRANSACTION_REJECTED, 'Signature rejected by user');
7303
7303
  }
@@ -7758,7 +7758,7 @@ class PassportImxProviderFactory {
7758
7758
  this.passportEventEmitter = passportEventEmitter;
7759
7759
  }
7760
7760
  async getProvider() {
7761
- const user = await this.authManager.loginSilent() || await this.authManager.login();
7761
+ const user = await this.authManager.login();
7762
7762
  return this.createProviderInstance(user);
7763
7763
  }
7764
7764
  async getProviderSilent() {
@@ -7972,19 +7972,7 @@ class ConfirmationScreen {
7972
7972
  constructor(config) {
7973
7973
  this.config = config;
7974
7974
  }
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) {
7975
+ requestConfirmation(transactionId, imxEtherAddress, chainType, chainId) {
7988
7976
  return new Promise((resolve, reject) => {
7989
7977
  const messageHandler = ({ data, origin }) => {
7990
7978
  if (origin !== this.config.passportDomain
@@ -8014,17 +8002,17 @@ class ConfirmationScreen {
8014
8002
  window.addEventListener('message', messageHandler);
8015
8003
  let href = '';
8016
8004
  if (chainType === TransactionApprovalRequestChainTypeEnum.Starkex) {
8017
- href = this.getHref('transaction', { transactionId, etherAddress, chainType });
8005
+ // eslint-disable-next-line max-len
8006
+ href = `${this.config.passportDomain}/transaction-confirmation/transaction?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=starkex`;
8018
8007
  }
8019
8008
  else {
8020
- href = this.getHref('zkevm', {
8021
- transactionId, etherAddress, chainType, chainId,
8022
- });
8009
+ // eslint-disable-next-line max-len
8010
+ href = `${this.config.passportDomain}/transaction-confirmation/zkevm?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=evm&chainId=${chainId}`;
8023
8011
  }
8024
8012
  this.showConfirmationScreen(href, messageHandler, resolve);
8025
8013
  });
8026
8014
  }
8027
- requestMessageConfirmation(messageID, etherAddress) {
8015
+ requestMessageConfirmation(messageId) {
8028
8016
  return new Promise((resolve, reject) => {
8029
8017
  const messageHandler = ({ data, origin }) => {
8030
8018
  if (origin !== this.config.passportDomain
@@ -8052,7 +8040,7 @@ class ConfirmationScreen {
8052
8040
  return;
8053
8041
  }
8054
8042
  window.addEventListener('message', messageHandler);
8055
- const href = this.getHref('zkevm/message', { messageID, etherAddress });
8043
+ const href = `${this.config.passportDomain}/transaction-confirmation/zkevm/message?messageID=${messageId}`;
8056
8044
  this.showConfirmationScreen(href, messageHandler, resolve);
8057
8045
  });
8058
8046
  }
@@ -8062,7 +8050,7 @@ class ConfirmationScreen {
8062
8050
  return;
8063
8051
  }
8064
8052
  this.confirmationWindow = openPopupCenter({
8065
- url: this.getHref('loading'),
8053
+ url: `${this.config.passportDomain}/transaction-confirmation/loading`,
8066
8054
  title: CONFIRMATION_WINDOW_TITLE,
8067
8055
  width: popupOptions?.width || CONFIRMATION_WINDOW_WIDTH,
8068
8056
  height: popupOptions?.height || CONFIRMATION_WINDOW_HEIGHT,
@@ -8075,7 +8063,7 @@ class ConfirmationScreen {
8075
8063
  return new Promise((resolve, rejects) => {
8076
8064
  const iframe = document.createElement('iframe');
8077
8065
  iframe.setAttribute('id', CONFIRMATION_IFRAME_ID);
8078
- iframe.setAttribute('src', this.getHref('logout'));
8066
+ iframe.setAttribute('src', `${this.config.passportDomain}/transaction-confirmation/logout`);
8079
8067
  iframe.setAttribute('style', CONFIRMATION_IFRAME_STYLE);
8080
8068
  const logoutHandler = ({ data, origin }) => {
8081
8069
  if (origin !== this.config.passportDomain
@@ -8519,17 +8507,7 @@ class ZkEvmProvider {
8519
8507
  this.magicAdapter = magicAdapter;
8520
8508
  this.config = config;
8521
8509
  this.confirmationScreen = confirmationScreen;
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
- }
8510
+ this.jsonRpcProvider = new JsonRpcProvider(this.config.zkEvmRpcUrl);
8533
8511
  this.multiRollupApiClients = multiRollupApiClients;
8534
8512
  this.eventEmitter = new TypedEventEmitter();
8535
8513
  passportEventEmitter.on(PassportEvents.LOGGED_OUT, this.handleLogout);
@@ -8755,20 +8733,6 @@ class Passport {
8755
8733
  passportEventEmitter: this.passportEventEmitter,
8756
8734
  });
8757
8735
  }
8758
- async signIn(options) {
8759
- const { useCachedSession = false } = options || {};
8760
- let user = await this.authManager.loginSilent();
8761
- if (!user && !useCachedSession) {
8762
- user = await this.authManager.login();
8763
- }
8764
- if (!user) {
8765
- return null;
8766
- }
8767
- return user.profile;
8768
- }
8769
- /**
8770
- * @deprecated The method connectImx(useCachedSession) should be used instead
8771
- */
8772
8736
  async connectImxSilent() {
8773
8737
  return this.passportImxProviderFactory.getProviderSilent();
8774
8738
  }
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.28.2",
4
+ "version": "0.28.3-alpha.1",
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",
11
13
  "@ethersproject/abi": "^5.7.0",
12
14
  "@ethersproject/abstract-signer": "^5.7.0",
13
15
  "@ethersproject/providers": "^5.7.2",
14
16
  "@ethersproject/wallet": "^5.7.0",
15
17
  "@imtbl/core-sdk": "^2.0.2",
18
+ "@imtbl/react-analytics": "0.0.5-alpha",
16
19
  "@jest/globals": "^29.5.0",
17
20
  "@magic-ext/oidc": "^1.0.1",
18
21
  "@metamask/detect-provider": "^2.0.0",
@@ -20,13 +23,25 @@
20
23
  "@uniswap/router-sdk": "^1.4.0",
21
24
  "@uniswap/sdk-core": "^3.0.1",
22
25
  "@uniswap/v3-sdk": "^3.9.0",
26
+ "assert": "^2.0.0",
23
27
  "axios": "^1.3.5",
24
28
  "bn.js": "^5.2.1",
29
+ "buffer": "^6.0.3",
30
+ "crypto-browserify": "^3.12.0",
25
31
  "enc-utils": "^3.0.0",
26
32
  "ethers": "^5.7.2",
33
+ "https-browserify": "^1.0.0",
27
34
  "jwt-decode": "^3.1.2",
28
35
  "magic-sdk": "^13.3.1",
29
- "oidc-client-ts": "^2.2.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"
30
45
  },
31
46
  "devDependencies": {
32
47
  "@imtbl/blockchain-data": "0.0.0",
@@ -94,10 +109,6 @@
94
109
  "./checkout_sdk": {
95
110
  "types": "./dist/checkout_sdk.d.ts",
96
111
  "import": "./dist/checkout_sdk.js"
97
- },
98
- "./checkout_widgets": {
99
- "types": "./dist/checkout_widgets.d.ts",
100
- "import": "./dist/checkout_widgets.js"
101
112
  }
102
113
  },
103
114
  "files": [