@imtbl/sdk 0.44.1 → 0.44.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.
@@ -10748,7 +10748,7 @@ interface FeePercentage {
10748
10748
  percentageDecimal: number;
10749
10749
  }
10750
10750
 
10751
- type BuyResult = BuyResultSuccess | BuyResultFailed | BuyResultInsufficientFunds;
10751
+ type BuyResult = BuyResultSuccess | BuyResultFailed | BuyResultFulfillmentsUnsettled | BuyResultInsufficientFunds;
10752
10752
  /**
10753
10753
  * Represents the result of {@link Checkout.buy}
10754
10754
  * @property {CheckoutStatus.SUCCESS} status
@@ -10777,6 +10777,20 @@ type BuyResultFailed = {
10777
10777
  /** The sufficient result of smart checkout */
10778
10778
  smartCheckoutResult: SmartCheckoutSufficient;
10779
10779
  };
10780
+ /**
10781
+ * Represents the result of {@link Checkout.buy}
10782
+ * @property {CheckoutStatus.FULFILLMENTS_UNSETTLED} status
10783
+ * @property {SmartCheckoutSufficient} smartCheckoutResult
10784
+ * @property {SendTransactionResult[]} transactions
10785
+ */
10786
+ type BuyResultFulfillmentsUnsettled = {
10787
+ /** The status to indicate success */
10788
+ status: CheckoutStatus.FULFILLMENTS_UNSETTLED;
10789
+ /** The sufficient result of smart checkout */
10790
+ smartCheckoutResult: SmartCheckoutSufficient;
10791
+ /** Array of transaction results */
10792
+ transactions: TransactionResponse[];
10793
+ };
10780
10794
  /**
10781
10795
  * Represents the result of {@link Checkout.buy}
10782
10796
  * @property {CheckoutStatus.INSUFFICIENT_FUNDS} status
@@ -10788,6 +10802,14 @@ type BuyResultInsufficientFunds = {
10788
10802
  /** The insufficient result of smart checkout */
10789
10803
  smartCheckoutResult: SmartCheckoutInsufficient;
10790
10804
  };
10805
+ /**
10806
+ * Represents the overrides available for {@link Checkout.buy}
10807
+ * @property {boolean} waitFulfillmentSettlements
10808
+ */
10809
+ type BuyOverrides = {
10810
+ /** If the buy should wait for the fulfillment transactions to settle */
10811
+ waitFulfillmentSettlements?: boolean;
10812
+ };
10791
10813
  type SellResult = SellResultSuccess | SellResultFailed | SellResultInsufficientFunds;
10792
10814
  /**
10793
10815
  * Represents the result of {@link Checkout.sell}
@@ -10860,11 +10882,13 @@ type CancelResultFailed = {
10860
10882
  * @property {string} SUCCESS - If checkout succeeded as the transactions were able to be processed
10861
10883
  * @property {string} FAILED - If checkout failed due to transactions not settling on chain
10862
10884
  * @property {string} INSUFFICIENT_FUNDS - If checkout failed due to insufficient funds
10885
+ * @property {string} FULFILLMENTS_UNSETTLED - If checkout succeeded but the fulfillment transactions are not yet settled
10863
10886
  */
10864
10887
  declare enum CheckoutStatus {
10865
10888
  SUCCESS = "SUCCESS",
10866
10889
  FAILED = "FAILED",
10867
- INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS"
10890
+ INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS",
10891
+ FULFILLMENTS_UNSETTLED = "FULFILLMENTS_UNSETTLED"
10868
10892
  }
10869
10893
  /**
10870
10894
  * The type representing the order to buy
@@ -11423,11 +11447,13 @@ type AvailableRoutingOptions = {
11423
11447
  * Interface representing the parameters for {@link Checkout.buy}
11424
11448
  * @property {Web3Provider} provider - The provider to use for the buy.
11425
11449
  * @property {Array<BuyOrder>} orders - The orders to buy
11450
+ * @property {BuyOverrides} overrides - The overrides to use for the buy.
11426
11451
  * Currently only processes the first order in the array until batch processing is supported.
11427
11452
  */
11428
11453
  interface BuyParams {
11429
11454
  provider: Web3Provider;
11430
11455
  orders: Array<BuyOrder>;
11456
+ overrides?: BuyOverrides;
11431
11457
  }
11432
11458
 
11433
11459
  /**
@@ -13527,4 +13553,4 @@ declare class BlockExplorerService {
13527
13553
  static getTransactionLink(chainId: ChainId, hash: string): string | undefined;
13528
13554
  }
13529
13555
 
13530
- export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BlockExplorerService, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeTransactionSent, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyParams, BuyResult, BuyResultFailed, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CancelParams, CancelResult, CancelResultFailed, 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 };
13556
+ export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BlockExplorerService, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeTransactionSent, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyOverrides, BuyParams, BuyResult, BuyResultFailed, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CancelParams, CancelResult, CancelResultFailed, 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 };
package/dist/checkout.js CHANGED
@@ -16336,38 +16336,84 @@ class TokenBridge {
16336
16336
  * @throws {BridgeError} - If an error occurs during the query, a BridgeError will be thrown with a specific error type.
16337
16337
  */
16338
16338
  async getTransactionStatus(req) {
16339
- const axelarAPIEndpoint = this.getAxelarEndpoint(req.sourceChainId);
16340
16339
  const txStatusResponse = {
16341
16340
  transactions: [],
16342
16341
  };
16343
- const abiCoder = new AbiCoder();
16344
- const statusPromises = [];
16345
- for (const transaction of req.transactions) {
16346
- statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
16342
+ const txStatusItems = await this.getAxelarStatus(req.transactions, req.sourceChainId);
16343
+ const uniqueReceivers = await this.getUniqueReceivers(txStatusItems, req.sourceChainId);
16344
+ const pendingWithdrawalPromises = [];
16345
+ for (const address of uniqueReceivers) {
16346
+ pendingWithdrawalPromises.push(this.getPendingWithdrawals({ recipient: address }));
16347
16347
  }
16348
- let statusResponses;
16348
+ let pendingWithdrawalResponses = [];
16349
16349
  try {
16350
- statusResponses = await Promise.all(statusPromises);
16350
+ pendingWithdrawalResponses = await Promise.all(pendingWithdrawalPromises);
16351
16351
  }
16352
16352
  catch (err) {
16353
- throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
16353
+ console.log('err', err);
16354
+ throw new BridgeError(`Failed to fetch the pending withdrawals with: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
16354
16355
  }
16355
- const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
16356
+ txStatusResponse.transactions = txStatusItems;
16357
+ // try match a completed transaction to a pending flowRate transaction
16358
+ for (const txStatusRes of txStatusResponse.transactions) {
16359
+ if (txStatusRes.status === StatusResponse.COMPLETE) {
16360
+ (() => {
16361
+ for (const pendingWithdrawals of pendingWithdrawalResponses) {
16362
+ const flowRatedTxIndex = pendingWithdrawals.pending.findIndex((el) => (el.amount.toString() === txStatusRes.amount.toString()
16363
+ && el.token === txStatusRes.token
16364
+ && el.withdrawer === txStatusRes.sender
16365
+ && el.recipient === txStatusRes.recipient));
16366
+ if (flowRatedTxIndex !== -1) {
16367
+ txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
16368
+ txStatusRes.data = {
16369
+ canWithdraw: pendingWithdrawals.pending[flowRatedTxIndex].canWithdraw,
16370
+ timeoutStart: pendingWithdrawals.pending[flowRatedTxIndex].timeoutStart,
16371
+ timeoutEnd: pendingWithdrawals.pending[flowRatedTxIndex].timeoutEnd,
16372
+ };
16373
+ pendingWithdrawals.pending.splice(flowRatedTxIndex, 1);
16374
+ return;
16375
+ }
16376
+ }
16377
+ })();
16378
+ }
16379
+ }
16380
+ // Return the tx status response
16381
+ return txStatusResponse;
16382
+ }
16383
+ async getUniqueReceivers(txStatusItems, sourceChainId) {
16384
+ const uniqueReceivers = [];
16356
16385
  const isWithdraw = [
16357
16386
  ZKEVM_DEVNET_CHAIN_ID,
16358
16387
  ZKEVM_TESTNET_CHAIN_ID,
16359
16388
  ZKEVM_MAINNET_CHAIN_ID
16360
- ].includes(req.sourceChainId);
16361
- let rootBridge;
16362
- if (isWithdraw) {
16363
- rootBridge = await withBridgeError(async () => {
16364
- const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
16365
- return contract;
16366
- }, BridgeErrorType.INTERNAL_ERROR);
16389
+ ].includes(sourceChainId);
16390
+ for (let i = 0, l = txStatusItems.length; i < l; i++) {
16391
+ if (txStatusItems[i].status === StatusResponse.COMPLETE
16392
+ && isWithdraw && txStatusItems[i].recipient) {
16393
+ const receiverIndex = uniqueReceivers.findIndex((el) => el === txStatusItems[i].recipient);
16394
+ if (receiverIndex === -1) {
16395
+ uniqueReceivers.push(txStatusItems[i].recipient);
16396
+ }
16397
+ }
16398
+ } // for
16399
+ return uniqueReceivers;
16400
+ }
16401
+ async getAxelarStatus(transactions, sourceChainId) {
16402
+ const txStatusItems = [];
16403
+ const statusPromises = [];
16404
+ const axelarAPIEndpoint = this.getAxelarEndpoint(sourceChainId);
16405
+ const unpaidGasStatus = [GasPaidStatus.GAS_UNPAID, GasPaidStatus.GAS_PAID_NOT_ENOUGH_GAS];
16406
+ const abiCoder = new AbiCoder();
16407
+ for (const transaction of transactions) {
16408
+ statusPromises.push(queryTransactionStatus(axelarAPIEndpoint, transaction.txHash));
16409
+ }
16410
+ let statusResponses;
16411
+ try {
16412
+ statusResponses = await Promise.all(statusPromises);
16413
+ }
16414
+ catch (err) {
16415
+ throw new BridgeError(`Failed to fetch the Axelar Status with the reason: ${err}`, BridgeErrorType.AXELAR_GAS_ESTIMATE_FAILED);
16367
16416
  }
16368
- const flowRatePromises = [];
16369
- const flowRateLengthPromises = [];
16370
- const flowRatePromisesReceivers = [];
16371
16417
  for (let i = 0, l = statusResponses.length; i < l; i++) {
16372
16418
  let metaStatus;
16373
16419
  // consolidate axelar statuses to our own simplified metaStatus
@@ -16401,7 +16447,7 @@ class TokenBridge {
16401
16447
  }
16402
16448
  }
16403
16449
  let txItem = {
16404
- txHash: req.transactions[i].txHash,
16450
+ txHash: transactions[i].txHash,
16405
16451
  status: metaStatus,
16406
16452
  data: {
16407
16453
  gmpResponse: statusResponses[i].status,
@@ -16418,61 +16464,9 @@ class TokenBridge {
16418
16464
  amount: decodedData[4],
16419
16465
  };
16420
16466
  }
16421
- let flowRatePromiseIndex = flowRatePromisesReceivers.findIndex((el) => el === txItem.recipient);
16422
- if (metaStatus === StatusResponse.COMPLETE
16423
- && isWithdraw && txItem.recipient) {
16424
- // consolidate the calls we have to make to the flow rate by receiver
16425
- if (flowRatePromiseIndex === -1) {
16426
- flowRatePromisesReceivers.push(txItem.recipient);
16427
- flowRatePromiseIndex = flowRatePromisesReceivers.length - 1;
16428
- }
16429
- txItem.data.flowRatePromiseIndex = flowRatePromiseIndex;
16430
- }
16431
- txStatusResponse.transactions.push(txItem);
16467
+ txStatusItems.push(txItem);
16432
16468
  } // for
16433
- for (const flowRateReceiver of flowRatePromisesReceivers) {
16434
- flowRateLengthPromises.push(rootBridge.getPendingWithdrawalsLength(flowRateReceiver));
16435
- }
16436
- let flowRateLengthResponses = [];
16437
- try {
16438
- flowRateLengthResponses = await Promise.all(flowRateLengthPromises);
16439
- }
16440
- catch (err) {
16441
- throw new BridgeError(`Failed to fetch the Flow Rate pending lengths with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
16442
- }
16443
- for (let i = 0, l = flowRatePromisesReceivers.length; i < l; i++) {
16444
- const indices = [];
16445
- const indicesLength = flowRateLengthResponses[i].toNumber();
16446
- for (let j = 0; j < indicesLength; j++) {
16447
- indices.push(j);
16448
- }
16449
- flowRatePromises.push(rootBridge.getPendingWithdrawals(flowRatePromisesReceivers[i], indices));
16450
- }
16451
- let flowRateResponses = [];
16452
- if (flowRatePromises.length > 0) {
16453
- try {
16454
- flowRateResponses = await Promise.all(flowRatePromises);
16455
- }
16456
- catch (err) {
16457
- throw new BridgeError(`Failed to fetch the Flow Rate statuses with the reason: ${err}`, BridgeErrorType.FLOW_RATE_ERROR);
16458
- }
16459
- }
16460
- for (const txStatusRes of txStatusResponse.transactions) {
16461
- if (txStatusRes.data.flowRatePromiseIndex !== -1 && flowRateResponses[txStatusRes.data.flowRatePromiseIndex]) {
16462
- const flowRatedTx = flowRateResponses[txStatusRes.data.flowRatePromiseIndex].find((el) => (el.amount.toString() === txStatusRes.amount.toString()
16463
- && el.token === txStatusRes.token
16464
- && el.withdrawer === txStatusRes.sender));
16465
- if (flowRatedTx) {
16466
- txStatusRes.status = StatusResponse.FLOW_RATE_CONTROLLED;
16467
- txStatusRes.data = {
16468
- timestamp: flowRatedTx.timestamp.toString(),
16469
- };
16470
- }
16471
- }
16472
- delete txStatusRes.data.flowRatePromiseIndex;
16473
- }
16474
- // Return the tx status response
16475
- return txStatusResponse;
16469
+ return txStatusItems;
16476
16470
  }
16477
16471
  /**
16478
16472
  * Queries for the information about which tokens are flowrated and how long the delay is.
@@ -16498,6 +16492,7 @@ class TokenBridge {
16498
16492
  token = ETHEREUM_NATIVE_TOKEN_ADDRESS;
16499
16493
  }
16500
16494
  contractPromises.push(rootBridge.flowRateBuckets(token));
16495
+ contractPromises.push(rootBridge.largeTransferThresholds(token));
16501
16496
  }
16502
16497
  let contractPromisesRes;
16503
16498
  try {
@@ -16507,19 +16502,25 @@ class TokenBridge {
16507
16502
  throw new BridgeError('unable to query contract for flowrate info', BridgeErrorType.INTERNAL_ERROR);
16508
16503
  }
16509
16504
  const tokensRes = {};
16510
- // @note it's i + 2 because the first 2 promises are not token buckets
16505
+ const withdrawalQueueActivated = contractPromisesRes[0];
16506
+ const withdrawalDelay = contractPromisesRes[1].toNumber();
16507
+ // remove first 2 items from promise all response
16508
+ contractPromisesRes.splice(0, 2);
16509
+ // the remaining items should be sets of 2 per token
16511
16510
  for (let i = 0, l = req.tokens.length; i < l; i++) {
16511
+ const shifter = i * 2;
16512
16512
  tokensRes[req.tokens[i]] = {
16513
- capacity: contractPromisesRes[i + 2].capacity,
16514
- depth: contractPromisesRes[i + 2].depth,
16515
- refillTime: contractPromisesRes[i + 2].refillTime.toNumber(),
16516
- refillRate: contractPromisesRes[i + 2].refillRate,
16513
+ capacity: contractPromisesRes[shifter].capacity,
16514
+ depth: contractPromisesRes[shifter].depth,
16515
+ refillTime: contractPromisesRes[shifter].refillTime.toNumber(),
16516
+ refillRate: contractPromisesRes[shifter].refillRate,
16517
+ largeTransferThreshold: contractPromisesRes[shifter + 1],
16517
16518
  };
16518
16519
  }
16519
16520
  // Return the token mappings
16520
16521
  return {
16521
- withdrawalQueueActivated: contractPromisesRes[0],
16522
- withdrawalDelay: contractPromisesRes[1].toNumber(),
16522
+ withdrawalQueueActivated,
16523
+ withdrawalDelay,
16523
16524
  tokens: tokensRes,
16524
16525
  };
16525
16526
  }
@@ -16566,6 +16567,7 @@ class TokenBridge {
16566
16567
  canWithdraw: true,
16567
16568
  };
16568
16569
  }
16570
+ pendingWithdrawals.pending[i].recipient = req.recipient;
16569
16571
  pendingWithdrawals.pending[i].withdrawer = pending[i].withdrawer;
16570
16572
  pendingWithdrawals.pending[i].token = pending[i].token;
16571
16573
  pendingWithdrawals.pending[i].amount = pending[i].amount;
@@ -16609,6 +16611,7 @@ class TokenBridge {
16609
16611
  pendingWithdrawal: {
16610
16612
  canWithdraw: false,
16611
16613
  withdrawer: pending[0].withdrawer,
16614
+ recipient: req.recipient,
16612
16615
  token: pending[0].token,
16613
16616
  amount: pending[0].amount,
16614
16617
  timeoutStart: pending[0].timestamp.toNumber(),
@@ -16622,6 +16625,7 @@ class TokenBridge {
16622
16625
  pendingWithdrawal: {
16623
16626
  canWithdraw: true,
16624
16627
  withdrawer: pending[0].withdrawer,
16628
+ recipient: req.recipient,
16625
16629
  token: pending[0].token,
16626
16630
  amount: pending[0].amount,
16627
16631
  timeoutStart: pending[0].timestamp.toNumber(),
@@ -16647,10 +16651,38 @@ class TokenBridge {
16647
16651
  */
16648
16652
  async getTokenMapping(req) {
16649
16653
  // eslint-disable-next-line no-console
16650
- console.log('stubbed response with req', req);
16654
+ if (req.rootToken.toUpperCase() === 'NATIVE'
16655
+ || req.rootToken === this.config.bridgeContracts.rootChainWrappedETH) {
16656
+ const childBridge = await withBridgeError(async () => {
16657
+ const contract = new Contract(this.config.bridgeContracts.childERC20Bridge, CHILD_ERC20_BRIDGE, this.config.childProvider);
16658
+ return contract;
16659
+ }, BridgeErrorType.INTERNAL_ERROR);
16660
+ const childETHToken = await childBridge.childETHToken();
16661
+ return {
16662
+ rootToken: req.rootToken,
16663
+ childToken: childETHToken,
16664
+ };
16665
+ }
16666
+ const rootBridge = await withBridgeError(async () => {
16667
+ const contract = new Contract(this.config.bridgeContracts.rootERC20BridgeFlowRate, ROOT_ERC20_BRIDGE_FLOW_RATE, this.config.rootProvider);
16668
+ return contract;
16669
+ }, BridgeErrorType.INTERNAL_ERROR);
16670
+ const rootTokenChildAddress = await rootBridge.rootTokenToChildToken(req.rootToken);
16671
+ if (rootTokenChildAddress === AddressZero) {
16672
+ return {
16673
+ rootToken: req.rootToken,
16674
+ childToken: null,
16675
+ };
16676
+ }
16677
+ if (rootTokenChildAddress === req.rootToken) {
16678
+ return {
16679
+ rootToken: req.rootToken,
16680
+ childToken: 'NATIVE',
16681
+ };
16682
+ }
16651
16683
  return {
16652
- rootToken: '0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF',
16653
- childToken: 'NATIVE',
16684
+ rootToken: req.rootToken,
16685
+ childToken: rootTokenChildAddress,
16654
16686
  };
16655
16687
  }
16656
16688
  }
@@ -25921,7 +25953,7 @@ class APIError extends Error {
25921
25953
 
25922
25954
  /* eslint-disable implicit-arrow-linebreak */
25923
25955
  const defaultHeaders = {
25924
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.1',
25956
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.2',
25925
25957
  };
25926
25958
  /**
25927
25959
  * createAPIConfiguration to create a custom Configuration
@@ -26600,12 +26632,14 @@ const validateProviderDefaults = {
26600
26632
  * @property {string} SUCCESS - If checkout succeeded as the transactions were able to be processed
26601
26633
  * @property {string} FAILED - If checkout failed due to transactions not settling on chain
26602
26634
  * @property {string} INSUFFICIENT_FUNDS - If checkout failed due to insufficient funds
26635
+ * @property {string} FULFILLMENTS_UNSETTLED - If checkout succeeded but the fulfillment transactions are not yet settled
26603
26636
  */
26604
26637
  var CheckoutStatus;
26605
26638
  (function (CheckoutStatus) {
26606
26639
  CheckoutStatus["SUCCESS"] = "SUCCESS";
26607
26640
  CheckoutStatus["FAILED"] = "FAILED";
26608
26641
  CheckoutStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
26642
+ CheckoutStatus["FULFILLMENTS_UNSETTLED"] = "FULFILLMENTS_UNSETTLED";
26609
26643
  })(CheckoutStatus || (CheckoutStatus = {}));
26610
26644
  /**
26611
26645
  * An enum representing the item types
@@ -27280,7 +27314,7 @@ const GAS_OVERRIDES = {
27280
27314
  maxPriorityFeePerGas: BigNumber$1.from(101e9),
27281
27315
  };
27282
27316
 
27283
- const SDK_VERSION_MARKER = '0.44.1';
27317
+ const SDK_VERSION_MARKER = '0.44.2';
27284
27318
  // This SDK version is replaced by the `yarn build` command ran on the root level
27285
27319
  const globalPackageVersion = () => SDK_VERSION_MARKER;
27286
27320
 
@@ -30341,7 +30375,9 @@ const getTransactionOrGas = (gasLimit, fulfillmentTransactions) => {
30341
30375
  },
30342
30376
  };
30343
30377
  };
30344
- const buy = async (config, provider, orders) => {
30378
+ const buy = async (config, provider, orders, overrides = {
30379
+ waitFulfillmentSettlements: true,
30380
+ }) => {
30345
30381
  if (orders.length === 0) {
30346
30382
  throw new CheckoutError('No orders were provided to the orders array. Please provide at least one order.', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR);
30347
30383
  }
@@ -30469,18 +30505,35 @@ const buy = async (config, provider, orders) => {
30469
30505
  message: err.message,
30470
30506
  });
30471
30507
  }
30472
- const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
30473
- if (fulfillmentResult.type === SignTransactionStatusType.FAILED) {
30508
+ if (overrides.waitFulfillmentSettlements) {
30509
+ const fulfillmentResult = await signFulfillmentTransactions(provider, unsignedFulfillmentTransactions);
30510
+ if (fulfillmentResult.type === SignTransactionStatusType.FAILED) {
30511
+ return {
30512
+ status: CheckoutStatus.FAILED,
30513
+ transactionHash: fulfillmentResult.transactionHash,
30514
+ reason: fulfillmentResult.reason,
30515
+ smartCheckoutResult,
30516
+ };
30517
+ }
30474
30518
  return {
30475
- status: CheckoutStatus.FAILED,
30476
- transactionHash: fulfillmentResult.transactionHash,
30477
- reason: fulfillmentResult.reason,
30519
+ status: CheckoutStatus.SUCCESS,
30478
30520
  smartCheckoutResult,
30479
30521
  };
30480
30522
  }
30523
+ let transactions;
30524
+ try {
30525
+ const response = await Promise.all(unsignedFulfillmentTransactions.map((transaction) => sendTransaction(provider, transaction)));
30526
+ transactions = response.map((result) => result.transactionResponse);
30527
+ }
30528
+ catch (err) {
30529
+ throw new CheckoutError('An error occurred while executing the fulfillment transaction', CheckoutErrorType.EXECUTE_FULFILLMENT_TRANSACTION_ERROR, {
30530
+ message: err.message,
30531
+ });
30532
+ }
30481
30533
  return {
30482
- status: CheckoutStatus.SUCCESS,
30534
+ status: CheckoutStatus.FULFILLMENTS_UNSETTLED,
30483
30535
  smartCheckoutResult,
30536
+ transactions,
30484
30537
  };
30485
30538
  }
30486
30539
  return {
@@ -31057,7 +31110,7 @@ class Checkout {
31057
31110
  console.warn('This endpoint currently only processes the first order in the array.');
31058
31111
  }
31059
31112
  const web3Provider = await validateProvider(this.config, params.provider);
31060
- return await buy(this.config, web3Provider, params.orders);
31113
+ return await buy(this.config, web3Provider, params.orders, params.overrides);
31061
31114
  }
31062
31115
  /**
31063
31116
  * Determines the requirements for performing a sell.
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
17
17
  chainID,
18
18
  coreContractAddress,
19
19
  registrationContractAddress,
20
- sdkVersion: 'ts-immutable-sdk-0.44.1',
20
+ sdkVersion: 'ts-immutable-sdk-0.44.2',
21
21
  });
22
22
  /**
23
23
  * Sets `sdkVersion` at the time of build