@imtbl/sdk 0.44.2 → 0.44.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -10641,7 +10641,7 @@ class MultiRollupApiClients {
10641
10641
  }
10642
10642
 
10643
10643
  // eslint-disable-next-line @typescript-eslint/naming-convention
10644
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.2' };
10644
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.44.4' };
10645
10645
  const createConfig = ({ basePath, headers, }) => {
10646
10646
  if (!basePath.trim()) {
10647
10647
  throw Error('basePath can not be empty');
@@ -10713,7 +10713,7 @@ class APIError extends Error {
10713
10713
 
10714
10714
  /* eslint-disable implicit-arrow-linebreak */
10715
10715
  const defaultHeaders = {
10716
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.2',
10716
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.4',
10717
10717
  };
10718
10718
  /**
10719
10719
  * createAPIConfiguration to create a custom Configuration
@@ -11152,7 +11152,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
11152
11152
  chainID,
11153
11153
  coreContractAddress,
11154
11154
  registrationContractAddress,
11155
- sdkVersion: 'ts-immutable-sdk-0.44.2',
11155
+ sdkVersion: 'ts-immutable-sdk-0.44.4',
11156
11156
  });
11157
11157
  /**
11158
11158
  * Sets `sdkVersion` at the time of build
@@ -17902,7 +17902,8 @@ class Passport {
17902
17902
  this.passportEventEmitter = new TypedEventEmitter();
17903
17903
  const imxClientConfig = this.config.baseConfig.environment === Environment$1.PRODUCTION
17904
17904
  ? imxApiConfig.getProduction() : imxApiConfig.getSandbox();
17905
- const imxApiClients = new ImxApiClients(imxClientConfig);
17905
+ const imxApiClients = passportModuleConfiguration.overrides?.imxApiClients
17906
+ || new ImxApiClients(imxClientConfig);
17906
17907
  this.passportImxProviderFactory = new PassportImxProviderFactory({
17907
17908
  authManager: this.authManager,
17908
17909
  config: this.config,
@@ -36448,6 +36449,7 @@ var BridgeMethodsGasLimit;
36448
36449
  BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_SOURCE"] = 200000] = "MAP_TOKEN_SOURCE";
36449
36450
  BridgeMethodsGasLimit[BridgeMethodsGasLimit["MAP_TOKEN_DESTINATION"] = 200000] = "MAP_TOKEN_DESTINATION";
36450
36451
  BridgeMethodsGasLimit[BridgeMethodsGasLimit["FINALISE_WITHDRAWAL"] = 200000] = "FINALISE_WITHDRAWAL";
36452
+ BridgeMethodsGasLimit[BridgeMethodsGasLimit["APPROVE_TOKEN"] = 55000] = "APPROVE_TOKEN";
36451
36453
  })(BridgeMethodsGasLimit || (BridgeMethodsGasLimit = {}));
36452
36454
  var StatusResponse;
36453
36455
  (function (StatusResponse) {
@@ -36635,8 +36637,12 @@ class TokenBridge {
36635
36637
  throw new BridgeError(`Finalised withdrawals must be on the root chain (${this.config.bridgeInstance.rootChainID})`, BridgeErrorType.UNSUPPORTED_ERROR);
36636
36638
  }
36637
36639
  let sourceChainGas = BigNumber.from(0);
36640
+ let approvalFee = BigNumber.from(0);
36638
36641
  let bridgeFee = BigNumber.from(0);
36639
36642
  const imtblFee = BigNumber.from(0);
36643
+ if ('token' in req && req.token !== 'NATIVE') {
36644
+ approvalFee = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.APPROVE_TOKEN);
36645
+ }
36640
36646
  if (req.action === BridgeFeeActions.FINALISE_WITHDRAWAL) {
36641
36647
  sourceChainGas = await this.getGasEstimates(this.config.rootProvider, BridgeMethodsGasLimit.FINALISE_WITHDRAWAL);
36642
36648
  }
@@ -36647,9 +36653,10 @@ class TokenBridge {
36647
36653
  const feeResult = await this.calculateBridgeFee(req.sourceChainId, req.destinationChainId, BridgeMethodsGasLimit[`${req.action}_DESTINATION`], req.gasMultiplier);
36648
36654
  bridgeFee = feeResult.bridgeFee;
36649
36655
  }
36650
- const totalFees = sourceChainGas.add(bridgeFee).add(imtblFee);
36656
+ const totalFees = sourceChainGas.add(approvalFee).add(bridgeFee).add(imtblFee);
36651
36657
  return {
36652
36658
  sourceChainGas,
36659
+ approvalFee,
36653
36660
  bridgeFee,
36654
36661
  imtblFee,
36655
36662
  totalFees,
@@ -36879,6 +36886,8 @@ class TokenBridge {
36879
36886
  gasMultiplier,
36880
36887
  sourceChainId,
36881
36888
  destinationChainId,
36889
+ token,
36890
+ amount,
36882
36891
  });
36883
36892
  const canReceive = await this.checkReceiver(provider, recipient);
36884
36893
  if (!canReceive) {
@@ -41628,7 +41637,7 @@ async function switchWalletNetwork(config, web3Provider, chainId) {
41628
41637
  // eslint-disable-next-line @typescript-eslint/no-shadow
41629
41638
  }
41630
41639
  catch (err) {
41631
- throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
41640
+ throw new CheckoutError('User cancelled add network request', CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
41632
41641
  }
41633
41642
  }
41634
41643
  else {
@@ -41992,7 +42001,7 @@ const GAS_OVERRIDES = {
41992
42001
  maxPriorityFeePerGas: ethers.BigNumber.from(101e9),
41993
42002
  };
41994
42003
 
41995
- const SDK_VERSION_MARKER = '0.44.2';
42004
+ const SDK_VERSION_MARKER = '0.44.4';
41996
42005
  // This SDK version is replaced by the `yarn build` command ran on the root level
41997
42006
  const globalPackageVersion = () => SDK_VERSION_MARKER;
41998
42007
 
@@ -42022,8 +42031,8 @@ class RemoteConfigFetcher {
42022
42031
  try {
42023
42032
  responseData = JSON.parse(response.data);
42024
42033
  }
42025
- catch (jsonError) {
42026
- throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR);
42034
+ catch (err) {
42035
+ throw new CheckoutError('Invalid configuration', CheckoutErrorType.API_ERROR, { error: err });
42027
42036
  }
42028
42037
  }
42029
42038
  return responseData;
@@ -42036,7 +42045,7 @@ class RemoteConfigFetcher {
42036
42045
  response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config`);
42037
42046
  }
42038
42047
  catch (err) {
42039
- throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
42048
+ throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
42040
42049
  }
42041
42050
  // Ensure that the configuration is valid
42042
42051
  this.configCache = this.parseResponse(response);
@@ -42050,7 +42059,7 @@ class RemoteConfigFetcher {
42050
42059
  response = await this.httpClient.get(`${this.getEndpoint()}/${this.version}/config/tokens`);
42051
42060
  }
42052
42061
  catch (err) {
42053
- throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR);
42062
+ throw new CheckoutError(`Error: ${err.message}`, CheckoutErrorType.API_ERROR, { error: err });
42054
42063
  }
42055
42064
  // Ensure that the configuration is valid
42056
42065
  this.tokensCache = this.parseResponse(response);
@@ -42413,7 +42422,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
42413
42422
  // means we are safe to assume that a 404 is a missing wallet due to inactivity
42414
42423
  // or simply an incorrect wallet address was provided.
42415
42424
  if (err?.code !== globalAxios$1.HttpStatusCode.NotFound) {
42416
- throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
42425
+ throw new CheckoutError(err.message || 'InternalServerError | getTokensByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
42417
42426
  }
42418
42427
  }
42419
42428
  };
@@ -42432,7 +42441,7 @@ const getIndexerBalance = async (config, walletAddress, chainId, filterTokens) =
42432
42441
  // means we are safe to assume that a 404 is a missing wallet due to inactivity
42433
42442
  // or simply an incorrect wallet address was provided.
42434
42443
  if (err?.code !== globalAxios$1.HttpStatusCode.NotFound) {
42435
- throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, err);
42444
+ throw new CheckoutError(err.message || 'InternalServerError | getNativeTokenByWalletAddress', CheckoutErrorType.GET_INDEXER_BALANCE_ERROR, { error: err });
42436
42445
  }
42437
42446
  }
42438
42447
  };
@@ -42545,6 +42554,7 @@ async function checkIsWalletConnected(web3Provider) {
42545
42554
  }
42546
42555
  catch (err) {
42547
42556
  throw new CheckoutError('Check wallet connection request failed', CheckoutErrorType.PROVIDER_REQUEST_FAILED_ERROR, {
42557
+ error: err,
42548
42558
  rpcMethod: WalletAction.CHECK_CONNECTION,
42549
42559
  });
42550
42560
  }
@@ -42637,7 +42647,7 @@ async function validateProvider(config, web3Provider, validateProviderOptions) {
42637
42647
  }
42638
42648
  }
42639
42649
  catch (err) {
42640
- throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
42650
+ throw new CheckoutError('Unable to detect the web3Provider network', CheckoutErrorType.WEB3_PROVIDER_ERROR, { error: err });
42641
42651
  }
42642
42652
  if (web3ChainId !== underlyingChainId && !options.allowMistmatchedChainId) {
42643
42653
  throw new CheckoutError('Your wallet has changed network, please switch to a supported network', CheckoutErrorType.WEB3_PROVIDER_ERROR);
@@ -42689,15 +42699,15 @@ const sendTransaction = async (web3Provider, transaction) => {
42689
42699
  }
42690
42700
  catch (err) {
42691
42701
  if (err.code === ethers.ethers.errors.INSUFFICIENT_FUNDS) {
42692
- throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS);
42702
+ throw new CheckoutError(err.message, CheckoutErrorType.INSUFFICIENT_FUNDS, { error: err });
42693
42703
  }
42694
42704
  if (err.code === ethers.ethers.errors.ACTION_REJECTED) {
42695
- throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR);
42705
+ throw new CheckoutError(err.message, CheckoutErrorType.USER_REJECTED_REQUEST_ERROR, { error: err });
42696
42706
  }
42697
42707
  if (err.code === ethers.ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
42698
- throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
42708
+ throw new CheckoutError(err.message, CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
42699
42709
  }
42700
- throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED);
42710
+ throw new CheckoutError(err.message, CheckoutErrorType.TRANSACTION_FAILED, { error: err });
42701
42711
  }
42702
42712
  };
42703
42713
 
@@ -42710,6 +42720,8 @@ async function getBridgeFeeEstimate$1(tokenBridge, fromChainId, toChainId, confi
42710
42720
  gasMultiplier: 1.1,
42711
42721
  sourceChainId: fromChainId.toString(),
42712
42722
  destinationChainId: toChainId.toString(),
42723
+ token: NATIVE.toUpperCase(),
42724
+ amount: ethers.BigNumber.from(0),
42713
42725
  });
42714
42726
  }
42715
42727
 
@@ -42789,6 +42801,7 @@ async function bridgeToL2GasEstimator(readOnlyProviders, config) {
42789
42801
  gasEstimateType: GasEstimateType.BRIDGE_TO_L2,
42790
42802
  fees: {
42791
42803
  sourceChainGas: ethers.BigNumber.from(0),
42804
+ approvalFee: ethers.BigNumber.from(0),
42792
42805
  bridgeFee: ethers.BigNumber.from(0),
42793
42806
  imtblFee: ethers.BigNumber.from(0),
42794
42807
  totalFees: ethers.BigNumber.from(0),
@@ -42938,7 +42951,7 @@ const getERC20Allowance = async (provider, ownerAddress, contractAddress, spende
42938
42951
  return await contract.allowance(ownerAddress, spenderAddress);
42939
42952
  }
42940
42953
  catch (err) {
42941
- throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
42954
+ throw new CheckoutError('Failed to get the allowance for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
42942
42955
  }
42943
42956
  };
42944
42957
  // Returns the approval transaction for the ERC20 that the owner can sign
@@ -42951,8 +42964,8 @@ const getERC20ApprovalTransaction = async (provider, ownerAddress, contractAddre
42951
42964
  approveTransaction.from = ownerAddress;
42952
42965
  return approveTransaction;
42953
42966
  }
42954
- catch {
42955
- throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress });
42967
+ catch (err) {
42968
+ throw new CheckoutError('Failed to get the approval transaction for ERC20', CheckoutErrorType.GET_ERC20_ALLOWANCE_ERROR, { contractAddress, error: err });
42956
42969
  }
42957
42970
  };
42958
42971
  const hasERC20Allowances = async (provider, ownerAddress, itemRequirements) => {
@@ -43024,7 +43037,12 @@ const getERC721ApprovedForAll = async (provider, ownerAddress, contractAddress,
43024
43037
  return await contract.isApprovedForAll(ownerAddress, spenderAddress);
43025
43038
  }
43026
43039
  catch (err) {
43027
- throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, { ownerAddress, contractAddress, spenderAddress });
43040
+ throw new CheckoutError('Failed to check approval for all ERC721s of collection', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
43041
+ ownerAddress,
43042
+ contractAddress,
43043
+ spenderAddress,
43044
+ error: err,
43045
+ });
43028
43046
  }
43029
43047
  };
43030
43048
  // Returns a populated transaction to approve the ERC721 for the spender.
@@ -43038,7 +43056,11 @@ const getApproveTransaction = async (provider, ownerAddress, contractAddress, sp
43038
43056
  }
43039
43057
  catch (err) {
43040
43058
  throw new CheckoutError('Failed to get the approval transaction for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
43041
- id: id.toString(), contractAddress, spenderAddress, ownerAddress,
43059
+ id: id.toString(),
43060
+ contractAddress,
43061
+ spenderAddress,
43062
+ ownerAddress,
43063
+ error: err,
43042
43064
  });
43043
43065
  }
43044
43066
  };
@@ -43050,7 +43072,11 @@ const getERC721ApprovedAddress = async (provider, contractAddress, id) => {
43050
43072
  return await contract.getApproved(id);
43051
43073
  }
43052
43074
  catch (err) {
43053
- throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, { id: id.toString(), contractAddress });
43075
+ throw new CheckoutError('Failed to get approved address for ERC721', CheckoutErrorType.GET_ERC721_ALLOWANCE_ERROR, {
43076
+ id: id.toString(),
43077
+ contractAddress,
43078
+ error: err,
43079
+ });
43054
43080
  }
43055
43081
  };
43056
43082
  const convertIdToNumber = (id, contractAddress) => {
@@ -43378,8 +43404,8 @@ const getTokenBalances = async (config, provider, ownerAddress, itemRequirements
43378
43404
  const { balances } = await getAllBalances(config, provider, ownerAddress, getL2ChainId(config));
43379
43405
  return balances.filter((balance) => tokenMap.get((balance.token.address || NATIVE).toLocaleLowerCase()));
43380
43406
  }
43381
- catch (error) {
43382
- throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR);
43407
+ catch (err) {
43408
+ throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR, { error: err });
43383
43409
  }
43384
43410
  };
43385
43411
  /**
@@ -43417,8 +43443,8 @@ const getERC721Balances = async (provider, ownerAddress, itemRequirements) => {
43417
43443
  });
43418
43444
  });
43419
43445
  }
43420
- catch (error) {
43421
- throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR);
43446
+ catch (err) {
43447
+ throw new CheckoutError('Failed to get ERC721 balances', CheckoutErrorType.GET_ERC721_BALANCE_ERROR, { error: err });
43422
43448
  }
43423
43449
  return erc721Balances;
43424
43450
  };
@@ -43488,7 +43514,7 @@ const estimateGas = async (provider, transaction) => {
43488
43514
  return await provider.estimateGas(transaction);
43489
43515
  }
43490
43516
  catch (err) {
43491
- throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT);
43517
+ throw new CheckoutError('Failed to estimate gas for transaction', CheckoutErrorType.UNPREDICTABLE_GAS_LIMIT, { error: err });
43492
43518
  }
43493
43519
  };
43494
43520
  const getGasItemRequirement = (gas, transactionOrGas) => {
@@ -43552,14 +43578,14 @@ const availabilityService = (isDevelopment, isProduction) => {
43552
43578
  try {
43553
43579
  response = await globalAxios$1.post(`${postEndpoint()}/v1/availability/checkout/swap`);
43554
43580
  }
43555
- catch (error) {
43581
+ catch (err) {
43556
43582
  // The request was made and the server responded with a status code
43557
43583
  // that falls out of the range of 2xx
43558
- response = error.response;
43584
+ response = err.response;
43559
43585
  // If 403 then the service is geo-blocked
43560
43586
  if (response.status === 403)
43561
43587
  return false;
43562
- throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR);
43588
+ throw new CheckoutError(`Error fetching from api: ${response.status} ${response.statusText}`, CheckoutErrorType.API_ERROR, { error: err });
43563
43589
  }
43564
43590
  return true;
43565
43591
  };
@@ -44070,7 +44096,7 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
44070
44096
  };
44071
44097
  }
44072
44098
  catch (err) {
44073
- throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { message: err.message });
44099
+ throw new CheckoutError('Error estimating gas for bridge', CheckoutErrorType.BRIDGE_GAS_ESTIMATE_ERROR, { error: err });
44074
44100
  }
44075
44101
  };
44076
44102
 
@@ -44720,7 +44746,7 @@ const routingCalculator = async (config, ownerAddress, balanceRequirements, avai
44720
44746
  readOnlyProviders = await createReadOnlyProviders(config);
44721
44747
  }
44722
44748
  catch (err) {
44723
- throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, { message: err.message });
44749
+ throw new CheckoutError('Error occurred while creating read only providers', CheckoutErrorType.PROVIDER_ERROR, { error: err });
44724
44750
  }
44725
44751
  const tokenBalances = await measureAsyncExecution(config, 'Time to get token balances inside router', getAllTokenBalances(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
44726
44752
  const allowList = await measureAsyncExecution(config, 'Time to get routing allowlist', allowListCheck(config, tokenBalances, availableRoutingOptions));
@@ -44843,9 +44869,7 @@ const signApprovalTransactions = async (provider, approvalTransactions) => {
44843
44869
  receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
44844
44870
  }
44845
44871
  catch (err) {
44846
- throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, {
44847
- message: err.message,
44848
- });
44872
+ throw new CheckoutError('An error occurred while executing the approval transaction', CheckoutErrorType.EXECUTE_APPROVAL_TRANSACTION_ERROR, { error: err });
44849
44873
  }
44850
44874
  for (const receipt of receipts) {
44851
44875
  if (receipt.status === 0) {
@@ -44867,9 +44891,7 @@ const signFulfillmentTransactions = async (provider, fulfillmentTransactions) =>
44867
44891
  receipts = await Promise.all(response.map((transaction) => transaction.transactionResponse.wait()));
44868
44892
  }
44869
44893
  catch (err) {
44870
- throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
44871
- message: err.message,
44872
- });
44894
+ throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, { error: err });
44873
44895
  }
44874
44896
  for (const receipt of receipts) {
44875
44897
  if (receipt.status === 0) {
@@ -44895,9 +44917,7 @@ const signMessage = async (provider, unsignedMessage) => {
44895
44917
  };
44896
44918
  }
44897
44919
  catch (err) {
44898
- throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, {
44899
- message: err.message,
44900
- });
44920
+ throw new CheckoutError('An error occurred while signing the message', CheckoutErrorType.SIGN_MESSAGE_ERROR, { error: err });
44901
44921
  }
44902
44922
  };
44903
44923
 
@@ -45080,8 +45100,8 @@ const buy = async (config, provider, orders, overrides = {
45080
45100
  }
45081
45101
  catch (err) {
45082
45102
  throw new CheckoutError('An error occurred while getting the order listing', CheckoutErrorType.GET_ORDER_LISTING_ERROR, {
45103
+ error: err,
45083
45104
  orderId: id,
45084
- message: err.message,
45085
45105
  });
45086
45106
  }
45087
45107
  if (order.result.buy.length === 0) {
@@ -45120,7 +45140,7 @@ const buy = async (config, provider, orders, overrides = {
45120
45140
  if (!err.message.includes('The fulfiller does not have the balances needed to fulfill')) {
45121
45141
  throw new CheckoutError('Error occurred while trying to fulfill the order', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
45122
45142
  orderId: id,
45123
- message: err.message,
45143
+ error: err,
45124
45144
  });
45125
45145
  }
45126
45146
  }
@@ -45179,9 +45199,7 @@ const buy = async (config, provider, orders, overrides = {
45179
45199
  }
45180
45200
  }
45181
45201
  catch (err) {
45182
- throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, {
45183
- message: err.message,
45184
- });
45202
+ throw new CheckoutError('Error fetching fulfillment transaction', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR, { error: err });
45185
45203
  }
45186
45204
  if (overrides.waitFulfillmentSettlements) {
45187
45205
  const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
@@ -45220,7 +45238,9 @@ const buy = async (config, provider, orders, overrides = {
45220
45238
  };
45221
45239
  };
45222
45240
 
45223
- const cancel = async (config, provider, orderIds) => {
45241
+ const cancel = async (config, provider, orderIds, overrides = {
45242
+ waitFulfillmentSettlements: true,
45243
+ }) => {
45224
45244
  let unsignedCancelOrderTransaction;
45225
45245
  if (orderIds.length === 0) {
45226
45246
  throw new CheckoutError('No orderIds were provided to the orderIds array. Please provide at least one orderId.', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR);
@@ -45236,19 +45256,35 @@ const cancel = async (config, provider, orderIds) => {
45236
45256
  catch (err) {
45237
45257
  throw new CheckoutError('An error occurred while cancelling the order listing', CheckoutErrorType.CANCEL_ORDER_LISTING_ERROR, {
45238
45258
  orderId,
45239
- message: err.message,
45259
+ error: err,
45240
45260
  });
45241
45261
  }
45242
- const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
45243
- if (result.type === SignTransactionStatusType.FAILED) {
45262
+ if (overrides.waitFulfillmentSettlements) {
45263
+ const result = await signFulfillmentTransactions(provider, [unsignedCancelOrderTransaction]);
45264
+ if (result.type === SignTransactionStatusType.FAILED) {
45265
+ return {
45266
+ status: CheckoutStatus.FAILED,
45267
+ transactionHash: result.transactionHash,
45268
+ reason: result.reason,
45269
+ };
45270
+ }
45244
45271
  return {
45245
- status: CheckoutStatus.FAILED,
45246
- transactionHash: result.transactionHash,
45247
- reason: result.reason,
45272
+ status: CheckoutStatus.SUCCESS,
45248
45273
  };
45249
45274
  }
45275
+ let transactions;
45276
+ try {
45277
+ const response = await Promise.all([unsignedCancelOrderTransaction].map((transaction) => sendTransaction(provider, transaction)));
45278
+ transactions = response.map((result) => result.transactionResponse);
45279
+ }
45280
+ catch (err) {
45281
+ throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
45282
+ message: err.message,
45283
+ });
45284
+ }
45250
45285
  return {
45251
- status: CheckoutStatus.SUCCESS,
45286
+ status: CheckoutStatus.FULFILLMENTS_UNSETTLED,
45287
+ transactions,
45252
45288
  };
45253
45289
  };
45254
45290
 
@@ -45305,7 +45341,7 @@ const sell = async (config, provider, orders) => {
45305
45341
  }
45306
45342
  catch (err) {
45307
45343
  throw new CheckoutError('An error occurred while preparing the listing', CheckoutErrorType.PREPARE_ORDER_LISTING_ERROR, {
45308
- message: err.message,
45344
+ error: err,
45309
45345
  id: sellToken.id,
45310
45346
  collectionAddress: sellToken.collectionAddress,
45311
45347
  });
@@ -45361,7 +45397,7 @@ const sell = async (config, provider, orders) => {
45361
45397
  }
45362
45398
  catch (err) {
45363
45399
  throw new CheckoutError('An error occurred while creating the listing', CheckoutErrorType.CREATE_ORDER_LISTING_ERROR, {
45364
- message: err.message,
45400
+ error: err,
45365
45401
  collectionId: sellToken.id,
45366
45402
  collectionAddress: sellToken.collectionAddress,
45367
45403
  });
@@ -45658,7 +45694,7 @@ class Checkout {
45658
45694
  }
45659
45695
  }
45660
45696
  catch (err) {
45661
- reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { message: err.message }));
45697
+ reject(new CheckoutError('Failed to load widgets script', CheckoutErrorType.WIDGETS_SCRIPT_LOAD_ERROR, { error: err }));
45662
45698
  }
45663
45699
  });
45664
45700
  return factory;
@@ -45812,7 +45848,7 @@ class Checkout {
45812
45848
  // eslint-disable-next-line no-console
45813
45849
  console.warn('This endpoint currently only processes the first order in the array.');
45814
45850
  const web3Provider = await validateProvider(this.config, params.provider);
45815
- return await cancel(this.config, web3Provider, params.orderIds);
45851
+ return await cancel(this.config, web3Provider, params.orderIds, params.overrides);
45816
45852
  }
45817
45853
  /**
45818
45854
  * Determines the transaction requirements to complete a purchase.
@@ -45824,8 +45860,8 @@ class Checkout {
45824
45860
  try {
45825
45861
  itemRequirements = await getItemRequirementsFromRequirements(web3Provider, params.itemRequirements);
45826
45862
  }
45827
- catch (error) {
45828
- throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR);
45863
+ catch (err) {
45864
+ throw new CheckoutError('Failed to map item requirements', CheckoutErrorType.ITEM_REQUIREMENTS_ERROR, { error: err });
45829
45865
  }
45830
45866
  return await smartCheckout(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
45831
45867
  }