@imtbl/sdk 0.1.9-alpha → 0.1.9-alpha.2

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.
@@ -1,4 +1,6 @@
1
1
  /// <reference types="node" />
2
+ import { ExchangeContracts } from 'config';
3
+
2
4
  declare type Bytes = ArrayLike<number>;
3
5
  declare type BytesLike = Bytes | string;
4
6
  interface Hexable {
@@ -572,6 +574,20 @@ type Address = string;
572
574
  */
573
575
  type FungibleToken = Address | 'NATIVE';
574
576
 
577
+ type TokenInfo$1 = {
578
+ chainId: number;
579
+ address: string;
580
+ decimals: number;
581
+ symbol?: string;
582
+ name?: string;
583
+ };
584
+ interface ExchangeOverrides {
585
+ rpcURL: string;
586
+ exchangeContracts: ExchangeContracts;
587
+ commonRoutingTokens: TokenInfo$1[];
588
+ nativeToken: TokenInfo$1;
589
+ }
590
+
575
591
  /**
576
592
  * Enum representing the supported chains with their corresponding IDs.
577
593
  */
@@ -651,12 +667,6 @@ interface NetworkInfo {
651
667
  nativeCurrency: TokenInfo;
652
668
  isSupported: boolean;
653
669
  }
654
- /**
655
- * Enum representing the list of default supported providers.
656
- */
657
- declare enum ConnectionProviders {
658
- METAMASK = "metamask"
659
- }
660
670
  interface ConnectParams {
661
671
  provider: Web3Provider;
662
672
  }
@@ -741,6 +751,10 @@ interface TokenAmountEstimate {
741
751
  estimatedAmount?: BigNumber;
742
752
  token?: TokenInfo;
743
753
  }
754
+ declare const CHECKOUT_API_BASE_URL: {
755
+ sandbox: string;
756
+ production: string;
757
+ };
744
758
  /**
745
759
  * Object mapping the list of supported networks with the corresponding RPC urls.
746
760
  */
@@ -885,10 +899,10 @@ type CreateProviderResult = {
885
899
  };
886
900
  /**
887
901
  * Interface representing a wallet filter to be used in {@link GetWalletAllowListParams}.
888
- * @property {ConnectionProviders} connectionProvider - The connection provider to filter wallets by.
902
+ * @property {WalletProviderName} connectionProvider - The connection provider to filter wallets by.
889
903
  */
890
904
  interface WalletFilter {
891
- providerName: WalletProviderName;
905
+ walletProvider: WalletProviderName;
892
906
  }
893
907
  /**
894
908
  * Interface representing the parameters for {@link Checkout.getWalletAllowList}.
@@ -901,13 +915,13 @@ interface GetWalletAllowListParams {
901
915
  }
902
916
  /**
903
917
  * Interface representing information about a wallet used in {@link GetWalletAllowListResult}.
904
- * @property {ConnectionProviders} connectionProvider - The connection provider for the wallet.
918
+ * @property {WalletProviderName} connectionProvider - The connection provider for the wallet.
905
919
  * @property {string} name - The name of the wallet.
906
920
  * @property {string} description - A description of the wallet.
907
921
  * @property {string} icon - The URL/data:image of an icon for the wallet.
908
922
  */
909
923
  interface WalletInfo {
910
- providerName: WalletProviderName;
924
+ walletProvider: WalletProviderName;
911
925
  name: string;
912
926
  description: string;
913
927
  icon: string;
@@ -959,9 +973,42 @@ type ErrorType = {
959
973
  [key: string]: string;
960
974
  };
961
975
  };
976
+ type AllowedNetworkConfig = {
977
+ chainId: number;
978
+ };
979
+ type GasEstimateBridgeToL2TokenConfig = {
980
+ gasTokenAddress: string | 'NATIVE';
981
+ fromAddress: string;
982
+ };
983
+ type GasEstimateSwapTokenConfig = {
984
+ inAddress: string;
985
+ outAddress: string;
986
+ };
987
+ type GasEstimateTokenConfig = {
988
+ [key: string]: {
989
+ bridgeToL2Addresses?: GasEstimateBridgeToL2TokenConfig;
990
+ swapAddresses?: GasEstimateSwapTokenConfig;
991
+ };
992
+ };
993
+ type DexConfig = {
994
+ overrides?: ExchangeOverrides;
995
+ };
996
+ type RemoteConfiguration = {
997
+ dex: DexConfig;
998
+ allowedNetworks: AllowedNetworkConfig[];
999
+ gasEstimateTokens?: GasEstimateTokenConfig;
1000
+ };
1001
+ type RemoteConfigParams = {
1002
+ environment: Environment;
1003
+ };
1004
+ declare class RemoteConfigFetcher {
1005
+ constructor(params: RemoteConfigParams);
1006
+ get(key?: keyof RemoteConfiguration): Promise<RemoteConfiguration | RemoteConfiguration[keyof RemoteConfiguration] | undefined>;
1007
+ }
962
1008
  declare class CheckoutConfiguration {
963
1009
  readonly environment: Environment;
964
1010
  readonly networkMap: NetworkMap;
1011
+ readonly remoteConfigFetcher: RemoteConfigFetcher;
965
1012
  constructor(config: CheckoutModuleConfiguration);
966
1013
  }
967
1014
  declare class Checkout {
@@ -1059,4 +1106,4 @@ declare class Checkout {
1059
1106
  gasEstimate(params: GasEstimateParams): Promise<GasEstimateSwapResult | GasEstimateBridgeToL2Result>;
1060
1107
  }
1061
1108
 
1062
- export { ChainId, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, ConnectParams, ConnectResult, ConnectionProviders, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, NetworkFilter, NetworkFilterTypes, NetworkInfo, RPC_URL_MAP, SendTransactionParams, SendTransactionResult, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, WalletFilter, WalletFilterTypes, WalletInfo, WalletProviderName };
1109
+ export { CHECKOUT_API_BASE_URL, ChainId, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutErrorType, CheckoutModuleConfiguration, ConnectParams, ConnectResult, ErrorType, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, NetworkFilter, NetworkFilterTypes, NetworkInfo, RPC_URL_MAP, SendTransactionParams, SendTransactionResult, SwitchNetworkParams, SwitchNetworkResult, TokenFilter, TokenFilterTypes, TokenInfo, WalletFilter, WalletFilterTypes, WalletInfo, WalletProviderName };
@@ -4,6 +4,7 @@ import $7v2Z6$metamaskdetectprovider from '@metamask/detect-provider';
4
4
  import { BigNumber, utils as utils$1 } from 'ethers/lib/ethers';
5
5
  import { BridgeConfiguration, ETH_MAINNET_TO_ZKEVM_MAINNET, ETH_SEPOLIA_TO_ZKEVM_DEVNET, TokenBridge } from '@imtbl/bridge-sdk';
6
6
  import { Exchange, ExchangeConfiguration } from '@imtbl/dex-sdk';
7
+ import $7v2Z6$axios from 'axios';
7
8
 
8
9
  var Environment;
9
10
  (function (Environment) {
@@ -103,10 +104,6 @@ const $bc2bfebf768286d3$export$6a2ba3c3bd042990 = {
103
104
  };
104
105
 
105
106
 
106
- var $d176a05e966364ba$export$3bfad4d03ada24c4;
107
- (function(ConnectionProviders) {
108
- ConnectionProviders["METAMASK"] = "metamask";
109
- })($d176a05e966364ba$export$3bfad4d03ada24c4 || ($d176a05e966364ba$export$3bfad4d03ada24c4 = {}));
110
107
 
111
108
 
112
109
  var $de275b98d2b651c3$export$788b1fd17f3dad84;
@@ -117,10 +114,23 @@ var $de275b98d2b651c3$export$788b1fd17f3dad84;
117
114
 
118
115
 
119
116
 
117
+
118
+
119
+
120
+ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
121
+ [(Environment).SANDBOX]: "https://checkout-api.dev.immutable.com",
122
+ [(Environment).PRODUCTION]: "https://checkout-api.sandbox.immutable.com"
123
+ };
124
+ const $d85ad1457a3f1a83$export$720c0def10d6df2d = {
125
+ [($baec09ddc3013323$export$c06e1e7429de6283).ETHEREUM]: "/v1/rpc/eth-mainnet",
126
+ [($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA]: "/v1/rpc/eth-sepolia"
127
+ };
128
+
129
+
120
130
  const $a47e48dd2c04791b$export$345c852d0dc8f1df = new Map([
121
131
  [
122
132
  ($baec09ddc3013323$export$c06e1e7429de6283).ETHEREUM,
123
- "https://checkout-api.dev.immutable.com/v1/rpc/eth-mainnet"
133
+ `${($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment).PRODUCTION]}${($d85ad1457a3f1a83$export$720c0def10d6df2d)[($baec09ddc3013323$export$c06e1e7429de6283).ETHEREUM]}`
124
134
  ],
125
135
  [
126
136
  ($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET,
@@ -128,7 +138,7 @@ const $a47e48dd2c04791b$export$345c852d0dc8f1df = new Map([
128
138
  ],
129
139
  [
130
140
  ($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA,
131
- "https://checkout-api.dev.immutable.com/v1/rpc/eth-sepolia"
141
+ `${($d85ad1457a3f1a83$export$161d4a74df65fc08)[(Environment).PRODUCTION]}${($d85ad1457a3f1a83$export$720c0def10d6df2d)[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA]}`
132
142
  ],
133
143
  [
134
144
  ($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET,
@@ -260,6 +270,7 @@ const $e768639828688ca3$export$44dde05038008549 = {
260
270
 
261
271
 
262
272
 
273
+
263
274
  /**
264
275
  * The different types of errors that can be returned by the checkout process.
265
276
  */ var $a8bc256d81a5e2c1$export$e3dc0620abde7f5a;
@@ -319,10 +330,6 @@ const $a8bc256d81a5e2c1$export$bacc563de539c6c3 = async (fn, customError)=>{
319
330
  /* eslint-disable @typescript-eslint/no-explicit-any */
320
331
 
321
332
 
322
- var $497c134ecbc8a50f$exports = {};
323
- $497c134ecbc8a50f$exports = JSON.parse('[{"chainId":1},{"chainId":11155111},{"chainId":13372},{"chainId":13383}]');
324
-
325
-
326
333
  // this function needs to be in a separate file to prevent circular dependencies with ./network
327
334
 
328
335
 
@@ -372,7 +379,8 @@ async function $de192de6ef100f9f$var$addNetworkToWallet(networkMap, web3Provider
372
379
  }
373
380
  async function $de192de6ef100f9f$export$3043f6442a9ef563(config, { type: type = ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL , exclude: exclude }) {
374
381
  const { networkMap: networkMap } = config;
375
- const list = ((/*@__PURE__*/$parcel$interopDefault($497c134ecbc8a50f$exports))).filter((network)=>{
382
+ const allowedNetworkConfig = await config.remoteConfigFetcher.get("allowedNetworks");
383
+ const list = allowedNetworkConfig.filter((network)=>{
376
384
  const allowAllTokens = type === ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL;
377
385
  const networkNotExcluded = !(exclude || []).map((exc)=>exc.chainId).includes(network.chainId);
378
386
  return allowAllTokens && networkNotExcluded;
@@ -650,13 +658,13 @@ async function $bb88265fe45a0393$export$9e1fd9cc88c637a0(config, web3Provider, v
650
658
 
651
659
 
652
660
  var $6f3c55a615003cbf$exports = {};
653
- $6f3c55a615003cbf$exports = JSON.parse('[{"providerName":"metamask","icon":"some-icon-url","name":"MetaMask","description":"complete web3 wallet solution","platform":["desktop"]},{"providerName":"passport","icon":"pp-icon","name":"Passport","description":"Web3 with your email!","platform":["mobile","desktop"]},{"providerName":"gamestop","icon":"gme-icon","name":"GameStop","description":"Never stopping the game!","platform":["mobile"]}]');
661
+ $6f3c55a615003cbf$exports = JSON.parse('[{"walletProvider":"metamask","icon":"some-icon-url","name":"MetaMask","description":"complete web3 wallet solution","platform":["desktop"]},{"walletProvider":"passport","icon":"pp-icon","name":"Passport","description":"Web3 with your email!","platform":["mobile","desktop"]},{"walletProvider":"gamestop","icon":"gme-icon","name":"GameStop","description":"Never stopping the game!","platform":["mobile"]}]');
654
662
 
655
663
 
656
664
  async function $5cdde2ffe6360fec$export$a822caa90d7eef09({ type: type = ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL , exclude: exclude }) {
657
665
  // todo:For async API call, use the CheckoutError with errorType:API_CALL_ERROR?? or any other
658
666
  const filteredWalletsList = ((/*@__PURE__*/$parcel$interopDefault($6f3c55a615003cbf$exports))).filter((wallet)=>{
659
- const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.providerName).includes(wallet.providerName);
667
+ const walletNotExcluded = !exclude?.map((excludeWallet)=>excludeWallet.walletProvider).includes(wallet.walletProvider);
660
668
  const allowAllWallets = type === ($4f91c5f280efe242$export$a75605c67ea83a5a).ALL;
661
669
  const walletsAllowedForType = wallet.platform.includes(type);
662
670
  return walletNotExcluded && (allowAllWallets || walletsAllowedForType);
@@ -749,53 +757,6 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
749
757
 
750
758
 
751
759
 
752
- const $be6f32539b5e2cc9$var$chainId = 13383;
753
- const $be6f32539b5e2cc9$var$commonRoutingTokens = [
754
- {
755
- chainId: $be6f32539b5e2cc9$var$chainId,
756
- address: "0xFEa9FF93DC0C6DC73F8Be009Fe7a22Bb9dcE8A2d",
757
- decimals: 18,
758
- symbol: "FUN",
759
- name: "The Fungibles Token"
760
- },
761
- {
762
- chainId: $be6f32539b5e2cc9$var$chainId,
763
- address: "0x12739A8f1A8035F439092D016DAE19A2874F30d2",
764
- decimals: 18,
765
- symbol: "USDC",
766
- name: "US Dollar Coin"
767
- },
768
- {
769
- chainId: $be6f32539b5e2cc9$var$chainId,
770
- address: "0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e",
771
- decimals: 18,
772
- symbol: "DEX",
773
- name: "Dex"
774
- }
775
- ];
776
- const $be6f32539b5e2cc9$var$contractOverrides = {
777
- multicall: "0x7b19942581c9462D54155801fCA4a17edf3fD135",
778
- coreFactory: "0xD17c98b38bA28c7eA1080317EB9AB2b9663BEd92",
779
- quoterV2: "0x786ec643F231960D4C1A4E336990F8E7bF8f1277",
780
- peripheryRouter: "0x0d44bB14Cc1dD999255aBB1576b4964D0439C63D",
781
- migrator: "0x0Afe6F5f4DC34461A801420634239FFaD50A2e44",
782
- nonfungiblePositionManager: "0xF674847fBcca5C80315e3AE37043Dce99F6CC529",
783
- tickLens: "0x38034F18D38b74bdE496bdF60CCdBcb25B879e8d"
784
- };
785
- const $be6f32539b5e2cc9$export$3e9a43ac784794d5 = ()=>({
786
- rpcURL: "https://zkevm-rpc.dev.x.immutable.com",
787
- exchangeContracts: $be6f32539b5e2cc9$var$contractOverrides,
788
- commonRoutingTokens: $be6f32539b5e2cc9$var$commonRoutingTokens,
789
- nativeToken: {
790
- chainId: $be6f32539b5e2cc9$var$chainId,
791
- address: "",
792
- decimals: 18,
793
- symbol: "IMX",
794
- name: "Immutable X Token"
795
- }
796
- });
797
-
798
-
799
760
  async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, environment) {
800
761
  const rootChainProvider = readOnlyProviders.get(fromChainId);
801
762
  const childChainProvider = readOnlyProviders.get(toChainId);
@@ -811,24 +772,20 @@ async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId,
811
772
  });
812
773
  return new (TokenBridge)(bridgeConfig);
813
774
  }
814
- async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, environment) {
815
- const exchange = new (Exchange)(new (ExchangeConfiguration)({
775
+ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
776
+ const dexConfig = await config.remoteConfigFetcher.get("dex");
777
+ return new (Exchange)(new (ExchangeConfiguration)({
816
778
  chainId: chainId,
817
779
  baseConfig: new (ImmutableConfiguration)({
818
- environment: environment
780
+ environment: config.environment
819
781
  }),
820
- overrides: ($be6f32539b5e2cc9$export$3e9a43ac784794d5)()
782
+ overrides: dexConfig?.overrides
821
783
  }));
822
- return exchange;
823
784
  }
824
785
 
825
786
 
826
787
 
827
788
 
828
- var $d7b15ec974df6f92$exports = {};
829
- $d7b15ec974df6f92$exports = JSON.parse('{"11155111":{"bridgeToL2Addresses":{"gasTokenAddress":"NATIVE","fromAddress":"0xd1da7e9b2Ce1a4024DaD52b3D37F4c5c91a525C1"},"swapAddresses":{"inAddress":"0xFEa9FF93DC0C6DC73F8Be009Fe7a22Bb9dcE8A2d","outAddress":"0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e"}}}');
830
-
831
-
832
789
  const $2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS = "0x0000000000000000000000000000000000000000";
833
790
  const $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS = 18;
834
791
  const $2e7bf45a7c9a9570$var$getL1ChainId = (environment)=>{
@@ -839,15 +796,15 @@ const $2e7bf45a7c9a9570$var$getL2ChainId = (environment)=>{
839
796
  if (environment === (Environment).PRODUCTION) return ($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET;
840
797
  return ($baec09ddc3013323$export$c06e1e7429de6283).IMTBL_ZKEVM_DEVNET;
841
798
  };
842
- async function $2e7bf45a7c9a9570$var$bridgeToL2GasEstimator(readOnlyProviders, environment, isSpendingCapApprovalRequired, tokenAddress) {
843
- const fromChainId = $2e7bf45a7c9a9570$var$getL1ChainId(environment);
844
- const toChainId = $2e7bf45a7c9a9570$var$getL2ChainId(environment);
845
- const tokenAddresses = environment === (Environment).PRODUCTION ? ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA] : ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA];
846
- const { gasTokenAddress: gasTokenAddress , fromAddress: fromAddress } = tokenAddresses.bridgeToL2Addresses;
799
+ async function $2e7bf45a7c9a9570$var$bridgeToL2GasEstimator(readOnlyProviders, config, isSpendingCapApprovalRequired, tokenAddress) {
800
+ const fromChainId = $2e7bf45a7c9a9570$var$getL1ChainId(config.environment);
801
+ const toChainId = $2e7bf45a7c9a9570$var$getL2ChainId(config.environment);
802
+ const gasEstimateTokensConfig = await config.remoteConfigFetcher.get("gasEstimateTokens");
803
+ const { gasTokenAddress: gasTokenAddress , fromAddress: fromAddress } = gasEstimateTokensConfig[fromChainId.toString()].bridgeToL2Addresses;
847
804
  const provider = readOnlyProviders.get(fromChainId);
848
805
  try {
849
806
  const { estimatedAmount: estimatedAmount , token: token } = await (0, $570856c68db0bd36$export$51010590edbe56a6)(provider, fromChainId, isSpendingCapApprovalRequired, tokenAddress ?? gasTokenAddress);
850
- const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, environment);
807
+ const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config.environment);
851
808
  const { bridgeFee: bridgeFee , bridgeable: bridgeable } = await (0, $570856c68db0bd36$export$9e73e22953cebcfc)(tokenBridge, fromAddress, toChainId);
852
809
  return {
853
810
  gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
@@ -871,12 +828,12 @@ async function $2e7bf45a7c9a9570$var$bridgeToL2GasEstimator(readOnlyProviders, e
871
828
  };
872
829
  }
873
830
  }
874
- async function $2e7bf45a7c9a9570$var$swapGasEstimator(environment) {
875
- const tokenAddresses = environment === (Environment).PRODUCTION ? ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA] : ((/*@__PURE__*/$parcel$interopDefault($d7b15ec974df6f92$exports)))[($baec09ddc3013323$export$c06e1e7429de6283).SEPOLIA];
876
- const { inAddress: inAddress , outAddress: outAddress } = tokenAddresses.swapAddresses;
877
- const chainId = $2e7bf45a7c9a9570$var$getL2ChainId(environment);
831
+ async function $2e7bf45a7c9a9570$var$swapGasEstimator(config) {
832
+ const chainId = $2e7bf45a7c9a9570$var$getL2ChainId(config.environment);
833
+ const gasEstimateTokensConfig = await config.remoteConfigFetcher.get("gasEstimateTokens");
834
+ const { inAddress: inAddress , outAddress: outAddress } = gasEstimateTokensConfig[chainId].swapAddresses;
878
835
  try {
879
- const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, environment);
836
+ const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, config);
880
837
  // Create a fake transaction to get the gas from the quote
881
838
  const { info: info } = await exchange.getUnsignedSwapTxFromAmountIn($2e7bf45a7c9a9570$var$DUMMY_WALLET_ADDRESS, inAddress, outAddress, (0, BigNumber).from((0, utils$1).parseUnits("1", $2e7bf45a7c9a9570$var$DEFAULT_TOKEN_DECIMALS)));
882
839
  if (info.gasFeeEstimate === null) return {
@@ -905,12 +862,12 @@ async function $2e7bf45a7c9a9570$var$swapGasEstimator(environment) {
905
862
  };
906
863
  }
907
864
  }
908
- async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProviders, environment) {
865
+ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProviders, config) {
909
866
  switch(params.gasEstimateType){
910
867
  case ($de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2:
911
- return await $2e7bf45a7c9a9570$var$bridgeToL2GasEstimator(readOnlyProviders, environment, params.isSpendingCapApprovalRequired, params.tokenAddress);
868
+ return await $2e7bf45a7c9a9570$var$bridgeToL2GasEstimator(readOnlyProviders, config, params.isSpendingCapApprovalRequired, params.tokenAddress);
912
869
  case ($de275b98d2b651c3$export$788b1fd17f3dad84).SWAP:
913
- return await $2e7bf45a7c9a9570$var$swapGasEstimator(environment);
870
+ return await $2e7bf45a7c9a9570$var$swapGasEstimator(config);
914
871
  default:
915
872
  throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Invalid type provided for gasEstimateType", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).INVALID_GAS_ESTIMATE_TYPE);
916
873
  }
@@ -923,7 +880,35 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
923
880
 
924
881
 
925
882
 
926
- class $4013c5c91bb535f6$export$47a4ed4a38b9eecf extends Error {
883
+
884
+
885
+ class $a492ee374ae7b613$export$d902b56530cd5f87 {
886
+ cache;
887
+ environment;
888
+ constructor(params){
889
+ this.environment = params.environment;
890
+ }
891
+ async load() {
892
+ if (this.cache) return this.cache;
893
+ let response;
894
+ try {
895
+ response = await (0, $7v2Z6$axios).get(`${(0, $d85ad1457a3f1a83$export$161d4a74df65fc08)[this.environment]}/v1/config`);
896
+ } catch (error) {
897
+ throw new Error(`Error fetching config: ${error.message}`);
898
+ }
899
+ if (response.status !== 200) throw new Error(`Error fetching config: ${response.status} ${response.statusText}`);
900
+ this.cache = response.data;
901
+ return this.cache;
902
+ }
903
+ async get(key) {
904
+ const config = await this.load();
905
+ if (config && key) return config[key];
906
+ return config;
907
+ }
908
+ }
909
+
910
+
911
+ class $4013c5c91bb535f6$export$6ad73ea7e1b6f37f extends Error {
927
912
  message;
928
913
  constructor(message){
929
914
  super(message);
@@ -933,11 +918,15 @@ class $4013c5c91bb535f6$export$47a4ed4a38b9eecf extends Error {
933
918
  class $4013c5c91bb535f6$export$4823433c4a67bbc6 {
934
919
  environment;
935
920
  networkMap;
921
+ remoteConfigFetcher;
936
922
  constructor(config){
937
923
  // validate input
938
- if (!Object.values((Environment)).includes(config.baseConfig.environment)) throw new $4013c5c91bb535f6$export$47a4ed4a38b9eecf("Invalid checkout configuration of environment");
924
+ if (!Object.values((Environment)).includes(config.baseConfig.environment)) throw new $4013c5c91bb535f6$export$6ad73ea7e1b6f37f("Invalid checkout configuration of environment");
939
925
  this.environment = config.baseConfig.environment;
940
926
  this.networkMap = config.baseConfig.environment === (Environment).PRODUCTION ? ($a47e48dd2c04791b$export$6f24f3cef7d501c4) : ($a47e48dd2c04791b$export$3e81fc0987227f10);
927
+ this.remoteConfigFetcher = new ($a492ee374ae7b613$export$d902b56530cd5f87)({
928
+ environment: config.baseConfig.environment
929
+ });
941
930
  }
942
931
  }
943
932
 
@@ -1100,8 +1089,8 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
1100
1089
  * @returns The gas estimate for the given action.
1101
1090
  */ async gasEstimate(params) {
1102
1091
  this.readOnlyProviders = await ($0e0060cb42e136d2$export$339cb2be73677b30)(this.config, this.readOnlyProviders);
1103
- return await $2e7bf45a7c9a9570$export$942c8de7174809fc(params, this.readOnlyProviders, this.config.environment);
1092
+ return await $2e7bf45a7c9a9570$export$942c8de7174809fc(params, this.readOnlyProviders, this.config);
1104
1093
  }
1105
1094
  }
1106
1095
 
1107
- export { $baec09ddc3013323$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $d176a05e966364ba$export$3bfad4d03ada24c4 as ConnectionProviders, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $a47e48dd2c04791b$export$345c852d0dc8f1df as RPC_URL_MAP, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName };
1096
+ export { $d85ad1457a3f1a83$export$161d4a74df65fc08 as CHECKOUT_API_BASE_URL, $baec09ddc3013323$export$c06e1e7429de6283 as ChainId, $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 as Checkout, $a8bc256d81a5e2c1$export$e3dc0620abde7f5a as CheckoutErrorType, $de275b98d2b651c3$export$788b1fd17f3dad84 as GasEstimateType, $a47e48dd2c04791b$export$1f05a55fe0680cc7 as NetworkFilterTypes, $a47e48dd2c04791b$export$345c852d0dc8f1df as RPC_URL_MAP, $08d5ddc39acd6833$export$fd9b17d87f4121d2 as TokenFilterTypes, $4f91c5f280efe242$export$a75605c67ea83a5a as WalletFilterTypes, $e768639828688ca3$export$2d7a51a18d87e21d as WalletProviderName };
@@ -15026,11 +15026,11 @@ declare enum ConnectEventType {
15026
15026
  }
15027
15027
  /**
15028
15028
  * Type representing a Connect Widget event with type SUCCESS.
15029
- * @property {ConnectionProviders} providerPreference - The user's preferred connection provider.
15029
+ * @property {WalletProviderName} walletProvider - The user's preferred connection provider.
15030
15030
  */
15031
15031
  type ConnectionSuccess = {
15032
15032
  provider: Web3Provider;
15033
- providerName: WalletProviderName | undefined;
15033
+ walletProvider: WalletProviderName | undefined;
15034
15034
  };
15035
15035
  /**
15036
15036
  * Type representing a Connect Widget event with type FAILURE.
@@ -15047,10 +15047,10 @@ declare enum OrchestrationEventType {
15047
15047
  REQUEST_ONRAMP = "request-onramp"
15048
15048
  }
15049
15049
  type RequestConnectEvent = {
15050
- providerPreference: string;
15050
+ walletProvider: string;
15051
15051
  };
15052
15052
  type RequestWalletEvent = {
15053
- providerPreference: string;
15053
+ walletProvider: string;
15054
15054
  };
15055
15055
  type RequestSwapEvent = {
15056
15056
  fromTokenAddress: string;
@@ -15155,17 +15155,15 @@ declare global {
15155
15155
  }
15156
15156
  /**
15157
15157
  * Props for the Connect Widget component
15158
- * @property {string} providerPreference - The preferred wallet provider to connect to.
15159
15158
  * @property {string} theme - The theme to use.
15160
15159
  * @property {string} environment - The environment configuration
15161
15160
  */
15162
15161
  interface ImtblConnectProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
15163
- walletProvider?: string;
15164
15162
  widgetConfig?: string;
15165
15163
  }
15166
15164
  /**
15167
15165
  * Props for the Wallet Widget component
15168
- * @property {string} providerPreference - The preferred wallet provider to connect to.
15166
+ * @property {string} walletProvider - The preferred wallet provider to connect to.
15169
15167
  * @property {string} theme - The theme to use.
15170
15168
  * @property {string} environment - The environment configuration
15171
15169
  */
@@ -15175,7 +15173,7 @@ interface ImtblWalletProps extends React.DetailedHTMLProps<React.HTMLAttributes<
15175
15173
  }
15176
15174
  /**
15177
15175
  * Props for the Swap Widget component
15178
- * @property {string} providerPreference - The preferred wallet provider to connect to.
15176
+ * @property {string} walletProvider - The preferred wallet provider to connect to.
15179
15177
  * @property {string} theme - The theme to use.
15180
15178
  * @property {string} environment - The environment configuration
15181
15179
  * @property {string} amount - The amount to swap.
@@ -15191,18 +15189,16 @@ interface ImtblSwapProps extends React.DetailedHTMLProps<React.HTMLAttributes<HT
15191
15189
  }
15192
15190
  /**
15193
15191
  * Props for the Bridge Widget component
15194
- * @property {string} providerPreference - The preferred wallet provider to connect to.
15192
+ * @property {string} walletProvider - The preferred wallet provider to connect to.
15195
15193
  * @property {string} theme - The theme to use.
15196
15194
  * @property {string} environment - The environment configuration
15197
15195
  * @property {string} fromContractAddress - The contract address of the source token.
15198
- * @property {string} fromNetwork - The network of the source token.
15199
15196
  * @property {string} amount - The amount to bridge.
15200
15197
  */
15201
15198
  interface ImtblBridgeProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
15202
15199
  walletProvider?: string;
15203
15200
  widgetConfig?: string;
15204
15201
  fromContractAddress: string;
15205
- fromNetwork: string;
15206
15202
  amount: string;
15207
15203
  }
15208
15204
  /**
@@ -15212,9 +15208,7 @@ declare enum Network {
15212
15208
  ETHEREUM = "Ethereum",
15213
15209
  SEPOLIA = "Sepolia",
15214
15210
  IMTBL_ZKEVM_TESTNET = "Immutable zkEVM Testnet",
15215
- IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Devnet",
15216
- POLYGON_ZKEVM_TESTNET = "Polygon zkEVM Testnet",
15217
- POLYGON_ZKEVM = "Polygon zkEVM"
15211
+ IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Devnet"
15218
15212
  }
15219
15213
  /**
15220
15214
  * Enum representing the themes for the Checkout widgets.
@@ -15233,10 +15227,35 @@ declare enum CheckoutWidgetTagNames {
15233
15227
  SWAP = "imtbl-swap",
15234
15228
  BRIDGE = "imtbl-bridge"
15235
15229
  }
15230
+ /**
15231
+ * Represents the version of the Checkout Widgets to use defaults to (0.1.9-alpha)
15232
+ * @property {number} major - The major version of the widgets, must specify a major version even if it is 0, otherwise version defaults to (0.1.9-alpha)
15233
+ * @property {number} minor - The minor version of the widgets, leaving this blank will pickup all new minor versions released
15234
+ * @property {number} patch - The patch version of the widgets, leaving this blank will pickup all new patch versions released
15235
+ * @property {string} prerelease - The prerelease version of the widgets, can only be 'alpha' or 'beta', will be used in preference of build if it is also specified. Do not use in production.
15236
+ * @property {number} build - The build version of the widgets, this should not be used in production and will only be used for rare cases when a specific testing is required
15237
+ *
15238
+ * @example
15239
+ * { major: 0 } - use default version 0.1.9-alpha
15240
+ *
15241
+ * { major: 1 } - use version 1.x.x, pickup all new minor and patch versions released
15242
+ *
15243
+ * { major: 1, minor: 1 } - use version 1.1.x, pickup all new patch versions released
15244
+ *
15245
+ * { major: 1, minor: 2, patch: 3 } - use version 1.2.3 specifically
15246
+ */
15247
+ type SemanticVersion = {
15248
+ major: number;
15249
+ minor?: number;
15250
+ patch?: number;
15251
+ prerelease?: 'alpha' | 'beta';
15252
+ build?: number;
15253
+ };
15236
15254
  /**
15237
15255
  * Represents the configuration options for the Checkout Widgets.
15238
15256
  * @property {WidgetTheme} theme - The theme of the Checkout Widget (default: "DARK")
15239
15257
  * @property {Environment} environment - The environment configuration (default: "SANDBOX")
15258
+ * @property {SemanticVersion} version - The version of the checkout widgets js file to use (default: "0.1.0")
15240
15259
  * @property {boolean} isOnRampEnabled - Enable on-ramp top-up method (default: "true")
15241
15260
  * @property {boolean} isSwapEnabled - Enable swap top-up method (default: "true")
15242
15261
  * @property {boolean} isBridgeEnabled - Enable bridge top-up method (default: "true")
@@ -15244,6 +15263,7 @@ declare enum CheckoutWidgetTagNames {
15244
15263
  type CheckoutWidgetsConfig = {
15245
15264
  theme?: WidgetTheme;
15246
15265
  environment?: Environment;
15266
+ version?: SemanticVersion;
15247
15267
  isOnRampEnabled?: boolean;
15248
15268
  isSwapEnabled?: boolean;
15249
15269
  isBridgeEnabled?: boolean;
@@ -15254,13 +15274,12 @@ type CheckoutWidgetsConfig = {
15254
15274
  * (default: "metamask").
15255
15275
  * @property {string} fromContractAddress - The contract address to send tokens from.
15256
15276
  * @property {string} amount - The amount of tokens to send.
15257
- * @property {Network} fromNetwork - The network to send tokens from.
15258
15277
  */
15259
15278
  interface BridgeReactProps {
15260
15279
  walletProvider?: WalletProviderName;
15280
+ provider?: Web3Provider;
15261
15281
  fromContractAddress?: string;
15262
15282
  amount?: string;
15263
- fromNetwork?: Network;
15264
15283
  }
15265
15284
  /**
15266
15285
  * A React functional component that renders the Checkout Bridge Widget.
@@ -15268,20 +15287,11 @@ interface BridgeReactProps {
15268
15287
  * @returns {JSX.Element} - The rendered Bridge Widget component.
15269
15288
  */
15270
15289
  declare function BridgeReact(props: BridgeReactProps): JSX.Element;
15271
- /**
15272
- * Interface representing the props for the Connect Widget component.
15273
- * @property {string} providerPreference - The preferred provider for the Connect Widget
15274
- * (default: "metamask").
15275
- */
15276
- interface ConnectReactProps {
15277
- walletProvider?: string;
15278
- }
15279
15290
  /**
15280
15291
  * A React functional component that renders the Checkout Connect Widget.
15281
- * @param {ConnectReactProps} props - The props for the Connect Widget component.
15282
15292
  * @returns {JSX.Element} - The rendered Connect Widget component.
15283
15293
  */
15284
- declare function ConnectReact(props: ConnectReactProps): JSX.Element;
15294
+ declare function ConnectReact(): JSX.Element;
15285
15295
  /**
15286
15296
  * Interface representing the props for the Swap Widget component.
15287
15297
  * @property {string} walletProvider - The preferred provider for the Swap Widget (default: "metamask"}).
@@ -15291,6 +15301,7 @@ declare function ConnectReact(props: ConnectReactProps): JSX.Element;
15291
15301
  */
15292
15302
  interface SwapReactProps {
15293
15303
  walletProvider?: WalletProviderName;
15304
+ provider?: Web3Provider;
15294
15305
  fromContractAddress?: string;
15295
15306
  amount?: string;
15296
15307
  toContractAddress?: string;
@@ -15303,11 +15314,12 @@ interface SwapReactProps {
15303
15314
  declare function SwapReact(props: SwapReactProps): JSX.Element;
15304
15315
  /**
15305
15316
  * Interface representing the props for the Wallet Widget component.
15306
- * @property {string} providerPreference - The preferred provider for the Wallet Widget
15317
+ * @property {string} walletProvider - The preferred provider for the Wallet Widget
15307
15318
  * (default: "metamask").
15308
15319
  */
15309
15320
  interface WalletReactProps {
15310
15321
  walletProvider?: WalletProviderName;
15322
+ provider?: Web3Provider;
15311
15323
  }
15312
15324
  /**
15313
15325
  * A React functional component that renders the Checkout Wallet Widget.
@@ -15315,6 +15327,15 @@ interface WalletReactProps {
15315
15327
  * @returns {JSX.Element} - The rendered Wallet Widget component.
15316
15328
  */
15317
15329
  declare function WalletReact(props: WalletReactProps): JSX$1.Element;
15330
+ declare const DEFAULT_CHECKOUT_VERSION = "0.1.9-alpha";
15331
+ /**
15332
+ * Checking for valid version numbers input.
15333
+ * 0 is a valid value for major, minor and/or patch
15334
+ * The current release process only includes the checkout script in 'alpha' builds
15335
+ * so we must append '-alpha' to valid versions in order to load the script properly.
15336
+ * This may change in the future depending on the relase process.
15337
+ */
15338
+ declare function validateAndBuildVersion(version: SemanticVersion | undefined): string;
15318
15339
  /**
15319
15340
  * CheckoutWidgets allows to inject the Checkout Widgets into your application.
15320
15341
  * @param {CheckoutWidgetsConfig|undefined} config - Checkout Widget global configurations.
@@ -15325,11 +15346,5 @@ declare function CheckoutWidgets(config?: CheckoutWidgetsConfig): void;
15325
15346
  * @param {CheckoutWidgetsConfig} config - new Checkout Widget global configurations.
15326
15347
  */
15327
15348
  declare function UpdateConfig(config: CheckoutWidgetsConfig): void;
15328
- /**
15329
- * SetProvider allows to set the provider for an existing Checkout Widgets instance.
15330
- * @param {CheckoutWidgetTagNames} tagName - target Checkout Widget widget.
15331
- * @param {Web3Provider} provider - the provider to connect to the blockchain network.
15332
- */
15333
- declare function SetProvider(tagName: CheckoutWidgetTagNames, provider: Web3Provider | null): void;
15334
15349
 
15335
- export { BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectReact, ConnectReactProps, ConnectionFailed, ConnectionSuccess, IMTBLWidgetEvents, ImtblBridgeProps, ImtblConnectProps, ImtblSwapProps, ImtblWalletProps, Network, OrchestrationEventType, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, SetProvider, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, UpdateConfig, WalletDisconnectWalletEvent, WalletEventType, WalletNetworkSwitchEvent, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme };
15350
+ export { BridgeEventType, BridgeFailed, BridgeReact, BridgeReactProps, BridgeSuccess, CheckoutWidgetTagNames, CheckoutWidgets, CheckoutWidgetsConfig, ConnectEventType, ConnectReact, ConnectionFailed, ConnectionSuccess, DEFAULT_CHECKOUT_VERSION, IMTBLWidgetEvents, ImtblBridgeProps, ImtblConnectProps, ImtblSwapProps, ImtblWalletProps, Network, OrchestrationEventType, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, SemanticVersion, SwapEventType, SwapFailed, SwapReact, SwapReactProps, SwapRejected, SwapSuccess, UpdateConfig, WalletDisconnectWalletEvent, WalletEventType, WalletNetworkSwitchEvent, WalletReact, WalletReactProps, WidgetEvent, WidgetTheme, validateAndBuildVersion };