@imtbl/sdk 0.17.4 → 0.17.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +2 -1
- package/dist/checkout_sdk.js +3091 -59
- 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 +245 -50
- package/dist/index.d.ts +2 -1
- package/dist/index.js +245 -50
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2724,7 +2724,7 @@ class MultiRollupApiClients {
|
|
|
2724
2724
|
}
|
|
2725
2725
|
|
|
2726
2726
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2727
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.
|
|
2727
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.17.5' };
|
|
2728
2728
|
const createConfig = ({ basePath, headers, }) => {
|
|
2729
2729
|
if (!basePath.trim()) {
|
|
2730
2730
|
throw Error('basePath can not be empty');
|
|
@@ -2784,7 +2784,7 @@ class APIError extends Error {
|
|
|
2784
2784
|
|
|
2785
2785
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2786
2786
|
const defaultHeaders = {
|
|
2787
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.
|
|
2787
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.17.5',
|
|
2788
2788
|
};
|
|
2789
2789
|
/**
|
|
2790
2790
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -3070,7 +3070,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
3070
3070
|
chainID,
|
|
3071
3071
|
coreContractAddress,
|
|
3072
3072
|
registrationContractAddress,
|
|
3073
|
-
sdkVersion: 'ts-immutable-sdk-0.17.
|
|
3073
|
+
sdkVersion: 'ts-immutable-sdk-0.17.5',
|
|
3074
3074
|
});
|
|
3075
3075
|
/**
|
|
3076
3076
|
* Sets `sdkVersion` at the time of build
|
|
@@ -27832,6 +27832,7 @@ var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
|
27832
27832
|
CheckoutErrorType["EXECUTE_APPROVAL_TRANSACTION_ERROR"] = "EXECUTE_APPROVAL_TRANSACTION_ERROR";
|
|
27833
27833
|
CheckoutErrorType["EXECUTE_FULFILMENT_TRANSACTION_ERROR"] = "EXECUTE_FULFILMENT_TRANSACTION_ERROR";
|
|
27834
27834
|
CheckoutErrorType["SIGN_MESSAGE_ERROR"] = "SIGN_MESSAGE_ERROR";
|
|
27835
|
+
CheckoutErrorType["BRIDGE_GAS_ESTIMATE_ERROR"] = "BRIDGE_GAS_ESTIMATE_ERROR";
|
|
27835
27836
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
27836
27837
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
27837
27838
|
message;
|
|
@@ -28639,6 +28640,7 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
|
|
|
28639
28640
|
|
|
28640
28641
|
|
|
28641
28642
|
|
|
28643
|
+
|
|
28642
28644
|
async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config) {
|
|
28643
28645
|
const rootChainProvider = readOnlyProviders.get(fromChainId);
|
|
28644
28646
|
const childChainProvider = readOnlyProviders.get(toChainId);
|
|
@@ -28674,6 +28676,13 @@ async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
|
|
|
28674
28676
|
}
|
|
28675
28677
|
});
|
|
28676
28678
|
}
|
|
28679
|
+
function $67fc622a2b913d5f$export$436dd76f23f463ff(config) {
|
|
28680
|
+
return new (BlockchainData)({
|
|
28681
|
+
baseConfig: {
|
|
28682
|
+
environment: config.environment
|
|
28683
|
+
}
|
|
28684
|
+
});
|
|
28685
|
+
}
|
|
28677
28686
|
|
|
28678
28687
|
|
|
28679
28688
|
|
|
@@ -29464,43 +29473,30 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
|
|
|
29464
29473
|
|
|
29465
29474
|
|
|
29466
29475
|
|
|
29476
|
+
var $b23305044c0e096a$export$3057de18ac0c076;
|
|
29477
|
+
(function(RouteCalculatorType) {
|
|
29478
|
+
RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
29479
|
+
RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
|
|
29480
|
+
RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
|
|
29481
|
+
})($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
|
|
29482
|
+
var $b23305044c0e096a$export$3af78bb3e8650ee6;
|
|
29483
|
+
(function(FundingRouteType) {
|
|
29484
|
+
FundingRouteType["BRIDGE"] = "BRIDGE";
|
|
29485
|
+
FundingRouteType["ON_RAMP"] = "ONRAMP";
|
|
29486
|
+
FundingRouteType["SWAP"] = "SWAP";
|
|
29487
|
+
})($b23305044c0e096a$export$3af78bb3e8650ee6 || ($b23305044c0e096a$export$3af78bb3e8650ee6 = {}));
|
|
29467
29488
|
|
|
29468
29489
|
|
|
29469
29490
|
|
|
29470
29491
|
|
|
29471
29492
|
|
|
29472
|
-
|
|
29473
|
-
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
29474
|
-
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
29475
|
-
const readOnlyProviders = new Map();
|
|
29476
|
-
const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
|
|
29477
|
-
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
29478
|
-
});
|
|
29479
|
-
allowedNetworks.networks.forEach((networkInfo)=>{
|
|
29480
|
-
const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
|
|
29481
|
-
const provider = new (providers.JsonRpcProvider)(rpcUrl);
|
|
29482
|
-
readOnlyProviders.set(networkInfo.chainId, provider);
|
|
29483
|
-
});
|
|
29484
|
-
return readOnlyProviders;
|
|
29485
|
-
}
|
|
29486
|
-
|
|
29487
|
-
|
|
29488
|
-
|
|
29489
|
-
|
|
29490
|
-
const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, availableRoutingOptions)=>{
|
|
29493
|
+
const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, readOnlyProviders, ownerAddress, availableRoutingOptions)=>{
|
|
29491
29494
|
const chainBalances = new Map();
|
|
29492
29495
|
const chainBalancePromises = new Map();
|
|
29493
|
-
let readOnlyProviders = new Map();
|
|
29494
|
-
let providerError;
|
|
29495
|
-
try {
|
|
29496
|
-
readOnlyProviders = await (0, $0e0060cb42e136d2$export$339cb2be73677b30)(config);
|
|
29497
|
-
} catch (error) {
|
|
29498
|
-
providerError = error;
|
|
29499
|
-
}
|
|
29500
29496
|
if (readOnlyProviders.size === 0) {
|
|
29501
29497
|
const noProviderResult = {
|
|
29502
29498
|
success: false,
|
|
29503
|
-
error:
|
|
29499
|
+
error: new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 or L2 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR),
|
|
29504
29500
|
balances: []
|
|
29505
29501
|
};
|
|
29506
29502
|
chainBalances.set(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config), noProviderResult);
|
|
@@ -29544,44 +29540,243 @@ const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, av
|
|
|
29544
29540
|
};
|
|
29545
29541
|
|
|
29546
29542
|
|
|
29543
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
29544
|
+
|
|
29545
|
+
|
|
29546
|
+
|
|
29547
|
+
|
|
29548
|
+
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
29549
|
+
for (const balance of balances.balances){
|
|
29550
|
+
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
29551
|
+
}
|
|
29552
|
+
return (ethers.BigNumber).from(0);
|
|
29553
|
+
};
|
|
29554
|
+
|
|
29555
|
+
|
|
29556
|
+
|
|
29557
|
+
|
|
29558
|
+
|
|
29559
|
+
|
|
29560
|
+
const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProviders)=>{
|
|
29561
|
+
try {
|
|
29562
|
+
const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
|
|
29563
|
+
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
29564
|
+
isSpendingCapApprovalRequired: false
|
|
29565
|
+
}, readOnlyProviders, config);
|
|
29566
|
+
const gasEstimate = estimate.gasFee.estimatedAmount;
|
|
29567
|
+
const bridgeFee = estimate.bridgeFee.estimatedAmount;
|
|
29568
|
+
let totalFees = (0, ethers.BigNumber).from(0);
|
|
29569
|
+
if (gasEstimate) totalFees = totalFees.add(gasEstimate);
|
|
29570
|
+
if (bridgeFee) totalFees = totalFees.add(bridgeFee);
|
|
29571
|
+
return totalFees;
|
|
29572
|
+
} catch (err) {
|
|
29573
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
29574
|
+
message: err.message
|
|
29575
|
+
});
|
|
29576
|
+
}
|
|
29577
|
+
};
|
|
29578
|
+
|
|
29579
|
+
|
|
29580
|
+
|
|
29581
|
+
const $823db9fb0ca4bc15$export$c37d8687c27b9660 = "0x0000000000000000000000000000000000000001";
|
|
29582
|
+
const $823db9fb0ca4bc15$export$1430626eec86fce9 = (chainId)=>{
|
|
29583
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET) return "imtbl-zkevm-testnet";
|
|
29584
|
+
return "";
|
|
29585
|
+
};
|
|
29586
|
+
const $823db9fb0ca4bc15$export$53e663abd9b77fc1 = (chainId)=>{
|
|
29587
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA) return "0x2Fa06C6672dDCc066Ab04631192738799231dE4a";
|
|
29588
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM) return "0xF57e7e7C23978C3cAEC3C3548E3D615c346e79fF";
|
|
29589
|
+
return "";
|
|
29590
|
+
};
|
|
29591
|
+
|
|
29592
|
+
|
|
29593
|
+
|
|
29594
|
+
|
|
29595
|
+
|
|
29596
|
+
|
|
29597
|
+
|
|
29598
|
+
const $07ac9c0576988336$export$7847f5f5cce25dfa = async (config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, token, depositAmount)=>{
|
|
29599
|
+
try {
|
|
29600
|
+
const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config);
|
|
29601
|
+
const { unsignedTx: unsignedTx } = await tokenBridge.getUnsignedApproveDepositBridgeTx({
|
|
29602
|
+
depositorAddress: depositorAddress,
|
|
29603
|
+
token: token,
|
|
29604
|
+
depositAmount: depositAmount
|
|
29605
|
+
});
|
|
29606
|
+
if (unsignedTx === null) return (0, ethers.BigNumber).from(0);
|
|
29607
|
+
return await l1provider.estimateGas(unsignedTx);
|
|
29608
|
+
} catch (err) {
|
|
29609
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while attempting ot estimate gas for approval transaction", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
29610
|
+
message: err.message
|
|
29611
|
+
});
|
|
29612
|
+
}
|
|
29613
|
+
};
|
|
29614
|
+
const $07ac9c0576988336$export$a3dd181de896b7c7 = async (config, readOnlyProviders, l1provider, depositorAddress, l1Address, delta)=>{
|
|
29615
|
+
if (l1Address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) return (ethers.BigNumber).from(0); // Native ETH does not require approval
|
|
29616
|
+
const fromChainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
29617
|
+
const toChainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
|
|
29618
|
+
return await $07ac9c0576988336$export$7847f5f5cce25dfa(config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, l1Address, delta);
|
|
29619
|
+
};
|
|
29620
|
+
|
|
29621
|
+
|
|
29622
|
+
|
|
29623
|
+
const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (balances, totalFees)=>{
|
|
29624
|
+
const balance = ($f730af3b727f04ac$export$22fea095b15361de)(balances);
|
|
29625
|
+
return balance.gte(totalFees);
|
|
29626
|
+
};
|
|
29627
|
+
const $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f = (balanceRequirement)=>{
|
|
29628
|
+
if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return $d85ad1457a3f1a83$export$b80040cb173ba6e9;
|
|
29629
|
+
if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return balanceRequirement.required.token.address ?? "";
|
|
29630
|
+
return "";
|
|
29631
|
+
};
|
|
29632
|
+
const $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6 = async (config, balanceRequirement)=>{
|
|
29633
|
+
const l2address = $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f(balanceRequirement);
|
|
29634
|
+
if (l2address === "") return "";
|
|
29635
|
+
if (l2address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) return ($823db9fb0ca4bc15$export$53e663abd9b77fc1)(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
29636
|
+
const chainName = ($823db9fb0ca4bc15$export$1430626eec86fce9)(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
29637
|
+
if (chainName === "") return ""; // Chain name not a valid indexer chain name
|
|
29638
|
+
const blockchainData = ($67fc622a2b913d5f$export$436dd76f23f463ff)(config);
|
|
29639
|
+
const tokenData = await blockchainData.getToken({
|
|
29640
|
+
chainName: chainName,
|
|
29641
|
+
contractAddress: l2address
|
|
29642
|
+
});
|
|
29643
|
+
const l1address = tokenData.result.root_contract_address;
|
|
29644
|
+
if (l1address === null) return ""; // No L1 representation of this token
|
|
29645
|
+
return l1address;
|
|
29646
|
+
};
|
|
29647
|
+
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
29648
|
+
let bridgeFeeEstimate = feeEstimates.get(($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE);
|
|
29649
|
+
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
29650
|
+
bridgeFeeEstimate = await ($8a49d1a3783a2640$export$3aff971444a4f244)(config, readOnlyProviders);
|
|
29651
|
+
feeEstimates.set(($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE, bridgeFeeEstimate);
|
|
29652
|
+
return bridgeFeeEstimate;
|
|
29653
|
+
};
|
|
29654
|
+
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
29655
|
+
type: ($b23305044c0e096a$export$3af78bb3e8650ee6).BRIDGE,
|
|
29656
|
+
chainId: chainId,
|
|
29657
|
+
asset: {
|
|
29658
|
+
balance: balance.balance,
|
|
29659
|
+
formattedBalance: balance.formattedBalance,
|
|
29660
|
+
token: {
|
|
29661
|
+
name: balance.token.name,
|
|
29662
|
+
symbol: balance.token.symbol,
|
|
29663
|
+
address: balance.token.address,
|
|
29664
|
+
decimals: balance.token.decimals
|
|
29665
|
+
}
|
|
29666
|
+
}
|
|
29667
|
+
});
|
|
29668
|
+
const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
|
|
29669
|
+
if (!address || address === "") return true;
|
|
29670
|
+
return false;
|
|
29671
|
+
};
|
|
29672
|
+
const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProviders, depositorAddress, availableRoutingOptions, balanceRequirement, balances, feeEstimates)=>{
|
|
29673
|
+
if (!availableRoutingOptions.bridge) return undefined;
|
|
29674
|
+
const chainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
29675
|
+
const tokenBalanceResult = balances.get(chainId);
|
|
29676
|
+
const l1provider = readOnlyProviders.get(chainId);
|
|
29677
|
+
if (!l1provider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
|
|
29678
|
+
chainId: chainId.toString()
|
|
29679
|
+
});
|
|
29680
|
+
// If no balances on layer 1 then Bridge cannot be an option
|
|
29681
|
+
if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error getting balances", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_BALANCE_ERROR, {
|
|
29682
|
+
chainId: chainId.toString()
|
|
29683
|
+
});
|
|
29684
|
+
if (tokenBalanceResult.balances.length === 0) return undefined;
|
|
29685
|
+
const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
|
|
29686
|
+
// If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
|
|
29687
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
|
|
29688
|
+
const l1address = await $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6(config, balanceRequirement);
|
|
29689
|
+
if (l1address === "") return undefined;
|
|
29690
|
+
const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, balanceRequirement.delta.balance);
|
|
29691
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
|
|
29692
|
+
// If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
|
|
29693
|
+
if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
|
|
29694
|
+
const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
|
|
29695
|
+
if (nativeETHBalance && nativeETHBalance.balance.gte(balanceRequirement.delta.balance.add(bridgeFeeEstimate))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance);
|
|
29696
|
+
return undefined;
|
|
29697
|
+
}
|
|
29698
|
+
// Find the balance of the L1 representation of the token and check if the balance covers the delta
|
|
29699
|
+
const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
|
|
29700
|
+
if (erc20balance && erc20balance.balance.gte(balanceRequirement.delta.balance)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
|
|
29701
|
+
return undefined;
|
|
29702
|
+
};
|
|
29703
|
+
|
|
29704
|
+
|
|
29705
|
+
|
|
29706
|
+
|
|
29707
|
+
|
|
29708
|
+
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
29709
|
+
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
29710
|
+
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
29711
|
+
const readOnlyProviders = new Map();
|
|
29712
|
+
const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
|
|
29713
|
+
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
29714
|
+
});
|
|
29715
|
+
allowedNetworks.networks.forEach((networkInfo)=>{
|
|
29716
|
+
const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
|
|
29717
|
+
const provider = new (providers.JsonRpcProvider)(rpcUrl);
|
|
29718
|
+
readOnlyProviders.set(networkInfo.chainId, provider);
|
|
29719
|
+
});
|
|
29720
|
+
return readOnlyProviders;
|
|
29721
|
+
}
|
|
29722
|
+
|
|
29723
|
+
|
|
29724
|
+
|
|
29725
|
+
const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
|
|
29726
|
+
let insufficientBalanceCount = 0;
|
|
29727
|
+
let insufficientBridgeRequirement;
|
|
29728
|
+
for (const balanceRequirement of balanceRequirements.balanceRequirements)if (!balanceRequirement.sufficient) {
|
|
29729
|
+
insufficientBalanceCount++;
|
|
29730
|
+
insufficientBridgeRequirement = balanceRequirement;
|
|
29731
|
+
}
|
|
29732
|
+
if (insufficientBalanceCount === 1) return insufficientBridgeRequirement;
|
|
29733
|
+
return undefined;
|
|
29734
|
+
};
|
|
29547
29735
|
const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
|
|
29548
|
-
|
|
29549
|
-
|
|
29550
|
-
|
|
29736
|
+
let readOnlyProviders;
|
|
29737
|
+
try {
|
|
29738
|
+
readOnlyProviders = await (0, $0e0060cb42e136d2$export$339cb2be73677b30)(config);
|
|
29739
|
+
} catch (err) {
|
|
29740
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while creating read only providers", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
|
|
29741
|
+
message: err.message
|
|
29742
|
+
});
|
|
29743
|
+
}
|
|
29744
|
+
const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
|
|
29551
29745
|
// Get allowed tokens?
|
|
29552
|
-
//
|
|
29746
|
+
// Bridge and swap fee cache
|
|
29747
|
+
const feeEstimates = new Map();
|
|
29748
|
+
// Ensures only 1 balance requirement is insufficient otherwise one bridge route cannot be recommended
|
|
29749
|
+
let bridgeFundingStep;
|
|
29750
|
+
const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
|
|
29751
|
+
if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, insufficientRequirement, tokenBalances, feeEstimates);
|
|
29553
29752
|
// Check on-ramp routes
|
|
29554
29753
|
// Check swap routes
|
|
29555
29754
|
// > Could bridge first
|
|
29556
29755
|
// > Could on-ramp first
|
|
29557
29756
|
// > Could double swap
|
|
29558
|
-
return {
|
|
29757
|
+
if (bridgeFundingStep) return {
|
|
29559
29758
|
availableOptions: [],
|
|
29560
29759
|
response: {
|
|
29561
|
-
type:
|
|
29760
|
+
type: ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND,
|
|
29562
29761
|
message: "Routes found"
|
|
29563
29762
|
},
|
|
29564
29763
|
fundingRoutes: [
|
|
29565
29764
|
{
|
|
29566
29765
|
priority: 1,
|
|
29567
29766
|
steps: [
|
|
29568
|
-
|
|
29569
|
-
type: "bridge",
|
|
29570
|
-
chainId: 1,
|
|
29571
|
-
asset: {
|
|
29572
|
-
balance: (ethers.BigNumber).from(0),
|
|
29573
|
-
formattedBalance: "0",
|
|
29574
|
-
token: {
|
|
29575
|
-
name: "ETH",
|
|
29576
|
-
symbol: "ETH",
|
|
29577
|
-
decimals: 18
|
|
29578
|
-
}
|
|
29579
|
-
}
|
|
29580
|
-
}
|
|
29767
|
+
bridgeFundingStep
|
|
29581
29768
|
]
|
|
29582
29769
|
}
|
|
29583
29770
|
]
|
|
29584
29771
|
};
|
|
29772
|
+
return {
|
|
29773
|
+
availableOptions: [],
|
|
29774
|
+
response: {
|
|
29775
|
+
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
29776
|
+
message: "Routes not found"
|
|
29777
|
+
},
|
|
29778
|
+
fundingRoutes: []
|
|
29779
|
+
};
|
|
29585
29780
|
};
|
|
29586
29781
|
|
|
29587
29782
|
|
|
@@ -30294,7 +30489,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
30294
30489
|
function $parcel$export(e, n, v, s) {
|
|
30295
30490
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
30296
30491
|
}
|
|
30297
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.
|
|
30492
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.5";
|
|
30298
30493
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
30299
30494
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
30300
30495
|
|
package/dist/index.d.ts
CHANGED
|
@@ -15052,7 +15052,8 @@ declare enum CheckoutErrorType {
|
|
|
15052
15052
|
GET_ERC721_ALLOWANCE_ERROR = "GET_ERC721_ALLOWANCE_ERROR",
|
|
15053
15053
|
EXECUTE_APPROVAL_TRANSACTION_ERROR = "EXECUTE_APPROVAL_TRANSACTION_ERROR",
|
|
15054
15054
|
EXECUTE_FULFILMENT_TRANSACTION_ERROR = "EXECUTE_FULFILMENT_TRANSACTION_ERROR",
|
|
15055
|
-
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR"
|
|
15055
|
+
SIGN_MESSAGE_ERROR = "SIGN_MESSAGE_ERROR",
|
|
15056
|
+
BRIDGE_GAS_ESTIMATE_ERROR = "BRIDGE_GAS_ESTIMATE_ERROR"
|
|
15056
15057
|
}
|
|
15057
15058
|
/**
|
|
15058
15059
|
* Represents an error object with a specific type, optional message, and optional data.
|