@imtbl/sdk 0.30.3 → 0.30.5

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.
@@ -11658,15 +11658,6 @@ interface CheckConnectionResult {
11658
11658
  walletAddress: string;
11659
11659
  }
11660
11660
 
11661
- /**
11662
- * @typedef {string} Address - Represents an Ethereum address.
11663
- */
11664
- type Address = string;
11665
- /**
11666
- * @typedef {Address | 'NATIVE'} FungibleToken - Represents a fungible token, either an ERC20 token address or the native token.
11667
- */
11668
- type FungibleToken = Address | 'NATIVE';
11669
-
11670
11661
  /**
11671
11662
  * An enum representing the type of gas estimate.
11672
11663
  * @enum {string}
@@ -11687,12 +11678,10 @@ type GasEstimateParams = GasEstimateBridgeToL2Params | GasEstimateSwapParams;
11687
11678
  * An interface representing the parameters for estimating gas for a bridge to L2 transaction {@link Checkout.gasEstimate}.
11688
11679
  * @param {GasEstimateType.BRIDGE_TO_L2} gasEstimateType - The type of gas estimate.
11689
11680
  * @param {boolean} isSpendingCapApprovalRequired - Whether or not spending cap approval is required.
11690
- * @param {FungibleToken | undefined} tokenAddress - The address of the fungible token to use in the transaction.
11691
11681
  */
11692
11682
  interface GasEstimateBridgeToL2Params {
11693
11683
  gasEstimateType: GasEstimateType.BRIDGE_TO_L2;
11694
11684
  isSpendingCapApprovalRequired: boolean;
11695
- tokenAddress?: FungibleToken;
11696
11685
  }
11697
11686
  /**
11698
11687
  * An interface representing the parameters for a gas estimate swap {@link Checkout.gasEstimate}.
@@ -16526,13 +16526,13 @@ function mapFromOpenApiOrder(order) {
16526
16526
  return {
16527
16527
  type: 'ERC20',
16528
16528
  contractAddress: item.contract_address,
16529
- amount: item.start_amount,
16529
+ amount: item.amount,
16530
16530
  };
16531
16531
  }
16532
16532
  if (item.item_type === 'NATIVE') {
16533
16533
  return {
16534
16534
  type: 'NATIVE',
16535
- amount: item.start_amount,
16535
+ amount: item.amount,
16536
16536
  };
16537
16537
  }
16538
16538
  throw new Error('Buy items must be either ERC20 or NATIVE');
@@ -16580,13 +16580,13 @@ function mapFromOpenApiTrade(trade) {
16580
16580
  return {
16581
16581
  type: 'ERC20',
16582
16582
  contractAddress: item.contract_address,
16583
- amount: item.start_amount,
16583
+ amount: item.amount,
16584
16584
  };
16585
16585
  }
16586
16586
  if (item.item_type === 'NATIVE') {
16587
16587
  return {
16588
16588
  type: 'NATIVE',
16589
- amount: item.start_amount,
16589
+ amount: item.amount,
16590
16590
  };
16591
16591
  }
16592
16592
  throw new Error('Buy items must be either ERC20 or NATIVE');
@@ -16726,8 +16726,8 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
16726
16726
  switch (buyItem.item_type) {
16727
16727
  case 'NATIVE':
16728
16728
  return {
16729
- startAmount: buyItem.start_amount,
16730
- endAmount: buyItem.start_amount,
16729
+ startAmount: buyItem.amount,
16730
+ endAmount: buyItem.amount,
16731
16731
  itemType: ItemType$1.NATIVE,
16732
16732
  recipient: order.account_address,
16733
16733
  token: constants$1.AddressZero,
@@ -16735,8 +16735,8 @@ function mapImmutableOrderToSeaportOrderComponents(order, counter, zoneAddress)
16735
16735
  };
16736
16736
  case 'ERC20':
16737
16737
  return {
16738
- startAmount: buyItem.start_amount,
16739
- endAmount: buyItem.start_amount,
16738
+ startAmount: buyItem.amount,
16739
+ endAmount: buyItem.amount,
16740
16740
  itemType: ItemType$1.ERC20,
16741
16741
  recipient: order.account_address,
16742
16742
  token: buyItem.contract_address || constants$1.AddressZero,
@@ -17057,7 +17057,7 @@ class ImmutableApiClient {
17057
17057
  === ItemType$1.NATIVE
17058
17058
  ? 'NATIVE'
17059
17059
  : 'ERC20',
17060
- start_amount: orderComponents.consideration[0].startAmount,
17060
+ amount: orderComponents.consideration[0].startAmount,
17061
17061
  contract_address: orderComponents.consideration[0].token,
17062
17062
  },
17063
17063
  ],
@@ -20911,7 +20911,7 @@ class APIError extends Error {
20911
20911
 
20912
20912
  /* eslint-disable implicit-arrow-linebreak */
20913
20913
  const defaultHeaders = {
20914
- sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.30.3',
20914
+ sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.30.5',
20915
20915
  };
20916
20916
  /**
20917
20917
  * createAPIConfiguration to create a custom Configuration
@@ -22919,42 +22919,40 @@ function getTokenContract(address, contractInterface, signerOrProvider) {
22919
22919
 
22920
22920
  const DUMMY_WALLET_ADDRESS = '0x0000000000000000000000000000000000000001';
22921
22921
  const DEFAULT_TOKEN_DECIMALS = 18;
22922
- async function getTokenInfoByAddress(config, tokenAddress, chainId, provider) {
22923
- if (tokenAddress === 'NATIVE') {
22924
- return config.networkMap.get(chainId)?.nativeCurrency;
22925
- }
22926
- const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), provider);
22927
- const name = await contract.name();
22928
- const symbol = await contract.symbol();
22929
- const decimals = await contract.decimals();
22930
- return {
22931
- name,
22932
- symbol,
22933
- decimals,
22934
- address: tokenAddress,
22935
- };
22936
- }
22937
- async function bridgeToL2GasEstimator(readOnlyProviders, config, isSpendingCapApprovalRequired, tokenAddress) {
22922
+ async function bridgeToL2GasEstimator(readOnlyProviders, config, isSpendingCapApprovalRequired) {
22938
22923
  const fromChainId = getL1ChainId(config);
22939
22924
  const toChainId = getL2ChainId(config);
22940
22925
  const gasEstimateTokensConfig = (await config.remote.getConfig('gasEstimateTokens'));
22941
- const { gasTokenAddress, fromAddress } = gasEstimateTokensConfig[fromChainId].bridgeToL2Addresses;
22926
+ const { fromAddress } = gasEstimateTokensConfig[fromChainId].bridgeToL2Addresses;
22942
22927
  const provider = readOnlyProviders.get(fromChainId);
22943
22928
  if (!provider)
22944
22929
  throw new Error(`Missing JsonRpcProvider for chain id: ${fromChainId}`);
22945
22930
  try {
22946
- const gasFee = await getBridgeEstimatedGas(provider, isSpendingCapApprovalRequired);
22947
- gasFee.token = await getTokenInfoByAddress(config, tokenAddress ?? (gasTokenAddress || 'NATIVE'), fromChainId, provider);
22948
- const tokenBridge = await createBridgeInstance(fromChainId, toChainId, readOnlyProviders, config);
22949
- const { bridgeFee, bridgeable } = await getBridgeFeeEstimate$1(tokenBridge, fromAddress);
22931
+ let gasFees = {};
22932
+ const getGasFees = async () => {
22933
+ gasFees = await getBridgeEstimatedGas(provider, isSpendingCapApprovalRequired);
22934
+ gasFees.token = config.networkMap.get(fromChainId)?.nativeCurrency;
22935
+ };
22936
+ let bridgeFees = {
22937
+ bridgeFee: {},
22938
+ bridgeable: false,
22939
+ };
22940
+ const getBridgeFees = async () => {
22941
+ const tokenBridge = await createBridgeInstance(fromChainId, toChainId, readOnlyProviders, config);
22942
+ bridgeFees = await getBridgeFeeEstimate$1(tokenBridge, fromAddress);
22943
+ };
22944
+ await Promise.all([
22945
+ getGasFees(),
22946
+ getBridgeFees(),
22947
+ ]);
22950
22948
  return {
22951
22949
  gasEstimateType: GasEstimateType.BRIDGE_TO_L2,
22952
- gasFee,
22950
+ gasFee: gasFees,
22953
22951
  bridgeFee: {
22954
- estimatedAmount: bridgeFee?.estimatedAmount,
22955
- token: bridgeFee?.token,
22952
+ estimatedAmount: bridgeFees.bridgeFee?.estimatedAmount,
22953
+ token: bridgeFees.bridgeFee?.token,
22956
22954
  },
22957
- bridgeable,
22955
+ bridgeable: bridgeFees.bridgeable,
22958
22956
  };
22959
22957
  }
22960
22958
  catch {
@@ -23010,7 +23008,7 @@ async function swapGasEstimator(config) {
23010
23008
  async function gasEstimator(params, readOnlyProviders, config) {
23011
23009
  switch (params.gasEstimateType) {
23012
23010
  case GasEstimateType.BRIDGE_TO_L2:
23013
- return await bridgeToL2GasEstimator(readOnlyProviders, config, params.isSpendingCapApprovalRequired, params.tokenAddress);
23011
+ return await bridgeToL2GasEstimator(readOnlyProviders, config, params.isSpendingCapApprovalRequired);
23014
23012
  case GasEstimateType.SWAP:
23015
23013
  return await swapGasEstimator(config);
23016
23014
  default:
@@ -25628,7 +25626,7 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
25628
25626
  return itemRequirements;
25629
25627
  }
25630
25628
 
25631
- const SDK_VERSION_MARKER = '0.30.3';
25629
+ const SDK_VERSION_MARKER = '0.30.5';
25632
25630
  // This SDK version is replaced by the `yarn build` command ran on the root level
25633
25631
  const globalPackageVersion = () => SDK_VERSION_MARKER;
25634
25632
 
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
17
17
  chainID,
18
18
  coreContractAddress,
19
19
  registrationContractAddress,
20
- sdkVersion: 'ts-immutable-sdk-0.30.3',
20
+ sdkVersion: 'ts-immutable-sdk-0.30.5',
21
21
  });
22
22
  /**
23
23
  * Sets `sdkVersion` at the time of build