@imtbl/sdk 0.33.0 → 0.34.0
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 +3 -3
- package/dist/browser/checkout/widgets.js +56 -56
- package/dist/checkout.d.ts +11 -18
- package/dist/checkout.js +26 -23
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +11 -11
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +116 -216
- package/dist/index.d.ts +23 -11
- package/dist/index.js +117 -217
- package/dist/orderbook.d.ts +9 -1
- package/dist/orderbook.js +3 -1
- package/dist/passport.d.ts +10 -10
- package/dist/passport.js +91 -194
- package/package.json +1 -1
package/dist/checkout.d.ts
CHANGED
|
@@ -10488,7 +10488,7 @@ declare enum Networks {
|
|
|
10488
10488
|
}
|
|
10489
10489
|
interface OidcConfiguration {
|
|
10490
10490
|
clientId: string;
|
|
10491
|
-
logoutRedirectUri
|
|
10491
|
+
logoutRedirectUri?: string;
|
|
10492
10492
|
logoutMode?: 'redirect' | 'silent';
|
|
10493
10493
|
redirectUri: string;
|
|
10494
10494
|
scope?: string;
|
|
@@ -10521,13 +10521,6 @@ type DeviceConnectResponse = {
|
|
|
10521
10521
|
url: string;
|
|
10522
10522
|
interval: number;
|
|
10523
10523
|
};
|
|
10524
|
-
type DeviceTokenResponse = {
|
|
10525
|
-
access_token: string;
|
|
10526
|
-
refresh_token?: string;
|
|
10527
|
-
id_token: string;
|
|
10528
|
-
token_type: string;
|
|
10529
|
-
expires_in: number;
|
|
10530
|
-
};
|
|
10531
10524
|
|
|
10532
10525
|
/**
|
|
10533
10526
|
* ProviderErrors should take priority over RpcErrorCodes
|
|
@@ -10597,14 +10590,8 @@ declare class Passport {
|
|
|
10597
10590
|
*/
|
|
10598
10591
|
connectImxSilent(): Promise<IMXProvider | null>;
|
|
10599
10592
|
connectImx(): Promise<IMXProvider>;
|
|
10600
|
-
connectImxDeviceFlow(deviceCode: string, interval: number, timeoutMs?: number): Promise<IMXProvider | null>;
|
|
10601
10593
|
getPKCEAuthorizationUrl(): string;
|
|
10602
10594
|
connectImxPKCEFlow(authorizationCode: string, state: string): Promise<IMXProvider | null>;
|
|
10603
|
-
/**
|
|
10604
|
-
* @returns {boolean} the stored device flow credentials if they exist
|
|
10605
|
-
*/
|
|
10606
|
-
checkStoredDeviceFlowCredentials(): DeviceTokenResponse | null;
|
|
10607
|
-
connectImxWithCredentials(tokenResponse: DeviceTokenResponse): Promise<IMXProvider | null>;
|
|
10608
10595
|
connectEvm(): Provider;
|
|
10609
10596
|
/**
|
|
10610
10597
|
*
|
|
@@ -10617,17 +10604,23 @@ declare class Passport {
|
|
|
10617
10604
|
login(options?: {
|
|
10618
10605
|
useCachedSession: boolean;
|
|
10619
10606
|
}): Promise<UserProfile | null>;
|
|
10620
|
-
loginWithDeviceFlow(): Promise<DeviceConnectResponse>;
|
|
10621
10607
|
loginCallback(): Promise<void>;
|
|
10608
|
+
loginWithDeviceFlow(): Promise<DeviceConnectResponse>;
|
|
10609
|
+
loginWithDeviceFlowCallback(deviceCode: string, interval: number, timeoutMs?: number): Promise<UserProfile>;
|
|
10622
10610
|
logout(): Promise<void>;
|
|
10611
|
+
/**
|
|
10612
|
+
* Logs the user out of Passport when using device flow authentication.
|
|
10613
|
+
*
|
|
10614
|
+
* @returns {Promise<string>} The device flow end session endpoint. Consumers are responsible for
|
|
10615
|
+
* opening this URL in the same browser that was used to log the user in.
|
|
10616
|
+
*/
|
|
10617
|
+
logoutDeviceFlow(): Promise<string>;
|
|
10623
10618
|
/**
|
|
10624
10619
|
* This method should only be called from the logout redirect uri
|
|
10625
10620
|
* when logout mode is 'silent'.
|
|
10626
10621
|
*/
|
|
10627
10622
|
logoutSilentCallback(url: string): Promise<void>;
|
|
10628
|
-
logoutDeviceFlow(): Promise<void>;
|
|
10629
10623
|
getUserInfo(): Promise<UserProfile | undefined>;
|
|
10630
|
-
getUserInfoDeviceFlow(): Promise<UserProfile | undefined>;
|
|
10631
10624
|
getIdToken(): Promise<string | undefined>;
|
|
10632
10625
|
getAccessToken(): Promise<string | undefined>;
|
|
10633
10626
|
getLinkedAddresses(): Promise<string[]>;
|
|
@@ -12970,4 +12963,4 @@ declare const CHECKOUT_API_BASE_URL: {
|
|
|
12970
12963
|
production: string;
|
|
12971
12964
|
};
|
|
12972
12965
|
|
|
12973
|
-
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, CheckoutBridgeConfiguration, CheckoutConfiguration, CheckoutErrorType, CheckoutModuleConfiguration, CheckoutOnRampConfiguration, CheckoutStatus, CheckoutSwapConfiguration, 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, WalletDisconnect, WalletEventType, WalletFilter, WalletFilterTypes, WalletInfo, WalletNetworkSwitch, WalletProviderName, WalletWidgetConfiguration, WalletWidgetParams, Widget, WidgetConfiguration, WidgetConfigurations, WidgetEvent, WidgetEventData, WidgetEventTypes, WidgetParameters, WidgetProperties, WidgetTheme, WidgetType };
|
|
12966
|
+
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, 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, 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
|
@@ -14717,6 +14717,21 @@ const getCallData = (methodName, contractInterface) => {
|
|
|
14717
14717
|
return fragment ? contractInterface?.encodeFunctionData(fragment) : undefined;
|
|
14718
14718
|
};
|
|
14719
14719
|
|
|
14720
|
+
// 0.1% default slippage
|
|
14721
|
+
const DEFAULT_SLIPPAGE = 0.1;
|
|
14722
|
+
// 15 minutes from the time the transaction was prepared
|
|
14723
|
+
const DEFAULT_DEADLINE_SECONDS = 60 * 15;
|
|
14724
|
+
// most swaps will be able to resolve with 2 hops
|
|
14725
|
+
const DEFAULT_MAX_HOPS = 2;
|
|
14726
|
+
// after 10 hops, it is very unlikely a route will be available
|
|
14727
|
+
const MAX_MAX_HOPS = 10;
|
|
14728
|
+
// a max hop of 1 will require a direct swap with no intermediary pools
|
|
14729
|
+
const MIN_MAX_HOPS = 1;
|
|
14730
|
+
// precision used to calculate percentage from basis points
|
|
14731
|
+
const BASIS_POINT_PRECISION = 10000;
|
|
14732
|
+
// 10% maximum secondary fee
|
|
14733
|
+
const MAX_SECONDARY_FEE_BASIS_POINTS = 1000;
|
|
14734
|
+
|
|
14720
14735
|
const quoteReturnMapping = {
|
|
14721
14736
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
14722
14737
|
'0xcdca1753': ['uint256', 'uint160[]', 'uint32[]', 'uint256'],
|
|
@@ -14851,6 +14866,7 @@ const toPublicAmount = (amount) => ({
|
|
|
14851
14866
|
token: toPublicTokenType(amount.token),
|
|
14852
14867
|
value: amount.value,
|
|
14853
14868
|
});
|
|
14869
|
+
const getDefaultDeadlineSeconds = () => Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS;
|
|
14854
14870
|
|
|
14855
14871
|
const amountIndex = 0;
|
|
14856
14872
|
const gasEstimateIndex = 3;
|
|
@@ -15349,21 +15365,6 @@ fees, tradeType, nativeTokenService) {
|
|
|
15349
15365
|
return nativeTokenService.maybeWrapAmount(fees.amountLessFees());
|
|
15350
15366
|
}
|
|
15351
15367
|
|
|
15352
|
-
// 0.1% default slippage
|
|
15353
|
-
const DEFAULT_SLIPPAGE = 0.1;
|
|
15354
|
-
// 15 minutes from the current Unix time
|
|
15355
|
-
const DEFAULT_DEADLINE = Math.floor(Date.now() / 1000) + 60 * 15;
|
|
15356
|
-
// most swaps will be able to resolve with 2 hops
|
|
15357
|
-
const DEFAULT_MAX_HOPS = 2;
|
|
15358
|
-
// after 10 hops, it is very unlikely a route will be available
|
|
15359
|
-
const MAX_MAX_HOPS = 10;
|
|
15360
|
-
// a max hop of 1 will require a direct swap with no intermediary pools
|
|
15361
|
-
const MIN_MAX_HOPS = 1;
|
|
15362
|
-
// precision used to calculate percentage from basis points
|
|
15363
|
-
const BASIS_POINT_PRECISION = 10000;
|
|
15364
|
-
// 10% maximum secondary fee
|
|
15365
|
-
const MAX_SECONDARY_FEE_BASIS_POINTS = 1000;
|
|
15366
|
-
|
|
15367
15368
|
class Fees {
|
|
15368
15369
|
secondaryFees;
|
|
15369
15370
|
amount;
|
|
@@ -15908,7 +15909,7 @@ class Exchange {
|
|
|
15908
15909
|
* @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
|
|
15909
15910
|
* @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
|
|
15910
15911
|
*/
|
|
15911
|
-
async getUnsignedSwapTxFromAmountIn(fromAddress, tokenInAddress, tokenOutAddress, amountIn, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline =
|
|
15912
|
+
async getUnsignedSwapTxFromAmountIn(fromAddress, tokenInAddress, tokenOutAddress, amountIn, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = getDefaultDeadlineSeconds()) {
|
|
15912
15913
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.BigNumber.from(amountIn), slippagePercent, maxHops, deadline, TradeType.EXACT_INPUT);
|
|
15913
15914
|
}
|
|
15914
15915
|
/**
|
|
@@ -15924,7 +15925,7 @@ class Exchange {
|
|
|
15924
15925
|
* @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
|
|
15925
15926
|
* @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
|
|
15926
15927
|
*/
|
|
15927
|
-
async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline =
|
|
15928
|
+
async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = getDefaultDeadlineSeconds()) {
|
|
15928
15929
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.BigNumber.from(amountOut), slippagePercent, maxHops, deadline, TradeType.EXACT_OUTPUT);
|
|
15929
15930
|
}
|
|
15930
15931
|
}
|
|
@@ -16349,7 +16350,7 @@ class OrdersService {
|
|
|
16349
16350
|
* @returns ListListingsResult OK response.
|
|
16350
16351
|
* @throws ApiError
|
|
16351
16352
|
*/
|
|
16352
|
-
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
16353
|
+
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, accountAddress, sellItemMetadataId, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
16353
16354
|
return this.httpRequest.request({
|
|
16354
16355
|
method: 'GET',
|
|
16355
16356
|
url: '/v1/chains/{chain_name}/orders/listings',
|
|
@@ -16360,6 +16361,8 @@ class OrdersService {
|
|
|
16360
16361
|
'status': status,
|
|
16361
16362
|
'sell_item_contract_address': sellItemContractAddress,
|
|
16362
16363
|
'buy_item_contract_address': buyItemContractAddress,
|
|
16364
|
+
'account_address': accountAddress,
|
|
16365
|
+
'sell_item_metadata_id': sellItemMetadataId,
|
|
16363
16366
|
'sell_item_token_id': sellItemTokenId,
|
|
16364
16367
|
'from_updated_at': fromUpdatedAt,
|
|
16365
16368
|
'page_size': pageSize,
|
|
@@ -20984,7 +20987,7 @@ class APIError extends Error {
|
|
|
20984
20987
|
|
|
20985
20988
|
/* eslint-disable implicit-arrow-linebreak */
|
|
20986
20989
|
const defaultHeaders = {
|
|
20987
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
20990
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.34.0',
|
|
20988
20991
|
};
|
|
20989
20992
|
/**
|
|
20990
20993
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -22261,7 +22264,7 @@ const GAS_OVERRIDES = {
|
|
|
22261
22264
|
maxPriorityFeePerGas: BigNumber$1.from(101e9),
|
|
22262
22265
|
};
|
|
22263
22266
|
|
|
22264
|
-
const SDK_VERSION_MARKER = '0.
|
|
22267
|
+
const SDK_VERSION_MARKER = '0.34.0';
|
|
22265
22268
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
22266
22269
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
22267
22270
|
|
|
@@ -22620,8 +22623,8 @@ const resetBlockscoutClientMap = () => blockscoutClientMap.clear();
|
|
|
22620
22623
|
const getIndexerBalance = async (walletAddress, chainId, filterTokens) => {
|
|
22621
22624
|
// Shuffle the mapping of the tokens configuration so it is a hashmap
|
|
22622
22625
|
// for faster access to tokens config objects.
|
|
22623
|
-
const shouldFilter = filterTokens
|
|
22624
|
-
const mapFilterTokens = Object.assign({}, ...(filterTokens.map((t) => ({ [t.address || NATIVE]: t }))));
|
|
22626
|
+
const shouldFilter = filterTokens !== undefined;
|
|
22627
|
+
const mapFilterTokens = Object.assign({}, ...((filterTokens ?? []).map((t) => ({ [t.address || NATIVE]: t }))));
|
|
22625
22628
|
// Get blockscout client for the given chain
|
|
22626
22629
|
let blockscoutClient = blockscoutClientMap.get(chainId);
|
|
22627
22630
|
if (!blockscoutClient) {
|
|
@@ -22741,7 +22744,7 @@ const getAllBalances = async (config, web3Provider, walletAddress, chainId) => {
|
|
|
22741
22744
|
// Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
|
|
22742
22745
|
// is done.
|
|
22743
22746
|
const isL1Chain = getL1ChainId(config) === chainId;
|
|
22744
|
-
return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens :
|
|
22747
|
+
return await measureAsyncExecution(config, `Time to fetch balances using blockscout for ${chainId}`, getIndexerBalance(walletAddress, chainId, isL1Chain ? tokens : undefined));
|
|
22745
22748
|
}
|
|
22746
22749
|
// This fallback to use ERC20s calls which is a best effort solution
|
|
22747
22750
|
// Fails in fetching data from the RCP calls might result in some
|
|
@@ -17,7 +17,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
17
17
|
chainID,
|
|
18
18
|
coreContractAddress,
|
|
19
19
|
registrationContractAddress,
|
|
20
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
20
|
+
sdkVersion: 'ts-immutable-sdk-0.34.0',
|
|
21
21
|
});
|
|
22
22
|
/**
|
|
23
23
|
* Sets `sdkVersion` at the time of build
|