@imtbl/sdk 0.17.3 → 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 +3118 -67
- 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 +272 -58
- package/dist/index.d.ts +2 -1
- package/dist/index.js +272 -58
- 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
|
|
@@ -27334,6 +27334,7 @@ class Exchange {
|
|
|
27334
27334
|
|
|
27335
27335
|
|
|
27336
27336
|
|
|
27337
|
+
|
|
27337
27338
|
var $aa144554f9ef124b$export$226b052ecb8ca80;
|
|
27338
27339
|
(function(BuyStatusType) {
|
|
27339
27340
|
BuyStatusType["SUCCESS"] = "SUCCESS";
|
|
@@ -27469,12 +27470,6 @@ const $d85ad1457a3f1a83$export$161d4a74df65fc08 = {
|
|
|
27469
27470
|
const $d85ad1457a3f1a83$export$72176e2233d7d5d = true;
|
|
27470
27471
|
const $d85ad1457a3f1a83$export$566b5975cc83d6b4 = true;
|
|
27471
27472
|
const $d85ad1457a3f1a83$export$261cde2078dba35b = true;
|
|
27472
|
-
const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
|
|
27473
|
-
[($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET]: {
|
|
27474
|
-
url: "https://explorer.testnet.immutable.com",
|
|
27475
|
-
nativeToken: $d85ad1457a3f1a83$var$ZKEVM_NATIVE_TOKEN
|
|
27476
|
-
}
|
|
27477
|
-
};
|
|
27478
27473
|
const $d85ad1457a3f1a83$export$f6043d7fce62d71b = {
|
|
27479
27474
|
[(Environment$1).SANDBOX]: "https://global-stg.transak.com",
|
|
27480
27475
|
[(Environment$1).PRODUCTION]: "https://global.transak.com/"
|
|
@@ -27572,6 +27567,16 @@ const $d85ad1457a3f1a83$export$3a9ebede6a150274 = new Map([
|
|
|
27572
27567
|
}
|
|
27573
27568
|
]
|
|
27574
27569
|
]);
|
|
27570
|
+
const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
|
|
27571
|
+
[($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET]: {
|
|
27572
|
+
url: "https://explorer.testnet.immutable.com",
|
|
27573
|
+
nativeToken: $d85ad1457a3f1a83$export$3e81fc0987227f10.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET).nativeCurrency
|
|
27574
|
+
},
|
|
27575
|
+
[($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET]: {
|
|
27576
|
+
url: "https://explorer.mainnet.immutable.com",
|
|
27577
|
+
nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET).nativeCurrency
|
|
27578
|
+
}
|
|
27579
|
+
};
|
|
27575
27580
|
const $d85ad1457a3f1a83$export$db5daa1b5156ccfe = [
|
|
27576
27581
|
{
|
|
27577
27582
|
constant: true,
|
|
@@ -27827,6 +27832,7 @@ var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
|
27827
27832
|
CheckoutErrorType["EXECUTE_APPROVAL_TRANSACTION_ERROR"] = "EXECUTE_APPROVAL_TRANSACTION_ERROR";
|
|
27828
27833
|
CheckoutErrorType["EXECUTE_FULFILMENT_TRANSACTION_ERROR"] = "EXECUTE_FULFILMENT_TRANSACTION_ERROR";
|
|
27829
27834
|
CheckoutErrorType["SIGN_MESSAGE_ERROR"] = "SIGN_MESSAGE_ERROR";
|
|
27835
|
+
CheckoutErrorType["BRIDGE_GAS_ESTIMATE_ERROR"] = "BRIDGE_GAS_ESTIMATE_ERROR";
|
|
27830
27836
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
27831
27837
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
27832
27838
|
message;
|
|
@@ -28346,7 +28352,14 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
|
28346
28352
|
items.push(...resp.items);
|
|
28347
28353
|
}while (resp.next_page_params);
|
|
28348
28354
|
} catch (err) {
|
|
28349
|
-
|
|
28355
|
+
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
28356
|
+
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
28357
|
+
// activity on the chain. In this case, simply ignore the error and return
|
|
28358
|
+
// no currencies.
|
|
28359
|
+
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
28360
|
+
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
28361
|
+
// or simply an incorrect wallet address was provided.
|
|
28362
|
+
if (err?.code !== (globalAxios$1.HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
28350
28363
|
}
|
|
28351
28364
|
try {
|
|
28352
28365
|
const respNative = await $1564e43dde50bb61$var$blockscoutClient.getNativeTokenByWalletAddress({
|
|
@@ -28354,7 +28367,14 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
|
28354
28367
|
});
|
|
28355
28368
|
items.push(respNative);
|
|
28356
28369
|
} catch (err) {
|
|
28357
|
-
|
|
28370
|
+
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
28371
|
+
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
28372
|
+
// activity on the chain. In this case, simply ignore the error and return
|
|
28373
|
+
// no currencies.
|
|
28374
|
+
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
28375
|
+
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
28376
|
+
// or simply an incorrect wallet address was provided.
|
|
28377
|
+
if (err?.code !== (globalAxios$1.HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
28358
28378
|
}
|
|
28359
28379
|
return {
|
|
28360
28380
|
balances: items.map((item)=>{
|
|
@@ -28620,6 +28640,7 @@ async function $570856c68db0bd36$export$9e73e22953cebcfc(tokenBridge, tokenAddre
|
|
|
28620
28640
|
|
|
28621
28641
|
|
|
28622
28642
|
|
|
28643
|
+
|
|
28623
28644
|
async function $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config) {
|
|
28624
28645
|
const rootChainProvider = readOnlyProviders.get(fromChainId);
|
|
28625
28646
|
const childChainProvider = readOnlyProviders.get(toChainId);
|
|
@@ -28655,6 +28676,13 @@ async function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
|
|
|
28655
28676
|
}
|
|
28656
28677
|
});
|
|
28657
28678
|
}
|
|
28679
|
+
function $67fc622a2b913d5f$export$436dd76f23f463ff(config) {
|
|
28680
|
+
return new (BlockchainData)({
|
|
28681
|
+
baseConfig: {
|
|
28682
|
+
environment: config.environment
|
|
28683
|
+
}
|
|
28684
|
+
});
|
|
28685
|
+
}
|
|
28658
28686
|
|
|
28659
28687
|
|
|
28660
28688
|
|
|
@@ -29445,43 +29473,30 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
|
|
|
29445
29473
|
|
|
29446
29474
|
|
|
29447
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 = {}));
|
|
29448
29488
|
|
|
29449
29489
|
|
|
29450
29490
|
|
|
29451
29491
|
|
|
29452
29492
|
|
|
29453
|
-
|
|
29454
|
-
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
29455
|
-
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
29456
|
-
const readOnlyProviders = new Map();
|
|
29457
|
-
const allowedNetworks = await $de192de6ef100f9f$export$3043f6442a9ef563(config, {
|
|
29458
|
-
type: ($a47e48dd2c04791b$export$1f05a55fe0680cc7).ALL
|
|
29459
|
-
});
|
|
29460
|
-
allowedNetworks.networks.forEach((networkInfo)=>{
|
|
29461
|
-
const rpcUrl = config.networkMap.get(networkInfo.chainId)?.rpcUrls[0];
|
|
29462
|
-
const provider = new (providers.JsonRpcProvider)(rpcUrl);
|
|
29463
|
-
readOnlyProviders.set(networkInfo.chainId, provider);
|
|
29464
|
-
});
|
|
29465
|
-
return readOnlyProviders;
|
|
29466
|
-
}
|
|
29467
|
-
|
|
29468
|
-
|
|
29469
|
-
|
|
29470
|
-
|
|
29471
|
-
const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, availableRoutingOptions)=>{
|
|
29493
|
+
const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, readOnlyProviders, ownerAddress, availableRoutingOptions)=>{
|
|
29472
29494
|
const chainBalances = new Map();
|
|
29473
29495
|
const chainBalancePromises = new Map();
|
|
29474
|
-
let readOnlyProviders = new Map();
|
|
29475
|
-
let providerError;
|
|
29476
|
-
try {
|
|
29477
|
-
readOnlyProviders = await (0, $0e0060cb42e136d2$export$339cb2be73677b30)(config);
|
|
29478
|
-
} catch (error) {
|
|
29479
|
-
providerError = error;
|
|
29480
|
-
}
|
|
29481
29496
|
if (readOnlyProviders.size === 0) {
|
|
29482
29497
|
const noProviderResult = {
|
|
29483
29498
|
success: false,
|
|
29484
|
-
error:
|
|
29499
|
+
error: new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 or L2 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR),
|
|
29485
29500
|
balances: []
|
|
29486
29501
|
};
|
|
29487
29502
|
chainBalances.set(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config), noProviderResult);
|
|
@@ -29525,44 +29540,243 @@ const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, ownerAddress, av
|
|
|
29525
29540
|
};
|
|
29526
29541
|
|
|
29527
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
|
+
};
|
|
29528
29735
|
const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
|
|
29529
|
-
|
|
29530
|
-
|
|
29531
|
-
|
|
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);
|
|
29532
29745
|
// Get allowed tokens?
|
|
29533
|
-
//
|
|
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);
|
|
29534
29752
|
// Check on-ramp routes
|
|
29535
29753
|
// Check swap routes
|
|
29536
29754
|
// > Could bridge first
|
|
29537
29755
|
// > Could on-ramp first
|
|
29538
29756
|
// > Could double swap
|
|
29539
|
-
return {
|
|
29757
|
+
if (bridgeFundingStep) return {
|
|
29540
29758
|
availableOptions: [],
|
|
29541
29759
|
response: {
|
|
29542
|
-
type:
|
|
29760
|
+
type: ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND,
|
|
29543
29761
|
message: "Routes found"
|
|
29544
29762
|
},
|
|
29545
29763
|
fundingRoutes: [
|
|
29546
29764
|
{
|
|
29547
29765
|
priority: 1,
|
|
29548
29766
|
steps: [
|
|
29549
|
-
|
|
29550
|
-
type: "bridge",
|
|
29551
|
-
chainId: 1,
|
|
29552
|
-
asset: {
|
|
29553
|
-
balance: (ethers.BigNumber).from(0),
|
|
29554
|
-
formattedBalance: "0",
|
|
29555
|
-
token: {
|
|
29556
|
-
name: "ETH",
|
|
29557
|
-
symbol: "ETH",
|
|
29558
|
-
decimals: 18
|
|
29559
|
-
}
|
|
29560
|
-
}
|
|
29561
|
-
}
|
|
29767
|
+
bridgeFundingStep
|
|
29562
29768
|
]
|
|
29563
29769
|
}
|
|
29564
29770
|
]
|
|
29565
29771
|
};
|
|
29772
|
+
return {
|
|
29773
|
+
availableOptions: [],
|
|
29774
|
+
response: {
|
|
29775
|
+
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
29776
|
+
message: "Routes not found"
|
|
29777
|
+
},
|
|
29778
|
+
fundingRoutes: []
|
|
29779
|
+
};
|
|
29566
29780
|
};
|
|
29567
29781
|
|
|
29568
29782
|
|
|
@@ -30275,7 +30489,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
30275
30489
|
function $parcel$export(e, n, v, s) {
|
|
30276
30490
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
30277
30491
|
}
|
|
30278
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.
|
|
30492
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.17.5";
|
|
30279
30493
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
30280
30494
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
30281
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.
|