@funkit/connect 3.4.2 → 3.4.4
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/CHANGELOG.md +24 -0
- package/dist/hooks/useWalletAssets.d.ts +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +739 -692
- package/dist/modals/CheckoutModal/LoadingAccount.d.ts +1 -1
- package/dist/modals/CheckoutModal/TransferToken.d.ts +1 -1
- package/dist/providers/GeneralWalletProvider.d.ts +1 -0
- package/dist/utils/assets.d.ts +1 -0
- package/dist/wallets/walletConnectors/index.js +53 -53
- package/package.json +4 -4
- package/dist/wallets/walletConnectors/chunk-25VW5TZP.js +0 -92
- package/dist/wallets/walletConnectors/chunk-4HKPVECK.js +0 -95
- package/dist/wallets/walletConnectors/chunk-4K3EKHXR.js +0 -71
- package/dist/wallets/walletConnectors/chunk-57UUMOOZ.js +0 -95
- package/dist/wallets/walletConnectors/chunk-5MVCKMZT.js +0 -94
- package/dist/wallets/walletConnectors/chunk-5NZLWT3Y.js +0 -73
- package/dist/wallets/walletConnectors/chunk-B5D7DYVV.js +0 -101
- package/dist/wallets/walletConnectors/chunk-HCKLWBE5.js +0 -98
- package/dist/wallets/walletConnectors/chunk-HLH777AC.js +0 -108
- package/dist/wallets/walletConnectors/chunk-HMDUVRZP.js +0 -98
- package/dist/wallets/walletConnectors/chunk-IR3YKU2N.js +0 -103
- package/dist/wallets/walletConnectors/chunk-J2BF4L2V.js +0 -87
- package/dist/wallets/walletConnectors/chunk-KDGMYRMC.js +0 -102
- package/dist/wallets/walletConnectors/chunk-OKUX4BC4.js +0 -66
- package/dist/wallets/walletConnectors/chunk-VU6B3HMD.js +0 -96
- package/dist/wallets/walletConnectors/chunk-WAMHUVNP.js +0 -96
- package/dist/wallets/walletConnectors/chunk-YRK6XWL6.js +0 -149
- package/dist/wallets/walletConnectors/chunk-ZCKNEKQQ.js +0 -110
package/dist/index.js
CHANGED
|
@@ -508,7 +508,7 @@ import PrivyJS, {
|
|
|
508
508
|
} from "@privy-io/js-sdk-core";
|
|
509
509
|
import React188, {
|
|
510
510
|
createContext as createContext16,
|
|
511
|
-
useCallback as
|
|
511
|
+
useCallback as useCallback35,
|
|
512
512
|
useContext as useContext18,
|
|
513
513
|
useEffect as useEffect37,
|
|
514
514
|
useMemo as useMemo35,
|
|
@@ -1021,7 +1021,7 @@ var useInitialChainId = () => useContext4(FunkitConnectChainContext).initialChai
|
|
|
1021
1021
|
// src/providers/ModalContext.tsx
|
|
1022
1022
|
import React187, {
|
|
1023
1023
|
createContext as createContext15,
|
|
1024
|
-
useCallback as
|
|
1024
|
+
useCallback as useCallback34,
|
|
1025
1025
|
useContext as useContext17,
|
|
1026
1026
|
useEffect as useEffect36,
|
|
1027
1027
|
useMemo as useMemo34,
|
|
@@ -2149,6 +2149,10 @@ var useFunkitAccount = () => {
|
|
|
2149
2149
|
isWeb3Login
|
|
2150
2150
|
};
|
|
2151
2151
|
};
|
|
2152
|
+
var useFunkitUserInfo = () => {
|
|
2153
|
+
const { userInfo } = useContext6(GeneralWalletContext);
|
|
2154
|
+
return userInfo;
|
|
2155
|
+
};
|
|
2152
2156
|
var useFunkitDisconnect = () => {
|
|
2153
2157
|
const disconnectReturn = useDisconnect();
|
|
2154
2158
|
const { handleLogout } = useContext6(GeneralWalletContext);
|
|
@@ -4464,6 +4468,7 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
4464
4468
|
const shouldUpdateCheckoutItemAmount = isCheckoutCrFlow(checkoutItem) || !isCheckoutPostActionRequired(config);
|
|
4465
4469
|
return {
|
|
4466
4470
|
initSettings: {
|
|
4471
|
+
...checkoutItem.initSettings,
|
|
4467
4472
|
config: {
|
|
4468
4473
|
...config,
|
|
4469
4474
|
checkoutItemAmount: shouldUpdateCheckoutItemAmount ? newTargetAssetAmount : config.checkoutItemAmount,
|
|
@@ -5220,6 +5225,15 @@ import { keepPreviousData, useQuery as useQuery2 } from "@tanstack/react-query";
|
|
|
5220
5225
|
import { polygon } from "viem/chains";
|
|
5221
5226
|
import { useAccount as useAccount4 } from "wagmi";
|
|
5222
5227
|
|
|
5228
|
+
// src/utils/assets.ts
|
|
5229
|
+
import {
|
|
5230
|
+
dydxChain as dydxChain2,
|
|
5231
|
+
FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO6,
|
|
5232
|
+
STABLECOIN_SYMBOLS
|
|
5233
|
+
} from "@funkit/core";
|
|
5234
|
+
import { formatUnits } from "viem";
|
|
5235
|
+
import { arbitrum, mainnet as mainnet4, mantle, zkSync as zkSync2 } from "viem/chains";
|
|
5236
|
+
|
|
5223
5237
|
// src/utils/combineChainSymbolOrAddress.ts
|
|
5224
5238
|
function combineChainSymbolOrAddress({
|
|
5225
5239
|
chainId,
|
|
@@ -5229,166 +5243,432 @@ function combineChainSymbolOrAddress({
|
|
|
5229
5243
|
return `${chainId}|${symbolOrAddress}`;
|
|
5230
5244
|
}
|
|
5231
5245
|
|
|
5232
|
-
// src/
|
|
5233
|
-
var
|
|
5234
|
-
|
|
5235
|
-
return
|
|
5236
|
-
}
|
|
5237
|
-
var
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
chainId: normalizedAsset.chainId,
|
|
5254
|
-
symbolOrAddress: currentAddress
|
|
5255
|
-
});
|
|
5256
|
-
if (!chainAddress) {
|
|
5257
|
-
continue;
|
|
5258
|
-
}
|
|
5259
|
-
combinedAssets[chainAddress] = normalizedAsset;
|
|
5260
|
-
}
|
|
5261
|
-
}
|
|
5262
|
-
return combinedAssets;
|
|
5263
|
-
}
|
|
5264
|
-
async function fetchAssets(address, apiKey) {
|
|
5265
|
-
if (address === void 0) {
|
|
5266
|
-
return void 0;
|
|
5267
|
-
}
|
|
5268
|
-
const assets = await getAllWalletTokens({
|
|
5269
|
-
walletAddress: address,
|
|
5270
|
-
onlyVerifiedTokens: true,
|
|
5271
|
-
apiKey,
|
|
5272
|
-
signal: singletonAssetAbort.getAbortSignal()
|
|
5273
|
-
}).catch((err) => {
|
|
5274
|
-
logger.error("_fetchAssetsIfPossible:error", err);
|
|
5275
|
-
throw err;
|
|
5276
|
-
});
|
|
5277
|
-
const assetsCombined = combineAssets(assets);
|
|
5278
|
-
const totalWalletAssetsUsd = Object.values(assetsCombined).reduce(
|
|
5279
|
-
(acc, asset) => acc + (asset.totalUsdValue ?? 0),
|
|
5280
|
-
0
|
|
5246
|
+
// src/utils/assets.ts
|
|
5247
|
+
var ASSETS_LOW_VALUE_THRESHOLD = 0.1;
|
|
5248
|
+
var getNormalizedTokenBalance = (tokenBalance, decimals) => {
|
|
5249
|
+
return Number(formatUnits(BigInt(tokenBalance), decimals));
|
|
5250
|
+
};
|
|
5251
|
+
var isAssetUsableToPayForCheckout = (flags, checkoutItem, paymentMethod, assetChainId, assetTokenAddress, isWeb2Login, isWeb3Login) => {
|
|
5252
|
+
const targetChainId = checkoutItem.initSettings.config.targetChain;
|
|
5253
|
+
const isSameAsPurchasingToken = !isCheckoutPostActionRequired(checkoutItem.initSettings.config) && // however, if the destination is custom recipient address, it is possible to transfer money
|
|
5254
|
+
// TODO: this is not 100% correct, should also check if sourceAddr != customRecipientAddr
|
|
5255
|
+
!isCheckoutCrFlow(checkoutItem) && paymentMethod === "balance" /* ACCOUNT_BALANCE */ && targetChainId === assetChainId && checkoutItem.initSettings.config.targetAsset.toLowerCase() === assetTokenAddress.toLowerCase();
|
|
5256
|
+
const isConnectedAccountSupported = (
|
|
5257
|
+
// User is logged in with web2, ensure that the chain is supported for FunWallet
|
|
5258
|
+
isWeb2Login && FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO6[assetChainId].isFunWalletSupported || // User is logged in with web3 or not logged in at all, ignore
|
|
5259
|
+
isWeb3Login || !isWeb2Login && !isWeb3Login
|
|
5260
|
+
);
|
|
5261
|
+
const isZkSyncAssetsDisabled = flags["disable_zksync_source_assets" /* DisableZkSyncSourceAssets */] ?? true;
|
|
5262
|
+
const isMantleAssetsDisabled = flags["disable_mantle_source_assets" /* DisableMantleSourceAssets */] ?? true;
|
|
5263
|
+
const isAssetDisabled = (
|
|
5264
|
+
// Disable all mantle assets
|
|
5265
|
+
isMantleAssetsDisabled && assetChainId === mantle.id.toString() || // Disable all zksync assets
|
|
5266
|
+
isZkSyncAssetsDisabled && assetChainId === zkSync2.id.toString()
|
|
5281
5267
|
);
|
|
5268
|
+
const isPickedChainSupportedForCheckout = isConnectedAccountSupported && FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO6[assetChainId].isCheckoutSupported && !isAssetDisabled;
|
|
5269
|
+
const isUsable = !isSameAsPurchasingToken && isPickedChainSupportedForCheckout;
|
|
5282
5270
|
return {
|
|
5283
|
-
|
|
5284
|
-
|
|
5271
|
+
isUsable,
|
|
5272
|
+
reason: isUsable ? "" : isSameAsPurchasingToken ? "Not Applicable" : !isPickedChainSupportedForCheckout ? "Unsupported" : ""
|
|
5285
5273
|
};
|
|
5286
|
-
}
|
|
5287
|
-
var
|
|
5288
|
-
|
|
5289
|
-
|
|
5274
|
+
};
|
|
5275
|
+
var getAssetSymbolWithMaxUsdValue = ({
|
|
5276
|
+
accountHoldingsMap,
|
|
5277
|
+
filterSymbols
|
|
5290
5278
|
}) => {
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
};
|
|
5279
|
+
return Object.keys(accountHoldingsMap).filter(
|
|
5280
|
+
(symbol) => filterSymbols === void 0 || filterSymbols?.includes(symbol)
|
|
5281
|
+
).reduce((max, current) => {
|
|
5282
|
+
const currentItem = accountHoldingsMap[current];
|
|
5283
|
+
if (!currentItem || !isNotNullish(currentItem.usdAmount)) {
|
|
5284
|
+
return max;
|
|
5285
|
+
}
|
|
5286
|
+
if (max === null) {
|
|
5287
|
+
return current;
|
|
5288
|
+
}
|
|
5289
|
+
const maxItem = accountHoldingsMap[max];
|
|
5290
|
+
if (isNotNullish(maxItem?.usdAmount)) {
|
|
5291
|
+
return maxItem.usdAmount > currentItem.usdAmount ? max : current;
|
|
5292
|
+
}
|
|
5293
|
+
return max;
|
|
5294
|
+
}, null);
|
|
5307
5295
|
};
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
const cachedRequestPromise = cachedRequestPromises.get(asyncImage);
|
|
5323
|
-
if (cachedRequestPromise) {
|
|
5324
|
-
return cachedRequestPromise;
|
|
5296
|
+
var L1_FEES_ESTIMATE = 20;
|
|
5297
|
+
var L2_FEES_ESTIMATE = 1;
|
|
5298
|
+
var L2_COST_MARGIN_MULTIPLIER = 1.2;
|
|
5299
|
+
var MESH_L1_FEES_ESTIMATE = 8;
|
|
5300
|
+
var MESH_L2_FEES_ESTIMATE = 2;
|
|
5301
|
+
var MESH_CUSTOM_CLIENT_FEE_PERCENT = 0.055;
|
|
5302
|
+
var getMeshFeesUsdEstimate = (asset) => {
|
|
5303
|
+
let meshFeeEstimate = 0;
|
|
5304
|
+
meshFeeEstimate += (asset.usdAmount || 0) * MESH_CUSTOM_CLIENT_FEE_PERCENT;
|
|
5305
|
+
const sourceChainId = asset.pickedChainId;
|
|
5306
|
+
if (sourceChainId === mainnet4.id.toString()) {
|
|
5307
|
+
meshFeeEstimate += MESH_L1_FEES_ESTIMATE;
|
|
5308
|
+
} else {
|
|
5309
|
+
meshFeeEstimate += MESH_L2_FEES_ESTIMATE;
|
|
5325
5310
|
}
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
const
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5311
|
+
return meshFeeEstimate;
|
|
5312
|
+
};
|
|
5313
|
+
var getBaseFeeUsdEstimate = (checkoutItem, asset) => {
|
|
5314
|
+
const targetChainId = checkoutItem.initSettings.config.targetChain;
|
|
5315
|
+
const sourceChainId = asset.pickedChainId;
|
|
5316
|
+
if (targetChainId !== mainnet4.id.toString() && sourceChainId !== mainnet4.id.toString()) {
|
|
5317
|
+
return L2_FEES_ESTIMATE;
|
|
5318
|
+
} else {
|
|
5319
|
+
return L1_FEES_ESTIMATE;
|
|
5320
|
+
}
|
|
5321
|
+
};
|
|
5322
|
+
var getFeesUsdEstimate = (checkoutItem, asset) => {
|
|
5323
|
+
let feeEstimate = 0;
|
|
5324
|
+
feeEstimate += getBaseFeeUsdEstimate(checkoutItem, asset);
|
|
5325
|
+
if (checkoutItem.selectedPaymentMethodInfo?.paymentMethod === "brokerage" /* BROKERAGE */) {
|
|
5326
|
+
feeEstimate += getMeshFeesUsdEstimate(asset);
|
|
5327
|
+
}
|
|
5328
|
+
return feeEstimate;
|
|
5329
|
+
};
|
|
5330
|
+
var isAssetUsdAmountSufficient = (checkoutItem, asset) => {
|
|
5331
|
+
if (!isNotNullish(asset?.usdAmount)) {
|
|
5332
|
+
return false;
|
|
5333
|
+
}
|
|
5334
|
+
if (!isNotNullish(checkoutItem?.draftDollarValue)) {
|
|
5335
|
+
return false;
|
|
5336
|
+
}
|
|
5337
|
+
return asset.usdAmount > checkoutItem?.draftDollarValue + getFeesUsdEstimate(checkoutItem, asset);
|
|
5338
|
+
};
|
|
5339
|
+
var getRecommendedAsset = (flags, checkoutItem, accountHoldingsMap, isWeb3Login, isWeb2Login) => {
|
|
5340
|
+
const highestValueAssetSymbol = getAssetSymbolWithMaxUsdValue({
|
|
5341
|
+
accountHoldingsMap
|
|
5334
5342
|
});
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5343
|
+
if (!isNotNullish(highestValueAssetSymbol) || !isAssetUsdAmountSufficient(
|
|
5344
|
+
checkoutItem,
|
|
5345
|
+
accountHoldingsMap[highestValueAssetSymbol]
|
|
5346
|
+
)) {
|
|
5347
|
+
return null;
|
|
5348
|
+
}
|
|
5349
|
+
const assetsOnL1 = Object.keys(accountHoldingsMap)?.filter(
|
|
5350
|
+
(chainSymbolKey) => accountHoldingsMap[chainSymbolKey].pickedChainId === mainnet4.id.toString()
|
|
5341
5351
|
);
|
|
5342
|
-
|
|
5343
|
-
|
|
5344
|
-
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
5345
|
-
return forceUpdate;
|
|
5346
|
-
}
|
|
5347
|
-
function useAsyncImage(url) {
|
|
5348
|
-
const cachedUrl = typeof url === "function" ? cachedUrls.get(url) : void 0;
|
|
5349
|
-
const forceUpdate = useForceUpdate();
|
|
5350
|
-
useEffect13(() => {
|
|
5351
|
-
if (typeof url === "function" && !cachedUrl) {
|
|
5352
|
-
loadAsyncImage(url).then(forceUpdate);
|
|
5353
|
-
}
|
|
5354
|
-
}, [url, cachedUrl, forceUpdate]);
|
|
5355
|
-
return typeof url === "function" ? cachedUrl : url;
|
|
5356
|
-
}
|
|
5357
|
-
|
|
5358
|
-
// src/components/AsyncImage/AsyncImage.tsx
|
|
5359
|
-
function useTriggeredOnce() {
|
|
5360
|
-
return useReducer2(() => true, false);
|
|
5361
|
-
}
|
|
5362
|
-
function AsyncImage({
|
|
5363
|
-
alt,
|
|
5364
|
-
background,
|
|
5365
|
-
borderColor,
|
|
5366
|
-
borderRadius,
|
|
5367
|
-
boxShadow,
|
|
5368
|
-
height,
|
|
5369
|
-
useAsImage,
|
|
5370
|
-
src: srcProp,
|
|
5371
|
-
fallbackSrc,
|
|
5372
|
-
fallbackElement,
|
|
5373
|
-
width,
|
|
5374
|
-
testId
|
|
5375
|
-
}) {
|
|
5376
|
-
const src3 = useAsyncImage(srcProp || fallbackSrc);
|
|
5377
|
-
const isRemoteImage = src3 !== void 0 && /^http/.test(src3);
|
|
5378
|
-
const [isRemoteImageLoaded, setRemoteImageLoaded] = useTriggeredOnce();
|
|
5379
|
-
const [hasError, setHasError] = useState12(
|
|
5380
|
-
srcProp === void 0 && fallbackSrc === void 0
|
|
5352
|
+
const assetsOnL2 = Object.keys(accountHoldingsMap)?.filter(
|
|
5353
|
+
(chainSymbolKey) => accountHoldingsMap[chainSymbolKey].pickedChainId !== mainnet4.id.toString()
|
|
5381
5354
|
);
|
|
5382
|
-
const
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5355
|
+
const highestValueL1Asset = assetsOnL1.length ? getAssetSymbolWithMaxUsdValue({
|
|
5356
|
+
accountHoldingsMap,
|
|
5357
|
+
filterSymbols: assetsOnL1
|
|
5358
|
+
}) : null;
|
|
5359
|
+
const highestValueL2Asset = assetsOnL2.length ? getAssetSymbolWithMaxUsdValue({
|
|
5360
|
+
accountHoldingsMap,
|
|
5361
|
+
filterSymbols: assetsOnL2
|
|
5362
|
+
}) : null;
|
|
5363
|
+
if (!isNotNullish(highestValueL1Asset) && !isNotNullish(highestValueL2Asset)) {
|
|
5364
|
+
return null;
|
|
5365
|
+
}
|
|
5366
|
+
const highestValueL1UsdAmount = highestValueL1Asset ? accountHoldingsMap[highestValueL1Asset]?.usdAmount || 0 : null;
|
|
5367
|
+
const highestValueL2UsdAmount = highestValueL2Asset ? accountHoldingsMap[highestValueL2Asset]?.usdAmount || 0 : null;
|
|
5368
|
+
if (!isNotNullish(highestValueL1UsdAmount) && !isNotNullish(highestValueL2UsdAmount)) {
|
|
5369
|
+
return null;
|
|
5370
|
+
}
|
|
5371
|
+
const checkoutConfig = checkoutItem.initSettings.config;
|
|
5372
|
+
const targetChainId = getMockedTargetChainId(checkoutConfig, [
|
|
5373
|
+
dydxChain2.id.toString()
|
|
5374
|
+
]);
|
|
5375
|
+
const targetChainIdAssetSymbol = Object.keys(accountHoldingsMap).find(
|
|
5376
|
+
(chainIdSymbol) => {
|
|
5377
|
+
const item = accountHoldingsMap[chainIdSymbol];
|
|
5378
|
+
if (item.pickedChainId === targetChainId && item.tokenAddress === checkoutConfig.targetAsset) {
|
|
5379
|
+
return chainIdSymbol;
|
|
5380
|
+
}
|
|
5381
|
+
return null;
|
|
5382
|
+
}
|
|
5383
|
+
);
|
|
5384
|
+
if (isCheckoutPostActionRequired(checkoutItem.initSettings.config) || isCheckoutCrFlow(checkoutItem)) {
|
|
5385
|
+
if (targetChainIdAssetSymbol && isAssetUsdAmountSufficient(
|
|
5386
|
+
checkoutItem,
|
|
5387
|
+
accountHoldingsMap[targetChainIdAssetSymbol]
|
|
5388
|
+
)) {
|
|
5389
|
+
return {
|
|
5390
|
+
symbol: targetChainIdAssetSymbol,
|
|
5391
|
+
label: "Cheapest"
|
|
5392
|
+
};
|
|
5393
|
+
}
|
|
5394
|
+
}
|
|
5395
|
+
const usableAssetHoldingMap = checkoutItem ? Object.fromEntries(
|
|
5396
|
+
Object.entries(accountHoldingsMap).filter(
|
|
5397
|
+
([_, item]) => isAssetUsableToPayForCheckout(
|
|
5398
|
+
flags,
|
|
5399
|
+
checkoutItem,
|
|
5400
|
+
checkoutItem?.selectedPaymentMethodInfo?.paymentMethod,
|
|
5401
|
+
item.pickedChainId,
|
|
5402
|
+
item.tokenAddress,
|
|
5403
|
+
isWeb2Login,
|
|
5404
|
+
isWeb3Login
|
|
5405
|
+
).isUsable
|
|
5406
|
+
)
|
|
5407
|
+
) : {};
|
|
5408
|
+
const highestValueUsableAssetSymbol = getAssetSymbolWithMaxUsdValue({
|
|
5409
|
+
accountHoldingsMap: usableAssetHoldingMap
|
|
5410
|
+
});
|
|
5411
|
+
if (!isNotNullish(highestValueUsableAssetSymbol) || !isAssetUsdAmountSufficient(
|
|
5412
|
+
checkoutItem,
|
|
5413
|
+
usableAssetHoldingMap[highestValueUsableAssetSymbol]
|
|
5414
|
+
)) {
|
|
5415
|
+
return null;
|
|
5416
|
+
}
|
|
5417
|
+
const stableAssetOnTargetChainSymbols = STABLECOIN_SYMBOLS.map(
|
|
5418
|
+
(symbol) => combineChainSymbolOrAddress({
|
|
5419
|
+
chainId: targetChainId,
|
|
5420
|
+
symbolOrAddress: symbol
|
|
5421
|
+
})
|
|
5422
|
+
);
|
|
5423
|
+
const highestValueStableAssetOnTargetChain = getAssetSymbolWithMaxUsdValue({
|
|
5424
|
+
accountHoldingsMap: usableAssetHoldingMap,
|
|
5425
|
+
filterSymbols: stableAssetOnTargetChainSymbols.filter(
|
|
5426
|
+
(asset) => asset !== null
|
|
5427
|
+
)
|
|
5428
|
+
});
|
|
5429
|
+
if (isNotNullish(highestValueStableAssetOnTargetChain) && isAssetUsdAmountSufficient(
|
|
5430
|
+
checkoutItem,
|
|
5431
|
+
usableAssetHoldingMap[highestValueStableAssetOnTargetChain]
|
|
5432
|
+
)) {
|
|
5433
|
+
return {
|
|
5434
|
+
symbol: highestValueStableAssetOnTargetChain,
|
|
5435
|
+
label: "Cheapest"
|
|
5436
|
+
};
|
|
5437
|
+
}
|
|
5438
|
+
const targetChainIdEthSymbol = combineChainSymbolOrAddress({
|
|
5439
|
+
chainId: targetChainId,
|
|
5440
|
+
symbolOrAddress: "ETH"
|
|
5441
|
+
});
|
|
5442
|
+
if (isNotNullish(targetChainIdEthSymbol) && isAssetUsdAmountSufficient(
|
|
5443
|
+
checkoutItem,
|
|
5444
|
+
usableAssetHoldingMap[targetChainIdEthSymbol]
|
|
5445
|
+
)) {
|
|
5446
|
+
return {
|
|
5447
|
+
symbol: targetChainIdEthSymbol,
|
|
5448
|
+
label: "Cheapest"
|
|
5449
|
+
};
|
|
5450
|
+
}
|
|
5451
|
+
const targetChainCoreToken = targetChainId ? FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO6[targetChainId].coreToken : null;
|
|
5452
|
+
const targetChainIdAndCoreTokenSymbol = targetChainCoreToken?.symbol && combineChainSymbolOrAddress({
|
|
5453
|
+
chainId: targetChainId,
|
|
5454
|
+
symbolOrAddress: targetChainCoreToken?.symbol
|
|
5455
|
+
});
|
|
5456
|
+
if (isNotNullish(targetChainIdAndCoreTokenSymbol) && isAssetUsdAmountSufficient(
|
|
5457
|
+
checkoutItem,
|
|
5458
|
+
usableAssetHoldingMap[targetChainIdAndCoreTokenSymbol]
|
|
5459
|
+
)) {
|
|
5460
|
+
return {
|
|
5461
|
+
symbol: targetChainIdAndCoreTokenSymbol,
|
|
5462
|
+
label: "Cheapest"
|
|
5463
|
+
};
|
|
5464
|
+
}
|
|
5465
|
+
const highestValueUsableL2Asset = assetsOnL2.length ? getAssetSymbolWithMaxUsdValue({
|
|
5466
|
+
accountHoldingsMap: usableAssetHoldingMap,
|
|
5467
|
+
filterSymbols: assetsOnL2
|
|
5468
|
+
}) : null;
|
|
5469
|
+
const highestValueUsableL2UsdAmount = highestValueUsableL2Asset ? usableAssetHoldingMap[highestValueUsableL2Asset]?.usdAmount || 0 : null;
|
|
5470
|
+
if (targetChainId !== mainnet4.id.toString() && isNotNullish(highestValueUsableL2Asset) && isAssetUsdAmountSufficient(
|
|
5471
|
+
checkoutItem,
|
|
5472
|
+
usableAssetHoldingMap[highestValueUsableL2Asset]
|
|
5473
|
+
)) {
|
|
5474
|
+
return {
|
|
5475
|
+
symbol: highestValueUsableL2Asset,
|
|
5476
|
+
label: "Cheapest"
|
|
5477
|
+
};
|
|
5478
|
+
}
|
|
5479
|
+
const highestValueUsableAssetUsdAmount = highestValueUsableAssetSymbol ? usableAssetHoldingMap[highestValueUsableAssetSymbol]?.usdAmount || 0 : null;
|
|
5480
|
+
if (isNotNullish(highestValueUsableL2UsdAmount) && isNotNullish(highestValueUsableL2Asset) && highestValueUsableL2UsdAmount * L2_COST_MARGIN_MULTIPLIER > (highestValueUsableAssetUsdAmount || 0)) {
|
|
5481
|
+
return {
|
|
5482
|
+
symbol: highestValueUsableL2Asset,
|
|
5483
|
+
label: null
|
|
5484
|
+
};
|
|
5485
|
+
}
|
|
5486
|
+
return {
|
|
5487
|
+
symbol: highestValueUsableAssetSymbol,
|
|
5488
|
+
label: null
|
|
5489
|
+
};
|
|
5490
|
+
};
|
|
5491
|
+
var getTotalAssetBalance = (assets) => {
|
|
5492
|
+
const maxUsdBalance = Object.values(assets).reduce(
|
|
5493
|
+
(acc, { usdAmount }) => (usdAmount ?? 0) + acc,
|
|
5494
|
+
0
|
|
5495
|
+
);
|
|
5496
|
+
return formatCurrencyAndStringify(maxUsdBalance);
|
|
5497
|
+
};
|
|
5498
|
+
var FALLBACK_CHAIN_ID = arbitrum.id.toString();
|
|
5499
|
+
var getMockedTargetChainId = ({ targetChain }, mockedChains = []) => {
|
|
5500
|
+
return mockedChains.includes(targetChain) ? FALLBACK_CHAIN_ID : targetChain;
|
|
5501
|
+
};
|
|
5502
|
+
|
|
5503
|
+
// src/hooks/useWalletAssets.ts
|
|
5504
|
+
var FETCH_ASSETS_INTERVAL_MS = 6e4;
|
|
5505
|
+
function assetIsKnownAsset(asset) {
|
|
5506
|
+
return asset.totalUsdValue !== null && asset.price !== null;
|
|
5507
|
+
}
|
|
5508
|
+
var POLYGON_USDCE_TOKEN = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174";
|
|
5509
|
+
function normalizeAssetSymbol(asset) {
|
|
5510
|
+
if (asset.chainId === polygon.id.toString() && asset.contractAddress === POLYGON_USDCE_TOKEN) {
|
|
5511
|
+
return { ...asset, symbol: "USDC.e" };
|
|
5512
|
+
}
|
|
5513
|
+
return asset;
|
|
5514
|
+
}
|
|
5515
|
+
function combineAssets(assets) {
|
|
5516
|
+
const combinedAssets = {};
|
|
5517
|
+
for (const chainAssets of Object.values(assets)) {
|
|
5518
|
+
for (const [currentAddress, asset] of Object.entries(chainAssets)) {
|
|
5519
|
+
if (!assetIsKnownAsset(asset)) {
|
|
5520
|
+
continue;
|
|
5521
|
+
}
|
|
5522
|
+
const normalizedAsset = normalizeAssetSymbol(asset);
|
|
5523
|
+
const chainAddress = combineChainSymbolOrAddress({
|
|
5524
|
+
chainId: normalizedAsset.chainId,
|
|
5525
|
+
symbolOrAddress: currentAddress
|
|
5526
|
+
});
|
|
5527
|
+
if (!chainAddress) {
|
|
5528
|
+
continue;
|
|
5529
|
+
}
|
|
5530
|
+
combinedAssets[chainAddress] = normalizedAsset;
|
|
5531
|
+
}
|
|
5532
|
+
}
|
|
5533
|
+
return combinedAssets;
|
|
5534
|
+
}
|
|
5535
|
+
async function fetchAssets(address, apiKey) {
|
|
5536
|
+
if (address === void 0) {
|
|
5537
|
+
return void 0;
|
|
5538
|
+
}
|
|
5539
|
+
const assets = await getAllWalletTokens({
|
|
5540
|
+
walletAddress: address,
|
|
5541
|
+
onlyVerifiedTokens: true,
|
|
5542
|
+
apiKey,
|
|
5543
|
+
signal: singletonAssetAbort.getAbortSignal()
|
|
5544
|
+
}).catch((err) => {
|
|
5545
|
+
logger.error("_fetchAssetsIfPossible:error", err);
|
|
5546
|
+
throw err;
|
|
5547
|
+
});
|
|
5548
|
+
const assetsCombined = combineAssets(assets);
|
|
5549
|
+
const filteredAssetsCombined = Object.entries(assetsCombined).reduce(
|
|
5550
|
+
(acc, [address2, asset]) => {
|
|
5551
|
+
if (asset.totalUsdValue && asset.totalUsdValue >= ASSETS_LOW_VALUE_THRESHOLD) {
|
|
5552
|
+
acc[address2] = asset;
|
|
5553
|
+
}
|
|
5554
|
+
return acc;
|
|
5555
|
+
},
|
|
5556
|
+
{}
|
|
5557
|
+
);
|
|
5558
|
+
const totalWalletAssetsUsd = Object.values(filteredAssetsCombined).reduce(
|
|
5559
|
+
(acc, asset) => acc + (asset.totalUsdValue ?? 0),
|
|
5560
|
+
0
|
|
5561
|
+
);
|
|
5562
|
+
return {
|
|
5563
|
+
walletAssets: filteredAssetsCombined,
|
|
5564
|
+
totalWalletAssetsUsd
|
|
5565
|
+
};
|
|
5566
|
+
}
|
|
5567
|
+
var useWalletAssets = ({
|
|
5568
|
+
enableRefetchInterval = true,
|
|
5569
|
+
refetchOnMount = true
|
|
5570
|
+
}) => {
|
|
5571
|
+
const { address, isConnected } = useAccount4();
|
|
5572
|
+
const { apiKey } = useFunkitConfig();
|
|
5573
|
+
const { data, isLoading, isFetching } = useQuery2({
|
|
5574
|
+
queryKey: ["getWalletAssets", address, apiKey],
|
|
5575
|
+
queryFn: ({ queryKey: [_, addr, key] }) => fetchAssets(addr, key),
|
|
5576
|
+
placeholderData: keepPreviousData,
|
|
5577
|
+
enabled: address !== void 0 && isConnected,
|
|
5578
|
+
refetchOnMount,
|
|
5579
|
+
refetchInterval: enableRefetchInterval ? FETCH_ASSETS_INTERVAL_MS : void 0
|
|
5580
|
+
});
|
|
5581
|
+
return {
|
|
5582
|
+
walletAssets: data?.walletAssets,
|
|
5583
|
+
totalWalletAssetsUsd: data?.totalWalletAssetsUsd ?? 0,
|
|
5584
|
+
isLoading,
|
|
5585
|
+
isFetching
|
|
5586
|
+
};
|
|
5587
|
+
};
|
|
5588
|
+
|
|
5589
|
+
// src/modals/FunCheckoutHistoryModal/FunCheckoutHistoryTransaction.tsx
|
|
5590
|
+
import { FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO7 } from "@funkit/core";
|
|
5591
|
+
import { useEffect as useEffect20, useRef as useRef7 } from "react";
|
|
5592
|
+
import React99, { useState as useState21 } from "react";
|
|
5593
|
+
|
|
5594
|
+
// src/components/AsyncImage/AsyncImage.tsx
|
|
5595
|
+
import React35, { useMemo as useMemo7, useReducer as useReducer2, useState as useState12 } from "react";
|
|
5596
|
+
|
|
5597
|
+
// src/components/AsyncImage/useAsyncImage.ts
|
|
5598
|
+
import { useEffect as useEffect13, useReducer } from "react";
|
|
5599
|
+
var cachedUrls = /* @__PURE__ */ new Map();
|
|
5600
|
+
var cachedRequestPromises = /* @__PURE__ */ new Map();
|
|
5601
|
+
async function loadAsyncImage(asyncImage) {
|
|
5602
|
+
const cachedRequestPromise = cachedRequestPromises.get(asyncImage);
|
|
5603
|
+
if (cachedRequestPromise) {
|
|
5604
|
+
return cachedRequestPromise;
|
|
5605
|
+
}
|
|
5606
|
+
const load = async () => asyncImage().then(async (url) => {
|
|
5607
|
+
cachedUrls.set(asyncImage, url);
|
|
5608
|
+
return url;
|
|
5609
|
+
});
|
|
5610
|
+
const requestPromise = load().catch(() => {
|
|
5611
|
+
return load().catch(() => {
|
|
5612
|
+
cachedRequestPromises.delete(asyncImage);
|
|
5613
|
+
});
|
|
5614
|
+
});
|
|
5615
|
+
cachedRequestPromises.set(asyncImage, requestPromise);
|
|
5616
|
+
return requestPromise;
|
|
5617
|
+
}
|
|
5618
|
+
async function loadImages(...urls) {
|
|
5619
|
+
return await Promise.all(
|
|
5620
|
+
urls.map((url) => typeof url === "function" ? loadAsyncImage(url) : url)
|
|
5621
|
+
);
|
|
5622
|
+
}
|
|
5623
|
+
function useForceUpdate() {
|
|
5624
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
5625
|
+
return forceUpdate;
|
|
5626
|
+
}
|
|
5627
|
+
function useAsyncImage(url) {
|
|
5628
|
+
const cachedUrl = typeof url === "function" ? cachedUrls.get(url) : void 0;
|
|
5629
|
+
const forceUpdate = useForceUpdate();
|
|
5630
|
+
useEffect13(() => {
|
|
5631
|
+
if (typeof url === "function" && !cachedUrl) {
|
|
5632
|
+
loadAsyncImage(url).then(forceUpdate);
|
|
5633
|
+
}
|
|
5634
|
+
}, [url, cachedUrl, forceUpdate]);
|
|
5635
|
+
return typeof url === "function" ? cachedUrl : url;
|
|
5636
|
+
}
|
|
5637
|
+
|
|
5638
|
+
// src/components/AsyncImage/AsyncImage.tsx
|
|
5639
|
+
function useTriggeredOnce() {
|
|
5640
|
+
return useReducer2(() => true, false);
|
|
5641
|
+
}
|
|
5642
|
+
function AsyncImage({
|
|
5643
|
+
alt,
|
|
5644
|
+
background,
|
|
5645
|
+
borderColor,
|
|
5646
|
+
borderRadius,
|
|
5647
|
+
boxShadow,
|
|
5648
|
+
height,
|
|
5649
|
+
useAsImage,
|
|
5650
|
+
src: srcProp,
|
|
5651
|
+
fallbackSrc,
|
|
5652
|
+
fallbackElement,
|
|
5653
|
+
width,
|
|
5654
|
+
testId
|
|
5655
|
+
}) {
|
|
5656
|
+
const src3 = useAsyncImage(srcProp || fallbackSrc);
|
|
5657
|
+
const isRemoteImage = src3 !== void 0 && /^http/.test(src3);
|
|
5658
|
+
const [isRemoteImageLoaded, setRemoteImageLoaded] = useTriggeredOnce();
|
|
5659
|
+
const [hasError, setHasError] = useState12(
|
|
5660
|
+
srcProp === void 0 && fallbackSrc === void 0
|
|
5661
|
+
);
|
|
5662
|
+
const { asyncStyle, imgProps } = useMemo7(() => {
|
|
5663
|
+
const asyncStyle2 = !useAsImage ? getRemoteImageStyles(isRemoteImage, isRemoteImageLoaded, src3) : {};
|
|
5664
|
+
if (useAsImage || isRemoteImage) {
|
|
5665
|
+
const imgProps2 = {
|
|
5666
|
+
as: "img",
|
|
5667
|
+
src: src3,
|
|
5668
|
+
"aria-hidden": true,
|
|
5669
|
+
onError: ({
|
|
5670
|
+
currentTarget
|
|
5671
|
+
}) => {
|
|
5392
5672
|
currentTarget.onerror = null;
|
|
5393
5673
|
if (fallbackSrc !== void 0) {
|
|
5394
5674
|
currentTarget.src = fallbackSrc;
|
|
@@ -9569,7 +9849,10 @@ var statusNamingMap = {
|
|
|
9569
9849
|
function StatusTag({ state, refundState, isDelayed }) {
|
|
9570
9850
|
const { status, isCompleted } = useCheckoutStateBooleans(state);
|
|
9571
9851
|
const color = isCompleted ? "success" : "secondaryText";
|
|
9572
|
-
return /* @__PURE__ */ React99.createElement(Text, { color, size: "12", weight: "medium" }, refundState === "REFUNDED" ? "Refunded" :
|
|
9852
|
+
return /* @__PURE__ */ React99.createElement(Text, { color, size: "12", weight: "medium" }, refundState === "REFUNDED" ? "Refunded" : (
|
|
9853
|
+
// With some hardcoded timings in `FunCheckoutStatus`, it is possible for isDelayed to stay true while isCompleted is already true
|
|
9854
|
+
isDelayed && !isCompleted ? "Pending" : statusNamingMap[status]
|
|
9855
|
+
));
|
|
9573
9856
|
}
|
|
9574
9857
|
var ReceivedAmount = ({ config }) => {
|
|
9575
9858
|
const targetAmount = getCheckoutItemDisplay(config);
|
|
@@ -9629,7 +9912,7 @@ var AddressRedirectButton = ({
|
|
|
9629
9912
|
chainId,
|
|
9630
9913
|
address
|
|
9631
9914
|
}) => {
|
|
9632
|
-
const explorerInfo =
|
|
9915
|
+
const explorerInfo = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO7[chainId].explorerInfo;
|
|
9633
9916
|
return /* @__PURE__ */ React99.createElement(
|
|
9634
9917
|
FunRedirectButton,
|
|
9635
9918
|
{
|
|
@@ -11220,471 +11503,206 @@ var RedRoundErrorCross = ({ size = 15 }) => {
|
|
|
11220
11503
|
height: size,
|
|
11221
11504
|
viewBox: "0 0 8 9",
|
|
11222
11505
|
fill: "none",
|
|
11223
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
11224
|
-
},
|
|
11225
|
-
/* @__PURE__ */ React121.createElement("circle", { cx: "4", cy: "4.5", r: "4", fill: "#F34126" }),
|
|
11226
|
-
/* @__PURE__ */ React121.createElement(
|
|
11227
|
-
"path",
|
|
11228
|
-
{
|
|
11229
|
-
d: "M2.57111 2.59761L4 4.02654L5.42889 2.59761C5.54807 2.47844 5.7369 2.46734 5.87797 2.57755L5.90238 2.59979C6.03254 2.72994 6.03254 2.94096 5.90238 3.07111L4.47346 4.5L5.90238 5.92889C6.02156 6.04806 6.03266 6.2369 5.92244 6.37797L5.90022 6.40239C5.77007 6.53254 5.55904 6.53254 5.42888 6.40238L4 4.97346L2.57111 6.40239C2.45193 6.52156 2.2631 6.53266 2.12203 6.42245L2.09761 6.40021C1.96746 6.27006 1.96746 6.05904 2.09761 5.92889L3.52654 4.5L2.09761 3.07111C1.97844 2.95194 1.96734 2.7631 2.07755 2.62203L2.09978 2.59761C2.22993 2.46746 2.44095 2.46746 2.57111 2.59761ZM2.36024 6.33149L2.35293 6.33242C2.35536 6.33217 2.3578 6.33185 2.36024 6.33149ZM2.31088 6.33152L2.31385 6.33194L2.31088 6.33152ZM2.3814 6.3269L2.37242 6.3292C2.37542 6.32852 2.37842 6.32775 2.3814 6.3269ZM2.40026 6.32026L2.39333 6.323C2.39564 6.32215 2.39795 6.32123 2.40026 6.32026ZM2.25106 6.31043L2.23334 6.29839C2.24074 6.30415 2.2485 6.30919 2.25656 6.31353L2.25106 6.31043ZM2.41976 6.31047L2.4144 6.31349C2.4144 6.31349 2.41796 6.31153 2.41976 6.31047ZM5.81353 6.24343L5.81042 6.24894L5.79839 6.26667C5.80415 6.25927 5.80919 6.25149 5.81353 6.24343ZM5.82275 6.2231L5.82025 6.22939C5.82114 6.22729 5.82197 6.2252 5.82275 6.2231ZM5.82913 6.20184L5.82703 6.21006C5.82778 6.20739 5.8285 6.20462 5.82913 6.20184ZM5.83241 6.18215L5.83152 6.18912C5.83186 6.18683 5.83216 6.18449 5.83241 6.18215ZM5.66455 2.83328L4 4.49787L2.33545 2.83328L2.33327 2.83545L3.99787 4.5L2.33327 6.16455L2.33545 6.16672L4 4.50213L5.66455 6.16672L5.66673 6.16455L4.00213 4.5L5.66673 2.83545L5.66455 2.83328ZM5.83331 6.16189L5.83332 6.16672L5.83331 6.16189ZM5.83149 6.13977L5.83242 6.14707C5.83216 6.14465 5.83186 6.1422 5.83149 6.13977ZM5.8269 6.1186L5.8292 6.12758C5.82852 6.12458 5.82776 6.12158 5.8269 6.1186ZM5.82026 6.09974L5.823 6.10667C5.82214 6.10436 5.82123 6.10204 5.82026 6.09974ZM5.81048 6.08024L5.81349 6.0856C5.81349 6.0856 5.81153 6.08203 5.81048 6.08024ZM2.18651 2.9144L2.18903 2.9189L2.18651 2.9144ZM2.177 2.89333L2.17924 2.89907C2.17845 2.89716 2.17772 2.89526 2.177 2.89333ZM2.1708 2.87242L2.17226 2.87835C2.17174 2.87638 2.17125 2.87441 2.1708 2.87242ZM2.16751 2.85227L2.16806 2.85705L2.16751 2.85227ZM2.16674 2.83061L2.16667 2.83545L2.16674 2.83061ZM2.16848 2.81088L2.16806 2.81385L2.16848 2.81088ZM2.18957 2.75106L2.20161 2.73333C2.19585 2.74073 2.1908 2.74851 2.18647 2.75657L2.18957 2.75106ZM2.41433 2.68647L2.41984 2.68957L2.43756 2.70161C2.43016 2.69585 2.42238 2.69081 2.41433 2.68647ZM5.5856 2.68651L5.5811 2.68903L5.5856 2.68651ZM2.2565 2.68651L2.25199 2.68903L2.2565 2.68651ZM5.74344 2.68647L5.74894 2.68957L5.76666 2.70161C5.75926 2.69585 5.75149 2.69081 5.74344 2.68647ZM2.27691 2.67725L2.27183 2.67924L2.27691 2.67725ZM2.3933 2.67699L2.40029 2.67975C2.39796 2.67877 2.39564 2.67785 2.3933 2.67699ZM5.60667 2.677L5.60093 2.67924C5.60284 2.67846 5.60473 2.67771 5.60667 2.677ZM5.7231 2.67725L5.72939 2.67975C5.72729 2.67887 5.7252 2.67804 5.7231 2.67725ZM2.29821 2.67086L2.29254 2.67226L2.29821 2.67086ZM2.37241 2.6708L2.38143 2.6731C2.37842 2.67225 2.37542 2.67148 2.37241 2.6708ZM5.62758 2.6708L5.62165 2.67226C5.62363 2.67173 5.62559 2.67125 5.62758 2.6708ZM5.70184 2.67087L5.71006 2.67297C5.7074 2.67221 5.70463 2.67151 5.70184 2.67087ZM2.31856 2.66752L2.31385 2.66806L2.31856 2.66752ZM2.35224 2.66751L2.36022 2.66851C2.35757 2.66811 2.35491 2.66778 2.35224 2.66751ZM5.64774 2.66751L5.64295 2.66806L5.64774 2.66751ZM5.68148 2.66752L5.68912 2.66848C5.68661 2.6681 5.68405 2.66778 5.68148 2.66752ZM5.65972 2.66674L5.66941 2.66674C5.66618 2.66664 5.66295 2.66664 5.65972 2.66674ZM2.33059 2.66674L2.34028 2.66674C2.33705 2.66664 2.33382 2.66664 2.33059 2.66674Z",
|
|
11230
|
-
fill: "white"
|
|
11231
|
-
}
|
|
11232
|
-
)
|
|
11233
|
-
);
|
|
11234
|
-
};
|
|
11235
|
-
|
|
11236
|
-
// src/modals/ProfileDetails/FunProfileViews/Home/HomeCheckoutDisplayRow.css.ts
|
|
11237
|
-
var homeCheckoutDisplayRowStyle = { defaultBorder: "ukct4t1 _1rsrm2f10k _1rsrm2fwo", defaultBackground: "_1rsrm2fpq _1rsrm2fls", hoverBackground: "_1rsrm2fll" };
|
|
11238
|
-
|
|
11239
|
-
// src/modals/ProfileDetails/FunProfileViews/Home/HomeCheckoutDisplayRow.tsx
|
|
11240
|
-
var HOME_CHECKOUT_DISPLAY_ROW_HEIGHT = 52;
|
|
11241
|
-
var ASSET_ICON_SIZE = "24";
|
|
11242
|
-
var TEXT_SIZE_MEDIUM = "13";
|
|
11243
|
-
var TEXT_SIZE_SMALL = "10";
|
|
11244
|
-
var STATUS_FLEX_GAP_X = "4";
|
|
11245
|
-
var STATUS_ICON_SIZE = "8";
|
|
11246
|
-
var STATUS_TEXT_SIZE = TEXT_SIZE_SMALL;
|
|
11247
|
-
var TEXT_SKELETON_MARGIN_TOP = "2";
|
|
11248
|
-
var TEXT_SKELETON_MARGIN_BOTTOM = "3";
|
|
11249
|
-
var TEXT_SKELETON_WIDTH_SHORT = "48";
|
|
11250
|
-
var TEXT_SKELETON_WIDTH_MEDIUM = "72";
|
|
11251
|
-
var TEXT_SKELETON_WIDTH_LONG = "96";
|
|
11252
|
-
var ROW_FLEX_GAP_X = "8";
|
|
11253
|
-
var ROW_PADDING_Y = "8";
|
|
11254
|
-
var HomeCheckoutDisplayRow = ({
|
|
11255
|
-
checkoutHistoryItem,
|
|
11256
|
-
onSelect
|
|
11257
|
-
}) => {
|
|
11258
|
-
const { isProcessing, isCompleted, isError, isExpired, isFailed } = useCheckoutStateBooleans(checkoutHistoryItem.state);
|
|
11259
|
-
const checkoutClientMetadata = checkoutHistoryItem.clientMetadata;
|
|
11260
|
-
const getStatusElement = () => {
|
|
11261
|
-
if (isCompleted) {
|
|
11262
|
-
return /* @__PURE__ */ React122.createElement(
|
|
11263
|
-
Box,
|
|
11264
|
-
{
|
|
11265
|
-
display: "flex",
|
|
11266
|
-
flexDirection: "row",
|
|
11267
|
-
gap: STATUS_FLEX_GAP_X,
|
|
11268
|
-
alignItems: "center"
|
|
11269
|
-
},
|
|
11270
|
-
/* @__PURE__ */ React122.createElement(GreenRoundCheckmark, { size: parseInt(STATUS_ICON_SIZE) }),
|
|
11271
|
-
/* @__PURE__ */ React122.createElement(Text, { size: STATUS_TEXT_SIZE, color: "success" }, "Completed")
|
|
11272
|
-
);
|
|
11273
|
-
} else if (isError || isFailed || isExpired) {
|
|
11274
|
-
return /* @__PURE__ */ React122.createElement(
|
|
11275
|
-
Box,
|
|
11276
|
-
{
|
|
11277
|
-
display: "flex",
|
|
11278
|
-
flexDirection: "row",
|
|
11279
|
-
gap: STATUS_FLEX_GAP_X,
|
|
11280
|
-
alignItems: "center"
|
|
11281
|
-
},
|
|
11282
|
-
/* @__PURE__ */ React122.createElement(RedRoundErrorCross, { size: parseInt(STATUS_ICON_SIZE) }),
|
|
11283
|
-
/* @__PURE__ */ React122.createElement(Text, { size: STATUS_TEXT_SIZE, color: "error" }, "Failed")
|
|
11284
|
-
);
|
|
11285
|
-
} else if (isProcessing) {
|
|
11286
|
-
return /* @__PURE__ */ React122.createElement(
|
|
11287
|
-
Box,
|
|
11288
|
-
{
|
|
11289
|
-
display: "flex",
|
|
11290
|
-
flexDirection: "row",
|
|
11291
|
-
gap: STATUS_FLEX_GAP_X,
|
|
11292
|
-
alignItems: "center"
|
|
11293
|
-
},
|
|
11294
|
-
/* @__PURE__ */ React122.createElement(
|
|
11295
|
-
Box,
|
|
11296
|
-
{
|
|
11297
|
-
width: STATUS_ICON_SIZE,
|
|
11298
|
-
height: STATUS_ICON_SIZE,
|
|
11299
|
-
borderRadius: "full",
|
|
11300
|
-
background: "standby"
|
|
11301
|
-
}
|
|
11302
|
-
),
|
|
11303
|
-
/* @__PURE__ */ React122.createElement(Text, { size: STATUS_TEXT_SIZE, color: "standby" }, "Processing")
|
|
11304
|
-
);
|
|
11305
|
-
}
|
|
11306
|
-
};
|
|
11307
|
-
return /* @__PURE__ */ React122.createElement(
|
|
11308
|
-
Box,
|
|
11309
|
-
{
|
|
11310
|
-
className: clsx8(
|
|
11311
|
-
homeCheckoutDisplayRowStyle.defaultBorder,
|
|
11312
|
-
homeCheckoutDisplayRowStyle.defaultBackground,
|
|
11313
|
-
!isMobile() && homeCheckoutDisplayRowStyle.hoverBackground
|
|
11314
|
-
),
|
|
11315
|
-
display: "flex",
|
|
11316
|
-
flexDirection: "column",
|
|
11317
|
-
justifyContent: "center",
|
|
11318
|
-
gap: "24",
|
|
11319
|
-
paddingX: PROFILE_SIDE_PADDING,
|
|
11320
|
-
paddingY: ROW_PADDING_Y,
|
|
11321
|
-
role: "button",
|
|
11322
|
-
tabIndex: 0,
|
|
11323
|
-
borderWidth: "2",
|
|
11324
|
-
borderStyle: "solid",
|
|
11325
|
-
onClick: () => {
|
|
11326
|
-
if (checkoutHistoryItem.depositAddr) {
|
|
11327
|
-
onSelect(checkoutHistoryItem.depositAddr, "detail" /* DETAIL */);
|
|
11328
|
-
}
|
|
11329
|
-
}
|
|
11330
|
-
},
|
|
11331
|
-
/* @__PURE__ */ React122.createElement(Box, { display: "flex", alignItems: "center", gap: ROW_FLEX_GAP_X, width: "full" }, isNotNullish(checkoutClientMetadata.initSettings.config.iconSrc) && /* @__PURE__ */ React122.createElement(
|
|
11332
|
-
Box,
|
|
11333
|
-
{
|
|
11334
|
-
display: "flex",
|
|
11335
|
-
alignItems: "center",
|
|
11336
|
-
justifyContent: "center",
|
|
11337
|
-
style: {
|
|
11338
|
-
flexShrink: 0,
|
|
11339
|
-
minWidth: "29px"
|
|
11340
|
-
}
|
|
11341
|
-
},
|
|
11342
|
-
/* @__PURE__ */ React122.createElement(
|
|
11343
|
-
FunAssetAvatar,
|
|
11344
|
-
{
|
|
11345
|
-
assetSrc: checkoutClientMetadata.initSettings.config.iconSrc,
|
|
11346
|
-
assetName: "checkout-asset",
|
|
11347
|
-
assetIconSize: ASSET_ICON_SIZE,
|
|
11348
|
-
prioritizeDefaults: false,
|
|
11349
|
-
chainId: checkoutClientMetadata.initSettings.config.targetChain
|
|
11350
|
-
}
|
|
11351
|
-
)
|
|
11352
|
-
), /* @__PURE__ */ React122.createElement(Box, { display: "flex", flexDirection: "column", width: "full" }, /* @__PURE__ */ React122.createElement(
|
|
11353
|
-
Box,
|
|
11354
|
-
{
|
|
11355
|
-
display: "flex",
|
|
11356
|
-
justifyContent: "space-between",
|
|
11357
|
-
alignItems: "center",
|
|
11358
|
-
gap: "16"
|
|
11359
|
-
},
|
|
11360
|
-
/* @__PURE__ */ React122.createElement(Text, { size: TEXT_SIZE_MEDIUM, weight: "medium", color: "primaryText" }, checkoutClientMetadata.initSettings.config.checkoutItemTitle),
|
|
11361
|
-
/* @__PURE__ */ React122.createElement(Text, { size: TEXT_SIZE_MEDIUM, weight: "medium", color: "primaryText" }, `${formatCurrencyAndStringify(
|
|
11362
|
-
(checkoutClientMetadata?.finalDollarValue ?? // For backwards compatibility
|
|
11363
|
-
checkoutClientMetadata?.draftDollarValue) || 0
|
|
11364
|
-
)} USD`)
|
|
11365
|
-
), /* @__PURE__ */ React122.createElement(Box, { display: "flex", justifyContent: "space-between", gap: "16" }, /* @__PURE__ */ React122.createElement(Text, { size: TEXT_SIZE_SMALL, color: "secondaryText" }, formatTimestamp(new Date(checkoutHistoryItem.createdTimeMs), {
|
|
11366
|
-
year: "none",
|
|
11367
|
-
seconds: "none",
|
|
11368
|
-
month: "short"
|
|
11369
|
-
})), /* @__PURE__ */ React122.createElement(Box, null, getStatusElement()))))
|
|
11370
|
-
);
|
|
11371
|
-
};
|
|
11372
|
-
var HomeCheckoutDisplayRowSkeleton = () => {
|
|
11373
|
-
return /* @__PURE__ */ React122.createElement(
|
|
11374
|
-
Box,
|
|
11375
|
-
{
|
|
11376
|
-
display: "flex",
|
|
11377
|
-
flexDirection: "row",
|
|
11378
|
-
alignItems: "center",
|
|
11379
|
-
gap: ROW_FLEX_GAP_X,
|
|
11380
|
-
paddingX: PROFILE_SIDE_PADDING,
|
|
11381
|
-
paddingY: ROW_PADDING_Y
|
|
11506
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
11382
11507
|
},
|
|
11383
|
-
/* @__PURE__ */
|
|
11384
|
-
/* @__PURE__ */
|
|
11385
|
-
|
|
11386
|
-
{
|
|
11387
|
-
height: TEXT_SIZE_MEDIUM,
|
|
11388
|
-
marginBottom: TEXT_SKELETON_MARGIN_BOTTOM,
|
|
11389
|
-
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11390
|
-
width: TEXT_SKELETON_WIDTH_LONG
|
|
11391
|
-
}
|
|
11392
|
-
), /* @__PURE__ */ React122.createElement(
|
|
11393
|
-
FunSkeletonBlock,
|
|
11394
|
-
{
|
|
11395
|
-
height: TEXT_SIZE_SMALL,
|
|
11396
|
-
marginBottom: TEXT_SKELETON_MARGIN_BOTTOM,
|
|
11397
|
-
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11398
|
-
width: TEXT_SKELETON_WIDTH_MEDIUM
|
|
11399
|
-
}
|
|
11400
|
-
)),
|
|
11401
|
-
/* @__PURE__ */ React122.createElement(Box, { alignItems: "flex-end", display: "flex", flexDirection: "column" }, /* @__PURE__ */ React122.createElement(
|
|
11402
|
-
FunSkeletonBlock,
|
|
11403
|
-
{
|
|
11404
|
-
height: TEXT_SIZE_MEDIUM,
|
|
11405
|
-
marginBottom: TEXT_SKELETON_MARGIN_BOTTOM,
|
|
11406
|
-
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11407
|
-
width: TEXT_SKELETON_WIDTH_MEDIUM
|
|
11408
|
-
}
|
|
11409
|
-
), /* @__PURE__ */ React122.createElement(
|
|
11410
|
-
FunSkeletonBlock,
|
|
11508
|
+
/* @__PURE__ */ React121.createElement("circle", { cx: "4", cy: "4.5", r: "4", fill: "#F34126" }),
|
|
11509
|
+
/* @__PURE__ */ React121.createElement(
|
|
11510
|
+
"path",
|
|
11411
11511
|
{
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11415
|
-
width: TEXT_SKELETON_WIDTH_SHORT
|
|
11512
|
+
d: "M2.57111 2.59761L4 4.02654L5.42889 2.59761C5.54807 2.47844 5.7369 2.46734 5.87797 2.57755L5.90238 2.59979C6.03254 2.72994 6.03254 2.94096 5.90238 3.07111L4.47346 4.5L5.90238 5.92889C6.02156 6.04806 6.03266 6.2369 5.92244 6.37797L5.90022 6.40239C5.77007 6.53254 5.55904 6.53254 5.42888 6.40238L4 4.97346L2.57111 6.40239C2.45193 6.52156 2.2631 6.53266 2.12203 6.42245L2.09761 6.40021C1.96746 6.27006 1.96746 6.05904 2.09761 5.92889L3.52654 4.5L2.09761 3.07111C1.97844 2.95194 1.96734 2.7631 2.07755 2.62203L2.09978 2.59761C2.22993 2.46746 2.44095 2.46746 2.57111 2.59761ZM2.36024 6.33149L2.35293 6.33242C2.35536 6.33217 2.3578 6.33185 2.36024 6.33149ZM2.31088 6.33152L2.31385 6.33194L2.31088 6.33152ZM2.3814 6.3269L2.37242 6.3292C2.37542 6.32852 2.37842 6.32775 2.3814 6.3269ZM2.40026 6.32026L2.39333 6.323C2.39564 6.32215 2.39795 6.32123 2.40026 6.32026ZM2.25106 6.31043L2.23334 6.29839C2.24074 6.30415 2.2485 6.30919 2.25656 6.31353L2.25106 6.31043ZM2.41976 6.31047L2.4144 6.31349C2.4144 6.31349 2.41796 6.31153 2.41976 6.31047ZM5.81353 6.24343L5.81042 6.24894L5.79839 6.26667C5.80415 6.25927 5.80919 6.25149 5.81353 6.24343ZM5.82275 6.2231L5.82025 6.22939C5.82114 6.22729 5.82197 6.2252 5.82275 6.2231ZM5.82913 6.20184L5.82703 6.21006C5.82778 6.20739 5.8285 6.20462 5.82913 6.20184ZM5.83241 6.18215L5.83152 6.18912C5.83186 6.18683 5.83216 6.18449 5.83241 6.18215ZM5.66455 2.83328L4 4.49787L2.33545 2.83328L2.33327 2.83545L3.99787 4.5L2.33327 6.16455L2.33545 6.16672L4 4.50213L5.66455 6.16672L5.66673 6.16455L4.00213 4.5L5.66673 2.83545L5.66455 2.83328ZM5.83331 6.16189L5.83332 6.16672L5.83331 6.16189ZM5.83149 6.13977L5.83242 6.14707C5.83216 6.14465 5.83186 6.1422 5.83149 6.13977ZM5.8269 6.1186L5.8292 6.12758C5.82852 6.12458 5.82776 6.12158 5.8269 6.1186ZM5.82026 6.09974L5.823 6.10667C5.82214 6.10436 5.82123 6.10204 5.82026 6.09974ZM5.81048 6.08024L5.81349 6.0856C5.81349 6.0856 5.81153 6.08203 5.81048 6.08024ZM2.18651 2.9144L2.18903 2.9189L2.18651 2.9144ZM2.177 2.89333L2.17924 2.89907C2.17845 2.89716 2.17772 2.89526 2.177 2.89333ZM2.1708 2.87242L2.17226 2.87835C2.17174 2.87638 2.17125 2.87441 2.1708 2.87242ZM2.16751 2.85227L2.16806 2.85705L2.16751 2.85227ZM2.16674 2.83061L2.16667 2.83545L2.16674 2.83061ZM2.16848 2.81088L2.16806 2.81385L2.16848 2.81088ZM2.18957 2.75106L2.20161 2.73333C2.19585 2.74073 2.1908 2.74851 2.18647 2.75657L2.18957 2.75106ZM2.41433 2.68647L2.41984 2.68957L2.43756 2.70161C2.43016 2.69585 2.42238 2.69081 2.41433 2.68647ZM5.5856 2.68651L5.5811 2.68903L5.5856 2.68651ZM2.2565 2.68651L2.25199 2.68903L2.2565 2.68651ZM5.74344 2.68647L5.74894 2.68957L5.76666 2.70161C5.75926 2.69585 5.75149 2.69081 5.74344 2.68647ZM2.27691 2.67725L2.27183 2.67924L2.27691 2.67725ZM2.3933 2.67699L2.40029 2.67975C2.39796 2.67877 2.39564 2.67785 2.3933 2.67699ZM5.60667 2.677L5.60093 2.67924C5.60284 2.67846 5.60473 2.67771 5.60667 2.677ZM5.7231 2.67725L5.72939 2.67975C5.72729 2.67887 5.7252 2.67804 5.7231 2.67725ZM2.29821 2.67086L2.29254 2.67226L2.29821 2.67086ZM2.37241 2.6708L2.38143 2.6731C2.37842 2.67225 2.37542 2.67148 2.37241 2.6708ZM5.62758 2.6708L5.62165 2.67226C5.62363 2.67173 5.62559 2.67125 5.62758 2.6708ZM5.70184 2.67087L5.71006 2.67297C5.7074 2.67221 5.70463 2.67151 5.70184 2.67087ZM2.31856 2.66752L2.31385 2.66806L2.31856 2.66752ZM2.35224 2.66751L2.36022 2.66851C2.35757 2.66811 2.35491 2.66778 2.35224 2.66751ZM5.64774 2.66751L5.64295 2.66806L5.64774 2.66751ZM5.68148 2.66752L5.68912 2.66848C5.68661 2.6681 5.68405 2.66778 5.68148 2.66752ZM5.65972 2.66674L5.66941 2.66674C5.66618 2.66664 5.66295 2.66664 5.65972 2.66674ZM2.33059 2.66674L2.34028 2.66674C2.33705 2.66664 2.33382 2.66664 2.33059 2.66674Z",
|
|
11513
|
+
fill: "white"
|
|
11416
11514
|
}
|
|
11417
|
-
)
|
|
11515
|
+
)
|
|
11418
11516
|
);
|
|
11419
11517
|
};
|
|
11420
11518
|
|
|
11421
|
-
// src/modals/ProfileDetails/FunProfileViews/Home/
|
|
11422
|
-
|
|
11519
|
+
// src/modals/ProfileDetails/FunProfileViews/Home/HomeCheckoutDisplayRow.css.ts
|
|
11520
|
+
var homeCheckoutDisplayRowStyle = { defaultBorder: "ukct4t1 _1rsrm2f10k _1rsrm2fwo", defaultBackground: "_1rsrm2fpq _1rsrm2fls", hoverBackground: "_1rsrm2fll" };
|
|
11423
11521
|
|
|
11424
|
-
// src/
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
var
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
var
|
|
11436
|
-
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
isWeb2Login && FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO7[assetChainId].isFunWalletSupported || // User is logged in with web3 or not logged in at all, ignore
|
|
11443
|
-
isWeb3Login || !isWeb2Login && !isWeb3Login
|
|
11444
|
-
);
|
|
11445
|
-
const isZkSyncAssetsDisabled = flags["disable_zksync_source_assets" /* DisableZkSyncSourceAssets */] ?? true;
|
|
11446
|
-
const isMantleAssetsDisabled = flags["disable_mantle_source_assets" /* DisableMantleSourceAssets */] ?? true;
|
|
11447
|
-
const isAssetDisabled = (
|
|
11448
|
-
// Disable all mantle assets
|
|
11449
|
-
isMantleAssetsDisabled && assetChainId === mantle.id.toString() || // Disable all zksync assets
|
|
11450
|
-
isZkSyncAssetsDisabled && assetChainId === zkSync2.id.toString()
|
|
11451
|
-
);
|
|
11452
|
-
const isPickedChainSupportedForCheckout = isConnectedAccountSupported && FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO7[assetChainId].isCheckoutSupported && !isAssetDisabled;
|
|
11453
|
-
const isUsable = !isSameAsPurchasingToken && isPickedChainSupportedForCheckout;
|
|
11454
|
-
return {
|
|
11455
|
-
isUsable,
|
|
11456
|
-
reason: isUsable ? "" : isSameAsPurchasingToken ? "Not Applicable" : !isPickedChainSupportedForCheckout ? "Unsupported" : ""
|
|
11457
|
-
};
|
|
11458
|
-
};
|
|
11459
|
-
var getAssetSymbolWithMaxUsdValue = ({
|
|
11460
|
-
accountHoldingsMap,
|
|
11461
|
-
filterSymbols
|
|
11522
|
+
// src/modals/ProfileDetails/FunProfileViews/Home/HomeCheckoutDisplayRow.tsx
|
|
11523
|
+
var HOME_CHECKOUT_DISPLAY_ROW_HEIGHT = 52;
|
|
11524
|
+
var ASSET_ICON_SIZE = "24";
|
|
11525
|
+
var TEXT_SIZE_MEDIUM = "13";
|
|
11526
|
+
var TEXT_SIZE_SMALL = "10";
|
|
11527
|
+
var STATUS_FLEX_GAP_X = "4";
|
|
11528
|
+
var STATUS_ICON_SIZE = "8";
|
|
11529
|
+
var STATUS_TEXT_SIZE = TEXT_SIZE_SMALL;
|
|
11530
|
+
var TEXT_SKELETON_MARGIN_TOP = "2";
|
|
11531
|
+
var TEXT_SKELETON_MARGIN_BOTTOM = "3";
|
|
11532
|
+
var TEXT_SKELETON_WIDTH_SHORT = "48";
|
|
11533
|
+
var TEXT_SKELETON_WIDTH_MEDIUM = "72";
|
|
11534
|
+
var TEXT_SKELETON_WIDTH_LONG = "96";
|
|
11535
|
+
var ROW_FLEX_GAP_X = "8";
|
|
11536
|
+
var ROW_PADDING_Y = "8";
|
|
11537
|
+
var HomeCheckoutDisplayRow = ({
|
|
11538
|
+
checkoutHistoryItem,
|
|
11539
|
+
onSelect
|
|
11462
11540
|
}) => {
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11473
|
-
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
|
|
11488
|
-
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11510
|
-
feeEstimate += getMeshFeesUsdEstimate(asset);
|
|
11511
|
-
}
|
|
11512
|
-
return feeEstimate;
|
|
11513
|
-
};
|
|
11514
|
-
var isAssetUsdAmountSufficient = (checkoutItem, asset) => {
|
|
11515
|
-
if (!isNotNullish(asset?.usdAmount)) {
|
|
11516
|
-
return false;
|
|
11517
|
-
}
|
|
11518
|
-
if (!isNotNullish(checkoutItem?.draftDollarValue)) {
|
|
11519
|
-
return false;
|
|
11520
|
-
}
|
|
11521
|
-
return asset.usdAmount > checkoutItem?.draftDollarValue + getFeesUsdEstimate(checkoutItem, asset);
|
|
11522
|
-
};
|
|
11523
|
-
var getRecommendedAsset = (flags, checkoutItem, accountHoldingsMap, isWeb3Login, isWeb2Login) => {
|
|
11524
|
-
const highestValueAssetSymbol = getAssetSymbolWithMaxUsdValue({
|
|
11525
|
-
accountHoldingsMap
|
|
11526
|
-
});
|
|
11527
|
-
if (!isNotNullish(highestValueAssetSymbol) || !isAssetUsdAmountSufficient(
|
|
11528
|
-
checkoutItem,
|
|
11529
|
-
accountHoldingsMap[highestValueAssetSymbol]
|
|
11530
|
-
)) {
|
|
11531
|
-
return null;
|
|
11532
|
-
}
|
|
11533
|
-
const assetsOnL1 = Object.keys(accountHoldingsMap)?.filter(
|
|
11534
|
-
(chainSymbolKey) => accountHoldingsMap[chainSymbolKey].pickedChainId === mainnet4.id.toString()
|
|
11535
|
-
);
|
|
11536
|
-
const assetsOnL2 = Object.keys(accountHoldingsMap)?.filter(
|
|
11537
|
-
(chainSymbolKey) => accountHoldingsMap[chainSymbolKey].pickedChainId !== mainnet4.id.toString()
|
|
11538
|
-
);
|
|
11539
|
-
const highestValueL1Asset = assetsOnL1.length ? getAssetSymbolWithMaxUsdValue({
|
|
11540
|
-
accountHoldingsMap,
|
|
11541
|
-
filterSymbols: assetsOnL1
|
|
11542
|
-
}) : null;
|
|
11543
|
-
const highestValueL2Asset = assetsOnL2.length ? getAssetSymbolWithMaxUsdValue({
|
|
11544
|
-
accountHoldingsMap,
|
|
11545
|
-
filterSymbols: assetsOnL2
|
|
11546
|
-
}) : null;
|
|
11547
|
-
if (!isNotNullish(highestValueL1Asset) && !isNotNullish(highestValueL2Asset)) {
|
|
11548
|
-
return null;
|
|
11549
|
-
}
|
|
11550
|
-
const highestValueL1UsdAmount = highestValueL1Asset ? accountHoldingsMap[highestValueL1Asset]?.usdAmount || 0 : null;
|
|
11551
|
-
const highestValueL2UsdAmount = highestValueL2Asset ? accountHoldingsMap[highestValueL2Asset]?.usdAmount || 0 : null;
|
|
11552
|
-
if (!isNotNullish(highestValueL1UsdAmount) && !isNotNullish(highestValueL2UsdAmount)) {
|
|
11553
|
-
return null;
|
|
11554
|
-
}
|
|
11555
|
-
const checkoutConfig = checkoutItem.initSettings.config;
|
|
11556
|
-
const targetChainId = getMockedTargetChainId(checkoutConfig, [
|
|
11557
|
-
dydxChain2.id.toString()
|
|
11558
|
-
]);
|
|
11559
|
-
const targetChainIdAssetSymbol = Object.keys(accountHoldingsMap).find(
|
|
11560
|
-
(chainIdSymbol) => {
|
|
11561
|
-
const item = accountHoldingsMap[chainIdSymbol];
|
|
11562
|
-
if (item.pickedChainId === targetChainId && item.tokenAddress === checkoutConfig.targetAsset) {
|
|
11563
|
-
return chainIdSymbol;
|
|
11564
|
-
}
|
|
11565
|
-
return null;
|
|
11566
|
-
}
|
|
11567
|
-
);
|
|
11568
|
-
if (isCheckoutPostActionRequired(checkoutItem.initSettings.config) || isCheckoutCrFlow(checkoutItem)) {
|
|
11569
|
-
if (targetChainIdAssetSymbol && isAssetUsdAmountSufficient(
|
|
11570
|
-
checkoutItem,
|
|
11571
|
-
accountHoldingsMap[targetChainIdAssetSymbol]
|
|
11572
|
-
)) {
|
|
11573
|
-
return {
|
|
11574
|
-
symbol: targetChainIdAssetSymbol,
|
|
11575
|
-
label: "Cheapest"
|
|
11576
|
-
};
|
|
11541
|
+
const { isProcessing, isCompleted, isError, isExpired, isFailed } = useCheckoutStateBooleans(checkoutHistoryItem.state);
|
|
11542
|
+
const checkoutClientMetadata = checkoutHistoryItem.clientMetadata;
|
|
11543
|
+
const getStatusElement = () => {
|
|
11544
|
+
if (isCompleted) {
|
|
11545
|
+
return /* @__PURE__ */ React122.createElement(
|
|
11546
|
+
Box,
|
|
11547
|
+
{
|
|
11548
|
+
display: "flex",
|
|
11549
|
+
flexDirection: "row",
|
|
11550
|
+
gap: STATUS_FLEX_GAP_X,
|
|
11551
|
+
alignItems: "center"
|
|
11552
|
+
},
|
|
11553
|
+
/* @__PURE__ */ React122.createElement(GreenRoundCheckmark, { size: parseInt(STATUS_ICON_SIZE) }),
|
|
11554
|
+
/* @__PURE__ */ React122.createElement(Text, { size: STATUS_TEXT_SIZE, color: "success" }, "Completed")
|
|
11555
|
+
);
|
|
11556
|
+
} else if (isError || isFailed || isExpired) {
|
|
11557
|
+
return /* @__PURE__ */ React122.createElement(
|
|
11558
|
+
Box,
|
|
11559
|
+
{
|
|
11560
|
+
display: "flex",
|
|
11561
|
+
flexDirection: "row",
|
|
11562
|
+
gap: STATUS_FLEX_GAP_X,
|
|
11563
|
+
alignItems: "center"
|
|
11564
|
+
},
|
|
11565
|
+
/* @__PURE__ */ React122.createElement(RedRoundErrorCross, { size: parseInt(STATUS_ICON_SIZE) }),
|
|
11566
|
+
/* @__PURE__ */ React122.createElement(Text, { size: STATUS_TEXT_SIZE, color: "error" }, "Failed")
|
|
11567
|
+
);
|
|
11568
|
+
} else if (isProcessing) {
|
|
11569
|
+
return /* @__PURE__ */ React122.createElement(
|
|
11570
|
+
Box,
|
|
11571
|
+
{
|
|
11572
|
+
display: "flex",
|
|
11573
|
+
flexDirection: "row",
|
|
11574
|
+
gap: STATUS_FLEX_GAP_X,
|
|
11575
|
+
alignItems: "center"
|
|
11576
|
+
},
|
|
11577
|
+
/* @__PURE__ */ React122.createElement(
|
|
11578
|
+
Box,
|
|
11579
|
+
{
|
|
11580
|
+
width: STATUS_ICON_SIZE,
|
|
11581
|
+
height: STATUS_ICON_SIZE,
|
|
11582
|
+
borderRadius: "full",
|
|
11583
|
+
background: "standby"
|
|
11584
|
+
}
|
|
11585
|
+
),
|
|
11586
|
+
/* @__PURE__ */ React122.createElement(Text, { size: STATUS_TEXT_SIZE, color: "standby" }, "Processing")
|
|
11587
|
+
);
|
|
11577
11588
|
}
|
|
11578
|
-
}
|
|
11579
|
-
const usableAssetHoldingMap = checkoutItem ? Object.fromEntries(
|
|
11580
|
-
Object.entries(accountHoldingsMap).filter(
|
|
11581
|
-
([_, item]) => isAssetUsableToPayForCheckout(
|
|
11582
|
-
flags,
|
|
11583
|
-
checkoutItem,
|
|
11584
|
-
checkoutItem?.selectedPaymentMethodInfo?.paymentMethod,
|
|
11585
|
-
item.pickedChainId,
|
|
11586
|
-
item.tokenAddress,
|
|
11587
|
-
isWeb2Login,
|
|
11588
|
-
isWeb3Login
|
|
11589
|
-
).isUsable
|
|
11590
|
-
)
|
|
11591
|
-
) : {};
|
|
11592
|
-
const highestValueUsableAssetSymbol = getAssetSymbolWithMaxUsdValue({
|
|
11593
|
-
accountHoldingsMap: usableAssetHoldingMap
|
|
11594
|
-
});
|
|
11595
|
-
if (!isNotNullish(highestValueUsableAssetSymbol) || !isAssetUsdAmountSufficient(
|
|
11596
|
-
checkoutItem,
|
|
11597
|
-
usableAssetHoldingMap[highestValueUsableAssetSymbol]
|
|
11598
|
-
)) {
|
|
11599
|
-
return null;
|
|
11600
|
-
}
|
|
11601
|
-
const stableAssetOnTargetChainSymbols = STABLECOIN_SYMBOLS.map(
|
|
11602
|
-
(symbol) => combineChainSymbolOrAddress({
|
|
11603
|
-
chainId: targetChainId,
|
|
11604
|
-
symbolOrAddress: symbol
|
|
11605
|
-
})
|
|
11606
|
-
);
|
|
11607
|
-
const highestValueStableAssetOnTargetChain = getAssetSymbolWithMaxUsdValue({
|
|
11608
|
-
accountHoldingsMap: usableAssetHoldingMap,
|
|
11609
|
-
filterSymbols: stableAssetOnTargetChainSymbols.filter(
|
|
11610
|
-
(asset) => asset !== null
|
|
11611
|
-
)
|
|
11612
|
-
});
|
|
11613
|
-
if (isNotNullish(highestValueStableAssetOnTargetChain) && isAssetUsdAmountSufficient(
|
|
11614
|
-
checkoutItem,
|
|
11615
|
-
usableAssetHoldingMap[highestValueStableAssetOnTargetChain]
|
|
11616
|
-
)) {
|
|
11617
|
-
return {
|
|
11618
|
-
symbol: highestValueStableAssetOnTargetChain,
|
|
11619
|
-
label: "Cheapest"
|
|
11620
|
-
};
|
|
11621
|
-
}
|
|
11622
|
-
const targetChainIdEthSymbol = combineChainSymbolOrAddress({
|
|
11623
|
-
chainId: targetChainId,
|
|
11624
|
-
symbolOrAddress: "ETH"
|
|
11625
|
-
});
|
|
11626
|
-
if (isNotNullish(targetChainIdEthSymbol) && isAssetUsdAmountSufficient(
|
|
11627
|
-
checkoutItem,
|
|
11628
|
-
usableAssetHoldingMap[targetChainIdEthSymbol]
|
|
11629
|
-
)) {
|
|
11630
|
-
return {
|
|
11631
|
-
symbol: targetChainIdEthSymbol,
|
|
11632
|
-
label: "Cheapest"
|
|
11633
|
-
};
|
|
11634
|
-
}
|
|
11635
|
-
const targetChainCoreToken = targetChainId ? FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO7[targetChainId].coreToken : null;
|
|
11636
|
-
const targetChainIdAndCoreTokenSymbol = targetChainCoreToken?.symbol && combineChainSymbolOrAddress({
|
|
11637
|
-
chainId: targetChainId,
|
|
11638
|
-
symbolOrAddress: targetChainCoreToken?.symbol
|
|
11639
|
-
});
|
|
11640
|
-
if (isNotNullish(targetChainIdAndCoreTokenSymbol) && isAssetUsdAmountSufficient(
|
|
11641
|
-
checkoutItem,
|
|
11642
|
-
usableAssetHoldingMap[targetChainIdAndCoreTokenSymbol]
|
|
11643
|
-
)) {
|
|
11644
|
-
return {
|
|
11645
|
-
symbol: targetChainIdAndCoreTokenSymbol,
|
|
11646
|
-
label: "Cheapest"
|
|
11647
|
-
};
|
|
11648
|
-
}
|
|
11649
|
-
const highestValueUsableL2Asset = assetsOnL2.length ? getAssetSymbolWithMaxUsdValue({
|
|
11650
|
-
accountHoldingsMap: usableAssetHoldingMap,
|
|
11651
|
-
filterSymbols: assetsOnL2
|
|
11652
|
-
}) : null;
|
|
11653
|
-
const highestValueUsableL2UsdAmount = highestValueUsableL2Asset ? usableAssetHoldingMap[highestValueUsableL2Asset]?.usdAmount || 0 : null;
|
|
11654
|
-
if (targetChainId !== mainnet4.id.toString() && isNotNullish(highestValueUsableL2Asset) && isAssetUsdAmountSufficient(
|
|
11655
|
-
checkoutItem,
|
|
11656
|
-
usableAssetHoldingMap[highestValueUsableL2Asset]
|
|
11657
|
-
)) {
|
|
11658
|
-
return {
|
|
11659
|
-
symbol: highestValueUsableL2Asset,
|
|
11660
|
-
label: "Cheapest"
|
|
11661
|
-
};
|
|
11662
|
-
}
|
|
11663
|
-
const highestValueUsableAssetUsdAmount = highestValueUsableAssetSymbol ? usableAssetHoldingMap[highestValueUsableAssetSymbol]?.usdAmount || 0 : null;
|
|
11664
|
-
if (isNotNullish(highestValueUsableL2UsdAmount) && isNotNullish(highestValueUsableL2Asset) && highestValueUsableL2UsdAmount * L2_COST_MARGIN_MULTIPLIER > (highestValueUsableAssetUsdAmount || 0)) {
|
|
11665
|
-
return {
|
|
11666
|
-
symbol: highestValueUsableL2Asset,
|
|
11667
|
-
label: null
|
|
11668
|
-
};
|
|
11669
|
-
}
|
|
11670
|
-
return {
|
|
11671
|
-
symbol: highestValueUsableAssetSymbol,
|
|
11672
|
-
label: null
|
|
11673
11589
|
};
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11590
|
+
return /* @__PURE__ */ React122.createElement(
|
|
11591
|
+
Box,
|
|
11592
|
+
{
|
|
11593
|
+
className: clsx8(
|
|
11594
|
+
homeCheckoutDisplayRowStyle.defaultBorder,
|
|
11595
|
+
homeCheckoutDisplayRowStyle.defaultBackground,
|
|
11596
|
+
!isMobile() && homeCheckoutDisplayRowStyle.hoverBackground
|
|
11597
|
+
),
|
|
11598
|
+
display: "flex",
|
|
11599
|
+
flexDirection: "column",
|
|
11600
|
+
justifyContent: "center",
|
|
11601
|
+
gap: "24",
|
|
11602
|
+
paddingX: PROFILE_SIDE_PADDING,
|
|
11603
|
+
paddingY: ROW_PADDING_Y,
|
|
11604
|
+
role: "button",
|
|
11605
|
+
tabIndex: 0,
|
|
11606
|
+
borderWidth: "2",
|
|
11607
|
+
borderStyle: "solid",
|
|
11608
|
+
onClick: () => {
|
|
11609
|
+
if (checkoutHistoryItem.depositAddr) {
|
|
11610
|
+
onSelect(checkoutHistoryItem.depositAddr, "detail" /* DETAIL */);
|
|
11611
|
+
}
|
|
11612
|
+
}
|
|
11613
|
+
},
|
|
11614
|
+
/* @__PURE__ */ React122.createElement(Box, { display: "flex", alignItems: "center", gap: ROW_FLEX_GAP_X, width: "full" }, isNotNullish(checkoutClientMetadata.initSettings.config.iconSrc) && /* @__PURE__ */ React122.createElement(
|
|
11615
|
+
Box,
|
|
11616
|
+
{
|
|
11617
|
+
display: "flex",
|
|
11618
|
+
alignItems: "center",
|
|
11619
|
+
justifyContent: "center",
|
|
11620
|
+
style: {
|
|
11621
|
+
flexShrink: 0,
|
|
11622
|
+
minWidth: "29px"
|
|
11623
|
+
}
|
|
11624
|
+
},
|
|
11625
|
+
/* @__PURE__ */ React122.createElement(
|
|
11626
|
+
FunAssetAvatar,
|
|
11627
|
+
{
|
|
11628
|
+
assetSrc: checkoutClientMetadata.initSettings.config.iconSrc,
|
|
11629
|
+
assetName: "checkout-asset",
|
|
11630
|
+
assetIconSize: ASSET_ICON_SIZE,
|
|
11631
|
+
prioritizeDefaults: false,
|
|
11632
|
+
chainId: checkoutClientMetadata.initSettings.config.targetChain
|
|
11633
|
+
}
|
|
11634
|
+
)
|
|
11635
|
+
), /* @__PURE__ */ React122.createElement(Box, { display: "flex", flexDirection: "column", width: "full" }, /* @__PURE__ */ React122.createElement(
|
|
11636
|
+
Box,
|
|
11637
|
+
{
|
|
11638
|
+
display: "flex",
|
|
11639
|
+
justifyContent: "space-between",
|
|
11640
|
+
alignItems: "center",
|
|
11641
|
+
gap: "16"
|
|
11642
|
+
},
|
|
11643
|
+
/* @__PURE__ */ React122.createElement(Text, { size: TEXT_SIZE_MEDIUM, weight: "medium", color: "primaryText" }, checkoutClientMetadata.initSettings.config.checkoutItemTitle),
|
|
11644
|
+
/* @__PURE__ */ React122.createElement(Text, { size: TEXT_SIZE_MEDIUM, weight: "medium", color: "primaryText" }, `${formatCurrencyAndStringify(
|
|
11645
|
+
(checkoutClientMetadata?.finalDollarValue ?? // For backwards compatibility
|
|
11646
|
+
checkoutClientMetadata?.draftDollarValue) || 0
|
|
11647
|
+
)} USD`)
|
|
11648
|
+
), /* @__PURE__ */ React122.createElement(Box, { display: "flex", justifyContent: "space-between", gap: "16" }, /* @__PURE__ */ React122.createElement(Text, { size: TEXT_SIZE_SMALL, color: "secondaryText" }, formatTimestamp(new Date(checkoutHistoryItem.createdTimeMs), {
|
|
11649
|
+
year: "none",
|
|
11650
|
+
seconds: "none",
|
|
11651
|
+
month: "short"
|
|
11652
|
+
})), /* @__PURE__ */ React122.createElement(Box, null, getStatusElement()))))
|
|
11679
11653
|
);
|
|
11680
|
-
return formatCurrencyAndStringify(maxUsdBalance);
|
|
11681
11654
|
};
|
|
11682
|
-
var
|
|
11683
|
-
|
|
11684
|
-
|
|
11655
|
+
var HomeCheckoutDisplayRowSkeleton = () => {
|
|
11656
|
+
return /* @__PURE__ */ React122.createElement(
|
|
11657
|
+
Box,
|
|
11658
|
+
{
|
|
11659
|
+
display: "flex",
|
|
11660
|
+
flexDirection: "row",
|
|
11661
|
+
alignItems: "center",
|
|
11662
|
+
gap: ROW_FLEX_GAP_X,
|
|
11663
|
+
paddingX: PROFILE_SIDE_PADDING,
|
|
11664
|
+
paddingY: ROW_PADDING_Y
|
|
11665
|
+
},
|
|
11666
|
+
/* @__PURE__ */ React122.createElement(FunSkeletonCircle, { size: ASSET_ICON_SIZE }),
|
|
11667
|
+
/* @__PURE__ */ React122.createElement(Box, { display: "flex", flexDirection: "column", style: { flexGrow: 1 } }, /* @__PURE__ */ React122.createElement(
|
|
11668
|
+
FunSkeletonBlock,
|
|
11669
|
+
{
|
|
11670
|
+
height: TEXT_SIZE_MEDIUM,
|
|
11671
|
+
marginBottom: TEXT_SKELETON_MARGIN_BOTTOM,
|
|
11672
|
+
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11673
|
+
width: TEXT_SKELETON_WIDTH_LONG
|
|
11674
|
+
}
|
|
11675
|
+
), /* @__PURE__ */ React122.createElement(
|
|
11676
|
+
FunSkeletonBlock,
|
|
11677
|
+
{
|
|
11678
|
+
height: TEXT_SIZE_SMALL,
|
|
11679
|
+
marginBottom: TEXT_SKELETON_MARGIN_BOTTOM,
|
|
11680
|
+
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11681
|
+
width: TEXT_SKELETON_WIDTH_MEDIUM
|
|
11682
|
+
}
|
|
11683
|
+
)),
|
|
11684
|
+
/* @__PURE__ */ React122.createElement(Box, { alignItems: "flex-end", display: "flex", flexDirection: "column" }, /* @__PURE__ */ React122.createElement(
|
|
11685
|
+
FunSkeletonBlock,
|
|
11686
|
+
{
|
|
11687
|
+
height: TEXT_SIZE_MEDIUM,
|
|
11688
|
+
marginBottom: TEXT_SKELETON_MARGIN_BOTTOM,
|
|
11689
|
+
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11690
|
+
width: TEXT_SKELETON_WIDTH_MEDIUM
|
|
11691
|
+
}
|
|
11692
|
+
), /* @__PURE__ */ React122.createElement(
|
|
11693
|
+
FunSkeletonBlock,
|
|
11694
|
+
{
|
|
11695
|
+
height: STATUS_TEXT_SIZE,
|
|
11696
|
+
marginBottom: TEXT_SKELETON_MARGIN_BOTTOM,
|
|
11697
|
+
marginTop: TEXT_SKELETON_MARGIN_TOP,
|
|
11698
|
+
width: TEXT_SKELETON_WIDTH_SHORT
|
|
11699
|
+
}
|
|
11700
|
+
))
|
|
11701
|
+
);
|
|
11685
11702
|
};
|
|
11686
11703
|
|
|
11687
11704
|
// src/modals/ProfileDetails/FunProfileViews/Home/HomeTokenDisplayRow.tsx
|
|
11705
|
+
import React123, { useState as useState27 } from "react";
|
|
11688
11706
|
var HOME_TOKEN_BALANCE_DISPLAY_ROW_HEIGHT = 52;
|
|
11689
11707
|
var ASSET_ICON_SIZE2 = "24";
|
|
11690
11708
|
var TEXT_SIZE = "13";
|
|
@@ -12564,10 +12582,10 @@ import { getRiskAssessmentForAddress } from "@funkit/api-base";
|
|
|
12564
12582
|
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
12565
12583
|
var BLOCKED_RISK_LEVELS = ["Severe", "High"];
|
|
12566
12584
|
var hasRisk = async (apiKey, walletAddress, customRecipient) => {
|
|
12567
|
-
const getUserWalletRisk = getRiskAssessmentForAddress({
|
|
12585
|
+
const getUserWalletRisk = walletAddress ? getRiskAssessmentForAddress({
|
|
12568
12586
|
address: walletAddress,
|
|
12569
12587
|
apiKey
|
|
12570
|
-
}).then((assessment) => assessment?.risk);
|
|
12588
|
+
}).then((assessment) => assessment?.risk) : null;
|
|
12571
12589
|
const getRecipientWalletRisk = customRecipient ? getRiskAssessmentForAddress({
|
|
12572
12590
|
address: customRecipient,
|
|
12573
12591
|
apiKey
|
|
@@ -12576,8 +12594,16 @@ var hasRisk = async (apiKey, walletAddress, customRecipient) => {
|
|
|
12576
12594
|
getUserWalletRisk,
|
|
12577
12595
|
getRecipientWalletRisk
|
|
12578
12596
|
]);
|
|
12579
|
-
|
|
12580
|
-
|
|
12597
|
+
const isCheckoutRisky = addressRisks.some(
|
|
12598
|
+
(risk) => BLOCKED_RISK_LEVELS.includes(risk || "")
|
|
12599
|
+
);
|
|
12600
|
+
logger.log("riskAssessment_isCheckoutRisky", {
|
|
12601
|
+
isCheckoutRisky,
|
|
12602
|
+
addressRisks,
|
|
12603
|
+
walletAddress,
|
|
12604
|
+
customRecipient
|
|
12605
|
+
});
|
|
12606
|
+
return isCheckoutRisky;
|
|
12581
12607
|
};
|
|
12582
12608
|
var useIsCheckoutRisky = (checkoutItem) => {
|
|
12583
12609
|
const { walletAddress } = useGeneralWallet();
|
|
@@ -12868,7 +12894,7 @@ function CheckoutComplete({ modalState, onClose }) {
|
|
|
12868
12894
|
|
|
12869
12895
|
// src/modals/CheckoutModal/ConfirmationStep.tsx
|
|
12870
12896
|
import { ClientError as ClientError3, meshPreviewTransfer as meshPreviewTransfer2 } from "@funkit/api-base";
|
|
12871
|
-
import React182, { useCallback as
|
|
12897
|
+
import React182, { useCallback as useCallback33, useEffect as useEffect35, useMemo as useMemo33, useState as useState49 } from "react";
|
|
12872
12898
|
import { createPortal as createPortal9 } from "react-dom";
|
|
12873
12899
|
import { isAddress as isAddress3 } from "viem";
|
|
12874
12900
|
|
|
@@ -14324,7 +14350,7 @@ function FunPaymentMethods({
|
|
|
14324
14350
|
const totalUsableWalletAssetsUsd = Object.values(
|
|
14325
14351
|
usableWalletAssets ?? {}
|
|
14326
14352
|
).reduce((total, asset) => total + (asset.totalUsdValue || 0), 0);
|
|
14327
|
-
const isEmptyWallet = totalUsableWalletAssetsUsd <
|
|
14353
|
+
const isEmptyWallet = totalUsableWalletAssetsUsd < ASSETS_LOW_VALUE_THRESHOLD;
|
|
14328
14354
|
const maxUsdUsableAsset = useMemo21(() => {
|
|
14329
14355
|
if (!usableWalletAssets) {
|
|
14330
14356
|
return null;
|
|
@@ -14377,6 +14403,9 @@ function FunPaymentMethods({
|
|
|
14377
14403
|
if (selectablePaymentMethods.includes("balance" /* ACCOUNT_BALANCE */) && hasSufficientBalance2) {
|
|
14378
14404
|
return "balance" /* ACCOUNT_BALANCE */;
|
|
14379
14405
|
}
|
|
14406
|
+
if (selectablePaymentMethods.includes("token_transfer" /* TOKEN_TRANSFER */)) {
|
|
14407
|
+
return "token_transfer" /* TOKEN_TRANSFER */;
|
|
14408
|
+
}
|
|
14380
14409
|
if (selectablePaymentMethods.includes("card" /* CARD */)) {
|
|
14381
14410
|
return "card" /* CARD */;
|
|
14382
14411
|
}
|
|
@@ -14408,7 +14437,7 @@ function FunPaymentMethods({
|
|
|
14408
14437
|
const { textCustomizations } = useFunkitConfig();
|
|
14409
14438
|
const onClickContinue = useCallback20(async () => {
|
|
14410
14439
|
setIsContinuing(true);
|
|
14411
|
-
const executeContinue =
|
|
14440
|
+
const executeContinue = () => {
|
|
14412
14441
|
if (canContinue && selectedOption === "card" /* CARD */ && apiKey === POLYMARKET_API_KEY) {
|
|
14413
14442
|
onPolymarketCardSwitchWrapper();
|
|
14414
14443
|
return;
|
|
@@ -14446,7 +14475,7 @@ function FunPaymentMethods({
|
|
|
14446
14475
|
}
|
|
14447
14476
|
};
|
|
14448
14477
|
try {
|
|
14449
|
-
|
|
14478
|
+
executeContinue();
|
|
14450
14479
|
} finally {
|
|
14451
14480
|
setIsContinuing(false);
|
|
14452
14481
|
}
|
|
@@ -14785,7 +14814,7 @@ function CheckoutPrimaryInfo({
|
|
|
14785
14814
|
}
|
|
14786
14815
|
|
|
14787
14816
|
// src/modals/CheckoutModal/stepTransition.ts
|
|
14788
|
-
import { useCallback as
|
|
14817
|
+
import { useCallback as useCallback31, useRef as useRef15, useState as useState48 } from "react";
|
|
14789
14818
|
|
|
14790
14819
|
// src/hooks/useCheckoutQuoteNotification.ts
|
|
14791
14820
|
import { useMemo as useMemo22 } from "react";
|
|
@@ -15827,6 +15856,7 @@ function InputAmountLoaded({
|
|
|
15827
15856
|
inputProps: {
|
|
15828
15857
|
type: isInputInUsd ? "text" : "number",
|
|
15829
15858
|
autoFocus: true,
|
|
15859
|
+
disabled: isQuoting,
|
|
15830
15860
|
// get ios to use numpad key with period
|
|
15831
15861
|
inputMode: "decimal"
|
|
15832
15862
|
},
|
|
@@ -15855,6 +15885,7 @@ function InputAmountLoaded({
|
|
|
15855
15885
|
FunIconButton,
|
|
15856
15886
|
{
|
|
15857
15887
|
icon: /* @__PURE__ */ React154.createElement(SwitchIcon, null),
|
|
15888
|
+
isDisabled: isQuoting,
|
|
15858
15889
|
paddingY: "1",
|
|
15859
15890
|
paddingX: "6",
|
|
15860
15891
|
color: { base: "actionColor", hover: "actionColorHover" },
|
|
@@ -15869,6 +15900,7 @@ function InputAmountLoaded({
|
|
|
15869
15900
|
!!usdAvailableAmount && USD_AMOUNT_OPTIONS_PCT.map((percent) => /* @__PURE__ */ React154.createElement(
|
|
15870
15901
|
FunIconButton,
|
|
15871
15902
|
{
|
|
15903
|
+
isDisabled: isQuoting,
|
|
15872
15904
|
fontSize: "14",
|
|
15873
15905
|
fontWeight: "medium",
|
|
15874
15906
|
icon: null,
|
|
@@ -16360,11 +16392,6 @@ function loadingAccountNext(state, payload) {
|
|
|
16360
16392
|
step: "select_asset" /* SELECT_ASSET */,
|
|
16361
16393
|
paymentMethodInfo: payload.paymentMethodInfo
|
|
16362
16394
|
};
|
|
16363
|
-
case "token_transfer" /* TOKEN_TRANSFER */:
|
|
16364
|
-
return {
|
|
16365
|
-
...state,
|
|
16366
|
-
step: "transfer_token" /* TRANSFER_TOKEN */
|
|
16367
|
-
};
|
|
16368
16395
|
default:
|
|
16369
16396
|
return {
|
|
16370
16397
|
...state,
|
|
@@ -16386,7 +16413,6 @@ function LoadingAccount({
|
|
|
16386
16413
|
onNext
|
|
16387
16414
|
}) {
|
|
16388
16415
|
const { apiKey } = useFunkitConfig();
|
|
16389
|
-
const { isLoading: isLoadingFlags, flags } = useFlags();
|
|
16390
16416
|
const { walletAddress } = useGeneralWallet();
|
|
16391
16417
|
const { targetChainId } = modalState;
|
|
16392
16418
|
const { isLoading: isFetchingAssets, totalWalletAssetsUsd } = useWalletAssets(
|
|
@@ -16399,9 +16425,7 @@ function LoadingAccount({
|
|
|
16399
16425
|
connection
|
|
16400
16426
|
);
|
|
16401
16427
|
const { updateSelectedPaymentMethodInfo } = useCheckoutContext();
|
|
16402
|
-
const isTokenTransferEnabled = flags?.["enable_token_transfer" /* EnableTokenTransfer */];
|
|
16403
16428
|
useEffect30(() => {
|
|
16404
|
-
if (isLoadingFlags) return;
|
|
16405
16429
|
if (totalWalletAssetsUsd >= USABLE_AMOUNT) {
|
|
16406
16430
|
const paymentMethodInfo = createPaymentMethodInfo({
|
|
16407
16431
|
paymentMethod: "balance" /* ACCOUNT_BALANCE */,
|
|
@@ -16413,7 +16437,9 @@ function LoadingAccount({
|
|
|
16413
16437
|
usablePaymentMethod: "balance" /* ACCOUNT_BALANCE */,
|
|
16414
16438
|
paymentMethodInfo
|
|
16415
16439
|
});
|
|
16416
|
-
|
|
16440
|
+
return;
|
|
16441
|
+
}
|
|
16442
|
+
if (connection && hasNonZeroDollarToken(data)) {
|
|
16417
16443
|
const paymentMethodInfo = createPaymentMethodInfo({
|
|
16418
16444
|
paymentMethod: "brokerage" /* BROKERAGE */,
|
|
16419
16445
|
brokerage: connection.brokerage,
|
|
@@ -16425,27 +16451,19 @@ function LoadingAccount({
|
|
|
16425
16451
|
usablePaymentMethod: "brokerage" /* BROKERAGE */,
|
|
16426
16452
|
paymentMethodInfo
|
|
16427
16453
|
});
|
|
16428
|
-
|
|
16429
|
-
|
|
16430
|
-
|
|
16431
|
-
|
|
16432
|
-
updateSelectedPaymentMethodInfo(paymentMethodInfo);
|
|
16433
|
-
onNext({
|
|
16434
|
-
step: "loading_account" /* LOADING_ACCOUNT */,
|
|
16435
|
-
usablePaymentMethod: "token_transfer" /* TOKEN_TRANSFER */
|
|
16436
|
-
});
|
|
16437
|
-
} else if (!isLoadingMesh && !isFetchingAssets) {
|
|
16438
|
-
onNext({
|
|
16439
|
-
step: "loading_account" /* LOADING_ACCOUNT */,
|
|
16440
|
-
usablePaymentMethod: null
|
|
16441
|
-
});
|
|
16454
|
+
return;
|
|
16455
|
+
}
|
|
16456
|
+
if (isLoadingMesh || isFetchingAssets) {
|
|
16457
|
+
return;
|
|
16442
16458
|
}
|
|
16459
|
+
onNext({
|
|
16460
|
+
step: "loading_account" /* LOADING_ACCOUNT */,
|
|
16461
|
+
usablePaymentMethod: null
|
|
16462
|
+
});
|
|
16443
16463
|
}, [
|
|
16444
16464
|
walletAddress,
|
|
16445
16465
|
isLoadingMesh,
|
|
16446
|
-
isLoadingFlags,
|
|
16447
16466
|
apiKey,
|
|
16448
|
-
isTokenTransferEnabled,
|
|
16449
16467
|
isFetchingAssets,
|
|
16450
16468
|
data,
|
|
16451
16469
|
onNext,
|
|
@@ -16643,6 +16661,7 @@ function MeshVerification({
|
|
|
16643
16661
|
setExecutionError(transferResponse.errorMessage || "");
|
|
16644
16662
|
break;
|
|
16645
16663
|
case MeshExecuteTransferStatus.emailConfirmationRequired:
|
|
16664
|
+
case MeshExecuteTransferStatus.emailConfirmationApprovalRequired:
|
|
16646
16665
|
setScreen(3 /* EMAIL_CONFIRMATION */);
|
|
16647
16666
|
break;
|
|
16648
16667
|
case MeshExecuteTransferStatus.deviceConfirmationRequired:
|
|
@@ -16686,6 +16705,7 @@ function MeshVerification({
|
|
|
16686
16705
|
case MeshExecuteTransferStatus.deviceConfirmationRequired:
|
|
16687
16706
|
return "Device confirmation required";
|
|
16688
16707
|
case MeshExecuteTransferStatus.emailConfirmationRequired:
|
|
16708
|
+
case MeshExecuteTransferStatus.emailConfirmationApprovalRequired:
|
|
16689
16709
|
return "Email confirmation required";
|
|
16690
16710
|
case MeshExecuteTransferStatus.addressWhitelistRequired:
|
|
16691
16711
|
return "Manual whitelist required";
|
|
@@ -16702,6 +16722,7 @@ function MeshVerification({
|
|
|
16702
16722
|
case MeshExecuteTransferStatus.deviceConfirmationRequired:
|
|
16703
16723
|
return `Open the ${exchange} app and verify your transaction. After you've approved this transaction, click \u201CContinue.\u201D`;
|
|
16704
16724
|
case MeshExecuteTransferStatus.emailConfirmationRequired:
|
|
16725
|
+
case MeshExecuteTransferStatus.emailConfirmationApprovalRequired:
|
|
16705
16726
|
return `Click the link sent to your email to confirm this transaction. Click \u201CContinue\u201D after you've approved this transaction.`;
|
|
16706
16727
|
case MeshExecuteTransferStatus.addressWhitelistRequired:
|
|
16707
16728
|
return `Go to ${exchange} to manually whitelist your address. After you've whitelisted this address you can retry your transaction.`;
|
|
@@ -17854,7 +17875,7 @@ function useRemainingMeshExchangeConnections(selected) {
|
|
|
17854
17875
|
}
|
|
17855
17876
|
|
|
17856
17877
|
// src/modals/CheckoutModal/TransferToken.tsx
|
|
17857
|
-
import React181, { useState as useState47 } from "react";
|
|
17878
|
+
import React181, { useCallback as useCallback30, useState as useState47 } from "react";
|
|
17858
17879
|
import { mainnet as mainnet6, polygon as polygon3 } from "viem/chains";
|
|
17859
17880
|
|
|
17860
17881
|
// src/components/Dropdown/TokenDropdown.tsx
|
|
@@ -18295,9 +18316,9 @@ function CircleWithText({ text }) {
|
|
|
18295
18316
|
/* @__PURE__ */ React181.createElement(Text, { size: "13", color: "accentColor", weight: "bold" }, text)
|
|
18296
18317
|
);
|
|
18297
18318
|
}
|
|
18298
|
-
|
|
18319
|
+
var TRANSFER_TOKEN_LOG_PREFIX = "transferToken";
|
|
18320
|
+
function TransferToken({ onBack }) {
|
|
18299
18321
|
const filteredAssets = useEnabledTokenTransferChainTokens();
|
|
18300
|
-
const { textCustomizations } = useFunkitConfig();
|
|
18301
18322
|
const [selectedChainId, setSelectedChainId] = useState47(polygon3.id);
|
|
18302
18323
|
const selectedChainInfo = chainMetadataById[selectedChainId];
|
|
18303
18324
|
const [selectedToken, setSelectedToken] = useState47(
|
|
@@ -18305,6 +18326,18 @@ function TransferToken({ onNext }) {
|
|
|
18305
18326
|
);
|
|
18306
18327
|
const { depositAddress, minTransferUsd, showOriginalRecipient } = useTokenTransfer(selectedChainId, selectedToken);
|
|
18307
18328
|
const isLoadingDepositAddress = depositAddress === void 0;
|
|
18329
|
+
const onHelp = useCallback30(() => {
|
|
18330
|
+
logger.log(`${TRANSFER_TOKEN_LOG_PREFIX}_getHelpClicked`, {
|
|
18331
|
+
selectedChainId,
|
|
18332
|
+
selectedToken,
|
|
18333
|
+
depositAddress
|
|
18334
|
+
});
|
|
18335
|
+
window.open(
|
|
18336
|
+
"https://intercom.help/funxyz/en/articles/10003876-direct-deposit-guide-faqs",
|
|
18337
|
+
"_blank",
|
|
18338
|
+
"noopener,noreferrer"
|
|
18339
|
+
);
|
|
18340
|
+
}, [depositAddress, selectedChainId, selectedToken]);
|
|
18308
18341
|
return /* @__PURE__ */ React181.createElement(Box, { id: "token-transfer-page" }, /* @__PURE__ */ React181.createElement(
|
|
18309
18342
|
Box,
|
|
18310
18343
|
{
|
|
@@ -18314,16 +18347,6 @@ function TransferToken({ onNext }) {
|
|
|
18314
18347
|
justifyContent: "center",
|
|
18315
18348
|
gap: "14"
|
|
18316
18349
|
},
|
|
18317
|
-
/* @__PURE__ */ React181.createElement(Box, { display: "flex", flexDirection: "column", width: "full" }, /* @__PURE__ */ React181.createElement(
|
|
18318
|
-
FunPaymentMethodItem,
|
|
18319
|
-
{
|
|
18320
|
-
isSource: true,
|
|
18321
|
-
keyText: textCustomizations.transferTokens,
|
|
18322
|
-
disclaimerText: "No limit",
|
|
18323
|
-
keyIcon: /* @__PURE__ */ React181.createElement(LightningBoltIcon, null),
|
|
18324
|
-
onClick: () => onNext({ step: "transfer_token" /* TRANSFER_TOKEN */ })
|
|
18325
|
-
}
|
|
18326
|
-
)),
|
|
18327
18350
|
/* @__PURE__ */ React181.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center" }, isLoadingDepositAddress ? /* @__PURE__ */ React181.createElement(
|
|
18328
18351
|
Box,
|
|
18329
18352
|
{
|
|
@@ -18390,7 +18413,15 @@ function TransferToken({ onNext }) {
|
|
|
18390
18413
|
ChainDropdown_default,
|
|
18391
18414
|
{
|
|
18392
18415
|
assets: filteredAssets,
|
|
18393
|
-
onChainSelected: (chainId) =>
|
|
18416
|
+
onChainSelected: (chainId) => {
|
|
18417
|
+
logger.log(`${TRANSFER_TOKEN_LOG_PREFIX}_changeChain`, {
|
|
18418
|
+
previousChainId: selectedChainId,
|
|
18419
|
+
newChainId: chainId,
|
|
18420
|
+
selectedToken,
|
|
18421
|
+
depositAddress
|
|
18422
|
+
});
|
|
18423
|
+
setSelectedChainId(chainId);
|
|
18424
|
+
}
|
|
18394
18425
|
}
|
|
18395
18426
|
)
|
|
18396
18427
|
),
|
|
@@ -18409,7 +18440,15 @@ function TransferToken({ onNext }) {
|
|
|
18409
18440
|
{
|
|
18410
18441
|
selectedChainId,
|
|
18411
18442
|
assets: filteredAssets,
|
|
18412
|
-
onTokenSelected: (token) =>
|
|
18443
|
+
onTokenSelected: (token) => {
|
|
18444
|
+
logger.log(`${TRANSFER_TOKEN_LOG_PREFIX}_changeToken`, {
|
|
18445
|
+
previousToken: selectedToken,
|
|
18446
|
+
newToken: token,
|
|
18447
|
+
selectedChainId,
|
|
18448
|
+
depositAddress
|
|
18449
|
+
});
|
|
18450
|
+
setSelectedToken(token);
|
|
18451
|
+
}
|
|
18413
18452
|
}
|
|
18414
18453
|
)
|
|
18415
18454
|
),
|
|
@@ -18426,7 +18465,13 @@ function TransferToken({ onNext }) {
|
|
|
18426
18465
|
/* @__PURE__ */ React181.createElement(Text, { size: "12", color: "primaryText", weight: "medium" }, minTransferUsd === 0 ? "No minimum" : formatCurrencyAndStringify(minTransferUsd))
|
|
18427
18466
|
)
|
|
18428
18467
|
),
|
|
18429
|
-
showOriginalRecipient ? null : /* @__PURE__ */ React181.createElement(Box, { display: "flex", flexDirection: "column", gap: "14" }, /* @__PURE__ */ React181.createElement(Text, { size: "12", color: "secondaryText", weight: "medium" }, "Transfer ", selectedToken, " (", selectedChainInfo.name, ") to the deposit address above. The equivalent USD value (minus fees) will be automatically deposited into your account within ~60 seconds."), /* @__PURE__ */ React181.createElement(
|
|
18468
|
+
showOriginalRecipient ? null : /* @__PURE__ */ React181.createElement(Box, { display: "flex", flexDirection: "column", gap: "14", width: "full" }, /* @__PURE__ */ React181.createElement(Text, { size: "12", color: "secondaryText", weight: "medium" }, "Transfer ", selectedToken, " (", selectedChainInfo.name, ") to the deposit address above. The equivalent USD value (minus fees) will be automatically deposited into your account within ~60 seconds."), /* @__PURE__ */ React181.createElement(
|
|
18469
|
+
FunAlert,
|
|
18470
|
+
{
|
|
18471
|
+
icon: /* @__PURE__ */ React181.createElement(FunInfoIcon, null),
|
|
18472
|
+
description: /* @__PURE__ */ React181.createElement(Box, { display: "flex" }, /* @__PURE__ */ React181.createElement(Text, { size: "10", color: "secondaryText" }, "Experiencing problems?"), /* @__PURE__ */ React181.createElement(FunLinkButton, { text: "Get help.", onClick: onHelp }))
|
|
18473
|
+
}
|
|
18474
|
+
), /* @__PURE__ */ React181.createElement(
|
|
18430
18475
|
Text,
|
|
18431
18476
|
{
|
|
18432
18477
|
size: "10",
|
|
@@ -18515,7 +18560,7 @@ function initialState(checkoutItem) {
|
|
|
18515
18560
|
function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
18516
18561
|
const [modalState, setModalState] = useState48(() => initialState(checkoutItem));
|
|
18517
18562
|
const { clearCheckoutQuoteMessages } = useCheckoutQuoteNotification();
|
|
18518
|
-
const onCloseWrapper =
|
|
18563
|
+
const onCloseWrapper = useCallback31(() => {
|
|
18519
18564
|
checkoutItem.initSettings.onClose?.();
|
|
18520
18565
|
logger.log("closingCheckoutModal", {
|
|
18521
18566
|
checkoutStep: modalState.step,
|
|
@@ -18526,7 +18571,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
18526
18571
|
}, [checkoutItem, modalState.step, onClose]);
|
|
18527
18572
|
const { animateOut, navigateTo } = useAnimatedNavigation(setModalState);
|
|
18528
18573
|
const stateHistory = useRef15([]);
|
|
18529
|
-
const onNext =
|
|
18574
|
+
const onNext = useCallback31(
|
|
18530
18575
|
(payload) => {
|
|
18531
18576
|
clearCheckoutQuoteMessages();
|
|
18532
18577
|
stateHistory.current.push(modalState);
|
|
@@ -18535,7 +18580,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
18535
18580
|
},
|
|
18536
18581
|
[modalState, navigateTo, clearCheckoutQuoteMessages]
|
|
18537
18582
|
);
|
|
18538
|
-
const onBack =
|
|
18583
|
+
const onBack = useCallback31(() => {
|
|
18539
18584
|
clearCheckoutQuoteMessages();
|
|
18540
18585
|
const prevState = stateHistory.current.pop();
|
|
18541
18586
|
if (prevState) {
|
|
@@ -18624,7 +18669,7 @@ function useTitleConfig(checkoutItem, state) {
|
|
|
18624
18669
|
};
|
|
18625
18670
|
case "transfer_token" /* TRANSFER_TOKEN */:
|
|
18626
18671
|
return {
|
|
18627
|
-
hasBack:
|
|
18672
|
+
hasBack: true,
|
|
18628
18673
|
title: textCustomizations.transferTokens,
|
|
18629
18674
|
showFullHeight: false
|
|
18630
18675
|
};
|
|
@@ -18636,7 +18681,7 @@ function useTitleConfig(checkoutItem, state) {
|
|
|
18636
18681
|
// src/modals/CheckoutModal/useAccountBalancePostCheckout.ts
|
|
18637
18682
|
import { getPaymasterDataForCheckoutSponsoredTransfer } from "@funkit/api-base";
|
|
18638
18683
|
import { ERC20_ABI, USDT_ABI } from "@funkit/core";
|
|
18639
|
-
import { useCallback as
|
|
18684
|
+
import { useCallback as useCallback32 } from "react";
|
|
18640
18685
|
import { useAccount as useAccount8, useSendTransaction, useWriteContract } from "wagmi";
|
|
18641
18686
|
|
|
18642
18687
|
// src/utils/isMainnetUsdt.ts
|
|
@@ -18653,7 +18698,7 @@ function useWeb3AccountBalancePostCheckout(setPostCheckoutStepMessage) {
|
|
|
18653
18698
|
const { writeContractAsync } = useWriteContract();
|
|
18654
18699
|
const { sendTransactionAsync } = useSendTransaction();
|
|
18655
18700
|
const { cancelCheckout, checkoutItem } = useCheckoutContext();
|
|
18656
|
-
const handleWeb3AccountBalancePostCheckout =
|
|
18701
|
+
const handleWeb3AccountBalancePostCheckout = useCallback32(
|
|
18657
18702
|
async (depositAddress) => {
|
|
18658
18703
|
if (!checkoutItem?.latestQuote?.baseQuote.estTotalFromAmountBaseUnit) {
|
|
18659
18704
|
return;
|
|
@@ -18748,7 +18793,7 @@ function useWeb3AccountBalancePostCheckout(setPostCheckoutStepMessage) {
|
|
|
18748
18793
|
function useWeb2AccountBalancePostCheckout(apiKey) {
|
|
18749
18794
|
const { checkoutItem } = useCheckoutContext();
|
|
18750
18795
|
const { generateCheckoutTransferOpItems } = useCheckoutAccountBalanceTransfer();
|
|
18751
|
-
const handleWeb2AccountBalancePostCheckout =
|
|
18796
|
+
const handleWeb2AccountBalancePostCheckout = useCallback32(
|
|
18752
18797
|
async (depositAddress) => {
|
|
18753
18798
|
const { rFunWallet, rFunWalletAuth, transferOp, envConfig } = await generateCheckoutTransferOpItems(
|
|
18754
18799
|
depositAddress,
|
|
@@ -18796,7 +18841,7 @@ function useAccountBalancePostCheckout(setPostCheckoutStepMessage, apiKey) {
|
|
|
18796
18841
|
const { isWeb2Login, isWeb3Login } = useGeneralWallet();
|
|
18797
18842
|
const handleWeb2AccountBalancePostCheckout = useWeb2AccountBalancePostCheckout(apiKey);
|
|
18798
18843
|
const handleWeb3AccountBalancePostCheckout = useWeb3AccountBalancePostCheckout(setPostCheckoutStepMessage);
|
|
18799
|
-
const handleAccountBalancePostCheckout =
|
|
18844
|
+
const handleAccountBalancePostCheckout = useCallback32(
|
|
18800
18845
|
async (depositAddress) => {
|
|
18801
18846
|
if (isWeb2Login) {
|
|
18802
18847
|
await handleWeb2AccountBalancePostCheckout(depositAddress);
|
|
@@ -18900,7 +18945,7 @@ function ConfirmationStep({
|
|
|
18900
18945
|
const [postCheckoutError, setPostCheckoutError] = useState49();
|
|
18901
18946
|
const hasPostCheckoutError = postCheckoutError !== void 0;
|
|
18902
18947
|
const isContinuing = isConfirming || isPostCheckoutLoading;
|
|
18903
|
-
const handleMeshPostCheckout =
|
|
18948
|
+
const handleMeshPostCheckout = useCallback33(
|
|
18904
18949
|
async (depositAddress) => {
|
|
18905
18950
|
if (!funkitConfig.apiKey) {
|
|
18906
18951
|
throw new Error("Invalid funkit apiKey");
|
|
@@ -19014,11 +19059,11 @@ function ConfirmationStep({
|
|
|
19014
19059
|
setTimeout(() => setPostCheckoutError(void 0), timeMs);
|
|
19015
19060
|
}
|
|
19016
19061
|
};
|
|
19017
|
-
const restartCountdown =
|
|
19062
|
+
const restartCountdown = useCallback33(() => {
|
|
19018
19063
|
setCountdownKey((key) => key + 1);
|
|
19019
19064
|
setIsBeforeRegeneratingQuote(false);
|
|
19020
19065
|
}, []);
|
|
19021
|
-
const refreshQuote =
|
|
19066
|
+
const refreshQuote = useCallback33(async () => {
|
|
19022
19067
|
singletonCheckoutAbort.abort("Abort checkout data pre-loading");
|
|
19023
19068
|
singletonCheckoutAbort.setAbortController(new AbortController());
|
|
19024
19069
|
try {
|
|
@@ -19039,7 +19084,7 @@ function ConfirmationStep({
|
|
|
19039
19084
|
restartCountdown,
|
|
19040
19085
|
setCheckoutQuote
|
|
19041
19086
|
]);
|
|
19042
|
-
const onClickConfirm =
|
|
19087
|
+
const onClickConfirm = useCallback33(async () => {
|
|
19043
19088
|
if (!checkoutItem) {
|
|
19044
19089
|
return;
|
|
19045
19090
|
}
|
|
@@ -19426,16 +19471,16 @@ function FunCheckoutHistoryModal({
|
|
|
19426
19471
|
function useModalStateValue() {
|
|
19427
19472
|
const [isModalOpen, setModalOpen] = useState51(false);
|
|
19428
19473
|
return {
|
|
19429
|
-
closeModal:
|
|
19474
|
+
closeModal: useCallback34(() => setModalOpen(false), []),
|
|
19430
19475
|
isModalOpen,
|
|
19431
|
-
openModal:
|
|
19476
|
+
openModal: useCallback34(() => setModalOpen(true), [])
|
|
19432
19477
|
};
|
|
19433
19478
|
}
|
|
19434
19479
|
function useModalStateValueWithProp() {
|
|
19435
19480
|
const [isModalOpen, setModalOpen] = useState51(false);
|
|
19436
19481
|
const [prop, setProp] = useState51(null);
|
|
19437
19482
|
return {
|
|
19438
|
-
closeModal:
|
|
19483
|
+
closeModal: useCallback34(() => {
|
|
19439
19484
|
setTimeout(() => {
|
|
19440
19485
|
setProp(null);
|
|
19441
19486
|
}, DialogAnimationTimeOut);
|
|
@@ -19443,7 +19488,7 @@ function useModalStateValueWithProp() {
|
|
|
19443
19488
|
}, []),
|
|
19444
19489
|
isModalOpen,
|
|
19445
19490
|
prop,
|
|
19446
|
-
openModal:
|
|
19491
|
+
openModal: useCallback34((prop2) => {
|
|
19447
19492
|
if (prop2 != null) setProp(prop2);
|
|
19448
19493
|
setModalOpen(true);
|
|
19449
19494
|
}, [])
|
|
@@ -19929,7 +19974,7 @@ var FunkitWeb2Provider = ({
|
|
|
19929
19974
|
const [isLoggingIn, setIsLoggingIn] = useState52(false);
|
|
19930
19975
|
const [loginErrorMessage, setLoginErrorMessage] = useState52("");
|
|
19931
19976
|
const [loggedInUser, setLoggedInUser] = useState52(null);
|
|
19932
|
-
const setLoginMethodAndCache =
|
|
19977
|
+
const setLoginMethodAndCache = useCallback35(
|
|
19933
19978
|
(method) => {
|
|
19934
19979
|
try {
|
|
19935
19980
|
setLoginMethod(method);
|
|
@@ -19953,7 +19998,7 @@ var FunkitWeb2Provider = ({
|
|
|
19953
19998
|
setPrivyIframeUrl(newPrivy.embeddedWallet.getURL());
|
|
19954
19999
|
setPrivy(newPrivy);
|
|
19955
20000
|
}, [chains]);
|
|
19956
|
-
const handleIframeMessage =
|
|
20001
|
+
const handleIframeMessage = useCallback35(
|
|
19957
20002
|
(e) => {
|
|
19958
20003
|
if (e.origin === PRIVY_AUTH_URL && privy) {
|
|
19959
20004
|
const iframeHandler = privy.embeddedWallet.getMessageHandler();
|
|
@@ -19962,7 +20007,7 @@ var FunkitWeb2Provider = ({
|
|
|
19962
20007
|
},
|
|
19963
20008
|
[privy]
|
|
19964
20009
|
);
|
|
19965
|
-
const handleFunkitWeb2Logout =
|
|
20010
|
+
const handleFunkitWeb2Logout = useCallback35(async () => {
|
|
19966
20011
|
if (privy) {
|
|
19967
20012
|
logger.log("handleFunkitWeb2Logout_disconnecting_connectors", {
|
|
19968
20013
|
numConnectors: connectors.length
|
|
@@ -19975,7 +20020,7 @@ var FunkitWeb2Provider = ({
|
|
|
19975
20020
|
setLoginMethodAndCache(null);
|
|
19976
20021
|
}
|
|
19977
20022
|
}, [connectors, disconnectAsync, privy, setLoginMethodAndCache]);
|
|
19978
|
-
const handleFreshPrivyLogin =
|
|
20023
|
+
const handleFreshPrivyLogin = useCallback35(
|
|
19979
20024
|
async ({
|
|
19980
20025
|
firstLoginCode,
|
|
19981
20026
|
secondLoginCode,
|
|
@@ -20021,7 +20066,7 @@ var FunkitWeb2Provider = ({
|
|
|
20021
20066
|
},
|
|
20022
20067
|
[handleFunkitWeb2Logout, privy]
|
|
20023
20068
|
);
|
|
20024
|
-
const getPrivyUserEmbeddedWallet =
|
|
20069
|
+
const getPrivyUserEmbeddedWallet = useCallback35(
|
|
20025
20070
|
async (inputPrivyUser) => {
|
|
20026
20071
|
try {
|
|
20027
20072
|
if (!privy || !inputPrivyUser)
|
|
@@ -20040,7 +20085,7 @@ var FunkitWeb2Provider = ({
|
|
|
20040
20085
|
},
|
|
20041
20086
|
[privy]
|
|
20042
20087
|
);
|
|
20043
|
-
const getExistingPrivySession =
|
|
20088
|
+
const getExistingPrivySession = useCallback35(async () => {
|
|
20044
20089
|
try {
|
|
20045
20090
|
if (!privy) throw new Error(ERROR_MESSAGES.PRIVY_NOT_INITIALIZED);
|
|
20046
20091
|
const existingSession = await privy.user.get();
|
|
@@ -20049,7 +20094,7 @@ var FunkitWeb2Provider = ({
|
|
|
20049
20094
|
return null;
|
|
20050
20095
|
}
|
|
20051
20096
|
}, [privy]);
|
|
20052
|
-
const handleFunkitWeb2Login =
|
|
20097
|
+
const handleFunkitWeb2Login = useCallback35(
|
|
20053
20098
|
async ({
|
|
20054
20099
|
chainId,
|
|
20055
20100
|
firstLoginCode,
|
|
@@ -20122,9 +20167,9 @@ var FunkitWeb2Provider = ({
|
|
|
20122
20167
|
wallets
|
|
20123
20168
|
]
|
|
20124
20169
|
);
|
|
20125
|
-
const clearLoginError =
|
|
20170
|
+
const clearLoginError = useCallback35(() => setLoginErrorMessage(""), []);
|
|
20126
20171
|
const initChainId = useInitialChainId();
|
|
20127
|
-
const handleAutoLoginFlows =
|
|
20172
|
+
const handleAutoLoginFlows = useCallback35(async () => {
|
|
20128
20173
|
if (isNotNullish(loginMethod) && isNotNullish(initChainId)) {
|
|
20129
20174
|
const queryParams = new URLSearchParams(window.location.search);
|
|
20130
20175
|
const oauthCode = queryParams.get(PRIVY_OAUTH_CODE_URL_PARAM);
|
|
@@ -20166,7 +20211,7 @@ var FunkitWeb2Provider = ({
|
|
|
20166
20211
|
initChainId
|
|
20167
20212
|
// Do not include `handleAutoLoginFlows`,
|
|
20168
20213
|
]);
|
|
20169
|
-
const handleOauthRedirect =
|
|
20214
|
+
const handleOauthRedirect = useCallback35(
|
|
20170
20215
|
async (authProvider) => {
|
|
20171
20216
|
if (!privy) throw new Error(ERROR_MESSAGES.PRIVY_NOT_INITIALIZED);
|
|
20172
20217
|
try {
|
|
@@ -20190,7 +20235,7 @@ var FunkitWeb2Provider = ({
|
|
|
20190
20235
|
[privy, setLoginMethodAndCache]
|
|
20191
20236
|
);
|
|
20192
20237
|
const [isSendingOtpEmail, setIsSendingOtpEmail] = useState52(false);
|
|
20193
|
-
const handleSendOtpEmail =
|
|
20238
|
+
const handleSendOtpEmail = useCallback35(
|
|
20194
20239
|
async (emailAddress) => {
|
|
20195
20240
|
try {
|
|
20196
20241
|
if (!privy) throw new Error(ERROR_MESSAGES.PRIVY_NOT_INITIALIZED);
|
|
@@ -20217,7 +20262,7 @@ var FunkitWeb2Provider = ({
|
|
|
20217
20262
|
[privy, setLoginMethodAndCache]
|
|
20218
20263
|
);
|
|
20219
20264
|
const [isGeneratingFcUri, setIsGeneratingFcUri] = useState52(false);
|
|
20220
|
-
const handleGenerateFcUri =
|
|
20265
|
+
const handleGenerateFcUri = useCallback35(async () => {
|
|
20221
20266
|
try {
|
|
20222
20267
|
if (!privy) throw new Error(ERROR_MESSAGES.PRIVY_NOT_INITIALIZED);
|
|
20223
20268
|
setIsGeneratingFcUri(true);
|
|
@@ -20242,7 +20287,7 @@ var FunkitWeb2Provider = ({
|
|
|
20242
20287
|
setIsGeneratingFcUri(false);
|
|
20243
20288
|
}
|
|
20244
20289
|
}, [privy]);
|
|
20245
|
-
const getFcConnectionStatus =
|
|
20290
|
+
const getFcConnectionStatus = useCallback35(
|
|
20246
20291
|
async (channelToken) => {
|
|
20247
20292
|
try {
|
|
20248
20293
|
if (!privy) throw new Error(ERROR_MESSAGES.PRIVY_NOT_INITIALIZED);
|
|
@@ -20376,7 +20421,7 @@ import React190 from "react";
|
|
|
20376
20421
|
import { useAccount as useAccount12, useBalance, useConfig as useConfig6 } from "wagmi";
|
|
20377
20422
|
|
|
20378
20423
|
// src/hooks/useIsMounted.ts
|
|
20379
|
-
import { useCallback as
|
|
20424
|
+
import { useCallback as useCallback36, useEffect as useEffect38, useState as useState54 } from "react";
|
|
20380
20425
|
function useIsMounted() {
|
|
20381
20426
|
const [isMounted, setIsMounted] = useState54(false);
|
|
20382
20427
|
useEffect38(() => {
|
|
@@ -20385,7 +20430,7 @@ function useIsMounted() {
|
|
|
20385
20430
|
setIsMounted(false);
|
|
20386
20431
|
};
|
|
20387
20432
|
}, []);
|
|
20388
|
-
return
|
|
20433
|
+
return useCallback36(() => isMounted, [isMounted]);
|
|
20389
20434
|
}
|
|
20390
20435
|
|
|
20391
20436
|
// src/components/ConnectButton/abbreviateETHBalance.ts
|
|
@@ -21253,16 +21298,16 @@ var defaultAppInfo = {
|
|
|
21253
21298
|
var AppContext = createContext18(defaultAppInfo);
|
|
21254
21299
|
|
|
21255
21300
|
// src/providers/useFingerprint.ts
|
|
21256
|
-
import { useCallback as
|
|
21301
|
+
import { useCallback as useCallback37, useEffect as useEffect40 } from "react";
|
|
21257
21302
|
var storageKey5 = "funkit-connect-version";
|
|
21258
21303
|
function setFunkitConnectVersion({ version }) {
|
|
21259
21304
|
localStorage.setItem(storageKey5, version);
|
|
21260
21305
|
}
|
|
21261
21306
|
function getCurrentSdkVersion() {
|
|
21262
|
-
return "
|
|
21307
|
+
return "3.4.4";
|
|
21263
21308
|
}
|
|
21264
21309
|
function useFingerprint() {
|
|
21265
|
-
const fingerprint =
|
|
21310
|
+
const fingerprint = useCallback37(() => {
|
|
21266
21311
|
setFunkitConnectVersion({ version: getCurrentSdkVersion() });
|
|
21267
21312
|
}, []);
|
|
21268
21313
|
useEffect40(() => {
|
|
@@ -21271,7 +21316,7 @@ function useFingerprint() {
|
|
|
21271
21316
|
}
|
|
21272
21317
|
|
|
21273
21318
|
// src/providers/usePreloadImages.ts
|
|
21274
|
-
import { useCallback as
|
|
21319
|
+
import { useCallback as useCallback38, useEffect as useEffect41 } from "react";
|
|
21275
21320
|
|
|
21276
21321
|
// src/components/Icons/Assets.tsx
|
|
21277
21322
|
import React194 from "react";
|
|
@@ -21287,7 +21332,7 @@ var preloadLoginIcon = () => loadImages(src2);
|
|
|
21287
21332
|
function usePreloadImages() {
|
|
21288
21333
|
const funkitConnectChains = useFunkitConnectChains();
|
|
21289
21334
|
const walletConnectors = useWalletConnectors();
|
|
21290
|
-
const preloadImages =
|
|
21335
|
+
const preloadImages = useCallback38(() => {
|
|
21291
21336
|
loadImages(
|
|
21292
21337
|
...walletConnectors.map((wallet) => wallet.iconUrl),
|
|
21293
21338
|
...funkitConnectChains.map((chain) => chain.iconUrl).filter(isNotNullish)
|
|
@@ -21451,8 +21496,10 @@ export {
|
|
|
21451
21496
|
useCheckoutListenerByCheckoutId,
|
|
21452
21497
|
useCheckoutsListenerByUserId,
|
|
21453
21498
|
useConnectModal,
|
|
21499
|
+
useConnectionStatus,
|
|
21454
21500
|
useFunkitAccount,
|
|
21455
21501
|
useFunkitCheckout,
|
|
21456
21502
|
useFunkitDisconnect,
|
|
21457
|
-
useFunkitSwitchChains
|
|
21503
|
+
useFunkitSwitchChains,
|
|
21504
|
+
useFunkitUserInfo
|
|
21458
21505
|
};
|