@imtbl/sdk 0.44.4 → 0.45.1

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.
@@ -10131,7 +10131,7 @@ interface ImxOverrides {
10131
10131
  interface ImxModuleConfiguration extends ModuleConfiguration<ImxOverrides> {
10132
10132
  }
10133
10133
 
10134
- declare class ImmutableXClient {
10134
+ declare class IMXClient {
10135
10135
  private immutableX;
10136
10136
  depositsApi: DepositsApi$1;
10137
10137
  mintsApi: MintsApi$1;
@@ -21257,7 +21257,7 @@ interface PassportOverrides {
21257
21257
  magicProviderId: string;
21258
21258
  passportDomain: string;
21259
21259
  imxPublicApiDomain: string;
21260
- immutableXClient: ImmutableXClient;
21260
+ immutableXClient: IMXClient;
21261
21261
  imxApiClients: ImxApiClients;
21262
21262
  zkEvmRpcUrl: string;
21263
21263
  relayerUrl: string;
package/dist/checkout.js CHANGED
@@ -25961,7 +25961,7 @@ class APIError extends Error {
25961
25961
 
25962
25962
  /* eslint-disable implicit-arrow-linebreak */
25963
25963
  const defaultHeaders = {
25964
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.44.4',
25964
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.45.1',
25965
25965
  };
25966
25966
  /**
25967
25967
  * createAPIConfiguration to create a custom Configuration
@@ -27316,13 +27316,13 @@ const ERC721ABI = [
27316
27316
  },
27317
27317
  ];
27318
27318
  // Gas overrides -- Anti-spam mechanism for when the baseFee drops low
27319
- // https://github.com/immutable/imx-docs/blob/main/docs/main/zkEVM/overview/gas-configuration.md
27320
- const GAS_OVERRIDES = {
27321
- maxFeePerGas: BigNumber$1.from(102e9),
27322
- maxPriorityFeePerGas: BigNumber$1.from(101e9),
27319
+ // https://docs.immutable.com/docs/zkEVM/architecture/gas-config
27320
+ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
27321
+ maxFeePerGas: BigNumber$1.from(15e9),
27322
+ maxPriorityFeePerGas: BigNumber$1.from(10e9),
27323
27323
  };
27324
27324
 
27325
- const SDK_VERSION_MARKER = '0.44.4';
27325
+ const SDK_VERSION_MARKER = '0.45.1';
27326
27326
  // This SDK version is replaced by the `yarn build` command ran on the root level
27327
27327
  const globalPackageVersion = () => SDK_VERSION_MARKER;
27328
27328
 
@@ -27470,6 +27470,9 @@ class CheckoutConfiguration {
27470
27470
  }
27471
27471
 
27472
27472
  const isMatchingAddress = (addressA = '', addressB = '') => (addressA.toLowerCase() === addressB.toLowerCase());
27473
+ const isZkEvmChainId = (chainId) => chainId === ChainId.IMTBL_ZKEVM_DEVNET
27474
+ || chainId === ChainId.IMTBL_ZKEVM_TESTNET
27475
+ || chainId === ChainId.IMTBL_ZKEVM_MAINNET;
27473
27476
 
27474
27477
  const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId, exclude, }) => {
27475
27478
  let tokens = [];
@@ -27816,7 +27819,7 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
27816
27819
  });
27817
27820
  return { balances };
27818
27821
  };
27819
- const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
27822
+ const getAllBalances = async (config, web3Provider, walletAddress, chainId, forceFetch = false) => {
27820
27823
  if (!walletAddress && !web3Provider) {
27821
27824
  throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
27822
27825
  }
@@ -27838,6 +27841,9 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
27838
27841
  // eslint-disable-next-line no-console
27839
27842
  console.error(err);
27840
27843
  }
27844
+ if (forceFetch) {
27845
+ resetBlockscoutClientMap();
27846
+ }
27841
27847
  let address = walletAddress;
27842
27848
  if (flag && Blockscout.isChainSupported(chainId)) {
27843
27849
  // This is a hack because the widgets are still using the tokens symbol
@@ -28003,16 +28009,19 @@ async function getWalletAllowList(params) {
28003
28009
  };
28004
28010
  }
28005
28011
 
28006
- const setTransactionGasLimits = (transaction) => {
28012
+ const setTransactionGasLimits = async (web3Provider, transaction) => {
28007
28013
  const rawTx = transaction;
28008
- rawTx.maxFeePerGas = GAS_OVERRIDES.maxFeePerGas;
28009
- rawTx.maxPriorityFeePerGas = GAS_OVERRIDES.maxPriorityFeePerGas;
28014
+ const { chainId } = await web3Provider.getNetwork();
28015
+ if (!isZkEvmChainId(chainId))
28016
+ return rawTx;
28017
+ rawTx.maxFeePerGas = IMMUTABLE_ZKVEM_GAS_OVERRIDES.maxFeePerGas;
28018
+ rawTx.maxPriorityFeePerGas = IMMUTABLE_ZKVEM_GAS_OVERRIDES.maxPriorityFeePerGas;
28010
28019
  return rawTx;
28011
28020
  };
28012
28021
  const sendTransaction = async (web3Provider, transaction) => {
28013
28022
  try {
28014
28023
  const signer = web3Provider.getSigner();
28015
- const rawTx = setTransactionGasLimits(transaction);
28024
+ const rawTx = await setTransactionGasLimits(web3Provider, transaction);
28016
28025
  const transactionResponse = await signer.sendTransaction(rawTx);
28017
28026
  return {
28018
28027
  transactionResponse,
@@ -28714,7 +28723,7 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
28714
28723
  /**
28715
28724
  * Gets the balances for all NATIVE and ERC20 balance requirements.
28716
28725
  */
28717
- const getTokenBalances = async (config, provider, ownerAddress, itemRequirements) => {
28726
+ const getTokenBalances = async (config, provider, ownerAddress, itemRequirements, forceFetch = false) => {
28718
28727
  try {
28719
28728
  const tokenMap = new Map();
28720
28729
  getTokensFromRequirements(itemRequirements).forEach((item) => {
@@ -28722,7 +28731,7 @@ const getTokenBalances = async (config, provider, ownerAddress, itemRequirements
28722
28731
  return;
28723
28732
  tokenMap.set(item.address.toLocaleLowerCase(), item);
28724
28733
  });
28725
- const { balances } = await getAllBalances(config, provider, ownerAddress, getL2ChainId(config));
28734
+ const { balances } = await getAllBalances(config, provider, ownerAddress, getL2ChainId(config), forceFetch);
28726
28735
  return balances.filter((balance) => tokenMap.get((balance.token.address || NATIVE).toLocaleLowerCase()));
28727
28736
  }
28728
28737
  catch (err) {
@@ -28772,7 +28781,7 @@ const getERC721Balances = async (provider, ownerAddress, itemRequirements) => {
28772
28781
  /**
28773
28782
  * Checks the item requirements against the owner balances.
28774
28783
  */
28775
- const balanceCheck = async (config, provider, ownerAddress, itemRequirements) => {
28784
+ const balanceCheck = async (config, provider, ownerAddress, itemRequirements, forceFetch = false) => {
28776
28785
  const aggregatedItems = balanceAggregator(itemRequirements);
28777
28786
  const requiredToken = [];
28778
28787
  const requiredERC721 = [];
@@ -28793,7 +28802,7 @@ const balanceCheck = async (config, provider, ownerAddress, itemRequirements) =>
28793
28802
  // Get all ERC20 and NATIVE balances
28794
28803
  const balancePromises = [];
28795
28804
  if (requiredToken.length > 0) {
28796
- balancePromises.push(getTokenBalances(config, provider, ownerAddress, aggregatedItems));
28805
+ balancePromises.push(getTokenBalances(config, provider, ownerAddress, aggregatedItems, forceFetch));
28797
28806
  }
28798
28807
  // Get all ERC721 balances
28799
28808
  if (requiredERC721.length > 0) {
@@ -30156,7 +30165,7 @@ const smartCheckout = async (config, provider, itemRequirements, transactionOrGa
30156
30165
  aggregatedItems.push(gasItem);
30157
30166
  aggregatedItems = itemAggregator(aggregatedItems);
30158
30167
  }
30159
- const balanceCheckResult = await measureAsyncExecution(config, 'Time to run balance checks', balanceCheck(config, provider, ownerAddress, aggregatedItems));
30168
+ const balanceCheckResult = await measureAsyncExecution(config, 'Time to run balance checks', balanceCheck(config, provider, ownerAddress, aggregatedItems, true));
30160
30169
  const { sufficient } = balanceCheckResult;
30161
30170
  const transactionRequirements = balanceCheckResult.balanceRequirements;
30162
30171
  if (sufficient) {