@imtbl/sdk 0.17.3 → 0.17.5

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
@@ -2702,7 +2702,7 @@ class MultiRollupApiClients {
2702
2702
  }
2703
2703
 
2704
2704
  // eslint-disable-next-line @typescript-eslint/naming-convention
2705
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.3' };
2705
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.5' };
2706
2706
  const createConfig = ({ basePath, headers, }) => {
2707
2707
  if (!basePath.trim()) {
2708
2708
  throw Error('basePath can not be empty');
@@ -2762,7 +2762,7 @@ class APIError extends Error {
2762
2762
 
2763
2763
  /* eslint-disable implicit-arrow-linebreak */
2764
2764
  const defaultHeaders = {
2765
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.3',
2765
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.5',
2766
2766
  };
2767
2767
  /**
2768
2768
  * createAPIConfiguration to create a custom Configuration
@@ -3048,7 +3048,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
3048
3048
  chainID,
3049
3049
  coreContractAddress,
3050
3050
  registrationContractAddress,
3051
- sdkVersion: 'ts-immutable-sdk-0.17.3',
3051
+ sdkVersion: 'ts-immutable-sdk-0.17.5',
3052
3052
  });
3053
3053
  /**
3054
3054
  * Sets `sdkVersion` at the time of build
@@ -27312,6 +27312,7 @@ class Exchange {
27312
27312
 
27313
27313
 
27314
27314
 
27315
+
27315
27316
  var $aa144554f9ef124b$export$226b052ecb8ca80;
27316
27317
  (function(BuyStatusType) {
27317
27318
  BuyStatusType["SUCCESS"] = "SUCCESS";
@@ -27447,12 +27448,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
27447
27448
  const $d85ad1457a3f1a83$export$72176e2233d7d5d = true;
27448
27449
  const $d85ad1457a3f1a83$export$566b5975cc83d6b4 = true;
27449
27450
  const $d85ad1457a3f1a83$export$261cde2078dba35b = true;
27450
- const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
27451
- [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET]: {
27452
- url: "https://explorer.testnet.immutable.com",
27453
- nativeToken: $d85ad1457a3f1a83$var$ZKEVM_NATIVE_TOKEN
27454
- }
27455
- };
27456
27451
  const $d85ad1457a3f1a83$export$f6043d7fce62d71b = {
27457
27452
  [(Environment$1).SANDBOX]: "https://global-stg.transak.com",
27458
27453
  [(Environment$1).PRODUCTION]: "https://global.transak.com/"
@@ -27550,6 +27545,16 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
27550
27545
  }
27551
27546
  ]
27552
27547
  ]);
27548
+ const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
27549
+ [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET]: {
27550
+ url: "https://explorer.testnet.immutable.com",
27551
+ nativeToken: $d85ad1457a3f1a83$export$3e81fc0987227f10.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET).nativeCurrency
27552
+ },
27553
+ [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET]: {
27554
+ url: "https://explorer.mainnet.immutable.com",
27555
+ nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET).nativeCurrency
27556
+ }
27557
+ };
27553
27558
  const $d85ad1457a3f1a83$export$db5daa1b5156ccfe = [
27554
27559
  {
27555
27560
  constant: true,
@@ -27805,6 +27810,7 @@ var $e055e79256bbc1dd$export$80f4da0d409a629d;
27805
27810
  CheckoutErrorType["EXECUTE_APPROVAL_TRANSACTION_ERROR"] = "EXECUTE_APPROVAL_TRANSACTION_ERROR";
27806
27811
  CheckoutErrorType["EXECUTE_FULFILMENT_TRANSACTION_ERROR"] = "EXECUTE_FULFILMENT_TRANSACTION_ERROR";
27807
27812
  CheckoutErrorType["SIGN_MESSAGE_ERROR"] = "SIGN_MESSAGE_ERROR";
27813
+ CheckoutErrorType["BRIDGE_GAS_ESTIMATE_ERROR"] = "BRIDGE_GAS_ESTIMATE_ERROR";
27808
27814
  })($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
27809
27815
  class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
27810
27816
  message;
@@ -28324,7 +28330,14 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
28324
28330
  items.push(...resp.items);
28325
28331
  }while (resp.next_page_params);
28326
28332
  } catch (err) {
28327
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
28333
+ // In case of a 404, the wallet is a new wallet that hasn't been indexed by
28334
+ // the Blockscout just yet. This happens when a wallet hasn't had any
28335
+ // activity on the chain. In this case, simply ignore the error and return
28336
+ // no currencies.
28337
+ // In case of a malformed wallet address, Blockscout returns a 422, which
28338
+ // means we are safe to assume that a 404 is a missing wallet due to inactivity
28339
+ // or simply an incorrect wallet address was provided.
28340
+ if (err?.code !== (HttpStatusCode$2).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
28328
28341
  }
28329
28342
  try {
28330
28343
  const respNative = await $1564e43dde50bb61$var$blockscoutClient.getNativeTokenByWalletAddress({
@@ -28332,7 +28345,14 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
28332
28345
  });
28333
28346
  items.push(respNative);
28334
28347
  } catch (err) {
28335
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
28348
+ // In case of a 404, the wallet is a new wallet that hasn't been indexed by
28349
+ // the Blockscout just yet. This happens when a wallet hasn't had any
28350
+ // activity on the chain. In this case, simply ignore the error and return
28351
+ // no currencies.
28352
+ // In case of a malformed wallet address, Blockscout returns a 422, which
28353
+ // means we are safe to assume that a 404 is a missing wallet due to inactivity
28354
+ // or simply an incorrect wallet address was provided.
28355
+ if (err?.code !== (HttpStatusCode$2).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
28336
28356
  }
28337
28357
  return {
28338
28358
  balances: items.map((item)=>{
@@ -28598,6 +28618,7 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
28598
28618
 
28599
28619
 
28600
28620
 
28621
+
28601
28622
  async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config) {
28602
28623
  const rootChainProvider = readOnlyProviders.get(fromChainId);
28603
28624
  const childChainProvider = readOnlyProviders.get(toChainId);
@@ -28633,6 +28654,13 @@ async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
28633
28654
  }
28634
28655
  });
28635
28656
  }
28657
+ function $67fc622a2b913d5f$export$436dd76f23f463ff(config) {
28658
+ return new (BlockchainData)({
28659
+ baseConfig: {
28660
+ environment: config.environment
28661
+ }
28662
+ });
28663
+ }
28636
28664
 
28637
28665
 
28638
28666
 
@@ -29423,43 +29451,30 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
29423
29451
 
29424
29452
 
29425
29453
 
29454
+ var $b23305044c0e096a$export$3057de18ac0c076;
29455
+ (function(RouteCalculatorType) {
29456
+ RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
29457
+ RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
29458
+ RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
29459
+ })($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
29460
+ var $b23305044c0e096a$export$3af78bb3e8650ee6;
29461
+ (function(FundingRouteType) {
29462
+ FundingRouteType["BRIDGE"] = "BRIDGE";
29463
+ FundingRouteType["ON_RAMP"] = "ONRAMP";
29464
+ FundingRouteType["SWAP"] = "SWAP";
29465
+ })($b23305044c0e096a$export$3af78bb3e8650ee6 || ($b23305044c0e096a$export$3af78bb3e8650ee6 = {}));
29426
29466
 
29427
29467
 
29428
29468
 
29429
29469
 
29430
29470
 
29431
- async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
29432
- if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
29433
- if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
29434
- const readOnlyProviders = new Map();
29435
- const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
29436
- type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
29437
- });
29438
- allowedNetworks.networks.forEach((networkInfo)=>{
29439
- const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
29440
- const provider = new (JsonRpcProvider)(rpcUrl);
29441
- readOnlyProviders.set(networkInfo.chainId, provider);
29442
- });
29443
- return readOnlyProviders;
29444
- }
29445
-
29446
-
29447
-
29448
-
29449
- const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, availableRoutingOptions)=>{
29471
+ const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, readOnlyProviders, ownerAddress, availableRoutingOptions)=>{
29450
29472
  const chainBalances = new Map();
29451
29473
  const chainBalancePromises = new Map();
29452
- let readOnlyProviders = new Map();
29453
- let providerError;
29454
- try {
29455
- readOnlyProviders = await (0, $0e0060cb42e136d2$export$339cb2be73677b30)(config);
29456
- } catch (error) {
29457
- providerError = error;
29458
- }
29459
29474
  if (readOnlyProviders.size === 0) {
29460
29475
  const noProviderResult = {
29461
29476
  success: false,
29462
- error: providerError || new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Provider failed", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR),
29477
+ error: new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 or L2 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR),
29463
29478
  balances: []
29464
29479
  };
29465
29480
  chainBalances.set(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config), noProviderResult);
@@ -29503,44 +29518,243 @@ const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, av
29503
29518
  };
29504
29519
 
29505
29520
 
29521
+ /* eslint-disable @typescript-eslint/no-unused-vars */
29522
+
29523
+
29524
+
29525
+
29526
+ const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
29527
+ for (const balance of balances.balances){
29528
+ if (!balance.token.address || balance.token.address === "") return balance.balance;
29529
+ }
29530
+ return (BigNumber$1).from(0);
29531
+ };
29532
+
29533
+
29534
+
29535
+
29536
+
29537
+
29538
+ const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProviders)=>{
29539
+ try {
29540
+ const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
29541
+ gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
29542
+ isSpendingCapApprovalRequired: false
29543
+ }, readOnlyProviders, config);
29544
+ const gasEstimate = estimate.gasFee.estimatedAmount;
29545
+ const bridgeFee = estimate.bridgeFee.estimatedAmount;
29546
+ let totalFees = (0, BigNumber$1).from(0);
29547
+ if (gasEstimate) totalFees = totalFees.add(gasEstimate);
29548
+ if (bridgeFee) totalFees = totalFees.add(bridgeFee);
29549
+ return totalFees;
29550
+ } catch (err) {
29551
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
29552
+ message: err.message
29553
+ });
29554
+ }
29555
+ };
29556
+
29557
+
29558
+
29559
+ const $823db9fb0ca4bc15$export$c37d8687c27b9660 = "0x0000000000000000000000000000000000000001";
29560
+ const $823db9fb0ca4bc15$export$1430626eec86fce9 = (chainId)=>{
29561
+ if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET) return "imtbl-zkevm-testnet";
29562
+ return "";
29563
+ };
29564
+ const $823db9fb0ca4bc15$export$53e663abd9b77fc1 = (chainId)=>{
29565
+ if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA) return "0x2Fa06C6672dDCc066Ab04631192738799231dE4a";
29566
+ if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM) return "0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF";
29567
+ return "";
29568
+ };
29569
+
29570
+
29571
+
29572
+
29573
+
29574
+
29575
+
29576
+ const $07ac9c0576988336$export$7847f5f5cce25dfa = async (config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, token, depositAmount)=>{
29577
+ try {
29578
+ const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config);
29579
+ const { unsignedTx: unsignedTx } = await tokenBridge.getUnsignedApproveDepositBridgeTx({
29580
+ depositorAddress: depositorAddress,
29581
+ token: token,
29582
+ depositAmount: depositAmount
29583
+ });
29584
+ if (unsignedTx === null) return (0, BigNumber$1).from(0);
29585
+ return await l1provider.estimateGas(unsignedTx);
29586
+ } catch (err) {
29587
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while attempting ot estimate gas for approval transaction", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
29588
+ message: err.message
29589
+ });
29590
+ }
29591
+ };
29592
+ const $07ac9c0576988336$export$a3dd181de896b7c7 = async (config, readOnlyProviders, l1provider, depositorAddress, l1Address, delta)=>{
29593
+ if (l1Address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) return (BigNumber$1).from(0); // Native ETH does not require approval
29594
+ const fromChainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
29595
+ const toChainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
29596
+ return await $07ac9c0576988336$export$7847f5f5cce25dfa(config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, l1Address, delta);
29597
+ };
29598
+
29599
+
29600
+
29601
+ const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (balances, totalFees)=>{
29602
+ const balance = ($f730af3b727f04ac$export$22fea095b15361de)(balances);
29603
+ return balance.gte(totalFees);
29604
+ };
29605
+ const $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f = (balanceRequirement)=>{
29606
+ if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return $d85ad1457a3f1a83$export$b80040cb173ba6e9;
29607
+ if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return balanceRequirement.required.token.address ?? "";
29608
+ return "";
29609
+ };
29610
+ const $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6 = async (config, balanceRequirement)=>{
29611
+ const l2address = $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f(balanceRequirement);
29612
+ if (l2address === "") return "";
29613
+ if (l2address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) return ($823db9fb0ca4bc15$export$53e663abd9b77fc1)(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
29614
+ const chainName = ($823db9fb0ca4bc15$export$1430626eec86fce9)(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
29615
+ if (chainName === "") return ""; // Chain name not a valid indexer chain name
29616
+ const blockchainData = ($67fc622a2b913d5f$export$436dd76f23f463ff)(config);
29617
+ const tokenData = await blockchainData.getToken({
29618
+ chainName: chainName,
29619
+ contractAddress: l2address
29620
+ });
29621
+ const l1address = tokenData.result.root_contract_address;
29622
+ if (l1address === null) return ""; // No L1 representation of this token
29623
+ return l1address;
29624
+ };
29625
+ const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
29626
+ let bridgeFeeEstimate = feeEstimates.get(($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE);
29627
+ if (bridgeFeeEstimate) return bridgeFeeEstimate;
29628
+ bridgeFeeEstimate = await ($8a49d1a3783a2640$export$3aff971444a4f244)(config, readOnlyProviders);
29629
+ feeEstimates.set(($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE, bridgeFeeEstimate);
29630
+ return bridgeFeeEstimate;
29631
+ };
29632
+ const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
29633
+ type: ($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE,
29634
+ chainId: chainId,
29635
+ asset: {
29636
+ balance: balance.balance,
29637
+ formattedBalance: balance.formattedBalance,
29638
+ token: {
29639
+ name: balance.token.name,
29640
+ symbol: balance.token.symbol,
29641
+ address: balance.token.address,
29642
+ decimals: balance.token.decimals
29643
+ }
29644
+ }
29645
+ });
29646
+ const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
29647
+ if (!address || address === "") return true;
29648
+ return false;
29649
+ };
29650
+ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProviders, depositorAddress, availableRoutingOptions, balanceRequirement, balances, feeEstimates)=>{
29651
+ if (!availableRoutingOptions.bridge) return undefined;
29652
+ const chainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
29653
+ const tokenBalanceResult = balances.get(chainId);
29654
+ const l1provider = readOnlyProviders.get(chainId);
29655
+ if (!l1provider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
29656
+ chainId: chainId.toString()
29657
+ });
29658
+ // If no balances on layer 1 then Bridge cannot be an option
29659
+ if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error getting balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR, {
29660
+ chainId: chainId.toString()
29661
+ });
29662
+ if (tokenBalanceResult.balances.length === 0) return undefined;
29663
+ const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
29664
+ // If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
29665
+ if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
29666
+ const l1address = await $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6(config, balanceRequirement);
29667
+ if (l1address === "") return undefined;
29668
+ const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, balanceRequirement.delta.balance);
29669
+ if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
29670
+ // If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
29671
+ if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
29672
+ const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
29673
+ if (nativeETHBalance && nativeETHBalance.balance.gte(balanceRequirement.delta.balance.add(bridgeFeeEstimate))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance);
29674
+ return undefined;
29675
+ }
29676
+ // Find the balance of the L1 representation of the token and check if the balance covers the delta
29677
+ const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
29678
+ if (erc20balance && erc20balance.balance.gte(balanceRequirement.delta.balance)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
29679
+ return undefined;
29680
+ };
29681
+
29682
+
29683
+
29684
+
29685
+
29686
+ async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
29687
+ if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
29688
+ if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
29689
+ const readOnlyProviders = new Map();
29690
+ const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
29691
+ type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
29692
+ });
29693
+ allowedNetworks.networks.forEach((networkInfo)=>{
29694
+ const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
29695
+ const provider = new (JsonRpcProvider)(rpcUrl);
29696
+ readOnlyProviders.set(networkInfo.chainId, provider);
29697
+ });
29698
+ return readOnlyProviders;
29699
+ }
29700
+
29701
+
29702
+
29703
+ const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
29704
+ let insufficientBalanceCount = 0;
29705
+ let insufficientBridgeRequirement;
29706
+ for (const balanceRequirement of balanceRequirements.balanceRequirements)if (!balanceRequirement.sufficient) {
29707
+ insufficientBalanceCount++;
29708
+ insufficientBridgeRequirement = balanceRequirement;
29709
+ }
29710
+ if (insufficientBalanceCount === 1) return insufficientBridgeRequirement;
29711
+ return undefined;
29712
+ };
29506
29713
  const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
29507
- // eslint-disable-next-line no-console
29508
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
29509
- await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, ownerAddress, availableRoutingOptions);
29714
+ let readOnlyProviders;
29715
+ try {
29716
+ readOnlyProviders = await (0, $0e0060cb42e136d2$export$339cb2be73677b30)(config);
29717
+ } catch (err) {
29718
+ throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while creating read only providers", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
29719
+ message: err.message
29720
+ });
29721
+ }
29722
+ const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
29510
29723
  // Get allowed tokens?
29511
- // Check bridging routes
29724
+ // Bridge and swap fee cache
29725
+ const feeEstimates = new Map();
29726
+ // Ensures only 1 balance requirement is insufficient otherwise one bridge route cannot be recommended
29727
+ let bridgeFundingStep;
29728
+ const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
29729
+ if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, insufficientRequirement, tokenBalances, feeEstimates);
29512
29730
  // Check on-ramp routes
29513
29731
  // Check swap routes
29514
29732
  // > Could bridge first
29515
29733
  // > Could on-ramp first
29516
29734
  // > Could double swap
29517
- return {
29735
+ if (bridgeFundingStep) return {
29518
29736
  availableOptions: [],
29519
29737
  response: {
29520
- type: "ROUTES_FOUND",
29738
+ type: ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND,
29521
29739
  message: "Routes found"
29522
29740
  },
29523
29741
  fundingRoutes: [
29524
29742
  {
29525
29743
  priority: 1,
29526
29744
  steps: [
29527
- {
29528
- type: "bridge",
29529
- chainId: 1,
29530
- asset: {
29531
- balance: (BigNumber$1).from(0),
29532
- formattedBalance: "0",
29533
- token: {
29534
- name: "ETH",
29535
- symbol: "ETH",
29536
- decimals: 18
29537
- }
29538
- }
29539
- }
29745
+ bridgeFundingStep
29540
29746
  ]
29541
29747
  }
29542
29748
  ]
29543
29749
  };
29750
+ return {
29751
+ availableOptions: [],
29752
+ response: {
29753
+ type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
29754
+ message: "Routes not found"
29755
+ },
29756
+ fundingRoutes: []
29757
+ };
29544
29758
  };
29545
29759
 
29546
29760
 
@@ -30253,7 +30467,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
30253
30467
  function $parcel$export(e, n, v, s) {
30254
30468
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
30255
30469
  }
30256
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.3";
30470
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.5";
30257
30471
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
30258
30472
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
30259
30473
 
package/dist/passport.js CHANGED
@@ -1709,7 +1709,7 @@ class MultiRollupApiClients {
1709
1709
  }
1710
1710
 
1711
1711
  // eslint-disable-next-line @typescript-eslint/naming-convention
1712
- const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.17.3' };
1712
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.17.5' };
1713
1713
  const createConfig = ({ basePath, headers, }) => {
1714
1714
  if (!basePath.trim()) {
1715
1715
  throw Error('basePath can not be empty');
@@ -1765,7 +1765,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
1765
1765
  chainID,
1766
1766
  coreContractAddress,
1767
1767
  registrationContractAddress,
1768
- sdkVersion: 'ts-immutable-sdk-0.17.3',
1768
+ sdkVersion: 'ts-immutable-sdk-0.17.5',
1769
1769
  });
1770
1770
  /**
1771
1771
  * Sets `sdkVersion` at the time of build
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@imtbl/sdk",
3
3
  "description": "Immutable Unified SDK",
4
- "version": "0.17.3",
4
+ "version": "0.17.5",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",