@imtbl/sdk 0.18.0 → 0.18.2
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 +29 -10
- package/dist/checkout_sdk.js +350 -59
- package/dist/checkout_widgets.d.ts +1 -2
- package/dist/checkout_widgets.js +1 -2
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +6 -6
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +368 -66
- package/dist/index.d.ts +39 -11
- package/dist/index.js +370 -68
- package/dist/passport.js +19 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import globalAxios$1, { HttpStatusCode as HttpStatusCode$2 } from 'axios';
|
|
1
|
+
import globalAxios$1, { isAxiosError as isAxiosError$1, HttpStatusCode as HttpStatusCode$2 } from 'axios';
|
|
2
2
|
import { ImmutableX, Config, IMXError, createStarkSigner, generateLegacyStarkPrivateKey, TransfersApi, OrdersApi as OrdersApi$1, UsersApi, Contracts, TradesApi, ExchangesApi, WithdrawalsApi, MintsApi, DepositsApi, EncodingApi, TokensApi as TokensApi$1 } from '@imtbl/core-sdk';
|
|
3
|
-
import { UserManager } from 'oidc-client-ts';
|
|
3
|
+
import { UserManager, InMemoryWebStorage, WebStorageStateStore } from 'oidc-client-ts';
|
|
4
4
|
import jwt_decode from 'jwt-decode';
|
|
5
5
|
import * as crypto from 'crypto';
|
|
6
6
|
import { Magic } from 'magic-sdk';
|
|
@@ -22,6 +22,7 @@ import assert from 'assert';
|
|
|
22
22
|
import { FeeAmount, Route, SwapQuoter, Pool, Trade, toHex as toHex$1, encodeRouteToPath } from '@uniswap/v3-sdk';
|
|
23
23
|
import { keccak256 as keccak256$1 } from '@ethersproject/solidity';
|
|
24
24
|
import { SwapRouter } from '@uniswap/router-sdk';
|
|
25
|
+
import { parseUnits as parseUnits$1 } from 'ethers/lib/utils';
|
|
25
26
|
import { jsx } from 'react/jsx-runtime';
|
|
26
27
|
import { useEffect } from 'react';
|
|
27
28
|
|
|
@@ -2702,7 +2703,7 @@ class MultiRollupApiClients {
|
|
|
2702
2703
|
}
|
|
2703
2704
|
|
|
2704
2705
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2705
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.18.
|
|
2706
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.18.2' };
|
|
2706
2707
|
const createConfig = ({ basePath, headers, }) => {
|
|
2707
2708
|
if (!basePath.trim()) {
|
|
2708
2709
|
throw Error('basePath can not be empty');
|
|
@@ -2762,7 +2763,7 @@ class APIError extends Error {
|
|
|
2762
2763
|
|
|
2763
2764
|
/* eslint-disable implicit-arrow-linebreak */
|
|
2764
2765
|
const defaultHeaders = {
|
|
2765
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.18.
|
|
2766
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.18.2',
|
|
2766
2767
|
};
|
|
2767
2768
|
/**
|
|
2768
2769
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -3048,7 +3049,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
3048
3049
|
chainID,
|
|
3049
3050
|
coreContractAddress,
|
|
3050
3051
|
registrationContractAddress,
|
|
3051
|
-
sdkVersion: 'ts-immutable-sdk-0.18.
|
|
3052
|
+
sdkVersion: 'ts-immutable-sdk-0.18.2',
|
|
3052
3053
|
});
|
|
3053
3054
|
/**
|
|
3054
3055
|
* Sets `sdkVersion` at the time of build
|
|
@@ -7536,6 +7537,9 @@ var PassportErrorType;
|
|
|
7536
7537
|
PassportErrorType["CREATE_TRADE_ERROR"] = "CREATE_TRADE_ERROR";
|
|
7537
7538
|
PassportErrorType["OPERATION_NOT_SUPPORTED_ERROR"] = "OPERATION_NOT_SUPPORTED_ERROR";
|
|
7538
7539
|
})(PassportErrorType || (PassportErrorType = {}));
|
|
7540
|
+
function isAPIError(error) {
|
|
7541
|
+
return 'code' in error && 'message' in error;
|
|
7542
|
+
}
|
|
7539
7543
|
class PassportError extends Error {
|
|
7540
7544
|
type;
|
|
7541
7545
|
constructor(message, type) {
|
|
@@ -7548,7 +7552,13 @@ const withPassportError = async (fn, customErrorType) => {
|
|
|
7548
7552
|
return await fn();
|
|
7549
7553
|
}
|
|
7550
7554
|
catch (error) {
|
|
7551
|
-
|
|
7555
|
+
let errorMessage;
|
|
7556
|
+
if (isAxiosError$1(error) && error.response?.data && isAPIError(error.response.data)) {
|
|
7557
|
+
errorMessage = error.response.data.message;
|
|
7558
|
+
}
|
|
7559
|
+
else {
|
|
7560
|
+
errorMessage = error.message;
|
|
7561
|
+
}
|
|
7552
7562
|
throw new PassportError(errorMessage, customErrorType);
|
|
7553
7563
|
}
|
|
7554
7564
|
};
|
|
@@ -7615,6 +7625,8 @@ const formUrlEncodedHeader = {
|
|
|
7615
7625
|
},
|
|
7616
7626
|
};
|
|
7617
7627
|
const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
7628
|
+
const store = typeof window !== 'undefined' ? window.localStorage : new InMemoryWebStorage();
|
|
7629
|
+
const userStore = new WebStorageStateStore({ store });
|
|
7618
7630
|
const baseConfiguration = {
|
|
7619
7631
|
authority: authenticationDomain,
|
|
7620
7632
|
redirect_uri: oidcConfiguration.redirectUri,
|
|
@@ -7631,6 +7643,7 @@ const getAuthConfiguration = ({ oidcConfiguration, authenticationDomain, }) => {
|
|
|
7631
7643
|
mergeClaims: true,
|
|
7632
7644
|
loadUserInfo: true,
|
|
7633
7645
|
scope: oidcConfiguration.scope,
|
|
7646
|
+
userStore,
|
|
7634
7647
|
};
|
|
7635
7648
|
if (oidcConfiguration.audience) {
|
|
7636
7649
|
baseConfiguration.extraQueryParams = {
|
|
@@ -8855,7 +8868,7 @@ class ConfirmationScreen {
|
|
|
8855
8868
|
let href = '';
|
|
8856
8869
|
if (chainType === TransactionApprovalRequestChainTypeEnum.Starkex) {
|
|
8857
8870
|
// eslint-disable-next-line max-len
|
|
8858
|
-
href = `${this.config.passportDomain}/transaction-confirmation/transaction
|
|
8871
|
+
href = `${this.config.passportDomain}/transaction-confirmation/transaction?transactionId=${transactionId}&imxEtherAddress=${imxEtherAddress}&chainType=starkex`;
|
|
8859
8872
|
}
|
|
8860
8873
|
else {
|
|
8861
8874
|
// eslint-disable-next-line max-len
|
|
@@ -8902,7 +8915,7 @@ class ConfirmationScreen {
|
|
|
8902
8915
|
return;
|
|
8903
8916
|
}
|
|
8904
8917
|
this.confirmationWindow = openPopupCenter({
|
|
8905
|
-
url: `${this.config.passportDomain}/transaction-confirmation/loading
|
|
8918
|
+
url: `${this.config.passportDomain}/transaction-confirmation/loading`,
|
|
8906
8919
|
title: CONFIRMATION_WINDOW_TITLE,
|
|
8907
8920
|
width: popupOptions?.width || CONFIRMATION_WINDOW_WIDTH,
|
|
8908
8921
|
height: popupOptions?.height || CONFIRMATION_WINDOW_HEIGHT,
|
|
@@ -27733,6 +27746,8 @@ var $bc2bfebf768286d3$export$8cb0af6b2bed4b64;
|
|
|
27733
27746
|
|
|
27734
27747
|
|
|
27735
27748
|
|
|
27749
|
+
|
|
27750
|
+
|
|
27736
27751
|
var $de275b98d2b651c3$export$788b1fd17f3dad84;
|
|
27737
27752
|
(function(GasEstimateType) {
|
|
27738
27753
|
GasEstimateType["BRIDGE_TO_L2"] = "BRIDGE_TO_L2";
|
|
@@ -28138,6 +28153,12 @@ var $4b58188d47aafe8d$export$537fa3efd10ed435;
|
|
|
28138
28153
|
GasTokenType["NATIVE"] = "NATIVE";
|
|
28139
28154
|
GasTokenType["ERC20"] = "ERC20";
|
|
28140
28155
|
})($4b58188d47aafe8d$export$537fa3efd10ed435 || ($4b58188d47aafe8d$export$537fa3efd10ed435 = {}));
|
|
28156
|
+
var $4b58188d47aafe8d$export$3af78bb3e8650ee6;
|
|
28157
|
+
(function(FundingRouteType) {
|
|
28158
|
+
FundingRouteType["BRIDGE"] = "BRIDGE";
|
|
28159
|
+
FundingRouteType["ONRAMP"] = "ONRAMP";
|
|
28160
|
+
FundingRouteType["SWAP"] = "SWAP";
|
|
28161
|
+
})($4b58188d47aafe8d$export$3af78bb3e8650ee6 || ($4b58188d47aafe8d$export$3af78bb3e8650ee6 = {}));
|
|
28141
28162
|
|
|
28142
28163
|
|
|
28143
28164
|
var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
@@ -28183,6 +28204,7 @@ var $e055e79256bbc1dd$export$80f4da0d409a629d;
|
|
|
28183
28204
|
CheckoutErrorType["EXECUTE_FULFILMENT_TRANSACTION_ERROR"] = "EXECUTE_FULFILMENT_TRANSACTION_ERROR";
|
|
28184
28205
|
CheckoutErrorType["SIGN_MESSAGE_ERROR"] = "SIGN_MESSAGE_ERROR";
|
|
28185
28206
|
CheckoutErrorType["BRIDGE_GAS_ESTIMATE_ERROR"] = "BRIDGE_GAS_ESTIMATE_ERROR";
|
|
28207
|
+
CheckoutErrorType["ORDER_FEE_ERROR"] = "ORDER_FEE_ERROR";
|
|
28186
28208
|
})($a8bc256d81a5e2c1$export$e3dc0620abde7f5a || ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a = {}));
|
|
28187
28209
|
class $a8bc256d81a5e2c1$export$b722478a3cbfa3bc extends Error {
|
|
28188
28210
|
message;
|
|
@@ -29829,12 +29851,6 @@ var $b23305044c0e096a$export$3057de18ac0c076;
|
|
|
29829
29851
|
RouteCalculatorType["NO_ROUTES"] = "NO_ROUTES";
|
|
29830
29852
|
RouteCalculatorType["NO_OPTIONS"] = "NO_OPTIONS";
|
|
29831
29853
|
})($b23305044c0e096a$export$3057de18ac0c076 || ($b23305044c0e096a$export$3057de18ac0c076 = {}));
|
|
29832
|
-
var $b23305044c0e096a$export$3af78bb3e8650ee6;
|
|
29833
|
-
(function(FundingRouteType) {
|
|
29834
|
-
FundingRouteType["BRIDGE"] = "BRIDGE";
|
|
29835
|
-
FundingRouteType["ON_RAMP"] = "ONRAMP";
|
|
29836
|
-
FundingRouteType["SWAP"] = "SWAP";
|
|
29837
|
-
})($b23305044c0e096a$export$3af78bb3e8650ee6 || ($b23305044c0e096a$export$3af78bb3e8650ee6 = {}));
|
|
29838
29854
|
|
|
29839
29855
|
|
|
29840
29856
|
|
|
@@ -29894,7 +29910,6 @@ const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, readOnlyProvider
|
|
|
29894
29910
|
|
|
29895
29911
|
|
|
29896
29912
|
|
|
29897
|
-
|
|
29898
29913
|
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
29899
29914
|
for (const balance of balances.balances){
|
|
29900
29915
|
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
@@ -29978,6 +29993,18 @@ const $5a5ccedc98d53d25$var$filterTokens = (allowedTokens, balances)=>{
|
|
|
29978
29993
|
});
|
|
29979
29994
|
return [];
|
|
29980
29995
|
};
|
|
29996
|
+
const $5a5ccedc98d53d25$export$9ec9fc71f3ce62c4 = async (config, availableRoutingOptions)=>{
|
|
29997
|
+
if (availableRoutingOptions.onRamp) {
|
|
29998
|
+
const onRampOptions = await config.remote.getConfig("onramp");
|
|
29999
|
+
const onRampAllowList = {};
|
|
30000
|
+
Object.entries(onRampOptions).forEach(([onRampProvider, onRampProviderConfig])=>{
|
|
30001
|
+
// Allowed list per onRamp provider
|
|
30002
|
+
onRampAllowList[onRampProvider] = onRampProviderConfig.tokens ?? [];
|
|
30003
|
+
});
|
|
30004
|
+
return onRampAllowList;
|
|
30005
|
+
}
|
|
30006
|
+
return {};
|
|
30007
|
+
};
|
|
29981
30008
|
const $5a5ccedc98d53d25$export$d744af9f1c0712bc = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
29982
30009
|
if (availableRoutingOptions.bridge) {
|
|
29983
30010
|
const allowedTokens = (await config.remote.getConfig("bridge"))?.tokens ?? [];
|
|
@@ -29986,6 +30013,21 @@ const $5a5ccedc98d53d25$export$d744af9f1c0712bc = async (config, tokenBalances,
|
|
|
29986
30013
|
}
|
|
29987
30014
|
return [];
|
|
29988
30015
|
};
|
|
30016
|
+
const $5a5ccedc98d53d25$export$87ed7f956d73690 = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
30017
|
+
if (availableRoutingOptions.swap) {
|
|
30018
|
+
const allowedTokens = (await config.remote.getConfig("dex"))?.tokens ?? [];
|
|
30019
|
+
const balances = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
30020
|
+
return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
|
|
30021
|
+
}
|
|
30022
|
+
return [];
|
|
30023
|
+
};
|
|
30024
|
+
const $5a5ccedc98d53d25$export$1ad29657d49c5440 = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
30025
|
+
const tokenAllowList = {};
|
|
30026
|
+
tokenAllowList.swap = await $5a5ccedc98d53d25$export$87ed7f956d73690(config, tokenBalances, availableRoutingOptions);
|
|
30027
|
+
tokenAllowList.bridge = await $5a5ccedc98d53d25$export$d744af9f1c0712bc(config, tokenBalances, availableRoutingOptions);
|
|
30028
|
+
tokenAllowList.onRamp = await $5a5ccedc98d53d25$export$9ec9fc71f3ce62c4(config, availableRoutingOptions);
|
|
30029
|
+
return tokenAllowList;
|
|
30030
|
+
};
|
|
29989
30031
|
|
|
29990
30032
|
|
|
29991
30033
|
const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (balances, totalFees)=>{
|
|
@@ -30013,14 +30055,14 @@ const $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6 = async (config, balanceRequirem
|
|
|
30013
30055
|
return l1address;
|
|
30014
30056
|
};
|
|
30015
30057
|
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
30016
|
-
let bridgeFeeEstimate = feeEstimates.get(($
|
|
30058
|
+
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE);
|
|
30017
30059
|
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
30018
30060
|
bridgeFeeEstimate = await ($8a49d1a3783a2640$export$3aff971444a4f244)(config, readOnlyProviders);
|
|
30019
|
-
feeEstimates.set(($
|
|
30061
|
+
feeEstimates.set(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE, bridgeFeeEstimate);
|
|
30020
30062
|
return bridgeFeeEstimate;
|
|
30021
30063
|
};
|
|
30022
30064
|
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
30023
|
-
type: ($
|
|
30065
|
+
type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE,
|
|
30024
30066
|
chainId: chainId,
|
|
30025
30067
|
asset: {
|
|
30026
30068
|
balance: balance.balance,
|
|
@@ -30076,6 +30118,7 @@ const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProvide
|
|
|
30076
30118
|
|
|
30077
30119
|
|
|
30078
30120
|
|
|
30121
|
+
|
|
30079
30122
|
async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnlyProviders) {
|
|
30080
30123
|
if (config.isProduction && existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM)) return existingReadOnlyProviders;
|
|
30081
30124
|
if (existingReadOnlyProviders?.has(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA)) return existingReadOnlyProviders;
|
|
@@ -30093,16 +30136,199 @@ async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnl
|
|
|
30093
30136
|
|
|
30094
30137
|
|
|
30095
30138
|
|
|
30139
|
+
|
|
30140
|
+
|
|
30141
|
+
|
|
30142
|
+
|
|
30143
|
+
|
|
30144
|
+
const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, walletAddress, requiredToken, swappableTokens)=>{
|
|
30145
|
+
const dexQuotes = new Map();
|
|
30146
|
+
try {
|
|
30147
|
+
const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, config);
|
|
30148
|
+
const dexTransactionResponsePromises = [];
|
|
30149
|
+
// Create a quote for each swappable token
|
|
30150
|
+
for (const swappableToken of swappableTokens)dexTransactionResponsePromises.push(exchange.getUnsignedSwapTxFromAmountOut(walletAddress, swappableToken, requiredToken.address, requiredToken.amount));
|
|
30151
|
+
// Resolve all the quotes and link them back to the swappable token
|
|
30152
|
+
// The swappable token array is in the same position in the array as the quote in the promise array
|
|
30153
|
+
const dexTransactionResponse = await Promise.all(dexTransactionResponsePromises);
|
|
30154
|
+
dexTransactionResponse.forEach((response, index)=>{
|
|
30155
|
+
const swappableToken = swappableTokens[index];
|
|
30156
|
+
dexQuotes.set(swappableToken, {
|
|
30157
|
+
quote: response.quote,
|
|
30158
|
+
approval: response.approval?.gasFeeEstimate,
|
|
30159
|
+
swap: response.swap.gasFeeEstimate
|
|
30160
|
+
});
|
|
30161
|
+
});
|
|
30162
|
+
return dexQuotes;
|
|
30163
|
+
} catch {
|
|
30164
|
+
return dexQuotes;
|
|
30165
|
+
}
|
|
30166
|
+
};
|
|
30167
|
+
|
|
30168
|
+
|
|
30169
|
+
const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache, walletAddress, requiredToken, swappableTokens)=>{
|
|
30170
|
+
const dexQuotes = dexQuoteCache.get(requiredToken.address);
|
|
30171
|
+
if (dexQuotes) return dexQuotes;
|
|
30172
|
+
const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
|
|
30173
|
+
dexQuoteCache.set(requiredToken.address, quotes);
|
|
30174
|
+
return quotes;
|
|
30175
|
+
};
|
|
30176
|
+
|
|
30177
|
+
|
|
30178
|
+
const $91807edfd7057288$export$85e4d8628aabb217 = (balanceRequirement)=>{
|
|
30179
|
+
let address = "";
|
|
30180
|
+
let amount = (BigNumber$1).from(0);
|
|
30181
|
+
switch(balanceRequirement.type){
|
|
30182
|
+
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
|
|
30183
|
+
address = balanceRequirement.required.token.address ?? "";
|
|
30184
|
+
amount = balanceRequirement.delta.balance;
|
|
30185
|
+
break;
|
|
30186
|
+
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE:
|
|
30187
|
+
address = ($d85ad1457a3f1a83$export$b80040cb173ba6e9);
|
|
30188
|
+
amount = balanceRequirement.delta.balance;
|
|
30189
|
+
break;
|
|
30190
|
+
}
|
|
30191
|
+
return {
|
|
30192
|
+
address: address,
|
|
30193
|
+
amount: amount
|
|
30194
|
+
};
|
|
30195
|
+
};
|
|
30196
|
+
const $91807edfd7057288$export$7b6318fc1a8067b3 = (l2Balances, approval)=>{
|
|
30197
|
+
// Check if approval required
|
|
30198
|
+
if (!approval) return {
|
|
30199
|
+
sufficient: true,
|
|
30200
|
+
approvalGasFee: (BigNumber$1).from(0),
|
|
30201
|
+
approvalGasTokenAddress: ""
|
|
30202
|
+
};
|
|
30203
|
+
const approvalGasFee = approval.value;
|
|
30204
|
+
const approvalGasTokenAddress = approval.token.address;
|
|
30205
|
+
// No balance on L2 to cover approval fees
|
|
30206
|
+
if (l2Balances.length === 0) return {
|
|
30207
|
+
sufficient: false,
|
|
30208
|
+
approvalGasFee: approvalGasFee,
|
|
30209
|
+
approvalGasTokenAddress: approvalGasTokenAddress
|
|
30210
|
+
};
|
|
30211
|
+
// Find the users balance of the approval token
|
|
30212
|
+
const l2BalanceOfApprovalToken = l2Balances.find((balance)=>balance.token.address === approvalGasTokenAddress);
|
|
30213
|
+
if (!l2BalanceOfApprovalToken) return {
|
|
30214
|
+
sufficient: false,
|
|
30215
|
+
approvalGasFee: approvalGasFee,
|
|
30216
|
+
approvalGasTokenAddress: approvalGasTokenAddress
|
|
30217
|
+
};
|
|
30218
|
+
// If the user does not have enough of the token to cover approval fees then return sufficient false
|
|
30219
|
+
if (l2BalanceOfApprovalToken.balance.lt(approvalGasFee)) return {
|
|
30220
|
+
sufficient: false,
|
|
30221
|
+
approvalGasFee: approvalGasFee,
|
|
30222
|
+
approvalGasTokenAddress: approvalGasTokenAddress
|
|
30223
|
+
};
|
|
30224
|
+
// The user has enough to cover approval gas fees
|
|
30225
|
+
return {
|
|
30226
|
+
sufficient: true,
|
|
30227
|
+
approvalGasFee: approvalGasFee,
|
|
30228
|
+
approvalGasTokenAddress: approvalGasTokenAddress
|
|
30229
|
+
};
|
|
30230
|
+
};
|
|
30231
|
+
const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, swapFees, approvalFees, tokenBeingSwapped)=>{
|
|
30232
|
+
// Set up a map of token addresses to amounts for each of the swap fees
|
|
30233
|
+
const feeMap = new Map();
|
|
30234
|
+
// Add the approval fee to list of fees
|
|
30235
|
+
if (approvalFees.approvalGasTokenAddress !== "") feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
|
|
30236
|
+
// Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
|
|
30237
|
+
if (tokenBeingSwapped) {
|
|
30238
|
+
const fee = feeMap.get(tokenBeingSwapped.address);
|
|
30239
|
+
if (fee) feeMap.set(tokenBeingSwapped.address, fee.add(tokenBeingSwapped.amount));
|
|
30240
|
+
else feeMap.set(tokenBeingSwapped.address, tokenBeingSwapped.amount);
|
|
30241
|
+
}
|
|
30242
|
+
// Get all the fees and key them by their token id
|
|
30243
|
+
for (const swapFee of swapFees){
|
|
30244
|
+
const fee = feeMap.get(swapFee.amount.token.address);
|
|
30245
|
+
if (fee) {
|
|
30246
|
+
feeMap.set(swapFee.amount.token.address, fee.add(swapFee.amount.value));
|
|
30247
|
+
continue;
|
|
30248
|
+
}
|
|
30249
|
+
feeMap.set(swapFee.amount.token.address, swapFee.amount.value);
|
|
30250
|
+
}
|
|
30251
|
+
// Go through the map and for each token address check if the user has enough balance to cover the fee
|
|
30252
|
+
for (const [tokenAddress, fee] of feeMap.entries()){
|
|
30253
|
+
if (fee === (BigNumber$1).from(0)) continue;
|
|
30254
|
+
const l2BalanceOfFeeToken = l2Balances.find((balance)=>balance.token.address === tokenAddress);
|
|
30255
|
+
if (!l2BalanceOfFeeToken) return false;
|
|
30256
|
+
if (l2BalanceOfFeeToken.balance.lt(fee)) return false;
|
|
30257
|
+
}
|
|
30258
|
+
return true;
|
|
30259
|
+
};
|
|
30260
|
+
const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, dexQuoteCache, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens)=>{
|
|
30261
|
+
if (!availableRoutingOptions.swap) return undefined;
|
|
30262
|
+
if (swappableTokens.length === 0) return undefined;
|
|
30263
|
+
const requiredToken = $91807edfd7057288$export$85e4d8628aabb217(balanceRequirement);
|
|
30264
|
+
if (requiredToken.address === "") return undefined;
|
|
30265
|
+
const l2TokenBalanceResult = tokenBalanceResults.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
30266
|
+
if (!l2TokenBalanceResult) return undefined;
|
|
30267
|
+
const l2Balances = l2TokenBalanceResult.balances;
|
|
30268
|
+
if (l2Balances.length === 0) return undefined;
|
|
30269
|
+
const quotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, walletAddress, requiredToken, swappableTokens);
|
|
30270
|
+
const quoteTokenAddresses = Array.from(quotes.keys());
|
|
30271
|
+
for (const quoteTokenAddress of quoteTokenAddresses){
|
|
30272
|
+
const quote = quotes.get(quoteTokenAddress);
|
|
30273
|
+
if (!quote) continue;
|
|
30274
|
+
// Find the balance the user has for this quoted token
|
|
30275
|
+
const userBalanceOfQuotedToken = l2Balances.find((balance)=>balance.token.address === quoteTokenAddress);
|
|
30276
|
+
// If no balance found on L2 for this quoted token then continue
|
|
30277
|
+
if (!userBalanceOfQuotedToken) continue;
|
|
30278
|
+
// Check the amount of quoted token required against the user balance
|
|
30279
|
+
const amountOfQuoteTokenRequired = quote.quote.amount;
|
|
30280
|
+
// If user does not have enough balance to perform the swap with this token then continue
|
|
30281
|
+
if (userBalanceOfQuotedToken.balance.lt(amountOfQuoteTokenRequired.value)) continue;
|
|
30282
|
+
const approvalFees = $91807edfd7057288$export$7b6318fc1a8067b3(l2Balances, quote.approval);
|
|
30283
|
+
// If user does not have enough to cover approval fees then continue
|
|
30284
|
+
if (!approvalFees.sufficient) continue;
|
|
30285
|
+
// If user does not have enough to cover swap fees then continue
|
|
30286
|
+
if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, quote.quote.fees, approvalFees, {
|
|
30287
|
+
amount: amountOfQuoteTokenRequired.value,
|
|
30288
|
+
address: quoteTokenAddress
|
|
30289
|
+
})) continue;
|
|
30290
|
+
// User has sufficient funds to cover any approval and swap fees so use this token for the funding route
|
|
30291
|
+
// Currently we are not prioritising any particular token so just taking the first sufficient token
|
|
30292
|
+
return {
|
|
30293
|
+
type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).SWAP,
|
|
30294
|
+
chainId: ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config),
|
|
30295
|
+
asset: {
|
|
30296
|
+
balance: userBalanceOfQuotedToken.balance,
|
|
30297
|
+
formattedBalance: userBalanceOfQuotedToken.formattedBalance,
|
|
30298
|
+
token: userBalanceOfQuotedToken.token
|
|
30299
|
+
}
|
|
30300
|
+
};
|
|
30301
|
+
}
|
|
30302
|
+
return undefined;
|
|
30303
|
+
};
|
|
30304
|
+
|
|
30305
|
+
|
|
30306
|
+
|
|
30307
|
+
|
|
30308
|
+
|
|
30096
30309
|
const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
|
|
30097
30310
|
let insufficientBalanceCount = 0;
|
|
30098
|
-
let
|
|
30311
|
+
let insufficientRequirement;
|
|
30099
30312
|
for (const balanceRequirement of balanceRequirements.balanceRequirements)if (!balanceRequirement.sufficient) {
|
|
30100
30313
|
insufficientBalanceCount++;
|
|
30101
|
-
|
|
30314
|
+
insufficientRequirement = balanceRequirement;
|
|
30102
30315
|
}
|
|
30103
|
-
if (insufficientBalanceCount === 1) return
|
|
30316
|
+
if (insufficientBalanceCount === 1) return insufficientRequirement;
|
|
30104
30317
|
return undefined;
|
|
30105
30318
|
};
|
|
30319
|
+
const $c16168a9c28ae4fd$export$c39a7b7dc167cdb4 = async (config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, swapTokenAllowList)=>{
|
|
30320
|
+
if (!availableRoutingOptions.swap) return undefined;
|
|
30321
|
+
if (insufficientRequirement === undefined) return undefined;
|
|
30322
|
+
if (swapTokenAllowList === undefined) return undefined;
|
|
30323
|
+
const tokenBalanceResult = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
30324
|
+
if (!tokenBalanceResult) return undefined;
|
|
30325
|
+
if (tokenBalanceResult.error !== undefined || !tokenBalanceResult.success) return undefined;
|
|
30326
|
+
if (swapTokenAllowList.length === 0) return undefined;
|
|
30327
|
+
const swappableTokens = swapTokenAllowList.filter((token)=>token.address).map((token)=>token.address);
|
|
30328
|
+
if (swappableTokens.length === 0) return undefined;
|
|
30329
|
+
const swapFundingStep = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens);
|
|
30330
|
+
return swapFundingStep;
|
|
30331
|
+
};
|
|
30106
30332
|
const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, balanceRequirements, availableRoutingOptions)=>{
|
|
30107
30333
|
let readOnlyProviders;
|
|
30108
30334
|
try {
|
|
@@ -30113,40 +30339,52 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
30113
30339
|
});
|
|
30114
30340
|
}
|
|
30115
30341
|
const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
|
|
30342
|
+
const allowList = await ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions);
|
|
30116
30343
|
// Bridge and swap fee cache
|
|
30117
30344
|
const feeEstimates = new Map();
|
|
30118
|
-
//
|
|
30119
|
-
|
|
30345
|
+
// Dex quotes cache
|
|
30346
|
+
const dexQuoteCache = new Map();
|
|
30347
|
+
// Ensures only 1 balance requirement is insufficient otherwise one bridge or one swap route cannot be recommended
|
|
30120
30348
|
const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
|
|
30349
|
+
let bridgeFundingStep;
|
|
30121
30350
|
if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, insufficientRequirement, tokenBalances, feeEstimates);
|
|
30351
|
+
const swapFundingStep = await $c16168a9c28ae4fd$export$c39a7b7dc167cdb4(config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList.swap);
|
|
30122
30352
|
// Check on-ramp routes
|
|
30123
30353
|
// Check swap routes
|
|
30124
30354
|
// > Could bridge first
|
|
30125
30355
|
// > Could on-ramp first
|
|
30126
30356
|
// > Could double swap
|
|
30127
|
-
|
|
30128
|
-
availableOptions: [],
|
|
30129
|
-
response: {
|
|
30130
|
-
type: ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND,
|
|
30131
|
-
message: "Routes found"
|
|
30132
|
-
},
|
|
30133
|
-
fundingRoutes: [
|
|
30134
|
-
{
|
|
30135
|
-
priority: 1,
|
|
30136
|
-
steps: [
|
|
30137
|
-
bridgeFundingStep
|
|
30138
|
-
]
|
|
30139
|
-
}
|
|
30140
|
-
]
|
|
30141
|
-
};
|
|
30142
|
-
return {
|
|
30143
|
-
availableOptions: [],
|
|
30357
|
+
const response = {
|
|
30144
30358
|
response: {
|
|
30145
30359
|
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
30146
30360
|
message: "Routes not found"
|
|
30147
30361
|
},
|
|
30148
30362
|
fundingRoutes: []
|
|
30149
30363
|
};
|
|
30364
|
+
let priority = 0;
|
|
30365
|
+
if (bridgeFundingStep || swapFundingStep) {
|
|
30366
|
+
response.response.type = ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND;
|
|
30367
|
+
response.response.message = "Routes found";
|
|
30368
|
+
}
|
|
30369
|
+
if (bridgeFundingStep) {
|
|
30370
|
+
priority++;
|
|
30371
|
+
response.fundingRoutes.push({
|
|
30372
|
+
priority: priority,
|
|
30373
|
+
steps: [
|
|
30374
|
+
bridgeFundingStep
|
|
30375
|
+
]
|
|
30376
|
+
});
|
|
30377
|
+
}
|
|
30378
|
+
if (swapFundingStep) {
|
|
30379
|
+
priority++;
|
|
30380
|
+
response.fundingRoutes.push({
|
|
30381
|
+
priority: priority,
|
|
30382
|
+
steps: [
|
|
30383
|
+
swapFundingStep
|
|
30384
|
+
]
|
|
30385
|
+
});
|
|
30386
|
+
}
|
|
30387
|
+
return response;
|
|
30150
30388
|
};
|
|
30151
30389
|
|
|
30152
30390
|
|
|
@@ -30470,27 +30708,80 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
30470
30708
|
|
|
30471
30709
|
|
|
30472
30710
|
|
|
30711
|
+
|
|
30712
|
+
|
|
30713
|
+
|
|
30714
|
+
|
|
30715
|
+
const $9051cee080948594$export$9ac1563efd38130 = 1; // 100%
|
|
30716
|
+
const $9051cee080948594$export$768e717351d4b176 = 6; // will allow 0.000001 (0.0001%) as the minimum value
|
|
30717
|
+
const $9051cee080948594$var$calculateFeesPercent = (orderFee, amountBn)=>{
|
|
30718
|
+
const feePercentage = orderFee.amount;
|
|
30719
|
+
// note: multiply in and out of the maximum decimal places to the power of ten to do the math in big number integers
|
|
30720
|
+
const feePercentageMultiplier = Math.round(feePercentage.percentageDecimal * 10 ** $9051cee080948594$export$768e717351d4b176);
|
|
30721
|
+
const bnFeeAmount = amountBn.mul((BigNumber$1).from(feePercentageMultiplier)).div(10 ** $9051cee080948594$export$768e717351d4b176);
|
|
30722
|
+
return bnFeeAmount;
|
|
30723
|
+
};
|
|
30724
|
+
const $9051cee080948594$var$calculateFeesToken = (orderFee, decimals)=>{
|
|
30725
|
+
const feeToken = orderFee.amount;
|
|
30726
|
+
const bnFeeAmount = (parseUnits$1)(feeToken.token, decimals);
|
|
30727
|
+
return bnFeeAmount;
|
|
30728
|
+
};
|
|
30729
|
+
const $9051cee080948594$export$1e69c9cfc42e28d8 = (orderFees, weiAmount, decimals = 18)=>{
|
|
30730
|
+
let totalTokenFees = (BigNumber$1).from(0);
|
|
30731
|
+
const amountBn = (BigNumber$1).from(weiAmount);
|
|
30732
|
+
// note: multiply in and out of the maximum decimal places to the power of ten to do the math in big number integers
|
|
30733
|
+
const totalAllowableFees = amountBn.mul($9051cee080948594$export$9ac1563efd38130 * 10 ** $9051cee080948594$export$768e717351d4b176).div(10 ** $9051cee080948594$export$768e717351d4b176);
|
|
30734
|
+
const calculateFeesResult = [];
|
|
30735
|
+
for (const orderFee of orderFees){
|
|
30736
|
+
let currentFeeBn = (BigNumber$1).from(0);
|
|
30737
|
+
if (Object.hasOwn(orderFee.amount, "percentageDecimal")) {
|
|
30738
|
+
currentFeeBn = $9051cee080948594$var$calculateFeesPercent(orderFee, amountBn);
|
|
30739
|
+
totalTokenFees = totalTokenFees.add(currentFeeBn);
|
|
30740
|
+
} else if (Object.hasOwn(orderFee.amount, "token")) {
|
|
30741
|
+
currentFeeBn = $9051cee080948594$var$calculateFeesToken(orderFee, decimals);
|
|
30742
|
+
totalTokenFees = totalTokenFees.add(currentFeeBn);
|
|
30743
|
+
} else throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Unknown fee type parsed, must be percentageDecimal or token", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).ORDER_FEE_ERROR);
|
|
30744
|
+
if (totalTokenFees.gt(totalAllowableFees)) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`The combined fees are above the allowed maximum of ${$9051cee080948594$export$9ac1563efd38130 * 100}%`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).ORDER_FEE_ERROR);
|
|
30745
|
+
if (currentFeeBn.gt(0)) calculateFeesResult.push({
|
|
30746
|
+
amount: currentFeeBn.toString(),
|
|
30747
|
+
recipient: orderFee.recipient
|
|
30748
|
+
});
|
|
30749
|
+
} // for
|
|
30750
|
+
return calculateFeesResult;
|
|
30751
|
+
};
|
|
30752
|
+
|
|
30753
|
+
|
|
30473
30754
|
const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
|
|
30474
30755
|
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
30475
30756
|
id: id,
|
|
30476
30757
|
contractAddress: contractAddress,
|
|
30477
30758
|
spenderAddress: spenderAddress
|
|
30478
30759
|
});
|
|
30479
|
-
const $9085b221b72ac69e$export$586d02673c66d423 = (buyToken)=>{
|
|
30760
|
+
const $9085b221b72ac69e$export$586d02673c66d423 = (buyToken, decimals = 18)=>{
|
|
30761
|
+
const bnAmount = (parseUnits$1)(buyToken.amount, decimals);
|
|
30480
30762
|
if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return {
|
|
30481
30763
|
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE,
|
|
30482
|
-
amount:
|
|
30764
|
+
amount: bnAmount.toString()
|
|
30483
30765
|
};
|
|
30484
30766
|
return {
|
|
30485
30767
|
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20,
|
|
30486
|
-
amount:
|
|
30768
|
+
amount: bnAmount.toString(),
|
|
30487
30769
|
contractAddress: buyToken.contractAddress
|
|
30488
30770
|
};
|
|
30489
30771
|
};
|
|
30490
|
-
const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider,
|
|
30772
|
+
const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, orders)=>{
|
|
30491
30773
|
let orderbook;
|
|
30492
30774
|
let listing;
|
|
30493
30775
|
let spenderAddress = "";
|
|
30776
|
+
if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were parsed, must parse at least one order", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR);
|
|
30777
|
+
const { buyToken: buyToken, sellToken: sellToken, makerFees: makerFees } = orders[0];
|
|
30778
|
+
let decimals = 18;
|
|
30779
|
+
if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
|
|
30780
|
+
// get this from the allowed list
|
|
30781
|
+
const buyTokenContract = new (Contract$1)(buyToken.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
|
|
30782
|
+
decimals = buyTokenContract.decimals();
|
|
30783
|
+
}
|
|
30784
|
+
const buyTokenOrNative = $9085b221b72ac69e$export$586d02673c66d423(buyToken, decimals);
|
|
30494
30785
|
try {
|
|
30495
30786
|
const walletAddress = await provider.getSigner().getAddress();
|
|
30496
30787
|
orderbook = await $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
@@ -30498,22 +30789,22 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, id, c
|
|
|
30498
30789
|
spenderAddress = seaportContractAddress;
|
|
30499
30790
|
listing = await orderbook.prepareListing({
|
|
30500
30791
|
makerAddress: walletAddress,
|
|
30501
|
-
buy:
|
|
30792
|
+
buy: buyTokenOrNative,
|
|
30502
30793
|
sell: {
|
|
30503
30794
|
type: (0, $4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
30504
|
-
contractAddress:
|
|
30505
|
-
tokenId: id
|
|
30795
|
+
contractAddress: sellToken.collectionAddress,
|
|
30796
|
+
tokenId: sellToken.id
|
|
30506
30797
|
}
|
|
30507
30798
|
});
|
|
30508
30799
|
} catch (err) {
|
|
30509
30800
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while preparing the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR, {
|
|
30510
30801
|
message: err.message,
|
|
30511
|
-
id: id,
|
|
30512
|
-
collectionAddress:
|
|
30802
|
+
id: sellToken.id,
|
|
30803
|
+
collectionAddress: sellToken.collectionAddress
|
|
30513
30804
|
});
|
|
30514
30805
|
}
|
|
30515
30806
|
const itemRequirements = [
|
|
30516
|
-
$9085b221b72ac69e$export$af768ccdf17d5c04(id,
|
|
30807
|
+
$9085b221b72ac69e$export$af768ccdf17d5c04(sellToken.id, sellToken.collectionAddress, spenderAddress)
|
|
30517
30808
|
];
|
|
30518
30809
|
const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
|
|
30519
30810
|
type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).GAS,
|
|
@@ -30527,15 +30818,15 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, id, c
|
|
|
30527
30818
|
if (!unsignedMessage) // For sell it is expected the orderbook will always return an unsigned message
|
|
30528
30819
|
// If for some reason it is missing then we cannot proceed with the create listing
|
|
30529
30820
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("The unsigned message is missing after preparing the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).SIGN_MESSAGE_ERROR, {
|
|
30530
|
-
id: id,
|
|
30531
|
-
collectionAddress:
|
|
30821
|
+
id: sellToken.id,
|
|
30822
|
+
collectionAddress: sellToken.collectionAddress
|
|
30532
30823
|
});
|
|
30533
30824
|
const signedMessage = await ($25ac589234c10b67$export$1d9a7a8a40780de)(provider, unsignedMessage);
|
|
30534
30825
|
const unsignedTransactions = await ($a7367d01c6e76b1c$export$b087719c36e0f2dc)(listing.actions);
|
|
30535
30826
|
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
|
|
30536
30827
|
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
30537
|
-
id: id,
|
|
30538
|
-
collectionAddress:
|
|
30828
|
+
id: sellToken.id,
|
|
30829
|
+
collectionAddress: sellToken.collectionAddress,
|
|
30539
30830
|
smartCheckoutResult: smartCheckoutResult,
|
|
30540
30831
|
status: {
|
|
30541
30832
|
type: ($c2874b006e92b115$export$a9780122aaa0801a).FAILED,
|
|
@@ -30544,23 +30835,31 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, id, c
|
|
|
30544
30835
|
}
|
|
30545
30836
|
};
|
|
30546
30837
|
let orderId = "";
|
|
30838
|
+
const createListingParams = {
|
|
30839
|
+
orderComponents: signedMessage.orderComponents,
|
|
30840
|
+
orderHash: signedMessage.orderHash,
|
|
30841
|
+
orderSignature: signedMessage.signedMessage
|
|
30842
|
+
};
|
|
30843
|
+
if (makerFees !== undefined) {
|
|
30844
|
+
const orderBookFees = ($9051cee080948594$export$1e69c9cfc42e28d8)(makerFees, buyTokenOrNative.amount, decimals);
|
|
30845
|
+
// @TODO add support for an array of fees when the orderbook enables it
|
|
30846
|
+
if (orderBookFees.length !== makerFees.length) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("One of the fees is too small, must be greater than 0.000001", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CREATE_ORDER_LISTING_ERROR);
|
|
30847
|
+
const [makerFee] = orderBookFees;
|
|
30848
|
+
createListingParams.makerFee = makerFee;
|
|
30849
|
+
}
|
|
30547
30850
|
try {
|
|
30548
|
-
const order = await orderbook.createListing(
|
|
30549
|
-
orderComponents: signedMessage.orderComponents,
|
|
30550
|
-
orderHash: signedMessage.orderHash,
|
|
30551
|
-
orderSignature: signedMessage.signedMessage
|
|
30552
|
-
});
|
|
30851
|
+
const order = await orderbook.createListing(createListingParams);
|
|
30553
30852
|
orderId = order.result.id;
|
|
30554
30853
|
} catch (err) {
|
|
30555
30854
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while creating the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CREATE_ORDER_LISTING_ERROR, {
|
|
30556
30855
|
message: err.message,
|
|
30557
|
-
|
|
30558
|
-
collectionAddress:
|
|
30856
|
+
collectionId: sellToken.id,
|
|
30857
|
+
collectionAddress: sellToken.collectionAddress
|
|
30559
30858
|
});
|
|
30560
30859
|
}
|
|
30561
30860
|
return {
|
|
30562
|
-
id: id,
|
|
30563
|
-
collectionAddress:
|
|
30861
|
+
id: sellToken.id,
|
|
30862
|
+
collectionAddress: sellToken.collectionAddress,
|
|
30564
30863
|
smartCheckoutResult: smartCheckoutResult,
|
|
30565
30864
|
status: {
|
|
30566
30865
|
type: ($c2874b006e92b115$export$a9780122aaa0801a).SUCCESS,
|
|
@@ -30569,8 +30868,8 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, id, c
|
|
|
30569
30868
|
};
|
|
30570
30869
|
}
|
|
30571
30870
|
return {
|
|
30572
|
-
id: id,
|
|
30573
|
-
collectionAddress:
|
|
30871
|
+
id: sellToken.id,
|
|
30872
|
+
collectionAddress: sellToken.collectionAddress,
|
|
30574
30873
|
smartCheckoutResult: smartCheckoutResult
|
|
30575
30874
|
};
|
|
30576
30875
|
};
|
|
@@ -30756,12 +31055,16 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
30756
31055
|
/**
|
|
30757
31056
|
* Determines the requirements for performing a sell.
|
|
30758
31057
|
* @param {SellParams} params - The parameters for the sell.
|
|
31058
|
+
* Only currently actions the first order in the array until we support batch processing.
|
|
31059
|
+
* Only currently actions the first fee in the fees array of each order until we support multiple fees.
|
|
30759
31060
|
*/ async sell(params) {
|
|
30760
31061
|
if (this.config.isProduction) throw new Error("This endpoint is not currently available.");
|
|
30761
31062
|
// eslint-disable-next-line no-console
|
|
30762
31063
|
console.warn("This endpoint is currently under construction.");
|
|
31064
|
+
if (params.orders.length > 1) // eslint-disable-next-line no-console
|
|
31065
|
+
console.warn("This endpoint currently only actions the first order in the array.");
|
|
30763
31066
|
const web3Provider = await $bb88265fe45a0393$export$9e1fd9cc88c637a0(this.config, params.provider);
|
|
30764
|
-
await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.
|
|
31067
|
+
await $9085b221b72ac69e$export$e761f9e0703de895(this.config, web3Provider, params.orders);
|
|
30765
31068
|
}
|
|
30766
31069
|
/**
|
|
30767
31070
|
* Cancels a sell.
|
|
@@ -30859,7 +31162,7 @@ var checkout_sdk = /*#__PURE__*/Object.freeze({
|
|
|
30859
31162
|
function $parcel$export(e, n, v, s) {
|
|
30860
31163
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
30861
31164
|
}
|
|
30862
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.18.
|
|
31165
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.18.2";
|
|
30863
31166
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
30864
31167
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
30865
31168
|
|
|
@@ -31014,7 +31317,6 @@ $parcel$export($045213b18e9f1f94$exports, "CheckoutWidgetTagNames", () => $04521
|
|
|
31014
31317
|
(function(WidgetTheme) {
|
|
31015
31318
|
WidgetTheme["LIGHT"] = "light";
|
|
31016
31319
|
WidgetTheme["DARK"] = "dark";
|
|
31017
|
-
WidgetTheme["CUSTOM"] = "custom";
|
|
31018
31320
|
})($045213b18e9f1f94$export$c88931fdc51854eb || ($045213b18e9f1f94$export$c88931fdc51854eb = {}));
|
|
31019
31321
|
var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
31020
31322
|
(function(CheckoutWidgetTagNames) {
|