@imtbl/sdk 0.17.1 → 0.17.3

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 };
@@ -17014,6 +17014,10 @@ var $0472f23319457bfb$export$b874c6b1dfe85e02;
17014
17014
  })($0472f23319457bfb$export$b874c6b1dfe85e02 || ($0472f23319457bfb$export$b874c6b1dfe85e02 = {}));
17015
17015
 
17016
17016
 
17017
+ var $bc2bfebf768286d3$export$8cb0af6b2bed4b64;
17018
+ (function(OnRampProvider) {
17019
+ OnRampProvider["TRANSAK"] = "201811419111";
17020
+ })($bc2bfebf768286d3$export$8cb0af6b2bed4b64 || ($bc2bfebf768286d3$export$8cb0af6b2bed4b64 = {}));
17017
17021
 
17018
17022
 
17019
17023
 
@@ -17045,6 +17049,7 @@ var $08d5ddc39acd6833$export$fd9b17d87f4121d2;
17045
17049
  TokenFilterTypes["ALL"] = "all";
17046
17050
  TokenFilterTypes["SWAP"] = "swap";
17047
17051
  TokenFilterTypes["BRIDGE"] = "bridge";
17052
+ TokenFilterTypes["ONRAMP"] = "onramp";
17048
17053
  })($08d5ddc39acd6833$export$fd9b17d87f4121d2 || ($08d5ddc39acd6833$export$fd9b17d87f4121d2 = {}));
17049
17054
 
17050
17055
 
@@ -17110,6 +17115,10 @@ const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
17110
17115
  nativeToken: $d85ad1457a3f1a83$var$ZKEVM_NATIVE_TOKEN
17111
17116
  }
17112
17117
  };
17118
+ const $d85ad1457a3f1a83$export$f6043d7fce62d71b = {
17119
+ [(Environment$1).SANDBOX]: "https://global-stg.transak.com",
17120
+ [(Environment$1).PRODUCTION]: "https://global.transak.com/"
17121
+ };
17113
17122
  const $d85ad1457a3f1a83$export$6f24f3cef7d501c4 = new Map([
17114
17123
  [
17115
17124
  ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM,
@@ -17416,6 +17425,12 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
17416
17425
  })($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
17417
17426
 
17418
17427
 
17428
+ var $e055e79256bbc1dd$export$80f4da0d409a629d;
17429
+ (function(ExchangeType) {
17430
+ ExchangeType["ONRAMP"] = "onramp";
17431
+ })($e055e79256bbc1dd$export$80f4da0d409a629d || ($e055e79256bbc1dd$export$80f4da0d409a629d = {}));
17432
+
17433
+
17419
17434
 
17420
17435
 
17421
17436
  /**
@@ -17627,8 +17642,118 @@ async function $de192de6ef100f9f$export$b827d9418aeb5dbd(config, web3Provider, c
17627
17642
 
17628
17643
 
17629
17644
 
17645
+
17646
+
17647
+
17648
+
17649
+
17650
+ class $a492ee374ae7b613$export$d902b56530cd5f87 {
17651
+ isDevelopment;
17652
+ isProduction;
17653
+ configCache;
17654
+ tokensCache;
17655
+ constructor(params){
17656
+ this.isDevelopment = params.isDevelopment;
17657
+ this.isProduction = params.isProduction;
17658
+ }
17659
+ static async makeHttpRequest(url) {
17660
+ let response;
17661
+ try {
17662
+ response = await (0, $7v2Z6$axios).get(url);
17663
+ } catch (error) {
17664
+ throw new Error(`Error fetching from api: ${error.message}`);
17665
+ }
17666
+ if (response.status !== 200) throw new Error(`Error fetching from api: ${response.status} ${response.statusText}`);
17667
+ return response;
17668
+ }
17669
+ getEndpoint = ()=>{
17670
+ if (this.isDevelopment) return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[$d85ad1457a3f1a83$export$7d3a9eeba384fa59];
17671
+ if (this.isProduction) return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment$1).PRODUCTION];
17672
+ return ($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment$1).SANDBOX];
17673
+ };
17674
+ async loadConfig() {
17675
+ if (this.configCache) return this.configCache;
17676
+ const response = await $a492ee374ae7b613$export$d902b56530cd5f87.makeHttpRequest(`${this.getEndpoint()}/v1/config`);
17677
+ this.configCache = response.data;
17678
+ return this.configCache;
17679
+ }
17680
+ async loadConfigTokens() {
17681
+ if (this.tokensCache) return this.tokensCache;
17682
+ const response = await $a492ee374ae7b613$export$d902b56530cd5f87.makeHttpRequest(`${this.getEndpoint()}/v1/config/tokens`);
17683
+ this.tokensCache = response.data;
17684
+ return this.tokensCache;
17685
+ }
17686
+ async getConfig(key) {
17687
+ const config = await this.loadConfig();
17688
+ if (!config) return undefined;
17689
+ if (!key) return config;
17690
+ return config[key];
17691
+ }
17692
+ async getTokensConfig(chainId) {
17693
+ const config = await this.loadConfigTokens();
17694
+ if (!config || !config[chainId]) return {};
17695
+ return config[chainId] ?? [];
17696
+ }
17697
+ }
17698
+
17699
+
17700
+ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
17701
+ message;
17702
+ constructor(message){
17703
+ super(message);
17704
+ this.message = message;
17705
+ }
17706
+ }
17707
+ const $4013c5c91bb535f6$var$networkMap = (prod, dev)=>{
17708
+ if (dev) return $d85ad1457a3f1a83$export$3a9ebede6a150274;
17709
+ if (prod) return $d85ad1457a3f1a83$export$6f24f3cef7d501c4;
17710
+ return $d85ad1457a3f1a83$export$3e81fc0987227f10;
17711
+ };
17712
+ const $4013c5c91bb535f6$export$9b794d067cdd1af6 = (config)=>{
17713
+ // DevMode and Sandbox will both use Sepolia.
17714
+ if (!config.isProduction) return ($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA;
17715
+ return ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM;
17716
+ };
17717
+ const $4013c5c91bb535f6$export$c9af4e4b001c6476 = (config)=>{
17718
+ if (config.isDevelopment) return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET;
17719
+ if (config.isProduction) return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET;
17720
+ return ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET;
17721
+ };
17722
+ class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
17723
+ // This is a hidden feature that is only available
17724
+ // when building the project from source code.
17725
+ // This will be used to get around the lack of
17726
+ // Environment.DEVELOPMENT
17727
+ isDevelopment = false;
17728
+ isProduction;
17729
+ isOnRampEnabled;
17730
+ isSwapEnabled;
17731
+ isBridgeEnabled;
17732
+ remote;
17733
+ environment;
17734
+ networkMap;
17735
+ constructor(config){
17736
+ if (!Object.values((Environment$1)).includes(config.baseConfig.environment)) throw new $4013c5c91bb535f6$export$6ad73ea7e1b6f37f("Invalid checkout configuration of environment");
17737
+ this.environment = config.baseConfig.environment;
17738
+ // Developer mode will super set any environment configuration
17739
+ this.isProduction = !this.isDevelopment && this.environment === (Environment$1).PRODUCTION;
17740
+ this.isOnRampEnabled = config.isOnRampEnabled ?? ($d85ad1457a3f1a83$export$72176e2233d7d5d);
17741
+ this.isSwapEnabled = config.isSwapEnabled ?? ($d85ad1457a3f1a83$export$566b5975cc83d6b4);
17742
+ this.isBridgeEnabled = config.isBridgeEnabled ?? ($d85ad1457a3f1a83$export$261cde2078dba35b);
17743
+ this.networkMap = $4013c5c91bb535f6$var$networkMap(this.isProduction, this.isDevelopment);
17744
+ this.remote = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
17745
+ isDevelopment: this.isDevelopment,
17746
+ isProduction: this.isProduction
17747
+ });
17748
+ }
17749
+ }
17750
+
17751
+
17752
+
17753
+
17630
17754
  const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type = ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL, chainId: chainId, exclude: exclude })=>{
17631
17755
  let tokens = [];
17756
+ let onRampConfig;
17632
17757
  switch(type){
17633
17758
  case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).SWAP:
17634
17759
  // Fetch tokens from dex-tokens config because
@@ -17636,10 +17761,16 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type =
17636
17761
  // legal reasons.
17637
17762
  tokens = (await config.remote.getConfig("dex")).tokens || [];
17638
17763
  break;
17764
+ case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ONRAMP:
17765
+ onRampConfig = await config.remote.getConfig("onramp");
17766
+ // Only using Transak as it's the only on-ramp provider at the moment
17767
+ if (!onRampConfig) tokens = [];
17768
+ tokens = onRampConfig[($bc2bfebf768286d3$export$8cb0af6b2bed4b64).TRANSAK]?.tokens || [];
17769
+ break;
17639
17770
  case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).BRIDGE:
17640
17771
  case ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ALL:
17641
17772
  default:
17642
- tokens = (await config.remote.getTokensConfig(chainId)).allowed;
17773
+ tokens = (await config.remote.getTokensConfig(chainId || ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config))).allowed;
17643
17774
  }
17644
17775
  if (!exclude || exclude?.length === 0) return {
17645
17776
  tokens: tokens
@@ -17712,7 +17843,7 @@ class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
17712
17843
  if (params.nextPage) url += `&${new URLSearchParams(params.nextPage)}`;
17713
17844
  // Cache response data to prevent unnecessary requests
17714
17845
  const cached = this.getCache(url);
17715
- if (cached && cached.status < 400) return Promise.resolve(cached.data);
17846
+ if (cached) return Promise.resolve(cached);
17716
17847
  const response = await $fd8a8472dcc3ec2b$export$ef140a6b05dfc786.makeHttpRequest(url);
17717
17848
  if (response.status >= 400) return Promise.reject({
17718
17849
  code: response.status,
@@ -17751,7 +17882,7 @@ class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
17751
17882
  const url = `${this.url}/api/v2/addresses/${params.walletAddress}`;
17752
17883
  // Cache response data to prevent unnecessary requests
17753
17884
  const cached = this.getCache(url);
17754
- if (cached && cached.status < 400) return Promise.resolve(cached.data);
17885
+ if (cached) return Promise.resolve(cached);
17755
17886
  const response = await $fd8a8472dcc3ec2b$export$ef140a6b05dfc786.makeHttpRequest(url);
17756
17887
  if (response.status >= 400) return Promise.reject({
17757
17888
  code: response.status,
@@ -18169,114 +18300,6 @@ async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
18169
18300
 
18170
18301
 
18171
18302
 
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
18303
  const $2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS = "0x0000000000000000000000000000000000000001";
18281
18304
  const $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS = 18;
18282
18305
  async function $2e7bf45a7c9a9570$var$getTokenInfoByAddress(config, tokenAddress, chainId, provider) {
@@ -19614,6 +19637,49 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, id, c
19614
19637
 
19615
19638
 
19616
19639
 
19640
+
19641
+
19642
+ class $a77d203f701a3b72$export$1453e9b801542ef4 {
19643
+ config;
19644
+ /**
19645
+ * Constructs a new instance of the FiatRampService class.
19646
+ * @param {CheckoutConfiguration} config - The config required for the FiatRampService.
19647
+ */ constructor(config){
19648
+ this.config = config;
19649
+ }
19650
+ async feeEstimate() {
19651
+ const config = await this.config.remote.getConfig("onramp");
19652
+ return config[($bc2bfebf768286d3$export$8cb0af6b2bed4b64).TRANSAK]?.fees;
19653
+ }
19654
+ async createWidgetUrl(params) {
19655
+ return await this.getTransakWidgetUrl(params);
19656
+ }
19657
+ async getTransakWidgetUrl(params) {
19658
+ let widgetUrl = `${($d85ad1457a3f1a83$export$f6043d7fce62d71b)[this.config.environment]}?`;
19659
+ const onRampConfig = await this.config.remote.getConfig("onramp");
19660
+ const apiKey = onRampConfig[($bc2bfebf768286d3$export$8cb0af6b2bed4b64).TRANSAK].publishableApiKey;
19661
+ const transakPublishableKey = `apiKey=${apiKey}`;
19662
+ const zkevmNetwork = "network=immutablezkevm";
19663
+ const defaultPaymentMethod = "defaultPaymentMethod=credit_debit_card";
19664
+ 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";
19665
+ const productsAvailed = "productsAvailed=buy";
19666
+ const exchangeScreenTitle = "exchangeScreenTitle=Buy";
19667
+ const themeColor = "themeColor=0D0D0D";
19668
+ widgetUrl += `${transakPublishableKey}&` + `${zkevmNetwork}&` + `${defaultPaymentMethod}&` + `${disableBankTransfer}&` + `${productsAvailed}&` + `${exchangeScreenTitle}&` + `${themeColor}`;
19669
+ if (params.isPassport && params.email) {
19670
+ const encodedEmail = encodeURIComponent(params.email);
19671
+ widgetUrl += `&email=${encodedEmail}&isAutoFillUserData=true&disableWalletAddressForm=true`;
19672
+ }
19673
+ if (params.tokenAmount && params.tokenSymbol) widgetUrl += `&defaultCryptoAmount=${params.tokenAmount}&cryptoCurrencyCode=${params.tokenSymbol}`;
19674
+ else widgetUrl += "&defaultCryptoCurrency=IMX";
19675
+ if (params.walletAddress) widgetUrl += `&walletAddress=${params.walletAddress}`;
19676
+ return widgetUrl;
19677
+ }
19678
+ }
19679
+
19680
+
19681
+
19682
+
19617
19683
  const $a8cb37a3fc8eb863$var$SANDBOX_CONFIGURATION = {
19618
19684
  baseConfig: {
19619
19685
  environment: (Environment$1).SANDBOX
@@ -19621,12 +19687,14 @@ const $a8cb37a3fc8eb863$var$SANDBOX_CONFIGURATION = {
19621
19687
  };
19622
19688
  class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
19623
19689
  config;
19690
+ fiatRampService;
19624
19691
  readOnlyProviders;
19625
19692
  /**
19626
19693
  * Constructs a new instance of the CheckoutModule class.
19627
19694
  * @param {CheckoutModuleConfiguration} [config=SANDBOX_CONFIGURATION] - The configuration object for the CheckoutModule.
19628
19695
  */ constructor(config = $a8cb37a3fc8eb863$var$SANDBOX_CONFIGURATION){
19629
19696
  this.config = new ($4013c5c91bb535f6$export$4823433c4a67bbc6)(config);
19697
+ this.fiatRampService = new ($a77d203f701a3b72$export$1453e9b801542ef4)(this.config);
19630
19698
  this.readOnlyProviders = new Map();
19631
19699
  }
19632
19700
  /**
@@ -19787,6 +19855,43 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
19787
19855
  this.readOnlyProviders = await ($0e0060cb42e136d2$export$339cb2be73677b30)(this.config, this.readOnlyProviders);
19788
19856
  return await $2e7bf45a7c9a9570$export$942c8de7174809fc(params, this.readOnlyProviders, this.config);
19789
19857
  }
19858
+ /**
19859
+ * Creates and returns a URL for the fiat ramp widget.
19860
+ * @param {FiatRampParams} params - The parameters for creating the url.
19861
+ * @returns {Promise<string>} - A promise that resolves to a string url.
19862
+ */ async createFiatRampUrl(params) {
19863
+ let tokenAmount;
19864
+ let tokenSymbol = "IMX";
19865
+ let email;
19866
+ const walletAddress = await params.web3Provider.getSigner().getAddress();
19867
+ const isPassport = params.web3Provider.provider?.isPassport || false;
19868
+ if (isPassport && params.passport) {
19869
+ const userInfo = await params.passport.getUserInfo();
19870
+ email = userInfo?.email;
19871
+ }
19872
+ const tokenList = await $efe60cea83bfc4e8$export$473cec51305fdae8(this.config, {
19873
+ type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ONRAMP
19874
+ });
19875
+ const token = tokenList.tokens.find((t)=>t.address?.toLowerCase() === params.tokenAddress?.toLowerCase());
19876
+ if (token) {
19877
+ tokenAmount = params.tokenAmount;
19878
+ tokenSymbol = token.symbol;
19879
+ }
19880
+ return await this.fiatRampService.createWidgetUrl({
19881
+ exchangeType: params.exchangeType,
19882
+ isPassport: isPassport,
19883
+ walletAddress: walletAddress,
19884
+ tokenAmount: tokenAmount,
19885
+ tokenSymbol: tokenSymbol,
19886
+ email: email
19887
+ });
19888
+ }
19889
+ /**
19890
+ * Fetches fiat ramp fee estimations.
19891
+ * @returns {Promise<OnRampProviderFees>} - A promise that resolves to OnRampProviderFees.
19892
+ */ async getExchangeFeeEstimate() {
19893
+ return await this.fiatRampService.feeEstimate();
19894
+ }
19790
19895
  }
19791
19896
 
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 };
19897
+ 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 };