@imtbl/sdk 0.22.2 → 0.23.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockchain_data.js +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +409 -171
- package/dist/checkout_sdk.js +265 -177
- package/dist/checkout_widgets.d.ts +1 -1
- package/dist/checkout_widgets.js +99 -30
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +12 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +366 -208
- package/dist/index.d.ts +435 -183
- package/dist/index.js +366 -208
- package/dist/passport.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3009,7 +3009,7 @@ class MultiRollupApiClients {
|
|
|
3009
3009
|
}
|
|
3010
3010
|
|
|
3011
3011
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3012
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.
|
|
3012
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.23.0-alpha' };
|
|
3013
3013
|
const createConfig = ({ basePath, headers, }) => {
|
|
3014
3014
|
if (!basePath.trim()) {
|
|
3015
3015
|
throw Error('basePath can not be empty');
|
|
@@ -3069,7 +3069,7 @@ class APIError extends Error {
|
|
|
3069
3069
|
|
|
3070
3070
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3071
3071
|
const defaultHeaders = {
|
|
3072
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
3072
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.23.0-alpha',
|
|
3073
3073
|
};
|
|
3074
3074
|
/**
|
|
3075
3075
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -3355,7 +3355,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
3355
3355
|
chainID,
|
|
3356
3356
|
coreContractAddress,
|
|
3357
3357
|
registrationContractAddress,
|
|
3358
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
3358
|
+
sdkVersion: 'ts-immutable-sdk-0.23.0-alpha',
|
|
3359
3359
|
});
|
|
3360
3360
|
/**
|
|
3361
3361
|
* Sets `sdkVersion` at the time of build
|
|
@@ -28051,18 +28051,8 @@ class Exchange {
|
|
|
28051
28051
|
|
|
28052
28052
|
|
|
28053
28053
|
|
|
28054
|
-
var $aa144554f9ef124b$export$226b052ecb8ca80;
|
|
28055
|
-
(function(BuyStatusType) {
|
|
28056
|
-
BuyStatusType["SUCCESS"] = "SUCCESS";
|
|
28057
|
-
BuyStatusType["FAILED"] = "FAILED";
|
|
28058
|
-
})($aa144554f9ef124b$export$226b052ecb8ca80 || ($aa144554f9ef124b$export$226b052ecb8ca80 = {}));
|
|
28059
28054
|
|
|
28060
28055
|
|
|
28061
|
-
var $1e6b81bbd98b3a91$export$c0189a8c30039654;
|
|
28062
|
-
(function(CancelStatusType) {
|
|
28063
|
-
CancelStatusType["SUCCESS"] = "SUCCESS";
|
|
28064
|
-
CancelStatusType["FAILED"] = "FAILED";
|
|
28065
|
-
})($1e6b81bbd98b3a91$export$c0189a8c30039654 || ($1e6b81bbd98b3a91$export$c0189a8c30039654 = {}));
|
|
28066
28056
|
|
|
28067
28057
|
|
|
28068
28058
|
/**
|
|
@@ -28116,11 +28106,6 @@ var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
|
28116
28106
|
|
|
28117
28107
|
|
|
28118
28108
|
|
|
28119
|
-
var $c2874b006e92b115$export$a9780122aaa0801a;
|
|
28120
|
-
(function(SellStatusType) {
|
|
28121
|
-
SellStatusType["SUCCESS"] = "SUCCESS";
|
|
28122
|
-
SellStatusType["FAILED"] = "FAILED";
|
|
28123
|
-
})($c2874b006e92b115$export$a9780122aaa0801a || ($c2874b006e92b115$export$a9780122aaa0801a = {}));
|
|
28124
28109
|
|
|
28125
28110
|
|
|
28126
28111
|
var $08d5ddc39acd6833$export$fd9b17d87f4121d2;
|
|
@@ -28490,6 +28475,12 @@ const $d85ad1457a3f1a83$export$8b8be7a2a654f23e = [
|
|
|
28490
28475
|
];
|
|
28491
28476
|
|
|
28492
28477
|
|
|
28478
|
+
var $4b58188d47aafe8d$export$de7bcda3c490bf18;
|
|
28479
|
+
(function(CheckoutStatus) {
|
|
28480
|
+
CheckoutStatus["SUCCESS"] = "SUCCESS";
|
|
28481
|
+
CheckoutStatus["FAILED"] = "FAILED";
|
|
28482
|
+
CheckoutStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
28483
|
+
})($4b58188d47aafe8d$export$de7bcda3c490bf18 || ($4b58188d47aafe8d$export$de7bcda3c490bf18 = {}));
|
|
28493
28484
|
var $4b58188d47aafe8d$export$1fc8f52ad1810e52;
|
|
28494
28485
|
(function(ItemType) {
|
|
28495
28486
|
ItemType["NATIVE"] = "NATIVE";
|
|
@@ -28506,12 +28497,18 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
|
|
|
28506
28497
|
GasTokenType["NATIVE"] = "NATIVE";
|
|
28507
28498
|
GasTokenType["ERC20"] = "ERC20";
|
|
28508
28499
|
})($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
|
|
28509
|
-
var $4b58188d47aafe8d$export$
|
|
28510
|
-
(function(
|
|
28511
|
-
|
|
28512
|
-
|
|
28513
|
-
|
|
28514
|
-
})($4b58188d47aafe8d$export$
|
|
28500
|
+
var $4b58188d47aafe8d$export$d0616bd3e995b8be;
|
|
28501
|
+
(function(RoutingOutcomeType) {
|
|
28502
|
+
RoutingOutcomeType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
28503
|
+
RoutingOutcomeType["NO_ROUTES_FOUND"] = "NO_ROUTES_FOUND";
|
|
28504
|
+
RoutingOutcomeType["NO_ROUTE_OPTIONS"] = "NO_ROUTE_OPTIONS";
|
|
28505
|
+
})($4b58188d47aafe8d$export$d0616bd3e995b8be || ($4b58188d47aafe8d$export$d0616bd3e995b8be = {}));
|
|
28506
|
+
var $4b58188d47aafe8d$export$6fbaa98ee06d03e8;
|
|
28507
|
+
(function(FundingStepType) {
|
|
28508
|
+
FundingStepType["BRIDGE"] = "BRIDGE";
|
|
28509
|
+
FundingStepType["SWAP"] = "SWAP";
|
|
28510
|
+
FundingStepType["ONRAMP"] = "ONRAMP";
|
|
28511
|
+
})($4b58188d47aafe8d$export$6fbaa98ee06d03e8 || ($4b58188d47aafe8d$export$6fbaa98ee06d03e8 = {}));
|
|
28515
28512
|
|
|
28516
28513
|
|
|
28517
28514
|
var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
@@ -29521,7 +29518,6 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
29521
29518
|
|
|
29522
29519
|
|
|
29523
29520
|
|
|
29524
|
-
|
|
29525
29521
|
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
29526
29522
|
const aggregatedAllowances = [];
|
|
29527
29523
|
if (!erc20allowances.sufficient) {
|
|
@@ -30174,7 +30170,7 @@ const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>false;
|
|
|
30174
30170
|
|
|
30175
30171
|
|
|
30176
30172
|
const $7f2e17f026d4fc8d$var$isPassportProvider = (provider)=>(provider.provider?.isPassport === true) ?? false;
|
|
30177
|
-
const $7f2e17f026d4fc8d$export$
|
|
30173
|
+
const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
|
|
30178
30174
|
const availableRoutingOptions = {
|
|
30179
30175
|
onRamp: config.isOnRampEnabled,
|
|
30180
30176
|
swap: config.isSwapEnabled,
|
|
@@ -30207,13 +30203,6 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
|
|
|
30207
30203
|
|
|
30208
30204
|
|
|
30209
30205
|
|
|
30210
|
-
var $b23305044c0e096a$export$3057de18ac0c076;
|
|
30211
|
-
(function(RouteCalculatorType) {
|
|
30212
|
-
RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
30213
|
-
RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
|
|
30214
|
-
RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
|
|
30215
|
-
})($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
|
|
30216
|
-
|
|
30217
30206
|
|
|
30218
30207
|
|
|
30219
30208
|
|
|
@@ -30330,6 +30319,44 @@ const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache,
|
|
|
30330
30319
|
};
|
|
30331
30320
|
|
|
30332
30321
|
|
|
30322
|
+
const $91807edfd7057288$export$db6bd467891859dc = (chainId, fundsRequired, userBalance)=>{
|
|
30323
|
+
const tokenAddress = userBalance.token.address;
|
|
30324
|
+
let type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20;
|
|
30325
|
+
if (tokenAddress === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
|
|
30326
|
+
return {
|
|
30327
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).SWAP,
|
|
30328
|
+
chainId: chainId,
|
|
30329
|
+
fundingItem: {
|
|
30330
|
+
type: type,
|
|
30331
|
+
fundsRequired: {
|
|
30332
|
+
amount: fundsRequired,
|
|
30333
|
+
formattedAmount: (ethers.utils).formatUnits(fundsRequired, userBalance.token.decimals)
|
|
30334
|
+
},
|
|
30335
|
+
userBalance: {
|
|
30336
|
+
balance: userBalance.balance,
|
|
30337
|
+
formattedBalance: userBalance.formattedBalance
|
|
30338
|
+
},
|
|
30339
|
+
token: userBalance.token
|
|
30340
|
+
},
|
|
30341
|
+
// WT-1734 - Add fees
|
|
30342
|
+
fees: {
|
|
30343
|
+
approvalGasFees: {
|
|
30344
|
+
amount: (ethers.BigNumber).from(0),
|
|
30345
|
+
formattedAmount: "0"
|
|
30346
|
+
},
|
|
30347
|
+
swapGasFees: {
|
|
30348
|
+
amount: (ethers.BigNumber).from(0),
|
|
30349
|
+
formattedAmount: "0"
|
|
30350
|
+
},
|
|
30351
|
+
swapFees: [
|
|
30352
|
+
{
|
|
30353
|
+
amount: (ethers.BigNumber).from(0),
|
|
30354
|
+
formattedAmount: "0"
|
|
30355
|
+
}
|
|
30356
|
+
]
|
|
30357
|
+
}
|
|
30358
|
+
};
|
|
30359
|
+
};
|
|
30333
30360
|
const $91807edfd7057288$export$85e4d8628aabb217 = (balanceRequirement)=>{
|
|
30334
30361
|
let address = "";
|
|
30335
30362
|
let amount = (ethers.BigNumber).from(0);
|
|
@@ -30418,7 +30445,8 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
30418
30445
|
if (swappableTokens.length === 0) return fundingSteps;
|
|
30419
30446
|
const requiredToken = $91807edfd7057288$export$85e4d8628aabb217(balanceRequirement);
|
|
30420
30447
|
if (requiredToken.address === "") return fundingSteps;
|
|
30421
|
-
const
|
|
30448
|
+
const chainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
|
|
30449
|
+
const l2TokenBalanceResult = tokenBalanceResults.get(chainId);
|
|
30422
30450
|
if (!l2TokenBalanceResult) return fundingSteps;
|
|
30423
30451
|
const l2Balances = l2TokenBalanceResult.balances;
|
|
30424
30452
|
if (l2Balances.length === 0) return fundingSteps;
|
|
@@ -30445,15 +30473,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
30445
30473
|
})) continue;
|
|
30446
30474
|
// User has sufficient funds to cover any approval and swap fees so use this token for the funding route
|
|
30447
30475
|
// Currently we are not prioritising any particular token so just taking the first sufficient token
|
|
30448
|
-
fundingSteps.push(
|
|
30449
|
-
type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).SWAP,
|
|
30450
|
-
chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
|
|
30451
|
-
asset: {
|
|
30452
|
-
balance: userBalanceOfQuotedToken.balance,
|
|
30453
|
-
formattedBalance: userBalanceOfQuotedToken.formattedBalance,
|
|
30454
|
-
token: userBalanceOfQuotedToken.token
|
|
30455
|
-
}
|
|
30456
|
-
});
|
|
30476
|
+
fundingSteps.push($91807edfd7057288$export$db6bd467891859dc(chainId, amountOfQuoteTokenRequired.value, userBalanceOfQuotedToken));
|
|
30457
30477
|
}
|
|
30458
30478
|
return fundingSteps;
|
|
30459
30479
|
};
|
|
@@ -30511,6 +30531,7 @@ const $5a5ccedc98d53d25$export$1ad29657d49c5440 = async (config, tokenBalances,
|
|
|
30511
30531
|
|
|
30512
30532
|
|
|
30513
30533
|
|
|
30534
|
+
|
|
30514
30535
|
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
30515
30536
|
for (const balance of balances.balances){
|
|
30516
30537
|
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
@@ -30523,7 +30544,7 @@ const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
|
30523
30544
|
|
|
30524
30545
|
|
|
30525
30546
|
|
|
30526
|
-
const $
|
|
30547
|
+
const $15fe1c77041bd4f4$export$9e73e22953cebcfc = async (config, readOnlyProviders)=>{
|
|
30527
30548
|
try {
|
|
30528
30549
|
const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
|
|
30529
30550
|
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
@@ -30534,7 +30555,18 @@ const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProvide
|
|
|
30534
30555
|
let totalFees = (0, ethers.BigNumber).from(0);
|
|
30535
30556
|
if (gasEstimate) totalFees = totalFees.add(gasEstimate);
|
|
30536
30557
|
if (bridgeFee) totalFees = totalFees.add(bridgeFee);
|
|
30537
|
-
return
|
|
30558
|
+
return {
|
|
30559
|
+
type: (0, $4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE,
|
|
30560
|
+
gasFee: {
|
|
30561
|
+
estimatedAmount: gasEstimate ?? (0, ethers.BigNumber).from(0),
|
|
30562
|
+
token: estimate.gasFee.token
|
|
30563
|
+
},
|
|
30564
|
+
bridgeFee: {
|
|
30565
|
+
estimatedAmount: bridgeFee ?? (0, ethers.BigNumber).from(0),
|
|
30566
|
+
token: estimate.bridgeFee.token
|
|
30567
|
+
},
|
|
30568
|
+
totalFees: totalFees
|
|
30569
|
+
};
|
|
30538
30570
|
} catch (err) {
|
|
30539
30571
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
30540
30572
|
message: err.message
|
|
@@ -30622,24 +30654,48 @@ const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (tokenBalanceResult, totalFees
|
|
|
30622
30654
|
return balance.gte(totalFees);
|
|
30623
30655
|
};
|
|
30624
30656
|
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
30625
|
-
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$
|
|
30657
|
+
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE);
|
|
30626
30658
|
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
30627
|
-
bridgeFeeEstimate = await ($
|
|
30628
|
-
feeEstimates.set(($4b58188d47aafe8d$export$
|
|
30659
|
+
bridgeFeeEstimate = await ($15fe1c77041bd4f4$export$9e73e22953cebcfc)(config, readOnlyProviders);
|
|
30660
|
+
feeEstimates.set(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE, bridgeFeeEstimate);
|
|
30629
30661
|
return bridgeFeeEstimate;
|
|
30630
30662
|
};
|
|
30631
|
-
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
30632
|
-
type: ($4b58188d47aafe8d$export$
|
|
30663
|
+
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance, bridgeRequirement, itemType)=>({
|
|
30664
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE,
|
|
30633
30665
|
chainId: chainId,
|
|
30634
|
-
|
|
30635
|
-
|
|
30636
|
-
|
|
30666
|
+
fundingItem: {
|
|
30667
|
+
type: itemType,
|
|
30668
|
+
fundsRequired: {
|
|
30669
|
+
amount: bridgeRequirement.amount,
|
|
30670
|
+
formattedAmount: bridgeRequirement.formattedAmount
|
|
30671
|
+
},
|
|
30672
|
+
userBalance: {
|
|
30673
|
+
balance: balance.balance,
|
|
30674
|
+
formattedBalance: balance.formattedBalance
|
|
30675
|
+
},
|
|
30637
30676
|
token: {
|
|
30638
30677
|
name: balance.token.name,
|
|
30639
30678
|
symbol: balance.token.symbol,
|
|
30640
30679
|
address: balance.token.address,
|
|
30641
30680
|
decimals: balance.token.decimals
|
|
30642
30681
|
}
|
|
30682
|
+
},
|
|
30683
|
+
// WT-1734 - Add fees
|
|
30684
|
+
fees: {
|
|
30685
|
+
approvalGasFees: {
|
|
30686
|
+
amount: (ethers.BigNumber).from(0),
|
|
30687
|
+
formattedAmount: "0"
|
|
30688
|
+
},
|
|
30689
|
+
bridgeGasFees: {
|
|
30690
|
+
amount: (ethers.BigNumber).from(0),
|
|
30691
|
+
formattedAmount: "0"
|
|
30692
|
+
},
|
|
30693
|
+
bridgeFees: [
|
|
30694
|
+
{
|
|
30695
|
+
amount: (ethers.BigNumber).from(0),
|
|
30696
|
+
formattedAmount: "0"
|
|
30697
|
+
}
|
|
30698
|
+
]
|
|
30643
30699
|
}
|
|
30644
30700
|
});
|
|
30645
30701
|
const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
|
|
@@ -30661,7 +30717,7 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
|
|
|
30661
30717
|
if (allowedTokenList.length === 0) return undefined;
|
|
30662
30718
|
const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
|
|
30663
30719
|
// If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
|
|
30664
|
-
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
|
|
30720
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate.totalFees)) return undefined;
|
|
30665
30721
|
const l1RepresentationResult = await ($887d24b47765b1c0$export$952cdf461a00a8c6)(config, bridgeRequirement.l2address);
|
|
30666
30722
|
// No mapping on L1 for this token
|
|
30667
30723
|
const { l1address: l1address } = l1RepresentationResult;
|
|
@@ -30671,16 +30727,20 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
|
|
|
30671
30727
|
if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
|
|
30672
30728
|
} else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
|
|
30673
30729
|
const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, bridgeRequirement.amount);
|
|
30674
|
-
|
|
30730
|
+
let totalFees = bridgeFeeEstimate.bridgeFee.estimatedAmount;
|
|
30675
30731
|
// If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
|
|
30676
30732
|
if (l1address === ($887d24b47765b1c0$export$c37d8687c27b9660)) {
|
|
30677
30733
|
const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
|
|
30678
|
-
if (
|
|
30734
|
+
if (bridgeFeeEstimate.gasFee.estimatedAmount) totalFees = totalFees.add(bridgeFeeEstimate.gasFee.estimatedAmount);
|
|
30735
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, totalFees)) return undefined;
|
|
30736
|
+
if (nativeETHBalance && nativeETHBalance.balance.gte(bridgeRequirement.amount.add(totalFees))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance, bridgeRequirement, ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE);
|
|
30679
30737
|
return undefined;
|
|
30680
30738
|
}
|
|
30739
|
+
totalFees.add(gasForApproval).add(bridgeFeeEstimate.gasFee.estimatedAmount);
|
|
30740
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, totalFees)) return undefined;
|
|
30681
30741
|
// Find the balance of the L1 representation of the token and check if the balance covers the delta
|
|
30682
30742
|
const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
|
|
30683
|
-
if (erc20balance && erc20balance.balance.gte(bridgeRequirement.amount)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
|
|
30743
|
+
if (erc20balance && erc20balance.balance.gte(bridgeRequirement.amount)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance, bridgeRequirement, ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20);
|
|
30684
30744
|
return undefined;
|
|
30685
30745
|
};
|
|
30686
30746
|
|
|
@@ -30866,18 +30926,19 @@ const $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount = (config, toke
|
|
|
30866
30926
|
const $afd57acae9471ac5$export$1fc63300bde5e690 = (tokenBalances, swapRoutes)=>{
|
|
30867
30927
|
const originalSwapSteps = [];
|
|
30868
30928
|
for (const route of swapRoutes){
|
|
30869
|
-
const { chainId: chainId,
|
|
30929
|
+
const { chainId: chainId, fundingItem: fundingItem } = route;
|
|
30930
|
+
const { userBalance: userBalance } = route.fundingItem;
|
|
30870
30931
|
const tokenBalance = tokenBalances.get(chainId);
|
|
30871
30932
|
if (!tokenBalance) continue;
|
|
30872
30933
|
let originalBalance = (ethers.BigNumber).from(0);
|
|
30873
30934
|
let originalFormattedBalance = "0";
|
|
30874
|
-
const l2balance = tokenBalance.balances.find((balance)=>balance.token.address ===
|
|
30935
|
+
const l2balance = tokenBalance.balances.find((balance)=>balance.token.address === fundingItem.token.address);
|
|
30875
30936
|
if (l2balance) {
|
|
30876
30937
|
originalBalance = l2balance.balance;
|
|
30877
30938
|
originalFormattedBalance = l2balance.formattedBalance;
|
|
30878
30939
|
}
|
|
30879
|
-
|
|
30880
|
-
|
|
30940
|
+
userBalance.balance = originalBalance;
|
|
30941
|
+
userBalance.formattedBalance = originalFormattedBalance;
|
|
30881
30942
|
originalSwapSteps.push(route);
|
|
30882
30943
|
}
|
|
30883
30944
|
return originalSwapSteps;
|
|
@@ -30887,11 +30948,11 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
|
|
|
30887
30948
|
for (const bridgeFundingStep of bridgeFundingSteps){
|
|
30888
30949
|
if (!bridgeFundingStep) continue;
|
|
30889
30950
|
const mapping = l1tol2Addresses.find((addresses)=>{
|
|
30890
|
-
if (bridgeFundingStep.
|
|
30891
|
-
return addresses.l1address === bridgeFundingStep.
|
|
30951
|
+
if (bridgeFundingStep.fundingItem.token.address === undefined) return addresses.l1address === ($887d24b47765b1c0$export$c37d8687c27b9660) && addresses.l2address;
|
|
30952
|
+
return addresses.l1address === bridgeFundingStep.fundingItem.token.address && addresses.l2address;
|
|
30892
30953
|
});
|
|
30893
30954
|
if (!mapping) continue;
|
|
30894
|
-
const swapFundingStep = swapFundingSteps.find((step)=>step.
|
|
30955
|
+
const swapFundingStep = swapFundingSteps.find((step)=>step.fundingItem.token.address === mapping.l2address);
|
|
30895
30956
|
if (!swapFundingStep) continue;
|
|
30896
30957
|
bridgeAndSwapRoutes.push({
|
|
30897
30958
|
bridgeFundingStep: bridgeFundingStep,
|
|
@@ -30967,22 +31028,27 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
|
|
|
30967
31028
|
|
|
30968
31029
|
const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutingOptions, balanceRequirement)=>{
|
|
30969
31030
|
if (balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 && balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return undefined;
|
|
30970
|
-
const
|
|
31031
|
+
const { required: required, current: current, delta: delta } = balanceRequirement;
|
|
30971
31032
|
let hasAllowList = false;
|
|
30972
31033
|
const onRampProvidersAllowList = await ($5a5ccedc98d53d25$export$9ec9fc71f3ce62c4)(config, availableRoutingOptions);
|
|
30973
31034
|
Object.values(onRampProvidersAllowList).forEach((onRampAllowList)=>{
|
|
30974
|
-
if (onRampAllowList.length > 0 && !hasAllowList) hasAllowList = !!onRampAllowList.find((token)=>token.address ===
|
|
31035
|
+
if (onRampAllowList.length > 0 && !hasAllowList) hasAllowList = !!onRampAllowList.find((token)=>token.address === required.token?.address);
|
|
30975
31036
|
});
|
|
30976
31037
|
if (!hasAllowList) return undefined;
|
|
30977
31038
|
return {
|
|
30978
|
-
type: ($4b58188d47aafe8d$export$
|
|
31039
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).ONRAMP,
|
|
30979
31040
|
chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
|
|
30980
|
-
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
}
|
|
31041
|
+
fundingItem: {
|
|
31042
|
+
type: required.token.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9) ? ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE : ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
31043
|
+
fundsRequired: {
|
|
31044
|
+
amount: delta.balance,
|
|
31045
|
+
formattedAmount: delta.formattedBalance
|
|
31046
|
+
},
|
|
31047
|
+
userBalance: {
|
|
31048
|
+
balance: current.balance,
|
|
31049
|
+
formattedBalance: current.formattedBalance
|
|
31050
|
+
},
|
|
31051
|
+
token: required.token
|
|
30986
31052
|
}
|
|
30987
31053
|
};
|
|
30988
31054
|
};
|
|
@@ -31056,11 +31122,8 @@ const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutin
|
|
|
31056
31122
|
};
|
|
31057
31123
|
const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
|
|
31058
31124
|
if (!$c16168a9c28ae4fd$var$hasAvailableRoutingOptions(availableRoutingOptions)) return {
|
|
31059
|
-
|
|
31060
|
-
|
|
31061
|
-
message: "No options available"
|
|
31062
|
-
},
|
|
31063
|
-
fundingRoutes: []
|
|
31125
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).NO_ROUTE_OPTIONS,
|
|
31126
|
+
message: "No routing options are available"
|
|
31064
31127
|
};
|
|
31065
31128
|
let readOnlyProviders;
|
|
31066
31129
|
try {
|
|
@@ -31094,25 +31157,37 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31094
31157
|
if (index === 2) onRampFundingStep = result;
|
|
31095
31158
|
if (index === 3) bridgeAndSwapFundingSteps = result;
|
|
31096
31159
|
});
|
|
31160
|
+
if (!bridgeFundingStep && swapFundingSteps.length === 0 && !onRampFundingStep && bridgeAndSwapFundingSteps.length === 0) return {
|
|
31161
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).NO_ROUTES_FOUND,
|
|
31162
|
+
message: "Smart Checkout did not find any funding routes to fulfill the transaction"
|
|
31163
|
+
};
|
|
31097
31164
|
const response = {
|
|
31098
|
-
|
|
31099
|
-
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
31100
|
-
message: "Routes not found"
|
|
31101
|
-
},
|
|
31165
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).ROUTES_FOUND,
|
|
31102
31166
|
fundingRoutes: []
|
|
31103
31167
|
};
|
|
31104
31168
|
let priority = 0;
|
|
31105
|
-
if (bridgeFundingStep || swapFundingSteps.length > 0 || onRampFundingStep || bridgeAndSwapFundingSteps.length > 0) {
|
|
31106
|
-
response.response.type = ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND;
|
|
31107
|
-
response.response.message = "Routes found";
|
|
31108
|
-
}
|
|
31109
31169
|
if (bridgeFundingStep) {
|
|
31110
31170
|
priority++;
|
|
31111
31171
|
response.fundingRoutes.push({
|
|
31112
31172
|
priority: priority,
|
|
31113
31173
|
steps: [
|
|
31114
31174
|
bridgeFundingStep
|
|
31115
|
-
]
|
|
31175
|
+
],
|
|
31176
|
+
// WT-1734 - Add fees
|
|
31177
|
+
totalFees: {
|
|
31178
|
+
gas: {
|
|
31179
|
+
amount: (ethers.BigNumber).from(0),
|
|
31180
|
+
formattedAmount: "0"
|
|
31181
|
+
},
|
|
31182
|
+
other: {
|
|
31183
|
+
amount: (ethers.BigNumber).from(0),
|
|
31184
|
+
formattedAmount: "0"
|
|
31185
|
+
},
|
|
31186
|
+
total: {
|
|
31187
|
+
amount: (ethers.BigNumber).from(0),
|
|
31188
|
+
formattedAmount: "0"
|
|
31189
|
+
}
|
|
31190
|
+
}
|
|
31116
31191
|
});
|
|
31117
31192
|
}
|
|
31118
31193
|
if (swapFundingSteps.length > 0) {
|
|
@@ -31122,7 +31197,22 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31122
31197
|
priority: priority,
|
|
31123
31198
|
steps: [
|
|
31124
31199
|
swapFundingStep
|
|
31125
|
-
]
|
|
31200
|
+
],
|
|
31201
|
+
// WT-1734 - Add fees
|
|
31202
|
+
totalFees: {
|
|
31203
|
+
gas: {
|
|
31204
|
+
amount: (ethers.BigNumber).from(0),
|
|
31205
|
+
formattedAmount: "0"
|
|
31206
|
+
},
|
|
31207
|
+
other: {
|
|
31208
|
+
amount: (ethers.BigNumber).from(0),
|
|
31209
|
+
formattedAmount: "0"
|
|
31210
|
+
},
|
|
31211
|
+
total: {
|
|
31212
|
+
amount: (ethers.BigNumber).from(0),
|
|
31213
|
+
formattedAmount: "0"
|
|
31214
|
+
}
|
|
31215
|
+
}
|
|
31126
31216
|
});
|
|
31127
31217
|
});
|
|
31128
31218
|
}
|
|
@@ -31145,34 +31235,29 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31145
31235
|
steps: [
|
|
31146
31236
|
bridgeStep,
|
|
31147
31237
|
swapStep
|
|
31148
|
-
]
|
|
31238
|
+
],
|
|
31239
|
+
// WT-1734 - Add fees
|
|
31240
|
+
totalFees: {
|
|
31241
|
+
gas: {
|
|
31242
|
+
amount: (ethers.BigNumber).from(0),
|
|
31243
|
+
formattedAmount: "0"
|
|
31244
|
+
},
|
|
31245
|
+
other: {
|
|
31246
|
+
amount: (ethers.BigNumber).from(0),
|
|
31247
|
+
formattedAmount: "0"
|
|
31248
|
+
},
|
|
31249
|
+
total: {
|
|
31250
|
+
amount: (ethers.BigNumber).from(0),
|
|
31251
|
+
formattedAmount: "0"
|
|
31252
|
+
}
|
|
31253
|
+
}
|
|
31149
31254
|
});
|
|
31150
31255
|
});
|
|
31151
31256
|
}
|
|
31152
|
-
// eslint-disable-next-line no-console
|
|
31153
|
-
console.log("** response", response);
|
|
31154
31257
|
return response;
|
|
31155
31258
|
};
|
|
31156
31259
|
|
|
31157
31260
|
|
|
31158
|
-
const $0e7419077c373b24$export$4a2a19d99fef3b1b = (balanceCheckResult)=>{
|
|
31159
|
-
let sufficient = true;
|
|
31160
|
-
const transactionRequirements = [];
|
|
31161
|
-
for (const balance of balanceCheckResult.balanceRequirements){
|
|
31162
|
-
if (!balance.sufficient) sufficient = false;
|
|
31163
|
-
transactionRequirements.push({
|
|
31164
|
-
type: balance.type,
|
|
31165
|
-
sufficient: balance.sufficient,
|
|
31166
|
-
required: balance.required,
|
|
31167
|
-
current: balance.current,
|
|
31168
|
-
delta: balance.delta
|
|
31169
|
-
});
|
|
31170
|
-
}
|
|
31171
|
-
return {
|
|
31172
|
-
sufficient: sufficient,
|
|
31173
|
-
transactionRequirements: transactionRequirements
|
|
31174
|
-
};
|
|
31175
|
-
};
|
|
31176
31261
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
31177
31262
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
31178
31263
|
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
@@ -31184,12 +31269,25 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemR
|
|
|
31184
31269
|
aggregatedItems.push(gasItem);
|
|
31185
31270
|
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
31186
31271
|
}
|
|
31187
|
-
const
|
|
31188
|
-
|
|
31189
|
-
const
|
|
31190
|
-
|
|
31191
|
-
|
|
31192
|
-
|
|
31272
|
+
const balanceCheckResult = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
|
|
31273
|
+
const { sufficient: sufficient } = balanceCheckResult;
|
|
31274
|
+
const transactionRequirements = balanceCheckResult.balanceRequirements;
|
|
31275
|
+
if (sufficient) return {
|
|
31276
|
+
sufficient: sufficient,
|
|
31277
|
+
transactionRequirements: transactionRequirements
|
|
31278
|
+
};
|
|
31279
|
+
const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
|
|
31280
|
+
const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
|
|
31281
|
+
const isPassport = provider.provider?.isPassport || false;
|
|
31282
|
+
return {
|
|
31283
|
+
sufficient: sufficient,
|
|
31284
|
+
transactionRequirements: transactionRequirements,
|
|
31285
|
+
router: {
|
|
31286
|
+
isPassport: isPassport,
|
|
31287
|
+
availableRoutingOptions: availableRoutingOptions,
|
|
31288
|
+
routingOutcome: routingOutcome
|
|
31289
|
+
}
|
|
31290
|
+
};
|
|
31193
31291
|
};
|
|
31194
31292
|
|
|
31195
31293
|
|
|
@@ -31434,7 +31532,6 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31434
31532
|
unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
|
|
31435
31533
|
} catch {
|
|
31436
31534
|
// Silently ignore error as this is usually thrown if user does not have enough balance
|
|
31437
|
-
// todo: if balance error - can we determine if its the balance error otherwise throw?
|
|
31438
31535
|
}
|
|
31439
31536
|
try {
|
|
31440
31537
|
unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
|
|
@@ -31473,13 +31570,12 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31473
31570
|
if (smartCheckoutResult.sufficient) {
|
|
31474
31571
|
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
|
|
31475
31572
|
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31476
|
-
|
|
31477
|
-
|
|
31478
|
-
|
|
31479
|
-
|
|
31480
|
-
|
|
31481
|
-
|
|
31482
|
-
}
|
|
31573
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31574
|
+
transactionHash: approvalResult.transactionHash,
|
|
31575
|
+
reason: approvalResult.reason,
|
|
31576
|
+
smartCheckoutResult: [
|
|
31577
|
+
smartCheckoutResult
|
|
31578
|
+
]
|
|
31483
31579
|
};
|
|
31484
31580
|
try {
|
|
31485
31581
|
if (unsignedFulfillmentTransactions.length === 0) unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
|
|
@@ -31490,25 +31586,25 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31490
31586
|
}
|
|
31491
31587
|
const fulfillmentResult = await ($25ac589234c10b67$export$3f05b33bd1f29038)(provider, unsignedFulfillmentTransactions);
|
|
31492
31588
|
if (fulfillmentResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31493
|
-
|
|
31494
|
-
|
|
31495
|
-
|
|
31496
|
-
|
|
31497
|
-
|
|
31498
|
-
|
|
31499
|
-
}
|
|
31589
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31590
|
+
transactionHash: fulfillmentResult.transactionHash,
|
|
31591
|
+
reason: fulfillmentResult.reason,
|
|
31592
|
+
smartCheckoutResult: [
|
|
31593
|
+
smartCheckoutResult
|
|
31594
|
+
]
|
|
31500
31595
|
};
|
|
31501
31596
|
return {
|
|
31502
|
-
|
|
31503
|
-
|
|
31504
|
-
|
|
31505
|
-
|
|
31506
|
-
}
|
|
31597
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
|
|
31598
|
+
smartCheckoutResult: [
|
|
31599
|
+
smartCheckoutResult
|
|
31600
|
+
]
|
|
31507
31601
|
};
|
|
31508
31602
|
}
|
|
31509
31603
|
return {
|
|
31510
|
-
|
|
31511
|
-
|
|
31604
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
|
|
31605
|
+
smartCheckoutResult: [
|
|
31606
|
+
smartCheckoutResult
|
|
31607
|
+
]
|
|
31512
31608
|
};
|
|
31513
31609
|
};
|
|
31514
31610
|
|
|
@@ -31523,7 +31619,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31523
31619
|
const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
|
|
31524
31620
|
let unsignedCancelOrderTransaction;
|
|
31525
31621
|
if (orderIds.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orderIds were passed in, must pass at least one orderId to cancel", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR);
|
|
31526
|
-
// Update this when bulk cancel is
|
|
31622
|
+
// Update this when bulk cancel is supported
|
|
31527
31623
|
const orderId = orderIds[0];
|
|
31528
31624
|
try {
|
|
31529
31625
|
const offererAddress = await provider.getSigner().getAddress();
|
|
@@ -31540,18 +31636,12 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
31540
31636
|
unsignedCancelOrderTransaction
|
|
31541
31637
|
]);
|
|
31542
31638
|
if (result.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31543
|
-
|
|
31544
|
-
|
|
31545
|
-
|
|
31546
|
-
transactionHash: result.transactionHash,
|
|
31547
|
-
reason: result.reason
|
|
31548
|
-
}
|
|
31639
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31640
|
+
transactionHash: result.transactionHash,
|
|
31641
|
+
reason: result.reason
|
|
31549
31642
|
};
|
|
31550
31643
|
return {
|
|
31551
|
-
|
|
31552
|
-
status: {
|
|
31553
|
-
type: ($1e6b81bbd98b3a91$export$c0189a8c30039654).SUCCESS
|
|
31554
|
-
}
|
|
31644
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS
|
|
31555
31645
|
};
|
|
31556
31646
|
};
|
|
31557
31647
|
|
|
@@ -31567,7 +31657,6 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
31567
31657
|
|
|
31568
31658
|
|
|
31569
31659
|
|
|
31570
|
-
|
|
31571
31660
|
const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
|
|
31572
31661
|
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
31573
31662
|
id: id,
|
|
@@ -31631,6 +31720,16 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31631
31720
|
}
|
|
31632
31721
|
});
|
|
31633
31722
|
if (smartCheckoutResult.sufficient) {
|
|
31723
|
+
const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
|
|
31724
|
+
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
|
|
31725
|
+
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31726
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31727
|
+
transactionHash: approvalResult.transactionHash,
|
|
31728
|
+
reason: approvalResult.reason,
|
|
31729
|
+
smartCheckoutResult: [
|
|
31730
|
+
smartCheckoutResult
|
|
31731
|
+
]
|
|
31732
|
+
};
|
|
31634
31733
|
const unsignedMessage = ($a7367d01c6e76b1c$export$d62081fac18000c2)(listing.orderHash, listing.orderComponents, listing.actions);
|
|
31635
31734
|
if (!unsignedMessage) // For sell it is expected the orderbook will always return an unsigned message
|
|
31636
31735
|
// If for some reason it is missing then we cannot proceed with the create listing
|
|
@@ -31639,18 +31738,6 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31639
31738
|
collectionAddress: sellToken.collectionAddress
|
|
31640
31739
|
});
|
|
31641
31740
|
const signedMessage = await ($25ac589234c10b67$export$1d9a7a8a40780de)(provider, unsignedMessage);
|
|
31642
|
-
const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
|
|
31643
|
-
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
|
|
31644
|
-
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31645
|
-
id: sellToken.id,
|
|
31646
|
-
collectionAddress: sellToken.collectionAddress,
|
|
31647
|
-
smartCheckoutResult: smartCheckoutResult,
|
|
31648
|
-
status: {
|
|
31649
|
-
type: ($c2874b006e92b115$export$a9780122aaa0801a).FAILED,
|
|
31650
|
-
transactionHash: approvalResult.transactionHash,
|
|
31651
|
-
reason: approvalResult.reason
|
|
31652
|
-
}
|
|
31653
|
-
};
|
|
31654
31741
|
let orderId = "";
|
|
31655
31742
|
const createListingParams = {
|
|
31656
31743
|
orderComponents: signedMessage.orderComponents,
|
|
@@ -31674,19 +31761,20 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31674
31761
|
});
|
|
31675
31762
|
}
|
|
31676
31763
|
return {
|
|
31677
|
-
|
|
31678
|
-
|
|
31679
|
-
|
|
31680
|
-
|
|
31681
|
-
|
|
31682
|
-
|
|
31683
|
-
|
|
31764
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
|
|
31765
|
+
orderIds: [
|
|
31766
|
+
orderId
|
|
31767
|
+
],
|
|
31768
|
+
smartCheckoutResult: [
|
|
31769
|
+
smartCheckoutResult
|
|
31770
|
+
]
|
|
31684
31771
|
};
|
|
31685
31772
|
}
|
|
31686
31773
|
return {
|
|
31687
|
-
|
|
31688
|
-
|
|
31689
|
-
|
|
31774
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
|
|
31775
|
+
smartCheckoutResult: [
|
|
31776
|
+
smartCheckoutResult
|
|
31777
|
+
]
|
|
31690
31778
|
};
|
|
31691
31779
|
};
|
|
31692
31780
|
|
|
@@ -31898,9 +31986,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31898
31986
|
// eslint-disable-next-line no-console
|
|
31899
31987
|
console.warn("This endpoint is currently under construction.");
|
|
31900
31988
|
if (params.orders.length > 1) // eslint-disable-next-line no-console
|
|
31901
|
-
console.warn("This endpoint currently only
|
|
31989
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31902
31990
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31903
|
-
await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
|
|
31991
|
+
return await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
|
|
31904
31992
|
}
|
|
31905
31993
|
/**
|
|
31906
31994
|
* Determines the requirements for performing a sell.
|
|
@@ -31912,9 +32000,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31912
32000
|
// eslint-disable-next-line no-console
|
|
31913
32001
|
console.warn("This endpoint is currently under construction.");
|
|
31914
32002
|
if (params.orders.length > 1) // eslint-disable-next-line no-console
|
|
31915
|
-
console.warn("This endpoint currently only
|
|
32003
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31916
32004
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31917
|
-
await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
|
|
32005
|
+
return await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
|
|
31918
32006
|
}
|
|
31919
32007
|
/**
|
|
31920
32008
|
* Cancels a sell.
|
|
@@ -31924,9 +32012,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31924
32012
|
// eslint-disable-next-line no-console
|
|
31925
32013
|
console.warn("This endpoint is currently under construction.");
|
|
31926
32014
|
// eslint-disable-next-line no-console
|
|
31927
|
-
console.warn("This endpoint currently only
|
|
32015
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31928
32016
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31929
|
-
await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
|
|
32017
|
+
return await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
|
|
31930
32018
|
}
|
|
31931
32019
|
/**
|
|
31932
32020
|
* Determines the transaction requirements to complete a purchase.
|
|
@@ -31942,7 +32030,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31942
32030
|
} catch {
|
|
31943
32031
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to map item requirements", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).ITEM_REQUIREMENTS_ERROR);
|
|
31944
32032
|
}
|
|
31945
|
-
await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
32033
|
+
return await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
31946
32034
|
}
|
|
31947
32035
|
/**
|
|
31948
32036
|
* Checks if the given object is a Web3 provider.
|
|
@@ -32005,6 +32093,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
32005
32093
|
get ChainName () { return $0472f23319457bfb$export$b874c6b1dfe85e02; },
|
|
32006
32094
|
Checkout: $a8cb37a3fc8eb863$export$1f60ba4ec72508a0,
|
|
32007
32095
|
get CheckoutErrorType () { return $a8bc256d81a5e2c1$export$e3dc0620abde7f5a; },
|
|
32096
|
+
get CheckoutStatus () { return $4b58188d47aafe8d$export$de7bcda3c490bf18; },
|
|
32008
32097
|
get ExchangeType () { return $e055e79256bbc1dd$export$80f4da0d409a629d; },
|
|
32009
32098
|
get GasEstimateType () { return $de275b98d2b651c3$export$788b1fd17f3dad84; },
|
|
32010
32099
|
get GasTokenType () { return $4b58188d47aafe8d$export$537fa3efd10ed435; },
|
|
@@ -32019,11 +32108,54 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
32019
32108
|
function $parcel$export(e, n, v, s) {
|
|
32020
32109
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
32021
32110
|
}
|
|
32022
|
-
|
|
32111
|
+
var $045213b18e9f1f94$exports = {};
|
|
32112
|
+
|
|
32113
|
+
$parcel$export($045213b18e9f1f94$exports, "WidgetTheme", () => $045213b18e9f1f94$export$c88931fdc51854eb);
|
|
32114
|
+
$parcel$export($045213b18e9f1f94$exports, "CheckoutWidgetTagNames", () => $045213b18e9f1f94$export$75be0f6af9650f2c);
|
|
32115
|
+
/**
|
|
32116
|
+
* Enum representing the themes for the Checkout widgets.
|
|
32117
|
+
*/ var $045213b18e9f1f94$export$c88931fdc51854eb;
|
|
32118
|
+
(function(WidgetTheme) {
|
|
32119
|
+
WidgetTheme["LIGHT"] = "light";
|
|
32120
|
+
WidgetTheme["DARK"] = "dark";
|
|
32121
|
+
})($045213b18e9f1f94$export$c88931fdc51854eb || ($045213b18e9f1f94$export$c88931fdc51854eb = {}));
|
|
32122
|
+
var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
32123
|
+
(function(CheckoutWidgetTagNames) {
|
|
32124
|
+
CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
|
|
32125
|
+
CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
|
|
32126
|
+
CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
|
|
32127
|
+
CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
|
|
32128
|
+
CheckoutWidgetTagNames["ONRAMP"] = "imtbl-onramp";
|
|
32129
|
+
})($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
|
|
32130
|
+
|
|
32131
|
+
|
|
32132
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.23.0-alpha";
|
|
32023
32133
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
32024
32134
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
32025
32135
|
|
|
32026
32136
|
|
|
32137
|
+
function $430e3eda76fa4d5f$var$getWidgetConfig(element) {
|
|
32138
|
+
const config = element.getAttribute("widgetconfig");
|
|
32139
|
+
if (!config) return null;
|
|
32140
|
+
try {
|
|
32141
|
+
return JSON.parse(config);
|
|
32142
|
+
} catch (err) {
|
|
32143
|
+
// eslint-disable-next-line no-console
|
|
32144
|
+
console.warn(`Unable to decode widgetconfig for ${element}: `, err);
|
|
32145
|
+
}
|
|
32146
|
+
return null;
|
|
32147
|
+
}
|
|
32148
|
+
function $430e3eda76fa4d5f$var$setWidgetConfig(element, config) {
|
|
32149
|
+
element.setAttribute("widgetconfig", JSON.stringify(config));
|
|
32150
|
+
}
|
|
32151
|
+
function $430e3eda76fa4d5f$var$saveConfig(config) {
|
|
32152
|
+
if (window === undefined) {
|
|
32153
|
+
// eslint-disable-next-line no-console
|
|
32154
|
+
console.error("missing window object: please run Checkout client side");
|
|
32155
|
+
return;
|
|
32156
|
+
}
|
|
32157
|
+
window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
|
|
32158
|
+
}
|
|
32027
32159
|
function $430e3eda76fa4d5f$export$46b1ae20f762ad4c(version) {
|
|
32028
32160
|
const defaultPackageVersion = ($d663162fd5a0853f$export$1169f5475725171b)();
|
|
32029
32161
|
if (version === undefined || version.major === undefined) return defaultPackageVersion;
|
|
@@ -32045,6 +32177,29 @@ function $430e3eda76fa4d5f$export$46b1ae20f762ad4c(version) {
|
|
|
32045
32177
|
if (Number.isInteger(version.build) && version.build >= 0) validatedVersion += `.${version.build.toString()}`;
|
|
32046
32178
|
return validatedVersion;
|
|
32047
32179
|
}
|
|
32180
|
+
function $430e3eda76fa4d5f$var$loadScript(config) {
|
|
32181
|
+
if (document === undefined) {
|
|
32182
|
+
// eslint-disable-next-line no-console
|
|
32183
|
+
console.error("missing document object: please run Checkout client side");
|
|
32184
|
+
return;
|
|
32185
|
+
}
|
|
32186
|
+
const validVersion = $430e3eda76fa4d5f$export$46b1ae20f762ad4c(config?.version);
|
|
32187
|
+
// Prevent the script to be loaded more than once
|
|
32188
|
+
// by checking the presence of the script and its version.
|
|
32189
|
+
const initScript = document.querySelector('[data-product="checkout"]');
|
|
32190
|
+
if (initScript) {
|
|
32191
|
+
// eslint-disable-next-line no-console
|
|
32192
|
+
console.warn("checkout script has already been loaded, it can only be loaded once.");
|
|
32193
|
+
return;
|
|
32194
|
+
}
|
|
32195
|
+
const tag = document.createElement("script");
|
|
32196
|
+
let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout.js`;
|
|
32197
|
+
if (($d663162fd5a0853f$export$83bf90b30cdfd29f)()) cdnUrl = "http://localhost:3000/lib/js/imtbl-checkout.js";
|
|
32198
|
+
tag.setAttribute("data-product", "checkout");
|
|
32199
|
+
tag.setAttribute("data-version", validVersion);
|
|
32200
|
+
tag.setAttribute("src", cdnUrl);
|
|
32201
|
+
document.head.appendChild(tag);
|
|
32202
|
+
}
|
|
32048
32203
|
function $430e3eda76fa4d5f$export$af210a0808087845(config) {
|
|
32049
32204
|
if (window === undefined) {
|
|
32050
32205
|
// eslint-disable-next-line no-console
|
|
@@ -32056,21 +32211,45 @@ function $430e3eda76fa4d5f$export$af210a0808087845(config) {
|
|
|
32056
32211
|
console.error("missing document object: please run Checkout client side");
|
|
32057
32212
|
return;
|
|
32058
32213
|
}
|
|
32059
|
-
|
|
32060
|
-
|
|
32061
|
-
let cdnUrl = `https://cdn.jsdelivr.net/npm/@imtbl/sdk@${validVersion}/dist/browser/checkout.js`;
|
|
32062
|
-
if (($d663162fd5a0853f$export$83bf90b30cdfd29f)()) cdnUrl = "http://localhost:3000/lib/js/imtbl-checkout.js";
|
|
32063
|
-
checkoutWidgetJS.setAttribute("src", cdnUrl);
|
|
32064
|
-
document.head.appendChild(checkoutWidgetJS);
|
|
32065
|
-
window.ImtblCheckoutWidgetConfig = JSON.stringify(config);
|
|
32214
|
+
$430e3eda76fa4d5f$var$loadScript(config || {});
|
|
32215
|
+
$430e3eda76fa4d5f$var$saveConfig(config || {});
|
|
32066
32216
|
}
|
|
32067
32217
|
function $430e3eda76fa4d5f$export$bf1548ba7e61c17f(config) {
|
|
32068
32218
|
if (window === undefined) {
|
|
32219
|
+
// eslint-disable-next-line no-console
|
|
32220
|
+
console.error("missing window object: please run Checkout client side");
|
|
32221
|
+
return;
|
|
32222
|
+
}
|
|
32223
|
+
if (document === undefined) {
|
|
32069
32224
|
// eslint-disable-next-line no-console
|
|
32070
32225
|
console.error("missing document object: please run Checkout client side");
|
|
32071
32226
|
return;
|
|
32072
32227
|
}
|
|
32073
|
-
|
|
32228
|
+
let globalConfig = {};
|
|
32229
|
+
try {
|
|
32230
|
+
globalConfig = JSON.parse(window.ImtblCheckoutWidgetConfig);
|
|
32231
|
+
} catch (err) {
|
|
32232
|
+
// eslint-disable-next-line no-console
|
|
32233
|
+
console.warn("Unable to decode window.ImtblCheckoutWidgetConfig: ", err);
|
|
32234
|
+
}
|
|
32235
|
+
Object.values(($045213b18e9f1f94$export$75be0f6af9650f2c)).forEach((elem)=>{
|
|
32236
|
+
const widgets = document.getElementsByTagName(elem);
|
|
32237
|
+
if (!widgets) return;
|
|
32238
|
+
// Loop through all the widgets to ensure that the script
|
|
32239
|
+
// get the correct local configs for the DOM elements and
|
|
32240
|
+
// simply update the global configurations.
|
|
32241
|
+
for (const e of widgets){
|
|
32242
|
+
const widgetConf = $430e3eda76fa4d5f$var$getWidgetConfig(e) || {};
|
|
32243
|
+
$430e3eda76fa4d5f$var$setWidgetConfig(e, {
|
|
32244
|
+
...widgetConf,
|
|
32245
|
+
...config
|
|
32246
|
+
});
|
|
32247
|
+
}
|
|
32248
|
+
});
|
|
32249
|
+
$430e3eda76fa4d5f$var$saveConfig({
|
|
32250
|
+
...globalConfig,
|
|
32251
|
+
...config
|
|
32252
|
+
});
|
|
32074
32253
|
}
|
|
32075
32254
|
|
|
32076
32255
|
|
|
@@ -32177,27 +32356,6 @@ $parcel$export($d882ddc5600b1284$exports, "OnRampEventType", () => $d882ddc5600b
|
|
|
32177
32356
|
OnRampEventType["SUCCESS"] = "success";
|
|
32178
32357
|
OnRampEventType["FAILURE"] = "failure";
|
|
32179
32358
|
})($d882ddc5600b1284$export$66ec39c0924078d8 || ($d882ddc5600b1284$export$66ec39c0924078d8 = {}));
|
|
32180
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
32181
|
-
|
|
32182
|
-
var $045213b18e9f1f94$exports = {};
|
|
32183
|
-
|
|
32184
|
-
$parcel$export($045213b18e9f1f94$exports, "WidgetTheme", () => $045213b18e9f1f94$export$c88931fdc51854eb);
|
|
32185
|
-
$parcel$export($045213b18e9f1f94$exports, "CheckoutWidgetTagNames", () => $045213b18e9f1f94$export$75be0f6af9650f2c);
|
|
32186
|
-
/**
|
|
32187
|
-
* Enum representing the themes for the Checkout widgets.
|
|
32188
|
-
*/ var $045213b18e9f1f94$export$c88931fdc51854eb;
|
|
32189
|
-
(function(WidgetTheme) {
|
|
32190
|
-
WidgetTheme["LIGHT"] = "light";
|
|
32191
|
-
WidgetTheme["DARK"] = "dark";
|
|
32192
|
-
})($045213b18e9f1f94$export$c88931fdc51854eb || ($045213b18e9f1f94$export$c88931fdc51854eb = {}));
|
|
32193
|
-
var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
32194
|
-
(function(CheckoutWidgetTagNames) {
|
|
32195
|
-
CheckoutWidgetTagNames["CONNECT"] = "imtbl-connect";
|
|
32196
|
-
CheckoutWidgetTagNames["WALLET"] = "imtbl-wallet";
|
|
32197
|
-
CheckoutWidgetTagNames["SWAP"] = "imtbl-swap";
|
|
32198
|
-
CheckoutWidgetTagNames["BRIDGE"] = "imtbl-bridge";
|
|
32199
|
-
CheckoutWidgetTagNames["ONRAMP"] = "imtbl-onramp";
|
|
32200
|
-
})($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
|
|
32201
32359
|
|
|
32202
32360
|
|
|
32203
32361
|
var $1f969328e5988c99$exports = {};
|