@imtbl/sdk 0.22.2 → 0.23.0-alpha

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.js CHANGED
@@ -2987,7 +2987,7 @@ class MultiRollupApiClients {
2987
2987
  }
2988
2988
 
2989
2989
  // eslint-disable-next-line @typescript-eslint/naming-convention
2990
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.22.2' };
2990
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.23.0-alpha' };
2991
2991
  const createConfig = ({ basePath, headers, }) => {
2992
2992
  if (!basePath.trim()) {
2993
2993
  throw Error('basePath can not be empty');
@@ -3047,7 +3047,7 @@ class APIError extends Error {
3047
3047
 
3048
3048
  /* eslint-disable implicit-arrow-linebreak */
3049
3049
  const defaultHeaders = {
3050
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.22.2',
3050
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.23.0-alpha',
3051
3051
  };
3052
3052
  /**
3053
3053
  * createAPIConfiguration to create a custom Configuration
@@ -3333,7 +3333,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
3333
3333
  chainID,
3334
3334
  coreContractAddress,
3335
3335
  registrationContractAddress,
3336
- sdkVersion: 'ts-immutable-sdk-0.22.2',
3336
+ sdkVersion: 'ts-immutable-sdk-0.23.0-alpha',
3337
3337
  });
3338
3338
  /**
3339
3339
  * Sets `sdkVersion` at the time of build
@@ -28029,18 +28029,8 @@ class Exchange {
28029
28029
 
28030
28030
 
28031
28031
 
28032
- var $aa144554f9ef124b$export$226b052ecb8ca80;
28033
- (function(BuyStatusType) {
28034
- BuyStatusType["SUCCESS"] = "SUCCESS";
28035
- BuyStatusType["FAILED"] = "FAILED";
28036
- })($aa144554f9ef124b$export$226b052ecb8ca80 || ($aa144554f9ef124b$export$226b052ecb8ca80 = {}));
28037
28032
 
28038
28033
 
28039
- var $1e6b81bbd98b3a91$export$c0189a8c30039654;
28040
- (function(CancelStatusType) {
28041
- CancelStatusType["SUCCESS"] = "SUCCESS";
28042
- CancelStatusType["FAILED"] = "FAILED";
28043
- })($1e6b81bbd98b3a91$export$c0189a8c30039654 || ($1e6b81bbd98b3a91$export$c0189a8c30039654 = {}));
28044
28034
 
28045
28035
 
28046
28036
  /**
@@ -28094,11 +28084,6 @@ var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
28094
28084
 
28095
28085
 
28096
28086
 
28097
- var $c2874b006e92b115$export$a9780122aaa0801a;
28098
- (function(SellStatusType) {
28099
- SellStatusType["SUCCESS"] = "SUCCESS";
28100
- SellStatusType["FAILED"] = "FAILED";
28101
- })($c2874b006e92b115$export$a9780122aaa0801a || ($c2874b006e92b115$export$a9780122aaa0801a = {}));
28102
28087
 
28103
28088
 
28104
28089
  var $08d5ddc39acd6833$export$fd9b17d87f4121d2;
@@ -28468,6 +28453,12 @@ const $d85ad1457a3f1a83$export$8b8be7a2a654f23e = [
28468
28453
  ];
28469
28454
 
28470
28455
 
28456
+ var $4b58188d47aafe8d$export$de7bcda3c490bf18;
28457
+ (function(CheckoutStatus) {
28458
+ CheckoutStatus["SUCCESS"] = "SUCCESS";
28459
+ CheckoutStatus["FAILED"] = "FAILED";
28460
+ CheckoutStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
28461
+ })($4b58188d47aafe8d$export$de7bcda3c490bf18 || ($4b58188d47aafe8d$export$de7bcda3c490bf18 = {}));
28471
28462
  var $4b58188d47aafe8d$export$1fc8f52ad1810e52;
28472
28463
  (function(ItemType) {
28473
28464
  ItemType["NATIVE"] = "NATIVE";
@@ -28484,12 +28475,18 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
28484
28475
  GasTokenType["NATIVE"] = "NATIVE";
28485
28476
  GasTokenType["ERC20"] = "ERC20";
28486
28477
  })($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
28487
- var $4b58188d47aafe8d$export$3af78bb3e8650ee6;
28488
- (function(FundingRouteType) {
28489
- FundingRouteType["BRIDGE"] = "BRIDGE";
28490
- FundingRouteType["ONRAMP"] = "ONRAMP";
28491
- FundingRouteType["SWAP"] = "SWAP";
28492
- })($4b58188d47aafe8d$export$3af78bb3e8650ee6 || ($4b58188d47aafe8d$export$3af78bb3e8650ee6 = {}));
28478
+ var $4b58188d47aafe8d$export$d0616bd3e995b8be;
28479
+ (function(RoutingOutcomeType) {
28480
+ RoutingOutcomeType["ROUTES_FOUND"] = "ROUTES_FOUND";
28481
+ RoutingOutcomeType["NO_ROUTES_FOUND"] = "NO_ROUTES_FOUND";
28482
+ RoutingOutcomeType["NO_ROUTE_OPTIONS"] = "NO_ROUTE_OPTIONS";
28483
+ })($4b58188d47aafe8d$export$d0616bd3e995b8be || ($4b58188d47aafe8d$export$d0616bd3e995b8be = {}));
28484
+ var $4b58188d47aafe8d$export$6fbaa98ee06d03e8;
28485
+ (function(FundingStepType) {
28486
+ FundingStepType["BRIDGE"] = "BRIDGE";
28487
+ FundingStepType["SWAP"] = "SWAP";
28488
+ FundingStepType["ONRAMP"] = "ONRAMP";
28489
+ })($4b58188d47aafe8d$export$6fbaa98ee06d03e8 || ($4b58188d47aafe8d$export$6fbaa98ee06d03e8 = {}));
28493
28490
 
28494
28491
 
28495
28492
  var $e055e79256bbc1dd$export$80f4da0d409a629d;
@@ -29499,7 +29496,6 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
29499
29496
 
29500
29497
 
29501
29498
 
29502
-
29503
29499
  const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
29504
29500
  const aggregatedAllowances = [];
29505
29501
  if (!erc20allowances.sufficient) {
@@ -30152,7 +30148,7 @@ const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>false;
30152
30148
 
30153
30149
 
30154
30150
  const $7f2e17f026d4fc8d$var$isPassportProvider = (provider)=>(provider.provider?.isPassport === true) ?? false;
30155
- const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
30151
+ const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
30156
30152
  const availableRoutingOptions = {
30157
30153
  onRamp: config.isOnRampEnabled,
30158
30154
  swap: config.isSwapEnabled,
@@ -30185,13 +30181,6 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
30185
30181
 
30186
30182
 
30187
30183
 
30188
- var $b23305044c0e096a$export$3057de18ac0c076;
30189
- (function(RouteCalculatorType) {
30190
- RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
30191
- RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
30192
- RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
30193
- })($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
30194
-
30195
30184
 
30196
30185
 
30197
30186
 
@@ -30308,6 +30297,44 @@ const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache,
30308
30297
  };
30309
30298
 
30310
30299
 
30300
+ const $91807edfd7057288$export$db6bd467891859dc = (chainId, fundsRequired, userBalance)=>{
30301
+ const tokenAddress = userBalance.token.address;
30302
+ let type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20;
30303
+ if (tokenAddress === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
30304
+ return {
30305
+ type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).SWAP,
30306
+ chainId: chainId,
30307
+ fundingItem: {
30308
+ type: type,
30309
+ fundsRequired: {
30310
+ amount: fundsRequired,
30311
+ formattedAmount: (utils$1).formatUnits(fundsRequired, userBalance.token.decimals)
30312
+ },
30313
+ userBalance: {
30314
+ balance: userBalance.balance,
30315
+ formattedBalance: userBalance.formattedBalance
30316
+ },
30317
+ token: userBalance.token
30318
+ },
30319
+ // WT-1734 - Add fees
30320
+ fees: {
30321
+ approvalGasFees: {
30322
+ amount: (BigNumber$1).from(0),
30323
+ formattedAmount: "0"
30324
+ },
30325
+ swapGasFees: {
30326
+ amount: (BigNumber$1).from(0),
30327
+ formattedAmount: "0"
30328
+ },
30329
+ swapFees: [
30330
+ {
30331
+ amount: (BigNumber$1).from(0),
30332
+ formattedAmount: "0"
30333
+ }
30334
+ ]
30335
+ }
30336
+ };
30337
+ };
30311
30338
  const $91807edfd7057288$export$85e4d8628aabb217 = (balanceRequirement)=>{
30312
30339
  let address = "";
30313
30340
  let amount = (BigNumber$1).from(0);
@@ -30396,7 +30423,8 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
30396
30423
  if (swappableTokens.length === 0) return fundingSteps;
30397
30424
  const requiredToken = $91807edfd7057288$export$85e4d8628aabb217(balanceRequirement);
30398
30425
  if (requiredToken.address === "") return fundingSteps;
30399
- const l2TokenBalanceResult = tokenBalanceResults.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
30426
+ const chainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
30427
+ const l2TokenBalanceResult = tokenBalanceResults.get(chainId);
30400
30428
  if (!l2TokenBalanceResult) return fundingSteps;
30401
30429
  const l2Balances = l2TokenBalanceResult.balances;
30402
30430
  if (l2Balances.length === 0) return fundingSteps;
@@ -30423,15 +30451,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
30423
30451
  })) continue;
30424
30452
  // User has sufficient funds to cover any approval and swap fees so use this token for the funding route
30425
30453
  // Currently we are not prioritising any particular token so just taking the first sufficient token
30426
- fundingSteps.push({
30427
- type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).SWAP,
30428
- chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
30429
- asset: {
30430
- balance: userBalanceOfQuotedToken.balance,
30431
- formattedBalance: userBalanceOfQuotedToken.formattedBalance,
30432
- token: userBalanceOfQuotedToken.token
30433
- }
30434
- });
30454
+ fundingSteps.push($91807edfd7057288$export$db6bd467891859dc(chainId, amountOfQuoteTokenRequired.value, userBalanceOfQuotedToken));
30435
30455
  }
30436
30456
  return fundingSteps;
30437
30457
  };
@@ -30489,6 +30509,7 @@ const $5a5ccedc98d53d25$export$1ad29657d49c5440 = async (config, tokenBalances,
30489
30509
 
30490
30510
 
30491
30511
 
30512
+
30492
30513
  const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
30493
30514
  for (const balance of balances.balances){
30494
30515
  if (!balance.token.address || balance.token.address === "") return balance.balance;
@@ -30501,7 +30522,7 @@ const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
30501
30522
 
30502
30523
 
30503
30524
 
30504
- const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProviders)=>{
30525
+ const $15fe1c77041bd4f4$export$9e73e22953cebcfc = async (config, readOnlyProviders)=>{
30505
30526
  try {
30506
30527
  const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
30507
30528
  gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
@@ -30512,7 +30533,18 @@ const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProvide
30512
30533
  let totalFees = (0, BigNumber$1).from(0);
30513
30534
  if (gasEstimate) totalFees = totalFees.add(gasEstimate);
30514
30535
  if (bridgeFee) totalFees = totalFees.add(bridgeFee);
30515
- return totalFees;
30536
+ return {
30537
+ type: (0, $4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE,
30538
+ gasFee: {
30539
+ estimatedAmount: gasEstimate ?? (0, BigNumber$1).from(0),
30540
+ token: estimate.gasFee.token
30541
+ },
30542
+ bridgeFee: {
30543
+ estimatedAmount: bridgeFee ?? (0, BigNumber$1).from(0),
30544
+ token: estimate.bridgeFee.token
30545
+ },
30546
+ totalFees: totalFees
30547
+ };
30516
30548
  } catch (err) {
30517
30549
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
30518
30550
  message: err.message
@@ -30600,24 +30632,48 @@ const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (tokenBalanceResult, totalFees
30600
30632
  return balance.gte(totalFees);
30601
30633
  };
30602
30634
  const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
30603
- let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE);
30635
+ let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE);
30604
30636
  if (bridgeFeeEstimate) return bridgeFeeEstimate;
30605
- bridgeFeeEstimate = await ($8a49d1a3783a2640$export$3aff971444a4f244)(config, readOnlyProviders);
30606
- feeEstimates.set(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE, bridgeFeeEstimate);
30637
+ bridgeFeeEstimate = await ($15fe1c77041bd4f4$export$9e73e22953cebcfc)(config, readOnlyProviders);
30638
+ feeEstimates.set(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE, bridgeFeeEstimate);
30607
30639
  return bridgeFeeEstimate;
30608
30640
  };
30609
- const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
30610
- type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE,
30641
+ const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance, bridgeRequirement, itemType)=>({
30642
+ type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE,
30611
30643
  chainId: chainId,
30612
- asset: {
30613
- balance: balance.balance,
30614
- formattedBalance: balance.formattedBalance,
30644
+ fundingItem: {
30645
+ type: itemType,
30646
+ fundsRequired: {
30647
+ amount: bridgeRequirement.amount,
30648
+ formattedAmount: bridgeRequirement.formattedAmount
30649
+ },
30650
+ userBalance: {
30651
+ balance: balance.balance,
30652
+ formattedBalance: balance.formattedBalance
30653
+ },
30615
30654
  token: {
30616
30655
  name: balance.token.name,
30617
30656
  symbol: balance.token.symbol,
30618
30657
  address: balance.token.address,
30619
30658
  decimals: balance.token.decimals
30620
30659
  }
30660
+ },
30661
+ // WT-1734 - Add fees
30662
+ fees: {
30663
+ approvalGasFees: {
30664
+ amount: (BigNumber$1).from(0),
30665
+ formattedAmount: "0"
30666
+ },
30667
+ bridgeGasFees: {
30668
+ amount: (BigNumber$1).from(0),
30669
+ formattedAmount: "0"
30670
+ },
30671
+ bridgeFees: [
30672
+ {
30673
+ amount: (BigNumber$1).from(0),
30674
+ formattedAmount: "0"
30675
+ }
30676
+ ]
30621
30677
  }
30622
30678
  });
30623
30679
  const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
@@ -30639,7 +30695,7 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
30639
30695
  if (allowedTokenList.length === 0) return undefined;
30640
30696
  const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
30641
30697
  // If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
30642
- if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
30698
+ if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate.totalFees)) return undefined;
30643
30699
  const l1RepresentationResult = await ($887d24b47765b1c0$export$952cdf461a00a8c6)(config, bridgeRequirement.l2address);
30644
30700
  // No mapping on L1 for this token
30645
30701
  const { l1address: l1address } = l1RepresentationResult;
@@ -30649,16 +30705,20 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
30649
30705
  if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
30650
30706
  } else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
30651
30707
  const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, bridgeRequirement.amount);
30652
- if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
30708
+ let totalFees = bridgeFeeEstimate.bridgeFee.estimatedAmount;
30653
30709
  // If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
30654
30710
  if (l1address === ($887d24b47765b1c0$export$c37d8687c27b9660)) {
30655
30711
  const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
30656
- if (nativeETHBalance && nativeETHBalance.balance.gte(bridgeRequirement.amount.add(bridgeFeeEstimate))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance);
30712
+ if (bridgeFeeEstimate.gasFee.estimatedAmount) totalFees = totalFees.add(bridgeFeeEstimate.gasFee.estimatedAmount);
30713
+ if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, totalFees)) return undefined;
30714
+ if (nativeETHBalance && nativeETHBalance.balance.gte(bridgeRequirement.amount.add(totalFees))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance, bridgeRequirement, ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE);
30657
30715
  return undefined;
30658
30716
  }
30717
+ totalFees.add(gasForApproval).add(bridgeFeeEstimate.gasFee.estimatedAmount);
30718
+ if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, totalFees)) return undefined;
30659
30719
  // Find the balance of the L1 representation of the token and check if the balance covers the delta
30660
30720
  const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
30661
- if (erc20balance && erc20balance.balance.gte(bridgeRequirement.amount)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
30721
+ if (erc20balance && erc20balance.balance.gte(bridgeRequirement.amount)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance, bridgeRequirement, ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20);
30662
30722
  return undefined;
30663
30723
  };
30664
30724
 
@@ -30844,18 +30904,19 @@ const $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount = (config, toke
30844
30904
  const $afd57acae9471ac5$export$1fc63300bde5e690 = (tokenBalances, swapRoutes)=>{
30845
30905
  const originalSwapSteps = [];
30846
30906
  for (const route of swapRoutes){
30847
- const { chainId: chainId, asset: asset } = route;
30907
+ const { chainId: chainId, fundingItem: fundingItem } = route;
30908
+ const { userBalance: userBalance } = route.fundingItem;
30848
30909
  const tokenBalance = tokenBalances.get(chainId);
30849
30910
  if (!tokenBalance) continue;
30850
30911
  let originalBalance = (BigNumber$1).from(0);
30851
30912
  let originalFormattedBalance = "0";
30852
- const l2balance = tokenBalance.balances.find((balance)=>balance.token.address === asset.token.address);
30913
+ const l2balance = tokenBalance.balances.find((balance)=>balance.token.address === fundingItem.token.address);
30853
30914
  if (l2balance) {
30854
30915
  originalBalance = l2balance.balance;
30855
30916
  originalFormattedBalance = l2balance.formattedBalance;
30856
30917
  }
30857
- route.asset.balance = originalBalance;
30858
- route.asset.formattedBalance = originalFormattedBalance;
30918
+ userBalance.balance = originalBalance;
30919
+ userBalance.formattedBalance = originalFormattedBalance;
30859
30920
  originalSwapSteps.push(route);
30860
30921
  }
30861
30922
  return originalSwapSteps;
@@ -30865,11 +30926,11 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
30865
30926
  for (const bridgeFundingStep of bridgeFundingSteps){
30866
30927
  if (!bridgeFundingStep) continue;
30867
30928
  const mapping = l1tol2Addresses.find((addresses)=>{
30868
- if (bridgeFundingStep.asset.token.address === undefined) return addresses.l1address === ($887d24b47765b1c0$export$c37d8687c27b9660) && addresses.l2address;
30869
- return addresses.l1address === bridgeFundingStep.asset.token.address && addresses.l2address;
30929
+ if (bridgeFundingStep.fundingItem.token.address === undefined) return addresses.l1address === ($887d24b47765b1c0$export$c37d8687c27b9660) && addresses.l2address;
30930
+ return addresses.l1address === bridgeFundingStep.fundingItem.token.address && addresses.l2address;
30870
30931
  });
30871
30932
  if (!mapping) continue;
30872
- const swapFundingStep = swapFundingSteps.find((step)=>step.asset.token.address === mapping.l2address);
30933
+ const swapFundingStep = swapFundingSteps.find((step)=>step.fundingItem.token.address === mapping.l2address);
30873
30934
  if (!swapFundingStep) continue;
30874
30935
  bridgeAndSwapRoutes.push({
30875
30936
  bridgeFundingStep: bridgeFundingStep,
@@ -30945,22 +31006,27 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
30945
31006
 
30946
31007
  const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutingOptions, balanceRequirement)=>{
30947
31008
  if (balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 && balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return undefined;
30948
- const requiredBalance = balanceRequirement.required;
31009
+ const { required: required, current: current, delta: delta } = balanceRequirement;
30949
31010
  let hasAllowList = false;
30950
31011
  const onRampProvidersAllowList = await ($5a5ccedc98d53d25$export$9ec9fc71f3ce62c4)(config, availableRoutingOptions);
30951
31012
  Object.values(onRampProvidersAllowList).forEach((onRampAllowList)=>{
30952
- if (onRampAllowList.length > 0 && !hasAllowList) hasAllowList = !!onRampAllowList.find((token)=>token.address === requiredBalance.token?.address);
31013
+ if (onRampAllowList.length > 0 && !hasAllowList) hasAllowList = !!onRampAllowList.find((token)=>token.address === required.token?.address);
30953
31014
  });
30954
31015
  if (!hasAllowList) return undefined;
30955
31016
  return {
30956
- type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).ONRAMP,
31017
+ type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).ONRAMP,
30957
31018
  chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
30958
- asset: {
30959
- balance: requiredBalance.balance,
30960
- formattedBalance: requiredBalance.formattedBalance,
30961
- token: {
30962
- ...requiredBalance.token
30963
- }
31019
+ fundingItem: {
31020
+ type: required.token.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9) ? ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE : ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
31021
+ fundsRequired: {
31022
+ amount: delta.balance,
31023
+ formattedAmount: delta.formattedBalance
31024
+ },
31025
+ userBalance: {
31026
+ balance: current.balance,
31027
+ formattedBalance: current.formattedBalance
31028
+ },
31029
+ token: required.token
30964
31030
  }
30965
31031
  };
30966
31032
  };
@@ -31034,11 +31100,8 @@ const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutin
31034
31100
  };
31035
31101
  const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
31036
31102
  if (!$c16168a9c28ae4fd$var$hasAvailableRoutingOptions(availableRoutingOptions)) return {
31037
- response: {
31038
- type: ($b23305044c0e096a$export$3057de18ac0c076).NO_OPTIONS,
31039
- message: "No options available"
31040
- },
31041
- fundingRoutes: []
31103
+ type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).NO_ROUTE_OPTIONS,
31104
+ message: "No routing options are available"
31042
31105
  };
31043
31106
  let readOnlyProviders;
31044
31107
  try {
@@ -31072,25 +31135,37 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
31072
31135
  if (index === 2) onRampFundingStep = result;
31073
31136
  if (index === 3) bridgeAndSwapFundingSteps = result;
31074
31137
  });
31138
+ if (!bridgeFundingStep && swapFundingSteps.length === 0 && !onRampFundingStep && bridgeAndSwapFundingSteps.length === 0) return {
31139
+ type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).NO_ROUTES_FOUND,
31140
+ message: "Smart Checkout did not find any funding routes to fulfill the transaction"
31141
+ };
31075
31142
  const response = {
31076
- response: {
31077
- type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
31078
- message: "Routes not found"
31079
- },
31143
+ type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).ROUTES_FOUND,
31080
31144
  fundingRoutes: []
31081
31145
  };
31082
31146
  let priority = 0;
31083
- if (bridgeFundingStep || swapFundingSteps.length > 0 || onRampFundingStep || bridgeAndSwapFundingSteps.length > 0) {
31084
- response.response.type = ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND;
31085
- response.response.message = "Routes found";
31086
- }
31087
31147
  if (bridgeFundingStep) {
31088
31148
  priority++;
31089
31149
  response.fundingRoutes.push({
31090
31150
  priority: priority,
31091
31151
  steps: [
31092
31152
  bridgeFundingStep
31093
- ]
31153
+ ],
31154
+ // WT-1734 - Add fees
31155
+ totalFees: {
31156
+ gas: {
31157
+ amount: (BigNumber$1).from(0),
31158
+ formattedAmount: "0"
31159
+ },
31160
+ other: {
31161
+ amount: (BigNumber$1).from(0),
31162
+ formattedAmount: "0"
31163
+ },
31164
+ total: {
31165
+ amount: (BigNumber$1).from(0),
31166
+ formattedAmount: "0"
31167
+ }
31168
+ }
31094
31169
  });
31095
31170
  }
31096
31171
  if (swapFundingSteps.length > 0) {
@@ -31100,7 +31175,22 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
31100
31175
  priority: priority,
31101
31176
  steps: [
31102
31177
  swapFundingStep
31103
- ]
31178
+ ],
31179
+ // WT-1734 - Add fees
31180
+ totalFees: {
31181
+ gas: {
31182
+ amount: (BigNumber$1).from(0),
31183
+ formattedAmount: "0"
31184
+ },
31185
+ other: {
31186
+ amount: (BigNumber$1).from(0),
31187
+ formattedAmount: "0"
31188
+ },
31189
+ total: {
31190
+ amount: (BigNumber$1).from(0),
31191
+ formattedAmount: "0"
31192
+ }
31193
+ }
31104
31194
  });
31105
31195
  });
31106
31196
  }
@@ -31123,34 +31213,29 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
31123
31213
  steps: [
31124
31214
  bridgeStep,
31125
31215
  swapStep
31126
- ]
31216
+ ],
31217
+ // WT-1734 - Add fees
31218
+ totalFees: {
31219
+ gas: {
31220
+ amount: (BigNumber$1).from(0),
31221
+ formattedAmount: "0"
31222
+ },
31223
+ other: {
31224
+ amount: (BigNumber$1).from(0),
31225
+ formattedAmount: "0"
31226
+ },
31227
+ total: {
31228
+ amount: (BigNumber$1).from(0),
31229
+ formattedAmount: "0"
31230
+ }
31231
+ }
31127
31232
  });
31128
31233
  });
31129
31234
  }
31130
- // eslint-disable-next-line no-console
31131
- console.log("** response", response);
31132
31235
  return response;
31133
31236
  };
31134
31237
 
31135
31238
 
31136
- const $0e7419077c373b24$export$4a2a19d99fef3b1b = (balanceCheckResult)=>{
31137
- let sufficient = true;
31138
- const transactionRequirements = [];
31139
- for (const balance of balanceCheckResult.balanceRequirements){
31140
- if (!balance.sufficient) sufficient = false;
31141
- transactionRequirements.push({
31142
- type: balance.type,
31143
- sufficient: balance.sufficient,
31144
- required: balance.required,
31145
- current: balance.current,
31146
- delta: balance.delta
31147
- });
31148
- }
31149
- return {
31150
- sufficient: sufficient,
31151
- transactionRequirements: transactionRequirements
31152
- };
31153
- };
31154
31239
  const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
31155
31240
  const ownerAddress = await provider.getSigner().getAddress();
31156
31241
  let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
@@ -31162,12 +31247,25 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemR
31162
31247
  aggregatedItems.push(gasItem);
31163
31248
  aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
31164
31249
  }
31165
- const balanceRequirements = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
31166
- // Determine which services are available
31167
- const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$f1ca3744c025ab81)(config, provider);
31168
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
31169
- await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceRequirements, availableRoutingOptions);
31170
- return $0e7419077c373b24$export$4a2a19d99fef3b1b(balanceRequirements);
31250
+ const balanceCheckResult = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
31251
+ const { sufficient: sufficient } = balanceCheckResult;
31252
+ const transactionRequirements = balanceCheckResult.balanceRequirements;
31253
+ if (sufficient) return {
31254
+ sufficient: sufficient,
31255
+ transactionRequirements: transactionRequirements
31256
+ };
31257
+ const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
31258
+ const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
31259
+ const isPassport = provider.provider?.isPassport || false;
31260
+ return {
31261
+ sufficient: sufficient,
31262
+ transactionRequirements: transactionRequirements,
31263
+ router: {
31264
+ isPassport: isPassport,
31265
+ availableRoutingOptions: availableRoutingOptions,
31266
+ routingOutcome: routingOutcome
31267
+ }
31268
+ };
31171
31269
  };
31172
31270
 
31173
31271
 
@@ -31412,7 +31510,6 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
31412
31510
  unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
31413
31511
  } catch {
31414
31512
  // Silently ignore error as this is usually thrown if user does not have enough balance
31415
- // todo: if balance error - can we determine if its the balance error otherwise throw?
31416
31513
  }
31417
31514
  try {
31418
31515
  unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
@@ -31451,13 +31548,12 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
31451
31548
  if (smartCheckoutResult.sufficient) {
31452
31549
  const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
31453
31550
  if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
31454
- smartCheckoutResult: smartCheckoutResult,
31455
- orderId: id,
31456
- status: {
31457
- type: ($aa144554f9ef124b$export$226b052ecb8ca80).FAILED,
31458
- transactionHash: approvalResult.transactionHash,
31459
- reason: approvalResult.reason
31460
- }
31551
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
31552
+ transactionHash: approvalResult.transactionHash,
31553
+ reason: approvalResult.reason,
31554
+ smartCheckoutResult: [
31555
+ smartCheckoutResult
31556
+ ]
31461
31557
  };
31462
31558
  try {
31463
31559
  if (unsignedFulfillmentTransactions.length === 0) unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
@@ -31468,25 +31564,25 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
31468
31564
  }
31469
31565
  const fulfillmentResult = await ($25ac589234c10b67$export$3f05b33bd1f29038)(provider, unsignedFulfillmentTransactions);
31470
31566
  if (fulfillmentResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
31471
- smartCheckoutResult: smartCheckoutResult,
31472
- orderId: id,
31473
- status: {
31474
- type: ($aa144554f9ef124b$export$226b052ecb8ca80).FAILED,
31475
- transactionHash: fulfillmentResult.transactionHash,
31476
- reason: fulfillmentResult.reason
31477
- }
31567
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
31568
+ transactionHash: fulfillmentResult.transactionHash,
31569
+ reason: fulfillmentResult.reason,
31570
+ smartCheckoutResult: [
31571
+ smartCheckoutResult
31572
+ ]
31478
31573
  };
31479
31574
  return {
31480
- smartCheckoutResult: smartCheckoutResult,
31481
- orderId: id,
31482
- status: {
31483
- type: ($aa144554f9ef124b$export$226b052ecb8ca80).SUCCESS
31484
- }
31575
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
31576
+ smartCheckoutResult: [
31577
+ smartCheckoutResult
31578
+ ]
31485
31579
  };
31486
31580
  }
31487
31581
  return {
31488
- smartCheckoutResult: smartCheckoutResult,
31489
- orderId: id
31582
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
31583
+ smartCheckoutResult: [
31584
+ smartCheckoutResult
31585
+ ]
31490
31586
  };
31491
31587
  };
31492
31588
 
@@ -31501,7 +31597,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
31501
31597
  const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
31502
31598
  let unsignedCancelOrderTransaction;
31503
31599
  if (orderIds.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orderIds were passed in, must pass at least one orderId to cancel", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR);
31504
- // Update this when bulk cancel is supproted
31600
+ // Update this when bulk cancel is supported
31505
31601
  const orderId = orderIds[0];
31506
31602
  try {
31507
31603
  const offererAddress = await provider.getSigner().getAddress();
@@ -31518,18 +31614,12 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
31518
31614
  unsignedCancelOrderTransaction
31519
31615
  ]);
31520
31616
  if (result.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
31521
- orderId: orderId,
31522
- status: {
31523
- type: ($1e6b81bbd98b3a91$export$c0189a8c30039654).FAILED,
31524
- transactionHash: result.transactionHash,
31525
- reason: result.reason
31526
- }
31617
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
31618
+ transactionHash: result.transactionHash,
31619
+ reason: result.reason
31527
31620
  };
31528
31621
  return {
31529
- orderId: orderId,
31530
- status: {
31531
- type: ($1e6b81bbd98b3a91$export$c0189a8c30039654).SUCCESS
31532
- }
31622
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS
31533
31623
  };
31534
31624
  };
31535
31625
 
@@ -31545,7 +31635,6 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
31545
31635
 
31546
31636
 
31547
31637
 
31548
-
31549
31638
  const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
31550
31639
  type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
31551
31640
  id: id,
@@ -31609,6 +31698,16 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
31609
31698
  }
31610
31699
  });
31611
31700
  if (smartCheckoutResult.sufficient) {
31701
+ const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
31702
+ const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
31703
+ if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
31704
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
31705
+ transactionHash: approvalResult.transactionHash,
31706
+ reason: approvalResult.reason,
31707
+ smartCheckoutResult: [
31708
+ smartCheckoutResult
31709
+ ]
31710
+ };
31612
31711
  const unsignedMessage = ($a7367d01c6e76b1c$export$d62081fac18000c2)(listing.orderHash, listing.orderComponents, listing.actions);
31613
31712
  if (!unsignedMessage) // For sell it is expected the orderbook will always return an unsigned message
31614
31713
  // If for some reason it is missing then we cannot proceed with the create listing
@@ -31617,18 +31716,6 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
31617
31716
  collectionAddress: sellToken.collectionAddress
31618
31717
  });
31619
31718
  const signedMessage = await ($25ac589234c10b67$export$1d9a7a8a40780de)(provider, unsignedMessage);
31620
- const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
31621
- const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
31622
- if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
31623
- id: sellToken.id,
31624
- collectionAddress: sellToken.collectionAddress,
31625
- smartCheckoutResult: smartCheckoutResult,
31626
- status: {
31627
- type: ($c2874b006e92b115$export$a9780122aaa0801a).FAILED,
31628
- transactionHash: approvalResult.transactionHash,
31629
- reason: approvalResult.reason
31630
- }
31631
- };
31632
31719
  let orderId = "";
31633
31720
  const createListingParams = {
31634
31721
  orderComponents: signedMessage.orderComponents,
@@ -31652,19 +31739,20 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
31652
31739
  });
31653
31740
  }
31654
31741
  return {
31655
- id: sellToken.id,
31656
- collectionAddress: sellToken.collectionAddress,
31657
- smartCheckoutResult: smartCheckoutResult,
31658
- status: {
31659
- type: ($c2874b006e92b115$export$a9780122aaa0801a).SUCCESS,
31660
- orderId: orderId
31661
- }
31742
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
31743
+ orderIds: [
31744
+ orderId
31745
+ ],
31746
+ smartCheckoutResult: [
31747
+ smartCheckoutResult
31748
+ ]
31662
31749
  };
31663
31750
  }
31664
31751
  return {
31665
- id: sellToken.id,
31666
- collectionAddress: sellToken.collectionAddress,
31667
- smartCheckoutResult: smartCheckoutResult
31752
+ status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
31753
+ smartCheckoutResult: [
31754
+ smartCheckoutResult
31755
+ ]
31668
31756
  };
31669
31757
  };
31670
31758
 
@@ -31876,9 +31964,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
31876
31964
  // eslint-disable-next-line no-console
31877
31965
  console.warn("This endpoint is currently under construction.");
31878
31966
  if (params.orders.length > 1) // eslint-disable-next-line no-console
31879
- console.warn("This endpoint currently only actions the first order in the array.");
31967
+ console.warn("This endpoint currently only processes the first order in the array.");
31880
31968
  const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
31881
- await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
31969
+ return await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
31882
31970
  }
31883
31971
  /**
31884
31972
  * Determines the requirements for performing a sell.
@@ -31890,9 +31978,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
31890
31978
  // eslint-disable-next-line no-console
31891
31979
  console.warn("This endpoint is currently under construction.");
31892
31980
  if (params.orders.length > 1) // eslint-disable-next-line no-console
31893
- console.warn("This endpoint currently only actions the first order in the array.");
31981
+ console.warn("This endpoint currently only processes the first order in the array.");
31894
31982
  const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
31895
- await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
31983
+ return await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
31896
31984
  }
31897
31985
  /**
31898
31986
  * Cancels a sell.
@@ -31902,9 +31990,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
31902
31990
  // eslint-disable-next-line no-console
31903
31991
  console.warn("This endpoint is currently under construction.");
31904
31992
  // eslint-disable-next-line no-console
31905
- console.warn("This endpoint currently only actions the first order in the array.");
31993
+ console.warn("This endpoint currently only processes the first order in the array.");
31906
31994
  const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
31907
- await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
31995
+ return await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
31908
31996
  }
31909
31997
  /**
31910
31998
  * Determines the transaction requirements to complete a purchase.
@@ -31920,7 +32008,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
31920
32008
  } catch {
31921
32009
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to map item requirements", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).ITEM_REQUIREMENTS_ERROR);
31922
32010
  }
31923
- await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
32011
+ return await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
31924
32012
  }
31925
32013
  /**
31926
32014
  * Checks if the given object is a Web3 provider.
@@ -31983,6 +32071,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
31983
32071
  get ChainName () { return $0472f23319457bfb$export$b874c6b1dfe85e02; },
31984
32072
  Checkout: $a8cb37a3fc8eb863$export$1f60ba4ec72508a0,
31985
32073
  get CheckoutErrorType () { return $a8bc256d81a5e2c1$export$e3dc0620abde7f5a; },
32074
+ get CheckoutStatus () { return $4b58188d47aafe8d$export$de7bcda3c490bf18; },
31986
32075
  get ExchangeType () { return $e055e79256bbc1dd$export$80f4da0d409a629d; },
31987
32076
  get GasEstimateType () { return $de275b98d2b651c3$export$788b1fd17f3dad84; },
31988
32077
  get GasTokenType () { return $4b58188d47aafe8d$export$537fa3efd10ed435; },
@@ -31997,11 +32086,54 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
31997
32086
  function $parcel$export(e, n, v, s) {
31998
32087
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
31999
32088
  }
32000
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.22.2";
32089
+ var $045213b18e9f1f94$exports = {};
32090
+
32091
+ $parcel$export($045213b18e9f1f94$exports, "WidgetTheme", () => $045213b18e9f1f94$export$c88931fdc51854eb);
32092
+ $parcel$export($045213b18e9f1f94$exports, "CheckoutWidgetTagNames", () => $045213b18e9f1f94$export$75be0f6af9650f2c);
32093
+ /**
32094
+ * Enum representing the themes for the Checkout widgets.
32095
+ */ var $045213b18e9f1f94$export$c88931fdc51854eb;
32096
+ (function(WidgetTheme) {
32097
+ WidgetTheme["LIGHT"] = "light";
32098
+ WidgetTheme["DARK"] = "dark";
32099
+ })($045213b18e9f1f94$export$c88931fdc51854eb || ($045213b18e9f1f94$export$c88931fdc51854eb = {}));
32100
+ var $045213b18e9f1f94$export$75be0f6af9650f2c;
32101
+ (function(CheckoutWidgetTagNames) {
32102
+ CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
32103
+ CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
32104
+ CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
32105
+ CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
32106
+ CheckoutWidgetTagNames["ONRAMP"] = "imtbl-onramp";
32107
+ })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
32108
+
32109
+
32110
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.23.0-alpha";
32001
32111
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
32002
32112
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
32003
32113
 
32004
32114
 
32115
+ function $430e3eda76fa4d5f$var$getWidgetConfig(element) {
32116
+ const config = element.getAttribute("widgetconfig");
32117
+ if (!config) return null;
32118
+ try {
32119
+ return JSON.parse(config);
32120
+ } catch (err) {
32121
+ // eslint-disable-next-line no-console
32122
+ console.warn(`Unable to decode widgetconfig for ${element}: `, err);
32123
+ }
32124
+ return null;
32125
+ }
32126
+ function $430e3eda76fa4d5f$var$setWidgetConfig(element, config) {
32127
+ element.setAttribute("widgetconfig", JSON.stringify(config));
32128
+ }
32129
+ function $430e3eda76fa4d5f$var$saveConfig(config) {
32130
+ if (window === undefined) {
32131
+ // eslint-disable-next-line no-console
32132
+ console.error("missing window object: please run Checkout client side");
32133
+ return;
32134
+ }
32135
+ window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
32136
+ }
32005
32137
  function $430e3eda76fa4d5f$export$46b1ae20f762ad4c(version) {
32006
32138
  const defaultPackageVersion = ($d663162fd5a0853f$export$1169f5475725171b)();
32007
32139
  if (version === undefined || version.major === undefined) return defaultPackageVersion;
@@ -32023,6 +32155,29 @@ function $430e3eda76fa4d5f$export$46b1ae20f762ad4c(version) {
32023
32155
  if (Number.isInteger(version.build) && version.build >= 0) validatedVersion += `.${version.build.toString()}`;
32024
32156
  return validatedVersion;
32025
32157
  }
32158
+ function $430e3eda76fa4d5f$var$loadScript(config) {
32159
+ if (document === undefined) {
32160
+ // eslint-disable-next-line no-console
32161
+ console.error("missing document object: please run Checkout client side");
32162
+ return;
32163
+ }
32164
+ const validVersion = $430e3eda76fa4d5f$export$46b1ae20f762ad4c(config?.version);
32165
+ // Prevent the script to be loaded more than once
32166
+ // by checking the presence of the script and its version.
32167
+ const initScript = document.querySelector('[data-product="checkout"]');
32168
+ if (initScript) {
32169
+ // eslint-disable-next-line no-console
32170
+ console.warn("checkout script has already been loaded, it can only be loaded once.");
32171
+ return;
32172
+ }
32173
+ const tag = document.createElement("script");
32174
+ let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout.js`;
32175
+ if (($d663162fd5a0853f$export$83bf90b30cdfd29f)()) cdnUrl = "http://localhost:3000/lib/js/imtbl-checkout.js";
32176
+ tag.setAttribute("data-product", "checkout");
32177
+ tag.setAttribute("data-version", validVersion);
32178
+ tag.setAttribute("src", cdnUrl);
32179
+ document.head.appendChild(tag);
32180
+ }
32026
32181
  function $430e3eda76fa4d5f$export$af210a0808087845(config) {
32027
32182
  if (window === undefined) {
32028
32183
  // eslint-disable-next-line no-console
@@ -32034,21 +32189,45 @@ function $430e3eda76fa4d5f$export$af210a0808087845(config) {
32034
32189
  console.error("missing document object: please run Checkout client side");
32035
32190
  return;
32036
32191
  }
32037
- const checkoutWidgetJS = document.createElement("script");
32038
- const validVersion = $430e3eda76fa4d5f$export$46b1ae20f762ad4c(config?.version);
32039
- let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout.js`;
32040
- if (($d663162fd5a0853f$export$83bf90b30cdfd29f)()) cdnUrl = "http://localhost:3000/lib/js/imtbl-checkout.js";
32041
- checkoutWidgetJS.setAttribute("src", cdnUrl);
32042
- document.head.appendChild(checkoutWidgetJS);
32043
- window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
32192
+ $430e3eda76fa4d5f$var$loadScript(config || {});
32193
+ $430e3eda76fa4d5f$var$saveConfig(config || {});
32044
32194
  }
32045
32195
  function $430e3eda76fa4d5f$export$bf1548ba7e61c17f(config) {
32046
32196
  if (window === undefined) {
32197
+ // eslint-disable-next-line no-console
32198
+ console.error("missing window object: please run Checkout client side");
32199
+ return;
32200
+ }
32201
+ if (document === undefined) {
32047
32202
  // eslint-disable-next-line no-console
32048
32203
  console.error("missing document object: please run Checkout client side");
32049
32204
  return;
32050
32205
  }
32051
- window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
32206
+ let globalConfig = {};
32207
+ try {
32208
+ globalConfig = JSON.parse(window.ImtblCheckoutWidgetConfig);
32209
+ } catch (err) {
32210
+ // eslint-disable-next-line no-console
32211
+ console.warn("Unable to decode window.ImtblCheckoutWidgetConfig: ", err);
32212
+ }
32213
+ Object.values(($045213b18e9f1f94$export$75be0f6af9650f2c)).forEach((elem)=>{
32214
+ const widgets = document.getElementsByTagName(elem);
32215
+ if (!widgets) return;
32216
+ // Loop through all the widgets to ensure that the script
32217
+ // get the correct local configs for the DOM elements and
32218
+ // simply update the global configurations.
32219
+ for (const e of widgets){
32220
+ const widgetConf = $430e3eda76fa4d5f$var$getWidgetConfig(e) || {};
32221
+ $430e3eda76fa4d5f$var$setWidgetConfig(e, {
32222
+ ...widgetConf,
32223
+ ...config
32224
+ });
32225
+ }
32226
+ });
32227
+ $430e3eda76fa4d5f$var$saveConfig({
32228
+ ...globalConfig,
32229
+ ...config
32230
+ });
32052
32231
  }
32053
32232
 
32054
32233
 
@@ -32155,27 +32334,6 @@ $parcel$export($d882ddc5600b1284$exports, "OnRampEventType", () => $d882ddc5600b
32155
32334
  OnRampEventType["SUCCESS"] = "success";
32156
32335
  OnRampEventType["FAILURE"] = "failure";
32157
32336
  })($d882ddc5600b1284$export$66ec39c0924078d8 || ($d882ddc5600b1284$export$66ec39c0924078d8 = {}));
32158
- /* eslint-disable @typescript-eslint/naming-convention */
32159
-
32160
- var $045213b18e9f1f94$exports = {};
32161
-
32162
- $parcel$export($045213b18e9f1f94$exports, "WidgetTheme", () => $045213b18e9f1f94$export$c88931fdc51854eb);
32163
- $parcel$export($045213b18e9f1f94$exports, "CheckoutWidgetTagNames", () => $045213b18e9f1f94$export$75be0f6af9650f2c);
32164
- /**
32165
- * Enum representing the themes for the Checkout widgets.
32166
- */ var $045213b18e9f1f94$export$c88931fdc51854eb;
32167
- (function(WidgetTheme) {
32168
- WidgetTheme["LIGHT"] = "light";
32169
- WidgetTheme["DARK"] = "dark";
32170
- })($045213b18e9f1f94$export$c88931fdc51854eb || ($045213b18e9f1f94$export$c88931fdc51854eb = {}));
32171
- var $045213b18e9f1f94$export$75be0f6af9650f2c;
32172
- (function(CheckoutWidgetTagNames) {
32173
- CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
32174
- CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
32175
- CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
32176
- CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
32177
- CheckoutWidgetTagNames["ONRAMP"] = "imtbl-onramp";
32178
- })($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
32179
32337
 
32180
32338
 
32181
32339
  var $1f969328e5988c99$exports = {};