@imtbl/sdk 1.5.0 → 1.5.2

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.5.0';
141
+ const SDK_VERSION$1 = '1.5.2';
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.5.0';
17091
+ const SDK_VERSION = '1.5.2';
17092
17092
  let initialised = false;
17093
17093
  const isInitialised = () => initialised;
17094
17094
  const getReferrer = () => {
@@ -19907,6 +19907,9 @@ const MIN_MAX_HOPS = 1;
19907
19907
  const BASIS_POINT_PRECISION = 10000;
19908
19908
  // 10% maximum secondary fee
19909
19909
  const MAX_SECONDARY_FEE_BASIS_POINTS = 1000;
19910
+ // How much more gas does a swap with secondary fees cost?
19911
+ // This number is the average difference of a number of different swaps with different hop amounts, etc.
19912
+ const AVERAGE_SECONDARY_FEE_EXTRA_GAS = 50876;
19910
19913
 
19911
19914
  const quoteReturnMapping = {
19912
19915
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -20327,6 +20330,59 @@ startTokenIn = tokenIn) => {
20327
20330
  return routes;
20328
20331
  };
20329
20332
 
20333
+ const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
20334
+ const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
20335
+
20336
+ const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
20337
+ const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
20338
+
20339
+ const NATIVE_IMX_IMMUTABLE_TESTNET = {
20340
+ chainId: IMMUTABLE_TESTNET_CHAIN_ID,
20341
+ decimals: 18,
20342
+ symbol: 'tIMX',
20343
+ name: 'Immutable Testnet Token',
20344
+ type: 'native',
20345
+ };
20346
+ const WIMX_IMMUTABLE_TESTNET = {
20347
+ chainId: IMMUTABLE_TESTNET_CHAIN_ID,
20348
+ address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
20349
+ decimals: 18,
20350
+ symbol: 'WIMX',
20351
+ name: 'Wrapped Immutable Testnet Token',
20352
+ type: 'erc20',
20353
+ };
20354
+ const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
20355
+ WIMX_IMMUTABLE_TESTNET,
20356
+ ];
20357
+
20358
+ const NATIVE_IMX_IMMUTABLE_MAINNET = {
20359
+ chainId: IMMUTABLE_MAINNET_CHAIN_ID,
20360
+ decimals: 18,
20361
+ symbol: 'IMX',
20362
+ name: 'Immutable Token',
20363
+ type: 'native',
20364
+ };
20365
+ const WIMX_IMMUTABLE_MAINNET = {
20366
+ chainId: IMMUTABLE_MAINNET_CHAIN_ID,
20367
+ address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
20368
+ decimals: 18,
20369
+ symbol: 'WIMX',
20370
+ name: 'Wrapped Immutable Token',
20371
+ type: 'erc20',
20372
+ };
20373
+ const ETH_IMMUTABLE_MAINNET = {
20374
+ chainId: IMMUTABLE_MAINNET_CHAIN_ID,
20375
+ address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
20376
+ decimals: 18,
20377
+ symbol: 'ETH',
20378
+ name: 'Ethereum',
20379
+ type: 'erc20',
20380
+ };
20381
+ const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
20382
+ WIMX_IMMUTABLE_MAINNET,
20383
+ ETH_IMMUTABLE_MAINNET,
20384
+ ];
20385
+
20330
20386
  const getFeeData = async (provider) => {
20331
20387
  const [block, maxPriorityFeePerGas] = await Promise.all([
20332
20388
  provider.getBlock('latest'),
@@ -20362,9 +20418,13 @@ const fetchGasPrice = async (provider, nativeToken) => {
20362
20418
  * @param {BigNumber} gasEstimate - The total gas units that will be used for the transaction
20363
20419
  * @returns - The cost of the transaction in the gas token's smallest denomination (e.g. WEI)
20364
20420
  */
20365
- const calculateGasFee = (gasPrice, gasEstimate) =>
20366
- // eslint-disable-next-line implicit-arrow-linebreak
20367
- newAmount(gasEstimate.mul(gasPrice.value), gasPrice.token);
20421
+ const calculateGasFee = (hasSecondaryFees, gasPrice, gasEstimate) => {
20422
+ const baseGasFee = newAmount(gasEstimate.mul(gasPrice.value), gasPrice.token);
20423
+ if (!hasSecondaryFees)
20424
+ return baseGasFee;
20425
+ return newAmount(baseGasFee.value.add(gasPrice.value.mul(AVERAGE_SECONDARY_FEE_EXTRA_GAS)), gasPrice.token);
20426
+ // eslint-disable-next-line implicit-arrow-linebreak
20427
+ };
20368
20428
 
20369
20429
  /**
20370
20430
  * Check if the spender needs approval for the token
@@ -20451,7 +20511,7 @@ const getApproval = async (provider, ownerAddress, preparedApproval, gasPrice) =
20451
20511
  return null;
20452
20512
  }
20453
20513
  const gasEstimate = await getApproveGasEstimate(provider, ownerAddress, preparedApproval.spender, preparedApproval.amount.token.address);
20454
- const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, gasEstimate) : null;
20514
+ const gasFeeEstimate = gasPrice ? calculateGasFee(false, gasPrice, gasEstimate) : null;
20455
20515
  return {
20456
20516
  transaction: approveTransaction,
20457
20517
  gasFeeEstimate: gasFeeEstimate ? toPublicAmount(gasFeeEstimate) : null,
@@ -20600,59 +20660,6 @@ const IMX_WRAP_GAS_COST = 45038;
20600
20660
  // to avoid an extra remote call.
20601
20661
  const IMX_UNWRAP_GAS_COST = 35216;
20602
20662
 
20603
- const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
20604
- const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
20605
-
20606
- const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
20607
- const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
20608
-
20609
- const NATIVE_IMX_IMMUTABLE_TESTNET = {
20610
- chainId: IMMUTABLE_TESTNET_CHAIN_ID,
20611
- decimals: 18,
20612
- symbol: 'tIMX',
20613
- name: 'Immutable Testnet Token',
20614
- type: 'native',
20615
- };
20616
- const WIMX_IMMUTABLE_TESTNET = {
20617
- chainId: IMMUTABLE_TESTNET_CHAIN_ID,
20618
- address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
20619
- decimals: 18,
20620
- symbol: 'WIMX',
20621
- name: 'Wrapped Immutable Testnet Token',
20622
- type: 'erc20',
20623
- };
20624
- const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
20625
- WIMX_IMMUTABLE_TESTNET,
20626
- ];
20627
-
20628
- const NATIVE_IMX_IMMUTABLE_MAINNET = {
20629
- chainId: IMMUTABLE_MAINNET_CHAIN_ID,
20630
- decimals: 18,
20631
- symbol: 'IMX',
20632
- name: 'Immutable Token',
20633
- type: 'native',
20634
- };
20635
- const WIMX_IMMUTABLE_MAINNET = {
20636
- chainId: IMMUTABLE_MAINNET_CHAIN_ID,
20637
- address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
20638
- decimals: 18,
20639
- symbol: 'WIMX',
20640
- name: 'Wrapped Immutable Token',
20641
- type: 'erc20',
20642
- };
20643
- const ETH_IMMUTABLE_MAINNET = {
20644
- chainId: IMMUTABLE_MAINNET_CHAIN_ID,
20645
- address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
20646
- decimals: 18,
20647
- symbol: 'ETH',
20648
- name: 'Ethereum',
20649
- type: 'erc20',
20650
- };
20651
- const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
20652
- WIMX_IMMUTABLE_MAINNET,
20653
- ETH_IMMUTABLE_MAINNET,
20654
- ];
20655
-
20656
20663
  const zeroNativeCurrencyValue = '0x00';
20657
20664
  const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
20658
20665
  function buildSinglePoolSwap(tokenIn, tokenOut, recipient, trade, route, amountIn, amountOut, routerContract, paymentsContract) {
@@ -20893,8 +20900,8 @@ const getSwapRecipient = (tokenOut, fromAddress, routerContractAddress, secondar
20893
20900
  function getSwap(tokenIn, tokenOut, adjustedQuote, fromAddress, slippage, deadline, routerContractAddress, secondaryFeesContractAddress, gasPrice, secondaryFees) {
20894
20901
  const swapRecipient = getSwapRecipient(tokenOut, fromAddress, routerContractAddress, secondaryFeesContractAddress, secondaryFees);
20895
20902
  const { calldata, maximumAmountIn } = createSwapParameters(tokenIn, tokenOut, adjustedQuote, swapRecipient, slippage, deadline, secondaryFees);
20896
- // TODO: Add additional gas fee estimates for secondary fees
20897
- const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, adjustedQuote.gasEstimate) : null;
20903
+ const hasSecondaryFees = secondaryFees.length > 0;
20904
+ const gasFeeEstimate = gasPrice ? calculateGasFee(hasSecondaryFees, gasPrice, adjustedQuote.gasEstimate) : null;
20898
20905
  const transactionValue = getTransactionValue(tokenIn, maximumAmountIn);
20899
20906
  return {
20900
20907
  transaction: {
@@ -21116,7 +21123,7 @@ class Exchange {
21116
21123
  async getUnwrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
21117
21124
  const calldata = wimxInterface.encodeFunctionData('withdraw', [tokenAmount]);
21118
21125
  const gasEstimate = ethers.BigNumber.from(IMX_UNWRAP_GAS_COST);
21119
- const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
21126
+ const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
21120
21127
  // This transaction is for calling calling `withdraw` on the WETH/WIMX contract.
21121
21128
  const transactionDetails = {
21122
21129
  transaction: {
@@ -21134,7 +21141,7 @@ class Exchange {
21134
21141
  getWrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
21135
21142
  const calldata = wimxInterface.encodeFunctionData('deposit');
21136
21143
  const gasEstimate = ethers.BigNumber.from(IMX_WRAP_GAS_COST);
21137
- const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
21144
+ const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
21138
21145
  // This transaction is for calling calling `deposit` on the WETH/WIMX contract.
21139
21146
  const transactionDetails = {
21140
21147
  transaction: {
@@ -27266,7 +27273,7 @@ class APIError extends Error {
27266
27273
 
27267
27274
  /* eslint-disable implicit-arrow-linebreak */
27268
27275
  const defaultHeaders = {
27269
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.0',
27276
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.2',
27270
27277
  };
27271
27278
  /**
27272
27279
  * createAPIConfiguration to create a custom Configuration
@@ -28633,7 +28640,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
28633
28640
  maxPriorityFeePerGas: BigNumber$1.from(10e9),
28634
28641
  };
28635
28642
 
28636
- const SDK_VERSION_MARKER = '1.5.0';
28643
+ const SDK_VERSION_MARKER = '1.5.2';
28637
28644
  // This SDK version is replaced by the `yarn build` command ran on the root level
28638
28645
  const globalPackageVersion = () => SDK_VERSION_MARKER;
28639
28646
 
@@ -31895,9 +31902,7 @@ const buy = async (config, provider, orders, overrides = {
31895
31902
  };
31896
31903
  };
31897
31904
 
31898
- const cancel = async (config, provider, orderIds, overrides = {
31899
- waitFulfillmentSettlements: true,
31900
- }) => {
31905
+ const cancelOnChain = async (config, orderbook, provider, orderIds, waitFulfillmentSettlements) => {
31901
31906
  let unsignedCancelOrderTransaction;
31902
31907
  if (orderIds.length === 0) {
31903
31908
  throw new CheckoutError('No orderIds were provided to the orderIds array. Please provide at least one orderId.', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR);
@@ -31906,7 +31911,6 @@ const cancel = async (config, provider, orderIds, overrides = {
31906
31911
  const orderId = orderIds[0];
31907
31912
  try {
31908
31913
  const offererAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
31909
- const orderbook = createOrderbookInstance(config);
31910
31914
  const cancelOrderResponse = await measureAsyncExecution(config, 'Time to get the cancel order from the orderbook', orderbook.cancelOrdersOnChain([orderId], offererAddress));
31911
31915
  unsignedCancelOrderTransaction = await cancelOrderResponse.cancellationAction.buildTransaction();
31912
31916
  }
@@ -31916,7 +31920,7 @@ const cancel = async (config, provider, orderIds, overrides = {
31916
31920
  error: err,
31917
31921
  });
31918
31922
  }
31919
- if (overrides.waitFulfillmentSettlements) {
31923
+ if (waitFulfillmentSettlements) {
31920
31924
  const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
31921
31925
  if (result.type === SignTransactionStatusType.FAILED) {
31922
31926
  return {
@@ -31944,6 +31948,56 @@ const cancel = async (config, provider, orderIds, overrides = {
31944
31948
  transactions,
31945
31949
  };
31946
31950
  };
31951
+ const gaslessCancel = async (orderbook, provider, orderIds) => {
31952
+ try {
31953
+ const signer = provider.getSigner();
31954
+ const address = await signer.getAddress();
31955
+ const { signableAction } = await orderbook.prepareOrderCancellations(orderIds);
31956
+ // eslint-disable-next-line no-underscore-dangle
31957
+ const signedMessage = await signer._signTypedData(signableAction.message.domain, signableAction.message.types, signableAction.message.value);
31958
+ const { result } = await orderbook.cancelOrders(orderIds, address, signedMessage);
31959
+ const successfulCancellations = [];
31960
+ const failedCancellations = [];
31961
+ const pendingCancellations = [];
31962
+ for (const success of result.successful_cancellations) {
31963
+ successfulCancellations.push({
31964
+ orderId: success,
31965
+ });
31966
+ }
31967
+ for (const failed of result.failed_cancellations) {
31968
+ failedCancellations.push({
31969
+ orderId: failed.order,
31970
+ reason: failed.reason_code,
31971
+ });
31972
+ }
31973
+ for (const pending of result.pending_cancellations) {
31974
+ pendingCancellations.push({
31975
+ orderId: pending,
31976
+ });
31977
+ }
31978
+ return {
31979
+ successfulCancellations,
31980
+ failedCancellations,
31981
+ pendingCancellations,
31982
+ };
31983
+ }
31984
+ catch (err) {
31985
+ throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
31986
+ orderIds,
31987
+ error: err,
31988
+ });
31989
+ }
31990
+ };
31991
+ const cancel = async (config, provider, orderIds, overrides = {
31992
+ waitFulfillmentSettlements: true,
31993
+ useGaslessCancel: false,
31994
+ }) => {
31995
+ const orderbook = createOrderbookInstance(config);
31996
+ if (overrides.useGaslessCancel) {
31997
+ return await gaslessCancel(orderbook, provider, orderIds);
31998
+ }
31999
+ return await cancelOnChain(config, orderbook, provider, orderIds, overrides.waitFulfillmentSettlements ?? true);
32000
+ };
31947
32001
 
31948
32002
  const getERC721Requirement = (id, contractAddress, spenderAddress) => ({
31949
32003
  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.5.0';
130
+ const SDK_VERSION = '1.5.2';
131
131
  let initialised = false;
132
132
  const isInitialised = () => initialised;
133
133
  const getReferrer = () => {