@imtbl/sdk 0.36.3 → 0.36.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.
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout/sdk.js +6 -6
- package/dist/browser/checkout/widgets.js +58 -58
- package/dist/checkout.d.ts +50 -7
- package/dist/checkout.js +79 -23
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +10 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +81 -24
- package/dist/index.d.ts +54 -6
- package/dist/index.js +81 -24
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/checkout.d.ts
CHANGED
|
@@ -10644,12 +10644,12 @@ declare enum ChainId {
|
|
|
10644
10644
|
}
|
|
10645
10645
|
/**
|
|
10646
10646
|
* Enum representing different chain names.
|
|
10647
|
-
* @enum {
|
|
10648
|
-
* @property {
|
|
10649
|
-
* @property {
|
|
10650
|
-
* @property {
|
|
10651
|
-
* @property {
|
|
10652
|
-
* @property {
|
|
10647
|
+
* @enum {string}
|
|
10648
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
|
|
10649
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
|
|
10650
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
|
|
10651
|
+
* @property {string} ETHEREUM - The chain name for Ethereum.
|
|
10652
|
+
* @property {string} SEPOLIA - The chain name for Sepolia.
|
|
10653
10653
|
*/
|
|
10654
10654
|
declare enum ChainName {
|
|
10655
10655
|
ETHEREUM = "Ethereum",
|
|
@@ -10658,6 +10658,22 @@ declare enum ChainName {
|
|
|
10658
10658
|
IMTBL_ZKEVM_DEVNET = "Immutable zkEVM Dev",
|
|
10659
10659
|
IMTBL_ZKEVM_MAINNET = "Immutable zkEVM"
|
|
10660
10660
|
}
|
|
10661
|
+
/**
|
|
10662
|
+
* Enum representing different chain slugs.
|
|
10663
|
+
* @enum {string}
|
|
10664
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain slug for IMTBL ZKEVM Mainnet.
|
|
10665
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain slug for IMTBL ZKEVM Testnet.
|
|
10666
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain slug for IMTBL ZKEVM Devnet.
|
|
10667
|
+
* @property {string} ETHEREUM - The chain slug for Ethereum.
|
|
10668
|
+
* @property {string} SEPOLIA - The chain slug for Sepolia.
|
|
10669
|
+
*/
|
|
10670
|
+
declare enum ChainSlug {
|
|
10671
|
+
ETHEREUM = "ethereum",
|
|
10672
|
+
SEPOLIA = "sepolia",
|
|
10673
|
+
IMTBL_ZKEVM_MAINNET = "imtbl-zkevm-mainnet",
|
|
10674
|
+
IMTBL_ZKEVM_TESTNET = "imtbl-zkevm-testnet",
|
|
10675
|
+
IMTBL_ZKEVM_DEVNET = "imtbl-zkevm-devnet"
|
|
10676
|
+
}
|
|
10661
10677
|
|
|
10662
10678
|
/**
|
|
10663
10679
|
* Represents information about a token.
|
|
@@ -10675,6 +10691,15 @@ interface TokenInfo {
|
|
|
10675
10691
|
address?: string;
|
|
10676
10692
|
icon?: string;
|
|
10677
10693
|
}
|
|
10694
|
+
/**
|
|
10695
|
+
* Interface representing the parameters for {@link Checkout.getTokenInfo}.
|
|
10696
|
+
* @property {Web3Provider | JsonRpcProvider} provider - The provider used to get the balance.
|
|
10697
|
+
* @property {string} tokenAddress - The contract address of the token.
|
|
10698
|
+
*/
|
|
10699
|
+
interface GetTokenInfoParams {
|
|
10700
|
+
provider: Web3Provider | JsonRpcProvider;
|
|
10701
|
+
tokenAddress: string;
|
|
10702
|
+
}
|
|
10678
10703
|
|
|
10679
10704
|
/**
|
|
10680
10705
|
* Interface representing the parameters for {@link Checkout.getBalance}.
|
|
@@ -11503,6 +11528,7 @@ interface CheckoutModuleConfiguration extends ModuleConfiguration<CheckoutOverri
|
|
|
11503
11528
|
* @property {AllowedNetworkConfig[]} allowedNetworks
|
|
11504
11529
|
* @property {GasEstimateTokenConfig | undefined} gasEstimateTokens
|
|
11505
11530
|
* @property {ImxAddressConfig | undefined} imxAddressMapping
|
|
11531
|
+
* @property {TelemetryConfig | undefined} telemetry
|
|
11506
11532
|
*/
|
|
11507
11533
|
type RemoteConfiguration = {
|
|
11508
11534
|
/** The config used for the DEX. */
|
|
@@ -11517,6 +11543,8 @@ type RemoteConfiguration = {
|
|
|
11517
11543
|
gasEstimateTokens?: GasEstimateTokenConfig;
|
|
11518
11544
|
/** The IMX address mappings across available networks. */
|
|
11519
11545
|
imxAddressMapping?: ImxAddressConfig;
|
|
11546
|
+
/** Telemetry config. */
|
|
11547
|
+
telemetry?: TelemetryConfig;
|
|
11520
11548
|
};
|
|
11521
11549
|
/**
|
|
11522
11550
|
* A type representing the fee structure for an OnRamp provider
|
|
@@ -11588,6 +11616,13 @@ type AllowedNetworkConfig = {
|
|
|
11588
11616
|
type ImxAddressConfig = {
|
|
11589
11617
|
[chainId: string]: string;
|
|
11590
11618
|
};
|
|
11619
|
+
/**
|
|
11620
|
+
* A type representing the telemetry configurations.
|
|
11621
|
+
* @property {string} publishableApiKey
|
|
11622
|
+
*/
|
|
11623
|
+
type TelemetryConfig = {
|
|
11624
|
+
publishableApiKey: string;
|
|
11625
|
+
};
|
|
11591
11626
|
/**
|
|
11592
11627
|
* A type representing the required information to estimate gas for a transaction.
|
|
11593
11628
|
* @type {{ [key: string]: { bridgeToL2Addresses?: GasEstimateBridgeToL2TokenConfig, swapAddresses?: GasEstimateSwapTokenConfig } }}
|
|
@@ -12756,6 +12791,13 @@ declare class Checkout {
|
|
|
12756
12791
|
* @returns {Promise<SwitchNetworkResult>} - A promise that resolves to the result of switching the network.
|
|
12757
12792
|
*/
|
|
12758
12793
|
switchNetwork(params: SwitchNetworkParams): Promise<SwitchNetworkResult>;
|
|
12794
|
+
/**
|
|
12795
|
+
* Retrieves the token information given the token address. This function makes RPC calls to
|
|
12796
|
+
* ERC20 contracts to fetch the main contract information (e.g. symbol).
|
|
12797
|
+
* @param {GetTokenInfoParams} params - The parameters for retrieving the token information.
|
|
12798
|
+
* @returns {Promise<TokenInfo>} - A promise that resolves to the token info request.
|
|
12799
|
+
*/
|
|
12800
|
+
getTokenInfo(params: GetTokenInfoParams): Promise<TokenInfo>;
|
|
12759
12801
|
/**
|
|
12760
12802
|
* Retrieves the balance of a wallet address.
|
|
12761
12803
|
* @param {GetBalanceParams} params - The parameters for retrieving the balance.
|
|
@@ -12936,6 +12978,7 @@ declare enum CheckoutErrorType {
|
|
|
12936
12978
|
CONNECT_PROVIDER_ERROR = "CONNECT_PROVIDER_ERROR",
|
|
12937
12979
|
GET_BALANCE_ERROR = "GET_BALANCE_ERROR",
|
|
12938
12980
|
GET_INDEXER_BALANCE_ERROR = "GET_INDEXER_BALANCE_ERROR",
|
|
12981
|
+
GET_ERC20_INFO_ERROR = "GET_ERC20_INFO_ERROR",
|
|
12939
12982
|
GET_ERC20_BALANCE_ERROR = "GET_ERC20_BALANCE_ERROR",
|
|
12940
12983
|
GET_ERC721_BALANCE_ERROR = "GET_ERC721_BALANCE_ERROR",
|
|
12941
12984
|
GET_NETWORK_INFO_ERROR = "GET_NETWORK_INFO_ERROR",
|
|
@@ -12985,4 +13028,4 @@ type ErrorType = {
|
|
|
12985
13028
|
};
|
|
12986
13029
|
};
|
|
12987
13030
|
|
|
12988
|
-
export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeTransactionSent, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyParams, BuyResult, BuyResultFailed, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CancelParams, CancelResult, CancelResultFailed, CancelResultSuccess, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutBridgeConfiguration, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutOnRampConfiguration, CheckoutStatus, CheckoutSwapConfiguration, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectResult, ConnectTargetLayer, ConnectWidgetConfiguration, ConnectWidgetParams, ConnectionFailed, ConnectionSuccess, CreateProviderParams, CreateProviderResult, DexConfig, ERC20ItemRequirement, ERC721Balance, ERC721ItemRequirement, ErrorType, ExchangeType, Fee, FeePercentage, FeeToken, FiatRampParams, FulfillmentTransaction, FundingItem, FundingRoute, FundingStep, FundingStepType, GasAmount, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasToken, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetWalletAllowListParams, GetWalletAllowListResult, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, IWidgetsFactory, ItemBalance, ItemType, NativeItemRequirement, NetworkFilter, NetworkFilterTypes, NetworkInfo, NoRouteOptions, NoRoutesFound, OnRampEventType, OnRampFailed, OnRampFundingStep, OnRampProviderFees, OnRampSuccess, OnRampWidgetParams, OnrampWidgetConfiguration, OrchestrationEvent, OrchestrationEventData, OrchestrationEventType, OrderFee, ProviderEvent, ProviderEventType, ProviderUpdated, RemoteConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, RoutesFound, RoutingOutcome, RoutingOutcomeType, SaleEventType, SaleFailed, SaleItem, SaleSuccess, SaleTransactionSuccess, SaleWidgetConfiguration, SaleWidgetParams, SellOrder, SellParams, SellResult, SellResultFailed, SellResultInsufficientFunds, SellResultSuccess, SellToken, SemanticVersion, SendTransactionParams, SendTransactionResult, SmartCheckoutInsufficient, SmartCheckoutParams, SmartCheckoutResult, SmartCheckoutRouter, SmartCheckoutSufficient, SwapEventType, SwapFailed, SwapFundingStep, SwapRejected, SwapSuccess, SwapWidgetConfiguration, SwapWidgetParams, SwitchNetworkParams, SwitchNetworkResult, TokenAmountEstimate, TokenBalance, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, TransactionRequirement, WalletDisconnect, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitch, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
|
|
13031
|
+
export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeTransactionSent, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyParams, BuyResult, BuyResultFailed, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CancelParams, CancelResult, CancelResultFailed, CancelResultSuccess, ChainId, ChainName, ChainSlug, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutBridgeConfiguration, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutOnRampConfiguration, CheckoutStatus, CheckoutSwapConfiguration, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectResult, ConnectTargetLayer, ConnectWidgetConfiguration, ConnectWidgetParams, ConnectionFailed, ConnectionSuccess, CreateProviderParams, CreateProviderResult, DexConfig, ERC20ItemRequirement, ERC721Balance, ERC721ItemRequirement, ErrorType, ExchangeType, Fee, FeePercentage, FeeToken, FiatRampParams, FulfillmentTransaction, FundingItem, FundingRoute, FundingStep, FundingStepType, GasAmount, GasEstimateBridgeToL2Result, GasEstimateParams, GasEstimateSwapResult, GasEstimateTokenConfig, GasEstimateType, GasToken, GasTokenType, GetAllBalancesParams, GetAllBalancesResult, GetBalanceParams, GetBalanceResult, GetNetworkAllowListParams, GetNetworkAllowListResult, GetNetworkParams, GetTokenAllowListParams, GetTokenAllowListResult, GetTokenInfoParams, GetWalletAllowListParams, GetWalletAllowListResult, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, IWidgetsFactory, ItemBalance, ItemType, NativeItemRequirement, NetworkFilter, NetworkFilterTypes, NetworkInfo, NoRouteOptions, NoRoutesFound, OnRampEventType, OnRampFailed, OnRampFundingStep, OnRampProviderFees, OnRampSuccess, OnRampWidgetParams, OnrampWidgetConfiguration, OrchestrationEvent, OrchestrationEventData, OrchestrationEventType, OrderFee, ProviderEvent, ProviderEventType, ProviderUpdated, RemoteConfiguration, RequestBridgeEvent, RequestConnectEvent, RequestOnrampEvent, RequestSwapEvent, RequestWalletEvent, RoutesFound, RoutingOutcome, RoutingOutcomeType, SaleEventType, SaleFailed, SaleItem, SaleSuccess, SaleTransactionSuccess, SaleWidgetConfiguration, SaleWidgetParams, SellOrder, SellParams, SellResult, SellResultFailed, SellResultInsufficientFunds, SellResultSuccess, SellToken, SemanticVersion, SendTransactionParams, SendTransactionResult, SmartCheckoutInsufficient, SmartCheckoutParams, SmartCheckoutResult, SmartCheckoutRouter, SmartCheckoutSufficient, SwapEventType, SwapFailed, SwapFundingStep, SwapRejected, SwapSuccess, SwapWidgetConfiguration, SwapWidgetParams, SwitchNetworkParams, SwitchNetworkResult, TokenAmountEstimate, TokenBalance, TokenFilter, TokenFilterTypes, TokenInfo, TransactionOrGasType, TransactionRequirement, WalletDisconnect, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitch, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
|
package/dist/checkout.js
CHANGED
|
@@ -25833,7 +25833,7 @@ class APIError extends Error {
|
|
|
25833
25833
|
|
|
25834
25834
|
/* eslint-disable implicit-arrow-linebreak */
|
|
25835
25835
|
const defaultHeaders = {
|
|
25836
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.
|
|
25836
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.36.4',
|
|
25837
25837
|
};
|
|
25838
25838
|
/**
|
|
25839
25839
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -26393,12 +26393,12 @@ var ChainId;
|
|
|
26393
26393
|
})(ChainId || (ChainId = {}));
|
|
26394
26394
|
/**
|
|
26395
26395
|
* Enum representing different chain names.
|
|
26396
|
-
* @enum {
|
|
26397
|
-
* @property {
|
|
26398
|
-
* @property {
|
|
26399
|
-
* @property {
|
|
26400
|
-
* @property {
|
|
26401
|
-
* @property {
|
|
26396
|
+
* @enum {string}
|
|
26397
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain name for IMTBL ZKEVM Mainnet.
|
|
26398
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain name for IMTBL ZKEVM Testnet.
|
|
26399
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain name for IMTBL ZKEVM Devnet.
|
|
26400
|
+
* @property {string} ETHEREUM - The chain name for Ethereum.
|
|
26401
|
+
* @property {string} SEPOLIA - The chain name for Sepolia.
|
|
26402
26402
|
*/
|
|
26403
26403
|
var ChainName;
|
|
26404
26404
|
(function (ChainName) {
|
|
@@ -26408,6 +26408,23 @@ var ChainName;
|
|
|
26408
26408
|
ChainName["IMTBL_ZKEVM_DEVNET"] = "Immutable zkEVM Dev";
|
|
26409
26409
|
ChainName["IMTBL_ZKEVM_MAINNET"] = "Immutable zkEVM";
|
|
26410
26410
|
})(ChainName || (ChainName = {}));
|
|
26411
|
+
/**
|
|
26412
|
+
* Enum representing different chain slugs.
|
|
26413
|
+
* @enum {string}
|
|
26414
|
+
* @property {string} IMTBL_ZKEVM_MAINNET - The chain slug for IMTBL ZKEVM Mainnet.
|
|
26415
|
+
* @property {string} IMTBL_ZKEVM_TESTNET - The chain slug for IMTBL ZKEVM Testnet.
|
|
26416
|
+
* @property {string} IMTBL_ZKEVM_DEVNET - The chain slug for IMTBL ZKEVM Devnet.
|
|
26417
|
+
* @property {string} ETHEREUM - The chain slug for Ethereum.
|
|
26418
|
+
* @property {string} SEPOLIA - The chain slug for Sepolia.
|
|
26419
|
+
*/
|
|
26420
|
+
var ChainSlug;
|
|
26421
|
+
(function (ChainSlug) {
|
|
26422
|
+
ChainSlug["ETHEREUM"] = "ethereum";
|
|
26423
|
+
ChainSlug["SEPOLIA"] = "sepolia";
|
|
26424
|
+
ChainSlug["IMTBL_ZKEVM_MAINNET"] = "imtbl-zkevm-mainnet";
|
|
26425
|
+
ChainSlug["IMTBL_ZKEVM_TESTNET"] = "imtbl-zkevm-testnet";
|
|
26426
|
+
ChainSlug["IMTBL_ZKEVM_DEVNET"] = "imtbl-zkevm-devnet";
|
|
26427
|
+
})(ChainSlug || (ChainSlug = {}));
|
|
26411
26428
|
|
|
26412
26429
|
var OnRampProvider;
|
|
26413
26430
|
(function (OnRampProvider) {
|
|
@@ -26572,6 +26589,7 @@ var CheckoutErrorType;
|
|
|
26572
26589
|
CheckoutErrorType["CONNECT_PROVIDER_ERROR"] = "CONNECT_PROVIDER_ERROR";
|
|
26573
26590
|
CheckoutErrorType["GET_BALANCE_ERROR"] = "GET_BALANCE_ERROR";
|
|
26574
26591
|
CheckoutErrorType["GET_INDEXER_BALANCE_ERROR"] = "GET_INDEXER_BALANCE_ERROR";
|
|
26592
|
+
CheckoutErrorType["GET_ERC20_INFO_ERROR"] = "GET_ERC20_INFO_ERROR";
|
|
26575
26593
|
CheckoutErrorType["GET_ERC20_BALANCE_ERROR"] = "GET_ERC20_BALANCE_ERROR";
|
|
26576
26594
|
CheckoutErrorType["GET_ERC721_BALANCE_ERROR"] = "GET_ERC721_BALANCE_ERROR";
|
|
26577
26595
|
CheckoutErrorType["GET_NETWORK_INFO_ERROR"] = "GET_NETWORK_INFO_ERROR";
|
|
@@ -27139,7 +27157,7 @@ const GAS_OVERRIDES = {
|
|
|
27139
27157
|
maxPriorityFeePerGas: BigNumber$1.from(101e9),
|
|
27140
27158
|
};
|
|
27141
27159
|
|
|
27142
|
-
const SDK_VERSION_MARKER = '0.36.
|
|
27160
|
+
const SDK_VERSION_MARKER = '0.36.4';
|
|
27143
27161
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
27144
27162
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
27145
27163
|
|
|
@@ -27300,6 +27318,22 @@ const getTokenAllowList = async (config, { type = TokenFilterTypes.ALL, chainId,
|
|
|
27300
27318
|
};
|
|
27301
27319
|
};
|
|
27302
27320
|
const isNativeToken = (address) => !address || address.toLocaleLowerCase() === NATIVE;
|
|
27321
|
+
async function getERC20TokenInfo(web3Provider, tokenAddress) {
|
|
27322
|
+
return await withCheckoutError(async () => {
|
|
27323
|
+
const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
|
|
27324
|
+
const [name, symbol, decimals] = await Promise.all([
|
|
27325
|
+
contract.name(),
|
|
27326
|
+
contract.symbol(),
|
|
27327
|
+
contract.decimals(),
|
|
27328
|
+
]);
|
|
27329
|
+
return {
|
|
27330
|
+
name,
|
|
27331
|
+
symbol,
|
|
27332
|
+
decimals,
|
|
27333
|
+
address: tokenAddress,
|
|
27334
|
+
};
|
|
27335
|
+
}, { type: CheckoutErrorType.GET_ERC20_INFO_ERROR });
|
|
27336
|
+
}
|
|
27303
27337
|
|
|
27304
27338
|
const CACHE_DATA_TTL = 60; // seconds
|
|
27305
27339
|
/**
|
|
@@ -27470,20 +27504,18 @@ async function getERC20Balance(web3Provider, walletAddress, tokenAddress) {
|
|
|
27470
27504
|
return await withCheckoutError(async () => {
|
|
27471
27505
|
const contract = new Contract$1(tokenAddress, JSON.stringify(ERC20ABI), web3Provider);
|
|
27472
27506
|
return Promise.all([
|
|
27473
|
-
|
|
27474
|
-
contract.symbol(),
|
|
27507
|
+
getERC20TokenInfo(web3Provider, tokenAddress),
|
|
27475
27508
|
contract.balanceOf(walletAddress),
|
|
27476
|
-
contract.decimals(),
|
|
27477
27509
|
])
|
|
27478
|
-
.then(([
|
|
27479
|
-
const formattedBalance = utils$1.formatUnits(balance, decimals);
|
|
27510
|
+
.then(([tokenInfo, balance]) => {
|
|
27511
|
+
const formattedBalance = utils$1.formatUnits(balance, tokenInfo.decimals);
|
|
27480
27512
|
return {
|
|
27481
27513
|
balance,
|
|
27482
27514
|
formattedBalance,
|
|
27483
27515
|
token: {
|
|
27484
|
-
name,
|
|
27485
|
-
symbol,
|
|
27486
|
-
decimals,
|
|
27516
|
+
name: tokenInfo.name,
|
|
27517
|
+
symbol: tokenInfo.symbol,
|
|
27518
|
+
decimals: tokenInfo.decimals,
|
|
27487
27519
|
address: tokenAddress,
|
|
27488
27520
|
},
|
|
27489
27521
|
};
|
|
@@ -27583,6 +27615,9 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
27583
27615
|
const allBalancePromises = [];
|
|
27584
27616
|
tokens
|
|
27585
27617
|
.forEach((token) => {
|
|
27618
|
+
// For some reason isNativeToken always returns undefined.
|
|
27619
|
+
// We have spent way too much time figuring out why this is happening.
|
|
27620
|
+
// That we have given up -- keep it as it is for now.
|
|
27586
27621
|
if (!token.address || token.address.toLocaleLowerCase() === NATIVE) {
|
|
27587
27622
|
allBalancePromises.push(getBalance(config, web3Provider, walletAddress));
|
|
27588
27623
|
}
|
|
@@ -27591,13 +27626,25 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
27591
27626
|
}
|
|
27592
27627
|
});
|
|
27593
27628
|
const balanceResults = await Promise.allSettled(allBalancePromises);
|
|
27594
|
-
const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) =>
|
|
27629
|
+
const balances = balanceResults.filter((result) => result.status === 'fulfilled').map((result) => {
|
|
27630
|
+
const resp = result;
|
|
27631
|
+
const { token } = resp.value;
|
|
27632
|
+
// For some reason isNativeToken always returns undefined.
|
|
27633
|
+
// We have spent way too much time figuring out why this is happening.
|
|
27634
|
+
// That we have given up -- keep it as it is for now.
|
|
27635
|
+
if (!token.address || token.address.toLocaleLowerCase() === NATIVE)
|
|
27636
|
+
resp.value.token.address = NATIVE;
|
|
27637
|
+
return resp.value;
|
|
27638
|
+
});
|
|
27595
27639
|
return { balances };
|
|
27596
27640
|
};
|
|
27597
27641
|
const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
27598
27642
|
if (!walletAddress && !web3Provider) {
|
|
27599
27643
|
throw new CheckoutError('both walletAddress and provider are missing. At least one must be provided.', CheckoutErrorType.MISSING_PARAMS);
|
|
27600
27644
|
}
|
|
27645
|
+
if (!config.networkMap.get(chainId)) {
|
|
27646
|
+
throw new CheckoutError(`chain ID ${chainId} not supported by the environment`, CheckoutErrorType.CHAIN_NOT_SUPPORTED_ERROR);
|
|
27647
|
+
}
|
|
27601
27648
|
const { tokens } = await getTokenAllowList(config, {
|
|
27602
27649
|
type: TokenFilterTypes.ALL,
|
|
27603
27650
|
chainId,
|
|
@@ -29179,11 +29226,11 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders, fromChainId, toCh
|
|
|
29179
29226
|
const INDEXER_ETH_ROOT_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000eee';
|
|
29180
29227
|
const getIndexerChainName = (chainId) => {
|
|
29181
29228
|
if (chainId === ChainId.IMTBL_ZKEVM_MAINNET)
|
|
29182
|
-
return
|
|
29229
|
+
return ChainSlug.IMTBL_ZKEVM_MAINNET;
|
|
29183
29230
|
if (chainId === ChainId.IMTBL_ZKEVM_TESTNET)
|
|
29184
|
-
return
|
|
29231
|
+
return ChainSlug.IMTBL_ZKEVM_TESTNET;
|
|
29185
29232
|
if (chainId === ChainId.IMTBL_ZKEVM_DEVNET)
|
|
29186
|
-
return
|
|
29233
|
+
return ChainSlug.IMTBL_ZKEVM_DEVNET;
|
|
29187
29234
|
return '';
|
|
29188
29235
|
};
|
|
29189
29236
|
// Indexer ERC20 call does not support IMX so cannot get root chain mapping from this endpoint.
|
|
@@ -30629,6 +30676,8 @@ class Checkout {
|
|
|
30629
30676
|
*/
|
|
30630
30677
|
async widgets(init) {
|
|
30631
30678
|
const checkout = this;
|
|
30679
|
+
// Preload the configurations
|
|
30680
|
+
await checkout.config.remote.getConfig();
|
|
30632
30681
|
const factory = new Promise((resolve, reject) => {
|
|
30633
30682
|
function checkForWidgetsBundleLoaded() {
|
|
30634
30683
|
if (typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
@@ -30644,8 +30693,6 @@ class Checkout {
|
|
|
30644
30693
|
try {
|
|
30645
30694
|
const script = loadUnresolved(init.version);
|
|
30646
30695
|
if (script.loaded && typeof ImmutableCheckoutWidgets !== 'undefined') {
|
|
30647
|
-
// eslint-disable-next-line no-console
|
|
30648
|
-
console.warn('Checkout widgets script is already loaded');
|
|
30649
30696
|
resolve(new ImmutableCheckoutWidgets.WidgetsFactory(checkout, init.config));
|
|
30650
30697
|
}
|
|
30651
30698
|
else {
|
|
@@ -30699,6 +30746,15 @@ class Checkout {
|
|
|
30699
30746
|
const switchNetworkRes = await switchWalletNetwork(this.config, web3Provider, params.chainId);
|
|
30700
30747
|
return switchNetworkRes;
|
|
30701
30748
|
}
|
|
30749
|
+
/**
|
|
30750
|
+
* Retrieves the token information given the token address. This function makes RPC calls to
|
|
30751
|
+
* ERC20 contracts to fetch the main contract information (e.g. symbol).
|
|
30752
|
+
* @param {GetTokenInfoParams} params - The parameters for retrieving the token information.
|
|
30753
|
+
* @returns {Promise<TokenInfo>} - A promise that resolves to the token info request.
|
|
30754
|
+
*/
|
|
30755
|
+
async getTokenInfo(params) {
|
|
30756
|
+
return await getERC20TokenInfo(params.provider, params.tokenAddress);
|
|
30757
|
+
}
|
|
30702
30758
|
/**
|
|
30703
30759
|
* Retrieves the balance of a wallet address.
|
|
30704
30760
|
* @param {GetBalanceParams} params - The parameters for retrieving the balance.
|
|
@@ -30878,4 +30934,4 @@ class Checkout {
|
|
|
30878
30934
|
}
|
|
30879
30935
|
}
|
|
30880
30936
|
|
|
30881
|
-
export { BridgeEventType, ChainId, ChainName, Checkout, CheckoutConfiguration, CheckoutErrorType, CheckoutStatus, ConnectEventType, ConnectTargetLayer, ExchangeType, FundingStepType, GasEstimateType, GasTokenType, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, ItemType, NetworkFilterTypes, OnRampEventType, OrchestrationEventType, ProviderEventType, RoutingOutcomeType, SaleEventType, SwapEventType, TokenFilterTypes, TransactionOrGasType, WalletEventType, WalletFilterTypes, WalletProviderName, WidgetTheme, WidgetType };
|
|
30937
|
+
export { BridgeEventType, ChainId, ChainName, ChainSlug, Checkout, CheckoutConfiguration, CheckoutErrorType, CheckoutStatus, ConnectEventType, ConnectTargetLayer, ExchangeType, FundingStepType, GasEstimateType, GasTokenType, IMMUTABLE_API_BASE_URL, IMTBLWidgetEvents, ItemType, NetworkFilterTypes, OnRampEventType, OrchestrationEventType, ProviderEventType, RoutingOutcomeType, SaleEventType, SwapEventType, TokenFilterTypes, TransactionOrGasType, WalletEventType, WalletFilterTypes, WalletProviderName, WidgetTheme, WidgetType };
|
|
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
17
17
|
chainID,
|
|
18
18
|
coreContractAddress,
|
|
19
19
|
registrationContractAddress,
|
|
20
|
-
sdkVersion: 'ts-immutable-sdk-0.36.
|
|
20
|
+
sdkVersion: 'ts-immutable-sdk-0.36.4',
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
23
23
|
* Sets `sdkVersion` at the time of build
|