@imtbl/sdk 0.17.2 → 0.17.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11276,14 +11276,45 @@ interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverri
11276
11276
  * A type representing various remotely defined configurations which are
11277
11277
  * accessible via the Checkout config and configured based on the Environment.
11278
11278
  * @property {DexConfig} dex - The config used for the DEX.
11279
+ * @property {OnRampConfig} onramp - The config used for the OnRamp
11279
11280
  * @property {AllowedNetworkConfig[]} allowedNetworks - An array representing the allowed networks.
11280
11281
  * @property {GasEstimateTokenConfig | undefined} gasEstimateTokens - The config for the tokens used to estimate gas.
11281
11282
  */
11282
11283
  type RemoteConfiguration = {
11283
11284
  dex: DexConfig;
11285
+ onramp: OnRampConfig;
11284
11286
  allowedNetworks: AllowedNetworkConfig[];
11285
11287
  gasEstimateTokens?: GasEstimateTokenConfig;
11286
11288
  };
11289
+ /**
11290
+ * A type representing the fee structure for an OnRamp provider
11291
+ * @property {string | undefined} minPercentage - minimum percentage fee shown if a fee range is provided
11292
+ * @property {string | undefined} maxPercentage - maximum percentage fee shown if a fee range is provided
11293
+ * @property {string | undefined} feePercentage - specific fee percentage shown if there is no range provided
11294
+ */
11295
+ type OnRampProviderFees = {
11296
+ minPercentage?: string;
11297
+ maxPercentage?: string;
11298
+ feePercentage?: string;
11299
+ };
11300
+ /**
11301
+ * A type representing the configuration for the OnRamp for a specific provider.
11302
+ * @property {string} publishableApiKey - on ramp provider publishable api-key
11303
+ * @property {TokenInfo[]} tokens - allowed tokens for the OnRamp provider
11304
+ * @property {OnRampProviderFees} fees - on ramp provider transaction fees
11305
+ */
11306
+ type OnRampProviderConfig = {
11307
+ publishableApiKey: string;
11308
+ tokens: TokenInfo[];
11309
+ fees: OnRampProviderFees;
11310
+ };
11311
+ /**
11312
+ * A type representing the configuration for the OnRamp.
11313
+ * @property {OnRampProviderConfig} transak - OnRamp config for Transak provider
11314
+ */
11315
+ type OnRampConfig = {
11316
+ [key: string]: OnRampProviderConfig;
11317
+ };
11287
11318
  /**
11288
11319
  * A type representing the configuration for the DEX.
11289
11320
  * @property {ExchangeOverrides | undefined} overrides - The DEX overrides.
@@ -11614,7 +11645,8 @@ interface GetTokenAllowListResult {
11614
11645
  declare enum TokenFilterTypes {
11615
11646
  ALL = "all",
11616
11647
  SWAP = "swap",
11617
- BRIDGE = "bridge"
11648
+ BRIDGE = "bridge",
11649
+ ONRAMP = "onramp"
11618
11650
  }
11619
11651
  /**
11620
11652
  * Interface representing a token filter that can be used to exclude certain tokens.
@@ -11727,6 +11759,29 @@ type NetworkDetails = {
11727
11759
  blockExplorerUrls?: string[];
11728
11760
  };
11729
11761
  type NetworkMap = Map<ChainId, NetworkDetails>;
11762
+ /**
11763
+ * An enum representing the type of exchange.
11764
+ * @enum {string}
11765
+ * @property {string} ONRAMP - The exchange type for transacting.
11766
+ */
11767
+ declare enum ExchangeType {
11768
+ ONRAMP = "onramp"
11769
+ }
11770
+ /**
11771
+ * Interface representing the result of {@link Checkout.createFiatRampUrl}.
11772
+ * @property {ExchangeType} exchangeType - The ExchangeType specified.
11773
+ * @property {Web3Provider} web3Provider - The Web3Provider used to exchange.
11774
+ * @property {string | undefined} tokenAmount - The token amount specified as input.
11775
+ * @property {string | undefined} tokenAddress - The token address specified as input.
11776
+ * @property {Passport | undefined} passport - The Passport instance specified as input.
11777
+ */
11778
+ interface FiatRampParams {
11779
+ exchangeType: ExchangeType;
11780
+ web3Provider: Web3Provider;
11781
+ tokenAmount?: string;
11782
+ tokenAddress?: string;
11783
+ passport?: Passport;
11784
+ }
11730
11785
  /**
11731
11786
  * Enum representing different types of errors that can occur during the checkout process.
11732
11787
  */
@@ -11795,8 +11850,27 @@ declare class CheckoutConfiguration {
11795
11850
  readonly networkMap: NetworkMap;
11796
11851
  constructor(config: CheckoutModuleConfiguration);
11797
11852
  }
11853
+ interface FiatRampWidgetParams {
11854
+ exchangeType: ExchangeType;
11855
+ isPassport: boolean;
11856
+ walletAddress?: string;
11857
+ tokenAmount?: string;
11858
+ tokenSymbol?: string;
11859
+ email?: string;
11860
+ }
11861
+ declare class FiatRampService {
11862
+ readonly config: CheckoutConfiguration;
11863
+ /**
11864
+ * Constructs a new instance of the FiatRampService class.
11865
+ * @param {CheckoutConfiguration} config - The config required for the FiatRampService.
11866
+ */
11867
+ constructor(config: CheckoutConfiguration);
11868
+ feeEstimate(): Promise<OnRampProviderFees>;
11869
+ createWidgetUrl(params: FiatRampWidgetParams): Promise<string>;
11870
+ }
11798
11871
  declare class Checkout {
11799
11872
  readonly config: CheckoutConfiguration;
11873
+ readonly fiatRampService: FiatRampService;
11800
11874
  /**
11801
11875
  * Constructs a new instance of the CheckoutModule class.
11802
11876
  * @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
@@ -11901,6 +11975,17 @@ declare class Checkout {
11901
11975
  * @returns {Promise<GasEstimateSwapResult | GasEstimateBridgeToL2Result>} - A promise that resolves to the gas estimation result.
11902
11976
  */
11903
11977
  gasEstimate(params: GasEstimateParams): Promise<GasEstimateSwapResult | GasEstimateBridgeToL2Result>;
11978
+ /**
11979
+ * Creates and returns a URL for the fiat ramp widget.
11980
+ * @param {FiatRampParams} params - The parameters for creating the url.
11981
+ * @returns {Promise<string>} - A promise that resolves to a string url.
11982
+ */
11983
+ createFiatRampUrl(params: FiatRampParams): Promise<string>;
11984
+ /**
11985
+ * Fetches fiat ramp fee estimations.
11986
+ * @returns {Promise<OnRampProviderFees>} - A promise that resolves to OnRampProviderFees.
11987
+ */
11988
+ getExchangeFeeEstimate(): Promise<OnRampProviderFees>;
11904
11989
  }
11905
11990
 
11906
- export { AllowedNetworkConfig, BuyParams, BuyResult, CHECKOUT_API_BASE_URL, CancelParams, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, ConnectParams, ConnectResult, DexConfig, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, ItemType, NetworkFilter, NetworkFilterTypes, NetworkInfo, RemoteConfiguration, SellParams, SellResult, SendTransactionParams, SendTransactionResult, SmartCheckoutParams, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, WalletFilter, WalletFilterTypes, WalletInfo, WalletProviderName };
11991
+ export { AllowedNetworkConfig, BuyParams, BuyResult, CHECKOUT_API_BASE_URL, CancelParams, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, ConnectParams, ConnectResult, DexConfig, ErrorType, ExchangeType, FiatRampParams, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, ItemType, NetworkFilter, NetworkFilterTypes, NetworkInfo, RemoteConfiguration, SellParams, SellResult, SendTransactionParams, SendTransactionResult, SmartCheckoutParams, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, WalletFilter, WalletFilterTypes, WalletInfo, WalletProviderName };
@@ -1,6 +1,6 @@
1
1
  import { ethers, ContractFactory, utils, Contract as Contract$1, BigNumber as BigNumber$1, providers, constants as constants$1 } from 'ethers';
2
- import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
3
2
  import $7v2Z6$axios, { HttpStatusCode } from 'axios';
3
+ import { Web3Provider, JsonRpcProvider } from '@ethersproject/providers';
4
4
  import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
5
5
  import { TradeType, Token, CurrencyAmount, Percent } from '@uniswap/sdk-core';
6
6
  import assert from 'assert';
@@ -16974,6 +16974,7 @@ const constants = {
16974
16974
 
16975
16975
 
16976
16976
 
16977
+
16977
16978
  var $aa144554f9ef124b$export$226b052ecb8ca80;
16978
16979
  (function(BuyStatusType) {
16979
16980
  BuyStatusType["SUCCESS"] = "SUCCESS";
@@ -17014,6 +17015,10 @@ var $0472f23319457bfb$export$b874c6b1dfe85e02;
17014
17015
  })($0472f23319457bfb$export$b874c6b1dfe85e02 || ($0472f23319457bfb$export$b874c6b1dfe85e02 = {}));
17015
17016
 
17016
17017
 
17018
+ var $bc2bfebf768286d3$export$8cb0af6b2bed4b64;
17019
+ (function(OnRampProvider) {
17020
+ OnRampProvider["TRANSAK"] = "201811419111";
17021
+ })($bc2bfebf768286d3$export$8cb0af6b2bed4b64 || ($bc2bfebf768286d3$export$8cb0af6b2bed4b64 = {}));
17017
17022
 
17018
17023
 
17019
17024
 
@@ -17045,6 +17050,7 @@ var $08d5ddc39acd6833$export$fd9b17d87f4121d2;
17045
17050
  TokenFilterTypes["ALL"] = "all";
17046
17051
  TokenFilterTypes["SWAP"] = "swap";
17047
17052
  TokenFilterTypes["BRIDGE"] = "bridge";
17053
+ TokenFilterTypes["ONRAMP"] = "onramp";
17048
17054
  })($08d5ddc39acd6833$export$fd9b17d87f4121d2 || ($08d5ddc39acd6833$export$fd9b17d87f4121d2 = {}));
17049
17055
 
17050
17056
 
@@ -17104,11 +17110,9 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
17104
17110
  const $d85ad1457a3f1a83$export$72176e2233d7d5d = true;
17105
17111
  const $d85ad1457a3f1a83$export$566b5975cc83d6b4 = true;
17106
17112
  const $d85ad1457a3f1a83$export$261cde2078dba35b = true;
17107
- const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
17108
- [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET]: {
17109
- url: "https://explorer.testnet.immutable.com",
17110
- nativeToken: $d85ad1457a3f1a83$var$ZKEVM_NATIVE_TOKEN
17111
- }
17113
+ const $d85ad1457a3f1a83$export$f6043d7fce62d71b = {
17114
+ [(Environment$1).SANDBOX]: "https://global-stg.transak.com",
17115
+ [(Environment$1).PRODUCTION]: "https://global.transak.com/"
17112
17116
  };
17113
17117
  const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
17114
17118
  [
@@ -17203,6 +17207,16 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
17203
17207
  }
17204
17208
  ]
17205
17209
  ]);
17210
+ const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
17211
+ [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET]: {
17212
+ url: "https://explorer.testnet.immutable.com",
17213
+ nativeToken: $d85ad1457a3f1a83$export$3e81fc0987227f10.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET).nativeCurrency
17214
+ },
17215
+ [($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET]: {
17216
+ url: "https://explorer.mainnet.immutable.com",
17217
+ nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET).nativeCurrency
17218
+ }
17219
+ };
17206
17220
  const $d85ad1457a3f1a83$export$db5daa1b5156ccfe = [
17207
17221
  {
17208
17222
  constant: true,
@@ -17416,6 +17430,12 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
17416
17430
  })($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
17417
17431
 
17418
17432
 
17433
+ var $e055e79256bbc1dd$export$80f4da0d409a629d;
17434
+ (function(ExchangeType) {
17435
+ ExchangeType["ONRAMP"] = "onramp";
17436
+ })($e055e79256bbc1dd$export$80f4da0d409a629d || ($e055e79256bbc1dd$export$80f4da0d409a629d = {}));
17437
+
17438
+
17419
17439
 
17420
17440
 
17421
17441
  /**
@@ -17627,8 +17647,118 @@ async function $de192de6ef100f9f$export$b827d9418aeb5dbd(config, web3Provider, c
17627
17647
 
17628
17648
 
17629
17649
 
17650
+
17651
+
17652
+
17653
+
17654
+
17655
+ class $a492ee374ae7b613$export$d902b56530cd5f87 {
17656
+ isDevelopment;
17657
+ isProduction;
17658
+ configCache;
17659
+ tokensCache;
17660
+ constructor(params){
17661
+ this.isDevelopment = params.isDevelopment;
17662
+ this.isProduction = params.isProduction;
17663
+ }
17664
+ static async makeHttpRequest(url) {
17665
+ let response;
17666
+ try {
17667
+ response = await (0, $7v2Z6$axios).get(url);
17668
+ } catch (error) {
17669
+ throw new Error(`Error fetching from api: ${error.message}`);
17670
+ }
17671
+ if (response.status !== 200) throw new Error(`Error fetching from api: ${response.status} ${response.statusText}`);
17672
+ return response;
17673
+ }
17674
+ getEndpoint = ()=>{
17675
+ if (this.isDevelopment) return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[$d85ad1457a3f1a83$export$7d3a9eeba384fa59];
17676
+ if (this.isProduction) return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment$1).PRODUCTION];
17677
+ return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment$1).SANDBOX];
17678
+ };
17679
+ async loadConfig() {
17680
+ if (this.configCache) return this.configCache;
17681
+ const response = await $a492ee374ae7b613$export$d902b56530cd5f87.makeHttpRequest(`${this.getEndpoint()}/v1/config`);
17682
+ this.configCache = response.data;
17683
+ return this.configCache;
17684
+ }
17685
+ async loadConfigTokens() {
17686
+ if (this.tokensCache) return this.tokensCache;
17687
+ const response = await $a492ee374ae7b613$export$d902b56530cd5f87.makeHttpRequest(`${this.getEndpoint()}/v1/config/tokens`);
17688
+ this.tokensCache = response.data;
17689
+ return this.tokensCache;
17690
+ }
17691
+ async getConfig(key) {
17692
+ const config = await this.loadConfig();
17693
+ if (!config) return undefined;
17694
+ if (!key) return config;
17695
+ return config[key];
17696
+ }
17697
+ async getTokensConfig(chainId) {
17698
+ const config = await this.loadConfigTokens();
17699
+ if (!config || !config[chainId]) return {};
17700
+ return config[chainId] ?? [];
17701
+ }
17702
+ }
17703
+
17704
+
17705
+ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
17706
+ message;
17707
+ constructor(message){
17708
+ super(message);
17709
+ this.message = message;
17710
+ }
17711
+ }
17712
+ const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
17713
+ if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
17714
+ if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
17715
+ return $d85ad1457a3f1a83$export$3e81fc0987227f10;
17716
+ };
17717
+ const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
17718
+ // DevMode and Sandbox will both use Sepolia.
17719
+ if (!config.isProduction) return ($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA;
17720
+ return ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM;
17721
+ };
17722
+ const $4013c5c91bb535f6$export$c9af4e4b001c6476 = (config)=>{
17723
+ if (config.isDevelopment) return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET;
17724
+ if (config.isProduction) return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET;
17725
+ return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET;
17726
+ };
17727
+ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
17728
+ // This is a hidden feature that is only available
17729
+ // when building the project from source code.
17730
+ // This will be used to get around the lack of
17731
+ // Environment.DEVELOPMENT
17732
+ isDevelopment = false;
17733
+ isProduction;
17734
+ isOnRampEnabled;
17735
+ isSwapEnabled;
17736
+ isBridgeEnabled;
17737
+ remote;
17738
+ environment;
17739
+ networkMap;
17740
+ constructor(config){
17741
+ if (!Object.values((Environment$1)).includes(config.baseConfig.environment)) throw new $4013c5c91bb535f6$export$6ad73ea7e1b6f37f("Invalid checkout configuration of environment");
17742
+ this.environment = config.baseConfig.environment;
17743
+ // Developer mode will super set any environment configuration
17744
+ this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
17745
+ this.isOnRampEnabled = config.isOnRampEnabled ?? ($d85ad1457a3f1a83$export$72176e2233d7d5d);
17746
+ this.isSwapEnabled = config.isSwapEnabled ?? ($d85ad1457a3f1a83$export$566b5975cc83d6b4);
17747
+ this.isBridgeEnabled = config.isBridgeEnabled ?? ($d85ad1457a3f1a83$export$261cde2078dba35b);
17748
+ this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
17749
+ this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
17750
+ isDevelopment: this.isDevelopment,
17751
+ isProduction: this.isProduction
17752
+ });
17753
+ }
17754
+ }
17755
+
17756
+
17757
+
17758
+
17630
17759
  const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type = ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL, chainId: chainId, exclude: exclude })=>{
17631
17760
  let tokens = [];
17761
+ let onRampConfig;
17632
17762
  switch(type){
17633
17763
  case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).SWAP:
17634
17764
  // Fetch tokens from dex-tokens config because
@@ -17636,10 +17766,16 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type =
17636
17766
  // legal reasons.
17637
17767
  tokens = (await config.remote.getConfig("dex")).tokens || [];
17638
17768
  break;
17769
+ case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ONRAMP:
17770
+ onRampConfig = await config.remote.getConfig("onramp");
17771
+ // Only using Transak as it's the only on-ramp provider at the moment
17772
+ if (!onRampConfig) tokens = [];
17773
+ tokens = onRampConfig[($bc2bfebf768286d3$export$8cb0af6b2bed4b64).TRANSAK]?.tokens || [];
17774
+ break;
17639
17775
  case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).BRIDGE:
17640
17776
  case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL:
17641
17777
  default:
17642
- tokens = (await config.remote.getTokensConfig(chainId)).allowed;
17778
+ tokens = (await config.remote.getTokensConfig(chainId || ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config))).allowed;
17643
17779
  }
17644
17780
  if (!exclude || exclude?.length === 0) return {
17645
17781
  tokens: tokens
@@ -17855,7 +17991,14 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
17855
17991
  items.push(...resp.items);
17856
17992
  }while (resp.next_page_params);
17857
17993
  } catch (err) {
17858
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
17994
+ // In case of a 404, the wallet is a new wallet that hasn't been indexed by
17995
+ // the Blockscout just yet. This happens when a wallet hasn't had any
17996
+ // activity on the chain. In this case, simply ignore the error and return
17997
+ // no currencies.
17998
+ // In case of a malformed wallet address, Blockscout returns a 422, which
17999
+ // means we are safe to assume that a 404 is a missing wallet due to inactivity
18000
+ // or simply an incorrect wallet address was provided.
18001
+ if (err?.code !== (HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
17859
18002
  }
17860
18003
  try {
17861
18004
  const respNative = await $1564e43dde50bb61$var$blockscoutClient.getNativeTokenByWalletAddress({
@@ -17863,7 +18006,14 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
17863
18006
  });
17864
18007
  items.push(respNative);
17865
18008
  } catch (err) {
17866
- throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
18009
+ // In case of a 404, the wallet is a new wallet that hasn't been indexed by
18010
+ // the Blockscout just yet. This happens when a wallet hasn't had any
18011
+ // activity on the chain. In this case, simply ignore the error and return
18012
+ // no currencies.
18013
+ // In case of a malformed wallet address, Blockscout returns a 422, which
18014
+ // means we are safe to assume that a 404 is a missing wallet due to inactivity
18015
+ // or simply an incorrect wallet address was provided.
18016
+ if (err?.code !== (HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
17867
18017
  }
17868
18018
  return {
17869
18019
  balances: items.map((item)=>{
@@ -18169,114 +18319,6 @@ async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
18169
18319
 
18170
18320
 
18171
18321
 
18172
-
18173
-
18174
-
18175
-
18176
- class $a492ee374ae7b613$export$d902b56530cd5f87 {
18177
- isDevelopment;
18178
- isProduction;
18179
- configCache;
18180
- tokensCache;
18181
- constructor(params){
18182
- this.isDevelopment = params.isDevelopment;
18183
- this.isProduction = params.isProduction;
18184
- }
18185
- static async makeHttpRequest(url) {
18186
- let response;
18187
- try {
18188
- response = await (0, $7v2Z6$axios).get(url);
18189
- } catch (error) {
18190
- throw new Error(`Error fetching from api: ${error.message}`);
18191
- }
18192
- if (response.status !== 200) throw new Error(`Error fetching from api: ${response.status} ${response.statusText}`);
18193
- return response;
18194
- }
18195
- getEndpoint = ()=>{
18196
- if (this.isDevelopment) return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[$d85ad1457a3f1a83$export$7d3a9eeba384fa59];
18197
- if (this.isProduction) return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment$1).PRODUCTION];
18198
- return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment$1).SANDBOX];
18199
- };
18200
- async loadConfig() {
18201
- if (this.configCache) return this.configCache;
18202
- const response = await $a492ee374ae7b613$export$d902b56530cd5f87.makeHttpRequest(`${this.getEndpoint()}/v1/config`);
18203
- this.configCache = response.data;
18204
- return this.configCache;
18205
- }
18206
- async loadConfigTokens() {
18207
- if (this.tokensCache) return this.tokensCache;
18208
- const response = await $a492ee374ae7b613$export$d902b56530cd5f87.makeHttpRequest(`${this.getEndpoint()}/v1/config/tokens`);
18209
- this.tokensCache = response.data;
18210
- return this.tokensCache;
18211
- }
18212
- async getConfig(key) {
18213
- const config = await this.loadConfig();
18214
- if (!config) return undefined;
18215
- if (!key) return config;
18216
- return config[key];
18217
- }
18218
- async getTokensConfig(chainId) {
18219
- const config = await this.loadConfigTokens();
18220
- if (!config || !config[chainId]) return {};
18221
- return config[chainId] ?? [];
18222
- }
18223
- }
18224
-
18225
-
18226
- class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
18227
- message;
18228
- constructor(message){
18229
- super(message);
18230
- this.message = message;
18231
- }
18232
- }
18233
- const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
18234
- if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
18235
- if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
18236
- return $d85ad1457a3f1a83$export$3e81fc0987227f10;
18237
- };
18238
- const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
18239
- // DevMode and Sandbox will both use Sepolia.
18240
- if (!config.isProduction) return ($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA;
18241
- return ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM;
18242
- };
18243
- const $4013c5c91bb535f6$export$c9af4e4b001c6476 = (config)=>{
18244
- if (config.isDevelopment) return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET;
18245
- if (config.isProduction) return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET;
18246
- return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET;
18247
- };
18248
- class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
18249
- // This is a hidden feature that is only available
18250
- // when building the project from source code.
18251
- // This will be used to get around the lack of
18252
- // Environment.DEVELOPMENT
18253
- isDevelopment = false;
18254
- isProduction;
18255
- isOnRampEnabled;
18256
- isSwapEnabled;
18257
- isBridgeEnabled;
18258
- remote;
18259
- environment;
18260
- networkMap;
18261
- constructor(config){
18262
- if (!Object.values((Environment$1)).includes(config.baseConfig.environment)) throw new $4013c5c91bb535f6$export$6ad73ea7e1b6f37f("Invalid checkout configuration of environment");
18263
- this.environment = config.baseConfig.environment;
18264
- // Developer mode will super set any environment configuration
18265
- this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
18266
- this.isOnRampEnabled = config.isOnRampEnabled ?? ($d85ad1457a3f1a83$export$72176e2233d7d5d);
18267
- this.isSwapEnabled = config.isSwapEnabled ?? ($d85ad1457a3f1a83$export$566b5975cc83d6b4);
18268
- this.isBridgeEnabled = config.isBridgeEnabled ?? ($d85ad1457a3f1a83$export$261cde2078dba35b);
18269
- this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
18270
- this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
18271
- isDevelopment: this.isDevelopment,
18272
- isProduction: this.isProduction
18273
- });
18274
- }
18275
- }
18276
-
18277
-
18278
-
18279
-
18280
18322
  const $2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS = "0x0000000000000000000000000000000000000001";
18281
18323
  const $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS = 18;
18282
18324
  async function $2e7bf45a7c9a9570$var$getTokenInfoByAddress(config, tokenAddress, chainId, provider) {
@@ -19614,6 +19656,49 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, id, c
19614
19656
 
19615
19657
 
19616
19658
 
19659
+
19660
+
19661
+ class $a77d203f701a3b72$export$1453e9b801542ef4 {
19662
+ config;
19663
+ /**
19664
+ * Constructs a new instance of the FiatRampService class.
19665
+ * @param {CheckoutConfiguration} config - The config required for the FiatRampService.
19666
+ */ constructor(config){
19667
+ this.config = config;
19668
+ }
19669
+ async feeEstimate() {
19670
+ const config = await this.config.remote.getConfig("onramp");
19671
+ return config[($bc2bfebf768286d3$export$8cb0af6b2bed4b64).TRANSAK]?.fees;
19672
+ }
19673
+ async createWidgetUrl(params) {
19674
+ return await this.getTransakWidgetUrl(params);
19675
+ }
19676
+ async getTransakWidgetUrl(params) {
19677
+ let widgetUrl = `${($d85ad1457a3f1a83$export$f6043d7fce62d71b)[this.config.environment]}?`;
19678
+ const onRampConfig = await this.config.remote.getConfig("onramp");
19679
+ const apiKey = onRampConfig[($bc2bfebf768286d3$export$8cb0af6b2bed4b64).TRANSAK].publishableApiKey;
19680
+ const transakPublishableKey = `apiKey=${apiKey}`;
19681
+ const zkevmNetwork = "network=immutablezkevm";
19682
+ const defaultPaymentMethod = "defaultPaymentMethod=credit_debit_card";
19683
+ const disableBankTransfer = "disablePaymentMethods=sepa_bank_transfer,gbp_bank_transfer,pm_cash_app,pm_jwire,pm_paymaya,pm_bpi,pm_ubp,pm_grabpay,pm_shopeepay,pm_gcash,pm_pix,pm_astropay,pm_pse,inr_bank_transfer";
19684
+ const productsAvailed = "productsAvailed=buy";
19685
+ const exchangeScreenTitle = "exchangeScreenTitle=Buy";
19686
+ const themeColor = "themeColor=0D0D0D";
19687
+ widgetUrl += `${transakPublishableKey}&` + `${zkevmNetwork}&` + `${defaultPaymentMethod}&` + `${disableBankTransfer}&` + `${productsAvailed}&` + `${exchangeScreenTitle}&` + `${themeColor}`;
19688
+ if (params.isPassport && params.email) {
19689
+ const encodedEmail = encodeURIComponent(params.email);
19690
+ widgetUrl += `&email=${encodedEmail}&isAutoFillUserData=true&disableWalletAddressForm=true`;
19691
+ }
19692
+ if (params.tokenAmount && params.tokenSymbol) widgetUrl += `&defaultCryptoAmount=${params.tokenAmount}&cryptoCurrencyCode=${params.tokenSymbol}`;
19693
+ else widgetUrl += "&defaultCryptoCurrency=IMX";
19694
+ if (params.walletAddress) widgetUrl += `&walletAddress=${params.walletAddress}`;
19695
+ return widgetUrl;
19696
+ }
19697
+ }
19698
+
19699
+
19700
+
19701
+
19617
19702
  const $a8cb37a3fc8eb863$var$SANDBOX_CONFIGURATION = {
19618
19703
  baseConfig: {
19619
19704
  environment: (Environment$1).SANDBOX
@@ -19621,12 +19706,14 @@ const $a8cb37a3fc8eb863$var$SANDBOX_CONFIGURATION = {
19621
19706
  };
19622
19707
  class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
19623
19708
  config;
19709
+ fiatRampService;
19624
19710
  readOnlyProviders;
19625
19711
  /**
19626
19712
  * Constructs a new instance of the CheckoutModule class.
19627
19713
  * @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
19628
19714
  */ constructor(config = $a8cb37a3fc8eb863$var$SANDBOX_CONFIGURATION){
19629
19715
  this.config = new ($4013c5c91bb535f6$export$4823433c4a67bbc6)(config);
19716
+ this.fiatRampService = new ($a77d203f701a3b72$export$1453e9b801542ef4)(this.config);
19630
19717
  this.readOnlyProviders = new Map();
19631
19718
  }
19632
19719
  /**
@@ -19787,6 +19874,43 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
19787
19874
  this.readOnlyProviders = await ($0e0060cb42e136d2$export$339cb2be73677b30)(this.config, this.readOnlyProviders);
19788
19875
  return await $2e7bf45a7c9a9570$export$942c8de7174809fc(params, this.readOnlyProviders, this.config);
19789
19876
  }
19877
+ /**
19878
+ * Creates and returns a URL for the fiat ramp widget.
19879
+ * @param {FiatRampParams} params - The parameters for creating the url.
19880
+ * @returns {Promise<string>} - A promise that resolves to a string url.
19881
+ */ async createFiatRampUrl(params) {
19882
+ let tokenAmount;
19883
+ let tokenSymbol = "IMX";
19884
+ let email;
19885
+ const walletAddress = await params.web3Provider.getSigner().getAddress();
19886
+ const isPassport = params.web3Provider.provider?.isPassport || false;
19887
+ if (isPassport && params.passport) {
19888
+ const userInfo = await params.passport.getUserInfo();
19889
+ email = userInfo?.email;
19890
+ }
19891
+ const tokenList = await $efe60cea83bfc4e8$export$473cec51305fdae8(this.config, {
19892
+ type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ONRAMP
19893
+ });
19894
+ const token = tokenList.tokens.find((t)=>t.address?.toLowerCase() === params.tokenAddress?.toLowerCase());
19895
+ if (token) {
19896
+ tokenAmount = params.tokenAmount;
19897
+ tokenSymbol = token.symbol;
19898
+ }
19899
+ return await this.fiatRampService.createWidgetUrl({
19900
+ exchangeType: params.exchangeType,
19901
+ isPassport: isPassport,
19902
+ walletAddress: walletAddress,
19903
+ tokenAmount: tokenAmount,
19904
+ tokenSymbol: tokenSymbol,
19905
+ email: email
19906
+ });
19907
+ }
19908
+ /**
19909
+ * Fetches fiat ramp fee estimations.
19910
+ * @returns {Promise<OnRampProviderFees>} - A promise that resolves to OnRampProviderFees.
19911
+ */ async getExchangeFeeEstimate() {
19912
+ return await this.fiatRampService.feeEstimate();
19913
+ }
19790
19914
  }
19791
19915
 
19792
- export { $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, $4b58188d47aafe8d$export$537fa3efd10ed435 as GasTokenType, $4b58188d47aafe8d$export$1fc8f52ad1810e52 as ItemType, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $4b58188d47aafe8d$export$65c64e46348ee3c1 as TransactionOrGasType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName };
19916
+ export { $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $0472f23319457bfb$export$c06e1e7429de6283 as ChainId, $0472f23319457bfb$export$b874c6b1dfe85e02 as ChainName, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $e055e79256bbc1dd$export$80f4da0d409a629d as ExchangeType, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, $4b58188d47aafe8d$export$537fa3efd10ed435 as GasTokenType, $4b58188d47aafe8d$export$1fc8f52ad1810e52 as ItemType, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $4b58188d47aafe8d$export$65c64e46348ee3c1 as TransactionOrGasType, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName };