@imtbl/sdk 0.17.4 → 0.17.6
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.js +2 -2
- package/dist/checkout_sdk.d.ts +10 -1
- package/dist/checkout_sdk.js +3114 -62
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +15 -15
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +268 -53
- package/dist/index.d.ts +10 -1
- package/dist/index.js +268 -53
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2702,7 +2702,7 @@ class MultiRollupApiClients {
|
|
|
2702
2702
|
}
|
|
2703
2703
|
|
|
2704
2704
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2705
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.
|
|
2705
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.6' };
|
|
2706
2706
|
const createConfig = ({ basePath, headers, }) => {
|
|
2707
2707
|
if (!basePath.trim()) {
|
|
2708
2708
|
throw Error('basePath can not be empty');
|
|
@@ -2762,7 +2762,7 @@ class APIError extends Error {
|
|
|
2762
2762
|
|
|
2763
2763
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2764
2764
|
const defaultHeaders = {
|
|
2765
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.
|
|
2765
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.6',
|
|
2766
2766
|
};
|
|
2767
2767
|
/**
|
|
2768
2768
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -3048,7 +3048,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
3048
3048
|
chainID,
|
|
3049
3049
|
coreContractAddress,
|
|
3050
3050
|
registrationContractAddress,
|
|
3051
|
-
sdkVersion: 'ts-immutable-sdk-0.17.
|
|
3051
|
+
sdkVersion: 'ts-immutable-sdk-0.17.6',
|
|
3052
3052
|
});
|
|
3053
3053
|
/**
|
|
3054
3054
|
* Sets `sdkVersion` at the time of build
|
|
@@ -27810,6 +27810,7 @@ var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
|
27810
27810
|
CheckoutErrorType["EXECUTE_APPROVAL_TRANSACTION_ERROR"] = "EXECUTE_APPROVAL_TRANSACTION_ERROR";
|
|
27811
27811
|
CheckoutErrorType["EXECUTE_FULFILMENT_TRANSACTION_ERROR"] = "EXECUTE_FULFILMENT_TRANSACTION_ERROR";
|
|
27812
27812
|
CheckoutErrorType["SIGN_MESSAGE_ERROR"] = "SIGN_MESSAGE_ERROR";
|
|
27813
|
+
CheckoutErrorType["BRIDGE_GAS_ESTIMATE_ERROR"] = "BRIDGE_GAS_ESTIMATE_ERROR";
|
|
27813
27814
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
27814
27815
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
27815
27816
|
message;
|
|
@@ -28617,6 +28618,7 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
|
|
|
28617
28618
|
|
|
28618
28619
|
|
|
28619
28620
|
|
|
28621
|
+
|
|
28620
28622
|
async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config) {
|
|
28621
28623
|
const rootChainProvider = readOnlyProviders.get(fromChainId);
|
|
28622
28624
|
const childChainProvider = readOnlyProviders.get(toChainId);
|
|
@@ -28652,6 +28654,13 @@ async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
|
|
|
28652
28654
|
}
|
|
28653
28655
|
});
|
|
28654
28656
|
}
|
|
28657
|
+
function $67fc622a2b913d5f$export$436dd76f23f463ff(config) {
|
|
28658
|
+
return new (BlockchainData)({
|
|
28659
|
+
baseConfig: {
|
|
28660
|
+
environment: config.environment
|
|
28661
|
+
}
|
|
28662
|
+
});
|
|
28663
|
+
}
|
|
28655
28664
|
|
|
28656
28665
|
|
|
28657
28666
|
|
|
@@ -29405,8 +29414,8 @@ const $7d1bfafb81e64d74$export$3a4140bd9e983e4e = async (provider, insufficientI
|
|
|
29405
29414
|
|
|
29406
29415
|
|
|
29407
29416
|
|
|
29408
|
-
const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>
|
|
29409
|
-
const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>
|
|
29417
|
+
const $1fda5c40669a566d$export$1fac8e857d728583 = async ()=>false;
|
|
29418
|
+
const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>false;
|
|
29410
29419
|
|
|
29411
29420
|
|
|
29412
29421
|
const $7f2e17f026d4fc8d$var$isPassportProvider = (provider)=>(provider.provider?.isPassport === true) ?? false;
|
|
@@ -29442,43 +29451,30 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
|
|
|
29442
29451
|
|
|
29443
29452
|
|
|
29444
29453
|
|
|
29454
|
+
var $b23305044c0e096a$export$3057de18ac0c076;
|
|
29455
|
+
(function(RouteCalculatorType) {
|
|
29456
|
+
RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
29457
|
+
RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
|
|
29458
|
+
RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
|
|
29459
|
+
})($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
|
|
29460
|
+
var $b23305044c0e096a$export$3af78bb3e8650ee6;
|
|
29461
|
+
(function(FundingRouteType) {
|
|
29462
|
+
FundingRouteType["BRIDGE"] = "BRIDGE";
|
|
29463
|
+
FundingRouteType["ON_RAMP"] = "ONRAMP";
|
|
29464
|
+
FundingRouteType["SWAP"] = "SWAP";
|
|
29465
|
+
})($b23305044c0e096a$export$3af78bb3e8650ee6 || ($b23305044c0e096a$export$3af78bb3e8650ee6 = {}));
|
|
29445
29466
|
|
|
29446
29467
|
|
|
29447
29468
|
|
|
29448
29469
|
|
|
29449
29470
|
|
|
29450
|
-
|
|
29451
|
-
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
29452
|
-
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
29453
|
-
const readOnlyProviders = new Map();
|
|
29454
|
-
const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
|
|
29455
|
-
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
29456
|
-
});
|
|
29457
|
-
allowedNetworks.networks.forEach((networkInfo)=>{
|
|
29458
|
-
const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
|
|
29459
|
-
const provider = new (JsonRpcProvider)(rpcUrl);
|
|
29460
|
-
readOnlyProviders.set(networkInfo.chainId, provider);
|
|
29461
|
-
});
|
|
29462
|
-
return readOnlyProviders;
|
|
29463
|
-
}
|
|
29464
|
-
|
|
29465
|
-
|
|
29466
|
-
|
|
29467
|
-
|
|
29468
|
-
const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, availableRoutingOptions)=>{
|
|
29471
|
+
const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, readOnlyProviders, ownerAddress, availableRoutingOptions)=>{
|
|
29469
29472
|
const chainBalances = new Map();
|
|
29470
29473
|
const chainBalancePromises = new Map();
|
|
29471
|
-
let readOnlyProviders = new Map();
|
|
29472
|
-
let providerError;
|
|
29473
|
-
try {
|
|
29474
|
-
readOnlyProviders = await (0, $0e0060cb42e136d2$export$339cb2be73677b30)(config);
|
|
29475
|
-
} catch (error) {
|
|
29476
|
-
providerError = error;
|
|
29477
|
-
}
|
|
29478
29474
|
if (readOnlyProviders.size === 0) {
|
|
29479
29475
|
const noProviderResult = {
|
|
29480
29476
|
success: false,
|
|
29481
|
-
error:
|
|
29477
|
+
error: new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 or L2 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR),
|
|
29482
29478
|
balances: []
|
|
29483
29479
|
};
|
|
29484
29480
|
chainBalances.set(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config), noProviderResult);
|
|
@@ -29522,44 +29518,263 @@ const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, av
|
|
|
29522
29518
|
};
|
|
29523
29519
|
|
|
29524
29520
|
|
|
29521
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
29522
|
+
|
|
29523
|
+
|
|
29524
|
+
|
|
29525
|
+
|
|
29526
|
+
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
29527
|
+
for (const balance of balances.balances){
|
|
29528
|
+
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
29529
|
+
}
|
|
29530
|
+
return (BigNumber$1).from(0);
|
|
29531
|
+
};
|
|
29532
|
+
|
|
29533
|
+
|
|
29534
|
+
|
|
29535
|
+
|
|
29536
|
+
|
|
29537
|
+
|
|
29538
|
+
const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProviders)=>{
|
|
29539
|
+
try {
|
|
29540
|
+
const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
|
|
29541
|
+
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
29542
|
+
isSpendingCapApprovalRequired: false
|
|
29543
|
+
}, readOnlyProviders, config);
|
|
29544
|
+
const gasEstimate = estimate.gasFee.estimatedAmount;
|
|
29545
|
+
const bridgeFee = estimate.bridgeFee.estimatedAmount;
|
|
29546
|
+
let totalFees = (0, BigNumber$1).from(0);
|
|
29547
|
+
if (gasEstimate) totalFees = totalFees.add(gasEstimate);
|
|
29548
|
+
if (bridgeFee) totalFees = totalFees.add(bridgeFee);
|
|
29549
|
+
return totalFees;
|
|
29550
|
+
} catch (err) {
|
|
29551
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
29552
|
+
message: err.message
|
|
29553
|
+
});
|
|
29554
|
+
}
|
|
29555
|
+
};
|
|
29556
|
+
|
|
29557
|
+
|
|
29558
|
+
|
|
29559
|
+
const $823db9fb0ca4bc15$export$c37d8687c27b9660 = "0x0000000000000000000000000000000000000001";
|
|
29560
|
+
const $823db9fb0ca4bc15$export$1430626eec86fce9 = (chainId)=>{
|
|
29561
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET) return "imtbl-zkevm-testnet";
|
|
29562
|
+
return "";
|
|
29563
|
+
};
|
|
29564
|
+
const $823db9fb0ca4bc15$export$53e663abd9b77fc1 = (chainId)=>{
|
|
29565
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA) return "0x2Fa06C6672dDCc066Ab04631192738799231dE4a";
|
|
29566
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM) return "0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF";
|
|
29567
|
+
return "";
|
|
29568
|
+
};
|
|
29569
|
+
|
|
29570
|
+
|
|
29571
|
+
|
|
29572
|
+
|
|
29573
|
+
|
|
29574
|
+
|
|
29575
|
+
|
|
29576
|
+
const $07ac9c0576988336$export$7847f5f5cce25dfa = async (config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, token, depositAmount)=>{
|
|
29577
|
+
try {
|
|
29578
|
+
const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config);
|
|
29579
|
+
const { unsignedTx: unsignedTx } = await tokenBridge.getUnsignedApproveDepositBridgeTx({
|
|
29580
|
+
depositorAddress: depositorAddress,
|
|
29581
|
+
token: token,
|
|
29582
|
+
depositAmount: depositAmount
|
|
29583
|
+
});
|
|
29584
|
+
if (unsignedTx === null) return (0, BigNumber$1).from(0);
|
|
29585
|
+
return await l1provider.estimateGas(unsignedTx);
|
|
29586
|
+
} catch (err) {
|
|
29587
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while attempting ot estimate gas for approval transaction", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
29588
|
+
message: err.message
|
|
29589
|
+
});
|
|
29590
|
+
}
|
|
29591
|
+
};
|
|
29592
|
+
const $07ac9c0576988336$export$a3dd181de896b7c7 = async (config, readOnlyProviders, l1provider, depositorAddress, l1Address, delta)=>{
|
|
29593
|
+
if (l1Address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) return (BigNumber$1).from(0); // Native ETH does not require approval
|
|
29594
|
+
const fromChainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
29595
|
+
const toChainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
|
|
29596
|
+
return await $07ac9c0576988336$export$7847f5f5cce25dfa(config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, l1Address, delta);
|
|
29597
|
+
};
|
|
29598
|
+
|
|
29599
|
+
|
|
29600
|
+
|
|
29601
|
+
|
|
29602
|
+
const $5a5ccedc98d53d25$var$filterTokens = (allowedTokens, balances)=>{
|
|
29603
|
+
if (balances && balances.success) return allowedTokens.filter((token)=>{
|
|
29604
|
+
if ("address" in token) return balances.balances.find((balance)=>balance.token.address === token.address && balance.balance.gt(0));
|
|
29605
|
+
return balances.balances.find((balance)=>!("address" in balance.token) && balance.balance.gt(0));
|
|
29606
|
+
});
|
|
29607
|
+
return [];
|
|
29608
|
+
};
|
|
29609
|
+
const $5a5ccedc98d53d25$export$d744af9f1c0712bc = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
29610
|
+
if (availableRoutingOptions.bridge) {
|
|
29611
|
+
const allowedTokens = (await config.remote.getConfig("bridge"))?.tokens ?? [];
|
|
29612
|
+
const balances = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
29613
|
+
return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
|
|
29614
|
+
}
|
|
29615
|
+
return [];
|
|
29616
|
+
};
|
|
29617
|
+
|
|
29618
|
+
|
|
29619
|
+
const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (balances, totalFees)=>{
|
|
29620
|
+
const balance = ($f730af3b727f04ac$export$22fea095b15361de)(balances);
|
|
29621
|
+
return balance.gte(totalFees);
|
|
29622
|
+
};
|
|
29623
|
+
const $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f = (balanceRequirement)=>{
|
|
29624
|
+
if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return $d85ad1457a3f1a83$export$b80040cb173ba6e9;
|
|
29625
|
+
if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return balanceRequirement.required.token.address ?? "";
|
|
29626
|
+
return "";
|
|
29627
|
+
};
|
|
29628
|
+
const $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6 = async (config, balanceRequirement)=>{
|
|
29629
|
+
const l2address = $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f(balanceRequirement);
|
|
29630
|
+
if (l2address === "") return "";
|
|
29631
|
+
if (l2address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) return ($823db9fb0ca4bc15$export$53e663abd9b77fc1)(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
29632
|
+
const chainName = ($823db9fb0ca4bc15$export$1430626eec86fce9)(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
29633
|
+
if (chainName === "") return ""; // Chain name not a valid indexer chain name
|
|
29634
|
+
const blockchainData = ($67fc622a2b913d5f$export$436dd76f23f463ff)(config);
|
|
29635
|
+
const tokenData = await blockchainData.getToken({
|
|
29636
|
+
chainName: chainName,
|
|
29637
|
+
contractAddress: l2address
|
|
29638
|
+
});
|
|
29639
|
+
const l1address = tokenData.result.root_contract_address;
|
|
29640
|
+
if (l1address === null) return ""; // No L1 representation of this token
|
|
29641
|
+
return l1address;
|
|
29642
|
+
};
|
|
29643
|
+
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
29644
|
+
let bridgeFeeEstimate = feeEstimates.get(($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE);
|
|
29645
|
+
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
29646
|
+
bridgeFeeEstimate = await ($8a49d1a3783a2640$export$3aff971444a4f244)(config, readOnlyProviders);
|
|
29647
|
+
feeEstimates.set(($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE, bridgeFeeEstimate);
|
|
29648
|
+
return bridgeFeeEstimate;
|
|
29649
|
+
};
|
|
29650
|
+
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
29651
|
+
type: ($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE,
|
|
29652
|
+
chainId: chainId,
|
|
29653
|
+
asset: {
|
|
29654
|
+
balance: balance.balance,
|
|
29655
|
+
formattedBalance: balance.formattedBalance,
|
|
29656
|
+
token: {
|
|
29657
|
+
name: balance.token.name,
|
|
29658
|
+
symbol: balance.token.symbol,
|
|
29659
|
+
address: balance.token.address,
|
|
29660
|
+
decimals: balance.token.decimals
|
|
29661
|
+
}
|
|
29662
|
+
}
|
|
29663
|
+
});
|
|
29664
|
+
const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
|
|
29665
|
+
if (!address || address === "") return true;
|
|
29666
|
+
return false;
|
|
29667
|
+
};
|
|
29668
|
+
const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProviders, depositorAddress, availableRoutingOptions, balanceRequirement, balances, feeEstimates)=>{
|
|
29669
|
+
if (!availableRoutingOptions.bridge) return undefined;
|
|
29670
|
+
const chainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
29671
|
+
const tokenBalanceResult = balances.get(chainId);
|
|
29672
|
+
const l1provider = readOnlyProviders.get(chainId);
|
|
29673
|
+
if (!l1provider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
|
|
29674
|
+
chainId: chainId.toString()
|
|
29675
|
+
});
|
|
29676
|
+
// If no balances on layer 1 then Bridge cannot be an option
|
|
29677
|
+
if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) return undefined;
|
|
29678
|
+
const allowedTokenList = await ($5a5ccedc98d53d25$export$d744af9f1c0712bc)(config, balances, availableRoutingOptions);
|
|
29679
|
+
if (allowedTokenList.length === 0) return undefined;
|
|
29680
|
+
const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
|
|
29681
|
+
// If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
|
|
29682
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
|
|
29683
|
+
const l1address = await $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6(config, balanceRequirement);
|
|
29684
|
+
if (l1address === "") return undefined;
|
|
29685
|
+
// Ensure l1address is in the allowed token list
|
|
29686
|
+
if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
|
|
29687
|
+
if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
|
|
29688
|
+
} else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
|
|
29689
|
+
const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, balanceRequirement.delta.balance);
|
|
29690
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
|
|
29691
|
+
// If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
|
|
29692
|
+
if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
|
|
29693
|
+
const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
|
|
29694
|
+
if (nativeETHBalance && nativeETHBalance.balance.gte(balanceRequirement.delta.balance.add(bridgeFeeEstimate))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance);
|
|
29695
|
+
return undefined;
|
|
29696
|
+
}
|
|
29697
|
+
// Find the balance of the L1 representation of the token and check if the balance covers the delta
|
|
29698
|
+
const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
|
|
29699
|
+
if (erc20balance && erc20balance.balance.gte(balanceRequirement.delta.balance)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
|
|
29700
|
+
return undefined;
|
|
29701
|
+
};
|
|
29702
|
+
|
|
29703
|
+
|
|
29704
|
+
|
|
29705
|
+
|
|
29706
|
+
|
|
29707
|
+
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
29708
|
+
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
29709
|
+
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
29710
|
+
const readOnlyProviders = new Map();
|
|
29711
|
+
const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
|
|
29712
|
+
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
29713
|
+
});
|
|
29714
|
+
allowedNetworks.networks.forEach((networkInfo)=>{
|
|
29715
|
+
const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
|
|
29716
|
+
const provider = new (JsonRpcProvider)(rpcUrl);
|
|
29717
|
+
readOnlyProviders.set(networkInfo.chainId, provider);
|
|
29718
|
+
});
|
|
29719
|
+
return readOnlyProviders;
|
|
29720
|
+
}
|
|
29721
|
+
|
|
29722
|
+
|
|
29723
|
+
|
|
29724
|
+
const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
|
|
29725
|
+
let insufficientBalanceCount = 0;
|
|
29726
|
+
let insufficientBridgeRequirement;
|
|
29727
|
+
for (const balanceRequirement of balanceRequirements.balanceRequirements)if (!balanceRequirement.sufficient) {
|
|
29728
|
+
insufficientBalanceCount++;
|
|
29729
|
+
insufficientBridgeRequirement = balanceRequirement;
|
|
29730
|
+
}
|
|
29731
|
+
if (insufficientBalanceCount === 1) return insufficientBridgeRequirement;
|
|
29732
|
+
return undefined;
|
|
29733
|
+
};
|
|
29525
29734
|
const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
|
|
29526
|
-
|
|
29527
|
-
|
|
29528
|
-
|
|
29529
|
-
|
|
29530
|
-
|
|
29735
|
+
let readOnlyProviders;
|
|
29736
|
+
try {
|
|
29737
|
+
readOnlyProviders = await (0, $0e0060cb42e136d2$export$339cb2be73677b30)(config);
|
|
29738
|
+
} catch (err) {
|
|
29739
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while creating read only providers", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
|
|
29740
|
+
message: err.message
|
|
29741
|
+
});
|
|
29742
|
+
}
|
|
29743
|
+
const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
|
|
29744
|
+
// Bridge and swap fee cache
|
|
29745
|
+
const feeEstimates = new Map();
|
|
29746
|
+
// Ensures only 1 balance requirement is insufficient otherwise one bridge route cannot be recommended
|
|
29747
|
+
let bridgeFundingStep;
|
|
29748
|
+
const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
|
|
29749
|
+
if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, insufficientRequirement, tokenBalances, feeEstimates);
|
|
29531
29750
|
// Check on-ramp routes
|
|
29532
29751
|
// Check swap routes
|
|
29533
29752
|
// > Could bridge first
|
|
29534
29753
|
// > Could on-ramp first
|
|
29535
29754
|
// > Could double swap
|
|
29536
|
-
return {
|
|
29755
|
+
if (bridgeFundingStep) return {
|
|
29537
29756
|
availableOptions: [],
|
|
29538
29757
|
response: {
|
|
29539
|
-
type:
|
|
29758
|
+
type: ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND,
|
|
29540
29759
|
message: "Routes found"
|
|
29541
29760
|
},
|
|
29542
29761
|
fundingRoutes: [
|
|
29543
29762
|
{
|
|
29544
29763
|
priority: 1,
|
|
29545
29764
|
steps: [
|
|
29546
|
-
|
|
29547
|
-
type: "bridge",
|
|
29548
|
-
chainId: 1,
|
|
29549
|
-
asset: {
|
|
29550
|
-
balance: (BigNumber$1).from(0),
|
|
29551
|
-
formattedBalance: "0",
|
|
29552
|
-
token: {
|
|
29553
|
-
name: "ETH",
|
|
29554
|
-
symbol: "ETH",
|
|
29555
|
-
decimals: 18
|
|
29556
|
-
}
|
|
29557
|
-
}
|
|
29558
|
-
}
|
|
29765
|
+
bridgeFundingStep
|
|
29559
29766
|
]
|
|
29560
29767
|
}
|
|
29561
29768
|
]
|
|
29562
29769
|
};
|
|
29770
|
+
return {
|
|
29771
|
+
availableOptions: [],
|
|
29772
|
+
response: {
|
|
29773
|
+
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
29774
|
+
message: "Routes not found"
|
|
29775
|
+
},
|
|
29776
|
+
fundingRoutes: []
|
|
29777
|
+
};
|
|
29563
29778
|
};
|
|
29564
29779
|
|
|
29565
29780
|
|
|
@@ -30272,7 +30487,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
30272
30487
|
function $parcel$export(e, n, v, s) {
|
|
30273
30488
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
30274
30489
|
}
|
|
30275
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.
|
|
30490
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.6";
|
|
30276
30491
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
30277
30492
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
30278
30493
|
|
package/dist/passport.js
CHANGED
|
@@ -1709,7 +1709,7 @@ class MultiRollupApiClients {
|
|
|
1709
1709
|
}
|
|
1710
1710
|
|
|
1711
1711
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1712
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.17.
|
|
1712
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.17.6' };
|
|
1713
1713
|
const createConfig = ({ basePath, headers, }) => {
|
|
1714
1714
|
if (!basePath.trim()) {
|
|
1715
1715
|
throw Error('basePath can not be empty');
|
|
@@ -1765,7 +1765,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
1765
1765
|
chainID,
|
|
1766
1766
|
coreContractAddress,
|
|
1767
1767
|
registrationContractAddress,
|
|
1768
|
-
sdkVersion: 'ts-immutable-sdk-0.17.
|
|
1768
|
+
sdkVersion: 'ts-immutable-sdk-0.17.6',
|
|
1769
1769
|
});
|
|
1770
1770
|
/**
|
|
1771
1771
|
* Sets `sdkVersion` at the time of build
|
package/package.json
CHANGED