@imtbl/sdk 1.4.2 → 1.5.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.
@@ -21615,7 +21615,7 @@ type SellResultInsufficientFunds = {
21615
21615
  /** The insufficient result of smart checkout */
21616
21616
  smartCheckoutResult: SmartCheckoutInsufficient;
21617
21617
  };
21618
- type CancelResult = CancelResultSuccess | CancelResultFailed | CancelResultFulfillmentsUnsettled;
21618
+ type CancelResult = CancelResultSuccess | CancelResultFailed | CancelResultFulfillmentsUnsettled | CancelResultGasless;
21619
21619
  /**
21620
21620
  * Represents the result of {@link Checkout.cancel}
21621
21621
  * @property {CheckoutStatus.SUCCESS} status
@@ -21644,18 +21644,58 @@ type CancelResultFailed = {
21644
21644
  * @property {SendTransactionResult[]} transactions
21645
21645
  */
21646
21646
  type CancelResultFulfillmentsUnsettled = {
21647
- /** The status to indicate success */
21647
+ /** The status to indicate the fulfillments have not yet settled on chain. */
21648
21648
  status: CheckoutStatus.FULFILLMENTS_UNSETTLED;
21649
21649
  /** Array of transaction results */
21650
21650
  transactions: TransactionResponse[];
21651
21651
  };
21652
+ /**
21653
+ * Represents the result of {@link Checkout.cancel} when using gasless cancel
21654
+ * @property {SuccessfulGaslessCancellation[]} successfulCancellations
21655
+ * @property {FailedGaslessCancellation[]} failedCancellations
21656
+ * @property {PendingGaslessCancellation[]} pendingCancellations
21657
+ */
21658
+ type CancelResultGasless = {
21659
+ successfulCancellations: SuccessfulGaslessCancellation[];
21660
+ failedCancellations: FailedGaslessCancellation[];
21661
+ pendingCancellations: PendingGaslessCancellation[];
21662
+ };
21663
+ /**
21664
+ * Represents a successful gasless cancellation
21665
+ * @property {string} orderId
21666
+ */
21667
+ type SuccessfulGaslessCancellation = {
21668
+ /** The order id of the successful cancellation */
21669
+ orderId: string;
21670
+ };
21671
+ /**
21672
+ * Represents a failed gasless cancellation
21673
+ * @property {string} orderId
21674
+ * @property {string} reason
21675
+ */
21676
+ type FailedGaslessCancellation = {
21677
+ /** The order id of the failed cancellation */
21678
+ orderId: string;
21679
+ /** The reason for failure */
21680
+ reason: string;
21681
+ };
21682
+ /**
21683
+ * Represents a pending gasless cancellation
21684
+ * @property {string} orderId
21685
+ */
21686
+ type PendingGaslessCancellation = {
21687
+ /** The order id of the pending cancellation */
21688
+ orderId: string;
21689
+ };
21652
21690
  /**
21653
21691
  * Represents the overrides available for {@link Checkout.cancel}
21654
21692
  * @property {boolean} waitFulfillmentSettlements
21655
21693
  */
21656
21694
  type CancelOverrides = {
21657
- /** If the buy should wait for the fulfillment transactions to settle */
21695
+ /** If the cancel should wait for the fulfillment transactions to settle */
21658
21696
  waitFulfillmentSettlements?: boolean;
21697
+ /** If the cancel should use the gasless option */
21698
+ useGaslessCancel?: boolean;
21659
21699
  };
21660
21700
  /**
21661
21701
  * An enum representing the checkout status types
@@ -21674,7 +21714,7 @@ declare enum CheckoutStatus {
21674
21714
  /**
21675
21715
  * The type representing the order to buy
21676
21716
  * @property {string} orderId
21677
- * @property {Array<OrderFee>} takerFees
21717
+ * @property {OrderFee[]} takerFees
21678
21718
  */
21679
21719
  type BuyOrder = {
21680
21720
  /** the id of the order to buy */
@@ -23991,4 +24031,4 @@ declare class BlockExplorerService {
23991
24031
  static getTransactionLink(chainId: ChainId, hash: string): string | undefined;
23992
24032
  }
23993
24033
 
23994
- export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BlockExplorerService, BridgeClaimWithdrawalFailed, BridgeClaimWithdrawalSuccess, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeTransactionSent, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyOverrides, BuyParams, BuyResult, BuyResultFailed, BuyResultFulfillmentsUnsettled, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CancelOverrides, CancelParams, CancelResult, CancelResultFailed, CancelResultFulfillmentsUnsettled, CancelResultSuccess, ChainId, ChainName, ChainSlug, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutBridgeConfiguration, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutOnRampConfiguration, CheckoutStatus, CheckoutSwapConfiguration, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectResult, ConnectTargetLayer, ConnectWidgetConfiguration, ConnectWidgetParams, ConnectionFailed, ConnectionSuccess, CreateProviderParams, CreateProviderResult, DexConfig, ERC20ItemRequirement, ERC721Balance, ERC721ItemRequirement, ErrorType, ExchangeType, Fee, FeePercentage, FeeToken, FeeType, FiatRampParams, FulfillmentTransaction, FundingItem, FundingRoute, FundingStep, FundingStepType, GasAmount, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasToken, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetTokenInfoParams, GetWalletAllowListParams, GetWalletAllowListResult, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, IWidgetsFactory, ItemBalance, ItemType, LanguageChanged, NativeItemRequirement, NetworkFilter, NetworkFilterTypes, NetworkInfo, NoRouteOptions, NoRoutesFound, OnRampEventType, OnRampFailed, OnRampFundingStep, OnRampProviderFees, OnRampSuccess, OnRampWidgetParams, OnrampWidgetConfiguration, OrchestrationEvent, OrchestrationEventData, OrchestrationEventType, OrderFee, ProviderEvent, ProviderEventType, ProviderUpdated, RemoteConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, RoutesFound, RoutingOutcome, RoutingOutcomeType, SaleEventType, SaleFailed, SaleItem, SalePaymentMethod, SalePaymentTypes, SaleSuccess, SaleTransactionSuccess, SaleWidgetConfiguration, SaleWidgetParams, SellOrder, SellParams, SellResult, SellResultFailed, SellResultInsufficientFunds, SellResultSuccess, SellToken, SemanticVersion, SendTransactionParams, SendTransactionResult, SmartCheckoutInsufficient, SmartCheckoutParams, SmartCheckoutResult, SmartCheckoutRouter, SmartCheckoutSufficient, SwapEventType, SwapFailed, SwapFundingStep, SwapRejected, SwapSuccess, SwapWidgetConfiguration, SwapWidgetParams, SwitchNetworkParams, SwitchNetworkResult, TokenAmountEstimate, TokenBalance, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, TransactionRequirement, WalletDisconnect, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitch, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetLanguage, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
24034
+ export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BlockExplorerService, BridgeClaimWithdrawalFailed, BridgeClaimWithdrawalSuccess, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeTransactionSent, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyOverrides, BuyParams, BuyResult, BuyResultFailed, BuyResultFulfillmentsUnsettled, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CancelOverrides, CancelParams, CancelResult, CancelResultFailed, CancelResultFulfillmentsUnsettled, CancelResultGasless, CancelResultSuccess, ChainId, ChainName, ChainSlug, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutBridgeConfiguration, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutOnRampConfiguration, CheckoutStatus, CheckoutSwapConfiguration, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectResult, ConnectTargetLayer, ConnectWidgetConfiguration, ConnectWidgetParams, ConnectionFailed, ConnectionSuccess, CreateProviderParams, CreateProviderResult, DexConfig, ERC20ItemRequirement, ERC721Balance, ERC721ItemRequirement, ErrorType, ExchangeType, FailedGaslessCancellation, Fee, FeePercentage, FeeToken, FeeType, FiatRampParams, FulfillmentTransaction, FundingItem, FundingRoute, FundingStep, FundingStepType, GasAmount, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasToken, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetTokenInfoParams, GetWalletAllowListParams, GetWalletAllowListResult, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, IWidgetsFactory, ItemBalance, ItemType, LanguageChanged, NativeItemRequirement, NetworkFilter, NetworkFilterTypes, NetworkInfo, NoRouteOptions, NoRoutesFound, OnRampEventType, OnRampFailed, OnRampFundingStep, OnRampProviderFees, OnRampSuccess, OnRampWidgetParams, OnrampWidgetConfiguration, OrchestrationEvent, OrchestrationEventData, OrchestrationEventType, OrderFee, PendingGaslessCancellation, ProviderEvent, ProviderEventType, ProviderUpdated, RemoteConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, RoutesFound, RoutingOutcome, RoutingOutcomeType, SaleEventType, SaleFailed, SaleItem, SalePaymentMethod, SalePaymentTypes, SaleSuccess, SaleTransactionSuccess, SaleWidgetConfiguration, SaleWidgetParams, SellOrder, SellParams, SellResult, SellResultFailed, SellResultInsufficientFunds, SellResultSuccess, SellToken, SemanticVersion, SendTransactionParams, SendTransactionResult, SmartCheckoutInsufficient, SmartCheckoutParams, SmartCheckoutResult, SmartCheckoutRouter, SmartCheckoutSufficient, SuccessfulGaslessCancellation, SwapEventType, SwapFailed, SwapFundingStep, SwapRejected, SwapSuccess, SwapWidgetConfiguration, SwapWidgetParams, SwitchNetworkParams, SwitchNetworkResult, TokenAmountEstimate, TokenBalance, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, TransactionRequirement, WalletDisconnect, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitch, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetLanguage, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
package/dist/checkout.js CHANGED
@@ -138,7 +138,7 @@ const flattenProperties$1 = (properties) => {
138
138
  };
139
139
 
140
140
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
141
- const SDK_VERSION$1 = '1.4.2';
141
+ const SDK_VERSION$1 = '1.5.1';
142
142
  let initialised$1 = false;
143
143
  const isInitialised$1 = () => initialised$1;
144
144
  const getReferrer$1 = () => {
@@ -17088,7 +17088,7 @@ const flattenProperties = (properties) => {
17088
17088
  };
17089
17089
 
17090
17090
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
17091
- const SDK_VERSION = '1.4.2';
17091
+ const SDK_VERSION = '1.5.1';
17092
17092
  let initialised = false;
17093
17093
  const isInitialised = () => initialised;
17094
17094
  const getReferrer = () => {
@@ -21666,7 +21666,7 @@ class OrdersService {
21666
21666
  * @returns ListListingsResult OK response.
21667
21667
  * @throws ApiError
21668
21668
  */
21669
- listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, accountAddress, sellItemMetadataId, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
21669
+ listListings({ chainName, status, sellItemContractAddress, buyItemType, buyItemContractAddress, accountAddress, sellItemMetadataId, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
21670
21670
  return this.httpRequest.request({
21671
21671
  method: 'GET',
21672
21672
  url: '/v1/chains/{chain_name}/orders/listings',
@@ -21676,6 +21676,7 @@ class OrdersService {
21676
21676
  query: {
21677
21677
  'status': status,
21678
21678
  'sell_item_contract_address': sellItemContractAddress,
21679
+ 'buy_item_type': buyItemType,
21679
21680
  'buy_item_contract_address': buyItemContractAddress,
21680
21681
  'account_address': accountAddress,
21681
21682
  'sell_item_metadata_id': sellItemMetadataId,
@@ -27265,7 +27266,7 @@ class APIError extends Error {
27265
27266
 
27266
27267
  /* eslint-disable implicit-arrow-linebreak */
27267
27268
  const defaultHeaders = {
27268
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.4.2',
27269
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.1',
27269
27270
  };
27270
27271
  /**
27271
27272
  * createAPIConfiguration to create a custom Configuration
@@ -28632,7 +28633,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
28632
28633
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
28633
28634
  };
28634
28635
 
28635
- const SDK_VERSION_MARKER = '1.4.2';
28636
+ const SDK_VERSION_MARKER = '1.5.1';
28636
28637
  // This SDK version is replaced by the `yarn build` command ran on the root level
28637
28638
  const globalPackageVersion = () => SDK_VERSION_MARKER;
28638
28639
 
@@ -31894,9 +31895,7 @@ const buy = async (config, provider, orders, overrides = {
31894
31895
  };
31895
31896
  };
31896
31897
 
31897
- const cancel = async (config, provider, orderIds, overrides = {
31898
- waitFulfillmentSettlements: true,
31899
- }) => {
31898
+ const cancelOnChain = async (config, orderbook, provider, orderIds, waitFulfillmentSettlements) => {
31900
31899
  let unsignedCancelOrderTransaction;
31901
31900
  if (orderIds.length === 0) {
31902
31901
  throw new CheckoutError('No orderIds were provided to the orderIds array. Please provide at least one orderId.', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR);
@@ -31905,7 +31904,6 @@ const cancel = async (config, provider, orderIds, overrides = {
31905
31904
  const orderId = orderIds[0];
31906
31905
  try {
31907
31906
  const offererAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
31908
- const orderbook = createOrderbookInstance(config);
31909
31907
  const cancelOrderResponse = await measureAsyncExecution(config, 'Time to get the cancel order from the orderbook', orderbook.cancelOrdersOnChain([orderId], offererAddress));
31910
31908
  unsignedCancelOrderTransaction = await cancelOrderResponse.cancellationAction.buildTransaction();
31911
31909
  }
@@ -31915,7 +31913,7 @@ const cancel = async (config, provider, orderIds, overrides = {
31915
31913
  error: err,
31916
31914
  });
31917
31915
  }
31918
- if (overrides.waitFulfillmentSettlements) {
31916
+ if (waitFulfillmentSettlements) {
31919
31917
  const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
31920
31918
  if (result.type === SignTransactionStatusType.FAILED) {
31921
31919
  return {
@@ -31943,6 +31941,56 @@ const cancel = async (config, provider, orderIds, overrides = {
31943
31941
  transactions,
31944
31942
  };
31945
31943
  };
31944
+ const gaslessCancel = async (orderbook, provider, orderIds) => {
31945
+ try {
31946
+ const signer = provider.getSigner();
31947
+ const address = await signer.getAddress();
31948
+ const { signableAction } = await orderbook.prepareOrderCancellations(orderIds);
31949
+ // eslint-disable-next-line no-underscore-dangle
31950
+ const signedMessage = await signer._signTypedData(signableAction.message.domain, signableAction.message.types, signableAction.message.value);
31951
+ const { result } = await orderbook.cancelOrders(orderIds, address, signedMessage);
31952
+ const successfulCancellations = [];
31953
+ const failedCancellations = [];
31954
+ const pendingCancellations = [];
31955
+ for (const success of result.successful_cancellations) {
31956
+ successfulCancellations.push({
31957
+ orderId: success,
31958
+ });
31959
+ }
31960
+ for (const failed of result.failed_cancellations) {
31961
+ failedCancellations.push({
31962
+ orderId: failed.order,
31963
+ reason: failed.reason_code,
31964
+ });
31965
+ }
31966
+ for (const pending of result.pending_cancellations) {
31967
+ pendingCancellations.push({
31968
+ orderId: pending,
31969
+ });
31970
+ }
31971
+ return {
31972
+ successfulCancellations,
31973
+ failedCancellations,
31974
+ pendingCancellations,
31975
+ };
31976
+ }
31977
+ catch (err) {
31978
+ throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
31979
+ orderIds,
31980
+ error: err,
31981
+ });
31982
+ }
31983
+ };
31984
+ const cancel = async (config, provider, orderIds, overrides = {
31985
+ waitFulfillmentSettlements: true,
31986
+ useGaslessCancel: false,
31987
+ }) => {
31988
+ const orderbook = createOrderbookInstance(config);
31989
+ if (overrides.useGaslessCancel) {
31990
+ return await gaslessCancel(orderbook, provider, orderIds);
31991
+ }
31992
+ return await cancelOnChain(config, orderbook, provider, orderIds, overrides.waitFulfillmentSettlements ?? true);
31993
+ };
31946
31994
 
31947
31995
  const getERC721Requirement = (id, contractAddress, spenderAddress) => ({
31948
31996
  type: ItemType.ERC721,
package/dist/config.js CHANGED
@@ -127,7 +127,7 @@ const flattenProperties = (properties) => {
127
127
  };
128
128
 
129
129
  // WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
130
- const SDK_VERSION = '1.4.2';
130
+ const SDK_VERSION = '1.5.1';
131
131
  let initialised = false;
132
132
  const isInitialised = () => initialised;
133
133
  const getReferrer = () => {