@imtbl/sdk 0.28.6-alpha → 0.28.7-alpha
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 +51 -51
- package/dist/checkout_sdk.d.ts +45 -24
- package/dist/checkout_sdk.js +75 -62
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +163 -84
- package/dist/index.d.ts +49 -23
- package/dist/index.js +164 -85
- package/dist/passport.d.ts +7 -1
- package/dist/passport.js +67 -21
- package/dist/provider.d.ts +7 -0
- package/dist/provider.js +22 -2
- package/package.json +3 -3
package/dist/checkout_sdk.d.ts
CHANGED
|
@@ -10019,6 +10019,12 @@ interface IMXProvider {
|
|
|
10019
10019
|
* @return {Promise<RegisterUserResponse>} Returns a promise that resolves with the user registration response
|
|
10020
10020
|
*/
|
|
10021
10021
|
registerOffchain(): Promise<RegisterUserResponse>;
|
|
10022
|
+
/**
|
|
10023
|
+
* Checks if a User is registered off-chain
|
|
10024
|
+
*
|
|
10025
|
+
* @return {Promise<boolean>} Returns a promise that resolves with true if the User is registered with IMX, false otherwise
|
|
10026
|
+
*/
|
|
10027
|
+
isRegisteredOffchain(): Promise<boolean>;
|
|
10022
10028
|
/**
|
|
10023
10029
|
* Checks if a User is registered on-chain
|
|
10024
10030
|
*
|
|
@@ -10471,7 +10477,7 @@ type UserProfile = {
|
|
|
10471
10477
|
};
|
|
10472
10478
|
declare enum Networks {
|
|
10473
10479
|
PRODUCTION = "mainnet",
|
|
10474
|
-
SANDBOX = "
|
|
10480
|
+
SANDBOX = "sepolia"
|
|
10475
10481
|
}
|
|
10476
10482
|
interface OidcConfiguration {
|
|
10477
10483
|
clientId: string;
|
|
@@ -11466,21 +11472,6 @@ type ChainTokensConfig = {
|
|
|
11466
11472
|
blockscout?: boolean;
|
|
11467
11473
|
};
|
|
11468
11474
|
|
|
11469
|
-
/**
|
|
11470
|
-
* Represents information about a network.
|
|
11471
|
-
* @interface NetworkInfo
|
|
11472
|
-
* @property {string} name - The name of the network.
|
|
11473
|
-
* @property {number} chainId - The chain ID of the network.
|
|
11474
|
-
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
|
|
11475
|
-
* @property {boolean} isSupported - Indicates whether the network is supported.
|
|
11476
|
-
*/
|
|
11477
|
-
interface NetworkInfo {
|
|
11478
|
-
name: string;
|
|
11479
|
-
chainId: number;
|
|
11480
|
-
nativeCurrency: TokenInfo;
|
|
11481
|
-
isSupported: boolean;
|
|
11482
|
-
}
|
|
11483
|
-
|
|
11484
11475
|
/**
|
|
11485
11476
|
* Interface representing the params of {@link Checkout.connect}.
|
|
11486
11477
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
@@ -11491,11 +11482,9 @@ interface ConnectParams {
|
|
|
11491
11482
|
/**
|
|
11492
11483
|
* Interface representing the result of {@link Checkout.connect}.
|
|
11493
11484
|
* @property {Web3Provider} provider - The provider used to connect to the network.
|
|
11494
|
-
* @property {NetworkInfo} network - Information about the connected network.
|
|
11495
11485
|
*/
|
|
11496
11486
|
interface ConnectResult {
|
|
11497
11487
|
provider: Web3Provider;
|
|
11498
|
-
network: NetworkInfo;
|
|
11499
11488
|
}
|
|
11500
11489
|
/**
|
|
11501
11490
|
* Interface representing the params of {@link Checkout.checkIsWalletConnected}.
|
|
@@ -11587,6 +11576,21 @@ interface TokenAmountEstimate {
|
|
|
11587
11576
|
token?: TokenInfo;
|
|
11588
11577
|
}
|
|
11589
11578
|
|
|
11579
|
+
/**
|
|
11580
|
+
* Represents information about a network.
|
|
11581
|
+
* @interface NetworkInfo
|
|
11582
|
+
* @property {string} name - The name of the network.
|
|
11583
|
+
* @property {number} chainId - The chain ID of the network.
|
|
11584
|
+
* @property {TokenInfo} nativeCurrency - Information about the native currency of the network.
|
|
11585
|
+
* @property {boolean} isSupported - Indicates whether the network is supported.
|
|
11586
|
+
*/
|
|
11587
|
+
interface NetworkInfo {
|
|
11588
|
+
name: string;
|
|
11589
|
+
chainId: number;
|
|
11590
|
+
nativeCurrency: TokenInfo;
|
|
11591
|
+
isSupported: boolean;
|
|
11592
|
+
}
|
|
11593
|
+
|
|
11590
11594
|
/**
|
|
11591
11595
|
* Interface representing the parameters for {@link Checkout.switchNetwork}.
|
|
11592
11596
|
* @property {Web3Provider} provider - The provider to connect to the network.
|
|
@@ -12002,11 +12006,12 @@ declare enum SaleEventType {
|
|
|
12002
12006
|
CLOSE_WIDGET = "close-widget",
|
|
12003
12007
|
SUCCESS = "success",
|
|
12004
12008
|
FAILURE = "failure",
|
|
12005
|
-
REJECTED = "rejected"
|
|
12009
|
+
REJECTED = "rejected",
|
|
12010
|
+
TRANSACTION_SUCCESS = "transaction-success"
|
|
12006
12011
|
}
|
|
12007
12012
|
/**
|
|
12008
12013
|
* Represents a successful Sale transaction.
|
|
12009
|
-
* @property {
|
|
12014
|
+
* @property {Array} transactions - The executed transactions
|
|
12010
12015
|
*/
|
|
12011
12016
|
type SaleSuccess = {
|
|
12012
12017
|
transactions: {
|
|
@@ -12019,10 +12024,25 @@ type SaleSuccess = {
|
|
|
12019
12024
|
* Type representing a Sale Widget with type FAILURE.
|
|
12020
12025
|
* @property {string} reason - The reason why the swap failed.
|
|
12021
12026
|
* @property {number} timestamp - The timestamp of the failed swap.
|
|
12027
|
+
* @property {Array} transactions - The executed transactions
|
|
12022
12028
|
*/
|
|
12023
12029
|
type SaleFailed = {
|
|
12024
12030
|
reason: string;
|
|
12025
12031
|
timestamp: number;
|
|
12032
|
+
transactions: {
|
|
12033
|
+
method: string;
|
|
12034
|
+
hash: string | undefined;
|
|
12035
|
+
}[];
|
|
12036
|
+
};
|
|
12037
|
+
/**
|
|
12038
|
+
* Type representing a Sale Widget with type TRANSACTION_SUCCESS.
|
|
12039
|
+
* @property {Object} transactions - The executed transactions
|
|
12040
|
+
*/
|
|
12041
|
+
type SaleTransactionSuccess = {
|
|
12042
|
+
transactions: {
|
|
12043
|
+
method: string;
|
|
12044
|
+
hash: string | undefined;
|
|
12045
|
+
}[];
|
|
12026
12046
|
};
|
|
12027
12047
|
|
|
12028
12048
|
/**
|
|
@@ -12308,6 +12328,7 @@ type WidgetEventData = {
|
|
|
12308
12328
|
[SaleEventType.FAILURE]: SaleFailed;
|
|
12309
12329
|
[SaleEventType.REJECTED]: any;
|
|
12310
12330
|
[SaleEventType.CLOSE_WIDGET]: {};
|
|
12331
|
+
[SaleEventType.TRANSACTION_SUCCESS]: SaleTransactionSuccess;
|
|
12311
12332
|
} & OrchestrationMapping & ProviderEventMapping;
|
|
12312
12333
|
};
|
|
12313
12334
|
/**
|
|
@@ -12366,10 +12387,10 @@ interface Widget<T extends WidgetType> {
|
|
|
12366
12387
|
*/
|
|
12367
12388
|
unmount(): void;
|
|
12368
12389
|
/**
|
|
12369
|
-
* Update the widget
|
|
12370
|
-
* @param
|
|
12390
|
+
* Update the widget properties
|
|
12391
|
+
* @param props Widget specific properties including configuration
|
|
12371
12392
|
*/
|
|
12372
|
-
update(
|
|
12393
|
+
update(props: WidgetProperties<T>): void;
|
|
12373
12394
|
/**
|
|
12374
12395
|
* Add a listener for a widget event.
|
|
12375
12396
|
* @param event Widget specific event name.
|
|
@@ -12685,4 +12706,4 @@ type ErrorType = {
|
|
|
12685
12706
|
};
|
|
12686
12707
|
};
|
|
12687
12708
|
|
|
12688
|
-
export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeSuccess, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyParams, BuyResult, BuyResultFailed, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CHECKOUT_API_BASE_URL, CancelParams, CancelResult, CancelResultFailed, CancelResultSuccess, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutStatus, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectResult, ConnectTargetLayer, ConnectWidgetConfiguration, ConnectWidgetParams, ConnectionFailed, ConnectionSuccess, DexConfig, ERC20ItemRequirement, ERC721Balance, ERC721ItemRequirement, ErrorType, ExchangeType, 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, 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, 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, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
|
|
12709
|
+
export { AllowedNetworkConfig, AvailableRoutingOptions, BalanceDelta, BridgeEventType, BridgeFailed, BridgeFundingStep, BridgeSuccess, BridgeWidgetConfiguration, BridgeWidgetParams, BuyOrder, BuyParams, BuyResult, BuyResultFailed, BuyResultInsufficientFunds, BuyResultSuccess, BuyToken, CHECKOUT_API_BASE_URL, CancelParams, CancelResult, CancelResultFailed, CancelResultSuccess, ChainId, ChainName, CheckConnectionParams, CheckConnectionResult, Checkout, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutStatus, CheckoutWidgetsConfig, ConnectEventType, ConnectParams, ConnectResult, ConnectTargetLayer, ConnectWidgetConfiguration, ConnectWidgetParams, ConnectionFailed, ConnectionSuccess, 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, 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, WalletDisconnectWalletEvent, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitchEvent, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
|
package/dist/checkout_sdk.js
CHANGED
|
@@ -20787,7 +20787,7 @@ class APIError extends Error {
|
|
|
20787
20787
|
|
|
20788
20788
|
/* eslint-disable implicit-arrow-linebreak */
|
|
20789
20789
|
const defaultHeaders = {
|
|
20790
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.
|
|
20790
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.28.7-alpha',
|
|
20791
20791
|
};
|
|
20792
20792
|
/**
|
|
20793
20793
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -21237,6 +21237,7 @@ var SaleEventType;
|
|
|
21237
21237
|
SaleEventType["SUCCESS"] = "success";
|
|
21238
21238
|
SaleEventType["FAILURE"] = "failure";
|
|
21239
21239
|
SaleEventType["REJECTED"] = "rejected";
|
|
21240
|
+
SaleEventType["TRANSACTION_SUCCESS"] = "transaction-success";
|
|
21240
21241
|
})(SaleEventType || (SaleEventType = {}));
|
|
21241
21242
|
|
|
21242
21243
|
/**
|
|
@@ -22405,6 +22406,9 @@ async function getERC20Balance(web3Provider, walletAddress, contractAddress) {
|
|
|
22405
22406
|
}
|
|
22406
22407
|
// Blockscout client singleton per chain id
|
|
22407
22408
|
const blockscoutClientMap = new Map();
|
|
22409
|
+
// This function is a utility function that can be used to reset the
|
|
22410
|
+
// blockscout map and therefore clear all the cache.
|
|
22411
|
+
const resetBlockscoutClientMap = () => blockscoutClientMap.clear();
|
|
22408
22412
|
const getIndexerBalance = async (walletAddress, chainId, filterTokens) => {
|
|
22409
22413
|
// Shuffle the mapping of the tokens configuration so it is a hashmap
|
|
22410
22414
|
// for faster access to tokens config objects.
|
|
@@ -22505,6 +22509,8 @@ const getBalances = async (config, web3Provider, walletAddress, tokens) => {
|
|
|
22505
22509
|
return { balances };
|
|
22506
22510
|
};
|
|
22507
22511
|
const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
22512
|
+
// eslint-disable-next-line no-param-reassign
|
|
22513
|
+
chainId ||= await web3Provider.getSigner().getChainId();
|
|
22508
22514
|
const { tokens } = await getTokenAllowList(config, {
|
|
22509
22515
|
type: TokenFilterTypes.ALL,
|
|
22510
22516
|
chainId,
|
|
@@ -22527,7 +22533,7 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
|
22527
22533
|
// Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
|
|
22528
22534
|
// is done.
|
|
22529
22535
|
const isL1Chain = getL1ChainId(config) === chainId;
|
|
22530
|
-
return measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens : []));
|
|
22536
|
+
return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens : []));
|
|
22531
22537
|
}
|
|
22532
22538
|
// This fallback to use ERC20s calls which is a best effort solution
|
|
22533
22539
|
// Fails in fetching data from the RCP calls might result in some
|
|
@@ -23401,18 +23407,15 @@ const getTokenBalanceRequirement = (itemRequirement, balances) => {
|
|
|
23401
23407
|
* Gets the balances for all NATIVE and ERC20 balance requirements.
|
|
23402
23408
|
*/
|
|
23403
23409
|
const getTokenBalances = async (config, provider, ownerAddress, itemRequirements) => {
|
|
23404
|
-
let tokenBalances = [];
|
|
23405
23410
|
try {
|
|
23406
|
-
const
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
|
|
23410
|
-
];
|
|
23411
|
+
const tokenMap = new Map();
|
|
23412
|
+
getTokensFromRequirements(itemRequirements).forEach((item) => tokenMap.set((item.address || '').toLocaleLowerCase(), item));
|
|
23413
|
+
const { balances } = await getAllBalances(config, provider, ownerAddress);
|
|
23414
|
+
return balances.filter((balance) => tokenMap.get((balance.token.address || '').toLocaleLowerCase()));
|
|
23411
23415
|
}
|
|
23412
23416
|
catch (error) {
|
|
23413
23417
|
throw new CheckoutError('Failed to get balances', CheckoutErrorType.GET_BALANCE_ERROR);
|
|
23414
23418
|
}
|
|
23415
|
-
return tokenBalances;
|
|
23416
23419
|
};
|
|
23417
23420
|
/**
|
|
23418
23421
|
* Gets the balances for all ERC721 balance requirements.
|
|
@@ -23459,53 +23462,56 @@ const getERC721Balances = async (provider, ownerAddress, itemRequirements) => {
|
|
|
23459
23462
|
*/
|
|
23460
23463
|
const balanceCheck = async (config, provider, ownerAddress, itemRequirements) => {
|
|
23461
23464
|
const aggregatedItems = balanceAggregator(itemRequirements);
|
|
23462
|
-
|
|
23463
|
-
|
|
23464
|
-
|
|
23465
|
-
|
|
23466
|
-
|
|
23465
|
+
const requiredToken = [];
|
|
23466
|
+
const requiredERC721 = [];
|
|
23467
|
+
aggregatedItems.forEach((item) => {
|
|
23468
|
+
switch (item.type) {
|
|
23469
|
+
case ItemType.ERC20:
|
|
23470
|
+
case ItemType.NATIVE:
|
|
23471
|
+
requiredToken.push(item);
|
|
23472
|
+
break;
|
|
23473
|
+
case ItemType.ERC721:
|
|
23474
|
+
requiredERC721.push(item);
|
|
23475
|
+
break;
|
|
23476
|
+
}
|
|
23477
|
+
});
|
|
23478
|
+
if (requiredERC721.length === 0 && requiredToken.length === 0) {
|
|
23467
23479
|
throw new CheckoutError('Unsupported item requirement balance check', CheckoutErrorType.UNSUPPORTED_BALANCE_REQUIREMENT_ERROR);
|
|
23468
23480
|
}
|
|
23469
23481
|
// Get all ERC20 and NATIVE balances
|
|
23470
|
-
const
|
|
23471
|
-
|
|
23472
|
-
.
|
|
23473
|
-
if (tokenItemRequirements.length > 0) {
|
|
23474
|
-
currentBalances.push(getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
23482
|
+
const balancePromises = [];
|
|
23483
|
+
if (requiredToken.length > 0) {
|
|
23484
|
+
balancePromises.push(getTokenBalances(config, provider, ownerAddress, aggregatedItems));
|
|
23475
23485
|
}
|
|
23476
23486
|
// Get all ERC721 balances
|
|
23477
|
-
|
|
23478
|
-
.
|
|
23479
|
-
if (erc721ItemRequirements.length > 0) {
|
|
23480
|
-
currentBalances.push(getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
23487
|
+
if (requiredERC721.length > 0) {
|
|
23488
|
+
balancePromises.push(getERC721Balances(provider, ownerAddress, aggregatedItems));
|
|
23481
23489
|
}
|
|
23482
23490
|
// Wait for all balances and calculate the requirements
|
|
23483
|
-
const
|
|
23484
|
-
|
|
23485
|
-
|
|
23486
|
-
|
|
23487
|
-
|
|
23488
|
-
|
|
23491
|
+
const promisesResponses = await Promise.all(balancePromises);
|
|
23492
|
+
const balanceRequirements = [];
|
|
23493
|
+
// Get all ERC20 and NATIVE balances
|
|
23494
|
+
if (requiredToken.length > 0 && promisesResponses.length > 0) {
|
|
23495
|
+
const result = promisesResponses.shift();
|
|
23496
|
+
if (result) {
|
|
23497
|
+
requiredToken.forEach((item) => {
|
|
23498
|
+
balanceRequirements.push(getTokenBalanceRequirement(item, result));
|
|
23489
23499
|
});
|
|
23490
|
-
if (erc721ItemRequirements.length > 0) {
|
|
23491
|
-
const erc721Balances = balances[1];
|
|
23492
|
-
erc721ItemRequirements.forEach((erc721ItemRequirement) => {
|
|
23493
|
-
requirements.push(getERC721BalanceRequirement(erc721ItemRequirement, erc721Balances));
|
|
23494
|
-
});
|
|
23495
|
-
}
|
|
23496
23500
|
}
|
|
23497
|
-
|
|
23498
|
-
|
|
23499
|
-
|
|
23500
|
-
|
|
23501
|
-
|
|
23501
|
+
}
|
|
23502
|
+
// Get all ERC721 balances
|
|
23503
|
+
if (requiredERC721.length > 0 && promisesResponses.length > 0) {
|
|
23504
|
+
const result = promisesResponses.shift();
|
|
23505
|
+
if (result) {
|
|
23506
|
+
requiredERC721.forEach((item) => {
|
|
23507
|
+
balanceRequirements.push(getERC721BalanceRequirement(item, result));
|
|
23502
23508
|
});
|
|
23503
23509
|
}
|
|
23504
|
-
|
|
23505
|
-
|
|
23506
|
-
|
|
23507
|
-
|
|
23508
|
-
|
|
23510
|
+
}
|
|
23511
|
+
// Find if there are any requirements that aren't sufficient.
|
|
23512
|
+
// If there is not item with sufficient === false then the requirements
|
|
23513
|
+
// are satisfied.
|
|
23514
|
+
const sufficient = balanceRequirements.find((req) => req.sufficient === false) === undefined;
|
|
23509
23515
|
return {
|
|
23510
23516
|
sufficient,
|
|
23511
23517
|
balanceRequirements,
|
|
@@ -24108,8 +24114,12 @@ const getBridgeFeeEstimate = async (config, readOnlyProviders) => {
|
|
|
24108
24114
|
// If the root address evaluates to this then its ETH
|
|
24109
24115
|
const INDEXER_ETH_ROOT_CONTRACT_ADDRESS = '0x0000000000000000000000000000000000000001';
|
|
24110
24116
|
const getIndexerChainName = (chainId) => {
|
|
24117
|
+
if (chainId === ChainId.IMTBL_ZKEVM_MAINNET)
|
|
24118
|
+
return 'imtbl-zkevm-mainnet';
|
|
24111
24119
|
if (chainId === ChainId.IMTBL_ZKEVM_TESTNET)
|
|
24112
24120
|
return 'imtbl-zkevm-testnet';
|
|
24121
|
+
if (chainId === ChainId.IMTBL_ZKEVM_DEVNET)
|
|
24122
|
+
return 'imtbl-zkevm-devent';
|
|
24113
24123
|
return '';
|
|
24114
24124
|
};
|
|
24115
24125
|
// Indexer ERC20 call does not support IMX so cannot get root chain mapping from this endpoint.
|
|
@@ -25108,18 +25118,26 @@ const getTransactionOrGas = (gasLimit, fulfillmentTransactions) => {
|
|
|
25108
25118
|
};
|
|
25109
25119
|
};
|
|
25110
25120
|
const buy = async (config, provider, orders) => {
|
|
25111
|
-
let orderbook;
|
|
25112
|
-
let order;
|
|
25113
|
-
let spenderAddress = '';
|
|
25114
|
-
const gasLimit = constants.estimatedFulfillmentGasGwei;
|
|
25115
25121
|
if (orders.length === 0) {
|
|
25116
25122
|
throw new CheckoutError('No orders were provided to the orders array. Please provide at least one order.', CheckoutErrorType.FULFILL_ORDER_LISTING_ERROR);
|
|
25117
25123
|
}
|
|
25124
|
+
let order;
|
|
25125
|
+
let spenderAddress = '';
|
|
25126
|
+
let decimals = 18;
|
|
25127
|
+
const gasLimit = constants.estimatedFulfillmentGasGwei;
|
|
25128
|
+
const orderbook = createOrderbookInstance(config);
|
|
25129
|
+
const blockchainClient = createBlockchainDataInstance(config);
|
|
25130
|
+
const fulfillerAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
|
|
25131
|
+
// Prefetch balances and store them in memory
|
|
25132
|
+
resetBlockscoutClientMap();
|
|
25133
|
+
getAllBalances(config, provider, fulfillerAddress, getL1ChainId(config));
|
|
25134
|
+
getAllBalances(config, provider, fulfillerAddress, getL2ChainId(config));
|
|
25118
25135
|
const { id, takerFees } = orders[0];
|
|
25136
|
+
let orderChainName;
|
|
25119
25137
|
try {
|
|
25120
|
-
orderbook = createOrderbookInstance(config);
|
|
25121
25138
|
order = await measureAsyncExecution(config, 'Time to fetch the listing from the orderbook', orderbook.getListing(id));
|
|
25122
|
-
const { seaportContractAddress } = orderbook.config();
|
|
25139
|
+
const { seaportContractAddress, chainName } = orderbook.config();
|
|
25140
|
+
orderChainName = chainName;
|
|
25123
25141
|
spenderAddress = seaportContractAddress;
|
|
25124
25142
|
}
|
|
25125
25143
|
catch (err) {
|
|
@@ -25135,10 +25153,10 @@ const buy = async (config, provider, orders) => {
|
|
|
25135
25153
|
});
|
|
25136
25154
|
}
|
|
25137
25155
|
const buyToken = order.result.buy[0];
|
|
25138
|
-
|
|
25139
|
-
|
|
25140
|
-
|
|
25141
|
-
|
|
25156
|
+
if (buyToken.type === 'ERC20') {
|
|
25157
|
+
const token = await measureAsyncExecution(config, 'Time to get decimals of token contract for the buy token', blockchainClient.getToken({ contractAddress: buyToken.contractAddress, chainName: orderChainName }));
|
|
25158
|
+
if (token.result.decimals)
|
|
25159
|
+
decimals = token.result.decimals;
|
|
25142
25160
|
}
|
|
25143
25161
|
let fees = [];
|
|
25144
25162
|
if (takerFees && takerFees.length > 0) {
|
|
@@ -25149,7 +25167,6 @@ const buy = async (config, provider, orders) => {
|
|
|
25149
25167
|
let orderActions = [];
|
|
25150
25168
|
const fulfillOrderStartTime = performance.now();
|
|
25151
25169
|
try {
|
|
25152
|
-
const fulfillerAddress = await measureAsyncExecution(config, 'Time to get the address from the provider', provider.getSigner().getAddress());
|
|
25153
25170
|
const { actions } = await measureAsyncExecution(config, 'Time to call fulfillOrder from the orderbook', orderbook.fulfillOrder(id, fulfillerAddress, fees));
|
|
25154
25171
|
orderActions = actions;
|
|
25155
25172
|
unsignedApprovalTransactions = await measureAsyncExecution(config, 'Time to construct the unsigned approval transactions', getUnsignedERC20ApprovalTransactions(actions));
|
|
@@ -25487,7 +25504,7 @@ async function getItemRequirementsFromRequirements(provider, requirements) {
|
|
|
25487
25504
|
return itemRequirements;
|
|
25488
25505
|
}
|
|
25489
25506
|
|
|
25490
|
-
const SDK_VERSION_MARKER = '0.28.
|
|
25507
|
+
const SDK_VERSION_MARKER = '0.28.7-alpha';
|
|
25491
25508
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
25492
25509
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
25493
25510
|
|
|
@@ -25648,11 +25665,7 @@ class Checkout {
|
|
|
25648
25665
|
async connect(params) {
|
|
25649
25666
|
const web3Provider = await validateProvider(this.config, params.provider, { allowUnsupportedProvider: true });
|
|
25650
25667
|
await connectSite(web3Provider);
|
|
25651
|
-
|
|
25652
|
-
return {
|
|
25653
|
-
provider: web3Provider,
|
|
25654
|
-
network: networkInfo,
|
|
25655
|
-
};
|
|
25668
|
+
return { provider: web3Provider };
|
|
25656
25669
|
}
|
|
25657
25670
|
/**
|
|
25658
25671
|
* Switches the network for the current wallet provider.
|
|
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
17
17
|
chainID,
|
|
18
18
|
coreContractAddress,
|
|
19
19
|
registrationContractAddress,
|
|
20
|
-
sdkVersion: 'ts-immutable-sdk-0.28.
|
|
20
|
+
sdkVersion: 'ts-immutable-sdk-0.28.7-alpha',
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
23
23
|
* Sets `sdkVersion` at the time of build
|