@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.js
CHANGED
|
@@ -2987,7 +2987,7 @@ class MultiRollupApiClients {
|
|
|
2987
2987
|
}
|
|
2988
2988
|
|
|
2989
2989
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2990
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.22.
|
|
2990
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.22.3' };
|
|
2991
2991
|
const createConfig = ({ basePath, headers, }) => {
|
|
2992
2992
|
if (!basePath.trim()) {
|
|
2993
2993
|
throw Error('basePath can not be empty');
|
|
@@ -3047,7 +3047,7 @@ class APIError extends Error {
|
|
|
3047
3047
|
|
|
3048
3048
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3049
3049
|
const defaultHeaders = {
|
|
3050
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.22.
|
|
3050
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.22.3',
|
|
3051
3051
|
};
|
|
3052
3052
|
/**
|
|
3053
3053
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -3333,7 +3333,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
3333
3333
|
chainID,
|
|
3334
3334
|
coreContractAddress,
|
|
3335
3335
|
registrationContractAddress,
|
|
3336
|
-
sdkVersion: 'ts-immutable-sdk-0.22.
|
|
3336
|
+
sdkVersion: 'ts-immutable-sdk-0.22.3',
|
|
3337
3337
|
});
|
|
3338
3338
|
/**
|
|
3339
3339
|
* Sets `sdkVersion` at the time of build
|
|
@@ -7903,6 +7903,22 @@ class DeviceCredentialsManager {
|
|
|
7903
7903
|
}
|
|
7904
7904
|
}
|
|
7905
7905
|
|
|
7906
|
+
function isIdTokenExpired(idToken) {
|
|
7907
|
+
if (!idToken) {
|
|
7908
|
+
return false;
|
|
7909
|
+
}
|
|
7910
|
+
const decodedToken = jwt_decode(idToken);
|
|
7911
|
+
const now = Math.floor(Date.now() / 1000);
|
|
7912
|
+
return decodedToken.exp < now;
|
|
7913
|
+
}
|
|
7914
|
+
function isTokenExpired(oidcUser) {
|
|
7915
|
+
const { id_token: idToken, expired } = oidcUser;
|
|
7916
|
+
if (expired) {
|
|
7917
|
+
return true;
|
|
7918
|
+
}
|
|
7919
|
+
return isIdTokenExpired(idToken);
|
|
7920
|
+
}
|
|
7921
|
+
|
|
7906
7922
|
const formUrlEncodedHeader = {
|
|
7907
7923
|
headers: {
|
|
7908
7924
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -8180,23 +8196,30 @@ class AuthManager {
|
|
|
8180
8196
|
}, PassportErrorType.LOGOUT_ERROR);
|
|
8181
8197
|
}
|
|
8182
8198
|
async loginSilent() {
|
|
8183
|
-
return withPassportError(async () =>
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8199
|
+
return withPassportError(async () => this.getUser(), PassportErrorType.SILENT_LOGIN_ERROR);
|
|
8200
|
+
}
|
|
8201
|
+
async getWebUser() {
|
|
8202
|
+
const oidcUser = await this.userManager.getUser();
|
|
8203
|
+
if (!oidcUser) {
|
|
8204
|
+
return null;
|
|
8205
|
+
}
|
|
8206
|
+
const tokenExpired = isTokenExpired(oidcUser);
|
|
8207
|
+
if (!tokenExpired) {
|
|
8192
8208
|
return AuthManager.mapOidcUserToDomainModel(oidcUser);
|
|
8193
|
-
}
|
|
8209
|
+
}
|
|
8210
|
+
if (oidcUser.refresh_token) {
|
|
8211
|
+
const newOidcUser = await this.userManager.signinSilent();
|
|
8212
|
+
if (newOidcUser) {
|
|
8213
|
+
return AuthManager.mapOidcUserToDomainModel(newOidcUser);
|
|
8214
|
+
}
|
|
8215
|
+
}
|
|
8216
|
+
return null;
|
|
8194
8217
|
}
|
|
8195
8218
|
async getUser() {
|
|
8196
8219
|
return withPassportError(async () => {
|
|
8197
|
-
const
|
|
8198
|
-
if (
|
|
8199
|
-
return
|
|
8220
|
+
const user = await this.getWebUser();
|
|
8221
|
+
if (user) {
|
|
8222
|
+
return user;
|
|
8200
8223
|
}
|
|
8201
8224
|
const deviceToken = this.deviceCredentialsManager.getCredentials();
|
|
8202
8225
|
if (deviceToken) {
|
|
@@ -28006,18 +28029,8 @@ class Exchange {
|
|
|
28006
28029
|
|
|
28007
28030
|
|
|
28008
28031
|
|
|
28009
|
-
var $aa144554f9ef124b$export$226b052ecb8ca80;
|
|
28010
|
-
(function(BuyStatusType) {
|
|
28011
|
-
BuyStatusType["SUCCESS"] = "SUCCESS";
|
|
28012
|
-
BuyStatusType["FAILED"] = "FAILED";
|
|
28013
|
-
})($aa144554f9ef124b$export$226b052ecb8ca80 || ($aa144554f9ef124b$export$226b052ecb8ca80 = {}));
|
|
28014
28032
|
|
|
28015
28033
|
|
|
28016
|
-
var $1e6b81bbd98b3a91$export$c0189a8c30039654;
|
|
28017
|
-
(function(CancelStatusType) {
|
|
28018
|
-
CancelStatusType["SUCCESS"] = "SUCCESS";
|
|
28019
|
-
CancelStatusType["FAILED"] = "FAILED";
|
|
28020
|
-
})($1e6b81bbd98b3a91$export$c0189a8c30039654 || ($1e6b81bbd98b3a91$export$c0189a8c30039654 = {}));
|
|
28021
28034
|
|
|
28022
28035
|
|
|
28023
28036
|
/**
|
|
@@ -28071,11 +28084,6 @@ var $a47e48dd2c04791b$export$1f05a55fe0680cc7;
|
|
|
28071
28084
|
|
|
28072
28085
|
|
|
28073
28086
|
|
|
28074
|
-
var $c2874b006e92b115$export$a9780122aaa0801a;
|
|
28075
|
-
(function(SellStatusType) {
|
|
28076
|
-
SellStatusType["SUCCESS"] = "SUCCESS";
|
|
28077
|
-
SellStatusType["FAILED"] = "FAILED";
|
|
28078
|
-
})($c2874b006e92b115$export$a9780122aaa0801a || ($c2874b006e92b115$export$a9780122aaa0801a = {}));
|
|
28079
28087
|
|
|
28080
28088
|
|
|
28081
28089
|
var $08d5ddc39acd6833$export$fd9b17d87f4121d2;
|
|
@@ -28445,6 +28453,12 @@ const $d85ad1457a3f1a83$export$8b8be7a2a654f23e = [
|
|
|
28445
28453
|
];
|
|
28446
28454
|
|
|
28447
28455
|
|
|
28456
|
+
var $4b58188d47aafe8d$export$de7bcda3c490bf18;
|
|
28457
|
+
(function(CheckoutStatus) {
|
|
28458
|
+
CheckoutStatus["SUCCESS"] = "SUCCESS";
|
|
28459
|
+
CheckoutStatus["FAILED"] = "FAILED";
|
|
28460
|
+
CheckoutStatus["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
28461
|
+
})($4b58188d47aafe8d$export$de7bcda3c490bf18 || ($4b58188d47aafe8d$export$de7bcda3c490bf18 = {}));
|
|
28448
28462
|
var $4b58188d47aafe8d$export$1fc8f52ad1810e52;
|
|
28449
28463
|
(function(ItemType) {
|
|
28450
28464
|
ItemType["NATIVE"] = "NATIVE";
|
|
@@ -28461,12 +28475,18 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
|
|
|
28461
28475
|
GasTokenType["NATIVE"] = "NATIVE";
|
|
28462
28476
|
GasTokenType["ERC20"] = "ERC20";
|
|
28463
28477
|
})($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
|
|
28464
|
-
var $4b58188d47aafe8d$export$
|
|
28465
|
-
(function(
|
|
28466
|
-
|
|
28467
|
-
|
|
28468
|
-
|
|
28469
|
-
})($4b58188d47aafe8d$export$
|
|
28478
|
+
var $4b58188d47aafe8d$export$d0616bd3e995b8be;
|
|
28479
|
+
(function(RoutingOutcomeType) {
|
|
28480
|
+
RoutingOutcomeType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
28481
|
+
RoutingOutcomeType["NO_ROUTES_FOUND"] = "NO_ROUTES_FOUND";
|
|
28482
|
+
RoutingOutcomeType["NO_ROUTE_OPTIONS"] = "NO_ROUTE_OPTIONS";
|
|
28483
|
+
})($4b58188d47aafe8d$export$d0616bd3e995b8be || ($4b58188d47aafe8d$export$d0616bd3e995b8be = {}));
|
|
28484
|
+
var $4b58188d47aafe8d$export$6fbaa98ee06d03e8;
|
|
28485
|
+
(function(FundingStepType) {
|
|
28486
|
+
FundingStepType["BRIDGE"] = "BRIDGE";
|
|
28487
|
+
FundingStepType["SWAP"] = "SWAP";
|
|
28488
|
+
FundingStepType["ONRAMP"] = "ONRAMP";
|
|
28489
|
+
})($4b58188d47aafe8d$export$6fbaa98ee06d03e8 || ($4b58188d47aafe8d$export$6fbaa98ee06d03e8 = {}));
|
|
28470
28490
|
|
|
28471
28491
|
|
|
28472
28492
|
var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
@@ -29476,7 +29496,6 @@ async function $2e7bf45a7c9a9570$export$942c8de7174809fc(params, readOnlyProvide
|
|
|
29476
29496
|
|
|
29477
29497
|
|
|
29478
29498
|
|
|
29479
|
-
|
|
29480
29499
|
const $ddc6bcd0896481e5$export$2fbfa41a4de56a89 = (erc20allowances, erc721allowances)=>{
|
|
29481
29500
|
const aggregatedAllowances = [];
|
|
29482
29501
|
if (!erc20allowances.sufficient) {
|
|
@@ -30129,7 +30148,7 @@ const $1fda5c40669a566d$export$2e83e9eeaf217e20 = async ()=>false;
|
|
|
30129
30148
|
|
|
30130
30149
|
|
|
30131
30150
|
const $7f2e17f026d4fc8d$var$isPassportProvider = (provider)=>(provider.provider?.isPassport === true) ?? false;
|
|
30132
|
-
const $7f2e17f026d4fc8d$export$
|
|
30151
|
+
const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
|
|
30133
30152
|
const availableRoutingOptions = {
|
|
30134
30153
|
onRamp: config.isOnRampEnabled,
|
|
30135
30154
|
swap: config.isSwapEnabled,
|
|
@@ -30162,13 +30181,6 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
|
|
|
30162
30181
|
|
|
30163
30182
|
|
|
30164
30183
|
|
|
30165
|
-
var $b23305044c0e096a$export$3057de18ac0c076;
|
|
30166
|
-
(function(RouteCalculatorType) {
|
|
30167
|
-
RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
30168
|
-
RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
|
|
30169
|
-
RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
|
|
30170
|
-
})($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
|
|
30171
|
-
|
|
30172
30184
|
|
|
30173
30185
|
|
|
30174
30186
|
|
|
@@ -30285,6 +30297,44 @@ const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache,
|
|
|
30285
30297
|
};
|
|
30286
30298
|
|
|
30287
30299
|
|
|
30300
|
+
const $91807edfd7057288$export$db6bd467891859dc = (chainId, fundsRequired, userBalance)=>{
|
|
30301
|
+
const tokenAddress = userBalance.token.address;
|
|
30302
|
+
let type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20;
|
|
30303
|
+
if (tokenAddress === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) type = ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE;
|
|
30304
|
+
return {
|
|
30305
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).SWAP,
|
|
30306
|
+
chainId: chainId,
|
|
30307
|
+
fundingItem: {
|
|
30308
|
+
type: type,
|
|
30309
|
+
fundsRequired: {
|
|
30310
|
+
amount: fundsRequired,
|
|
30311
|
+
formattedAmount: (utils$1).formatUnits(fundsRequired, userBalance.token.decimals)
|
|
30312
|
+
},
|
|
30313
|
+
userBalance: {
|
|
30314
|
+
balance: userBalance.balance,
|
|
30315
|
+
formattedBalance: userBalance.formattedBalance
|
|
30316
|
+
},
|
|
30317
|
+
token: userBalance.token
|
|
30318
|
+
},
|
|
30319
|
+
// WT-1734 - Add fees
|
|
30320
|
+
fees: {
|
|
30321
|
+
approvalGasFees: {
|
|
30322
|
+
amount: (BigNumber$1).from(0),
|
|
30323
|
+
formattedAmount: "0"
|
|
30324
|
+
},
|
|
30325
|
+
swapGasFees: {
|
|
30326
|
+
amount: (BigNumber$1).from(0),
|
|
30327
|
+
formattedAmount: "0"
|
|
30328
|
+
},
|
|
30329
|
+
swapFees: [
|
|
30330
|
+
{
|
|
30331
|
+
amount: (BigNumber$1).from(0),
|
|
30332
|
+
formattedAmount: "0"
|
|
30333
|
+
}
|
|
30334
|
+
]
|
|
30335
|
+
}
|
|
30336
|
+
};
|
|
30337
|
+
};
|
|
30288
30338
|
const $91807edfd7057288$export$85e4d8628aabb217 = (balanceRequirement)=>{
|
|
30289
30339
|
let address = "";
|
|
30290
30340
|
let amount = (BigNumber$1).from(0);
|
|
@@ -30373,7 +30423,8 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
30373
30423
|
if (swappableTokens.length === 0) return fundingSteps;
|
|
30374
30424
|
const requiredToken = $91807edfd7057288$export$85e4d8628aabb217(balanceRequirement);
|
|
30375
30425
|
if (requiredToken.address === "") return fundingSteps;
|
|
30376
|
-
const
|
|
30426
|
+
const chainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
|
|
30427
|
+
const l2TokenBalanceResult = tokenBalanceResults.get(chainId);
|
|
30377
30428
|
if (!l2TokenBalanceResult) return fundingSteps;
|
|
30378
30429
|
const l2Balances = l2TokenBalanceResult.balances;
|
|
30379
30430
|
if (l2Balances.length === 0) return fundingSteps;
|
|
@@ -30400,15 +30451,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
30400
30451
|
})) continue;
|
|
30401
30452
|
// User has sufficient funds to cover any approval and swap fees so use this token for the funding route
|
|
30402
30453
|
// Currently we are not prioritising any particular token so just taking the first sufficient token
|
|
30403
|
-
fundingSteps.push(
|
|
30404
|
-
type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).SWAP,
|
|
30405
|
-
chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
|
|
30406
|
-
asset: {
|
|
30407
|
-
balance: userBalanceOfQuotedToken.balance,
|
|
30408
|
-
formattedBalance: userBalanceOfQuotedToken.formattedBalance,
|
|
30409
|
-
token: userBalanceOfQuotedToken.token
|
|
30410
|
-
}
|
|
30411
|
-
});
|
|
30454
|
+
fundingSteps.push($91807edfd7057288$export$db6bd467891859dc(chainId, amountOfQuoteTokenRequired.value, userBalanceOfQuotedToken));
|
|
30412
30455
|
}
|
|
30413
30456
|
return fundingSteps;
|
|
30414
30457
|
};
|
|
@@ -30466,6 +30509,7 @@ const $5a5ccedc98d53d25$export$1ad29657d49c5440 = async (config, tokenBalances,
|
|
|
30466
30509
|
|
|
30467
30510
|
|
|
30468
30511
|
|
|
30512
|
+
|
|
30469
30513
|
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
30470
30514
|
for (const balance of balances.balances){
|
|
30471
30515
|
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
@@ -30478,7 +30522,7 @@ const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
|
30478
30522
|
|
|
30479
30523
|
|
|
30480
30524
|
|
|
30481
|
-
const $
|
|
30525
|
+
const $15fe1c77041bd4f4$export$9e73e22953cebcfc = async (config, readOnlyProviders)=>{
|
|
30482
30526
|
try {
|
|
30483
30527
|
const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
|
|
30484
30528
|
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
@@ -30489,7 +30533,18 @@ const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProvide
|
|
|
30489
30533
|
let totalFees = (0, BigNumber$1).from(0);
|
|
30490
30534
|
if (gasEstimate) totalFees = totalFees.add(gasEstimate);
|
|
30491
30535
|
if (bridgeFee) totalFees = totalFees.add(bridgeFee);
|
|
30492
|
-
return
|
|
30536
|
+
return {
|
|
30537
|
+
type: (0, $4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE,
|
|
30538
|
+
gasFee: {
|
|
30539
|
+
estimatedAmount: gasEstimate ?? (0, BigNumber$1).from(0),
|
|
30540
|
+
token: estimate.gasFee.token
|
|
30541
|
+
},
|
|
30542
|
+
bridgeFee: {
|
|
30543
|
+
estimatedAmount: bridgeFee ?? (0, BigNumber$1).from(0),
|
|
30544
|
+
token: estimate.bridgeFee.token
|
|
30545
|
+
},
|
|
30546
|
+
totalFees: totalFees
|
|
30547
|
+
};
|
|
30493
30548
|
} catch (err) {
|
|
30494
30549
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
30495
30550
|
message: err.message
|
|
@@ -30577,24 +30632,48 @@ const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (tokenBalanceResult, totalFees
|
|
|
30577
30632
|
return balance.gte(totalFees);
|
|
30578
30633
|
};
|
|
30579
30634
|
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
30580
|
-
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$
|
|
30635
|
+
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE);
|
|
30581
30636
|
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
30582
|
-
bridgeFeeEstimate = await ($
|
|
30583
|
-
feeEstimates.set(($4b58188d47aafe8d$export$
|
|
30637
|
+
bridgeFeeEstimate = await ($15fe1c77041bd4f4$export$9e73e22953cebcfc)(config, readOnlyProviders);
|
|
30638
|
+
feeEstimates.set(($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE, bridgeFeeEstimate);
|
|
30584
30639
|
return bridgeFeeEstimate;
|
|
30585
30640
|
};
|
|
30586
|
-
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
30587
|
-
type: ($4b58188d47aafe8d$export$
|
|
30641
|
+
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance, bridgeRequirement, itemType)=>({
|
|
30642
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).BRIDGE,
|
|
30588
30643
|
chainId: chainId,
|
|
30589
|
-
|
|
30590
|
-
|
|
30591
|
-
|
|
30644
|
+
fundingItem: {
|
|
30645
|
+
type: itemType,
|
|
30646
|
+
fundsRequired: {
|
|
30647
|
+
amount: bridgeRequirement.amount,
|
|
30648
|
+
formattedAmount: bridgeRequirement.formattedAmount
|
|
30649
|
+
},
|
|
30650
|
+
userBalance: {
|
|
30651
|
+
balance: balance.balance,
|
|
30652
|
+
formattedBalance: balance.formattedBalance
|
|
30653
|
+
},
|
|
30592
30654
|
token: {
|
|
30593
30655
|
name: balance.token.name,
|
|
30594
30656
|
symbol: balance.token.symbol,
|
|
30595
30657
|
address: balance.token.address,
|
|
30596
30658
|
decimals: balance.token.decimals
|
|
30597
30659
|
}
|
|
30660
|
+
},
|
|
30661
|
+
// WT-1734 - Add fees
|
|
30662
|
+
fees: {
|
|
30663
|
+
approvalGasFees: {
|
|
30664
|
+
amount: (BigNumber$1).from(0),
|
|
30665
|
+
formattedAmount: "0"
|
|
30666
|
+
},
|
|
30667
|
+
bridgeGasFees: {
|
|
30668
|
+
amount: (BigNumber$1).from(0),
|
|
30669
|
+
formattedAmount: "0"
|
|
30670
|
+
},
|
|
30671
|
+
bridgeFees: [
|
|
30672
|
+
{
|
|
30673
|
+
amount: (BigNumber$1).from(0),
|
|
30674
|
+
formattedAmount: "0"
|
|
30675
|
+
}
|
|
30676
|
+
]
|
|
30598
30677
|
}
|
|
30599
30678
|
});
|
|
30600
30679
|
const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
|
|
@@ -30616,7 +30695,7 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
|
|
|
30616
30695
|
if (allowedTokenList.length === 0) return undefined;
|
|
30617
30696
|
const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
|
|
30618
30697
|
// If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
|
|
30619
|
-
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
|
|
30698
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate.totalFees)) return undefined;
|
|
30620
30699
|
const l1RepresentationResult = await ($887d24b47765b1c0$export$952cdf461a00a8c6)(config, bridgeRequirement.l2address);
|
|
30621
30700
|
// No mapping on L1 for this token
|
|
30622
30701
|
const { l1address: l1address } = l1RepresentationResult;
|
|
@@ -30626,16 +30705,20 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
|
|
|
30626
30705
|
if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
|
|
30627
30706
|
} else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
|
|
30628
30707
|
const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, bridgeRequirement.amount);
|
|
30629
|
-
|
|
30708
|
+
let totalFees = bridgeFeeEstimate.bridgeFee.estimatedAmount;
|
|
30630
30709
|
// If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
|
|
30631
30710
|
if (l1address === ($887d24b47765b1c0$export$c37d8687c27b9660)) {
|
|
30632
30711
|
const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
|
|
30633
|
-
if (
|
|
30712
|
+
if (bridgeFeeEstimate.gasFee.estimatedAmount) totalFees = totalFees.add(bridgeFeeEstimate.gasFee.estimatedAmount);
|
|
30713
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, totalFees)) return undefined;
|
|
30714
|
+
if (nativeETHBalance && nativeETHBalance.balance.gte(bridgeRequirement.amount.add(totalFees))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance, bridgeRequirement, ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE);
|
|
30634
30715
|
return undefined;
|
|
30635
30716
|
}
|
|
30717
|
+
totalFees.add(gasForApproval).add(bridgeFeeEstimate.gasFee.estimatedAmount);
|
|
30718
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, totalFees)) return undefined;
|
|
30636
30719
|
// Find the balance of the L1 representation of the token and check if the balance covers the delta
|
|
30637
30720
|
const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
|
|
30638
|
-
if (erc20balance && erc20balance.balance.gte(bridgeRequirement.amount)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
|
|
30721
|
+
if (erc20balance && erc20balance.balance.gte(bridgeRequirement.amount)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance, bridgeRequirement, ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20);
|
|
30639
30722
|
return undefined;
|
|
30640
30723
|
};
|
|
30641
30724
|
|
|
@@ -30821,18 +30904,19 @@ const $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount = (config, toke
|
|
|
30821
30904
|
const $afd57acae9471ac5$export$1fc63300bde5e690 = (tokenBalances, swapRoutes)=>{
|
|
30822
30905
|
const originalSwapSteps = [];
|
|
30823
30906
|
for (const route of swapRoutes){
|
|
30824
|
-
const { chainId: chainId,
|
|
30907
|
+
const { chainId: chainId, fundingItem: fundingItem } = route;
|
|
30908
|
+
const { userBalance: userBalance } = route.fundingItem;
|
|
30825
30909
|
const tokenBalance = tokenBalances.get(chainId);
|
|
30826
30910
|
if (!tokenBalance) continue;
|
|
30827
30911
|
let originalBalance = (BigNumber$1).from(0);
|
|
30828
30912
|
let originalFormattedBalance = "0";
|
|
30829
|
-
const l2balance = tokenBalance.balances.find((balance)=>balance.token.address ===
|
|
30913
|
+
const l2balance = tokenBalance.balances.find((balance)=>balance.token.address === fundingItem.token.address);
|
|
30830
30914
|
if (l2balance) {
|
|
30831
30915
|
originalBalance = l2balance.balance;
|
|
30832
30916
|
originalFormattedBalance = l2balance.formattedBalance;
|
|
30833
30917
|
}
|
|
30834
|
-
|
|
30835
|
-
|
|
30918
|
+
userBalance.balance = originalBalance;
|
|
30919
|
+
userBalance.formattedBalance = originalFormattedBalance;
|
|
30836
30920
|
originalSwapSteps.push(route);
|
|
30837
30921
|
}
|
|
30838
30922
|
return originalSwapSteps;
|
|
@@ -30842,11 +30926,11 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
|
|
|
30842
30926
|
for (const bridgeFundingStep of bridgeFundingSteps){
|
|
30843
30927
|
if (!bridgeFundingStep) continue;
|
|
30844
30928
|
const mapping = l1tol2Addresses.find((addresses)=>{
|
|
30845
|
-
if (bridgeFundingStep.
|
|
30846
|
-
return addresses.l1address === bridgeFundingStep.
|
|
30929
|
+
if (bridgeFundingStep.fundingItem.token.address === undefined) return addresses.l1address === ($887d24b47765b1c0$export$c37d8687c27b9660) && addresses.l2address;
|
|
30930
|
+
return addresses.l1address === bridgeFundingStep.fundingItem.token.address && addresses.l2address;
|
|
30847
30931
|
});
|
|
30848
30932
|
if (!mapping) continue;
|
|
30849
|
-
const swapFundingStep = swapFundingSteps.find((step)=>step.
|
|
30933
|
+
const swapFundingStep = swapFundingSteps.find((step)=>step.fundingItem.token.address === mapping.l2address);
|
|
30850
30934
|
if (!swapFundingStep) continue;
|
|
30851
30935
|
bridgeAndSwapRoutes.push({
|
|
30852
30936
|
bridgeFundingStep: bridgeFundingStep,
|
|
@@ -30922,22 +31006,27 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
|
|
|
30922
31006
|
|
|
30923
31007
|
const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutingOptions, balanceRequirement)=>{
|
|
30924
31008
|
if (balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20 && balanceRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return undefined;
|
|
30925
|
-
const
|
|
31009
|
+
const { required: required, current: current, delta: delta } = balanceRequirement;
|
|
30926
31010
|
let hasAllowList = false;
|
|
30927
31011
|
const onRampProvidersAllowList = await ($5a5ccedc98d53d25$export$9ec9fc71f3ce62c4)(config, availableRoutingOptions);
|
|
30928
31012
|
Object.values(onRampProvidersAllowList).forEach((onRampAllowList)=>{
|
|
30929
|
-
if (onRampAllowList.length > 0 && !hasAllowList) hasAllowList = !!onRampAllowList.find((token)=>token.address ===
|
|
31013
|
+
if (onRampAllowList.length > 0 && !hasAllowList) hasAllowList = !!onRampAllowList.find((token)=>token.address === required.token?.address);
|
|
30930
31014
|
});
|
|
30931
31015
|
if (!hasAllowList) return undefined;
|
|
30932
31016
|
return {
|
|
30933
|
-
type: ($4b58188d47aafe8d$export$
|
|
31017
|
+
type: ($4b58188d47aafe8d$export$6fbaa98ee06d03e8).ONRAMP,
|
|
30934
31018
|
chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
|
|
30935
|
-
|
|
30936
|
-
|
|
30937
|
-
|
|
30938
|
-
|
|
30939
|
-
|
|
30940
|
-
}
|
|
31019
|
+
fundingItem: {
|
|
31020
|
+
type: required.token.address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9) ? ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE : ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
31021
|
+
fundsRequired: {
|
|
31022
|
+
amount: delta.balance,
|
|
31023
|
+
formattedAmount: delta.formattedBalance
|
|
31024
|
+
},
|
|
31025
|
+
userBalance: {
|
|
31026
|
+
balance: current.balance,
|
|
31027
|
+
formattedBalance: current.formattedBalance
|
|
31028
|
+
},
|
|
31029
|
+
token: required.token
|
|
30941
31030
|
}
|
|
30942
31031
|
};
|
|
30943
31032
|
};
|
|
@@ -31011,11 +31100,8 @@ const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutin
|
|
|
31011
31100
|
};
|
|
31012
31101
|
const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
|
|
31013
31102
|
if (!$c16168a9c28ae4fd$var$hasAvailableRoutingOptions(availableRoutingOptions)) return {
|
|
31014
|
-
|
|
31015
|
-
|
|
31016
|
-
message: "No options available"
|
|
31017
|
-
},
|
|
31018
|
-
fundingRoutes: []
|
|
31103
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).NO_ROUTE_OPTIONS,
|
|
31104
|
+
message: "No routing options are available"
|
|
31019
31105
|
};
|
|
31020
31106
|
let readOnlyProviders;
|
|
31021
31107
|
try {
|
|
@@ -31049,25 +31135,37 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31049
31135
|
if (index === 2) onRampFundingStep = result;
|
|
31050
31136
|
if (index === 3) bridgeAndSwapFundingSteps = result;
|
|
31051
31137
|
});
|
|
31138
|
+
if (!bridgeFundingStep && swapFundingSteps.length === 0 && !onRampFundingStep && bridgeAndSwapFundingSteps.length === 0) return {
|
|
31139
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).NO_ROUTES_FOUND,
|
|
31140
|
+
message: "Smart Checkout did not find any funding routes to fulfill the transaction"
|
|
31141
|
+
};
|
|
31052
31142
|
const response = {
|
|
31053
|
-
|
|
31054
|
-
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
31055
|
-
message: "Routes not found"
|
|
31056
|
-
},
|
|
31143
|
+
type: ($4b58188d47aafe8d$export$d0616bd3e995b8be).ROUTES_FOUND,
|
|
31057
31144
|
fundingRoutes: []
|
|
31058
31145
|
};
|
|
31059
31146
|
let priority = 0;
|
|
31060
|
-
if (bridgeFundingStep || swapFundingSteps.length > 0 || onRampFundingStep || bridgeAndSwapFundingSteps.length > 0) {
|
|
31061
|
-
response.response.type = ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND;
|
|
31062
|
-
response.response.message = "Routes found";
|
|
31063
|
-
}
|
|
31064
31147
|
if (bridgeFundingStep) {
|
|
31065
31148
|
priority++;
|
|
31066
31149
|
response.fundingRoutes.push({
|
|
31067
31150
|
priority: priority,
|
|
31068
31151
|
steps: [
|
|
31069
31152
|
bridgeFundingStep
|
|
31070
|
-
]
|
|
31153
|
+
],
|
|
31154
|
+
// WT-1734 - Add fees
|
|
31155
|
+
totalFees: {
|
|
31156
|
+
gas: {
|
|
31157
|
+
amount: (BigNumber$1).from(0),
|
|
31158
|
+
formattedAmount: "0"
|
|
31159
|
+
},
|
|
31160
|
+
other: {
|
|
31161
|
+
amount: (BigNumber$1).from(0),
|
|
31162
|
+
formattedAmount: "0"
|
|
31163
|
+
},
|
|
31164
|
+
total: {
|
|
31165
|
+
amount: (BigNumber$1).from(0),
|
|
31166
|
+
formattedAmount: "0"
|
|
31167
|
+
}
|
|
31168
|
+
}
|
|
31071
31169
|
});
|
|
31072
31170
|
}
|
|
31073
31171
|
if (swapFundingSteps.length > 0) {
|
|
@@ -31077,7 +31175,22 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31077
31175
|
priority: priority,
|
|
31078
31176
|
steps: [
|
|
31079
31177
|
swapFundingStep
|
|
31080
|
-
]
|
|
31178
|
+
],
|
|
31179
|
+
// WT-1734 - Add fees
|
|
31180
|
+
totalFees: {
|
|
31181
|
+
gas: {
|
|
31182
|
+
amount: (BigNumber$1).from(0),
|
|
31183
|
+
formattedAmount: "0"
|
|
31184
|
+
},
|
|
31185
|
+
other: {
|
|
31186
|
+
amount: (BigNumber$1).from(0),
|
|
31187
|
+
formattedAmount: "0"
|
|
31188
|
+
},
|
|
31189
|
+
total: {
|
|
31190
|
+
amount: (BigNumber$1).from(0),
|
|
31191
|
+
formattedAmount: "0"
|
|
31192
|
+
}
|
|
31193
|
+
}
|
|
31081
31194
|
});
|
|
31082
31195
|
});
|
|
31083
31196
|
}
|
|
@@ -31100,34 +31213,29 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
31100
31213
|
steps: [
|
|
31101
31214
|
bridgeStep,
|
|
31102
31215
|
swapStep
|
|
31103
|
-
]
|
|
31216
|
+
],
|
|
31217
|
+
// WT-1734 - Add fees
|
|
31218
|
+
totalFees: {
|
|
31219
|
+
gas: {
|
|
31220
|
+
amount: (BigNumber$1).from(0),
|
|
31221
|
+
formattedAmount: "0"
|
|
31222
|
+
},
|
|
31223
|
+
other: {
|
|
31224
|
+
amount: (BigNumber$1).from(0),
|
|
31225
|
+
formattedAmount: "0"
|
|
31226
|
+
},
|
|
31227
|
+
total: {
|
|
31228
|
+
amount: (BigNumber$1).from(0),
|
|
31229
|
+
formattedAmount: "0"
|
|
31230
|
+
}
|
|
31231
|
+
}
|
|
31104
31232
|
});
|
|
31105
31233
|
});
|
|
31106
31234
|
}
|
|
31107
|
-
// eslint-disable-next-line no-console
|
|
31108
|
-
console.log("** response", response);
|
|
31109
31235
|
return response;
|
|
31110
31236
|
};
|
|
31111
31237
|
|
|
31112
31238
|
|
|
31113
|
-
const $0e7419077c373b24$export$4a2a19d99fef3b1b = (balanceCheckResult)=>{
|
|
31114
|
-
let sufficient = true;
|
|
31115
|
-
const transactionRequirements = [];
|
|
31116
|
-
for (const balance of balanceCheckResult.balanceRequirements){
|
|
31117
|
-
if (!balance.sufficient) sufficient = false;
|
|
31118
|
-
transactionRequirements.push({
|
|
31119
|
-
type: balance.type,
|
|
31120
|
-
sufficient: balance.sufficient,
|
|
31121
|
-
required: balance.required,
|
|
31122
|
-
current: balance.current,
|
|
31123
|
-
delta: balance.delta
|
|
31124
|
-
});
|
|
31125
|
-
}
|
|
31126
|
-
return {
|
|
31127
|
-
sufficient: sufficient,
|
|
31128
|
-
transactionRequirements: transactionRequirements
|
|
31129
|
-
};
|
|
31130
|
-
};
|
|
31131
31239
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
31132
31240
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
31133
31241
|
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
@@ -31139,12 +31247,25 @@ const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemR
|
|
|
31139
31247
|
aggregatedItems.push(gasItem);
|
|
31140
31248
|
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
31141
31249
|
}
|
|
31142
|
-
const
|
|
31143
|
-
|
|
31144
|
-
const
|
|
31145
|
-
|
|
31146
|
-
|
|
31147
|
-
|
|
31250
|
+
const balanceCheckResult = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
|
|
31251
|
+
const { sufficient: sufficient } = balanceCheckResult;
|
|
31252
|
+
const transactionRequirements = balanceCheckResult.balanceRequirements;
|
|
31253
|
+
if (sufficient) return {
|
|
31254
|
+
sufficient: sufficient,
|
|
31255
|
+
transactionRequirements: transactionRequirements
|
|
31256
|
+
};
|
|
31257
|
+
const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
|
|
31258
|
+
const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
|
|
31259
|
+
const isPassport = provider.provider?.isPassport || false;
|
|
31260
|
+
return {
|
|
31261
|
+
sufficient: sufficient,
|
|
31262
|
+
transactionRequirements: transactionRequirements,
|
|
31263
|
+
router: {
|
|
31264
|
+
isPassport: isPassport,
|
|
31265
|
+
availableRoutingOptions: availableRoutingOptions,
|
|
31266
|
+
routingOutcome: routingOutcome
|
|
31267
|
+
}
|
|
31268
|
+
};
|
|
31148
31269
|
};
|
|
31149
31270
|
|
|
31150
31271
|
|
|
@@ -31389,7 +31510,6 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31389
31510
|
unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
|
|
31390
31511
|
} catch {
|
|
31391
31512
|
// Silently ignore error as this is usually thrown if user does not have enough balance
|
|
31392
|
-
// todo: if balance error - can we determine if its the balance error otherwise throw?
|
|
31393
31513
|
}
|
|
31394
31514
|
try {
|
|
31395
31515
|
unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
|
|
@@ -31428,13 +31548,12 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31428
31548
|
if (smartCheckoutResult.sufficient) {
|
|
31429
31549
|
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
|
|
31430
31550
|
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31431
|
-
|
|
31432
|
-
|
|
31433
|
-
|
|
31434
|
-
|
|
31435
|
-
|
|
31436
|
-
|
|
31437
|
-
}
|
|
31551
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31552
|
+
transactionHash: approvalResult.transactionHash,
|
|
31553
|
+
reason: approvalResult.reason,
|
|
31554
|
+
smartCheckoutResult: [
|
|
31555
|
+
smartCheckoutResult
|
|
31556
|
+
]
|
|
31438
31557
|
};
|
|
31439
31558
|
try {
|
|
31440
31559
|
if (unsignedFulfillmentTransactions.length === 0) unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
|
|
@@ -31445,25 +31564,25 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31445
31564
|
}
|
|
31446
31565
|
const fulfillmentResult = await ($25ac589234c10b67$export$3f05b33bd1f29038)(provider, unsignedFulfillmentTransactions);
|
|
31447
31566
|
if (fulfillmentResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31448
|
-
|
|
31449
|
-
|
|
31450
|
-
|
|
31451
|
-
|
|
31452
|
-
|
|
31453
|
-
|
|
31454
|
-
}
|
|
31567
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31568
|
+
transactionHash: fulfillmentResult.transactionHash,
|
|
31569
|
+
reason: fulfillmentResult.reason,
|
|
31570
|
+
smartCheckoutResult: [
|
|
31571
|
+
smartCheckoutResult
|
|
31572
|
+
]
|
|
31455
31573
|
};
|
|
31456
31574
|
return {
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
|
|
31460
|
-
|
|
31461
|
-
}
|
|
31575
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
|
|
31576
|
+
smartCheckoutResult: [
|
|
31577
|
+
smartCheckoutResult
|
|
31578
|
+
]
|
|
31462
31579
|
};
|
|
31463
31580
|
}
|
|
31464
31581
|
return {
|
|
31465
|
-
|
|
31466
|
-
|
|
31582
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
|
|
31583
|
+
smartCheckoutResult: [
|
|
31584
|
+
smartCheckoutResult
|
|
31585
|
+
]
|
|
31467
31586
|
};
|
|
31468
31587
|
};
|
|
31469
31588
|
|
|
@@ -31478,7 +31597,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
31478
31597
|
const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
|
|
31479
31598
|
let unsignedCancelOrderTransaction;
|
|
31480
31599
|
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);
|
|
31481
|
-
// Update this when bulk cancel is
|
|
31600
|
+
// Update this when bulk cancel is supported
|
|
31482
31601
|
const orderId = orderIds[0];
|
|
31483
31602
|
try {
|
|
31484
31603
|
const offererAddress = await provider.getSigner().getAddress();
|
|
@@ -31495,18 +31614,12 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
31495
31614
|
unsignedCancelOrderTransaction
|
|
31496
31615
|
]);
|
|
31497
31616
|
if (result.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31498
|
-
|
|
31499
|
-
|
|
31500
|
-
|
|
31501
|
-
transactionHash: result.transactionHash,
|
|
31502
|
-
reason: result.reason
|
|
31503
|
-
}
|
|
31617
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31618
|
+
transactionHash: result.transactionHash,
|
|
31619
|
+
reason: result.reason
|
|
31504
31620
|
};
|
|
31505
31621
|
return {
|
|
31506
|
-
|
|
31507
|
-
status: {
|
|
31508
|
-
type: ($1e6b81bbd98b3a91$export$c0189a8c30039654).SUCCESS
|
|
31509
|
-
}
|
|
31622
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS
|
|
31510
31623
|
};
|
|
31511
31624
|
};
|
|
31512
31625
|
|
|
@@ -31522,7 +31635,6 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
31522
31635
|
|
|
31523
31636
|
|
|
31524
31637
|
|
|
31525
|
-
|
|
31526
31638
|
const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
|
|
31527
31639
|
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
31528
31640
|
id: id,
|
|
@@ -31586,6 +31698,16 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31586
31698
|
}
|
|
31587
31699
|
});
|
|
31588
31700
|
if (smartCheckoutResult.sufficient) {
|
|
31701
|
+
const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
|
|
31702
|
+
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
|
|
31703
|
+
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31704
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).FAILED,
|
|
31705
|
+
transactionHash: approvalResult.transactionHash,
|
|
31706
|
+
reason: approvalResult.reason,
|
|
31707
|
+
smartCheckoutResult: [
|
|
31708
|
+
smartCheckoutResult
|
|
31709
|
+
]
|
|
31710
|
+
};
|
|
31589
31711
|
const unsignedMessage = ($a7367d01c6e76b1c$export$d62081fac18000c2)(listing.orderHash, listing.orderComponents, listing.actions);
|
|
31590
31712
|
if (!unsignedMessage) // For sell it is expected the orderbook will always return an unsigned message
|
|
31591
31713
|
// If for some reason it is missing then we cannot proceed with the create listing
|
|
@@ -31594,18 +31716,6 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31594
31716
|
collectionAddress: sellToken.collectionAddress
|
|
31595
31717
|
});
|
|
31596
31718
|
const signedMessage = await ($25ac589234c10b67$export$1d9a7a8a40780de)(provider, unsignedMessage);
|
|
31597
|
-
const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
|
|
31598
|
-
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
|
|
31599
|
-
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
31600
|
-
id: sellToken.id,
|
|
31601
|
-
collectionAddress: sellToken.collectionAddress,
|
|
31602
|
-
smartCheckoutResult: smartCheckoutResult,
|
|
31603
|
-
status: {
|
|
31604
|
-
type: ($c2874b006e92b115$export$a9780122aaa0801a).FAILED,
|
|
31605
|
-
transactionHash: approvalResult.transactionHash,
|
|
31606
|
-
reason: approvalResult.reason
|
|
31607
|
-
}
|
|
31608
|
-
};
|
|
31609
31719
|
let orderId = "";
|
|
31610
31720
|
const createListingParams = {
|
|
31611
31721
|
orderComponents: signedMessage.orderComponents,
|
|
@@ -31629,19 +31739,20 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
31629
31739
|
});
|
|
31630
31740
|
}
|
|
31631
31741
|
return {
|
|
31632
|
-
|
|
31633
|
-
|
|
31634
|
-
|
|
31635
|
-
|
|
31636
|
-
|
|
31637
|
-
|
|
31638
|
-
|
|
31742
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).SUCCESS,
|
|
31743
|
+
orderIds: [
|
|
31744
|
+
orderId
|
|
31745
|
+
],
|
|
31746
|
+
smartCheckoutResult: [
|
|
31747
|
+
smartCheckoutResult
|
|
31748
|
+
]
|
|
31639
31749
|
};
|
|
31640
31750
|
}
|
|
31641
31751
|
return {
|
|
31642
|
-
|
|
31643
|
-
|
|
31644
|
-
|
|
31752
|
+
status: ($4b58188d47aafe8d$export$de7bcda3c490bf18).INSUFFICIENT_FUNDS,
|
|
31753
|
+
smartCheckoutResult: [
|
|
31754
|
+
smartCheckoutResult
|
|
31755
|
+
]
|
|
31645
31756
|
};
|
|
31646
31757
|
};
|
|
31647
31758
|
|
|
@@ -31853,9 +31964,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31853
31964
|
// eslint-disable-next-line no-console
|
|
31854
31965
|
console.warn("This endpoint is currently under construction.");
|
|
31855
31966
|
if (params.orders.length > 1) // eslint-disable-next-line no-console
|
|
31856
|
-
console.warn("This endpoint currently only
|
|
31967
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31857
31968
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31858
|
-
await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
|
|
31969
|
+
return await $64863c39386de592$export$7f8e2b98eca5a7f0(this.config, web3Provider, params.orders);
|
|
31859
31970
|
}
|
|
31860
31971
|
/**
|
|
31861
31972
|
* Determines the requirements for performing a sell.
|
|
@@ -31867,9 +31978,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31867
31978
|
// eslint-disable-next-line no-console
|
|
31868
31979
|
console.warn("This endpoint is currently under construction.");
|
|
31869
31980
|
if (params.orders.length > 1) // eslint-disable-next-line no-console
|
|
31870
|
-
console.warn("This endpoint currently only
|
|
31981
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31871
31982
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31872
|
-
await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
|
|
31983
|
+
return await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
|
|
31873
31984
|
}
|
|
31874
31985
|
/**
|
|
31875
31986
|
* Cancels a sell.
|
|
@@ -31879,9 +31990,9 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31879
31990
|
// eslint-disable-next-line no-console
|
|
31880
31991
|
console.warn("This endpoint is currently under construction.");
|
|
31881
31992
|
// eslint-disable-next-line no-console
|
|
31882
|
-
console.warn("This endpoint currently only
|
|
31993
|
+
console.warn("This endpoint currently only processes the first order in the array.");
|
|
31883
31994
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
31884
|
-
await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
|
|
31995
|
+
return await $9c3db1bb9c8b69d3$export$70b61ad426ddbe54(this.config, web3Provider, params.orderIds);
|
|
31885
31996
|
}
|
|
31886
31997
|
/**
|
|
31887
31998
|
* Determines the transaction requirements to complete a purchase.
|
|
@@ -31897,7 +32008,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
31897
32008
|
} catch {
|
|
31898
32009
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Failed to map item requirements", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).ITEM_REQUIREMENTS_ERROR);
|
|
31899
32010
|
}
|
|
31900
|
-
await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
32011
|
+
return await $0e7419077c373b24$export$9e073f9ada8c81e6(this.config, web3Provider, itemRequirements, params.transactionOrGasAmount);
|
|
31901
32012
|
}
|
|
31902
32013
|
/**
|
|
31903
32014
|
* Checks if the given object is a Web3 provider.
|
|
@@ -31960,6 +32071,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
31960
32071
|
get ChainName () { return $0472f23319457bfb$export$b874c6b1dfe85e02; },
|
|
31961
32072
|
Checkout: $a8cb37a3fc8eb863$export$1f60ba4ec72508a0,
|
|
31962
32073
|
get CheckoutErrorType () { return $a8bc256d81a5e2c1$export$e3dc0620abde7f5a; },
|
|
32074
|
+
get CheckoutStatus () { return $4b58188d47aafe8d$export$de7bcda3c490bf18; },
|
|
31963
32075
|
get ExchangeType () { return $e055e79256bbc1dd$export$80f4da0d409a629d; },
|
|
31964
32076
|
get GasEstimateType () { return $de275b98d2b651c3$export$788b1fd17f3dad84; },
|
|
31965
32077
|
get GasTokenType () { return $4b58188d47aafe8d$export$537fa3efd10ed435; },
|
|
@@ -31974,7 +32086,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
31974
32086
|
function $parcel$export(e, n, v, s) {
|
|
31975
32087
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
31976
32088
|
}
|
|
31977
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.22.
|
|
32089
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.22.3";
|
|
31978
32090
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
31979
32091
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
31980
32092
|
|