@imtbl/sdk 0.22.1 → 0.22.3
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.js +1 -1
- 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 +304 -192
- package/dist/index.d.ts +434 -182
- package/dist/index.js +304 -192
- package/dist/passport.js +38 -15
- package/package.json +2 -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.22.
|
|
3012
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.22.3' };
|
|
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.22.
|
|
3072
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.22.3',
|
|
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.22.
|
|
3358
|
+
sdkVersion: 'ts-immutable-sdk-0.22.3',
|
|
3359
3359
|
});
|
|
3360
3360
|
/**
|
|
3361
3361
|
* Sets `sdkVersion` at the time of build
|
|
@@ -7925,6 +7925,22 @@ class DeviceCredentialsManager {
|
|
|
7925
7925
|
}
|
|
7926
7926
|
}
|
|
7927
7927
|
|
|
7928
|
+
function isIdTokenExpired(idToken) {
|
|
7929
|
+
if (!idToken) {
|
|
7930
|
+
return false;
|
|
7931
|
+
}
|
|
7932
|
+
const decodedToken = jwt_decode(idToken);
|
|
7933
|
+
const now = Math.floor(Date.now() / 1000);
|
|
7934
|
+
return decodedToken.exp < now;
|
|
7935
|
+
}
|
|
7936
|
+
function isTokenExpired(oidcUser) {
|
|
7937
|
+
const { id_token: idToken, expired } = oidcUser;
|
|
7938
|
+
if (expired) {
|
|
7939
|
+
return true;
|
|
7940
|
+
}
|
|
7941
|
+
return isIdTokenExpired(idToken);
|
|
7942
|
+
}
|
|
7943
|
+
|
|
7928
7944
|
const formUrlEncodedHeader = {
|
|
7929
7945
|
headers: {
|
|
7930
7946
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -8202,23 +8218,30 @@ class AuthManager {
|
|
|
8202
8218
|
}, PassportErrorType.LOGOUT_ERROR);
|
|
8203
8219
|
}
|
|
8204
8220
|
async loginSilent() {
|
|
8205
|
-
return withPassportError(async () =>
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
|
|
8210
|
-
|
|
8211
|
-
|
|
8212
|
-
|
|
8213
|
-
|
|
8221
|
+
return withPassportError(async () => this.getUser(), PassportErrorType.SILENT_LOGIN_ERROR);
|
|
8222
|
+
}
|
|
8223
|
+
async getWebUser() {
|
|
8224
|
+
const oidcUser = await this.userManager.getUser();
|
|
8225
|
+
if (!oidcUser) {
|
|
8226
|
+
return null;
|
|
8227
|
+
}
|
|
8228
|
+
const tokenExpired = isTokenExpired(oidcUser);
|
|
8229
|
+
if (!tokenExpired) {
|
|
8214
8230
|
return AuthManager.mapOidcUserToDomainModel(oidcUser);
|
|
8215
|
-
}
|
|
8231
|
+
}
|
|
8232
|
+
if (oidcUser.refresh_token) {
|
|
8233
|
+
const newOidcUser = await this.userManager.signinSilent();
|
|
8234
|
+
if (newOidcUser) {
|
|
8235
|
+
return AuthManager.mapOidcUserToDomainModel(newOidcUser);
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8238
|
+
return null;
|
|
8216
8239
|
}
|
|
8217
8240
|
async getUser() {
|
|
8218
8241
|
return withPassportError(async () => {
|
|
8219
|
-
const
|
|
8220
|
-
if (
|
|
8221
|
-
return
|
|
8242
|
+
const user = await this.getWebUser();
|
|
8243
|
+
if (user) {
|
|
8244
|
+
return user;
|
|
8222
8245
|
}
|
|
8223
8246
|
const deviceToken = this.deviceCredentialsManager.getCredentials();
|
|
8224
8247
|
if (deviceToken) {
|
|
@@ -28028,18 +28051,8 @@ class Exchange {
|
|
|
28028
28051
|
|
|
28029
28052
|
|
|
28030
28053
|
|
|
28031
|
-
var $aa144554f9ef124b$export$226b052ecb8ca80;
|
|
28032
|
-
(function(BuyStatusType) {
|
|
28033
|
-
BuyStatusType["SUCCESS"] = "SUCCESS";
|
|
28034
|
-
BuyStatusType["FAILED"] = "FAILED";
|
|
28035
|
-
})($aa144554f9ef124b$export$226b052ecb8ca80 || ($aa144554f9ef124b$export$226b052ecb8ca80 = {}));
|
|
28036
28054
|
|
|
28037
28055
|
|
|
28038
|
-
var $1e6b81bbd98b3a91$export$c0189a8c30039654;
|
|
28039
|
-
(function(CancelStatusType) {
|
|
28040
|
-
CancelStatusType["SUCCESS"] = "SUCCESS";
|
|
28041
|
-
CancelStatusType["FAILED"] = "FAILED";
|
|
28042
|
-
})($1e6b81bbd98b3a91$export$c0189a8c30039654 || ($1e6b81bbd98b3a91$export$c0189a8c30039654 = {}));
|
|
28043
28056
|
|
|
28044
28057
|
|
|
28045
28058
|
/**
|
|
@@ -28093,11 +28106,6 @@ var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
|
28093
28106
|
|
|
28094
28107
|
|
|
28095
28108
|
|
|
28096
|
-
var $c2874b006e92b115$export$a9780122aaa0801a;
|
|
28097
|
-
(function(SellStatusType) {
|
|
28098
|
-
SellStatusType["SUCCESS"] = "SUCCESS";
|
|
28099
|
-
SellStatusType["FAILED"] = "FAILED";
|
|
28100
|
-
})($c2874b006e92b115$export$a9780122aaa0801a || ($c2874b006e92b115$export$a9780122aaa0801a = {}));
|
|
28101
28109
|
|
|
28102
28110
|
|
|
28103
28111
|
var $08d5ddc39acd6833$export$fd9b17d87f4121d2;
|
|
@@ -28467,6 +28475,12 @@ const $d85ad1457a3f1a83$export$8b8be7a2a654f23e = [
|
|
|
28467
28475
|
];
|
|
28468
28476
|
|
|
28469
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 = {}));
|
|
28470
28484
|
var $4b58188d47aafe8d$export$1fc8f52ad1810e52;
|
|
28471
28485
|
(function(ItemType) {
|
|
28472
28486
|
ItemType["NATIVE"] = "NATIVE";
|
|
@@ -28483,12 +28497,18 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
|
|
|
28483
28497
|
GasTokenType["NATIVE"] = "NATIVE";
|
|
28484
28498
|
GasTokenType["ERC20"] = "ERC20";
|
|
28485
28499
|
})($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
|
|
28486
|
-
var $4b58188d47aafe8d$export$
|
|
28487
|
-
(function(
|
|
28488
|
-
|
|
28489
|
-
|
|
28490
|
-
|
|
28491
|
-
})($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 = {}));
|
|
28492
28512
|
|
|
28493
28513
|
|
|
28494
28514
|
var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
@@ -29498,7 +29518,6 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
29498
29518
|
|
|
29499
29519
|
|
|
29500
29520
|
|
|
29501
|
-
|
|
29502
29521
|
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
29503
29522
|
const aggregatedAllowances = [];
|
|
29504
29523
|
if (!erc20allowances.sufficient) {
|
|
@@ -30151,7 +30170,7 @@ const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>false;
|
|
|
30151
30170
|
|
|
30152
30171
|
|
|
30153
30172
|
const $7f2e17f026d4fc8d$var$isPassportProvider = (provider)=>(provider.provider?.isPassport === true) ?? false;
|
|
30154
|
-
const $7f2e17f026d4fc8d$export$
|
|
30173
|
+
const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
|
|
30155
30174
|
const availableRoutingOptions = {
|
|
30156
30175
|
onRamp: config.isOnRampEnabled,
|
|
30157
30176
|
swap: config.isSwapEnabled,
|
|
@@ -30184,13 +30203,6 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
|
|
|
30184
30203
|
|
|
30185
30204
|
|
|
30186
30205
|
|
|
30187
|
-
var $b23305044c0e096a$export$3057de18ac0c076;
|
|
30188
|
-
(function(RouteCalculatorType) {
|
|
30189
|
-
RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
30190
|
-
RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
|
|
30191
|
-
RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
|
|
30192
|
-
})($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
|
|
30193
|
-
|
|
30194
30206
|
|
|
30195
30207
|
|
|
30196
30208
|
|
|
@@ -30307,6 +30319,44 @@ const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache,
|
|
|
30307
30319
|
};
|
|
30308
30320
|
|
|
30309
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
|
+
};
|
|
30310
30360
|
const $91807edfd7057288$export$85e4d8628aabb217 = (balanceRequirement)=>{
|
|
30311
30361
|
let address = "";
|
|
30312
30362
|
let amount = (ethers.BigNumber).from(0);
|
|
@@ -30395,7 +30445,8 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
30395
30445
|
if (swappableTokens.length === 0) return fundingSteps;
|
|
30396
30446
|
const requiredToken = $91807edfd7057288$export$85e4d8628aabb217(balanceRequirement);
|
|
30397
30447
|
if (requiredToken.address === "") return fundingSteps;
|
|
30398
|
-
const
|
|
30448
|
+
const chainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
|
|
30449
|
+
const l2TokenBalanceResult = tokenBalanceResults.get(chainId);
|
|
30399
30450
|
if (!l2TokenBalanceResult) return fundingSteps;
|
|
30400
30451
|
const l2Balances = l2TokenBalanceResult.balances;
|
|
30401
30452
|
if (l2Balances.length === 0) return fundingSteps;
|
|
@@ -30422,15 +30473,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
30422
30473
|
})) continue;
|
|
30423
30474
|
// User has sufficient funds to cover any approval and swap fees so use this token for the funding route
|
|
30424
30475
|
// Currently we are not prioritising any particular token so just taking the first sufficient token
|
|
30425
|
-
fundingSteps.push(
|
|
30426
|
-
type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).SWAP,
|
|
30427
|
-
chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
|
|
30428
|
-
asset: {
|
|
30429
|
-
balance: userBalanceOfQuotedToken.balance,
|
|
30430
|
-
formattedBalance: userBalanceOfQuotedToken.formattedBalance,
|
|
30431
|
-
token: userBalanceOfQuotedToken.token
|
|
30432
|
-
}
|
|
30433
|
-
});
|
|
30476
|
+
fundingSteps.push($91807edfd7057288$export$db6bd467891859dc(chainId, amountOfQuoteTokenRequired.value, userBalanceOfQuotedToken));
|
|
30434
30477
|
}
|
|
30435
30478
|
return fundingSteps;
|
|
30436
30479
|
};
|
|
@@ -30488,6 +30531,7 @@ const $5a5ccedc98d53d25$export$1ad29657d49c5440 = async (config, tokenBalances,
|
|
|
30488
30531
|
|
|
30489
30532
|
|
|
30490
30533
|
|
|
30534
|
+
|
|
30491
30535
|
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
30492
30536
|
for (const balance of balances.balances){
|
|
30493
30537
|
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
@@ -30500,7 +30544,7 @@ const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
|
30500
30544
|
|
|
30501
30545
|
|
|
30502
30546
|
|
|
30503
|
-
const $
|
|
30547
|
+
const $15fe1c77041bd4f4$export$9e73e22953cebcfc = async (config, readOnlyProviders)=>{
|
|
30504
30548
|
try {
|
|
30505
30549
|
const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
|
|
30506
30550
|
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
@@ -30511,7 +30555,18 @@ const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProvide
|
|
|
30511
30555
|
let totalFees = (0, ethers.BigNumber).from(0);
|
|
30512
30556
|
if (gasEstimate) totalFees = totalFees.add(gasEstimate);
|
|
30513
30557
|
if (bridgeFee) totalFees = totalFees.add(bridgeFee);
|
|
30514
|
-
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
|
+
};
|
|
30515
30570
|
} catch (err) {
|
|
30516
30571
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
30517
30572
|
message: err.message
|
|
@@ -30599,24 +30654,48 @@ const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (tokenBalanceResult, totalFees
|
|
|
30599
30654
|
return balance.gte(totalFees);
|
|
30600
30655
|
};
|
|
30601
30656
|
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
30602
|
-
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$
|
|
30657
|
+
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE);
|
|
30603
30658
|
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
30604
|
-
bridgeFeeEstimate = await ($
|
|
30605
|
-
feeEstimates.set(($4b58188d47aafe8d$export$
|
|
30659
|
+
bridgeFeeEstimate = await ($15fe1c77041bd4f4$export$9e73e22953cebcfc)(config, readOnlyProviders);
|
|
30660
|
+
feeEstimates.set(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE, bridgeFeeEstimate);
|
|
30606
30661
|
return bridgeFeeEstimate;
|
|
30607
30662
|
};
|
|
30608
|
-
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
30609
|
-
type: ($4b58188d47aafe8d$export$
|
|
30663
|
+
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance, bridgeRequirement, itemType)=>({
|
|
30664
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE,
|
|
30610
30665
|
chainId: chainId,
|
|
30611
|
-
|
|
30612
|
-
|
|
30613
|
-
|
|
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
|
+
},
|
|
30614
30676
|
token: {
|
|
30615
30677
|
name: balance.token.name,
|
|
30616
30678
|
symbol: balance.token.symbol,
|
|
30617
30679
|
address: balance.token.address,
|
|
30618
30680
|
decimals: balance.token.decimals
|
|
30619
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
|
+
]
|
|
30620
30699
|
}
|
|
30621
30700
|
});
|
|
30622
30701
|
const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
|
|
@@ -30638,7 +30717,7 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
|
|
|
30638
30717
|
if (allowedTokenList.length === 0) return undefined;
|
|
30639
30718
|
const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
|
|
30640
30719
|
// If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
|
|
30641
|
-
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
|
|
30720
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate.totalFees)) return undefined;
|
|
30642
30721
|
const l1RepresentationResult = await ($887d24b47765b1c0$export$952cdf461a00a8c6)(config, bridgeRequirement.l2address);
|
|
30643
30722
|
// No mapping on L1 for this token
|
|
30644
30723
|
const { l1address: l1address } = l1RepresentationResult;
|
|
@@ -30648,16 +30727,20 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
|
|
|
30648
30727
|
if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
|
|
30649
30728
|
} else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
|
|
30650
30729
|
const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, bridgeRequirement.amount);
|
|
30651
|
-
|
|
30730
|
+
let totalFees = bridgeFeeEstimate.bridgeFee.estimatedAmount;
|
|
30652
30731
|
// If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
|
|
30653
30732
|
if (l1address === ($887d24b47765b1c0$export$c37d8687c27b9660)) {
|
|
30654
30733
|
const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
|
|
30655
|
-
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);
|
|
30656
30737
|
return undefined;
|
|
30657
30738
|
}
|
|
30739
|
+
totalFees.add(gasForApproval).add(bridgeFeeEstimate.gasFee.estimatedAmount);
|
|
30740
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, totalFees)) return undefined;
|
|
30658
30741
|
// Find the balance of the L1 representation of the token and check if the balance covers the delta
|
|
30659
30742
|
const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
|
|
30660
|
-
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);
|
|
30661
30744
|
return undefined;
|
|
30662
30745
|
};
|
|
30663
30746
|
|
|
@@ -30843,18 +30926,19 @@ const $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount = (config, toke
|
|
|
30843
30926
|
const $afd57acae9471ac5$export$1fc63300bde5e690 = (tokenBalances, swapRoutes)=>{
|
|
30844
30927
|
const originalSwapSteps = [];
|
|
30845
30928
|
for (const route of swapRoutes){
|
|
30846
|
-
const { chainId: chainId,
|
|
30929
|
+
const { chainId: chainId, fundingItem: fundingItem } = route;
|
|
30930
|
+
const { userBalance: userBalance } = route.fundingItem;
|
|
30847
30931
|
const tokenBalance = tokenBalances.get(chainId);
|
|
30848
30932
|
if (!tokenBalance) continue;
|
|
30849
30933
|
let originalBalance = (ethers.BigNumber).from(0);
|
|
30850
30934
|
let originalFormattedBalance = "0";
|
|
30851
|
-
const l2balance = tokenBalance.balances.find((balance)=>balance.token.address ===
|
|
30935
|
+
const l2balance = tokenBalance.balances.find((balance)=>balance.token.address === fundingItem.token.address);
|
|
30852
30936
|
if (l2balance) {
|
|
30853
30937
|
originalBalance = l2balance.balance;
|
|
30854
30938
|
originalFormattedBalance = l2balance.formattedBalance;
|
|
30855
30939
|
}
|
|
30856
|
-
|
|
30857
|
-
|
|
30940
|
+
userBalance.balance = originalBalance;
|
|
30941
|
+
userBalance.formattedBalance = originalFormattedBalance;
|
|
30858
30942
|
originalSwapSteps.push(route);
|
|
30859
30943
|
}
|
|
30860
30944
|
return originalSwapSteps;
|
|
@@ -30864,11 +30948,11 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
|
|
|
30864
30948
|
for (const bridgeFundingStep of bridgeFundingSteps){
|
|
30865
30949
|
if (!bridgeFundingStep) continue;
|
|
30866
30950
|
const mapping = l1tol2Addresses.find((addresses)=>{
|
|
30867
|
-
if (bridgeFundingStep.
|
|
30868
|
-
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;
|
|
30869
30953
|
});
|
|
30870
30954
|
if (!mapping) continue;
|
|
30871
|
-
const swapFundingStep = swapFundingSteps.find((step)=>step.
|
|
30955
|
+
const swapFundingStep = swapFundingSteps.find((step)=>step.fundingItem.token.address === mapping.l2address);
|
|
30872
30956
|
if (!swapFundingStep) continue;
|
|
30873
30957
|
bridgeAndSwapRoutes.push({
|
|
30874
30958
|
bridgeFundingStep: bridgeFundingStep,
|
|
@@ -30944,22 +31028,27 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
|
|
|
30944
31028
|
|
|
30945
31029
|
const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutingOptions, balanceRequirement)=>{
|
|
30946
31030
|
if (balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 && balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return undefined;
|
|
30947
|
-
const
|
|
31031
|
+
const { required: required, current: current, delta: delta } = balanceRequirement;
|
|
30948
31032
|
let hasAllowList = false;
|
|
30949
31033
|
const onRampProvidersAllowList = await ($5a5ccedc98d53d25$export$9ec9fc71f3ce62c4)(config, availableRoutingOptions);
|
|
30950
31034
|
Object.values(onRampProvidersAllowList).forEach((onRampAllowList)=>{
|
|
30951
|
-
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);
|
|
30952
31036
|
});
|
|
30953
31037
|
if (!hasAllowList) return undefined;
|
|
30954
31038
|
return {
|
|
30955
|
-
type: ($4b58188d47aafe8d$export$
|
|
31039
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).ONRAMP,
|
|
30956
31040
|
chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
|
|
30957
|
-
|
|
30958
|
-
|
|
30959
|
-
|
|
30960
|
-
|
|
30961
|
-
|
|
30962
|
-
}
|
|
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
|
|
30963
31052
|
}
|
|
30964
31053
|
};
|
|
30965
31054
|
};
|
|
@@ -31033,11 +31122,8 @@ const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutin
|
|
|
31033
31122
|
};
|
|
31034
31123
|
const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
|
|
31035
31124
|
if (!$c16168a9c28ae4fd$var$hasAvailableRoutingOptions(availableRoutingOptions)) return {
|
|
31036
|
-
|
|
31037
|
-
|
|
31038
|
-
message: "No options available"
|
|
31039
|
-
},
|
|
31040
|
-
fundingRoutes: []
|
|
31125
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).NO_ROUTE_OPTIONS,
|
|
31126
|
+
message: "No routing options are available"
|
|
31041
31127
|
};
|
|
31042
31128
|
let readOnlyProviders;
|
|
31043
31129
|
try {
|
|
@@ -31071,25 +31157,37 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31071
31157
|
if (index === 2) onRampFundingStep = result;
|
|
31072
31158
|
if (index === 3) bridgeAndSwapFundingSteps = result;
|
|
31073
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
|
+
};
|
|
31074
31164
|
const response = {
|
|
31075
|
-
|
|
31076
|
-
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
31077
|
-
message: "Routes not found"
|
|
31078
|
-
},
|
|
31165
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).ROUTES_FOUND,
|
|
31079
31166
|
fundingRoutes: []
|
|
31080
31167
|
};
|
|
31081
31168
|
let priority = 0;
|
|
31082
|
-
if (bridgeFundingStep || swapFundingSteps.length > 0 || onRampFundingStep || bridgeAndSwapFundingSteps.length > 0) {
|
|
31083
|
-
response.response.type = ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND;
|
|
31084
|
-
response.response.message = "Routes found";
|
|
31085
|
-
}
|
|
31086
31169
|
if (bridgeFundingStep) {
|
|
31087
31170
|
priority++;
|
|
31088
31171
|
response.fundingRoutes.push({
|
|
31089
31172
|
priority: priority,
|
|
31090
31173
|
steps: [
|
|
31091
31174
|
bridgeFundingStep
|
|
31092
|
-
]
|
|
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
|
+
}
|
|
31093
31191
|
});
|
|
31094
31192
|
}
|
|
31095
31193
|
if (swapFundingSteps.length > 0) {
|
|
@@ -31099,7 +31197,22 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31099
31197
|
priority: priority,
|
|
31100
31198
|
steps: [
|
|
31101
31199
|
swapFundingStep
|
|
31102
|
-
]
|
|
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
|
+
}
|
|
31103
31216
|
});
|
|
31104
31217
|
});
|
|
31105
31218
|
}
|
|
@@ -31122,34 +31235,29 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31122
31235
|
steps: [
|
|
31123
31236
|
bridgeStep,
|
|
31124
31237
|
swapStep
|
|
31125
|
-
]
|
|
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
|
+
}
|
|
31126
31254
|
});
|
|
31127
31255
|
});
|
|
31128
31256
|
}
|
|
31129
|
-
// eslint-disable-next-line no-console
|
|
31130
|
-
console.log("** response", response);
|
|
31131
31257
|
return response;
|
|
31132
31258
|
};
|
|
31133
31259
|
|
|
31134
31260
|
|
|
31135
|
-
const $0e7419077c373b24$export$4a2a19d99fef3b1b = (balanceCheckResult)=>{
|
|
31136
|
-
let sufficient = true;
|
|
31137
|
-
const transactionRequirements = [];
|
|
31138
|
-
for (const balance of balanceCheckResult.balanceRequirements){
|
|
31139
|
-
if (!balance.sufficient) sufficient = false;
|
|
31140
|
-
transactionRequirements.push({
|
|
31141
|
-
type: balance.type,
|
|
31142
|
-
sufficient: balance.sufficient,
|
|
31143
|
-
required: balance.required,
|
|
31144
|
-
current: balance.current,
|
|
31145
|
-
delta: balance.delta
|
|
31146
|
-
});
|
|
31147
|
-
}
|
|
31148
|
-
return {
|
|
31149
|
-
sufficient: sufficient,
|
|
31150
|
-
transactionRequirements: transactionRequirements
|
|
31151
|
-
};
|
|
31152
|
-
};
|
|
31153
31261
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
31154
31262
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
31155
31263
|
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
@@ -31161,12 +31269,25 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemR
|
|
|
31161
31269
|
aggregatedItems.push(gasItem);
|
|
31162
31270
|
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
31163
31271
|
}
|
|
31164
|
-
const
|
|
31165
|
-
|
|
31166
|
-
const
|
|
31167
|
-
|
|
31168
|
-
|
|
31169
|
-
|
|
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
|
+
};
|
|
31170
31291
|
};
|
|
31171
31292
|
|
|
31172
31293
|
|
|
@@ -31411,7 +31532,6 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31411
31532
|
unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
|
|
31412
31533
|
} catch {
|
|
31413
31534
|
// Silently ignore error as this is usually thrown if user does not have enough balance
|
|
31414
|
-
// todo: if balance error - can we determine if its the balance error otherwise throw?
|
|
31415
31535
|
}
|
|
31416
31536
|
try {
|
|
31417
31537
|
unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
|
|
@@ -31450,13 +31570,12 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31450
31570
|
if (smartCheckoutResult.sufficient) {
|
|
31451
31571
|
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
|
|
31452
31572
|
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31453
|
-
|
|
31454
|
-
|
|
31455
|
-
|
|
31456
|
-
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
}
|
|
31573
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31574
|
+
transactionHash: approvalResult.transactionHash,
|
|
31575
|
+
reason: approvalResult.reason,
|
|
31576
|
+
smartCheckoutResult: [
|
|
31577
|
+
smartCheckoutResult
|
|
31578
|
+
]
|
|
31460
31579
|
};
|
|
31461
31580
|
try {
|
|
31462
31581
|
if (unsignedFulfillmentTransactions.length === 0) unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
|
|
@@ -31467,25 +31586,25 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31467
31586
|
}
|
|
31468
31587
|
const fulfillmentResult = await ($25ac589234c10b67$export$3f05b33bd1f29038)(provider, unsignedFulfillmentTransactions);
|
|
31469
31588
|
if (fulfillmentResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31470
|
-
|
|
31471
|
-
|
|
31472
|
-
|
|
31473
|
-
|
|
31474
|
-
|
|
31475
|
-
|
|
31476
|
-
}
|
|
31589
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31590
|
+
transactionHash: fulfillmentResult.transactionHash,
|
|
31591
|
+
reason: fulfillmentResult.reason,
|
|
31592
|
+
smartCheckoutResult: [
|
|
31593
|
+
smartCheckoutResult
|
|
31594
|
+
]
|
|
31477
31595
|
};
|
|
31478
31596
|
return {
|
|
31479
|
-
|
|
31480
|
-
|
|
31481
|
-
|
|
31482
|
-
|
|
31483
|
-
}
|
|
31597
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
|
|
31598
|
+
smartCheckoutResult: [
|
|
31599
|
+
smartCheckoutResult
|
|
31600
|
+
]
|
|
31484
31601
|
};
|
|
31485
31602
|
}
|
|
31486
31603
|
return {
|
|
31487
|
-
|
|
31488
|
-
|
|
31604
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
|
|
31605
|
+
smartCheckoutResult: [
|
|
31606
|
+
smartCheckoutResult
|
|
31607
|
+
]
|
|
31489
31608
|
};
|
|
31490
31609
|
};
|
|
31491
31610
|
|
|
@@ -31500,7 +31619,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31500
31619
|
const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
|
|
31501
31620
|
let unsignedCancelOrderTransaction;
|
|
31502
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);
|
|
31503
|
-
// Update this when bulk cancel is
|
|
31622
|
+
// Update this when bulk cancel is supported
|
|
31504
31623
|
const orderId = orderIds[0];
|
|
31505
31624
|
try {
|
|
31506
31625
|
const offererAddress = await provider.getSigner().getAddress();
|
|
@@ -31517,18 +31636,12 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
31517
31636
|
unsignedCancelOrderTransaction
|
|
31518
31637
|
]);
|
|
31519
31638
|
if (result.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
|
|
31523
|
-
transactionHash: result.transactionHash,
|
|
31524
|
-
reason: result.reason
|
|
31525
|
-
}
|
|
31639
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31640
|
+
transactionHash: result.transactionHash,
|
|
31641
|
+
reason: result.reason
|
|
31526
31642
|
};
|
|
31527
31643
|
return {
|
|
31528
|
-
|
|
31529
|
-
status: {
|
|
31530
|
-
type: ($1e6b81bbd98b3a91$export$c0189a8c30039654).SUCCESS
|
|
31531
|
-
}
|
|
31644
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS
|
|
31532
31645
|
};
|
|
31533
31646
|
};
|
|
31534
31647
|
|
|
@@ -31544,7 +31657,6 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
31544
31657
|
|
|
31545
31658
|
|
|
31546
31659
|
|
|
31547
|
-
|
|
31548
31660
|
const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
|
|
31549
31661
|
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
31550
31662
|
id: id,
|
|
@@ -31608,6 +31720,16 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31608
31720
|
}
|
|
31609
31721
|
});
|
|
31610
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
|
+
};
|
|
31611
31733
|
const unsignedMessage = ($a7367d01c6e76b1c$export$d62081fac18000c2)(listing.orderHash, listing.orderComponents, listing.actions);
|
|
31612
31734
|
if (!unsignedMessage) // For sell it is expected the orderbook will always return an unsigned message
|
|
31613
31735
|
// If for some reason it is missing then we cannot proceed with the create listing
|
|
@@ -31616,18 +31738,6 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31616
31738
|
collectionAddress: sellToken.collectionAddress
|
|
31617
31739
|
});
|
|
31618
31740
|
const signedMessage = await ($25ac589234c10b67$export$1d9a7a8a40780de)(provider, unsignedMessage);
|
|
31619
|
-
const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
|
|
31620
|
-
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
|
|
31621
|
-
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31622
|
-
id: sellToken.id,
|
|
31623
|
-
collectionAddress: sellToken.collectionAddress,
|
|
31624
|
-
smartCheckoutResult: smartCheckoutResult,
|
|
31625
|
-
status: {
|
|
31626
|
-
type: ($c2874b006e92b115$export$a9780122aaa0801a).FAILED,
|
|
31627
|
-
transactionHash: approvalResult.transactionHash,
|
|
31628
|
-
reason: approvalResult.reason
|
|
31629
|
-
}
|
|
31630
|
-
};
|
|
31631
31741
|
let orderId = "";
|
|
31632
31742
|
const createListingParams = {
|
|
31633
31743
|
orderComponents: signedMessage.orderComponents,
|
|
@@ -31651,19 +31761,20 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31651
31761
|
});
|
|
31652
31762
|
}
|
|
31653
31763
|
return {
|
|
31654
|
-
|
|
31655
|
-
|
|
31656
|
-
|
|
31657
|
-
|
|
31658
|
-
|
|
31659
|
-
|
|
31660
|
-
|
|
31764
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
|
|
31765
|
+
orderIds: [
|
|
31766
|
+
orderId
|
|
31767
|
+
],
|
|
31768
|
+
smartCheckoutResult: [
|
|
31769
|
+
smartCheckoutResult
|
|
31770
|
+
]
|
|
31661
31771
|
};
|
|
31662
31772
|
}
|
|
31663
31773
|
return {
|
|
31664
|
-
|
|
31665
|
-
|
|
31666
|
-
|
|
31774
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
|
|
31775
|
+
smartCheckoutResult: [
|
|
31776
|
+
smartCheckoutResult
|
|
31777
|
+
]
|
|
31667
31778
|
};
|
|
31668
31779
|
};
|
|
31669
31780
|
|
|
@@ -31875,9 +31986,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31875
31986
|
// eslint-disable-next-line no-console
|
|
31876
31987
|
console.warn("This endpoint is currently under construction.");
|
|
31877
31988
|
if (params.orders.length > 1) // eslint-disable-next-line no-console
|
|
31878
|
-
console.warn("This endpoint currently only
|
|
31989
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31879
31990
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31880
|
-
await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
|
|
31991
|
+
return await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
|
|
31881
31992
|
}
|
|
31882
31993
|
/**
|
|
31883
31994
|
* Determines the requirements for performing a sell.
|
|
@@ -31889,9 +32000,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31889
32000
|
// eslint-disable-next-line no-console
|
|
31890
32001
|
console.warn("This endpoint is currently under construction.");
|
|
31891
32002
|
if (params.orders.length > 1) // eslint-disable-next-line no-console
|
|
31892
|
-
console.warn("This endpoint currently only
|
|
32003
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31893
32004
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31894
|
-
await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
|
|
32005
|
+
return await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
|
|
31895
32006
|
}
|
|
31896
32007
|
/**
|
|
31897
32008
|
* Cancels a sell.
|
|
@@ -31901,9 +32012,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31901
32012
|
// eslint-disable-next-line no-console
|
|
31902
32013
|
console.warn("This endpoint is currently under construction.");
|
|
31903
32014
|
// eslint-disable-next-line no-console
|
|
31904
|
-
console.warn("This endpoint currently only
|
|
32015
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31905
32016
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31906
|
-
await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
|
|
32017
|
+
return await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
|
|
31907
32018
|
}
|
|
31908
32019
|
/**
|
|
31909
32020
|
* Determines the transaction requirements to complete a purchase.
|
|
@@ -31919,7 +32030,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31919
32030
|
} catch {
|
|
31920
32031
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to map item requirements", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).ITEM_REQUIREMENTS_ERROR);
|
|
31921
32032
|
}
|
|
31922
|
-
await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
32033
|
+
return await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
31923
32034
|
}
|
|
31924
32035
|
/**
|
|
31925
32036
|
* Checks if the given object is a Web3 provider.
|
|
@@ -31982,6 +32093,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
31982
32093
|
get ChainName () { return $0472f23319457bfb$export$b874c6b1dfe85e02; },
|
|
31983
32094
|
Checkout: $a8cb37a3fc8eb863$export$1f60ba4ec72508a0,
|
|
31984
32095
|
get CheckoutErrorType () { return $a8bc256d81a5e2c1$export$e3dc0620abde7f5a; },
|
|
32096
|
+
get CheckoutStatus () { return $4b58188d47aafe8d$export$de7bcda3c490bf18; },
|
|
31985
32097
|
get ExchangeType () { return $e055e79256bbc1dd$export$80f4da0d409a629d; },
|
|
31986
32098
|
get GasEstimateType () { return $de275b98d2b651c3$export$788b1fd17f3dad84; },
|
|
31987
32099
|
get GasTokenType () { return $4b58188d47aafe8d$export$537fa3efd10ed435; },
|
|
@@ -31996,7 +32108,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
31996
32108
|
function $parcel$export(e, n, v, s) {
|
|
31997
32109
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
31998
32110
|
}
|
|
31999
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.22.
|
|
32111
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.22.3";
|
|
32000
32112
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
32001
32113
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
32002
32114
|
|