@imtbl/sdk 0.17.5 → 0.17.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -2724,7 +2724,7 @@ class MultiRollupApiClients {
2724
2724
  }
2725
2725
 
2726
2726
  // eslint-disable-next-line @typescript-eslint/naming-convention
2727
- const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.5' };
2727
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.6' };
2728
2728
  const createConfig = ({ basePath, headers, }) => {
2729
2729
  if (!basePath.trim()) {
2730
2730
  throw Error('basePath can not be empty');
@@ -2784,7 +2784,7 @@ class APIError extends Error {
2784
2784
 
2785
2785
  /* eslint-disable implicit-arrow-linebreak */
2786
2786
  const defaultHeaders = {
2787
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.5',
2787
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.6',
2788
2788
  };
2789
2789
  /**
2790
2790
  * createAPIConfiguration to create a custom Configuration
@@ -3070,7 +3070,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
3070
3070
  chainID,
3071
3071
  coreContractAddress,
3072
3072
  registrationContractAddress,
3073
- sdkVersion: 'ts-immutable-sdk-0.17.5',
3073
+ sdkVersion: 'ts-immutable-sdk-0.17.6',
3074
3074
  });
3075
3075
  /**
3076
3076
  * Sets `sdkVersion` at the time of build
@@ -29436,8 +29436,8 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
29436
29436
 
29437
29437
 
29438
29438
 
29439
- const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>true;
29440
- const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>true;
29439
+ const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>false;
29440
+ const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>false;
29441
29441
 
29442
29442
 
29443
29443
  const $7f2e17f026d4fc8d$var$isPassportProvider = (provider)=>(provider.provider?.isPassport === true) ?? false;
@@ -29620,6 +29620,24 @@ const $07ac9c0576988336$export$a3dd181de896b7c7 = async (config, readOnlyProvide
29620
29620
 
29621
29621
 
29622
29622
 
29623
+
29624
+ const $5a5ccedc98d53d25$var$filterTokens = (allowedTokens, balances)=>{
29625
+ if (balances && balances.success) return allowedTokens.filter((token)=>{
29626
+ if ("address" in token) return balances.balances.find((balance)=>balance.token.address === token.address && balance.balance.gt(0));
29627
+ return balances.balances.find((balance)=>!("address" in balance.token) && balance.balance.gt(0));
29628
+ });
29629
+ return [];
29630
+ };
29631
+ const $5a5ccedc98d53d25$export$d744af9f1c0712bc = async (config, tokenBalances, availableRoutingOptions)=>{
29632
+ if (availableRoutingOptions.bridge) {
29633
+ const allowedTokens = (await config.remote.getConfig("bridge"))?.tokens ?? [];
29634
+ const balances = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
29635
+ return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
29636
+ }
29637
+ return [];
29638
+ };
29639
+
29640
+
29623
29641
  const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (balances, totalFees)=>{
29624
29642
  const balance = ($f730af3b727f04ac$export$22fea095b15361de)(balances);
29625
29643
  return balance.gte(totalFees);
@@ -29678,15 +29696,18 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
29678
29696
  chainId: chainId.toString()
29679
29697
  });
29680
29698
  // If no balances on layer 1 then Bridge cannot be an option
29681
- if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error getting balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR, {
29682
- chainId: chainId.toString()
29683
- });
29684
- if (tokenBalanceResult.balances.length === 0) return undefined;
29699
+ if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) return undefined;
29700
+ const allowedTokenList = await ($5a5ccedc98d53d25$export$d744af9f1c0712bc)(config, balances, availableRoutingOptions);
29701
+ if (allowedTokenList.length === 0) return undefined;
29685
29702
  const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
29686
29703
  // If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
29687
29704
  if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
29688
29705
  const l1address = await $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6(config, balanceRequirement);
29689
29706
  if (l1address === "") return undefined;
29707
+ // Ensure l1address is in the allowed token list
29708
+ if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
29709
+ if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
29710
+ } else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
29690
29711
  const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, balanceRequirement.delta.balance);
29691
29712
  if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
29692
29713
  // If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
@@ -29742,7 +29763,6 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
29742
29763
  });
29743
29764
  }
29744
29765
  const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
29745
- // Get allowed tokens?
29746
29766
  // Bridge and swap fee cache
29747
29767
  const feeEstimates = new Map();
29748
29768
  // Ensures only 1 balance requirement is insufficient otherwise one bridge route cannot be recommended
@@ -30489,7 +30509,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
30489
30509
  function $parcel$export(e, n, v, s) {
30490
30510
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
30491
30511
  }
30492
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.5";
30512
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.6";
30493
30513
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
30494
30514
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
30495
30515
 
package/dist/index.d.ts CHANGED
@@ -14520,6 +14520,7 @@ interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverri
14520
14520
  type RemoteConfiguration = {
14521
14521
  dex: DexConfig;
14522
14522
  onramp: OnRampConfig;
14523
+ bridge: BridgeConfig;
14523
14524
  allowedNetworks: AllowedNetworkConfig[];
14524
14525
  gasEstimateTokens?: GasEstimateTokenConfig;
14525
14526
  };
@@ -14561,6 +14562,13 @@ type DexConfig = {
14561
14562
  overrides?: ExchangeOverrides;
14562
14563
  tokens?: TokenInfo[];
14563
14564
  };
14565
+ /**
14566
+ * A type representing the configuration for the Bridge.
14567
+ * @property {TokenInfo[] | undefined} tokens - An array of tokens compatible with the Bridge.
14568
+ */
14569
+ type BridgeConfig = {
14570
+ tokens?: TokenInfo[];
14571
+ };
14564
14572
  /**
14565
14573
  * A type representing an allowed network.
14566
14574
  * @property {number} chainId - The network chain id.
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.5' };
2705
+ const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.6' };
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.5',
2765
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.6',
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.5',
3051
+ sdkVersion: 'ts-immutable-sdk-0.17.6',
3052
3052
  });
3053
3053
  /**
3054
3054
  * Sets `sdkVersion` at the time of build
@@ -29414,8 +29414,8 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
29414
29414
 
29415
29415
 
29416
29416
 
29417
- const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>true;
29418
- const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>true;
29417
+ const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>false;
29418
+ const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>false;
29419
29419
 
29420
29420
 
29421
29421
  const $7f2e17f026d4fc8d$var$isPassportProvider = (provider)=>(provider.provider?.isPassport === true) ?? false;
@@ -29598,6 +29598,24 @@ const $07ac9c0576988336$export$a3dd181de896b7c7 = async (config, readOnlyProvide
29598
29598
 
29599
29599
 
29600
29600
 
29601
+
29602
+ const $5a5ccedc98d53d25$var$filterTokens = (allowedTokens, balances)=>{
29603
+ if (balances && balances.success) return allowedTokens.filter((token)=>{
29604
+ if ("address" in token) return balances.balances.find((balance)=>balance.token.address === token.address && balance.balance.gt(0));
29605
+ return balances.balances.find((balance)=>!("address" in balance.token) && balance.balance.gt(0));
29606
+ });
29607
+ return [];
29608
+ };
29609
+ const $5a5ccedc98d53d25$export$d744af9f1c0712bc = async (config, tokenBalances, availableRoutingOptions)=>{
29610
+ if (availableRoutingOptions.bridge) {
29611
+ const allowedTokens = (await config.remote.getConfig("bridge"))?.tokens ?? [];
29612
+ const balances = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
29613
+ return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
29614
+ }
29615
+ return [];
29616
+ };
29617
+
29618
+
29601
29619
  const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (balances, totalFees)=>{
29602
29620
  const balance = ($f730af3b727f04ac$export$22fea095b15361de)(balances);
29603
29621
  return balance.gte(totalFees);
@@ -29656,15 +29674,18 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
29656
29674
  chainId: chainId.toString()
29657
29675
  });
29658
29676
  // 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;
29677
+ if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) return undefined;
29678
+ const allowedTokenList = await ($5a5ccedc98d53d25$export$d744af9f1c0712bc)(config, balances, availableRoutingOptions);
29679
+ if (allowedTokenList.length === 0) return undefined;
29663
29680
  const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
29664
29681
  // If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
29665
29682
  if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
29666
29683
  const l1address = await $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6(config, balanceRequirement);
29667
29684
  if (l1address === "") return undefined;
29685
+ // Ensure l1address is in the allowed token list
29686
+ if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
29687
+ if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
29688
+ } else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
29668
29689
  const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, balanceRequirement.delta.balance);
29669
29690
  if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
29670
29691
  // If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
@@ -29720,7 +29741,6 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
29720
29741
  });
29721
29742
  }
29722
29743
  const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
29723
- // Get allowed tokens?
29724
29744
  // Bridge and swap fee cache
29725
29745
  const feeEstimates = new Map();
29726
29746
  // Ensures only 1 balance requirement is insufficient otherwise one bridge route cannot be recommended
@@ -30467,7 +30487,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
30467
30487
  function $parcel$export(e, n, v, s) {
30468
30488
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
30469
30489
  }
30470
- const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.5";
30490
+ const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.6";
30471
30491
  const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
30472
30492
  const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
30473
30493
 
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.5' };
1712
+ const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.17.6' };
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.5',
1768
+ sdkVersion: 'ts-immutable-sdk-0.17.6',
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.5",
4
+ "version": "0.17.6",
5
5
  "author": "Immutable",
6
6
  "browser": "./dist/index.browser.js",
7
7
  "bugs": "https://github.com/immutable/ts-immutable-sdk/issues",