@funkit/connect 10.5.0 → 10.6.0
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 +35 -0
- package/dist/clients/{chunk-WRS7AFM2.js → chunk-3LJQTM37.js} +0 -1
- package/dist/clients/{chunk-QHS5N7GP.js → chunk-TG2AACP2.js} +1 -1
- package/dist/clients/internal/nado/withdrawalConfig.js +1 -0
- package/dist/clients/lighter.css +5 -1
- package/dist/clients/lighter.js +1 -2
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.css +5 -1
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +2 -2
- package/dist/clients/polymarket/index.css +5 -1
- package/dist/clients/polymarket/index.js +2 -2
- package/dist/components/BottomLinks/BottomLinks.d.ts +3 -1
- package/dist/consts/meld.d.ts +1 -1
- package/dist/hooks/queries/useSwappedDefaultCurrency.d.ts +3 -3
- package/dist/hooks/queries/useWithdrawFops.d.ts +0 -1
- package/dist/hooks/track/useTrack.d.ts +1 -0
- package/dist/index.css +5 -1
- package/dist/index.js +1311 -1015
- package/dist/modals/CheckoutModal/ConfirmationStep/CheckoutPrimaryInfo.d.ts +1 -2
- package/dist/modals/CheckoutModal/InputAmount/useCheckoutAmountLimits.d.ts +6 -9
- package/dist/modals/WithdrawalModal/LighterWithdrawal.d.ts +34 -17
- package/dist/modals/WithdrawalModal/WithdrawalContent.d.ts +1 -61
- package/dist/modals/WithdrawalModal/withdrawalFormHelpers.d.ts +53 -0
- package/dist/modals/WithdrawalModal/withdrawalHooks.d.ts +38 -0
- package/dist/providers/FunkitConfigContext.d.ts +2 -2
- package/dist/utils/consts.d.ts +1 -1
- package/dist/utils/customer.d.ts +18 -3
- package/dist/utils/withdrawal.d.ts +6 -0
- package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
- package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
- package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
- package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
- package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
- package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
- package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
- package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
- package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
- package/dist/wallets/walletConnectors/index.js +36 -36
- package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
- package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
- package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
- package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
- package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
- package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
- package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
- package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
- package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
- package/package.json +2 -2
- package/dist/wallets/walletConnectors/{chunk-RB3HR4R2.js → chunk-4NV5BYRP.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-YEZM4CK4.js → chunk-AVDUNQUW.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-MIQTHJ6X.js → chunk-GUQM4QSL.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-4T6ZSRJF.js → chunk-IULPZP2Q.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-HNRB7KJU.js → chunk-JPN6TWIT.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-ZNX4EMPB.js → chunk-KCRO2AGO.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-STVVP43G.js → chunk-KI5Y2BBF.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-X6CGV36L.js → chunk-NR2OGDHQ.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-UK7C2JXW.js → chunk-OEEGYENV.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-F5XEEVG6.js → chunk-OX37G4YT.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-RVOY537T.js → chunk-SWFF3TWJ.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-CPI4TD43.js → chunk-TKB2OY6G.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-2VP2F6EK.js → chunk-W2LCLDPX.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-6BW3HLBG.js → chunk-WAHGI5L7.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-HTHAK6XB.js → chunk-WKNQMP4A.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-VTM6EECM.js → chunk-XCNHV3HS.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-CCQV2ZET.js → chunk-YO2K4MBH.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-VAPGUPHO.js → chunk-YQFGVZGR.js} +3 -3
package/dist/index.js
CHANGED
|
@@ -448,7 +448,7 @@ function Avatar({ address, imageUrl, loading, size }) {
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
// src/components/ConnectButton/ConnectButton.tsx
|
|
451
|
-
import React306, { useEffect as
|
|
451
|
+
import React306, { useEffect as useEffect84, useState as useState89 } from "react";
|
|
452
452
|
|
|
453
453
|
// src/css/touchableStyles.css.ts
|
|
454
454
|
var active = { shrink: "_7rkubb8", shrinkSm: "_7rkubb9" };
|
|
@@ -5644,7 +5644,7 @@ function useMainnetEnsName(address) {
|
|
|
5644
5644
|
import {
|
|
5645
5645
|
getAllWalletTokens
|
|
5646
5646
|
} from "@funkit/api-base";
|
|
5647
|
-
import { keepPreviousData as keepPreviousData4, useQuery as
|
|
5647
|
+
import { keepPreviousData as keepPreviousData4, useQuery as useQuery26 } from "@tanstack/react-query";
|
|
5648
5648
|
import { arbitrum as arbitrum6, polygon as polygon7 } from "viem/chains";
|
|
5649
5649
|
|
|
5650
5650
|
// src/domains/asset.ts
|
|
@@ -5748,7 +5748,7 @@ import React304, {
|
|
|
5748
5748
|
createContext as createContext20,
|
|
5749
5749
|
useCallback as useCallback61,
|
|
5750
5750
|
useContext as useContext20,
|
|
5751
|
-
useEffect as
|
|
5751
|
+
useEffect as useEffect83,
|
|
5752
5752
|
useRef as useRef44,
|
|
5753
5753
|
useState as useState88
|
|
5754
5754
|
} from "react";
|
|
@@ -6365,7 +6365,7 @@ function setFunkitConnectVersion({ version }) {
|
|
|
6365
6365
|
localStorage.setItem(storageKey, version);
|
|
6366
6366
|
}
|
|
6367
6367
|
function getCurrentSdkVersion() {
|
|
6368
|
-
return "10.
|
|
6368
|
+
return "10.6.0";
|
|
6369
6369
|
}
|
|
6370
6370
|
function useFingerprint() {
|
|
6371
6371
|
const fingerprint = useCallback3(() => {
|
|
@@ -6478,6 +6478,21 @@ var useTrack = () => {
|
|
|
6478
6478
|
},
|
|
6479
6479
|
[logStatsigEvent, statsigUser]
|
|
6480
6480
|
);
|
|
6481
|
+
const logEventV2 = useCallback4(
|
|
6482
|
+
// TODO: Typed events will be added
|
|
6483
|
+
(type, metadata) => {
|
|
6484
|
+
try {
|
|
6485
|
+
logStatsigEvent(
|
|
6486
|
+
type,
|
|
6487
|
+
void 0,
|
|
6488
|
+
flattenAndStringifyForStatsigEvent(type, metadata)
|
|
6489
|
+
);
|
|
6490
|
+
} catch (error) {
|
|
6491
|
+
logger.error("useTrack:logEventV2:error", error);
|
|
6492
|
+
}
|
|
6493
|
+
},
|
|
6494
|
+
[logStatsigEvent]
|
|
6495
|
+
);
|
|
6481
6496
|
const logMeasuredEvent = useCallback4(
|
|
6482
6497
|
(trackEventData) => {
|
|
6483
6498
|
const startTimeMs = eventStartTimes[trackEventData.eventName];
|
|
@@ -6524,6 +6539,7 @@ var useTrack = () => {
|
|
|
6524
6539
|
);
|
|
6525
6540
|
return {
|
|
6526
6541
|
logEvent,
|
|
6542
|
+
logEventV2,
|
|
6527
6543
|
logMeasuredEvent,
|
|
6528
6544
|
startMeasuredEvent,
|
|
6529
6545
|
updateUserAsync
|
|
@@ -6582,7 +6598,6 @@ var DEFAULT_UI_CUSTOMIZATIONS = {
|
|
|
6582
6598
|
showReceiveAmountUsd: false,
|
|
6583
6599
|
showSelectedRoute: false,
|
|
6584
6600
|
stepIndicatorType: "spinner",
|
|
6585
|
-
showTokenAmount: true,
|
|
6586
6601
|
showTransactionDigest: "none"
|
|
6587
6602
|
},
|
|
6588
6603
|
sourceChangeScreen: {
|
|
@@ -6839,7 +6854,7 @@ import {
|
|
|
6839
6854
|
getFops
|
|
6840
6855
|
} from "@funkit/api-base";
|
|
6841
6856
|
import { solanaChain as solanaChain2 } from "@funkit/chains";
|
|
6842
|
-
import { useQuery as
|
|
6857
|
+
import { useQuery as useQuery8 } from "@tanstack/react-query";
|
|
6843
6858
|
import { useMemo as useMemo15 } from "react";
|
|
6844
6859
|
|
|
6845
6860
|
// src/domains/swapped.ts
|
|
@@ -6899,14 +6914,16 @@ function validateFops(res, logTag) {
|
|
|
6899
6914
|
|
|
6900
6915
|
// src/hooks/useTokenTransfer.ts
|
|
6901
6916
|
import {
|
|
6902
|
-
bitcoinChain,
|
|
6903
6917
|
FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS as FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS2,
|
|
6918
|
+
bitcoinChain,
|
|
6904
6919
|
hyperCoreChain,
|
|
6905
6920
|
solanaChain,
|
|
6906
6921
|
tronChain
|
|
6907
6922
|
} from "@funkit/chains";
|
|
6908
6923
|
import {
|
|
6909
|
-
|
|
6924
|
+
getMinTransferValueEur,
|
|
6925
|
+
getMinTransferValueForChain,
|
|
6926
|
+
getMinTransferValueUsd
|
|
6910
6927
|
} from "@funkit/connect-core";
|
|
6911
6928
|
import { useMemo as useMemo8 } from "react";
|
|
6912
6929
|
import { arbitrum as arbitrum2, polygon as polygon2 } from "viem/chains";
|
|
@@ -6923,9 +6940,6 @@ var useIsStablecoin = () => {
|
|
|
6923
6940
|
);
|
|
6924
6941
|
};
|
|
6925
6942
|
|
|
6926
|
-
// src/utils/getExchangeRate.ts
|
|
6927
|
-
import { getExchangeRate } from "@funkit/connect-core";
|
|
6928
|
-
|
|
6929
6943
|
// src/utils/transfer.ts
|
|
6930
6944
|
import {
|
|
6931
6945
|
getDepositAddressForChain,
|
|
@@ -7276,30 +7290,37 @@ var useTokenTransfer = (selectedChainId, selectedToken, chainIds) => {
|
|
|
7276
7290
|
var useMinTransferValueUsd = (selectedChainId) => {
|
|
7277
7291
|
const limits = useDynamicConfig("mintokentransfervalue");
|
|
7278
7292
|
const { checkoutItem } = useCheckoutContext();
|
|
7279
|
-
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
|
|
7283
|
-
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
}) ?? 0;
|
|
7287
|
-
}
|
|
7288
|
-
return Math.ceil(limit);
|
|
7293
|
+
const config = checkoutItem?.initSettings.config;
|
|
7294
|
+
const minDepositAddOn = config?.getMinDepositUSD?.({
|
|
7295
|
+
tokenChainId: config.targetChain,
|
|
7296
|
+
tokenAddress: config.targetAsset,
|
|
7297
|
+
dynamicRoutingId: config.dynamicRoutingId
|
|
7298
|
+
}) ?? 0;
|
|
7299
|
+
return getMinTransferValueUsd(selectedChainId, limits, minDepositAddOn);
|
|
7289
7300
|
};
|
|
7290
7301
|
var useMinTransferValueEur = (selectedChainId) => {
|
|
7291
|
-
const
|
|
7302
|
+
const limits = useDynamicConfig("mintokentransfervalue");
|
|
7303
|
+
const { checkoutItem } = useCheckoutContext();
|
|
7304
|
+
const config = checkoutItem?.initSettings.config;
|
|
7305
|
+
const minDepositAddOn = config?.getMinDepositUSD?.({
|
|
7306
|
+
tokenChainId: config.targetChain,
|
|
7307
|
+
tokenAddress: config.targetAsset,
|
|
7308
|
+
dynamicRoutingId: config.dynamicRoutingId
|
|
7309
|
+
}) ?? 0;
|
|
7292
7310
|
const { data: exchangeRates } = useFiatExchangeRates();
|
|
7293
|
-
|
|
7294
|
-
|
|
7311
|
+
return getMinTransferValueEur(
|
|
7312
|
+
selectedChainId,
|
|
7313
|
+
limits,
|
|
7314
|
+
minDepositAddOn,
|
|
7315
|
+
exchangeRates
|
|
7316
|
+
);
|
|
7295
7317
|
};
|
|
7296
7318
|
var useMinTransferValues = (chainIds) => {
|
|
7297
7319
|
const limits = useDynamicConfig("mintokentransfervalue");
|
|
7298
7320
|
return useMemo8(() => {
|
|
7299
7321
|
return chainIds.reduce(
|
|
7300
7322
|
(acc, id) => {
|
|
7301
|
-
|
|
7302
|
-
acc[id] = Math.ceil(limit);
|
|
7323
|
+
acc[id] = getMinTransferValueUsd(id, limits);
|
|
7303
7324
|
return acc;
|
|
7304
7325
|
},
|
|
7305
7326
|
{}
|
|
@@ -9139,29 +9160,15 @@ var usePaymentSources = (currentPaymentMethodInfo, targetChainId) => {
|
|
|
9139
9160
|
};
|
|
9140
9161
|
|
|
9141
9162
|
// src/hooks/queries/useSwappedDefaultCurrency.ts
|
|
9142
|
-
import {
|
|
9143
|
-
import { useQuery as useQuery8 } from "@tanstack/react-query";
|
|
9163
|
+
import { useSwappedDefaultCurrencyQuery } from "@funkit/connect-core";
|
|
9144
9164
|
var useSwappedDefaultCurrency = () => {
|
|
9145
9165
|
const { apiKey } = useFunkitConfig();
|
|
9146
9166
|
const { userIpInfo } = useFunkitUserIp();
|
|
9147
|
-
|
|
9148
|
-
|
|
9149
|
-
|
|
9150
|
-
|
|
9151
|
-
return "USD";
|
|
9152
|
-
}
|
|
9153
|
-
const response = await getSwappedSupportedCountries({ apiKey, logger });
|
|
9154
|
-
const country = response.supported_countries.find(
|
|
9155
|
-
(country2) => country2.iso === userIpInfo?.alpha2
|
|
9156
|
-
);
|
|
9157
|
-
return country?.currency ?? "USD";
|
|
9158
|
-
},
|
|
9159
|
-
enabled: !!apiKey && !!userIpInfo,
|
|
9160
|
-
refetchOnMount: false,
|
|
9161
|
-
refetchOnReconnect: false,
|
|
9162
|
-
refetchOnWindowFocus: false
|
|
9167
|
+
return useSwappedDefaultCurrencyQuery({
|
|
9168
|
+
apiKey,
|
|
9169
|
+
countryCode: userIpInfo?.alpha2,
|
|
9170
|
+
logger
|
|
9163
9171
|
});
|
|
9164
|
-
return query;
|
|
9165
9172
|
};
|
|
9166
9173
|
|
|
9167
9174
|
// src/hooks/queries/useFops.ts
|
|
@@ -9197,7 +9204,7 @@ var useFops = () => {
|
|
|
9197
9204
|
const isValidRecipientAddress = !!recipientAddress && isAddressCompatibleWithChain(recipientAddress, Number(targetChain));
|
|
9198
9205
|
const countryCode = userIpInfo?.alpha2;
|
|
9199
9206
|
const isEnabled = isSwappedEnabled && !comingSoon && !!apiKey && !!targetAsset && !!targetChain && !isSwappedCurrencyCodeLoading && isValidRecipientAddress && !!transferInit && !!countryCode;
|
|
9200
|
-
const query =
|
|
9207
|
+
const query = useQuery8({
|
|
9201
9208
|
// `prefillFiatEmail` is intentionally NOT in the queryKey: it's read inside
|
|
9202
9209
|
// `queryFn` and captured at fetch time, so post-mount changes don't trigger a refetch
|
|
9203
9210
|
queryKey: [
|
|
@@ -9907,7 +9914,19 @@ import {
|
|
|
9907
9914
|
|
|
9908
9915
|
// src/utils/withdrawal.ts
|
|
9909
9916
|
import { isEVMAddressEquivalent, isTokenEquivalent as isTokenEquivalent3 } from "@funkit/utils";
|
|
9917
|
+
import * as dnum3 from "dnum";
|
|
9910
9918
|
import { parseUnits } from "viem";
|
|
9919
|
+
function deductFlatFee(inputAmount, feeTokens) {
|
|
9920
|
+
if (!feeTokens || feeTokens <= 0) {
|
|
9921
|
+
return inputAmount;
|
|
9922
|
+
}
|
|
9923
|
+
try {
|
|
9924
|
+
const net = dnum3.subtract(inputAmount || "0", feeTokens);
|
|
9925
|
+
return dnum3.greaterThan(net, 0) ? dnum3.toString(net) : "0";
|
|
9926
|
+
} catch {
|
|
9927
|
+
return "0";
|
|
9928
|
+
}
|
|
9929
|
+
}
|
|
9911
9930
|
function safeEvaluateWithdrawalSourceTokenBalance(fn) {
|
|
9912
9931
|
let raw;
|
|
9913
9932
|
try {
|
|
@@ -10494,7 +10513,7 @@ import React22, {
|
|
|
10494
10513
|
useRef as useRef3,
|
|
10495
10514
|
useState as useState12
|
|
10496
10515
|
} from "react";
|
|
10497
|
-
import { useQuery as
|
|
10516
|
+
import { useQuery as useQuery9 } from "@tanstack/react-query";
|
|
10498
10517
|
|
|
10499
10518
|
// src/utils/purifyCheckoutHistoryItem.ts
|
|
10500
10519
|
import { purifyCheckoutHistoryItem } from "@funkit/connect-core";
|
|
@@ -10636,7 +10655,7 @@ function useCheckoutHistoryContext() {
|
|
|
10636
10655
|
}
|
|
10637
10656
|
function useCheckoutsListenerByUserId(userId) {
|
|
10638
10657
|
const { apiKey } = useFunkitConfig();
|
|
10639
|
-
const { data, isLoading } =
|
|
10658
|
+
const { data, isLoading } = useQuery9({
|
|
10640
10659
|
enabled: !!userId,
|
|
10641
10660
|
queryKey: ["getPurifiedCheckoutsByUserId", userId],
|
|
10642
10661
|
queryFn: async () => {
|
|
@@ -10665,7 +10684,7 @@ function useCheckoutsListenerByUserId(userId) {
|
|
|
10665
10684
|
}
|
|
10666
10685
|
function useCheckoutListenerByCheckoutId(checkoutId) {
|
|
10667
10686
|
const { apiKey } = useFunkitConfig();
|
|
10668
|
-
const { data, isLoading } =
|
|
10687
|
+
const { data, isLoading } = useQuery9({
|
|
10669
10688
|
enabled: !!checkoutId && checkoutId !== "0x",
|
|
10670
10689
|
queryKey: ["getPurifiedCheckoutById", checkoutId],
|
|
10671
10690
|
queryFn: async () => {
|
|
@@ -10759,7 +10778,7 @@ import React303, {
|
|
|
10759
10778
|
createContext as createContext19,
|
|
10760
10779
|
useCallback as useCallback60,
|
|
10761
10780
|
useContext as useContext19,
|
|
10762
|
-
useEffect as
|
|
10781
|
+
useEffect as useEffect82,
|
|
10763
10782
|
useMemo as useMemo65,
|
|
10764
10783
|
useState as useState87
|
|
10765
10784
|
} from "react";
|
|
@@ -10778,7 +10797,7 @@ var topbarFadeWrapper = "_1r8f577";
|
|
|
10778
10797
|
var topbarOverflowContent = "_1r8f576 _1rsrm2fq3 _1rsrm2fs4";
|
|
10779
10798
|
|
|
10780
10799
|
// src/modals/WithdrawalModal/WithdrawalModal.tsx
|
|
10781
|
-
import React148, { useCallback as useCallback31, useEffect as
|
|
10800
|
+
import React148, { useCallback as useCallback31, useEffect as useEffect49, useState as useState45 } from "react";
|
|
10782
10801
|
import { mainnet as mainnet8 } from "viem/chains";
|
|
10783
10802
|
|
|
10784
10803
|
// src/components/FreeUsdcBanner/FreeUsdcBanner.tsx
|
|
@@ -10793,10 +10812,10 @@ import { useCallback as useCallback14 } from "react";
|
|
|
10793
10812
|
import {
|
|
10794
10813
|
getSupportedAssets
|
|
10795
10814
|
} from "@funkit/api-base";
|
|
10796
|
-
import { useQuery as
|
|
10815
|
+
import { useQuery as useQuery10 } from "@tanstack/react-query";
|
|
10797
10816
|
function useSupportedAssets(options) {
|
|
10798
10817
|
const { apiKey } = useFunkitConfig();
|
|
10799
|
-
return
|
|
10818
|
+
return useQuery10({
|
|
10800
10819
|
queryKey: ["getSupportedAssets", apiKey],
|
|
10801
10820
|
queryFn: () => getSupportedAssets({ apiKey, logger }),
|
|
10802
10821
|
refetchOnMount: false,
|
|
@@ -11506,8 +11525,8 @@ import React32 from "react";
|
|
|
11506
11525
|
import clsx4 from "clsx";
|
|
11507
11526
|
|
|
11508
11527
|
// src/utils/consts.ts
|
|
11528
|
+
import { MAX_BTC_LIGHTNING_AMOUNT_USD } from "@funkit/connect-core";
|
|
11509
11529
|
var MIN_CHECKOUT_AMOUNT_USD = 1;
|
|
11510
|
-
var MAX_BTC_LIGHTNING_AMOUNT_USD = 1e4;
|
|
11511
11530
|
var CONTACT_US_LINK = "https://intercom.help/funxyz/en/articles/10732578-contact-us";
|
|
11512
11531
|
var DEFAULT_CHECKOUT_HISTORY_DETAIL_TITLE = "Your Purchase";
|
|
11513
11532
|
|
|
@@ -12673,7 +12692,7 @@ import {
|
|
|
12673
12692
|
getDirectExecutionByTxHash as getDirectExecutionByTxHash2
|
|
12674
12693
|
} from "@funkit/api-base";
|
|
12675
12694
|
import { RELAY_TERMINAL_STATUSES } from "@funkit/fun-relay";
|
|
12676
|
-
import { useQuery as
|
|
12695
|
+
import { useQuery as useQuery11 } from "@tanstack/react-query";
|
|
12677
12696
|
var RELAY_FETCH_INTERVAL = 1500;
|
|
12678
12697
|
var logPrefix = "useDirectExecutionInfoPolling";
|
|
12679
12698
|
function useDirectExecutionInfoPolling({
|
|
@@ -12681,7 +12700,7 @@ function useDirectExecutionInfoPolling({
|
|
|
12681
12700
|
disabled = false
|
|
12682
12701
|
}) {
|
|
12683
12702
|
const { apiKey } = useFunkitConfig();
|
|
12684
|
-
const { data: directExecution, isLoading } =
|
|
12703
|
+
const { data: directExecution, isLoading } = useQuery11({
|
|
12685
12704
|
queryKey: [logPrefix, initDirectExecution?.txHash],
|
|
12686
12705
|
queryFn: async () => {
|
|
12687
12706
|
try {
|
|
@@ -14258,7 +14277,7 @@ import React54, {
|
|
|
14258
14277
|
// src/hooks/useBluvo.ts
|
|
14259
14278
|
import { bluvoGetWithdrawableBalanceById as bluvoGetWithdrawableBalanceById2 } from "@funkit/api-base";
|
|
14260
14279
|
import { FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO5 } from "@funkit/chains";
|
|
14261
|
-
import { keepPreviousData, useQuery as
|
|
14280
|
+
import { keepPreviousData, useQuery as useQuery12 } from "@tanstack/react-query";
|
|
14262
14281
|
import { useCallback as useCallback18, useMemo as useMemo21 } from "react";
|
|
14263
14282
|
import { parseUnits as parseUnits3 } from "viem";
|
|
14264
14283
|
|
|
@@ -14287,7 +14306,7 @@ var useBluvoExchangeBalance = ({
|
|
|
14287
14306
|
const deviceId = exchange && authorizedConnections?.[exchange] || "";
|
|
14288
14307
|
const isEnabled = !!exchange && !!deviceId;
|
|
14289
14308
|
const preferredChainId = checkoutItem?.initSettings.config.targetChain;
|
|
14290
|
-
const { data, isLoading, isError } =
|
|
14309
|
+
const { data, isLoading, isError } = useQuery12({
|
|
14291
14310
|
queryKey: ["bluvo-exchange-balance", deviceId, preferredChainId],
|
|
14292
14311
|
queryFn: async () => {
|
|
14293
14312
|
if (!exchange) {
|
|
@@ -14775,7 +14794,7 @@ function wrapResolveHealthFactor(resolve) {
|
|
|
14775
14794
|
// src/domains/quote.ts
|
|
14776
14795
|
import { getCheckoutQuote as getApiCheckoutQuote } from "@funkit/api-base";
|
|
14777
14796
|
import { RELAY_LIGHTER_CHAIN_ID } from "@funkit/fun-relay";
|
|
14778
|
-
import * as
|
|
14797
|
+
import * as dnum4 from "dnum";
|
|
14779
14798
|
import { formatUnits as formatUnits4 } from "viem";
|
|
14780
14799
|
|
|
14781
14800
|
// src/domains/fees.ts
|
|
@@ -15129,11 +15148,11 @@ async function checkAssetAmount(checkoutItem, finalEstimation, wagmiConfig, wall
|
|
|
15129
15148
|
0
|
|
15130
15149
|
);
|
|
15131
15150
|
const margin = 0.01;
|
|
15132
|
-
const minTargetAssetAmount =
|
|
15151
|
+
const minTargetAssetAmount = dnum4.from(
|
|
15133
15152
|
minSourceAssetAmount * exchangeRate * (1 + margin),
|
|
15134
15153
|
targetAssetDecimals
|
|
15135
15154
|
);
|
|
15136
|
-
const maxTargetAssetAmount =
|
|
15155
|
+
const maxTargetAssetAmount = dnum4.from(
|
|
15137
15156
|
maxSourceAssetAmount * exchangeRate * (1 - margin),
|
|
15138
15157
|
targetAssetDecimals
|
|
15139
15158
|
);
|
|
@@ -15250,7 +15269,7 @@ import React53, {
|
|
|
15250
15269
|
} from "react";
|
|
15251
15270
|
|
|
15252
15271
|
// src/domains/quoteMode/exactOut.ts
|
|
15253
|
-
import * as
|
|
15272
|
+
import * as dnum5 from "dnum";
|
|
15254
15273
|
|
|
15255
15274
|
// src/domains/feeEstimate.ts
|
|
15256
15275
|
import { mainnet as mainnet3 } from "viem/chains";
|
|
@@ -15305,10 +15324,10 @@ function createExactOutBuilder(isStablecoin) {
|
|
|
15305
15324
|
assetChainId,
|
|
15306
15325
|
paymentMethod
|
|
15307
15326
|
);
|
|
15308
|
-
const feeTokens =
|
|
15309
|
-
const maxAmount =
|
|
15310
|
-
const zero =
|
|
15311
|
-
return
|
|
15327
|
+
const feeTokens = dnum5.from(feeUsd / unitPrice, tokenBalanceBaseUnit[1]);
|
|
15328
|
+
const maxAmount = dnum5.subtract(tokenBalanceBaseUnit, feeTokens);
|
|
15329
|
+
const zero = dnum5.from(0, tokenBalanceBaseUnit[1]);
|
|
15330
|
+
return dnum5.greaterThan(maxAmount, zero) ? maxAmount : zero;
|
|
15312
15331
|
},
|
|
15313
15332
|
buildQuoteRequest({
|
|
15314
15333
|
tokenAmountBaseUnit
|
|
@@ -15320,7 +15339,7 @@ function createExactOutBuilder(isStablecoin) {
|
|
|
15320
15339
|
},
|
|
15321
15340
|
handleRetry({ error }) {
|
|
15322
15341
|
if (error.reason === "insufficientBalance" /* INSUFFICIENT_BALANCE */ && error.maxTargetAssetAmount !== void 0) {
|
|
15323
|
-
if (error.minTargetAssetAmount !== void 0 &&
|
|
15342
|
+
if (error.minTargetAssetAmount !== void 0 && dnum5.greaterThan(
|
|
15324
15343
|
error.minTargetAssetAmount,
|
|
15325
15344
|
error.maxTargetAssetAmount
|
|
15326
15345
|
)) {
|
|
@@ -15366,7 +15385,7 @@ function createExactOutBuilder(isStablecoin) {
|
|
|
15366
15385
|
}
|
|
15367
15386
|
|
|
15368
15387
|
// src/domains/quoteMode/exactIn.ts
|
|
15369
|
-
import * as
|
|
15388
|
+
import * as dnum6 from "dnum";
|
|
15370
15389
|
function createExactInBuilder() {
|
|
15371
15390
|
return {
|
|
15372
15391
|
mode: "EXACT_IN" /* EXACT_IN */,
|
|
@@ -15384,10 +15403,10 @@ function createExactInBuilder() {
|
|
|
15384
15403
|
if (!isNativeToken) {
|
|
15385
15404
|
return tokenBalanceBaseUnit;
|
|
15386
15405
|
}
|
|
15387
|
-
const gasBuffer = gasEstimateWei ??
|
|
15388
|
-
const zero =
|
|
15389
|
-
const maxAmount =
|
|
15390
|
-
return
|
|
15406
|
+
const gasBuffer = gasEstimateWei ?? dnum6.from(0, tokenBalanceBaseUnit[1]);
|
|
15407
|
+
const zero = dnum6.from(0, tokenBalanceBaseUnit[1]);
|
|
15408
|
+
const maxAmount = dnum6.subtract(tokenBalanceBaseUnit, gasBuffer);
|
|
15409
|
+
return dnum6.greaterThan(maxAmount, zero) ? maxAmount : zero;
|
|
15391
15410
|
},
|
|
15392
15411
|
buildQuoteRequest({
|
|
15393
15412
|
tokenAmountBaseUnit
|
|
@@ -15429,7 +15448,7 @@ function createExactInBuilder() {
|
|
|
15429
15448
|
return { type: "setFiatAmount" /* SET_FIAT_AMOUNT */, fiatAmount: percentage };
|
|
15430
15449
|
}
|
|
15431
15450
|
const base6 = maxSendableAmount ?? tokenBalanceBaseUnit;
|
|
15432
|
-
const fraction =
|
|
15451
|
+
const fraction = dnum6.multiply(base6, percentage / 100);
|
|
15433
15452
|
return {
|
|
15434
15453
|
type: "setTokenAmount" /* SET_TOKEN_AMOUNT */,
|
|
15435
15454
|
tokenAmountBaseUnit: fraction,
|
|
@@ -17711,7 +17730,6 @@ import {
|
|
|
17711
17730
|
} from "@funkit/api-base";
|
|
17712
17731
|
import { RELAY_LIGHTER_CHAIN_ID as RELAY_LIGHTER_CHAIN_ID2 } from "@funkit/fun-relay";
|
|
17713
17732
|
import { formatAddress as formatAddress3, formatCryptoAndStringify } from "@funkit/utils";
|
|
17714
|
-
import * as dnum6 from "dnum";
|
|
17715
17733
|
import { v4 as uuid2 } from "uuid";
|
|
17716
17734
|
import React86, {
|
|
17717
17735
|
useCallback as useCallback24,
|
|
@@ -19241,28 +19259,37 @@ function freeBalance(balance, lockedBalance) {
|
|
|
19241
19259
|
}
|
|
19242
19260
|
var LIGHTER_STAKING_POOL_INDEX = 281474976624800;
|
|
19243
19261
|
var LIGHTER_UNSTAKED_FEE_TOKENS = 3;
|
|
19244
|
-
var
|
|
19262
|
+
var LIGHTER_STAKING_THRESHOLD_LIT = 100;
|
|
19263
|
+
var LIGHTER_LIT_ASSET_INDEX = 2;
|
|
19245
19264
|
function findLighterStakingShare(shares) {
|
|
19246
19265
|
return shares.find(
|
|
19247
19266
|
(share) => share.public_pool_index === LIGHTER_STAKING_POOL_INDEX
|
|
19248
19267
|
);
|
|
19249
19268
|
}
|
|
19250
|
-
function
|
|
19251
|
-
const
|
|
19252
|
-
|
|
19253
|
-
|
|
19254
|
-
|
|
19255
|
-
|
|
19256
|
-
|
|
19257
|
-
if (!feeTokens || feeTokens <= 0) {
|
|
19258
|
-
return inputAmount;
|
|
19269
|
+
function resolveLighterSharePrice(poolAccount) {
|
|
19270
|
+
const totalShares = poolAccount?.pool_info?.total_shares;
|
|
19271
|
+
const litBalance = poolAccount?.assets?.find(
|
|
19272
|
+
(asset) => asset.asset_id === LIGHTER_LIT_ASSET_INDEX
|
|
19273
|
+
)?.balance;
|
|
19274
|
+
if (!totalShares || litBalance === void 0) {
|
|
19275
|
+
return void 0;
|
|
19259
19276
|
}
|
|
19260
|
-
|
|
19261
|
-
|
|
19262
|
-
|
|
19263
|
-
|
|
19264
|
-
|
|
19277
|
+
const sharePrice = Number(litBalance) / totalShares;
|
|
19278
|
+
return Number.isFinite(sharePrice) && sharePrice > 0 ? sharePrice : void 0;
|
|
19279
|
+
}
|
|
19280
|
+
function resolveLighterUnstakedFeeTokens(shares, sharePrice) {
|
|
19281
|
+
const share = findLighterStakingShare(shares);
|
|
19282
|
+
if (!share) {
|
|
19283
|
+
return LIGHTER_UNSTAKED_FEE_TOKENS;
|
|
19265
19284
|
}
|
|
19285
|
+
const stakedLit = sharePrice === void 0 ? Number(share.principal_amount ?? 0) : share.shares_amount * sharePrice;
|
|
19286
|
+
return stakedLit >= LIGHTER_STAKING_THRESHOLD_LIT ? 0 : LIGHTER_UNSTAKED_FEE_TOKENS;
|
|
19287
|
+
}
|
|
19288
|
+
function useLighterStakingSharePrice(enabled) {
|
|
19289
|
+
const { account } = useLighterAccount(
|
|
19290
|
+
enabled ? { by: "index", value: `${LIGHTER_STAKING_POOL_INDEX}` } : null
|
|
19291
|
+
);
|
|
19292
|
+
return useMemo25(() => resolveLighterSharePrice(account), [account]);
|
|
19266
19293
|
}
|
|
19267
19294
|
function useLighterWithdrawalBalances({
|
|
19268
19295
|
accountIndex
|
|
@@ -19360,26 +19387,41 @@ function useLighterWithdrawal(config, setRecipientAddress) {
|
|
|
19360
19387
|
} = useLighterWithdrawalBalances({
|
|
19361
19388
|
accountIndex: mainAccountIndex
|
|
19362
19389
|
});
|
|
19363
|
-
const
|
|
19390
|
+
const lighterSharePrice = useLighterStakingSharePrice(isLighterFast);
|
|
19391
|
+
const lighterFastUnstakedFee = isLighterFast ? resolveLighterUnstakedFeeTokens(lighterShares, lighterSharePrice) : 0;
|
|
19364
19392
|
useEffect32(() => {
|
|
19365
19393
|
if (!isLighterFast) {
|
|
19366
19394
|
return;
|
|
19367
19395
|
}
|
|
19396
|
+
const stakingShare = findLighterStakingShare(lighterShares);
|
|
19368
19397
|
logger.info("lighter:fast:unstaked-fee:resolved", {
|
|
19369
19398
|
accountIndex: mainAccountIndex,
|
|
19370
19399
|
sharesLength: lighterShares.length,
|
|
19400
|
+
sharePrice: lighterSharePrice,
|
|
19401
|
+
sharesAmount: stakingShare?.shares_amount,
|
|
19371
19402
|
unstakedFeeTokens: lighterFastUnstakedFee
|
|
19372
19403
|
});
|
|
19373
|
-
|
|
19374
|
-
|
|
19404
|
+
if (stakingShare && lighterSharePrice === void 0) {
|
|
19405
|
+
logger.warn("lighter:fast:share-price-unavailable", {
|
|
19406
|
+
accountIndex: mainAccountIndex,
|
|
19407
|
+
stakingPoolIndex: LIGHTER_STAKING_POOL_INDEX
|
|
19408
|
+
});
|
|
19409
|
+
}
|
|
19410
|
+
if (lighterShares.length > 1 || !stakingShare) {
|
|
19375
19411
|
logger.warn("lighter:fast:unexpected-shares", {
|
|
19376
19412
|
accountIndex: mainAccountIndex,
|
|
19377
19413
|
sharesLength: lighterShares.length,
|
|
19378
19414
|
publicPoolIndexes: lighterShares.map((s) => s.public_pool_index),
|
|
19379
|
-
hasStakingShare
|
|
19415
|
+
hasStakingShare: !!stakingShare
|
|
19380
19416
|
});
|
|
19381
19417
|
}
|
|
19382
|
-
}, [
|
|
19418
|
+
}, [
|
|
19419
|
+
isLighterFast,
|
|
19420
|
+
mainAccountIndex,
|
|
19421
|
+
lighterShares,
|
|
19422
|
+
lighterSharePrice,
|
|
19423
|
+
lighterFastUnstakedFee
|
|
19424
|
+
]);
|
|
19383
19425
|
const invalidateLighterAccount = useInvalidateLighterAccount();
|
|
19384
19426
|
return {
|
|
19385
19427
|
isLighterSecure,
|
|
@@ -19981,7 +20023,7 @@ import { useMemo as useMemo28 } from "react";
|
|
|
19981
20023
|
// src/hooks/queries/useSwappedExchanges.ts
|
|
19982
20024
|
import { RailConfigType as RailConfigType2, getFops as getFops2 } from "@funkit/api-base";
|
|
19983
20025
|
import { bitcoinChain as bitcoinChain2, solanaChain as solanaChain3, tronChain as tronChain2 } from "@funkit/chains";
|
|
19984
|
-
import { keepPreviousData as keepPreviousData2, useQuery as
|
|
20026
|
+
import { keepPreviousData as keepPreviousData2, useQuery as useQuery13 } from "@tanstack/react-query";
|
|
19985
20027
|
import { useMemo as useMemo27 } from "react";
|
|
19986
20028
|
var EVM_USDC_TARGETS = [
|
|
19987
20029
|
{ chainId: "1", address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" },
|
|
@@ -20072,7 +20114,7 @@ var useSwappedExchanges = () => {
|
|
|
20072
20114
|
}, [targetAsset, targetChain, transferInit]);
|
|
20073
20115
|
const countryCode = userIpInfo?.alpha2;
|
|
20074
20116
|
const isEnabled = isSwappedExchangesEnabled && !!apiKey && !!userId && !!countryCode && !!transferInit && recipientTargets.length > 0 && !isSwappedCurrencyCodeLoading;
|
|
20075
|
-
const query =
|
|
20117
|
+
const query = useQuery13({
|
|
20076
20118
|
queryKey: [
|
|
20077
20119
|
"cryptoToCryptoFops",
|
|
20078
20120
|
userId,
|
|
@@ -23242,7 +23284,7 @@ import {
|
|
|
23242
23284
|
formatCryptoAndStringify as formatCryptoAndStringify3,
|
|
23243
23285
|
formatCurrencyAndStringify as formatCurrencyAndStringify6
|
|
23244
23286
|
} from "@funkit/utils";
|
|
23245
|
-
import React135, {
|
|
23287
|
+
import React135, { useEffect as useEffect43, useMemo as useMemo39, useState as useState42 } from "react";
|
|
23246
23288
|
import { createPortal as createPortal4 } from "react-dom";
|
|
23247
23289
|
import { useDebounce } from "use-debounce";
|
|
23248
23290
|
import { isAddress } from "viem";
|
|
@@ -24716,7 +24758,7 @@ function FunNotification({
|
|
|
24716
24758
|
|
|
24717
24759
|
// src/hooks/queries/useWithdrawalQuote.ts
|
|
24718
24760
|
import { isTokenEquivalent as isTokenEquivalent6 } from "@funkit/utils";
|
|
24719
|
-
import { useQuery as
|
|
24761
|
+
import { useQuery as useQuery14 } from "@tanstack/react-query";
|
|
24720
24762
|
|
|
24721
24763
|
// src/hooks/useIsBlacklistedWithdrawalAddress.ts
|
|
24722
24764
|
import { isEVMAddressEquivalent as isEVMAddressEquivalent2 } from "@funkit/utils";
|
|
@@ -24769,7 +24811,7 @@ function useWithdrawalQuote({
|
|
|
24769
24811
|
const sourceAmountUSD = checkoutItem?.sourceAssetAmount;
|
|
24770
24812
|
const targetAsset = checkoutItem?.initSettings.config.targetAsset;
|
|
24771
24813
|
const targetChain = checkoutItem?.initSettings.config.targetChain;
|
|
24772
|
-
const enabled = isEnabled && !!apiKey && !!targetAsset && !!targetChain && !!selectedChainId &&
|
|
24814
|
+
const enabled = isEnabled && !!apiKey && !!targetAsset && !!targetChain && !!selectedChainId && Number(sourceAmountUSD) > 0 && !!recipientAddress && !!selectedTokenAddress && !!isValidAddress && !!checkoutItem && !isRecipientBlacklisted && // Note: Because we update the checkoutItem with React effects, the checkout item
|
|
24773
24815
|
// may not be matching the props in intermediate renders. This ensures we don't
|
|
24774
24816
|
// fire quotes in such states.
|
|
24775
24817
|
isTokenEquivalent6({
|
|
@@ -24779,7 +24821,7 @@ function useWithdrawalQuote({
|
|
|
24779
24821
|
secondTokenAddress: selectedTokenAddress
|
|
24780
24822
|
});
|
|
24781
24823
|
const { logEvent } = useTrack();
|
|
24782
|
-
const query =
|
|
24824
|
+
const query = useQuery14({
|
|
24783
24825
|
queryKey: [
|
|
24784
24826
|
"withdrawal",
|
|
24785
24827
|
"quote",
|
|
@@ -24831,6 +24873,10 @@ function useWithdrawalQuote({
|
|
|
24831
24873
|
},
|
|
24832
24874
|
retry: false,
|
|
24833
24875
|
enabled,
|
|
24876
|
+
// A mid-edit `enabled` flip is a mount (e.g. backspacing 10 → 1); at
|
|
24877
|
+
// staleTime 0 it refetches the stale key before the source write lands,
|
|
24878
|
+
// replaying the old amount. The interval keeps the quote fresh anyway.
|
|
24879
|
+
staleTime: QUOTE_REFRESH_INTERVAL_MS,
|
|
24834
24880
|
refetchInterval: enabled ? QUOTE_REFRESH_INTERVAL_MS : false,
|
|
24835
24881
|
refetchIntervalInBackground: true
|
|
24836
24882
|
});
|
|
@@ -24841,11 +24887,11 @@ function useWithdrawalQuote({
|
|
|
24841
24887
|
}
|
|
24842
24888
|
|
|
24843
24889
|
// src/hooks/queries/useWithdrawalRisk.ts
|
|
24844
|
-
import { useQuery as
|
|
24890
|
+
import { useQuery as useQuery15 } from "@tanstack/react-query";
|
|
24845
24891
|
import { useEffect as useEffect38, useRef as useRef19 } from "react";
|
|
24846
24892
|
var useWithdrawalRisk = (apiKey, receiveAddress, chainId2) => {
|
|
24847
24893
|
const lastRiskyAddressRef = useRef19(null);
|
|
24848
|
-
const query =
|
|
24894
|
+
const query = useQuery15({
|
|
24849
24895
|
// chainId is intentionally not in the key: risk is address-intrinsic and
|
|
24850
24896
|
// the fetcher doesn't use it — chainId only gates `enabled` below.
|
|
24851
24897
|
queryKey: ["withdrawal", "addressRisk", apiKey, receiveAddress],
|
|
@@ -24894,7 +24940,7 @@ import {
|
|
|
24894
24940
|
convertFunToRelayTokenAddress,
|
|
24895
24941
|
getRelayAssetPriceInfo
|
|
24896
24942
|
} from "@funkit/fun-relay";
|
|
24897
|
-
import { skipToken, useQuery as
|
|
24943
|
+
import { skipToken, useQuery as useQuery16 } from "@tanstack/react-query";
|
|
24898
24944
|
async function getFormattedRelayAssetPriceInfo({
|
|
24899
24945
|
chainId: chainId2,
|
|
24900
24946
|
assetTokenAddress
|
|
@@ -24947,7 +24993,7 @@ function useAssetAddressPrice({
|
|
|
24947
24993
|
}) {
|
|
24948
24994
|
const { apiKey } = useFunkitConfig();
|
|
24949
24995
|
const isStablecoin = useIsStablecoin();
|
|
24950
|
-
const { data, error, isLoading } =
|
|
24996
|
+
const { data, error, isLoading } = useQuery16({
|
|
24951
24997
|
queryKey: ["getAssetPriceInfo", chainId2, assetTokenAddress],
|
|
24952
24998
|
queryFn: enabled && chainId2 && assetTokenAddress ? () => getAssetPriceInfoWithFallback({
|
|
24953
24999
|
apiKey,
|
|
@@ -24964,150 +25010,6 @@ function useAssetAddressPrice({
|
|
|
24964
25010
|
};
|
|
24965
25011
|
}
|
|
24966
25012
|
|
|
24967
|
-
// src/hooks/useTokenAndChainDropdown.ts
|
|
24968
|
-
import { useEffect as useEffect39, useState as useState37 } from "react";
|
|
24969
|
-
import { polygon as polygon5 } from "viem/chains";
|
|
24970
|
-
|
|
24971
|
-
// src/hooks/useEnabledTokenTransferChainTokens.ts
|
|
24972
|
-
import { isTransferChainEnabled } from "@funkit/connect-core";
|
|
24973
|
-
function useEnabledTokenTransferChainTokens(transferInit, isWithdrawal) {
|
|
24974
|
-
const { symbolsByChainId } = useTokenTransferConfig(isWithdrawal);
|
|
24975
|
-
return Object.keys(
|
|
24976
|
-
symbolsByChainId
|
|
24977
|
-
).reduce(
|
|
24978
|
-
(acc, curChainIdString) => {
|
|
24979
|
-
const chainId2 = Number(curChainIdString);
|
|
24980
|
-
if (!isTransferChainEnabled(
|
|
24981
|
-
chainId2,
|
|
24982
|
-
transferInit ?? void 0,
|
|
24983
|
-
isWithdrawal
|
|
24984
|
-
)) {
|
|
24985
|
-
return acc;
|
|
24986
|
-
}
|
|
24987
|
-
if (symbolsByChainId[chainId2]?.length) {
|
|
24988
|
-
acc[chainId2] = symbolsByChainId[chainId2];
|
|
24989
|
-
}
|
|
24990
|
-
return acc;
|
|
24991
|
-
},
|
|
24992
|
-
{}
|
|
24993
|
-
);
|
|
24994
|
-
}
|
|
24995
|
-
|
|
24996
|
-
// src/hooks/useTokenAndChainDropdown.ts
|
|
24997
|
-
function resolveDefaultChainId(enabledChainSymbols, preferredChainId) {
|
|
24998
|
-
if (preferredChainId && enabledChainSymbols[preferredChainId] !== void 0) {
|
|
24999
|
-
return preferredChainId;
|
|
25000
|
-
}
|
|
25001
|
-
const firstAvailable = Number(Object.keys(enabledChainSymbols)[0]);
|
|
25002
|
-
return firstAvailable || polygon5.id;
|
|
25003
|
-
}
|
|
25004
|
-
function resolveDefaultToken(currentChainSymbols, preferredToken) {
|
|
25005
|
-
if (preferredToken && currentChainSymbols?.includes(preferredToken)) {
|
|
25006
|
-
return preferredToken;
|
|
25007
|
-
}
|
|
25008
|
-
return currentChainSymbols?.[0] ?? "";
|
|
25009
|
-
}
|
|
25010
|
-
function findChainForToken(enabledChainSymbols, token, fallbackChainId) {
|
|
25011
|
-
const matchingChainId = Object.keys(enabledChainSymbols).find(
|
|
25012
|
-
(chainId2) => enabledChainSymbols[Number(chainId2)]?.includes(token)
|
|
25013
|
-
);
|
|
25014
|
-
return matchingChainId ? Number(matchingChainId) : fallbackChainId;
|
|
25015
|
-
}
|
|
25016
|
-
var useTokenAndChainDropdown = ({
|
|
25017
|
-
defaultValues,
|
|
25018
|
-
isWithdrawal = false,
|
|
25019
|
-
noDefaultSelection = false,
|
|
25020
|
-
transferInit
|
|
25021
|
-
}) => {
|
|
25022
|
-
const getChainMetadata = useChainMetadata();
|
|
25023
|
-
const enabledChainSymbols = useEnabledTokenTransferChainTokens(
|
|
25024
|
-
transferInit ?? null,
|
|
25025
|
-
isWithdrawal
|
|
25026
|
-
);
|
|
25027
|
-
const tokenTransferConfig = useTokenTransferConfig(isWithdrawal);
|
|
25028
|
-
const isLoadingAssets = tokenTransferConfig.isLoading || Object.keys(tokenTransferConfig.symbolsByChainId).length === 0;
|
|
25029
|
-
const popularTokenSymbols = tokenTransferConfig.popularTokenSymbols ?? [];
|
|
25030
|
-
const preferredChainId = isWithdrawal ? tokenTransferConfig.defaultChainId ?? defaultValues?.chainId : defaultValues?.chainId ?? tokenTransferConfig.defaultChainId;
|
|
25031
|
-
const validDefaultChainId = resolveDefaultChainId(
|
|
25032
|
-
enabledChainSymbols,
|
|
25033
|
-
preferredChainId
|
|
25034
|
-
);
|
|
25035
|
-
const [selectedChainId, setSelectedChainId] = useState37(
|
|
25036
|
-
noDefaultSelection ? void 0 : validDefaultChainId
|
|
25037
|
-
);
|
|
25038
|
-
const selectedChainName = selectedChainId ? getChainMetadata(selectedChainId)?.name : void 0;
|
|
25039
|
-
const defaultChainSymbols = enabledChainSymbols?.[validDefaultChainId];
|
|
25040
|
-
const defaultSelectedToken = resolveDefaultToken(
|
|
25041
|
-
defaultChainSymbols,
|
|
25042
|
-
defaultValues?.token
|
|
25043
|
-
);
|
|
25044
|
-
const [selectedToken, setSelectedToken] = useState37(
|
|
25045
|
-
noDefaultSelection ? void 0 : defaultSelectedToken
|
|
25046
|
-
);
|
|
25047
|
-
useEffect39(() => {
|
|
25048
|
-
if (!noDefaultSelection) {
|
|
25049
|
-
setSelectedChainId(validDefaultChainId);
|
|
25050
|
-
}
|
|
25051
|
-
}, [validDefaultChainId, noDefaultSelection]);
|
|
25052
|
-
useEffect39(() => {
|
|
25053
|
-
if (!noDefaultSelection) {
|
|
25054
|
-
setSelectedToken(defaultSelectedToken);
|
|
25055
|
-
}
|
|
25056
|
-
}, [defaultSelectedToken, noDefaultSelection]);
|
|
25057
|
-
const handleTokenChange = (token, chainId2, autoUpdate) => {
|
|
25058
|
-
setSelectedToken(token);
|
|
25059
|
-
if (noDefaultSelection && selectedChainId === void 0) {
|
|
25060
|
-
return;
|
|
25061
|
-
}
|
|
25062
|
-
if (chainId2 !== void 0 && chainId2 !== selectedChainId) {
|
|
25063
|
-
setSelectedChainId(chainId2);
|
|
25064
|
-
}
|
|
25065
|
-
if (autoUpdate) {
|
|
25066
|
-
const targetChainId = chainId2 ?? selectedChainId;
|
|
25067
|
-
if (targetChainId !== void 0 && !enabledChainSymbols[targetChainId]?.includes(token)) {
|
|
25068
|
-
setSelectedChainId(
|
|
25069
|
-
findChainForToken(enabledChainSymbols, token, validDefaultChainId)
|
|
25070
|
-
);
|
|
25071
|
-
}
|
|
25072
|
-
}
|
|
25073
|
-
};
|
|
25074
|
-
const handleChainChange = (chainId2, autoUpdate) => {
|
|
25075
|
-
if (chainId2 === void 0) {
|
|
25076
|
-
return;
|
|
25077
|
-
}
|
|
25078
|
-
setSelectedChainId(chainId2);
|
|
25079
|
-
if (autoUpdate && selectedToken !== void 0 && !enabledChainSymbols[chainId2]?.includes(selectedToken)) {
|
|
25080
|
-
const firstToken = enabledChainSymbols[chainId2]?.[0];
|
|
25081
|
-
if (noDefaultSelection || firstToken) {
|
|
25082
|
-
setSelectedToken(firstToken);
|
|
25083
|
-
}
|
|
25084
|
-
}
|
|
25085
|
-
};
|
|
25086
|
-
return {
|
|
25087
|
-
assets: enabledChainSymbols,
|
|
25088
|
-
selectedChainId,
|
|
25089
|
-
handleChainChange,
|
|
25090
|
-
selectedToken,
|
|
25091
|
-
selectedChainName,
|
|
25092
|
-
handleTokenChange,
|
|
25093
|
-
isLoadingAssets,
|
|
25094
|
-
// Only promote default chain to top when there is an explicit default configured
|
|
25095
|
-
chainIdSortOrder: noDefaultSelection ? tokenTransferConfig.chainIdSortOrder : [
|
|
25096
|
-
validDefaultChainId,
|
|
25097
|
-
...tokenTransferConfig.chainIdSortOrder.filter(
|
|
25098
|
-
(id) => id !== validDefaultChainId
|
|
25099
|
-
)
|
|
25100
|
-
],
|
|
25101
|
-
priorityTokenSymbols: !noDefaultSelection && defaultSelectedToken ? [
|
|
25102
|
-
defaultSelectedToken,
|
|
25103
|
-
...tokenTransferConfig.priorityTokenSymbols.filter(
|
|
25104
|
-
(token) => token !== defaultSelectedToken
|
|
25105
|
-
)
|
|
25106
|
-
] : tokenTransferConfig.priorityTokenSymbols,
|
|
25107
|
-
popularTokenSymbols
|
|
25108
|
-
};
|
|
25109
|
-
};
|
|
25110
|
-
|
|
25111
25013
|
// src/utils/polymarket.ts
|
|
25112
25014
|
import {
|
|
25113
25015
|
encodeAbiParameters,
|
|
@@ -25166,7 +25068,7 @@ function getErrorNotification({
|
|
|
25166
25068
|
}
|
|
25167
25069
|
|
|
25168
25070
|
// src/modals/WithdrawalModal/RecipientAddress.tsx
|
|
25169
|
-
import React133, { useEffect as
|
|
25071
|
+
import React133, { useEffect as useEffect39, useState as useState37 } from "react";
|
|
25170
25072
|
import {
|
|
25171
25073
|
FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO as FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO8,
|
|
25172
25074
|
solanaChain as solanaChain4,
|
|
@@ -25200,7 +25102,7 @@ function useShowConnectWallet({ config }) {
|
|
|
25200
25102
|
isConnected,
|
|
25201
25103
|
connectedWalletAddress
|
|
25202
25104
|
});
|
|
25203
|
-
|
|
25105
|
+
useEffect39(() => {
|
|
25204
25106
|
logger.debug("withdrawalContent:showUseConnected", {
|
|
25205
25107
|
isConnected,
|
|
25206
25108
|
connectedWalletAddress,
|
|
@@ -25226,7 +25128,7 @@ function WithdrawRecipientAddress({
|
|
|
25226
25128
|
}) {
|
|
25227
25129
|
const { t } = useFunkitTranslation();
|
|
25228
25130
|
const hasAddressError = !isValidAddress && recipientAddress !== "";
|
|
25229
|
-
const [addressInputTouched, setAddressInputTouched] =
|
|
25131
|
+
const [addressInputTouched, setAddressInputTouched] = useState37(false);
|
|
25230
25132
|
const { updateCustomRecipient } = useCheckoutContext();
|
|
25231
25133
|
const { connector, address: connectedWalletAddress } = useAccount();
|
|
25232
25134
|
const wallets = usePreparedWalletConnectors();
|
|
@@ -25332,7 +25234,7 @@ import {
|
|
|
25332
25234
|
formatCurrencyAndStringify as formatCurrencyAndStringify5
|
|
25333
25235
|
} from "@funkit/utils";
|
|
25334
25236
|
import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
|
|
25335
|
-
import React134, { useState as
|
|
25237
|
+
import React134, { useState as useState38 } from "react";
|
|
25336
25238
|
function WithdrawAmountInput({
|
|
25337
25239
|
withdrawalInputAmount,
|
|
25338
25240
|
setWithdrawalInputAmount,
|
|
@@ -25360,7 +25262,7 @@ function WithdrawAmountInput({
|
|
|
25360
25262
|
const chipIconSrc = selectedOption?.iconSrc ?? getTokenIconUrl(getLighterBaseSymbol(activeSymbol));
|
|
25361
25263
|
const displaySymbol = getLighterBaseSymbol(activeSymbol);
|
|
25362
25264
|
const chipTooltip = isLighterFast ? t("withdrawal.lighterFastTokenTooltip") : void 0;
|
|
25363
|
-
const [amountInputTouched, setAmountInputTouched] =
|
|
25265
|
+
const [amountInputTouched, setAmountInputTouched] = useState38(false);
|
|
25364
25266
|
const handleAmountChange = (e) => {
|
|
25365
25267
|
if (!amountInputTouched) {
|
|
25366
25268
|
setAmountInputTouched(true);
|
|
@@ -25529,7 +25431,7 @@ function LighterSourceTokenDropdown({
|
|
|
25529
25431
|
onSelect
|
|
25530
25432
|
}) {
|
|
25531
25433
|
const themeRootProps = useThemeRootProps();
|
|
25532
|
-
const [isOpen, setIsOpen] =
|
|
25434
|
+
const [isOpen, setIsOpen] = useState38(false);
|
|
25533
25435
|
const hasMultipleOptions = !!options && options.length > 1;
|
|
25534
25436
|
const chip = /* @__PURE__ */ React134.createElement(
|
|
25535
25437
|
Box,
|
|
@@ -25655,267 +25557,8 @@ function LighterSourceTokenDropdown({
|
|
|
25655
25557
|
)));
|
|
25656
25558
|
}
|
|
25657
25559
|
|
|
25658
|
-
// src/modals/WithdrawalModal/
|
|
25659
|
-
import {
|
|
25660
|
-
|
|
25661
|
-
// src/hooks/useAutoClearState.ts
|
|
25662
|
-
import { useCallback as useCallback28, useEffect as useEffect41, useRef as useRef20, useState as useState40 } from "react";
|
|
25663
|
-
function useAutoClearState(initialValue = null) {
|
|
25664
|
-
const [state, setState] = useState40(initialValue);
|
|
25665
|
-
const timeoutRef = useRef20(void 0);
|
|
25666
|
-
useEffect41(() => {
|
|
25667
|
-
return () => {
|
|
25668
|
-
if (timeoutRef.current !== void 0) {
|
|
25669
|
-
clearTimeout(timeoutRef.current);
|
|
25670
|
-
}
|
|
25671
|
-
};
|
|
25672
|
-
}, []);
|
|
25673
|
-
return [
|
|
25674
|
-
state,
|
|
25675
|
-
useCallback28((newState, durationMs) => {
|
|
25676
|
-
if (timeoutRef.current) {
|
|
25677
|
-
clearTimeout(timeoutRef.current);
|
|
25678
|
-
timeoutRef.current = void 0;
|
|
25679
|
-
}
|
|
25680
|
-
setState(newState);
|
|
25681
|
-
if (durationMs !== void 0) {
|
|
25682
|
-
timeoutRef.current = setTimeout(() => setState(null), durationMs);
|
|
25683
|
-
}
|
|
25684
|
-
}, [])
|
|
25685
|
-
];
|
|
25686
|
-
}
|
|
25687
|
-
|
|
25688
|
-
// src/modals/WithdrawalModal/useWithdrawal.ts
|
|
25689
|
-
function generateSyntheticDepositAddress() {
|
|
25690
|
-
return "0x0000000000000000000000000000000000000001";
|
|
25691
|
-
}
|
|
25692
|
-
var SYNTHETIC_QUOTELESS_QUOTE_ID = "synthetic:quoteless-withdrawal";
|
|
25693
|
-
function useWithdrawal({
|
|
25694
|
-
config,
|
|
25695
|
-
withdrawalItem,
|
|
25696
|
-
onSuccess
|
|
25697
|
-
}) {
|
|
25698
|
-
const { t } = useFunkitTranslation();
|
|
25699
|
-
const { confirmCheckout, checkoutItem } = useCheckoutContext();
|
|
25700
|
-
const { refreshCheckoutHistory } = useCheckoutHistoryContext();
|
|
25701
|
-
const [error, setError] = useAutoClearState();
|
|
25702
|
-
const [isWithdrawing, setIsWithdrawing] = useState41(false);
|
|
25703
|
-
const [step, setStep] = useState41(null);
|
|
25704
|
-
const wagmiConfig = useConfig();
|
|
25705
|
-
const configType = isWalletWithdrawalConfig(config) ? "wallet" : isCustomWithdrawalConfig(config) ? "custom" : "unknown";
|
|
25706
|
-
const handleWithdrawal = useEffectEvent(
|
|
25707
|
-
async (formData) => {
|
|
25708
|
-
const baseLogContext = {
|
|
25709
|
-
configType,
|
|
25710
|
-
withdrawalId: withdrawalItem?.id ?? null,
|
|
25711
|
-
destinationAddress: formData.destinationAddress,
|
|
25712
|
-
chainId: formData.chainId,
|
|
25713
|
-
tokenSymbol: formData.tokenSymbol,
|
|
25714
|
-
quoteId: formData.quote?.baseQuote.quoteId ?? null
|
|
25715
|
-
};
|
|
25716
|
-
let customCallbackFailed = false;
|
|
25717
|
-
async function walletWithdrawal(walletConfig) {
|
|
25718
|
-
if (!formData.quote) {
|
|
25719
|
-
throw new Error("Missing quote for wallet withdrawal");
|
|
25720
|
-
}
|
|
25721
|
-
let preTxs = [];
|
|
25722
|
-
if (walletConfig.preWithdrawalAction) {
|
|
25723
|
-
customCallbackFailed = true;
|
|
25724
|
-
preTxs = await walletConfig.preWithdrawalAction({
|
|
25725
|
-
quoteId: formData.quote.baseQuote.quoteId,
|
|
25726
|
-
funQuote: formData.quote,
|
|
25727
|
-
targetAssetAddress: formData.tokenAddress,
|
|
25728
|
-
targetChainId: formData.chainId,
|
|
25729
|
-
destinationAddress: formData.destinationAddress,
|
|
25730
|
-
customerData: formData.customerData,
|
|
25731
|
-
userInputAmount: formData.userInputAmount,
|
|
25732
|
-
withdrawalUSD: formData.withdrawalUSD
|
|
25733
|
-
});
|
|
25734
|
-
customCallbackFailed = false;
|
|
25735
|
-
}
|
|
25736
|
-
const txHash = await confirmCheckout(
|
|
25737
|
-
formData.quote,
|
|
25738
|
-
setStep,
|
|
25739
|
-
walletConfig.wallet,
|
|
25740
|
-
preTxs
|
|
25741
|
-
);
|
|
25742
|
-
withdrawalItem?.initSettings.onWithdrawalConfirmation?.(
|
|
25743
|
-
formData.destinationAddress,
|
|
25744
|
-
formData
|
|
25745
|
-
);
|
|
25746
|
-
if (!txHash) {
|
|
25747
|
-
const invalidTxHashError = new Error(
|
|
25748
|
-
"Invalid txHash - unable to proceed with withdrawal"
|
|
25749
|
-
);
|
|
25750
|
-
logger.error("withdrawal:missingTxHash", invalidTxHashError, {
|
|
25751
|
-
...baseLogContext,
|
|
25752
|
-
stepMessage: step
|
|
25753
|
-
});
|
|
25754
|
-
throw invalidTxHashError;
|
|
25755
|
-
}
|
|
25756
|
-
return txHash;
|
|
25757
|
-
}
|
|
25758
|
-
async function callbackWithdrawal(customConfig) {
|
|
25759
|
-
const quoteId = formData.quote?.baseQuote.quoteId ?? SYNTHETIC_QUOTELESS_QUOTE_ID;
|
|
25760
|
-
customCallbackFailed = true;
|
|
25761
|
-
const callbackResult = await customConfig.withdrawCallback({
|
|
25762
|
-
quoteId,
|
|
25763
|
-
funQuote: formData.quote ?? null,
|
|
25764
|
-
targetAssetAddress: formData.tokenAddress,
|
|
25765
|
-
targetChainId: formData.chainId,
|
|
25766
|
-
destinationAddress: formData.destinationAddress,
|
|
25767
|
-
customerData: formData.customerData,
|
|
25768
|
-
userInputAmount: formData.userInputAmount,
|
|
25769
|
-
withdrawalUSD: formData.withdrawalUSD
|
|
25770
|
-
});
|
|
25771
|
-
customCallbackFailed = false;
|
|
25772
|
-
withdrawalItem?.initSettings.onWithdrawalConfirmation?.(
|
|
25773
|
-
quoteId,
|
|
25774
|
-
formData
|
|
25775
|
-
);
|
|
25776
|
-
if (callbackResult) {
|
|
25777
|
-
logger.log("directExecutionCheckoutConfirmed", {
|
|
25778
|
-
depositAddressOrHash: callbackResult
|
|
25779
|
-
});
|
|
25780
|
-
checkoutItem?.initSettings.onConfirmation?.(callbackResult);
|
|
25781
|
-
refreshCheckoutHistory();
|
|
25782
|
-
}
|
|
25783
|
-
return callbackResult ? callbackResult : generateSyntheticDepositAddress();
|
|
25784
|
-
}
|
|
25785
|
-
try {
|
|
25786
|
-
setIsWithdrawing(true);
|
|
25787
|
-
const onBeforeSign = isWalletWithdrawalConfig(config) || isCustomWithdrawalConfig(config) ? config.onBeforeSign : void 0;
|
|
25788
|
-
if (onBeforeSign) {
|
|
25789
|
-
logger.info("withdrawal:onBeforeSign", baseLogContext);
|
|
25790
|
-
customCallbackFailed = true;
|
|
25791
|
-
await onBeforeSign();
|
|
25792
|
-
customCallbackFailed = false;
|
|
25793
|
-
}
|
|
25794
|
-
let txHash;
|
|
25795
|
-
if (isWalletWithdrawalConfig(config)) {
|
|
25796
|
-
txHash = await walletWithdrawal(config);
|
|
25797
|
-
} else if (isCustomWithdrawalConfig(config)) {
|
|
25798
|
-
txHash = await callbackWithdrawal(config);
|
|
25799
|
-
} else {
|
|
25800
|
-
const invalidConfigError = new Error("Invalid withdrawal config");
|
|
25801
|
-
logger.error("withdrawal:invalidConfig", invalidConfigError, {
|
|
25802
|
-
...baseLogContext,
|
|
25803
|
-
providedConfigKeys: Object.keys(config ?? {})
|
|
25804
|
-
});
|
|
25805
|
-
throw invalidConfigError;
|
|
25806
|
-
}
|
|
25807
|
-
setError(null);
|
|
25808
|
-
logger.info("withdrawal:success", {
|
|
25809
|
-
...baseLogContext,
|
|
25810
|
-
stepMessage: step,
|
|
25811
|
-
withdrawalAmountUSD: formData.withdrawalUSD
|
|
25812
|
-
});
|
|
25813
|
-
onSuccess?.(formData, txHash);
|
|
25814
|
-
return txHash;
|
|
25815
|
-
} catch (err) {
|
|
25816
|
-
const caughtError = err instanceof Error ? err : new Error("Unknown withdrawal error");
|
|
25817
|
-
const isNestedError = caughtError.message === "Invalid txHash - unable to proceed with withdrawal" || caughtError.message === "Invalid withdrawal config";
|
|
25818
|
-
if (!isNestedError) {
|
|
25819
|
-
logger.error("withdrawal:executionFailed", caughtError, {
|
|
25820
|
-
...baseLogContext,
|
|
25821
|
-
stepMessage: step
|
|
25822
|
-
});
|
|
25823
|
-
}
|
|
25824
|
-
const error2 = customCallbackFailed ? {
|
|
25825
|
-
message: caughtError.message,
|
|
25826
|
-
type: "hint",
|
|
25827
|
-
code: "GENERIC_ERROR" /* GENERIC_ERROR */,
|
|
25828
|
-
durationMs: 1e4
|
|
25829
|
-
} : await toCheckoutConfirmationError(t, err, wagmiConfig);
|
|
25830
|
-
logger.info("toCheckoutConfirmationError:resulting_error", error2);
|
|
25831
|
-
setError(error2, error2.durationMs);
|
|
25832
|
-
withdrawalItem?.initSettings.onWithdrawalError?.({
|
|
25833
|
-
type: "error",
|
|
25834
|
-
message: err.message,
|
|
25835
|
-
metadata: err
|
|
25836
|
-
});
|
|
25837
|
-
return null;
|
|
25838
|
-
} finally {
|
|
25839
|
-
setIsWithdrawing(false);
|
|
25840
|
-
setStep(null);
|
|
25841
|
-
}
|
|
25842
|
-
}
|
|
25843
|
-
);
|
|
25844
|
-
return {
|
|
25845
|
-
withdrawalError: error,
|
|
25846
|
-
stepMessage: step,
|
|
25847
|
-
handleWithdrawal,
|
|
25848
|
-
isWithdrawing
|
|
25849
|
-
};
|
|
25850
|
-
}
|
|
25851
|
-
|
|
25852
|
-
// src/modals/WithdrawalModal/WithdrawalContent.tsx
|
|
25853
|
-
var PRICE_REFRESH_INTERVAL = 6e4;
|
|
25854
|
-
var FALLBACK_FEES = {
|
|
25855
|
-
marketMakerFeeUsd: 0,
|
|
25856
|
-
liquidityProviderFeeUsd: 0,
|
|
25857
|
-
eoaWalletFeeUsd: 0,
|
|
25858
|
-
paymentMethod: PaymentMethod.ACCOUNT_BALANCE,
|
|
25859
|
-
eoaWalletFeeToken: 0,
|
|
25860
|
-
nativeCurrencySymbol: "",
|
|
25861
|
-
totalFeesUsd: 0,
|
|
25862
|
-
totalFeesTokenWithoutGas: 0
|
|
25863
|
-
};
|
|
25864
|
-
function useWithdrawalAssets(config) {
|
|
25865
|
-
const enableEmptyWithdrawalSelection = useFeatureGate(
|
|
25866
|
-
"enable-empty-withdrawal-selection"
|
|
25867
|
-
);
|
|
25868
|
-
const {
|
|
25869
|
-
assets,
|
|
25870
|
-
selectedChainId,
|
|
25871
|
-
handleChainChange,
|
|
25872
|
-
selectedToken,
|
|
25873
|
-
selectedChainName,
|
|
25874
|
-
handleTokenChange,
|
|
25875
|
-
chainIdSortOrder,
|
|
25876
|
-
popularTokenSymbols,
|
|
25877
|
-
priorityTokenSymbols,
|
|
25878
|
-
isLoadingAssets
|
|
25879
|
-
} = useTokenAndChainDropdown({
|
|
25880
|
-
defaultValues: {
|
|
25881
|
-
chainId: Number.parseInt(config.sourceChainId),
|
|
25882
|
-
token: config.defaultReceiveToken ?? config.sourceTokenSymbol
|
|
25883
|
-
},
|
|
25884
|
-
isWithdrawal: true,
|
|
25885
|
-
noDefaultSelection: enableEmptyWithdrawalSelection
|
|
25886
|
-
});
|
|
25887
|
-
const { addressBySymbolByChainId } = useTokenTransferConfig(true);
|
|
25888
|
-
return {
|
|
25889
|
-
assets,
|
|
25890
|
-
selectedChainId,
|
|
25891
|
-
handleChainChange,
|
|
25892
|
-
selectedToken,
|
|
25893
|
-
selectedChainName,
|
|
25894
|
-
handleTokenChange,
|
|
25895
|
-
chainIdSortOrder,
|
|
25896
|
-
popularTokenSymbols,
|
|
25897
|
-
priorityTokenSymbols,
|
|
25898
|
-
isLoadingAssets,
|
|
25899
|
-
addressBySymbolByChainId
|
|
25900
|
-
};
|
|
25901
|
-
}
|
|
25902
|
-
function toUsdValue(sourceAmount, sourceTokenUsdPrice) {
|
|
25903
|
-
if (sourceTokenUsdPrice === void 0) {
|
|
25904
|
-
return void 0;
|
|
25905
|
-
}
|
|
25906
|
-
return Number(sourceAmount || 0) * sourceTokenUsdPrice;
|
|
25907
|
-
}
|
|
25908
|
-
function getRelayOutputCurrencyAmount(quote, fallback2) {
|
|
25909
|
-
try {
|
|
25910
|
-
const relayQuote = quote.baseQuote;
|
|
25911
|
-
return Number.parseFloat(
|
|
25912
|
-
relayQuote.metadata?.relayQuote?.details?.currencyOut?.amountFormatted || "0"
|
|
25913
|
-
) || fallback2 || 0;
|
|
25914
|
-
} catch (error) {
|
|
25915
|
-
logger.error("Error getting relay output currency amount:", error);
|
|
25916
|
-
return fallback2 || 0;
|
|
25917
|
-
}
|
|
25918
|
-
}
|
|
25560
|
+
// src/modals/WithdrawalModal/withdrawalFormHelpers.tsx
|
|
25561
|
+
import { validateWithdrawalAmount } from "@funkit/connect-core";
|
|
25919
25562
|
function getWithdrawButtonText({
|
|
25920
25563
|
isWithdrawing,
|
|
25921
25564
|
isValidAddress,
|
|
@@ -25976,38 +25619,237 @@ function isValidWithdrawal({
|
|
|
25976
25619
|
tokenAddress: checkoutConfig?.sourceTokenAddress || "0x",
|
|
25977
25620
|
tokenChainId: checkoutConfig?.sourceChain || "0"
|
|
25978
25621
|
}) ?? 0.01;
|
|
25979
|
-
const minInSourceTokenUnits = perTokenMin ?? (sourceTokenUsdPrice > 0 ? usdMin / sourceTokenUsdPrice : 0);
|
|
25980
|
-
const minWithdrawalDisplayValue = perTokenMin ?? usdMin;
|
|
25981
|
-
const inputAmount = Number(withdrawalInputAmount);
|
|
25982
|
-
const isWithdrawAmountTooLow = inputAmount < minInSourceTokenUnits;
|
|
25983
25622
|
const usdMax = config.getMaxWithdrawalUSD?.({
|
|
25984
25623
|
tokenAddress: checkoutConfig?.sourceTokenAddress || "0x",
|
|
25985
25624
|
tokenChainId: checkoutConfig?.sourceChain || "0"
|
|
25986
25625
|
});
|
|
25987
|
-
const maxInSourceTokenUnits = usdMax !== void 0 && sourceTokenUsdPrice > 0 ? usdMax / sourceTokenUsdPrice : void 0;
|
|
25988
|
-
const isWithdrawAmountTooHigh = maxInSourceTokenUnits !== void 0 && inputAmount > maxInSourceTokenUnits;
|
|
25989
|
-
const isWithdrawAmountAboveBalance = inputAmount > Number(sourceTokenBalance);
|
|
25990
|
-
const isWithdrawAmountValid = !isWithdrawAmountTooLow && !isWithdrawAmountTooHigh && !isWithdrawAmountAboveBalance;
|
|
25991
25626
|
return {
|
|
25992
25627
|
isValidAddress,
|
|
25993
25628
|
isValidAddressAndChain,
|
|
25994
|
-
|
|
25995
|
-
|
|
25996
|
-
|
|
25997
|
-
|
|
25998
|
-
|
|
25629
|
+
...validateWithdrawalAmount({
|
|
25630
|
+
withdrawalInputAmount,
|
|
25631
|
+
sourceTokenUsdPrice,
|
|
25632
|
+
sourceTokenBalance,
|
|
25633
|
+
perTokenMin,
|
|
25634
|
+
usdMin,
|
|
25635
|
+
usdMax
|
|
25636
|
+
})
|
|
25637
|
+
};
|
|
25638
|
+
}
|
|
25639
|
+
function toUsdValue(sourceAmount, sourceTokenUsdPrice) {
|
|
25640
|
+
if (sourceTokenUsdPrice === void 0) {
|
|
25641
|
+
return void 0;
|
|
25642
|
+
}
|
|
25643
|
+
return Number(sourceAmount || 0) * sourceTokenUsdPrice;
|
|
25644
|
+
}
|
|
25645
|
+
function getRelayOutputCurrencyAmount(quote, fallback2) {
|
|
25646
|
+
try {
|
|
25647
|
+
const relayQuote = quote.baseQuote;
|
|
25648
|
+
return Number.parseFloat(
|
|
25649
|
+
relayQuote.metadata?.relayQuote?.details?.currencyOut?.amountFormatted || "0"
|
|
25650
|
+
) || fallback2 || 0;
|
|
25651
|
+
} catch (error) {
|
|
25652
|
+
logger.error("Error getting relay output currency amount:", error);
|
|
25653
|
+
return fallback2 || 0;
|
|
25654
|
+
}
|
|
25655
|
+
}
|
|
25656
|
+
|
|
25657
|
+
// src/modals/WithdrawalModal/withdrawalHooks.tsx
|
|
25658
|
+
import { useCallback as useCallback28, useEffect as useEffect41, useRef as useRef20 } from "react";
|
|
25659
|
+
|
|
25660
|
+
// src/hooks/useTokenAndChainDropdown.ts
|
|
25661
|
+
import { useEffect as useEffect40, useState as useState39 } from "react";
|
|
25662
|
+
import { polygon as polygon5 } from "viem/chains";
|
|
25663
|
+
|
|
25664
|
+
// src/hooks/useEnabledTokenTransferChainTokens.ts
|
|
25665
|
+
import { isTransferChainEnabled } from "@funkit/connect-core";
|
|
25666
|
+
function useEnabledTokenTransferChainTokens(transferInit, isWithdrawal) {
|
|
25667
|
+
const { symbolsByChainId } = useTokenTransferConfig(isWithdrawal);
|
|
25668
|
+
return Object.keys(
|
|
25669
|
+
symbolsByChainId
|
|
25670
|
+
).reduce(
|
|
25671
|
+
(acc, curChainIdString) => {
|
|
25672
|
+
const chainId2 = Number(curChainIdString);
|
|
25673
|
+
if (!isTransferChainEnabled(
|
|
25674
|
+
chainId2,
|
|
25675
|
+
transferInit ?? void 0,
|
|
25676
|
+
isWithdrawal
|
|
25677
|
+
)) {
|
|
25678
|
+
return acc;
|
|
25679
|
+
}
|
|
25680
|
+
if (symbolsByChainId[chainId2]?.length) {
|
|
25681
|
+
acc[chainId2] = symbolsByChainId[chainId2];
|
|
25682
|
+
}
|
|
25683
|
+
return acc;
|
|
25684
|
+
},
|
|
25685
|
+
{}
|
|
25686
|
+
);
|
|
25687
|
+
}
|
|
25688
|
+
|
|
25689
|
+
// src/hooks/useTokenAndChainDropdown.ts
|
|
25690
|
+
function resolveDefaultChainId(enabledChainSymbols, preferredChainId) {
|
|
25691
|
+
if (preferredChainId && enabledChainSymbols[preferredChainId] !== void 0) {
|
|
25692
|
+
return preferredChainId;
|
|
25693
|
+
}
|
|
25694
|
+
const firstAvailable = Number(Object.keys(enabledChainSymbols)[0]);
|
|
25695
|
+
return firstAvailable || polygon5.id;
|
|
25696
|
+
}
|
|
25697
|
+
function resolveDefaultToken(currentChainSymbols, preferredToken) {
|
|
25698
|
+
if (preferredToken && currentChainSymbols?.includes(preferredToken)) {
|
|
25699
|
+
return preferredToken;
|
|
25700
|
+
}
|
|
25701
|
+
return currentChainSymbols?.[0] ?? "";
|
|
25702
|
+
}
|
|
25703
|
+
function findChainForToken(enabledChainSymbols, token, fallbackChainId) {
|
|
25704
|
+
const matchingChainId = Object.keys(enabledChainSymbols).find(
|
|
25705
|
+
(chainId2) => enabledChainSymbols[Number(chainId2)]?.includes(token)
|
|
25706
|
+
);
|
|
25707
|
+
return matchingChainId ? Number(matchingChainId) : fallbackChainId;
|
|
25708
|
+
}
|
|
25709
|
+
var useTokenAndChainDropdown = ({
|
|
25710
|
+
defaultValues,
|
|
25711
|
+
isWithdrawal = false,
|
|
25712
|
+
noDefaultSelection = false,
|
|
25713
|
+
transferInit
|
|
25714
|
+
}) => {
|
|
25715
|
+
const getChainMetadata = useChainMetadata();
|
|
25716
|
+
const enabledChainSymbols = useEnabledTokenTransferChainTokens(
|
|
25717
|
+
transferInit ?? null,
|
|
25718
|
+
isWithdrawal
|
|
25719
|
+
);
|
|
25720
|
+
const tokenTransferConfig = useTokenTransferConfig(isWithdrawal);
|
|
25721
|
+
const isLoadingAssets = tokenTransferConfig.isLoading || Object.keys(tokenTransferConfig.symbolsByChainId).length === 0;
|
|
25722
|
+
const popularTokenSymbols = tokenTransferConfig.popularTokenSymbols ?? [];
|
|
25723
|
+
const preferredChainId = isWithdrawal ? tokenTransferConfig.defaultChainId ?? defaultValues?.chainId : defaultValues?.chainId ?? tokenTransferConfig.defaultChainId;
|
|
25724
|
+
const validDefaultChainId = resolveDefaultChainId(
|
|
25725
|
+
enabledChainSymbols,
|
|
25726
|
+
preferredChainId
|
|
25727
|
+
);
|
|
25728
|
+
const [selectedChainId, setSelectedChainId] = useState39(
|
|
25729
|
+
noDefaultSelection ? void 0 : validDefaultChainId
|
|
25730
|
+
);
|
|
25731
|
+
const selectedChainName = selectedChainId ? getChainMetadata(selectedChainId)?.name : void 0;
|
|
25732
|
+
const defaultChainSymbols = enabledChainSymbols?.[validDefaultChainId];
|
|
25733
|
+
const defaultSelectedToken = resolveDefaultToken(
|
|
25734
|
+
defaultChainSymbols,
|
|
25735
|
+
defaultValues?.token
|
|
25736
|
+
);
|
|
25737
|
+
const [selectedToken, setSelectedToken] = useState39(
|
|
25738
|
+
noDefaultSelection ? void 0 : defaultSelectedToken
|
|
25739
|
+
);
|
|
25740
|
+
useEffect40(() => {
|
|
25741
|
+
if (!noDefaultSelection) {
|
|
25742
|
+
setSelectedChainId(validDefaultChainId);
|
|
25743
|
+
}
|
|
25744
|
+
}, [validDefaultChainId, noDefaultSelection]);
|
|
25745
|
+
useEffect40(() => {
|
|
25746
|
+
if (!noDefaultSelection) {
|
|
25747
|
+
setSelectedToken(defaultSelectedToken);
|
|
25748
|
+
}
|
|
25749
|
+
}, [defaultSelectedToken, noDefaultSelection]);
|
|
25750
|
+
const handleTokenChange = (token, chainId2, autoUpdate) => {
|
|
25751
|
+
setSelectedToken(token);
|
|
25752
|
+
if (noDefaultSelection && selectedChainId === void 0) {
|
|
25753
|
+
return;
|
|
25754
|
+
}
|
|
25755
|
+
if (chainId2 !== void 0 && chainId2 !== selectedChainId) {
|
|
25756
|
+
setSelectedChainId(chainId2);
|
|
25757
|
+
}
|
|
25758
|
+
if (autoUpdate) {
|
|
25759
|
+
const targetChainId = chainId2 ?? selectedChainId;
|
|
25760
|
+
if (targetChainId !== void 0 && !enabledChainSymbols[targetChainId]?.includes(token)) {
|
|
25761
|
+
setSelectedChainId(
|
|
25762
|
+
findChainForToken(enabledChainSymbols, token, validDefaultChainId)
|
|
25763
|
+
);
|
|
25764
|
+
}
|
|
25765
|
+
}
|
|
25766
|
+
};
|
|
25767
|
+
const handleChainChange = (chainId2, autoUpdate) => {
|
|
25768
|
+
if (chainId2 === void 0) {
|
|
25769
|
+
return;
|
|
25770
|
+
}
|
|
25771
|
+
setSelectedChainId(chainId2);
|
|
25772
|
+
if (autoUpdate && selectedToken !== void 0 && !enabledChainSymbols[chainId2]?.includes(selectedToken)) {
|
|
25773
|
+
const firstToken = enabledChainSymbols[chainId2]?.[0];
|
|
25774
|
+
if (noDefaultSelection || firstToken) {
|
|
25775
|
+
setSelectedToken(firstToken);
|
|
25776
|
+
}
|
|
25777
|
+
}
|
|
25778
|
+
};
|
|
25779
|
+
return {
|
|
25780
|
+
assets: enabledChainSymbols,
|
|
25781
|
+
selectedChainId,
|
|
25782
|
+
handleChainChange,
|
|
25783
|
+
selectedToken,
|
|
25784
|
+
selectedChainName,
|
|
25785
|
+
handleTokenChange,
|
|
25786
|
+
isLoadingAssets,
|
|
25787
|
+
// Only promote default chain to top when there is an explicit default configured
|
|
25788
|
+
chainIdSortOrder: noDefaultSelection ? tokenTransferConfig.chainIdSortOrder : [
|
|
25789
|
+
validDefaultChainId,
|
|
25790
|
+
...tokenTransferConfig.chainIdSortOrder.filter(
|
|
25791
|
+
(id) => id !== validDefaultChainId
|
|
25792
|
+
)
|
|
25793
|
+
],
|
|
25794
|
+
priorityTokenSymbols: !noDefaultSelection && defaultSelectedToken ? [
|
|
25795
|
+
defaultSelectedToken,
|
|
25796
|
+
...tokenTransferConfig.priorityTokenSymbols.filter(
|
|
25797
|
+
(token) => token !== defaultSelectedToken
|
|
25798
|
+
)
|
|
25799
|
+
] : tokenTransferConfig.priorityTokenSymbols,
|
|
25800
|
+
popularTokenSymbols
|
|
25801
|
+
};
|
|
25802
|
+
};
|
|
25803
|
+
|
|
25804
|
+
// src/modals/WithdrawalModal/withdrawalHooks.tsx
|
|
25805
|
+
function useWithdrawalAssets(config) {
|
|
25806
|
+
const enableEmptyWithdrawalSelection = useFeatureGate(
|
|
25807
|
+
"enable-empty-withdrawal-selection"
|
|
25808
|
+
);
|
|
25809
|
+
const {
|
|
25810
|
+
assets,
|
|
25811
|
+
selectedChainId,
|
|
25812
|
+
handleChainChange,
|
|
25813
|
+
selectedToken,
|
|
25814
|
+
selectedChainName,
|
|
25815
|
+
handleTokenChange,
|
|
25816
|
+
chainIdSortOrder,
|
|
25817
|
+
popularTokenSymbols,
|
|
25818
|
+
priorityTokenSymbols,
|
|
25819
|
+
isLoadingAssets
|
|
25820
|
+
} = useTokenAndChainDropdown({
|
|
25821
|
+
defaultValues: {
|
|
25822
|
+
chainId: Number.parseInt(config.sourceChainId),
|
|
25823
|
+
token: config.defaultReceiveToken ?? config.sourceTokenSymbol
|
|
25824
|
+
},
|
|
25825
|
+
isWithdrawal: true,
|
|
25826
|
+
noDefaultSelection: enableEmptyWithdrawalSelection
|
|
25827
|
+
});
|
|
25828
|
+
const { addressBySymbolByChainId } = useTokenTransferConfig(true);
|
|
25829
|
+
return {
|
|
25830
|
+
assets,
|
|
25831
|
+
selectedChainId,
|
|
25832
|
+
handleChainChange,
|
|
25833
|
+
selectedToken,
|
|
25834
|
+
selectedChainName,
|
|
25835
|
+
handleTokenChange,
|
|
25836
|
+
chainIdSortOrder,
|
|
25837
|
+
popularTokenSymbols,
|
|
25838
|
+
priorityTokenSymbols,
|
|
25839
|
+
isLoadingAssets,
|
|
25840
|
+
addressBySymbolByChainId
|
|
25999
25841
|
};
|
|
26000
25842
|
}
|
|
26001
25843
|
var useFrozenSourceTokenBalance = ({
|
|
26002
25844
|
isWithdrawing,
|
|
26003
25845
|
sourceTokenBalance
|
|
26004
25846
|
}) => {
|
|
26005
|
-
const frozenSourceTokenBalanceRef =
|
|
25847
|
+
const frozenSourceTokenBalanceRef = useRef20(null);
|
|
26006
25848
|
if (!isWithdrawing) {
|
|
26007
25849
|
frozenSourceTokenBalanceRef.current = null;
|
|
26008
25850
|
}
|
|
26009
25851
|
const displayedSourceTokenBalance = frozenSourceTokenBalanceRef.current ?? sourceTokenBalance;
|
|
26010
|
-
const freezeDisplayedSourceTokenBalance =
|
|
25852
|
+
const freezeDisplayedSourceTokenBalance = useCallback28((balance) => {
|
|
26011
25853
|
frozenSourceTokenBalanceRef.current = balance;
|
|
26012
25854
|
}, []);
|
|
26013
25855
|
return {
|
|
@@ -26015,14 +25857,306 @@ var useFrozenSourceTokenBalance = ({
|
|
|
26015
25857
|
freezeDisplayedSourceTokenBalance
|
|
26016
25858
|
};
|
|
26017
25859
|
};
|
|
26018
|
-
|
|
26019
|
-
|
|
25860
|
+
function useWithdrawalLogging({
|
|
25861
|
+
targetAssetFetchError,
|
|
25862
|
+
quoteErrorObject,
|
|
25863
|
+
isRisky,
|
|
25864
|
+
isRecipientBlacklisted,
|
|
25865
|
+
selectedChainId,
|
|
25866
|
+
selectedToken,
|
|
25867
|
+
recipientAddress,
|
|
25868
|
+
debouncedInputAmount,
|
|
25869
|
+
debouncedInputAmountUsd
|
|
25870
|
+
}) {
|
|
25871
|
+
const lastTargetAssetErrorRef = useRef20(null);
|
|
25872
|
+
const lastQuoteErrorRef = useRef20(null);
|
|
25873
|
+
const lastRiskyRecipientRef = useRef20(null);
|
|
25874
|
+
const lastBlacklistedRecipientRef = useRef20(null);
|
|
25875
|
+
useEffect41(() => {
|
|
25876
|
+
if (!targetAssetFetchError) {
|
|
25877
|
+
return;
|
|
25878
|
+
}
|
|
25879
|
+
const errorToLog = targetAssetFetchError instanceof Error ? targetAssetFetchError : new Error("Unknown target asset fetch error");
|
|
25880
|
+
const errorKey = `${errorToLog.message}:${selectedChainId}:${selectedToken}`;
|
|
25881
|
+
if (lastTargetAssetErrorRef.current === errorKey) {
|
|
25882
|
+
return;
|
|
25883
|
+
}
|
|
25884
|
+
logger.error("withdrawal:targetAssetFetchFailed", errorToLog, {
|
|
25885
|
+
chainId: selectedChainId,
|
|
25886
|
+
tokenSymbol: selectedToken
|
|
25887
|
+
});
|
|
25888
|
+
lastTargetAssetErrorRef.current = errorKey;
|
|
25889
|
+
}, [targetAssetFetchError, selectedChainId, selectedToken]);
|
|
25890
|
+
useEffect41(() => {
|
|
25891
|
+
if (!quoteErrorObject) {
|
|
25892
|
+
return;
|
|
25893
|
+
}
|
|
25894
|
+
const errorToLog = quoteErrorObject instanceof Error ? quoteErrorObject : new Error("Unknown withdrawal quote error");
|
|
25895
|
+
const errorKey = `${errorToLog.message}:${selectedChainId}:${selectedToken}:${recipientAddress}`;
|
|
25896
|
+
if (lastQuoteErrorRef.current === errorKey) {
|
|
25897
|
+
return;
|
|
25898
|
+
}
|
|
25899
|
+
logger.warn("withdrawal:quoteError", {
|
|
25900
|
+
chainId: selectedChainId,
|
|
25901
|
+
tokenSymbol: selectedToken,
|
|
25902
|
+
recipientAddress,
|
|
25903
|
+
withdrawalInputAmount: debouncedInputAmount,
|
|
25904
|
+
withdrawalAmountUSD: debouncedInputAmountUsd,
|
|
25905
|
+
errorMessage: errorToLog.message,
|
|
25906
|
+
errorName: errorToLog.name,
|
|
25907
|
+
errorStack: errorToLog.stack
|
|
25908
|
+
});
|
|
25909
|
+
lastQuoteErrorRef.current = errorKey;
|
|
25910
|
+
}, [
|
|
25911
|
+
quoteErrorObject,
|
|
25912
|
+
selectedChainId,
|
|
25913
|
+
selectedToken,
|
|
25914
|
+
recipientAddress,
|
|
25915
|
+
debouncedInputAmount,
|
|
25916
|
+
debouncedInputAmountUsd
|
|
25917
|
+
]);
|
|
25918
|
+
useEffect41(() => {
|
|
25919
|
+
if (!isRisky) {
|
|
25920
|
+
return;
|
|
25921
|
+
}
|
|
25922
|
+
const warningKey = `${recipientAddress}:${selectedChainId}`;
|
|
25923
|
+
if (lastRiskyRecipientRef.current === warningKey) {
|
|
25924
|
+
return;
|
|
25925
|
+
}
|
|
25926
|
+
logger.warn("withdrawal:riskyRecipientDetected", {
|
|
25927
|
+
recipientAddress,
|
|
25928
|
+
chainId: selectedChainId,
|
|
25929
|
+
tokenSymbol: selectedToken
|
|
25930
|
+
});
|
|
25931
|
+
lastRiskyRecipientRef.current = warningKey;
|
|
25932
|
+
}, [isRisky, recipientAddress, selectedChainId, selectedToken]);
|
|
25933
|
+
useEffect41(() => {
|
|
25934
|
+
if (!isRecipientBlacklisted) {
|
|
25935
|
+
return;
|
|
25936
|
+
}
|
|
25937
|
+
const warningKey = `${recipientAddress}:${selectedChainId}`;
|
|
25938
|
+
if (lastBlacklistedRecipientRef.current === warningKey) {
|
|
25939
|
+
return;
|
|
25940
|
+
}
|
|
25941
|
+
logger.warn("withdrawal:blacklistedRecipientDetected", {
|
|
25942
|
+
recipientAddress,
|
|
25943
|
+
chainId: selectedChainId,
|
|
25944
|
+
tokenSymbol: selectedToken
|
|
25945
|
+
});
|
|
25946
|
+
lastBlacklistedRecipientRef.current = warningKey;
|
|
25947
|
+
}, [isRecipientBlacklisted, recipientAddress, selectedChainId, selectedToken]);
|
|
25948
|
+
}
|
|
25949
|
+
|
|
25950
|
+
// src/modals/WithdrawalModal/useWithdrawal.ts
|
|
25951
|
+
import { useState as useState41 } from "react";
|
|
25952
|
+
|
|
25953
|
+
// src/hooks/useAutoClearState.ts
|
|
25954
|
+
import { useCallback as useCallback29, useEffect as useEffect42, useRef as useRef21, useState as useState40 } from "react";
|
|
25955
|
+
function useAutoClearState(initialValue = null) {
|
|
25956
|
+
const [state, setState] = useState40(initialValue);
|
|
25957
|
+
const timeoutRef = useRef21(void 0);
|
|
25958
|
+
useEffect42(() => {
|
|
25959
|
+
return () => {
|
|
25960
|
+
if (timeoutRef.current !== void 0) {
|
|
25961
|
+
clearTimeout(timeoutRef.current);
|
|
25962
|
+
}
|
|
25963
|
+
};
|
|
25964
|
+
}, []);
|
|
25965
|
+
return [
|
|
25966
|
+
state,
|
|
25967
|
+
useCallback29((newState, durationMs) => {
|
|
25968
|
+
if (timeoutRef.current) {
|
|
25969
|
+
clearTimeout(timeoutRef.current);
|
|
25970
|
+
timeoutRef.current = void 0;
|
|
25971
|
+
}
|
|
25972
|
+
setState(newState);
|
|
25973
|
+
if (durationMs !== void 0) {
|
|
25974
|
+
timeoutRef.current = setTimeout(() => setState(null), durationMs);
|
|
25975
|
+
}
|
|
25976
|
+
}, [])
|
|
25977
|
+
];
|
|
25978
|
+
}
|
|
25979
|
+
|
|
25980
|
+
// src/modals/WithdrawalModal/useWithdrawal.ts
|
|
25981
|
+
function generateSyntheticDepositAddress() {
|
|
25982
|
+
return "0x0000000000000000000000000000000000000001";
|
|
25983
|
+
}
|
|
25984
|
+
var SYNTHETIC_QUOTELESS_QUOTE_ID = "synthetic:quoteless-withdrawal";
|
|
25985
|
+
function useWithdrawal({
|
|
26020
25986
|
config,
|
|
26021
25987
|
withdrawalItem,
|
|
26022
|
-
|
|
26023
|
-
|
|
26024
|
-
|
|
26025
|
-
}
|
|
25988
|
+
onSuccess
|
|
25989
|
+
}) {
|
|
25990
|
+
const { t } = useFunkitTranslation();
|
|
25991
|
+
const { confirmCheckout, checkoutItem } = useCheckoutContext();
|
|
25992
|
+
const { refreshCheckoutHistory } = useCheckoutHistoryContext();
|
|
25993
|
+
const [error, setError] = useAutoClearState();
|
|
25994
|
+
const [isWithdrawing, setIsWithdrawing] = useState41(false);
|
|
25995
|
+
const [step, setStep] = useState41(null);
|
|
25996
|
+
const wagmiConfig = useConfig();
|
|
25997
|
+
const configType = isWalletWithdrawalConfig(config) ? "wallet" : isCustomWithdrawalConfig(config) ? "custom" : "unknown";
|
|
25998
|
+
const handleWithdrawal = useEffectEvent(
|
|
25999
|
+
async (formData) => {
|
|
26000
|
+
const baseLogContext = {
|
|
26001
|
+
configType,
|
|
26002
|
+
withdrawalId: withdrawalItem?.id ?? null,
|
|
26003
|
+
destinationAddress: formData.destinationAddress,
|
|
26004
|
+
chainId: formData.chainId,
|
|
26005
|
+
tokenSymbol: formData.tokenSymbol,
|
|
26006
|
+
quoteId: formData.quote?.baseQuote.quoteId ?? null
|
|
26007
|
+
};
|
|
26008
|
+
let customCallbackFailed = false;
|
|
26009
|
+
async function walletWithdrawal(walletConfig) {
|
|
26010
|
+
if (!formData.quote) {
|
|
26011
|
+
throw new Error("Missing quote for wallet withdrawal");
|
|
26012
|
+
}
|
|
26013
|
+
let preTxs = [];
|
|
26014
|
+
if (walletConfig.preWithdrawalAction) {
|
|
26015
|
+
customCallbackFailed = true;
|
|
26016
|
+
preTxs = await walletConfig.preWithdrawalAction({
|
|
26017
|
+
quoteId: formData.quote.baseQuote.quoteId,
|
|
26018
|
+
funQuote: formData.quote,
|
|
26019
|
+
targetAssetAddress: formData.tokenAddress,
|
|
26020
|
+
targetChainId: formData.chainId,
|
|
26021
|
+
destinationAddress: formData.destinationAddress,
|
|
26022
|
+
customerData: formData.customerData,
|
|
26023
|
+
userInputAmount: formData.userInputAmount,
|
|
26024
|
+
withdrawalUSD: formData.withdrawalUSD
|
|
26025
|
+
});
|
|
26026
|
+
customCallbackFailed = false;
|
|
26027
|
+
}
|
|
26028
|
+
const txHash = await confirmCheckout(
|
|
26029
|
+
formData.quote,
|
|
26030
|
+
setStep,
|
|
26031
|
+
walletConfig.wallet,
|
|
26032
|
+
preTxs
|
|
26033
|
+
);
|
|
26034
|
+
withdrawalItem?.initSettings.onWithdrawalConfirmation?.(
|
|
26035
|
+
formData.destinationAddress,
|
|
26036
|
+
formData
|
|
26037
|
+
);
|
|
26038
|
+
if (!txHash) {
|
|
26039
|
+
const invalidTxHashError = new Error(
|
|
26040
|
+
"Invalid txHash - unable to proceed with withdrawal"
|
|
26041
|
+
);
|
|
26042
|
+
logger.error("withdrawal:missingTxHash", invalidTxHashError, {
|
|
26043
|
+
...baseLogContext,
|
|
26044
|
+
stepMessage: step
|
|
26045
|
+
});
|
|
26046
|
+
throw invalidTxHashError;
|
|
26047
|
+
}
|
|
26048
|
+
return txHash;
|
|
26049
|
+
}
|
|
26050
|
+
async function callbackWithdrawal(customConfig) {
|
|
26051
|
+
const quoteId = formData.quote?.baseQuote.quoteId ?? SYNTHETIC_QUOTELESS_QUOTE_ID;
|
|
26052
|
+
customCallbackFailed = true;
|
|
26053
|
+
const callbackResult = await customConfig.withdrawCallback({
|
|
26054
|
+
quoteId,
|
|
26055
|
+
funQuote: formData.quote ?? null,
|
|
26056
|
+
targetAssetAddress: formData.tokenAddress,
|
|
26057
|
+
targetChainId: formData.chainId,
|
|
26058
|
+
destinationAddress: formData.destinationAddress,
|
|
26059
|
+
customerData: formData.customerData,
|
|
26060
|
+
userInputAmount: formData.userInputAmount,
|
|
26061
|
+
withdrawalUSD: formData.withdrawalUSD
|
|
26062
|
+
});
|
|
26063
|
+
customCallbackFailed = false;
|
|
26064
|
+
withdrawalItem?.initSettings.onWithdrawalConfirmation?.(
|
|
26065
|
+
quoteId,
|
|
26066
|
+
formData
|
|
26067
|
+
);
|
|
26068
|
+
if (callbackResult) {
|
|
26069
|
+
logger.log("directExecutionCheckoutConfirmed", {
|
|
26070
|
+
depositAddressOrHash: callbackResult
|
|
26071
|
+
});
|
|
26072
|
+
checkoutItem?.initSettings.onConfirmation?.(callbackResult);
|
|
26073
|
+
refreshCheckoutHistory();
|
|
26074
|
+
}
|
|
26075
|
+
return callbackResult ? callbackResult : generateSyntheticDepositAddress();
|
|
26076
|
+
}
|
|
26077
|
+
try {
|
|
26078
|
+
setIsWithdrawing(true);
|
|
26079
|
+
const onBeforeSign = isWalletWithdrawalConfig(config) || isCustomWithdrawalConfig(config) ? config.onBeforeSign : void 0;
|
|
26080
|
+
if (onBeforeSign) {
|
|
26081
|
+
logger.info("withdrawal:onBeforeSign", baseLogContext);
|
|
26082
|
+
customCallbackFailed = true;
|
|
26083
|
+
await onBeforeSign();
|
|
26084
|
+
customCallbackFailed = false;
|
|
26085
|
+
}
|
|
26086
|
+
let txHash;
|
|
26087
|
+
if (isWalletWithdrawalConfig(config)) {
|
|
26088
|
+
txHash = await walletWithdrawal(config);
|
|
26089
|
+
} else if (isCustomWithdrawalConfig(config)) {
|
|
26090
|
+
txHash = await callbackWithdrawal(config);
|
|
26091
|
+
} else {
|
|
26092
|
+
const invalidConfigError = new Error("Invalid withdrawal config");
|
|
26093
|
+
logger.error("withdrawal:invalidConfig", invalidConfigError, {
|
|
26094
|
+
...baseLogContext,
|
|
26095
|
+
providedConfigKeys: Object.keys(config ?? {})
|
|
26096
|
+
});
|
|
26097
|
+
throw invalidConfigError;
|
|
26098
|
+
}
|
|
26099
|
+
setError(null);
|
|
26100
|
+
logger.info("withdrawal:success", {
|
|
26101
|
+
...baseLogContext,
|
|
26102
|
+
stepMessage: step,
|
|
26103
|
+
withdrawalAmountUSD: formData.withdrawalUSD
|
|
26104
|
+
});
|
|
26105
|
+
onSuccess?.(formData, txHash);
|
|
26106
|
+
return txHash;
|
|
26107
|
+
} catch (err) {
|
|
26108
|
+
const caughtError = err instanceof Error ? err : new Error("Unknown withdrawal error");
|
|
26109
|
+
const isNestedError = caughtError.message === "Invalid txHash - unable to proceed with withdrawal" || caughtError.message === "Invalid withdrawal config";
|
|
26110
|
+
if (!isNestedError) {
|
|
26111
|
+
logger.error("withdrawal:executionFailed", caughtError, {
|
|
26112
|
+
...baseLogContext,
|
|
26113
|
+
stepMessage: step
|
|
26114
|
+
});
|
|
26115
|
+
}
|
|
26116
|
+
const error2 = customCallbackFailed ? {
|
|
26117
|
+
message: caughtError.message,
|
|
26118
|
+
type: "hint",
|
|
26119
|
+
code: "GENERIC_ERROR" /* GENERIC_ERROR */,
|
|
26120
|
+
durationMs: 1e4
|
|
26121
|
+
} : await toCheckoutConfirmationError(t, err, wagmiConfig);
|
|
26122
|
+
logger.info("toCheckoutConfirmationError:resulting_error", error2);
|
|
26123
|
+
setError(error2, error2.durationMs);
|
|
26124
|
+
withdrawalItem?.initSettings.onWithdrawalError?.({
|
|
26125
|
+
type: "error",
|
|
26126
|
+
message: err.message,
|
|
26127
|
+
metadata: err
|
|
26128
|
+
});
|
|
26129
|
+
return null;
|
|
26130
|
+
} finally {
|
|
26131
|
+
setIsWithdrawing(false);
|
|
26132
|
+
setStep(null);
|
|
26133
|
+
}
|
|
26134
|
+
}
|
|
26135
|
+
);
|
|
26136
|
+
return {
|
|
26137
|
+
withdrawalError: error,
|
|
26138
|
+
stepMessage: step,
|
|
26139
|
+
handleWithdrawal,
|
|
26140
|
+
isWithdrawing
|
|
26141
|
+
};
|
|
26142
|
+
}
|
|
26143
|
+
|
|
26144
|
+
// src/modals/WithdrawalModal/WithdrawalContent.tsx
|
|
26145
|
+
var PRICE_REFRESH_INTERVAL = 6e4;
|
|
26146
|
+
var FALLBACK_FEES = {
|
|
26147
|
+
marketMakerFeeUsd: 0,
|
|
26148
|
+
liquidityProviderFeeUsd: 0,
|
|
26149
|
+
eoaWalletFeeUsd: 0,
|
|
26150
|
+
paymentMethod: PaymentMethod.ACCOUNT_BALANCE,
|
|
26151
|
+
eoaWalletFeeToken: 0,
|
|
26152
|
+
nativeCurrencySymbol: "",
|
|
26153
|
+
totalFeesUsd: 0,
|
|
26154
|
+
totalFeesTokenWithoutGas: 0
|
|
26155
|
+
};
|
|
26156
|
+
function useCommonWithdrawalFlow({
|
|
26157
|
+
config,
|
|
26158
|
+
withdrawalItem
|
|
26159
|
+
}) {
|
|
26026
26160
|
const { t } = useFunkitTranslation();
|
|
26027
26161
|
const fallbackBalance = safeEvaluateWithdrawalSourceTokenBalance(
|
|
26028
26162
|
withdrawalItem?.withdrawalSourceTokenBalance
|
|
@@ -26032,25 +26166,10 @@ var WithdrawContent = ({
|
|
|
26032
26166
|
);
|
|
26033
26167
|
const token = config.sourceTokenSymbol;
|
|
26034
26168
|
const [recipientAddress, setRecipientAddress] = useState42("");
|
|
26035
|
-
const [withdrawalInputAmount, setWithdrawalInputAmount] = useState42("");
|
|
26036
|
-
const {
|
|
26037
|
-
isLighterSecure,
|
|
26038
|
-
isLighterFast,
|
|
26039
|
-
isUnifiedTradingMode,
|
|
26040
|
-
connectedAddress,
|
|
26041
|
-
lighterBalances,
|
|
26042
|
-
lighterAssets,
|
|
26043
|
-
lighterFastUnstakedFee,
|
|
26044
|
-
invalidateLighterAccount
|
|
26045
|
-
} = useLighterWithdrawal(config, setRecipientAddress);
|
|
26046
26169
|
const { address: connectedWalletAddress } = useAccount();
|
|
26047
|
-
const
|
|
26170
|
+
const [withdrawalInputAmount, setWithdrawalInputAmount] = useState42("");
|
|
26048
26171
|
const [debouncedInputAmount] = useDebounce(withdrawalInputAmount, 300);
|
|
26049
26172
|
const isAmountSettled = withdrawalInputAmount === debouncedInputAmount;
|
|
26050
|
-
const quoteInputAmount = deductLighterUnstakedFee(
|
|
26051
|
-
debouncedInputAmount,
|
|
26052
|
-
lighterFastUnstakedFee
|
|
26053
|
-
);
|
|
26054
26173
|
const {
|
|
26055
26174
|
updateTargetAsset,
|
|
26056
26175
|
updateTargetAssetAmount,
|
|
@@ -26070,15 +26189,12 @@ var WithdrawContent = ({
|
|
|
26070
26189
|
isLoadingAssets,
|
|
26071
26190
|
addressBySymbolByChainId
|
|
26072
26191
|
} = useWithdrawalAssets(config);
|
|
26073
|
-
const
|
|
26074
|
-
const {
|
|
26075
|
-
|
|
26076
|
-
|
|
26077
|
-
|
|
26078
|
-
|
|
26079
|
-
enabled: isLighterSecure
|
|
26080
|
-
});
|
|
26081
|
-
const sourceTokenUsdPrice = isLighterSecure ? lighterSecureSourceTokenUsdPrice : 1;
|
|
26192
|
+
const { apiKey, uiCustomizations } = useFunkitConfig();
|
|
26193
|
+
const {
|
|
26194
|
+
data: isRisky,
|
|
26195
|
+
isLoading: isCheckingAddressRisk,
|
|
26196
|
+
error: riskCheckError
|
|
26197
|
+
} = useWithdrawalRisk(apiKey, recipientAddress, selectedChainId);
|
|
26082
26198
|
const targetAssetAddress = selectedChainId !== void 0 && selectedToken ? addressBySymbolByChainId[selectedChainId]?.[selectedToken] : void 0;
|
|
26083
26199
|
const { error: targetAssetFetchError, price: targetUnitPrice } = useAssetAddressPrice({
|
|
26084
26200
|
chainId: selectedChainId?.toString(),
|
|
@@ -26086,44 +26202,90 @@ var WithdrawContent = ({
|
|
|
26086
26202
|
symbol: selectedToken,
|
|
26087
26203
|
refetchInterval: PRICE_REFRESH_INTERVAL
|
|
26088
26204
|
});
|
|
26089
|
-
const
|
|
26090
|
-
quoteInputAmount,
|
|
26091
|
-
sourceTokenUsdPrice
|
|
26092
|
-
);
|
|
26093
|
-
const targetAssetAmount = targetUnitPrice && debouncedInputAmountUsd !== void 0 ? debouncedInputAmountUsd / targetUnitPrice : void 0;
|
|
26094
|
-
useEffect42(() => {
|
|
26095
|
-
updateWithdrawalSourceAssetAmount(quoteInputAmount);
|
|
26096
|
-
}, [quoteInputAmount, updateWithdrawalSourceAssetAmount]);
|
|
26097
|
-
useEffect42(() => {
|
|
26098
|
-
setTimeout(() => {
|
|
26099
|
-
updateTargetAssetAmount(targetAssetAmount ?? 0);
|
|
26100
|
-
}, 0);
|
|
26101
|
-
}, [targetAssetAmount, updateTargetAssetAmount]);
|
|
26102
|
-
useEffect42(() => {
|
|
26103
|
-
if (!targetAssetAddress || !selectedChainId || !selectedToken) {
|
|
26104
|
-
return;
|
|
26105
|
-
}
|
|
26106
|
-
updateTargetAsset({
|
|
26107
|
-
targetAsset: targetAssetAddress,
|
|
26108
|
-
targetChain: selectedChainId.toString(),
|
|
26109
|
-
targetAssetTicker: selectedToken,
|
|
26110
|
-
targetAssetMinAmount: 0,
|
|
26111
|
-
iconSrc: getTokenIconUrl(selectedToken)
|
|
26112
|
-
});
|
|
26113
|
-
}, [targetAssetAddress, updateTargetAsset, selectedChainId, selectedToken]);
|
|
26114
|
-
const { apiKey, uiCustomizations } = useFunkitConfig();
|
|
26115
|
-
const {
|
|
26116
|
-
data: isRisky,
|
|
26117
|
-
isLoading: isCheckingAddressRisk,
|
|
26118
|
-
error: riskCheckError
|
|
26119
|
-
} = useWithdrawalRisk(apiKey, recipientAddress, selectedChainId);
|
|
26120
|
-
const { handleWithdrawal, isWithdrawing, withdrawalError } = useWithdrawal({
|
|
26205
|
+
const isRelaySelfTransfer = isNoOpSelfWithdrawal({
|
|
26121
26206
|
config,
|
|
26122
|
-
|
|
26123
|
-
|
|
26124
|
-
|
|
26125
|
-
|
|
26126
|
-
|
|
26207
|
+
recipientAddress,
|
|
26208
|
+
selectedChainId,
|
|
26209
|
+
destinationTokenAddress: targetAssetAddress
|
|
26210
|
+
});
|
|
26211
|
+
const isRecipientBlacklisted = useIsBlacklistedWithdrawalAddress(recipientAddress);
|
|
26212
|
+
const normalizedSelectedToken = selectedToken?.toUpperCase();
|
|
26213
|
+
const { checkoutItem } = useCheckoutContext();
|
|
26214
|
+
const checkoutConfig = checkoutItem?.initSettings.config;
|
|
26215
|
+
const isWithdrawalBannerVisible = message && (!expireAtMs || Date.now() <= expireAtMs);
|
|
26216
|
+
const isUsdceSelected = normalizedSelectedToken === "USDC.E";
|
|
26217
|
+
const showBannerSection = isWithdrawalBannerVisible || isUsdceSelected;
|
|
26218
|
+
const isRiskyAddress = !!isRisky && !isCheckingAddressRisk;
|
|
26219
|
+
return {
|
|
26220
|
+
t,
|
|
26221
|
+
fallbackBalance,
|
|
26222
|
+
selectedSourceToken,
|
|
26223
|
+
setSelectedSourceToken,
|
|
26224
|
+
token,
|
|
26225
|
+
recipientAddress,
|
|
26226
|
+
setRecipientAddress,
|
|
26227
|
+
connectedWalletAddress,
|
|
26228
|
+
withdrawalInputAmount,
|
|
26229
|
+
setWithdrawalInputAmount,
|
|
26230
|
+
debouncedInputAmount,
|
|
26231
|
+
isAmountSettled,
|
|
26232
|
+
updateTargetAsset,
|
|
26233
|
+
updateTargetAssetAmount,
|
|
26234
|
+
updateWithdrawalSourceAssetAmount,
|
|
26235
|
+
assets,
|
|
26236
|
+
selectedChainId,
|
|
26237
|
+
handleChainChange,
|
|
26238
|
+
selectedToken,
|
|
26239
|
+
handleTokenChange,
|
|
26240
|
+
selectedChainName,
|
|
26241
|
+
chainIdSortOrder,
|
|
26242
|
+
popularTokenSymbols,
|
|
26243
|
+
priorityTokenSymbols,
|
|
26244
|
+
isLoadingAssets,
|
|
26245
|
+
apiKey,
|
|
26246
|
+
uiCustomizations,
|
|
26247
|
+
isRisky,
|
|
26248
|
+
riskCheckError,
|
|
26249
|
+
targetAssetAddress,
|
|
26250
|
+
targetAssetFetchError,
|
|
26251
|
+
targetUnitPrice,
|
|
26252
|
+
isRelaySelfTransfer,
|
|
26253
|
+
isRecipientBlacklisted,
|
|
26254
|
+
checkoutConfig,
|
|
26255
|
+
isUsdceSelected,
|
|
26256
|
+
showBannerSection,
|
|
26257
|
+
isRiskyAddress
|
|
26258
|
+
};
|
|
26259
|
+
}
|
|
26260
|
+
function useClientSpecificWithdrawalFlow({
|
|
26261
|
+
config,
|
|
26262
|
+
onContinue,
|
|
26263
|
+
apiKey,
|
|
26264
|
+
connectedWalletAddress,
|
|
26265
|
+
selectedSourceToken,
|
|
26266
|
+
recipientAddress,
|
|
26267
|
+
withdrawalInputAmount,
|
|
26268
|
+
setRecipientAddress,
|
|
26269
|
+
handleWithdrawal,
|
|
26270
|
+
withdrawalError
|
|
26271
|
+
}) {
|
|
26272
|
+
const {
|
|
26273
|
+
isLighterSecure,
|
|
26274
|
+
isLighterFast,
|
|
26275
|
+
isUnifiedTradingMode,
|
|
26276
|
+
connectedAddress,
|
|
26277
|
+
lighterBalances,
|
|
26278
|
+
lighterAssets,
|
|
26279
|
+
lighterFastUnstakedFee,
|
|
26280
|
+
invalidateLighterAccount
|
|
26281
|
+
} = useLighterWithdrawal(config, setRecipientAddress);
|
|
26282
|
+
const lighterSecureMainnetAddress = isLighterSecure ? getLighterSecureMainnetAddress(selectedSourceToken) : void 0;
|
|
26283
|
+
const { price: lighterSecureSourceTokenUsdPrice } = useAssetAddressPrice({
|
|
26284
|
+
chainId: config.sourceChainId,
|
|
26285
|
+
assetTokenAddress: lighterSecureMainnetAddress,
|
|
26286
|
+
symbol: selectedSourceToken,
|
|
26287
|
+
refetchInterval: PRICE_REFRESH_INTERVAL,
|
|
26288
|
+
enabled: isLighterSecure
|
|
26127
26289
|
});
|
|
26128
26290
|
const {
|
|
26129
26291
|
isL1FallbackAvailable,
|
|
@@ -26137,63 +26299,18 @@ var WithdrawContent = ({
|
|
|
26137
26299
|
// `|` delimiter keeps distinct (token, amount) pairs from colliding.
|
|
26138
26300
|
resetKey: `${selectedSourceToken}|${withdrawalInputAmount}`
|
|
26139
26301
|
});
|
|
26140
|
-
const { displayedSourceTokenBalance, freezeDisplayedSourceTokenBalance } = useFrozenSourceTokenBalance({
|
|
26141
|
-
isWithdrawing,
|
|
26142
|
-
sourceTokenBalance
|
|
26143
|
-
});
|
|
26144
26302
|
const sourceTokenOptions = useLighterSourceTokenOptions(
|
|
26145
26303
|
config,
|
|
26146
26304
|
apiKey,
|
|
26147
26305
|
lighterAssets,
|
|
26148
26306
|
isUnifiedTradingMode
|
|
26149
26307
|
);
|
|
26150
|
-
const normalizedSelectedToken = selectedToken?.toUpperCase();
|
|
26151
|
-
const { checkoutItem } = useCheckoutContext();
|
|
26152
|
-
const checkoutConfig = checkoutItem?.initSettings.config;
|
|
26153
|
-
const {
|
|
26154
|
-
isValidAddress,
|
|
26155
|
-
isValidAddressAndChain,
|
|
26156
|
-
isWithdrawAmountValid,
|
|
26157
|
-
isWithdrawAmountTooLow,
|
|
26158
|
-
isWithdrawAmountTooHigh,
|
|
26159
|
-
isWithdrawAmountAboveBalance,
|
|
26160
|
-
minWithdrawalDisplayValue
|
|
26161
|
-
} = isValidWithdrawal({
|
|
26162
|
-
config,
|
|
26163
|
-
checkoutConfig,
|
|
26164
|
-
withdrawalInputAmount,
|
|
26165
|
-
// Fall back to 1 while Lighter Secure's spot price is loading: that flow
|
|
26166
|
-
// gates on `getMinWithdrawalAmount` (per-token) which takes priority over
|
|
26167
|
-
// the USD-min branch, so the placeholder is never consumed in practice.
|
|
26168
|
-
sourceTokenUsdPrice: sourceTokenUsdPrice ?? 1,
|
|
26169
|
-
sourceTokenBalance: displayedSourceTokenBalance,
|
|
26170
|
-
recipientAddress,
|
|
26171
|
-
selectedSourceToken,
|
|
26172
|
-
selectedChainId
|
|
26173
|
-
});
|
|
26174
|
-
const isRelaySelfTransfer = isNoOpSelfWithdrawal({
|
|
26175
|
-
config,
|
|
26176
|
-
recipientAddress,
|
|
26177
|
-
selectedChainId,
|
|
26178
|
-
destinationTokenAddress: targetAssetAddress
|
|
26179
|
-
});
|
|
26180
|
-
const {
|
|
26181
|
-
isLoading: isQuoteLoading,
|
|
26182
|
-
data: quote,
|
|
26183
|
-
error: quoteErrorObject,
|
|
26184
|
-
quoteEnabled
|
|
26185
|
-
} = useWithdrawalQuote({
|
|
26186
|
-
config,
|
|
26187
|
-
recipientAddress: isLighterSecure ? "" : recipientAddress,
|
|
26188
|
-
selectedChainId: selectedChainId?.toString(),
|
|
26189
|
-
selectedTokenAddress: isLighterSecure ? void 0 : targetAssetAddress,
|
|
26190
|
-
selectedTokenSymbol: isLighterSecure ? void 0 : selectedToken,
|
|
26191
|
-
// Quote only when risk is clear (fail-closed), the amount is valid and
|
|
26192
|
-
// settled, and it isn't a no-op self-transfer Relay would reject.
|
|
26193
|
-
isEnabled: isRisky === false && isWithdrawAmountValid && isAmountSettled && !isRelaySelfTransfer
|
|
26194
|
-
});
|
|
26195
26308
|
const lighterAssetIndex = isLighterSecure ? resolveLighterAssetIndex(lighterAssets, selectedSourceToken) : void 0;
|
|
26196
|
-
const submitLighterSecureWithdrawal = (
|
|
26309
|
+
const submitLighterSecureWithdrawal = ({
|
|
26310
|
+
sourceTokenBalance,
|
|
26311
|
+
sourceTokenUsdPrice,
|
|
26312
|
+
freezeDisplayedSourceTokenBalance
|
|
26313
|
+
}) => {
|
|
26197
26314
|
if (lighterAssetIndex === void 0) {
|
|
26198
26315
|
return;
|
|
26199
26316
|
}
|
|
@@ -26219,7 +26336,9 @@ var WithdrawContent = ({
|
|
|
26219
26336
|
userInputAmount: withdrawalInputAmount
|
|
26220
26337
|
});
|
|
26221
26338
|
};
|
|
26222
|
-
const submitLighterL1Withdrawal = (
|
|
26339
|
+
const submitLighterL1Withdrawal = ({
|
|
26340
|
+
sourceTokenUsdPrice
|
|
26341
|
+
}) => {
|
|
26223
26342
|
if (lighterAssetIndex === void 0 || lighterSecureMainnetAddress === void 0 || !isAddress(recipientAddress)) {
|
|
26224
26343
|
return;
|
|
26225
26344
|
}
|
|
@@ -26252,13 +26371,159 @@ var WithdrawContent = ({
|
|
|
26252
26371
|
}
|
|
26253
26372
|
});
|
|
26254
26373
|
};
|
|
26255
|
-
const
|
|
26374
|
+
const resolveClientSubmit = () => {
|
|
26256
26375
|
if (isL1FallbackAvailable) {
|
|
26257
|
-
submitLighterL1Withdrawal
|
|
26258
|
-
return;
|
|
26376
|
+
return submitLighterL1Withdrawal;
|
|
26259
26377
|
}
|
|
26260
26378
|
if (isLighterSecure) {
|
|
26261
|
-
submitLighterSecureWithdrawal
|
|
26379
|
+
return submitLighterSecureWithdrawal;
|
|
26380
|
+
}
|
|
26381
|
+
return void 0;
|
|
26382
|
+
};
|
|
26383
|
+
const submitClientWithdrawal = resolveClientSubmit();
|
|
26384
|
+
const polymarketSourceAddress = isPolymarketCustomer(apiKey) && connectedWalletAddress ? derivePolymarketProxyAddress(connectedWalletAddress) : void 0;
|
|
26385
|
+
const clientSourceTokenBalance = lighterBalances[selectedSourceToken.toUpperCase()];
|
|
26386
|
+
const clientSourceTokenUsdPrice = isLighterSecure ? lighterSecureSourceTokenUsdPrice : 1;
|
|
26387
|
+
const clientFlatFeeTokens = lighterFastUnstakedFee;
|
|
26388
|
+
return {
|
|
26389
|
+
isLighterSecure,
|
|
26390
|
+
isLighterFast,
|
|
26391
|
+
connectedAddress,
|
|
26392
|
+
invalidateLighterAccount,
|
|
26393
|
+
isL1FallbackAvailable,
|
|
26394
|
+
isSubmittingL1,
|
|
26395
|
+
l1FallbackError,
|
|
26396
|
+
sourceTokenOptions,
|
|
26397
|
+
lighterAssetIndex,
|
|
26398
|
+
submitClientWithdrawal,
|
|
26399
|
+
polymarketSourceAddress,
|
|
26400
|
+
clientSourceTokenBalance,
|
|
26401
|
+
clientSourceTokenUsdPrice,
|
|
26402
|
+
clientFlatFeeTokens
|
|
26403
|
+
};
|
|
26404
|
+
}
|
|
26405
|
+
function usePostClientCommonWithdrawalFlow({
|
|
26406
|
+
config,
|
|
26407
|
+
onSwitchToSecure,
|
|
26408
|
+
bottomBarId,
|
|
26409
|
+
disableSubmit,
|
|
26410
|
+
t,
|
|
26411
|
+
fallbackBalance,
|
|
26412
|
+
selectedSourceToken,
|
|
26413
|
+
token,
|
|
26414
|
+
recipientAddress,
|
|
26415
|
+
withdrawalInputAmount,
|
|
26416
|
+
debouncedInputAmount,
|
|
26417
|
+
isAmountSettled,
|
|
26418
|
+
updateTargetAsset,
|
|
26419
|
+
updateTargetAssetAmount,
|
|
26420
|
+
updateWithdrawalSourceAssetAmount,
|
|
26421
|
+
selectedChainId,
|
|
26422
|
+
selectedToken,
|
|
26423
|
+
selectedChainName,
|
|
26424
|
+
isRisky,
|
|
26425
|
+
riskCheckError,
|
|
26426
|
+
targetAssetAddress,
|
|
26427
|
+
targetAssetFetchError,
|
|
26428
|
+
targetUnitPrice,
|
|
26429
|
+
isRelaySelfTransfer,
|
|
26430
|
+
isRecipientBlacklisted,
|
|
26431
|
+
checkoutConfig,
|
|
26432
|
+
isLighterSecure,
|
|
26433
|
+
isLighterFast,
|
|
26434
|
+
clientSourceTokenBalance,
|
|
26435
|
+
clientSourceTokenUsdPrice: sourceTokenUsdPrice,
|
|
26436
|
+
clientFlatFeeTokens,
|
|
26437
|
+
isL1FallbackAvailable,
|
|
26438
|
+
isSubmittingL1,
|
|
26439
|
+
l1FallbackError,
|
|
26440
|
+
lighterAssetIndex,
|
|
26441
|
+
submitClientWithdrawal,
|
|
26442
|
+
polymarketSourceAddress,
|
|
26443
|
+
handleWithdrawal,
|
|
26444
|
+
isWithdrawing,
|
|
26445
|
+
withdrawalError
|
|
26446
|
+
}) {
|
|
26447
|
+
const sourceTokenBalance = clientSourceTokenBalance ?? fallbackBalance;
|
|
26448
|
+
const { displayedSourceTokenBalance, freezeDisplayedSourceTokenBalance } = useFrozenSourceTokenBalance({
|
|
26449
|
+
isWithdrawing,
|
|
26450
|
+
sourceTokenBalance
|
|
26451
|
+
});
|
|
26452
|
+
const quoteInputAmount = deductFlatFee(
|
|
26453
|
+
debouncedInputAmount,
|
|
26454
|
+
clientFlatFeeTokens
|
|
26455
|
+
);
|
|
26456
|
+
const debouncedInputAmountUsd = toUsdValue(
|
|
26457
|
+
quoteInputAmount,
|
|
26458
|
+
sourceTokenUsdPrice
|
|
26459
|
+
);
|
|
26460
|
+
const targetAssetAmount = targetUnitPrice && debouncedInputAmountUsd !== void 0 ? debouncedInputAmountUsd / targetUnitPrice : void 0;
|
|
26461
|
+
useEffect43(() => {
|
|
26462
|
+
updateWithdrawalSourceAssetAmount(quoteInputAmount);
|
|
26463
|
+
}, [quoteInputAmount, updateWithdrawalSourceAssetAmount]);
|
|
26464
|
+
useEffect43(() => {
|
|
26465
|
+
if (!targetAssetAddress || !selectedChainId || !selectedToken) {
|
|
26466
|
+
return;
|
|
26467
|
+
}
|
|
26468
|
+
updateTargetAsset({
|
|
26469
|
+
targetAsset: targetAssetAddress,
|
|
26470
|
+
targetChain: selectedChainId.toString(),
|
|
26471
|
+
targetAssetTicker: selectedToken,
|
|
26472
|
+
targetAssetMinAmount: 0,
|
|
26473
|
+
iconSrc: getTokenIconUrl(selectedToken)
|
|
26474
|
+
});
|
|
26475
|
+
}, [targetAssetAddress, updateTargetAsset, selectedChainId, selectedToken]);
|
|
26476
|
+
useEffect43(() => {
|
|
26477
|
+
setTimeout(() => {
|
|
26478
|
+
updateTargetAssetAmount(targetAssetAmount ?? 0);
|
|
26479
|
+
}, 0);
|
|
26480
|
+
}, [targetAssetAmount, updateTargetAssetAmount]);
|
|
26481
|
+
const {
|
|
26482
|
+
isValidAddress,
|
|
26483
|
+
isValidAddressAndChain,
|
|
26484
|
+
isWithdrawAmountValid,
|
|
26485
|
+
isWithdrawAmountTooLow,
|
|
26486
|
+
isWithdrawAmountTooHigh,
|
|
26487
|
+
isWithdrawAmountAboveBalance,
|
|
26488
|
+
minWithdrawalDisplayValue
|
|
26489
|
+
} = isValidWithdrawal({
|
|
26490
|
+
config,
|
|
26491
|
+
checkoutConfig,
|
|
26492
|
+
withdrawalInputAmount,
|
|
26493
|
+
// Fall back to 1 while Lighter Secure's spot price is loading: that flow
|
|
26494
|
+
// gates on `getMinWithdrawalAmount` (per-token) which takes priority over
|
|
26495
|
+
// the USD-min branch, so the placeholder is never consumed in practice.
|
|
26496
|
+
sourceTokenUsdPrice: sourceTokenUsdPrice ?? 1,
|
|
26497
|
+
sourceTokenBalance: displayedSourceTokenBalance,
|
|
26498
|
+
recipientAddress,
|
|
26499
|
+
selectedSourceToken,
|
|
26500
|
+
selectedChainId
|
|
26501
|
+
});
|
|
26502
|
+
const {
|
|
26503
|
+
isLoading: isQuoteLoading,
|
|
26504
|
+
data: quote,
|
|
26505
|
+
error: quoteErrorObject,
|
|
26506
|
+
quoteEnabled
|
|
26507
|
+
} = useWithdrawalQuote({
|
|
26508
|
+
config,
|
|
26509
|
+
recipientAddress: isLighterSecure ? "" : recipientAddress,
|
|
26510
|
+
selectedChainId: selectedChainId?.toString(),
|
|
26511
|
+
selectedTokenAddress: isLighterSecure ? void 0 : targetAssetAddress,
|
|
26512
|
+
selectedTokenSymbol: isLighterSecure ? void 0 : selectedToken,
|
|
26513
|
+
// Quote only when risk is clear (fail-closed), the amount is valid and
|
|
26514
|
+
// settled, and it isn't a no-op self-transfer Relay would reject.
|
|
26515
|
+
isEnabled: isRisky === false && isWithdrawAmountValid && // A cleared input parses to 0, which min-0 configs count as "valid" —
|
|
26516
|
+
// without this gate, erasing the amount re-enables the quote against the
|
|
26517
|
+
// still-stale checkout state and refires the previous request.
|
|
26518
|
+
Number(withdrawalInputAmount) > 0 && isAmountSettled && !isRelaySelfTransfer
|
|
26519
|
+
});
|
|
26520
|
+
const handleSubmit = () => {
|
|
26521
|
+
if (submitClientWithdrawal) {
|
|
26522
|
+
submitClientWithdrawal({
|
|
26523
|
+
sourceTokenBalance,
|
|
26524
|
+
sourceTokenUsdPrice,
|
|
26525
|
+
freezeDisplayedSourceTokenBalance
|
|
26526
|
+
});
|
|
26262
26527
|
return;
|
|
26263
26528
|
}
|
|
26264
26529
|
if (isQuoteLoading) {
|
|
@@ -26311,86 +26576,18 @@ var WithdrawContent = ({
|
|
|
26311
26576
|
quote: quote.finalEstimation
|
|
26312
26577
|
});
|
|
26313
26578
|
};
|
|
26314
|
-
const isRecipientBlacklisted = useIsBlacklistedWithdrawalAddress(recipientAddress);
|
|
26315
|
-
const polymarketSourceAddress = isPolymarketCustomer(apiKey) && connectedWalletAddress ? derivePolymarketProxyAddress(connectedWalletAddress) : void 0;
|
|
26316
26579
|
const isWithdrawingToSourceAddress = !!polymarketSourceAddress && recipientAddress.toLowerCase() === polymarketSourceAddress.toLowerCase();
|
|
26317
|
-
|
|
26318
|
-
|
|
26319
|
-
const lastRiskyRecipientRef = useRef21(null);
|
|
26320
|
-
const lastBlacklistedRecipientRef = useRef21(null);
|
|
26321
|
-
useEffect42(() => {
|
|
26322
|
-
if (!targetAssetFetchError) {
|
|
26323
|
-
return;
|
|
26324
|
-
}
|
|
26325
|
-
const errorToLog = targetAssetFetchError instanceof Error ? targetAssetFetchError : new Error("Unknown target asset fetch error");
|
|
26326
|
-
const errorKey = `${errorToLog.message}:${selectedChainId}:${selectedToken}`;
|
|
26327
|
-
if (lastTargetAssetErrorRef.current === errorKey) {
|
|
26328
|
-
return;
|
|
26329
|
-
}
|
|
26330
|
-
logger.error("withdrawal:targetAssetFetchFailed", errorToLog, {
|
|
26331
|
-
chainId: selectedChainId,
|
|
26332
|
-
tokenSymbol: selectedToken
|
|
26333
|
-
});
|
|
26334
|
-
lastTargetAssetErrorRef.current = errorKey;
|
|
26335
|
-
}, [targetAssetFetchError, selectedChainId, selectedToken]);
|
|
26336
|
-
useEffect42(() => {
|
|
26337
|
-
if (!quoteErrorObject) {
|
|
26338
|
-
return;
|
|
26339
|
-
}
|
|
26340
|
-
const errorToLog = quoteErrorObject instanceof Error ? quoteErrorObject : new Error("Unknown withdrawal quote error");
|
|
26341
|
-
const errorKey = `${errorToLog.message}:${selectedChainId}:${selectedToken}:${recipientAddress}`;
|
|
26342
|
-
if (lastQuoteErrorRef.current === errorKey) {
|
|
26343
|
-
return;
|
|
26344
|
-
}
|
|
26345
|
-
logger.warn("withdrawal:quoteError", {
|
|
26346
|
-
chainId: selectedChainId,
|
|
26347
|
-
tokenSymbol: selectedToken,
|
|
26348
|
-
recipientAddress,
|
|
26349
|
-
withdrawalInputAmount: debouncedInputAmount,
|
|
26350
|
-
withdrawalAmountUSD: debouncedInputAmountUsd,
|
|
26351
|
-
errorMessage: errorToLog.message,
|
|
26352
|
-
errorName: errorToLog.name,
|
|
26353
|
-
errorStack: errorToLog.stack
|
|
26354
|
-
});
|
|
26355
|
-
lastQuoteErrorRef.current = errorKey;
|
|
26356
|
-
}, [
|
|
26580
|
+
useWithdrawalLogging({
|
|
26581
|
+
targetAssetFetchError,
|
|
26357
26582
|
quoteErrorObject,
|
|
26583
|
+
isRisky,
|
|
26584
|
+
isRecipientBlacklisted,
|
|
26358
26585
|
selectedChainId,
|
|
26359
26586
|
selectedToken,
|
|
26360
26587
|
recipientAddress,
|
|
26361
26588
|
debouncedInputAmount,
|
|
26362
26589
|
debouncedInputAmountUsd
|
|
26363
|
-
|
|
26364
|
-
useEffect42(() => {
|
|
26365
|
-
if (!isRisky) {
|
|
26366
|
-
return;
|
|
26367
|
-
}
|
|
26368
|
-
const warningKey = `${recipientAddress}:${selectedChainId}`;
|
|
26369
|
-
if (lastRiskyRecipientRef.current === warningKey) {
|
|
26370
|
-
return;
|
|
26371
|
-
}
|
|
26372
|
-
logger.warn("withdrawal:riskyRecipientDetected", {
|
|
26373
|
-
recipientAddress,
|
|
26374
|
-
chainId: selectedChainId,
|
|
26375
|
-
tokenSymbol: selectedToken
|
|
26376
|
-
});
|
|
26377
|
-
lastRiskyRecipientRef.current = warningKey;
|
|
26378
|
-
}, [isRisky, recipientAddress, selectedChainId, selectedToken]);
|
|
26379
|
-
useEffect42(() => {
|
|
26380
|
-
if (!isRecipientBlacklisted) {
|
|
26381
|
-
return;
|
|
26382
|
-
}
|
|
26383
|
-
const warningKey = `${recipientAddress}:${selectedChainId}`;
|
|
26384
|
-
if (lastBlacklistedRecipientRef.current === warningKey) {
|
|
26385
|
-
return;
|
|
26386
|
-
}
|
|
26387
|
-
logger.warn("withdrawal:blacklistedRecipientDetected", {
|
|
26388
|
-
recipientAddress,
|
|
26389
|
-
chainId: selectedChainId,
|
|
26390
|
-
tokenSymbol: selectedToken
|
|
26391
|
-
});
|
|
26392
|
-
lastBlacklistedRecipientRef.current = warningKey;
|
|
26393
|
-
}, [isRecipientBlacklisted, recipientAddress, selectedChainId, selectedToken]);
|
|
26590
|
+
});
|
|
26394
26591
|
const bottomSectionRef = useBottomSectionRef(bottomBarId);
|
|
26395
26592
|
const isRecipientInputValid = isValidAddress && !isWithdrawingToSourceAddress;
|
|
26396
26593
|
const hasAddressError = !isRecipientInputValid && recipientAddress !== "";
|
|
@@ -26413,99 +26610,6 @@ var WithdrawContent = ({
|
|
|
26413
26610
|
const feesSummaryLoading = !isLighterSecure && isQuoteLoading;
|
|
26414
26611
|
const feesSummaryQuote = isLighterSecure ? void 0 : quote?.finalEstimation;
|
|
26415
26612
|
const feesSummaryUnavailable = isLighterSecure || !quoteEnabled;
|
|
26416
|
-
function renderAddressSection() {
|
|
26417
|
-
if (isLighterSecure) {
|
|
26418
|
-
return /* @__PURE__ */ React135.createElement(
|
|
26419
|
-
LighterSecureAddressDisplay,
|
|
26420
|
-
{
|
|
26421
|
-
address: recipientAddress || connectedAddress || ""
|
|
26422
|
-
}
|
|
26423
|
-
);
|
|
26424
|
-
}
|
|
26425
|
-
return /* @__PURE__ */ React135.createElement(
|
|
26426
|
-
WithdrawRecipientAddress,
|
|
26427
|
-
{
|
|
26428
|
-
isValidAddress: isRecipientInputValid,
|
|
26429
|
-
recipientAddress,
|
|
26430
|
-
config,
|
|
26431
|
-
setRecipientAddress,
|
|
26432
|
-
selectedToken,
|
|
26433
|
-
selectedChainId,
|
|
26434
|
-
isRiskyAddress
|
|
26435
|
-
}
|
|
26436
|
-
);
|
|
26437
|
-
}
|
|
26438
|
-
function renderReceiveTokenSection() {
|
|
26439
|
-
if (isLighterSecure) {
|
|
26440
|
-
return /* @__PURE__ */ React135.createElement(LighterSecureReceiveDisplay, { sourceTokenSymbol: selectedSourceToken });
|
|
26441
|
-
}
|
|
26442
|
-
return /* @__PURE__ */ React135.createElement(
|
|
26443
|
-
TokenAndChainDropdown,
|
|
26444
|
-
{
|
|
26445
|
-
isLoading: isLoadingAssets,
|
|
26446
|
-
assets,
|
|
26447
|
-
selectedToken,
|
|
26448
|
-
onTokenSelected: handleTokenChange,
|
|
26449
|
-
selectedChainId,
|
|
26450
|
-
onChainSelected: handleChainChange,
|
|
26451
|
-
tokenLabel: t("withdrawal.receiveToken"),
|
|
26452
|
-
chainLabel: t("withdrawal.receiveChain"),
|
|
26453
|
-
tokenPlaceholder: t("withdrawal.selectToken"),
|
|
26454
|
-
chainPlaceholder: t("withdrawal.selectChain"),
|
|
26455
|
-
alwaysOpenToTop: true,
|
|
26456
|
-
maxChainDropdownHeight: 195,
|
|
26457
|
-
maxTokenDropdownHeight: 195,
|
|
26458
|
-
hideNewTokenBadge: true,
|
|
26459
|
-
popularTokenSymbols,
|
|
26460
|
-
priorityTokenSymbols,
|
|
26461
|
-
chainIdSortOrder
|
|
26462
|
-
}
|
|
26463
|
-
);
|
|
26464
|
-
}
|
|
26465
|
-
function renderReceiveAmountValue() {
|
|
26466
|
-
if (isLighterSecure) {
|
|
26467
|
-
return /* @__PURE__ */ React135.createElement(
|
|
26468
|
-
LighterSecureReceiveAmountValue,
|
|
26469
|
-
{
|
|
26470
|
-
amount: withdrawalInputAmount,
|
|
26471
|
-
tokenSymbol: selectedSourceToken
|
|
26472
|
-
}
|
|
26473
|
-
);
|
|
26474
|
-
}
|
|
26475
|
-
if (isQuoteLoading) {
|
|
26476
|
-
return /* @__PURE__ */ React135.createElement(FunSkeletonBlock, { height: "txSummaryLineSkeletonHeight", width: "54" });
|
|
26477
|
-
}
|
|
26478
|
-
if (!quoteEnabled) {
|
|
26479
|
-
return /* @__PURE__ */ React135.createElement(
|
|
26480
|
-
Text,
|
|
26481
|
-
{
|
|
26482
|
-
color: "withdrawalYouWillReceiveValueUsd",
|
|
26483
|
-
size: "withdrawalYouWillReceive",
|
|
26484
|
-
weight: "withdrawalYouWillReceiveValueUsd"
|
|
26485
|
-
},
|
|
26486
|
-
NO_DATA_VALUE
|
|
26487
|
-
);
|
|
26488
|
-
}
|
|
26489
|
-
return /* @__PURE__ */ React135.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center", gap: "8" }, /* @__PURE__ */ React135.createElement(
|
|
26490
|
-
Text,
|
|
26491
|
-
{
|
|
26492
|
-
font: "amountValue",
|
|
26493
|
-
color: "withdrawalYouWillReceiveValueCrypto",
|
|
26494
|
-
size: "withdrawalYouWillReceive",
|
|
26495
|
-
weight: "withdrawalYouWillReceiveValueCrypto"
|
|
26496
|
-
},
|
|
26497
|
-
formatCryptoAndStringify3(receiveAmountCrypto, selectedToken)
|
|
26498
|
-
), /* @__PURE__ */ React135.createElement(
|
|
26499
|
-
Text,
|
|
26500
|
-
{
|
|
26501
|
-
font: "amountValue",
|
|
26502
|
-
color: "withdrawalYouWillReceiveValueUsd",
|
|
26503
|
-
size: "withdrawalYouWillReceive",
|
|
26504
|
-
weight: "withdrawalYouWillReceiveValueUsd"
|
|
26505
|
-
},
|
|
26506
|
-
formatCurrencyAndStringify6(receiveAmountFiatTotal)
|
|
26507
|
-
));
|
|
26508
|
-
}
|
|
26509
26613
|
const { swapImpactUsd, appFeeUsd, gasUsd } = extractRelayFeeInfo(
|
|
26510
26614
|
quote?.baseQuote?.metadata
|
|
26511
26615
|
);
|
|
@@ -26542,10 +26646,6 @@ var WithdrawContent = ({
|
|
|
26542
26646
|
t
|
|
26543
26647
|
]
|
|
26544
26648
|
);
|
|
26545
|
-
const isWithdrawalBannerVisible = message && (!expireAtMs || Date.now() <= expireAtMs);
|
|
26546
|
-
const isUsdceSelected = normalizedSelectedToken === "USDC.E";
|
|
26547
|
-
const showBannerSection = isWithdrawalBannerVisible || isUsdceSelected;
|
|
26548
|
-
const isRiskyAddress = !!isRisky && !isCheckingAddressRisk;
|
|
26549
26649
|
const maxExceededMessage = isLighterFast && isWithdrawAmountTooHigh ? /* @__PURE__ */ React135.createElement(
|
|
26550
26650
|
LighterFastMaxExceededMessage,
|
|
26551
26651
|
{
|
|
@@ -26568,6 +26668,214 @@ var WithdrawContent = ({
|
|
|
26568
26668
|
return null;
|
|
26569
26669
|
}
|
|
26570
26670
|
const topNotification = resolveTopNotification();
|
|
26671
|
+
return {
|
|
26672
|
+
displayedSourceTokenBalance,
|
|
26673
|
+
sourceTokenUsdPrice,
|
|
26674
|
+
isWithdrawAmountValid,
|
|
26675
|
+
isWithdrawAmountTooLow,
|
|
26676
|
+
isWithdrawAmountTooHigh,
|
|
26677
|
+
isWithdrawAmountAboveBalance,
|
|
26678
|
+
minWithdrawalDisplayValue,
|
|
26679
|
+
isQuoteLoading,
|
|
26680
|
+
quoteEnabled,
|
|
26681
|
+
handleSubmit,
|
|
26682
|
+
isRecipientInputValid,
|
|
26683
|
+
isCtaDisabled,
|
|
26684
|
+
feesSummaryLoading,
|
|
26685
|
+
feesSummaryQuote,
|
|
26686
|
+
feesSummaryUnavailable,
|
|
26687
|
+
receiveAmountCrypto,
|
|
26688
|
+
receiveAmountFiatTotal,
|
|
26689
|
+
withdrawButtonText,
|
|
26690
|
+
topNotification,
|
|
26691
|
+
bottomSectionRef
|
|
26692
|
+
};
|
|
26693
|
+
}
|
|
26694
|
+
var WithdrawContent = ({
|
|
26695
|
+
onContinue,
|
|
26696
|
+
config,
|
|
26697
|
+
withdrawalItem,
|
|
26698
|
+
onSwitchToSecure,
|
|
26699
|
+
bottomBarId = "withdrawal",
|
|
26700
|
+
disableSubmit = false
|
|
26701
|
+
}) => {
|
|
26702
|
+
const commonFlow = useCommonWithdrawalFlow({ config, withdrawalItem });
|
|
26703
|
+
const {
|
|
26704
|
+
t,
|
|
26705
|
+
selectedSourceToken,
|
|
26706
|
+
setSelectedSourceToken,
|
|
26707
|
+
recipientAddress,
|
|
26708
|
+
setRecipientAddress,
|
|
26709
|
+
withdrawalInputAmount,
|
|
26710
|
+
setWithdrawalInputAmount,
|
|
26711
|
+
connectedWalletAddress,
|
|
26712
|
+
assets,
|
|
26713
|
+
selectedChainId,
|
|
26714
|
+
handleChainChange,
|
|
26715
|
+
selectedToken,
|
|
26716
|
+
handleTokenChange,
|
|
26717
|
+
chainIdSortOrder,
|
|
26718
|
+
popularTokenSymbols,
|
|
26719
|
+
priorityTokenSymbols,
|
|
26720
|
+
isLoadingAssets,
|
|
26721
|
+
apiKey,
|
|
26722
|
+
uiCustomizations,
|
|
26723
|
+
isUsdceSelected,
|
|
26724
|
+
showBannerSection,
|
|
26725
|
+
isRiskyAddress
|
|
26726
|
+
} = commonFlow;
|
|
26727
|
+
const withdrawalDispatch = useWithdrawal({
|
|
26728
|
+
config,
|
|
26729
|
+
withdrawalItem,
|
|
26730
|
+
onSuccess: (withdrawal, txHash) => {
|
|
26731
|
+
invalidateLighterAccount();
|
|
26732
|
+
onContinue(withdrawal, txHash);
|
|
26733
|
+
}
|
|
26734
|
+
});
|
|
26735
|
+
const { handleWithdrawal, isWithdrawing, withdrawalError } = withdrawalDispatch;
|
|
26736
|
+
const clientFlow = useClientSpecificWithdrawalFlow({
|
|
26737
|
+
config,
|
|
26738
|
+
onContinue,
|
|
26739
|
+
apiKey,
|
|
26740
|
+
connectedWalletAddress,
|
|
26741
|
+
selectedSourceToken,
|
|
26742
|
+
recipientAddress,
|
|
26743
|
+
withdrawalInputAmount,
|
|
26744
|
+
setRecipientAddress,
|
|
26745
|
+
handleWithdrawal,
|
|
26746
|
+
withdrawalError
|
|
26747
|
+
});
|
|
26748
|
+
const {
|
|
26749
|
+
isLighterSecure,
|
|
26750
|
+
connectedAddress,
|
|
26751
|
+
invalidateLighterAccount,
|
|
26752
|
+
isL1FallbackAvailable,
|
|
26753
|
+
isSubmittingL1,
|
|
26754
|
+
sourceTokenOptions
|
|
26755
|
+
} = clientFlow;
|
|
26756
|
+
const {
|
|
26757
|
+
displayedSourceTokenBalance,
|
|
26758
|
+
sourceTokenUsdPrice,
|
|
26759
|
+
isWithdrawAmountValid,
|
|
26760
|
+
isWithdrawAmountTooLow,
|
|
26761
|
+
isWithdrawAmountTooHigh,
|
|
26762
|
+
isWithdrawAmountAboveBalance,
|
|
26763
|
+
minWithdrawalDisplayValue,
|
|
26764
|
+
isQuoteLoading,
|
|
26765
|
+
quoteEnabled,
|
|
26766
|
+
handleSubmit,
|
|
26767
|
+
isRecipientInputValid,
|
|
26768
|
+
isCtaDisabled,
|
|
26769
|
+
feesSummaryLoading,
|
|
26770
|
+
feesSummaryQuote,
|
|
26771
|
+
feesSummaryUnavailable,
|
|
26772
|
+
receiveAmountCrypto,
|
|
26773
|
+
receiveAmountFiatTotal,
|
|
26774
|
+
withdrawButtonText,
|
|
26775
|
+
topNotification,
|
|
26776
|
+
bottomSectionRef
|
|
26777
|
+
} = usePostClientCommonWithdrawalFlow({
|
|
26778
|
+
...commonFlow,
|
|
26779
|
+
...clientFlow,
|
|
26780
|
+
...withdrawalDispatch,
|
|
26781
|
+
config,
|
|
26782
|
+
onSwitchToSecure,
|
|
26783
|
+
bottomBarId,
|
|
26784
|
+
disableSubmit
|
|
26785
|
+
});
|
|
26786
|
+
function renderAddressSection() {
|
|
26787
|
+
if (isLighterSecure) {
|
|
26788
|
+
return /* @__PURE__ */ React135.createElement(
|
|
26789
|
+
LighterSecureAddressDisplay,
|
|
26790
|
+
{
|
|
26791
|
+
address: recipientAddress || connectedAddress || ""
|
|
26792
|
+
}
|
|
26793
|
+
);
|
|
26794
|
+
}
|
|
26795
|
+
return /* @__PURE__ */ React135.createElement(
|
|
26796
|
+
WithdrawRecipientAddress,
|
|
26797
|
+
{
|
|
26798
|
+
isValidAddress: isRecipientInputValid,
|
|
26799
|
+
recipientAddress,
|
|
26800
|
+
config,
|
|
26801
|
+
setRecipientAddress,
|
|
26802
|
+
selectedToken,
|
|
26803
|
+
selectedChainId,
|
|
26804
|
+
isRiskyAddress
|
|
26805
|
+
}
|
|
26806
|
+
);
|
|
26807
|
+
}
|
|
26808
|
+
function renderReceiveTokenSection() {
|
|
26809
|
+
if (isLighterSecure) {
|
|
26810
|
+
return /* @__PURE__ */ React135.createElement(LighterSecureReceiveDisplay, { sourceTokenSymbol: selectedSourceToken });
|
|
26811
|
+
}
|
|
26812
|
+
return /* @__PURE__ */ React135.createElement(
|
|
26813
|
+
TokenAndChainDropdown,
|
|
26814
|
+
{
|
|
26815
|
+
isLoading: isLoadingAssets,
|
|
26816
|
+
assets,
|
|
26817
|
+
selectedToken,
|
|
26818
|
+
onTokenSelected: handleTokenChange,
|
|
26819
|
+
selectedChainId,
|
|
26820
|
+
onChainSelected: handleChainChange,
|
|
26821
|
+
tokenLabel: t("withdrawal.receiveToken"),
|
|
26822
|
+
chainLabel: t("withdrawal.receiveChain"),
|
|
26823
|
+
tokenPlaceholder: t("withdrawal.selectToken"),
|
|
26824
|
+
chainPlaceholder: t("withdrawal.selectChain"),
|
|
26825
|
+
alwaysOpenToTop: true,
|
|
26826
|
+
maxChainDropdownHeight: 195,
|
|
26827
|
+
maxTokenDropdownHeight: 195,
|
|
26828
|
+
hideNewTokenBadge: true,
|
|
26829
|
+
popularTokenSymbols,
|
|
26830
|
+
priorityTokenSymbols,
|
|
26831
|
+
chainIdSortOrder
|
|
26832
|
+
}
|
|
26833
|
+
);
|
|
26834
|
+
}
|
|
26835
|
+
function renderReceiveAmountValue() {
|
|
26836
|
+
if (isLighterSecure) {
|
|
26837
|
+
return /* @__PURE__ */ React135.createElement(
|
|
26838
|
+
LighterSecureReceiveAmountValue,
|
|
26839
|
+
{
|
|
26840
|
+
amount: withdrawalInputAmount,
|
|
26841
|
+
tokenSymbol: selectedSourceToken
|
|
26842
|
+
}
|
|
26843
|
+
);
|
|
26844
|
+
}
|
|
26845
|
+
if (isQuoteLoading) {
|
|
26846
|
+
return /* @__PURE__ */ React135.createElement(FunSkeletonBlock, { height: "txSummaryLineSkeletonHeight", width: "54" });
|
|
26847
|
+
}
|
|
26848
|
+
if (!quoteEnabled) {
|
|
26849
|
+
return /* @__PURE__ */ React135.createElement(
|
|
26850
|
+
Text,
|
|
26851
|
+
{
|
|
26852
|
+
color: "withdrawalYouWillReceiveValueUsd",
|
|
26853
|
+
size: "withdrawalYouWillReceive",
|
|
26854
|
+
weight: "withdrawalYouWillReceiveValueUsd"
|
|
26855
|
+
},
|
|
26856
|
+
NO_DATA_VALUE
|
|
26857
|
+
);
|
|
26858
|
+
}
|
|
26859
|
+
return /* @__PURE__ */ React135.createElement(Box, { display: "flex", alignItems: "center", justifyContent: "center", gap: "8" }, /* @__PURE__ */ React135.createElement(
|
|
26860
|
+
Text,
|
|
26861
|
+
{
|
|
26862
|
+
font: "amountValue",
|
|
26863
|
+
color: "withdrawalYouWillReceiveValueCrypto",
|
|
26864
|
+
size: "withdrawalYouWillReceive",
|
|
26865
|
+
weight: "withdrawalYouWillReceiveValueCrypto"
|
|
26866
|
+
},
|
|
26867
|
+
formatCryptoAndStringify3(receiveAmountCrypto, selectedToken)
|
|
26868
|
+
), /* @__PURE__ */ React135.createElement(
|
|
26869
|
+
Text,
|
|
26870
|
+
{
|
|
26871
|
+
font: "amountValue",
|
|
26872
|
+
color: "withdrawalYouWillReceiveValueUsd",
|
|
26873
|
+
size: "withdrawalYouWillReceive",
|
|
26874
|
+
weight: "withdrawalYouWillReceiveValueUsd"
|
|
26875
|
+
},
|
|
26876
|
+
formatCurrencyAndStringify6(receiveAmountFiatTotal)
|
|
26877
|
+
));
|
|
26878
|
+
}
|
|
26571
26879
|
return /* @__PURE__ */ React135.createElement(Box, { id: "withdrawal-flow", display: "flex", flexDirection: "column", gap: "18" }, renderAddressSection(), /* @__PURE__ */ React135.createElement(
|
|
26572
26880
|
WithdrawAmountInput,
|
|
26573
26881
|
{
|
|
@@ -26598,7 +26906,7 @@ var WithdrawContent = ({
|
|
|
26598
26906
|
t(
|
|
26599
26907
|
isLighterxyzCustomer(apiKey) ? "withdrawal.receiveAmount" : "withdrawal.youWillReceive"
|
|
26600
26908
|
)
|
|
26601
|
-
), renderReceiveAmountValue()), /* @__PURE__ */ React135.createElement(
|
|
26909
|
+
), renderReceiveAmountValue()), !isLighterSecure && /* @__PURE__ */ React135.createElement(
|
|
26602
26910
|
PaymentFeesSummary,
|
|
26603
26911
|
{
|
|
26604
26912
|
fallbackFees: FALLBACK_FEES,
|
|
@@ -26631,7 +26939,11 @@ var WithdrawContent = ({
|
|
|
26631
26939
|
// the failed L2 attempt, so it stays enabled (gate on submit).
|
|
26632
26940
|
title: isL1FallbackAvailable ? t("withdrawal.lighterWithdrawOnChain") : withdrawButtonText,
|
|
26633
26941
|
isDisabled: isCtaDisabled,
|
|
26634
|
-
|
|
26942
|
+
// Spinner also while the quote is being calculated (fields
|
|
26943
|
+
// filled, first fetch in flight) — background refetches don't
|
|
26944
|
+
// re-trigger isLoading, so the CTA doesn't flash on the 25s
|
|
26945
|
+
// refresh.
|
|
26946
|
+
isLoading: isL1FallbackAvailable ? isSubmittingL1 : isWithdrawing || isQuoteLoading,
|
|
26635
26947
|
onClick: handleSubmit
|
|
26636
26948
|
}
|
|
26637
26949
|
}
|
|
@@ -26642,6 +26954,8 @@ var WithdrawContent = ({
|
|
|
26642
26954
|
|
|
26643
26955
|
// src/modals/WithdrawalModal/WithdrawalMethodSelect.tsx
|
|
26644
26956
|
import {
|
|
26957
|
+
getSwappedCashMinUsd,
|
|
26958
|
+
getSwappedSellCapEur,
|
|
26645
26959
|
getWithdrawalFopsDisclaimerLimit,
|
|
26646
26960
|
isSyntheticFop as isSyntheticFop2
|
|
26647
26961
|
} from "@funkit/connect-core";
|
|
@@ -26649,10 +26963,12 @@ import React141 from "react";
|
|
|
26649
26963
|
|
|
26650
26964
|
// src/hooks/queries/useWithdrawFops.ts
|
|
26651
26965
|
import { RailConfigType as RailConfigType3, getFops as getFops3 } from "@funkit/api-base";
|
|
26652
|
-
import { useQuery as
|
|
26966
|
+
import { useQuery as useQuery17 } from "@tanstack/react-query";
|
|
26653
26967
|
import { useMemo as useMemo40 } from "react";
|
|
26654
|
-
import {
|
|
26655
|
-
|
|
26968
|
+
import {
|
|
26969
|
+
buildSwappedSellLimits,
|
|
26970
|
+
findSwappedSourceOverride
|
|
26971
|
+
} from "@funkit/connect-core";
|
|
26656
26972
|
var useWithdrawFops = (params) => {
|
|
26657
26973
|
const { apiKey } = useFunkitConfig();
|
|
26658
26974
|
const { userInfo } = useGeneralWallet();
|
|
@@ -26683,7 +26999,7 @@ var useWithdrawFops = (params) => {
|
|
|
26683
26999
|
const userId = userInfo.id;
|
|
26684
27000
|
const countryCode = userIpInfo?.alpha2;
|
|
26685
27001
|
const isEnabled = (params.enabled ?? true) && !!apiKey && !!userId && !!userInfo.address && !!countryCode && !!params.sourceChainId && !!params.sourceTokenAddress && !isSwappedCurrencyCodeLoading;
|
|
26686
|
-
const query =
|
|
27002
|
+
const query = useQuery17({
|
|
26687
27003
|
// `prefillFiatEmail` is intentionally NOT in the queryKey: it's read inside
|
|
26688
27004
|
// `queryFn` and captured at fetch time, so post-mount changes don't trigger a refetch
|
|
26689
27005
|
queryKey: [
|
|
@@ -26717,13 +27033,14 @@ var useWithdrawFops = (params) => {
|
|
|
26717
27033
|
themeConfig,
|
|
26718
27034
|
"useWithdrawFops"
|
|
26719
27035
|
);
|
|
27036
|
+
const sellLimits = buildSwappedSellLimits(params.defaultMaxAmount);
|
|
26720
27037
|
logger.info("withdrawFops:sellLimits", {
|
|
26721
27038
|
sourceChainId: params.sourceChainId,
|
|
26722
27039
|
sourceTokenAddress: params.sourceTokenAddress,
|
|
26723
27040
|
swappedCurrencyCode,
|
|
26724
|
-
defaultMinAmountEur:
|
|
27041
|
+
defaultMinAmountEur: sellLimits.defaultMinAmount,
|
|
26725
27042
|
defaultMaxAmountEur: params.defaultMaxAmount,
|
|
26726
|
-
capApplied:
|
|
27043
|
+
capApplied: sellLimits.defaultMaxAmount != null
|
|
26727
27044
|
});
|
|
26728
27045
|
const response = await getFops3({
|
|
26729
27046
|
apiKey,
|
|
@@ -26745,14 +27062,7 @@ var useWithdrawFops = (params) => {
|
|
|
26745
27062
|
fiatCurrencyCode: swappedCurrencyCode,
|
|
26746
27063
|
sourceToken: acceptedToken,
|
|
26747
27064
|
thirdPartyPaymentConfigs,
|
|
26748
|
-
checkoutLimitsCriteria:
|
|
26749
|
-
defaultMinAmount: SWAPPED_MIN_SELL_EUR,
|
|
26750
|
-
// Only cap when the balance clears the minimum — a max at/below
|
|
26751
|
-
// the min is a contradictory range for Swapped's iframe.
|
|
26752
|
-
...params.defaultMaxAmount != null && params.defaultMaxAmount > SWAPPED_MIN_SELL_EUR && {
|
|
26753
|
-
defaultMaxAmount: params.defaultMaxAmount
|
|
26754
|
-
}
|
|
26755
|
-
}
|
|
27065
|
+
checkoutLimitsCriteria: sellLimits
|
|
26756
27066
|
}
|
|
26757
27067
|
]
|
|
26758
27068
|
}
|
|
@@ -26785,7 +27095,7 @@ var useWithdrawFops = (params) => {
|
|
|
26785
27095
|
|
|
26786
27096
|
// src/hooks/useSwappedPreload.ts
|
|
26787
27097
|
import { isSwappedFop } from "@funkit/connect-core";
|
|
26788
|
-
import { useEffect as
|
|
27098
|
+
import { useEffect as useEffect44 } from "react";
|
|
26789
27099
|
|
|
26790
27100
|
// src/modals/CheckoutModal/SourceChange/FormOfPaymentsList.tsx
|
|
26791
27101
|
import { getFopKey, isSyntheticFop, sortFops as sortFops2 } from "@funkit/connect-core";
|
|
@@ -27155,7 +27465,7 @@ function FormOfPaymentsList({
|
|
|
27155
27465
|
function useSwappedPreload(fopsData, mode) {
|
|
27156
27466
|
const fopPriority = useDynamicConfig("foppriority");
|
|
27157
27467
|
const { setIframeUrl } = useSwappedContext(mode);
|
|
27158
|
-
|
|
27468
|
+
useEffect44(() => {
|
|
27159
27469
|
if (!fopsData) {
|
|
27160
27470
|
setIframeUrl(null);
|
|
27161
27471
|
return;
|
|
@@ -27179,6 +27489,9 @@ function useSwappedPreload(fopsData, mode) {
|
|
|
27179
27489
|
}, [fopsData, setIframeUrl, fopPriority]);
|
|
27180
27490
|
}
|
|
27181
27491
|
|
|
27492
|
+
// src/utils/getExchangeRate.ts
|
|
27493
|
+
import { getExchangeRate } from "@funkit/connect-core";
|
|
27494
|
+
|
|
27182
27495
|
// src/modals/WithdrawalModal/WithdrawalMethodSelect.tsx
|
|
27183
27496
|
function NoCashMethodsNote({ hasFopsResult }) {
|
|
27184
27497
|
if (!hasFopsResult) {
|
|
@@ -27205,8 +27518,8 @@ function WithdrawalMethodSelect({
|
|
|
27205
27518
|
const { t } = useFunkitTranslation();
|
|
27206
27519
|
const exchangeRates = useFiatExchangeRates();
|
|
27207
27520
|
const eurRate = getExchangeRate("EUR", exchangeRates.data, 0);
|
|
27208
|
-
const eurMax =
|
|
27209
|
-
const cashMinUsd = eurRate
|
|
27521
|
+
const eurMax = getSwappedSellCapEur(usdBalance, eurRate);
|
|
27522
|
+
const cashMinUsd = getSwappedCashMinUsd(eurRate);
|
|
27210
27523
|
const isBelowMinimumBalance = cashMinUsd != null && usdBalance < cashMinUsd;
|
|
27211
27524
|
const isAwaitingCap = usdBalance > 0 && exchangeRates.isLoading;
|
|
27212
27525
|
const withdrawFops = useWithdrawFops({
|
|
@@ -27293,7 +27606,7 @@ function WithdrawalMethodSelect({
|
|
|
27293
27606
|
|
|
27294
27607
|
// src/modals/WithdrawalModal/WithdrawalSwappedIframeController.tsx
|
|
27295
27608
|
import { useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
27296
|
-
import React143, { useEffect as
|
|
27609
|
+
import React143, { useEffect as useEffect47 } from "react";
|
|
27297
27610
|
|
|
27298
27611
|
// src/components/SwappedIframeSkeleton.tsx
|
|
27299
27612
|
import React142 from "react";
|
|
@@ -27412,7 +27725,7 @@ function SwappedIframeSkeleton({
|
|
|
27412
27725
|
}
|
|
27413
27726
|
|
|
27414
27727
|
// src/hooks/useSwappedIframeLifecycle.ts
|
|
27415
|
-
import { useEffect as
|
|
27728
|
+
import { useEffect as useEffect45, useRef as useRef23 } from "react";
|
|
27416
27729
|
var SWAPPED_IFRAME_TIMEOUT = 15e3;
|
|
27417
27730
|
function useSwappedIframeLifecycle({
|
|
27418
27731
|
fopType,
|
|
@@ -27422,11 +27735,11 @@ function useSwappedIframeLifecycle({
|
|
|
27422
27735
|
const { activateIframe, deactivateIframe, isSwappedReady } = useSwappedContext(mode);
|
|
27423
27736
|
const timeoutRef = useRef23(void 0);
|
|
27424
27737
|
const stableOnTimeout = useEffectEvent(onTimeout);
|
|
27425
|
-
|
|
27738
|
+
useEffect45(() => {
|
|
27426
27739
|
activateIframe(fopType);
|
|
27427
27740
|
return () => deactivateIframe();
|
|
27428
27741
|
}, [fopType, activateIframe, deactivateIframe]);
|
|
27429
|
-
|
|
27742
|
+
useEffect45(() => {
|
|
27430
27743
|
if (isSwappedReady) {
|
|
27431
27744
|
clearTimeout(timeoutRef.current);
|
|
27432
27745
|
return;
|
|
@@ -27443,7 +27756,7 @@ function useSwappedIframeLifecycle({
|
|
|
27443
27756
|
|
|
27444
27757
|
// src/modals/WithdrawalModal/useFiatWithdrawal.ts
|
|
27445
27758
|
import { getCheckoutQuoteV2 as getCheckoutQuoteV22 } from "@funkit/api-base";
|
|
27446
|
-
import { useEffect as
|
|
27759
|
+
import { useEffect as useEffect46, useRef as useRef24 } from "react";
|
|
27447
27760
|
|
|
27448
27761
|
// src/utils/safeBigInt.ts
|
|
27449
27762
|
function safeBigInt(value, fallback2) {
|
|
@@ -27563,7 +27876,7 @@ function useFiatWithdrawal({
|
|
|
27563
27876
|
tokenAddress: config.sourceTokenAddress
|
|
27564
27877
|
})
|
|
27565
27878
|
) : null;
|
|
27566
|
-
|
|
27879
|
+
useEffect46(() => {
|
|
27567
27880
|
if (!legs || !checkoutItem) return;
|
|
27568
27881
|
updateTargetAsset({
|
|
27569
27882
|
targetAsset: legs.targetTokenAddress,
|
|
@@ -27592,7 +27905,7 @@ function useFiatWithdrawal({
|
|
|
27592
27905
|
onError();
|
|
27593
27906
|
}
|
|
27594
27907
|
});
|
|
27595
|
-
|
|
27908
|
+
useEffect46(() => {
|
|
27596
27909
|
if (withdrawalError) {
|
|
27597
27910
|
handleWithdrawalFailure();
|
|
27598
27911
|
}
|
|
@@ -27759,7 +28072,7 @@ function WithdrawalSwappedIframeController({
|
|
|
27759
28072
|
checkoutId: withdrawalItem?.id
|
|
27760
28073
|
})
|
|
27761
28074
|
);
|
|
27762
|
-
|
|
28075
|
+
useEffect47(() => {
|
|
27763
28076
|
if (isSwappedReady) {
|
|
27764
28077
|
const metadata = getTrackMetadata();
|
|
27765
28078
|
logger.info("swapped-withdrawal-iframe:ready", metadata);
|
|
@@ -27872,7 +28185,7 @@ function WithdrawalSwappedIframeController({
|
|
|
27872
28185
|
}
|
|
27873
28186
|
}
|
|
27874
28187
|
});
|
|
27875
|
-
|
|
28188
|
+
useEffect47(() => {
|
|
27876
28189
|
return swappedTransport.onMessage(handleSwappedMessage);
|
|
27877
28190
|
}, [swappedTransport, handleSwappedMessage]);
|
|
27878
28191
|
useSwappedIframeLifecycle({
|
|
@@ -27921,11 +28234,11 @@ import React144, { useCallback as useCallback30, useMemo as useMemo41, useState
|
|
|
27921
28234
|
import { createPortal as createPortal5 } from "react-dom";
|
|
27922
28235
|
|
|
27923
28236
|
// src/hooks/useFunListeners.ts
|
|
27924
|
-
import { useEffect as
|
|
28237
|
+
import { useEffect as useEffect48, useRef as useRef25 } from "react";
|
|
27925
28238
|
function useCheckoutHistoryListener(activate = true, singleDepositAddr) {
|
|
27926
28239
|
const activeIntervalRef = useRef25(void 0);
|
|
27927
28240
|
const { startCheckoutHistoryListener, stopCheckoutHistoryListener } = useCheckoutHistoryContext();
|
|
27928
|
-
|
|
28241
|
+
useEffect48(() => {
|
|
27929
28242
|
if (activate) {
|
|
27930
28243
|
const createdIntervalId = startCheckoutHistoryListener(
|
|
27931
28244
|
/* singleDepositAddr */
|
|
@@ -28198,7 +28511,7 @@ function WithdrawalModal({
|
|
|
28198
28511
|
"SELECT_METHOD" /* SELECT_METHOD */,
|
|
28199
28512
|
"ENTER_AMOUNT" /* ENTER_AMOUNT */
|
|
28200
28513
|
].includes(step);
|
|
28201
|
-
|
|
28514
|
+
useEffect49(() => {
|
|
28202
28515
|
setStep(
|
|
28203
28516
|
isInitialStepSelectMethod ? "SELECT_METHOD" /* SELECT_METHOD */ : "ENTER_AMOUNT" /* ENTER_AMOUNT */
|
|
28204
28517
|
);
|
|
@@ -28510,7 +28823,7 @@ import React268 from "react";
|
|
|
28510
28823
|
// src/modals/CheckoutModal/stepTransition.ts
|
|
28511
28824
|
import {
|
|
28512
28825
|
useCallback as useCallback54,
|
|
28513
|
-
useEffect as
|
|
28826
|
+
useEffect as useEffect71,
|
|
28514
28827
|
useRef as useRef38,
|
|
28515
28828
|
useState as useState78
|
|
28516
28829
|
} from "react";
|
|
@@ -29967,13 +30280,13 @@ function VirtualFiatAccount({
|
|
|
29967
30280
|
|
|
29968
30281
|
// src/modals/PolymarketPerpsTransfer/PerpsTransferStep.tsx
|
|
29969
30282
|
import { useQueryClient as useQueryClient6 } from "@tanstack/react-query";
|
|
29970
|
-
import React178, { useEffect as
|
|
30283
|
+
import React178, { useEffect as useEffect51, useRef as useRef26, useState as useState50 } from "react";
|
|
29971
30284
|
import { createPortal as createPortal9 } from "react-dom";
|
|
29972
30285
|
|
|
29973
30286
|
// src/hooks/usePolymarketAccountBalances.ts
|
|
29974
30287
|
import {
|
|
29975
30288
|
skipToken as skipToken2,
|
|
29976
|
-
useQuery as
|
|
30289
|
+
useQuery as useQuery18,
|
|
29977
30290
|
useQueryClient as useQueryClient5
|
|
29978
30291
|
} from "@tanstack/react-query";
|
|
29979
30292
|
import * as dnum7 from "dnum";
|
|
@@ -30033,7 +30346,7 @@ function useAccountBalance(account, refetchIntervalMs) {
|
|
|
30033
30346
|
const queryClient = useQueryClient5();
|
|
30034
30347
|
const getBalanceUsd = account?.getBalanceUsd;
|
|
30035
30348
|
const address = account?.address;
|
|
30036
|
-
const query =
|
|
30349
|
+
const query = useQuery18({
|
|
30037
30350
|
queryKey: polymarketAccountBalanceQueryKey(address),
|
|
30038
30351
|
// `skipToken` disables the query when the account isn't configured (the
|
|
30039
30352
|
// perps-transfer config is optional). It is *not* a fallback for a missing
|
|
@@ -30514,7 +30827,7 @@ function PerpsTransferRows({ form }) {
|
|
|
30514
30827
|
}
|
|
30515
30828
|
|
|
30516
30829
|
// src/modals/PolymarketPerpsTransfer/usePerpsTransferForm.ts
|
|
30517
|
-
import { useEffect as
|
|
30830
|
+
import { useEffect as useEffect50, useState as useState49 } from "react";
|
|
30518
30831
|
function parseAmount(amount) {
|
|
30519
30832
|
return Number(amount.replace(/,/g, ""));
|
|
30520
30833
|
}
|
|
@@ -30544,7 +30857,7 @@ function usePerpsTransferForm({
|
|
|
30544
30857
|
const { t } = useFunkitTranslation();
|
|
30545
30858
|
const [amount, setAmount] = useState49(initialAmountUsd);
|
|
30546
30859
|
const [direction, setDirection] = useState49(initialDirection);
|
|
30547
|
-
|
|
30860
|
+
useEffect50(() => {
|
|
30548
30861
|
if (status === "success") {
|
|
30549
30862
|
setAmount("");
|
|
30550
30863
|
}
|
|
@@ -30611,7 +30924,7 @@ function PerpsTransferStepComponent() {
|
|
|
30611
30924
|
successResetTimerRef.current = null;
|
|
30612
30925
|
}
|
|
30613
30926
|
};
|
|
30614
|
-
|
|
30927
|
+
useEffect51(() => clearSuccessResetTimer, []);
|
|
30615
30928
|
const perpsTransfer = checkoutItem?.initSettings.config.polymarketPerpsTransfer;
|
|
30616
30929
|
const balances = usePolymarketAccountBalances({
|
|
30617
30930
|
predictions: perpsTransfer?.predictions,
|
|
@@ -30759,7 +31072,7 @@ import { bluvoExecuteWithdrawal as bluvoExecuteWithdrawal2 } from "@funkit/api-b
|
|
|
30759
31072
|
// src/components/FunInput/FunTwoFaInput.tsx
|
|
30760
31073
|
import React181, {
|
|
30761
31074
|
useCallback as useCallback34,
|
|
30762
|
-
useEffect as
|
|
31075
|
+
useEffect as useEffect52,
|
|
30763
31076
|
useRef as useRef27,
|
|
30764
31077
|
useState as useState51
|
|
30765
31078
|
} from "react";
|
|
@@ -30780,7 +31093,7 @@ var FunTwoFaInput = ({
|
|
|
30780
31093
|
const [currentLength, setCurrentLength] = useState51(initialInputLength);
|
|
30781
31094
|
const [focusIndex, setFocusIndex] = useState51(0);
|
|
30782
31095
|
const [isFocused, setIsFocused] = useState51(false);
|
|
30783
|
-
|
|
31096
|
+
useEffect52(() => {
|
|
30784
31097
|
if (!value) {
|
|
30785
31098
|
setFocusIndex(0);
|
|
30786
31099
|
}
|
|
@@ -31360,7 +31673,7 @@ var TwoFactorIcon = () => /* @__PURE__ */ React182.createElement(
|
|
|
31360
31673
|
);
|
|
31361
31674
|
|
|
31362
31675
|
// src/modals/CheckoutModal/Brokerage/ConnectExchange.tsx
|
|
31363
|
-
import React186, { useCallback as useCallback35, useEffect as
|
|
31676
|
+
import React186, { useCallback as useCallback35, useEffect as useEffect53, useState as useState53 } from "react";
|
|
31364
31677
|
import { createPortal as createPortal11 } from "react-dom";
|
|
31365
31678
|
|
|
31366
31679
|
// src/components/FunMessage/FunMessage.tsx
|
|
@@ -31491,7 +31804,7 @@ function ConnectExchange({
|
|
|
31491
31804
|
setAuthError(errorMessage);
|
|
31492
31805
|
setIsLoadingBluvoModal(false);
|
|
31493
31806
|
});
|
|
31494
|
-
|
|
31807
|
+
useEffect53(() => {
|
|
31495
31808
|
if (isConnected) {
|
|
31496
31809
|
navigateToBrokerage();
|
|
31497
31810
|
}
|
|
@@ -31909,7 +32222,7 @@ function CheckoutComplete({
|
|
|
31909
32222
|
|
|
31910
32223
|
// src/modals/CheckoutModal/ConfirmationStep/ConfirmationStep.tsx
|
|
31911
32224
|
import * as dnum9 from "dnum";
|
|
31912
|
-
import React204, { useEffect as
|
|
32225
|
+
import React204, { useEffect as useEffect57, useMemo as useMemo49, useState as useState64 } from "react";
|
|
31913
32226
|
import { createPortal as createPortal14 } from "react-dom";
|
|
31914
32227
|
import { DirectExecutionType as DirectExecutionType6 } from "@funkit/api-base";
|
|
31915
32228
|
|
|
@@ -32347,7 +32660,7 @@ import {
|
|
|
32347
32660
|
import { permitTypedData, reserve, supply } from "@aave/client/actions";
|
|
32348
32661
|
import { sendWith, signERC20PermitWith } from "@aave/client/viem";
|
|
32349
32662
|
import { DirectExecutionType as DirectExecutionType4, createDirectExecution as createDirectExecution2 } from "@funkit/api-base";
|
|
32350
|
-
import { useQuery as
|
|
32663
|
+
import { useQuery as useQuery19 } from "@tanstack/react-query";
|
|
32351
32664
|
import * as dnum8 from "dnum";
|
|
32352
32665
|
import { useCallback as useCallback38, useState as useState55 } from "react";
|
|
32353
32666
|
import { erc20Abi as erc20Abi5 } from "viem";
|
|
@@ -32586,7 +32899,7 @@ function useAaveTargetPoolAllowance(checkoutItem, owner) {
|
|
|
32586
32899
|
const targetAsset = config?.targetAsset;
|
|
32587
32900
|
const market = targetChainStr ? AAVE_MARKET_ADDRESS_BY_CHAIN[targetChainStr] : void 0;
|
|
32588
32901
|
const wagmiConfig = useConfig();
|
|
32589
|
-
const { data } =
|
|
32902
|
+
const { data } = useQuery19({
|
|
32590
32903
|
queryKey: [
|
|
32591
32904
|
"aaveTargetPoolAllowance",
|
|
32592
32905
|
targetChainStr,
|
|
@@ -32618,7 +32931,7 @@ function useAaveTargetReservePermit(checkoutItem) {
|
|
|
32618
32931
|
const targetChainStr = config?.targetChain;
|
|
32619
32932
|
const targetAsset = config?.targetAsset;
|
|
32620
32933
|
const market = targetChainStr ? AAVE_MARKET_ADDRESS_BY_CHAIN[targetChainStr] : void 0;
|
|
32621
|
-
const { data } =
|
|
32934
|
+
const { data } = useQuery19({
|
|
32622
32935
|
queryKey: [
|
|
32623
32936
|
"aaveReservePermitSupported",
|
|
32624
32937
|
targetChainStr,
|
|
@@ -33206,7 +33519,6 @@ var ConfirmationStepLoading = () => {
|
|
|
33206
33519
|
// src/modals/CheckoutModal/ConfirmationStep/CheckoutPrimaryInfo.tsx
|
|
33207
33520
|
function CheckoutPrimaryInfo({
|
|
33208
33521
|
showLeftAlignedDollarValueWithLabel,
|
|
33209
|
-
showTokenAmount,
|
|
33210
33522
|
usdAmount,
|
|
33211
33523
|
config,
|
|
33212
33524
|
isLoading = false,
|
|
@@ -33217,7 +33529,6 @@ function CheckoutPrimaryInfo({
|
|
|
33217
33529
|
const isStablecoin = useIsStablecoin();
|
|
33218
33530
|
const checkoutValueRaw = inputFiatAmount != null ? inputFiatAmount : displayAmounts?.confirmationScreenDisplayAmount ? Number.parseFloat(displayAmounts.confirmationScreenDisplayAmount) : isStablecoin(config.targetAssetTicker) ? config.targetAssetAmount : usdAmount;
|
|
33219
33531
|
const checkoutValue = checkoutValueRaw != null ? floorToDecimals(checkoutValueRaw, 2) : void 0;
|
|
33220
|
-
const doShowTokenAmount = showTokenAmount && !config.generateActionsParams;
|
|
33221
33532
|
return /* @__PURE__ */ React199.createElement(
|
|
33222
33533
|
Box,
|
|
33223
33534
|
{
|
|
@@ -33247,17 +33558,7 @@ function CheckoutPrimaryInfo({
|
|
|
33247
33558
|
textAlign: showLeftAlignedDollarValueWithLabel ? "left" : "center"
|
|
33248
33559
|
},
|
|
33249
33560
|
"-"
|
|
33250
|
-
)
|
|
33251
|
-
doShowTokenAmount && /* @__PURE__ */ React199.createElement(Box, { display: "flex", gap: "5", justifyContent: "center" }, config.iconSrc ? /* @__PURE__ */ React199.createElement(
|
|
33252
|
-
FunAssetAvatar,
|
|
33253
|
-
{
|
|
33254
|
-
assetSrc: config.iconSrc,
|
|
33255
|
-
assetName: "checkout-asset",
|
|
33256
|
-
assetIconSize: "16",
|
|
33257
|
-
largeChainIcon: true,
|
|
33258
|
-
prioritizeDefaults: false
|
|
33259
|
-
}
|
|
33260
|
-
) : null, /* @__PURE__ */ React199.createElement(Text, { color: "tertiaryText", size: "14", weight: "medium" }, getCheckoutItemDisplay({ checkoutConfig: config })))
|
|
33561
|
+
)
|
|
33261
33562
|
);
|
|
33262
33563
|
}
|
|
33263
33564
|
|
|
@@ -33446,7 +33747,7 @@ function mapRetryAction(quoteBuilder, params) {
|
|
|
33446
33747
|
}
|
|
33447
33748
|
|
|
33448
33749
|
// src/modals/CheckoutModal/ConfirmationStep/useSourceAssetConfirm.tsx
|
|
33449
|
-
import { useEffect as
|
|
33750
|
+
import { useEffect as useEffect54, useState as useState58 } from "react";
|
|
33450
33751
|
function useSourceAssetConfirm(setPreloadedQuoteData) {
|
|
33451
33752
|
const { setCheckoutQuote, getCheckoutQuote, setQuoteProgress } = useQuoteContext();
|
|
33452
33753
|
const { checkoutItem, setCheckout } = useCheckoutContext();
|
|
@@ -33495,7 +33796,7 @@ function useHackyTriggerWorkaroundReactDevBrainExplode() {
|
|
|
33495
33796
|
function useTriggerQuoteAndOtherStuffsWithExtremeCaution(onResult, setPreloadedQuoteData) {
|
|
33496
33797
|
const [assetRefresh, triggerAssetConfirm] = useHackyTriggerWorkaroundReactDevBrainExplode();
|
|
33497
33798
|
const { isSourceAssetConfirming, onSourceAssetConfirmed } = useSourceAssetConfirm(setPreloadedQuoteData);
|
|
33498
|
-
|
|
33799
|
+
useEffect54(() => {
|
|
33499
33800
|
if (assetRefresh === 0) {
|
|
33500
33801
|
return;
|
|
33501
33802
|
}
|
|
@@ -33855,7 +34156,7 @@ function usePostCheckout({
|
|
|
33855
34156
|
}
|
|
33856
34157
|
|
|
33857
34158
|
// src/modals/CheckoutModal/ConfirmationStep/useQuoteRefresh.ts
|
|
33858
|
-
import { useCallback as useCallback43, useEffect as
|
|
34159
|
+
import { useCallback as useCallback43, useEffect as useEffect56, useMemo as useMemo48, useRef as useRef29, useState as useState63 } from "react";
|
|
33859
34160
|
|
|
33860
34161
|
// src/hooks/useCountdown.tsx
|
|
33861
34162
|
import React203 from "react";
|
|
@@ -33863,7 +34164,7 @@ import { useCallback as useCallback42, useState as useState62 } from "react";
|
|
|
33863
34164
|
|
|
33864
34165
|
// src/components/FunCountdown/FunCountdown.tsx
|
|
33865
34166
|
import { noop as noop5 } from "@funkit/utils";
|
|
33866
|
-
import React202, { useCallback as useCallback41, useEffect as
|
|
34167
|
+
import React202, { useCallback as useCallback41, useEffect as useEffect55, useState as useState61 } from "react";
|
|
33867
34168
|
|
|
33868
34169
|
// src/components/FunCountdown/FunCountdown.css.ts
|
|
33869
34170
|
var backgroundRing = "_1t0bc111 _1rsrm2f2mm";
|
|
@@ -33906,7 +34207,7 @@ var FunCountdown = ({
|
|
|
33906
34207
|
setRemainingSeconds((prev) => prev > 0 ? prev - 1 : prev);
|
|
33907
34208
|
}, [isPaused]);
|
|
33908
34209
|
useInterval(handleInterval, 1e3);
|
|
33909
|
-
|
|
34210
|
+
useEffect55(() => {
|
|
33910
34211
|
if (remainingSeconds === onBeforeCountdownEndsSeconds) {
|
|
33911
34212
|
onBeforeCountdownEndsOnce();
|
|
33912
34213
|
}
|
|
@@ -34137,7 +34438,7 @@ function useQuoteRefresh({
|
|
|
34137
34438
|
}
|
|
34138
34439
|
return null;
|
|
34139
34440
|
}, [isQuoting, quoteErrorMessage]);
|
|
34140
|
-
|
|
34441
|
+
useEffect56(() => {
|
|
34141
34442
|
if (isPendingRefresh && !isOnHold) {
|
|
34142
34443
|
setIsPendingRefresh(false);
|
|
34143
34444
|
refreshQuote();
|
|
@@ -34268,7 +34569,7 @@ function ConfirmationStep({
|
|
|
34268
34569
|
}
|
|
34269
34570
|
}
|
|
34270
34571
|
});
|
|
34271
|
-
|
|
34572
|
+
useEffect57(() => {
|
|
34272
34573
|
if (!isDirectWalletTransfer) {
|
|
34273
34574
|
triggerNewQuote({ maxRetries: 1 });
|
|
34274
34575
|
}
|
|
@@ -34409,7 +34710,7 @@ function ConfirmationStep({
|
|
|
34409
34710
|
const hasStaticPrimaryInfoValue = isExactIn && checkoutItem?.inputFiatAmount != null || !isExactIn && !!checkoutConfig?.targetAssetAmount && isStablecoin(checkoutConfig.targetAssetTicker);
|
|
34410
34711
|
const checkoutId = checkoutItem?.id;
|
|
34411
34712
|
const isReady = !!checkoutItem?.finalDollarValue && !isQuoteLoading;
|
|
34412
|
-
|
|
34713
|
+
useEffect57(() => {
|
|
34413
34714
|
if (checkoutId && isReady) {
|
|
34414
34715
|
logMeasuredEvent({
|
|
34415
34716
|
eventName: "fc::ready::confirmation" /* READY_CONFIRMATION */,
|
|
@@ -34420,8 +34721,7 @@ function ConfirmationStep({
|
|
|
34420
34721
|
const {
|
|
34421
34722
|
showAmountSummaryAbovePaymentMethod,
|
|
34422
34723
|
showDisclaimerAsAlert,
|
|
34423
|
-
showLeftAlignedDollarValueWithLabel
|
|
34424
|
-
showTokenAmount
|
|
34724
|
+
showLeftAlignedDollarValueWithLabel
|
|
34425
34725
|
} = uiCustomizations.confirmationScreen;
|
|
34426
34726
|
const paymentMethodSummary = /* @__PURE__ */ React204.createElement(
|
|
34427
34727
|
PaymentMethodSummary,
|
|
@@ -34467,7 +34767,6 @@ function ConfirmationStep({
|
|
|
34467
34767
|
CheckoutPrimaryInfo,
|
|
34468
34768
|
{
|
|
34469
34769
|
showLeftAlignedDollarValueWithLabel,
|
|
34470
|
-
showTokenAmount,
|
|
34471
34770
|
config: checkoutItem.initSettings.config,
|
|
34472
34771
|
usdAmount: latestQuote?.baseQuote.estSubtotalUsd,
|
|
34473
34772
|
isLoading: isQuoteLoading && !hasStaticPrimaryInfoValue,
|
|
@@ -34542,11 +34841,11 @@ function ConfirmationStep({
|
|
|
34542
34841
|
|
|
34543
34842
|
// src/modals/CheckoutModal/InputAmount/InputAmount.tsx
|
|
34544
34843
|
import { isMobile as isMobile7 } from "@funkit/utils";
|
|
34545
|
-
import React219, { useEffect as
|
|
34844
|
+
import React219, { useEffect as useEffect60 } from "react";
|
|
34546
34845
|
|
|
34547
34846
|
// src/hooks/queries/useMeldCurrencies.ts
|
|
34548
34847
|
import { getMeldSupportedFiat } from "@funkit/api-base";
|
|
34549
|
-
import { useQuery as
|
|
34848
|
+
import { useQuery as useQuery20 } from "@tanstack/react-query";
|
|
34550
34849
|
var getPriority = (currencyCode) => {
|
|
34551
34850
|
if (currencyCode === "USD") {
|
|
34552
34851
|
return 0;
|
|
@@ -34558,7 +34857,7 @@ var getPriority = (currencyCode) => {
|
|
|
34558
34857
|
};
|
|
34559
34858
|
var useMeldCurrencies = (isEnabled = true) => {
|
|
34560
34859
|
const { apiKey } = useFunkitConfig();
|
|
34561
|
-
const query =
|
|
34860
|
+
const query = useQuery20({
|
|
34562
34861
|
queryKey: ["meld", "currencies"],
|
|
34563
34862
|
queryFn: async () => {
|
|
34564
34863
|
if (!apiKey) {
|
|
@@ -34584,12 +34883,12 @@ var useMeldCurrencies = (isEnabled = true) => {
|
|
|
34584
34883
|
|
|
34585
34884
|
// src/hooks/queries/useMeldDefaultCurrency.ts
|
|
34586
34885
|
import { getMeldDefaultFiat } from "@funkit/api-base";
|
|
34587
|
-
import { useQuery as
|
|
34886
|
+
import { useQuery as useQuery21 } from "@tanstack/react-query";
|
|
34588
34887
|
var useMeldDefaultCurrency = (paymentMethod) => {
|
|
34589
34888
|
const { apiKey } = useFunkitConfig();
|
|
34590
34889
|
const { userIpInfo } = useFunkitUserIp();
|
|
34591
34890
|
const enableMeld = useIsMeldEnabled();
|
|
34592
|
-
const query =
|
|
34891
|
+
const query = useQuery21({
|
|
34593
34892
|
queryKey: ["meld", "defaultCurrency", paymentMethod],
|
|
34594
34893
|
queryFn: async () => {
|
|
34595
34894
|
if (!apiKey) {
|
|
@@ -34615,21 +34914,10 @@ var useMeldDefaultCurrency = (paymentMethod) => {
|
|
|
34615
34914
|
// src/hooks/queries/useMeldLimits.ts
|
|
34616
34915
|
import { getMeldFiatLimits } from "@funkit/api-base";
|
|
34617
34916
|
import { formatCurrencyAndStringify as formatCurrencyAndStringify8 } from "@funkit/utils";
|
|
34618
|
-
import { useQuery as
|
|
34619
|
-
|
|
34620
|
-
// src/consts/meld.ts
|
|
34621
|
-
var MELD_MIN_LIMIT_BUFFER = 5;
|
|
34622
|
-
var getMeldProviderIconUrl = (provider) => `https://sdk-cdn.fun.xyz/images/meld/${provider.toLowerCase()}.svg`;
|
|
34623
|
-
var getCurrencySymbol = (currencyCode) => {
|
|
34624
|
-
const formatter = new Intl.NumberFormat("en-US", {
|
|
34625
|
-
style: "currency",
|
|
34626
|
-
currency: currencyCode,
|
|
34627
|
-
currencyDisplay: "narrowSymbol"
|
|
34628
|
-
});
|
|
34629
|
-
return formatter.formatToParts(1).find(({ type }) => type === "currency")?.value ?? currencyCode;
|
|
34630
|
-
};
|
|
34917
|
+
import { useQuery as useQuery22 } from "@tanstack/react-query";
|
|
34631
34918
|
|
|
34632
34919
|
// src/hooks/useMinDeposit.ts
|
|
34920
|
+
import { getMeldMinDepositInCurrency } from "@funkit/connect-core";
|
|
34633
34921
|
function useMinCheckoutDeposit({
|
|
34634
34922
|
currency = "USD",
|
|
34635
34923
|
paymentMethod
|
|
@@ -34642,21 +34930,19 @@ function useMinCheckoutDeposit({
|
|
|
34642
34930
|
logger.warn("useMinCheckoutDeposit: No checkout item found");
|
|
34643
34931
|
return 0;
|
|
34644
34932
|
}
|
|
34645
|
-
const
|
|
34646
|
-
const
|
|
34647
|
-
|
|
34648
|
-
|
|
34649
|
-
const minDepositUsd = getMinDepositUSD?.({
|
|
34650
|
-
tokenChainId,
|
|
34651
|
-
tokenAddress,
|
|
34933
|
+
const config = checkoutItem.initSettings.config;
|
|
34934
|
+
const configuredMin = config.getMinDepositUSD?.({
|
|
34935
|
+
tokenChainId: config.targetChain,
|
|
34936
|
+
tokenAddress: config.targetAsset,
|
|
34652
34937
|
dynamicRoutingId: config.dynamicRoutingId
|
|
34653
|
-
})
|
|
34654
|
-
const
|
|
34655
|
-
|
|
34656
|
-
|
|
34657
|
-
|
|
34658
|
-
|
|
34659
|
-
|
|
34938
|
+
});
|
|
34939
|
+
const minDepositUsd = Number.isFinite(configuredMin) ? configuredMin : 0;
|
|
34940
|
+
return getMeldMinDepositInCurrency({
|
|
34941
|
+
minDepositUsd,
|
|
34942
|
+
paymentMethod,
|
|
34943
|
+
currency,
|
|
34944
|
+
exchangeRates
|
|
34945
|
+
});
|
|
34660
34946
|
}
|
|
34661
34947
|
|
|
34662
34948
|
// src/hooks/queries/useMeldLimits.ts
|
|
@@ -34665,7 +34951,7 @@ var useMeldLimits = (isEnabled = true) => {
|
|
|
34665
34951
|
const { userIpInfo } = useFunkitUserIp();
|
|
34666
34952
|
const cryptoCurrency = useMeldCryptoCurrencyCode();
|
|
34667
34953
|
const countryCode = userIpInfo?.alpha2;
|
|
34668
|
-
const query =
|
|
34954
|
+
const query = useQuery22({
|
|
34669
34955
|
queryKey: ["meld", "limits", countryCode, cryptoCurrency],
|
|
34670
34956
|
queryFn: async () => {
|
|
34671
34957
|
if (!apiKey || !countryCode) {
|
|
@@ -34759,18 +35045,18 @@ import {
|
|
|
34759
35045
|
} from "@funkit/utils";
|
|
34760
35046
|
import * as dnum11 from "dnum";
|
|
34761
35047
|
import { motion as motion13 } from "motion/react";
|
|
34762
|
-
import React217, { useEffect as
|
|
35048
|
+
import React217, { useEffect as useEffect59, useMemo as useMemo52 } from "react";
|
|
34763
35049
|
|
|
34764
35050
|
// src/components/AnimatedWidthWrapper/AnimatedWidthWrapper.tsx
|
|
34765
35051
|
import { motion as motion12 } from "motion/react";
|
|
34766
35052
|
import React205 from "react";
|
|
34767
|
-
import { useEffect as
|
|
35053
|
+
import { useEffect as useEffect58, useRef as useRef30, useState as useState65 } from "react";
|
|
34768
35054
|
function AnimatedWidthWrapper({ children }) {
|
|
34769
35055
|
const containerRef = useRef30(null);
|
|
34770
35056
|
const animationFrameRef = useRef30(null);
|
|
34771
35057
|
const resizeObserverRef = useRef30(null);
|
|
34772
35058
|
const [width, setWidth] = useState65("auto");
|
|
34773
|
-
|
|
35059
|
+
useEffect58(() => {
|
|
34774
35060
|
if (containerRef.current) {
|
|
34775
35061
|
resizeObserverRef.current = new ResizeObserver((entries) => {
|
|
34776
35062
|
animationFrameRef.current = requestAnimationFrame(() => {
|
|
@@ -36022,6 +36308,9 @@ var QuickOptions = ({
|
|
|
36022
36308
|
};
|
|
36023
36309
|
|
|
36024
36310
|
// src/modals/CheckoutModal/InputAmount/useCheckoutAmountLimits.ts
|
|
36311
|
+
import {
|
|
36312
|
+
getCheckoutAmountLimitsUsd
|
|
36313
|
+
} from "@funkit/connect-core";
|
|
36025
36314
|
var useCheckoutAmountLimits = ({
|
|
36026
36315
|
checkoutConfig,
|
|
36027
36316
|
paymentMethod
|
|
@@ -36035,21 +36324,13 @@ var useCheckoutAmountLimits = ({
|
|
|
36035
36324
|
tokenAddress: targetAsset,
|
|
36036
36325
|
dynamicRoutingId
|
|
36037
36326
|
});
|
|
36038
|
-
|
|
36039
|
-
|
|
36040
|
-
|
|
36041
|
-
|
|
36042
|
-
|
|
36043
|
-
|
|
36044
|
-
|
|
36045
|
-
case PaymentMethod.BROKERAGE:
|
|
36046
|
-
return {
|
|
36047
|
-
minUsd: Math.max(brokerageMinMax?.minUsd ?? 0, minDepositUsd ?? 0),
|
|
36048
|
-
maxUsd: maxDepositUsd
|
|
36049
|
-
};
|
|
36050
|
-
default:
|
|
36051
|
-
return { minUsd: minDepositUsd, maxUsd: maxDepositUsd };
|
|
36052
|
-
}
|
|
36327
|
+
return getCheckoutAmountLimitsUsd({
|
|
36328
|
+
paymentMethod,
|
|
36329
|
+
minDepositUsd,
|
|
36330
|
+
minTransferValueUsd,
|
|
36331
|
+
brokerageMinUsd: brokerageMinMax?.minUsd,
|
|
36332
|
+
maxDepositUsd
|
|
36333
|
+
});
|
|
36053
36334
|
};
|
|
36054
36335
|
|
|
36055
36336
|
// src/modals/CheckoutModal/InputAmount/useAmountInput.ts
|
|
@@ -37007,6 +37288,20 @@ import React215 from "react";
|
|
|
37007
37288
|
// src/components/MeldQuoteItem/MeldQuoteItem.tsx
|
|
37008
37289
|
import { formatCryptoAndStringify as formatCryptoAndStringify4 } from "@funkit/utils";
|
|
37009
37290
|
import React214 from "react";
|
|
37291
|
+
|
|
37292
|
+
// src/consts/meld.ts
|
|
37293
|
+
import { MELD_MIN_LIMIT_BUFFER } from "@funkit/connect-core";
|
|
37294
|
+
var getMeldProviderIconUrl = (provider) => `https://sdk-cdn.fun.xyz/images/meld/${provider.toLowerCase()}.svg`;
|
|
37295
|
+
var getCurrencySymbol = (currencyCode) => {
|
|
37296
|
+
const formatter = new Intl.NumberFormat("en-US", {
|
|
37297
|
+
style: "currency",
|
|
37298
|
+
currency: currencyCode,
|
|
37299
|
+
currencyDisplay: "narrowSymbol"
|
|
37300
|
+
});
|
|
37301
|
+
return formatter.formatToParts(1).find(({ type }) => type === "currency")?.value ?? currencyCode;
|
|
37302
|
+
};
|
|
37303
|
+
|
|
37304
|
+
// src/components/MeldQuoteItem/MeldQuoteItem.tsx
|
|
37010
37305
|
var providerLabelMap = {
|
|
37011
37306
|
COINBASEPAY: "Coinbase Pay",
|
|
37012
37307
|
MOONPAY: "MoonPay",
|
|
@@ -37255,7 +37550,7 @@ var useMeldLink = (sourceAmount, sourceCurrencyCode = "USD") => {
|
|
|
37255
37550
|
|
|
37256
37551
|
// src/modals/CheckoutModal/MeldQuotes/useMeldQuotes.tsx
|
|
37257
37552
|
import { getMeldQuotes } from "@funkit/api-base";
|
|
37258
|
-
import { useQuery as
|
|
37553
|
+
import { useQuery as useQuery23 } from "@tanstack/react-query";
|
|
37259
37554
|
import { useDebounce as useDebounce2 } from "use-debounce";
|
|
37260
37555
|
var DEBOUNCE_DELAY = 500;
|
|
37261
37556
|
var COUNTDOWN_INTERVAL_SEC = 60;
|
|
@@ -37267,7 +37562,7 @@ var useMeldQuotes = (sourceAmount, fiatCurrency, meldEnabled = true) => {
|
|
|
37267
37562
|
const { isAway } = useUserPresence();
|
|
37268
37563
|
const destinationCurrencyCode = useMeldCryptoCurrencyCode();
|
|
37269
37564
|
const sourceCurrencyCode = fiatCurrency || "USD";
|
|
37270
|
-
const query =
|
|
37565
|
+
const query = useQuery23({
|
|
37271
37566
|
queryKey: [
|
|
37272
37567
|
"meld",
|
|
37273
37568
|
"quotes",
|
|
@@ -37537,7 +37832,7 @@ function InputAmountLoaded({
|
|
|
37537
37832
|
}
|
|
37538
37833
|
return setFiatAmount(selectedFiat);
|
|
37539
37834
|
}
|
|
37540
|
-
|
|
37835
|
+
useEffect59(() => {
|
|
37541
37836
|
if (isInputInFiat !== modalState.isInputInFiat || fiatAmount !== modalState.fiatAmount || assetAmount !== modalState.assetAmount || sourceTokenKey !== modalState.sourceTokenKey) {
|
|
37542
37837
|
setModalState((state) => ({
|
|
37543
37838
|
...state,
|
|
@@ -38306,10 +38601,10 @@ function InputAmount(props) {
|
|
|
38306
38601
|
query: { enabled: gasFetchingEnabled }
|
|
38307
38602
|
});
|
|
38308
38603
|
const isLoaded = !!(checkoutItem && unitPrice && !sourceHoldingError && !isLoadingSourceHolding && !isMeldDefaultCurrencyLoading && (!gasFetchingEnabled || gasPriceWei !== void 0));
|
|
38309
|
-
|
|
38604
|
+
useEffect60(() => setCheckoutQuote(null), []);
|
|
38310
38605
|
const checkoutId = checkoutItem?.id;
|
|
38311
38606
|
const paymentMethod = paymentMethodInfo.paymentMethod;
|
|
38312
|
-
|
|
38607
|
+
useEffect60(() => {
|
|
38313
38608
|
if (checkoutId && isLoaded) {
|
|
38314
38609
|
logMeasuredEvent({
|
|
38315
38610
|
eventName: "fc::ready::input_amount" /* READY_INPUT_AMOUNT */,
|
|
@@ -38342,7 +38637,7 @@ function InputAmount(props) {
|
|
|
38342
38637
|
}
|
|
38343
38638
|
|
|
38344
38639
|
// src/modals/CheckoutModal/LightningInvoice/LightningInvoice.tsx
|
|
38345
|
-
import React224, { useEffect as
|
|
38640
|
+
import React224, { useEffect as useEffect63 } from "react";
|
|
38346
38641
|
import { createPortal as createPortal16 } from "react-dom";
|
|
38347
38642
|
|
|
38348
38643
|
// src/components/CopyAddress/CopyInputDisplayedAddress.tsx
|
|
@@ -38350,7 +38645,7 @@ import { truncateMiddleOfAddress } from "@funkit/utils";
|
|
|
38350
38645
|
import React220, { useCallback as useCallback49, useState as useState69 } from "react";
|
|
38351
38646
|
|
|
38352
38647
|
// src/hooks/useCopyToClipboard.ts
|
|
38353
|
-
import { useCallback as useCallback48, useEffect as
|
|
38648
|
+
import { useCallback as useCallback48, useEffect as useEffect61, useState as useState68 } from "react";
|
|
38354
38649
|
var useCopyToClipboard = (text, delay = 1500) => {
|
|
38355
38650
|
const [isCopied, setCopied] = useState68(false);
|
|
38356
38651
|
const handleCopy = useCallback48(() => {
|
|
@@ -38360,7 +38655,7 @@ var useCopyToClipboard = (text, delay = 1500) => {
|
|
|
38360
38655
|
navigator.clipboard.writeText(text);
|
|
38361
38656
|
setCopied(true);
|
|
38362
38657
|
}, [text]);
|
|
38363
|
-
|
|
38658
|
+
useEffect61(() => {
|
|
38364
38659
|
if (!isCopied) {
|
|
38365
38660
|
return;
|
|
38366
38661
|
}
|
|
@@ -38489,8 +38784,8 @@ import {
|
|
|
38489
38784
|
getLightningQuote
|
|
38490
38785
|
} from "@funkit/api-base";
|
|
38491
38786
|
import { LIGHTNING_MAINNET_CHAIN_ID, bitcoinChain as bitcoinChain4 } from "@funkit/chains";
|
|
38492
|
-
import { keepPreviousData as keepPreviousData3, useQuery as
|
|
38493
|
-
import { useEffect as
|
|
38787
|
+
import { keepPreviousData as keepPreviousData3, useQuery as useQuery24 } from "@tanstack/react-query";
|
|
38788
|
+
import { useEffect as useEffect62, useRef as useRef33, useState as useState70 } from "react";
|
|
38494
38789
|
import { parseUnits as parseUnits5 } from "viem";
|
|
38495
38790
|
var QUOTE_REFRESH_LEAD_MS = 3e3;
|
|
38496
38791
|
var QUOTE_REFRESH_MIN_MS = 250;
|
|
@@ -38508,7 +38803,7 @@ function useDeferredQuote(latestQuote) {
|
|
|
38508
38803
|
const [displayedQuote, setDisplayedQuote] = useState70(latestQuote);
|
|
38509
38804
|
const latestQuoteRef = useRef33(latestQuote);
|
|
38510
38805
|
latestQuoteRef.current = latestQuote;
|
|
38511
|
-
|
|
38806
|
+
useEffect62(() => {
|
|
38512
38807
|
if (!displayedQuote) {
|
|
38513
38808
|
if (latestQuote) {
|
|
38514
38809
|
setDisplayedQuote(latestQuote);
|
|
@@ -38533,7 +38828,7 @@ var useLightningQuote = ({
|
|
|
38533
38828
|
}) => {
|
|
38534
38829
|
const { apiKey } = useFunkitConfig();
|
|
38535
38830
|
const enabled = !!depositAddr && !!targetChain && !!targetAsset && !!walletAddress && !!fiatAmount;
|
|
38536
|
-
const query =
|
|
38831
|
+
const query = useQuery24({
|
|
38537
38832
|
queryKey: [
|
|
38538
38833
|
"lightning-quote",
|
|
38539
38834
|
depositAddr,
|
|
@@ -38898,7 +39193,7 @@ function LightningInvoice(props) {
|
|
|
38898
39193
|
isHidden: isLoading || !!error,
|
|
38899
39194
|
isPaused: isLoading || !!error
|
|
38900
39195
|
});
|
|
38901
|
-
|
|
39196
|
+
useEffect63(() => {
|
|
38902
39197
|
if (expiresAtMs !== void 0) {
|
|
38903
39198
|
restartCountdown();
|
|
38904
39199
|
}
|
|
@@ -38953,7 +39248,7 @@ function LightningInvoice(props) {
|
|
|
38953
39248
|
}
|
|
38954
39249
|
|
|
38955
39250
|
// src/modals/CheckoutModal/LoadingAccount.tsx
|
|
38956
|
-
import React233, { useEffect as
|
|
39251
|
+
import React233, { useEffect as useEffect64 } from "react";
|
|
38957
39252
|
|
|
38958
39253
|
// src/components/FunAsset/FunAssetLoading.tsx
|
|
38959
39254
|
import React226 from "react";
|
|
@@ -39693,7 +39988,7 @@ function LoadingAccount({
|
|
|
39693
39988
|
const hasCustomStartingStep = !!checkoutConfig?.startingStep;
|
|
39694
39989
|
const startsOnConfirmationStep = checkoutConfig?.startingStep === "confirmation" /* CONFIRMATION */;
|
|
39695
39990
|
const startsOnSelectAssetStep = checkoutConfig?.startingStep === "select_asset" /* SELECT_ASSET */;
|
|
39696
|
-
|
|
39991
|
+
useEffect64(() => {
|
|
39697
39992
|
if (isLoadingFiat || !checkoutConfig) {
|
|
39698
39993
|
return;
|
|
39699
39994
|
}
|
|
@@ -40021,7 +40316,7 @@ function MeldRedirect({
|
|
|
40021
40316
|
import { etherealChain, hyperEvmChain as hyperEvmChain3 } from "@funkit/chains";
|
|
40022
40317
|
import { isTokenEquivalent as isTokenEquivalent12 } from "@funkit/utils";
|
|
40023
40318
|
import React240, {
|
|
40024
|
-
useEffect as
|
|
40319
|
+
useEffect as useEffect65,
|
|
40025
40320
|
useLayoutEffect as useLayoutEffect2,
|
|
40026
40321
|
useMemo as useMemo59,
|
|
40027
40322
|
useState as useState72
|
|
@@ -40413,7 +40708,7 @@ function useAssetOptions({
|
|
|
40413
40708
|
return assetOptions;
|
|
40414
40709
|
}
|
|
40415
40710
|
function useScrollToSelectedAsset(selectedChainTokenSymbol) {
|
|
40416
|
-
|
|
40711
|
+
useEffect65(() => {
|
|
40417
40712
|
const optionEl = document.getElementById(
|
|
40418
40713
|
`option-${selectedChainTokenSymbol}`
|
|
40419
40714
|
);
|
|
@@ -40581,7 +40876,7 @@ function AccountSelectAsset({
|
|
|
40581
40876
|
const isDisabled = isAssetsEmpty || !selectedChainTokenSymbol || isLoading;
|
|
40582
40877
|
const onBalanceTopUpSwitch = checkoutItem?.initSettings.onBalanceTopUpSwitch;
|
|
40583
40878
|
const checkoutId = checkoutItem?.id;
|
|
40584
|
-
|
|
40879
|
+
useEffect65(() => {
|
|
40585
40880
|
if (checkoutId && !isLoading) {
|
|
40586
40881
|
logMeasuredEvent({
|
|
40587
40882
|
eventName: "fc::ready::select_asset" /* READY_SELECT_ASSET */,
|
|
@@ -40744,7 +41039,7 @@ import {
|
|
|
40744
41039
|
isSyntheticFop as isSyntheticFop3
|
|
40745
41040
|
} from "@funkit/connect-core";
|
|
40746
41041
|
import { isTokenEquivalent as isTokenEquivalent13, noop as noop6 } from "@funkit/utils";
|
|
40747
|
-
import React249, { useEffect as
|
|
41042
|
+
import React249, { useEffect as useEffect67, useMemo as useMemo60, useRef as useRef34, useState as useState73 } from "react";
|
|
40748
41043
|
import { createPortal as createPortal20 } from "react-dom";
|
|
40749
41044
|
|
|
40750
41045
|
// src/components/Dropdown/ReceiveTokenDropdown.tsx
|
|
@@ -40852,13 +41147,13 @@ function useIsUserUnderComplianceReview() {
|
|
|
40852
41147
|
}
|
|
40853
41148
|
|
|
40854
41149
|
// src/modals/CheckoutModal/SourceChange/ComplianceReviewBanner.tsx
|
|
40855
|
-
import React242, { useEffect as
|
|
41150
|
+
import React242, { useEffect as useEffect66 } from "react";
|
|
40856
41151
|
function ComplianceReviewBanner({
|
|
40857
41152
|
checkoutId
|
|
40858
41153
|
}) {
|
|
40859
41154
|
const { t } = useFunkitTranslation();
|
|
40860
41155
|
const { logEvent } = useTrack();
|
|
40861
|
-
|
|
41156
|
+
useEffect66(() => {
|
|
40862
41157
|
logEvent({
|
|
40863
41158
|
eventName: "fc::compliance_review::banner_shown" /* COMPLIANCE_REVIEW_BANNER_SHOWN */,
|
|
40864
41159
|
metadata: { checkoutId }
|
|
@@ -41455,7 +41750,7 @@ function SourceChange({
|
|
|
41455
41750
|
const showTagline = useDynamicConfig("showpoweredtagline");
|
|
41456
41751
|
const hasBottomBar = showTagline || !isAutoContinue || bottomBarCloseButtonConfig.enabled;
|
|
41457
41752
|
useSwappedPreload(fopsData?.data, "deposit");
|
|
41458
|
-
|
|
41753
|
+
useEffect67(() => {
|
|
41459
41754
|
const nextWithdrawalConfig = shouldSeedSourceChangeWithdrawalConfig ? resolvedWithdrawalConfig : void 0;
|
|
41460
41755
|
setModalState((state) => {
|
|
41461
41756
|
if (state.withdrawalConfig === nextWithdrawalConfig) {
|
|
@@ -41471,7 +41766,7 @@ function SourceChange({
|
|
|
41471
41766
|
setModalState,
|
|
41472
41767
|
shouldSeedSourceChangeWithdrawalConfig
|
|
41473
41768
|
]);
|
|
41474
|
-
|
|
41769
|
+
useEffect67(() => {
|
|
41475
41770
|
if (!paymentMethodInfo) {
|
|
41476
41771
|
return;
|
|
41477
41772
|
}
|
|
@@ -41554,7 +41849,7 @@ function SourceChange({
|
|
|
41554
41849
|
)
|
|
41555
41850
|
);
|
|
41556
41851
|
});
|
|
41557
|
-
|
|
41852
|
+
useEffect67(() => {
|
|
41558
41853
|
sendPaymentMethodTabEvent(paymentMethodTab);
|
|
41559
41854
|
}, [paymentMethodTab, sendPaymentMethodTabEvent]);
|
|
41560
41855
|
const handleNewSourceContinue = async (newSource2) => {
|
|
@@ -41927,7 +42222,7 @@ function trackEventForTabChange(checkoutItem, tab) {
|
|
|
41927
42222
|
|
|
41928
42223
|
// src/modals/CheckoutModal/SwappedIframe/SwappedIframeController.tsx
|
|
41929
42224
|
import { useQueryClient as useQueryClient7 } from "@tanstack/react-query";
|
|
41930
|
-
import React250, { useEffect as
|
|
42225
|
+
import React250, { useEffect as useEffect68, useRef as useRef35 } from "react";
|
|
41931
42226
|
import { createPortal as createPortal21 } from "react-dom";
|
|
41932
42227
|
var SwappedIframeInfo = {
|
|
41933
42228
|
Component: SwappedIframeController,
|
|
@@ -41982,10 +42277,10 @@ function SwappedIframeController({
|
|
|
41982
42277
|
metadata: {}
|
|
41983
42278
|
});
|
|
41984
42279
|
});
|
|
41985
|
-
|
|
42280
|
+
useEffect68(() => {
|
|
41986
42281
|
startMeasuredEvent("fc::ready::swapped_iframe" /* READY_SWAPPED_IFRAME */);
|
|
41987
42282
|
}, [startMeasuredEvent]);
|
|
41988
|
-
|
|
42283
|
+
useEffect68(() => {
|
|
41989
42284
|
if (isSwappedReady) {
|
|
41990
42285
|
const event = getTrackEvent("fc::ready::swapped_iframe" /* READY_SWAPPED_IFRAME */);
|
|
41991
42286
|
logger.info("swapped-iframe:ready", event.metadata);
|
|
@@ -42150,7 +42445,7 @@ function SwappedIframeController({
|
|
|
42150
42445
|
}
|
|
42151
42446
|
}
|
|
42152
42447
|
}
|
|
42153
|
-
|
|
42448
|
+
useEffect68(() => {
|
|
42154
42449
|
return swappedTransport.onMessage(handleSwappedMessage);
|
|
42155
42450
|
}, [swappedTransport, handleSwappedMessage]);
|
|
42156
42451
|
useSwappedIframeLifecycle({
|
|
@@ -42243,13 +42538,13 @@ var BitcoinLightningBanner = ({
|
|
|
42243
42538
|
borderColor: { custom: "rgba(0, 0, 0, 0.1)" }
|
|
42244
42539
|
}
|
|
42245
42540
|
)),
|
|
42246
|
-
/* @__PURE__ */ React251.createElement(Text, { as: "div", size: "
|
|
42541
|
+
/* @__PURE__ */ React251.createElement(Text, { as: "div", size: "buttonTextTertiary", color: "primaryText" }, t("transferToken.depositBitcoinLightning"), " ", /* @__PURE__ */ React251.createElement(
|
|
42247
42542
|
FunLinkButton,
|
|
42248
42543
|
{
|
|
42249
42544
|
text: t("transferToken.lightningTryItNow"),
|
|
42250
42545
|
onClick,
|
|
42251
42546
|
variant: "accent",
|
|
42252
|
-
size: "
|
|
42547
|
+
size: "buttonTextTertiary",
|
|
42253
42548
|
weight: "medium",
|
|
42254
42549
|
inline: true
|
|
42255
42550
|
}
|
|
@@ -42264,7 +42559,7 @@ import React252 from "react";
|
|
|
42264
42559
|
var bottomLinkStyle = "_17ejcqj1 _1rsrm2f2r4";
|
|
42265
42560
|
|
|
42266
42561
|
// src/components/BottomLinks/BottomLinks.tsx
|
|
42267
|
-
var BottomLinks = ({ links }) => {
|
|
42562
|
+
var BottomLinks = ({ fontSize = "13", links }) => {
|
|
42268
42563
|
return /* @__PURE__ */ React252.createElement(
|
|
42269
42564
|
Box,
|
|
42270
42565
|
{
|
|
@@ -42287,7 +42582,7 @@ var BottomLinks = ({ links }) => {
|
|
|
42287
42582
|
{
|
|
42288
42583
|
as: "a",
|
|
42289
42584
|
className: bottomLinkStyle,
|
|
42290
|
-
fontSize
|
|
42585
|
+
fontSize,
|
|
42291
42586
|
href: link.href,
|
|
42292
42587
|
rel: "noreferrer",
|
|
42293
42588
|
target: "_blank"
|
|
@@ -42688,7 +42983,7 @@ var TransferTokenDetails = ({
|
|
|
42688
42983
|
};
|
|
42689
42984
|
|
|
42690
42985
|
// src/modals/CheckoutModal/TransferToken/useTransferTokenTracking.ts
|
|
42691
|
-
import { useCallback as useCallback52, useEffect as
|
|
42986
|
+
import { useCallback as useCallback52, useEffect as useEffect69, useRef as useRef36 } from "react";
|
|
42692
42987
|
|
|
42693
42988
|
// src/modals/CheckoutModal/TransferToken/CheckoutNotifications.track.ts
|
|
42694
42989
|
function getNotificationId(item) {
|
|
@@ -42785,7 +43080,7 @@ function useTransferTokenTracking({
|
|
|
42785
43080
|
toTokenAddress
|
|
42786
43081
|
}) {
|
|
42787
43082
|
const { logEvent } = useTrack();
|
|
42788
|
-
|
|
43083
|
+
useEffect69(() => {
|
|
42789
43084
|
if (depositAddress && fromChainId && toChainId && toTokenAddress) {
|
|
42790
43085
|
setTokenTransferAddressShownAtMs({
|
|
42791
43086
|
fromChainId,
|
|
@@ -42867,7 +43162,7 @@ function useNotificationTracking({
|
|
|
42867
43162
|
itemRef.current = item;
|
|
42868
43163
|
statusRef.current = status;
|
|
42869
43164
|
const id = item ? getNotificationId(item) : null;
|
|
42870
|
-
|
|
43165
|
+
useEffect69(() => {
|
|
42871
43166
|
if (!id || !itemRef.current) {
|
|
42872
43167
|
return;
|
|
42873
43168
|
}
|
|
@@ -42905,7 +43200,7 @@ function useNotificationTracking({
|
|
|
42905
43200
|
notificationDisplayedAtRef.current = null;
|
|
42906
43201
|
};
|
|
42907
43202
|
}, [id, logEvent]);
|
|
42908
|
-
|
|
43203
|
+
useEffect69(() => {
|
|
42909
43204
|
if (!itemRef.current || !notificationDisplayedAtRef.current) {
|
|
42910
43205
|
return;
|
|
42911
43206
|
}
|
|
@@ -43345,6 +43640,7 @@ function TransferToken({
|
|
|
43345
43640
|
)), selectedChainId !== void 0 && /* @__PURE__ */ React259.createElement(ChainInfoBanners, { chainId: selectedChainId }), /* @__PURE__ */ React259.createElement(FunInfoBanner, null), hideFeeBreakdown ? /* @__PURE__ */ React259.createElement(
|
|
43346
43641
|
BottomLinks,
|
|
43347
43642
|
{
|
|
43643
|
+
fontSize: "buttonTextTertiary",
|
|
43348
43644
|
links: [
|
|
43349
43645
|
{ text: t("transferToken.terms"), href: FUN_TERMS_URL },
|
|
43350
43646
|
{ text: t("transferToken.help"), href: FUN_HELP_FAQ_URL }
|
|
@@ -43704,7 +44000,7 @@ var FiatAccountDetail = {
|
|
|
43704
44000
|
|
|
43705
44001
|
// src/modals/CheckoutModal/VirtualFiatAccount/KycIframe.tsx
|
|
43706
44002
|
import { BridgeCustomerStatus as BridgeCustomerStatus7 } from "@funkit/api-base";
|
|
43707
|
-
import React265, { useCallback as useCallback53, useEffect as
|
|
44003
|
+
import React265, { useCallback as useCallback53, useEffect as useEffect70, useMemo as useMemo61, useState as useState77 } from "react";
|
|
43708
44004
|
function useIframeListener(listeners, expectedOrigin) {
|
|
43709
44005
|
const handleMessage = useCallback53(
|
|
43710
44006
|
(event) => {
|
|
@@ -43731,7 +44027,7 @@ function useIframeListener(listeners, expectedOrigin) {
|
|
|
43731
44027
|
},
|
|
43732
44028
|
[listeners, expectedOrigin]
|
|
43733
44029
|
);
|
|
43734
|
-
|
|
44030
|
+
useEffect70(() => {
|
|
43735
44031
|
window.addEventListener("message", handleMessage);
|
|
43736
44032
|
return () => {
|
|
43737
44033
|
window.removeEventListener("message", handleMessage);
|
|
@@ -44032,7 +44328,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
44032
44328
|
ensureStepQueries(modalState.step);
|
|
44033
44329
|
}
|
|
44034
44330
|
});
|
|
44035
|
-
|
|
44331
|
+
useEffect71(() => {
|
|
44036
44332
|
ensureLoadingAccountScreen();
|
|
44037
44333
|
}, [ensureLoadingAccountScreen]);
|
|
44038
44334
|
const trackNextState = useCallback54(
|
|
@@ -44269,7 +44565,7 @@ function useCheckoutModalTitle(depositAddress, defaultTitle) {
|
|
|
44269
44565
|
import { IN_PROGRESS_CHECKOUT_STATES as IN_PROGRESS_CHECKOUT_STATES2 } from "@funkit/api-base";
|
|
44270
44566
|
import { formatTimestampToDate, fullMonthNames } from "@funkit/utils";
|
|
44271
44567
|
import clsx23 from "clsx";
|
|
44272
|
-
import React277, { useEffect as
|
|
44568
|
+
import React277, { useEffect as useEffect73, useMemo as useMemo62, useRef as useRef40, useState as useState80 } from "react";
|
|
44273
44569
|
import { Virtuoso } from "react-virtuoso";
|
|
44274
44570
|
|
|
44275
44571
|
// src/consts/layout.ts
|
|
@@ -44632,13 +44928,13 @@ import { useCallback as useCallback55, useState as useState79 } from "react";
|
|
|
44632
44928
|
|
|
44633
44929
|
// src/components/FunSelect/FunClickOutside.tsx
|
|
44634
44930
|
import React273 from "react";
|
|
44635
|
-
import { useEffect as
|
|
44931
|
+
import { useEffect as useEffect72, useRef as useRef39 } from "react";
|
|
44636
44932
|
function FunClickOutside({
|
|
44637
44933
|
children,
|
|
44638
44934
|
onClick
|
|
44639
44935
|
}) {
|
|
44640
44936
|
const wrapperRef = useRef39(null);
|
|
44641
|
-
|
|
44937
|
+
useEffect72(() => {
|
|
44642
44938
|
const handleClickListener = (event) => {
|
|
44643
44939
|
const clickedInside = wrapperRef.current?.contains(
|
|
44644
44940
|
event.target
|
|
@@ -44821,7 +45117,7 @@ function Home({
|
|
|
44821
45117
|
const { checkoutHistoryList, isCheckoutHistoryInited } = useCheckoutHistoryContext();
|
|
44822
45118
|
const { returnViewPresets } = useActivityTraversal();
|
|
44823
45119
|
const { animation: tabAnimation, navigateTo } = useAnimatedNavigation(setSelectedView);
|
|
44824
|
-
|
|
45120
|
+
useEffect73(() => {
|
|
44825
45121
|
const virtuosoDiv = virtuosoParentRef.current?.firstChild;
|
|
44826
45122
|
virtuosoDiv?.classList.add(animateVirtuosoInClass);
|
|
44827
45123
|
}, []);
|
|
@@ -45551,13 +45847,13 @@ function ChainModal({ onClose, open }) {
|
|
|
45551
45847
|
}
|
|
45552
45848
|
|
|
45553
45849
|
// src/modals/CheckoutModal/FunCheckoutModal.tsx
|
|
45554
|
-
import React301, { useEffect as
|
|
45850
|
+
import React301, { useEffect as useEffect81, useLayoutEffect as useLayoutEffect3, useRef as useRef43 } from "react";
|
|
45555
45851
|
|
|
45556
45852
|
// src/components/FunConnectOptions/FunConnectOptions.tsx
|
|
45557
45853
|
import React293, { useCallback as useCallback57, useMemo as useMemo63, useState as useState84 } from "react";
|
|
45558
45854
|
|
|
45559
45855
|
// src/components/FunConnectOptions/FunConnectResultStep.tsx
|
|
45560
|
-
import React288, { useEffect as
|
|
45856
|
+
import React288, { useEffect as useEffect74 } from "react";
|
|
45561
45857
|
var AUTO_CLOSE = 2e3;
|
|
45562
45858
|
var messageMap = (hasQrCode) => ({
|
|
45563
45859
|
error: {
|
|
@@ -45576,7 +45872,7 @@ var FunConnectResultStep = ({
|
|
|
45576
45872
|
qrCodeUri
|
|
45577
45873
|
}) => {
|
|
45578
45874
|
const hasAutoclose = type === "success";
|
|
45579
|
-
|
|
45875
|
+
useEffect74(() => {
|
|
45580
45876
|
if (!hasAutoclose) {
|
|
45581
45877
|
return;
|
|
45582
45878
|
}
|
|
@@ -46111,20 +46407,20 @@ var FunCheckoutBlocked = ({ reason }) => {
|
|
|
46111
46407
|
};
|
|
46112
46408
|
|
|
46113
46409
|
// src/modals/CheckoutModal/CheckoutModalPrefetchedHooks.tsx
|
|
46114
|
-
import { useEffect as
|
|
46410
|
+
import { useEffect as useEffect75 } from "react";
|
|
46115
46411
|
function CheckoutModalPrefetchedHooks() {
|
|
46116
46412
|
const { checkoutItem } = useCheckoutContext();
|
|
46117
46413
|
const { address: walletAddress } = useAccount();
|
|
46118
46414
|
const { setTargetAssetSupportsPermit, setTargetAssetPoolAllowance } = useQuoteContext();
|
|
46119
46415
|
const aavePermitSupported = useAaveTargetReservePermit(checkoutItem);
|
|
46120
|
-
|
|
46416
|
+
useEffect75(() => {
|
|
46121
46417
|
setTargetAssetSupportsPermit(aavePermitSupported);
|
|
46122
46418
|
}, [aavePermitSupported, setTargetAssetSupportsPermit]);
|
|
46123
46419
|
const aavePoolAllowance = useAaveTargetPoolAllowance(
|
|
46124
46420
|
checkoutItem,
|
|
46125
46421
|
walletAddress
|
|
46126
46422
|
);
|
|
46127
|
-
|
|
46423
|
+
useEffect75(() => {
|
|
46128
46424
|
setTargetAssetPoolAllowance(aavePoolAllowance);
|
|
46129
46425
|
}, [aavePoolAllowance, setTargetAssetPoolAllowance]);
|
|
46130
46426
|
return null;
|
|
@@ -46132,7 +46428,7 @@ function CheckoutModalPrefetchedHooks() {
|
|
|
46132
46428
|
|
|
46133
46429
|
// src/modals/CheckoutModal/TransferToken/CheckoutNotifications.tsx
|
|
46134
46430
|
import clsx26 from "clsx";
|
|
46135
|
-
import React300, { useCallback as useCallback59, useEffect as
|
|
46431
|
+
import React300, { useCallback as useCallback59, useEffect as useEffect79, useMemo as useMemo64, useState as useState86 } from "react";
|
|
46136
46432
|
|
|
46137
46433
|
// src/components/FunNotificationBanner/FunNotificationShowMoreButton.tsx
|
|
46138
46434
|
import React295 from "react";
|
|
@@ -46200,10 +46496,10 @@ var useRecentCheckouts = ({
|
|
|
46200
46496
|
|
|
46201
46497
|
// src/hooks/useOnNewNotification.ts
|
|
46202
46498
|
import { safeParseJson as safeParseJson2 } from "@funkit/utils";
|
|
46203
|
-
import { useEffect as
|
|
46499
|
+
import { useEffect as useEffect76 } from "react";
|
|
46204
46500
|
var storageKey5 = "fkc-processed-notifications";
|
|
46205
46501
|
var useOnNewNotification = (combinedNotifications, cb) => {
|
|
46206
|
-
|
|
46502
|
+
useEffect76(() => {
|
|
46207
46503
|
const alreadyProcessed = safeParseJsonObject(
|
|
46208
46504
|
sessionStorage.getItem(storageKey5)
|
|
46209
46505
|
);
|
|
@@ -46250,7 +46546,7 @@ import React298 from "react";
|
|
|
46250
46546
|
|
|
46251
46547
|
// src/components/FunNotificationBanner/FunNotificationBanner.tsx
|
|
46252
46548
|
import { AnimatePresence as AnimatePresence6, motion as motion19 } from "motion/react";
|
|
46253
|
-
import React297, { useEffect as
|
|
46549
|
+
import React297, { useEffect as useEffect78, useRef as useRef42, useState as useState85 } from "react";
|
|
46254
46550
|
import clsx25 from "clsx";
|
|
46255
46551
|
|
|
46256
46552
|
// src/components/FunNotificationBanner/FunNotificationBanner.css.ts
|
|
@@ -46260,7 +46556,7 @@ var showMoreButtonStyle = "_4yitd93 _1rsrm2f1r4 _1rsrm2f1i _1rsrm2f1f _1rsrm2f11
|
|
|
46260
46556
|
// src/components/FunNotificationBanner/FunNotificationBannerIcon.tsx
|
|
46261
46557
|
import clsx24 from "clsx";
|
|
46262
46558
|
import { motion as motion18, useAnimate as useAnimate3 } from "motion/react";
|
|
46263
|
-
import React296, { useCallback as useCallback58, useEffect as
|
|
46559
|
+
import React296, { useCallback as useCallback58, useEffect as useEffect77, useRef as useRef41 } from "react";
|
|
46264
46560
|
|
|
46265
46561
|
// src/components/FunNotificationBanner/FunNotificationBannerIcon.css.ts
|
|
46266
46562
|
var STATUS_SPINNER_BOTTOM_POSITION = -5;
|
|
@@ -46710,7 +47006,7 @@ var FunNotificationBannerIcon = ({
|
|
|
46710
47006
|
]);
|
|
46711
47007
|
}, [animate]);
|
|
46712
47008
|
const statusRef = useRef41(status);
|
|
46713
|
-
|
|
47009
|
+
useEffect77(() => {
|
|
46714
47010
|
if (statusRef.current !== status) {
|
|
46715
47011
|
if (statusRef.current === "processing" && status === "completed") {
|
|
46716
47012
|
triggerAnimationProcessingToCompleted();
|
|
@@ -46810,7 +47106,7 @@ var FunNotificationBanner = ({
|
|
|
46810
47106
|
const [isOpen, setIsOpen] = useState85(true);
|
|
46811
47107
|
const prevStatusRef = useRef42(status);
|
|
46812
47108
|
const prevStatus = prevStatusRef.current;
|
|
46813
|
-
|
|
47109
|
+
useEffect78(() => {
|
|
46814
47110
|
prevStatusRef.current = status;
|
|
46815
47111
|
}, [status]);
|
|
46816
47112
|
const direction = status && prevStatus && prevStatus !== status && (STATUS_RANK[status] ?? 0) < (STATUS_RANK[prevStatus] ?? 0) ? -1 : 1;
|
|
@@ -46998,13 +47294,13 @@ var FunNotificationBanner = ({
|
|
|
46998
47294
|
import {
|
|
46999
47295
|
getCheckoutByDepositAddress as getCheckoutByDepositAddress2
|
|
47000
47296
|
} from "@funkit/api-base";
|
|
47001
|
-
import { useQuery as
|
|
47297
|
+
import { useQuery as useQuery25 } from "@tanstack/react-query";
|
|
47002
47298
|
var useCheckout = (depositAddress, initial) => {
|
|
47003
47299
|
const { apiKey } = useFunkitConfig();
|
|
47004
47300
|
const { itemRefresh } = useDynamicConfig(
|
|
47005
47301
|
"checkoutnotificationsrefreshinterval"
|
|
47006
47302
|
);
|
|
47007
|
-
const query =
|
|
47303
|
+
const query = useQuery25({
|
|
47008
47304
|
queryKey: ["checkouts", "checkout", depositAddress],
|
|
47009
47305
|
queryFn: () => getCheckoutByDepositAddress2({
|
|
47010
47306
|
// biome-ignore lint/style/noNonNullAssertion: already checked for null
|
|
@@ -47357,13 +47653,13 @@ var CheckoutNotifications = ({
|
|
|
47357
47653
|
}),
|
|
47358
47654
|
[directExecutions, variant]
|
|
47359
47655
|
);
|
|
47360
|
-
|
|
47656
|
+
useEffect79(() => {
|
|
47361
47657
|
if (initialCheckouts || !checkouts) {
|
|
47362
47658
|
return;
|
|
47363
47659
|
}
|
|
47364
47660
|
setInitialCheckouts(checkouts);
|
|
47365
47661
|
}, [initialCheckouts, checkouts]);
|
|
47366
|
-
|
|
47662
|
+
useEffect79(() => {
|
|
47367
47663
|
if (initialDirectExecutions || !directExecutions) {
|
|
47368
47664
|
return;
|
|
47369
47665
|
}
|
|
@@ -47478,7 +47774,7 @@ function selectSuccessScreenBackground({
|
|
|
47478
47774
|
}
|
|
47479
47775
|
|
|
47480
47776
|
// src/modals/CheckoutModal/useCheckoutBlocked.ts
|
|
47481
|
-
import { useEffect as
|
|
47777
|
+
import { useEffect as useEffect80 } from "react";
|
|
47482
47778
|
var geoblockedViewableSteps = /* @__PURE__ */ new Set([
|
|
47483
47779
|
"loading_account" /* LOADING_ACCOUNT */,
|
|
47484
47780
|
"source_change" /* SOURCE_CHANGE */
|
|
@@ -47516,7 +47812,7 @@ function useCheckoutBlocked(params) {
|
|
|
47516
47812
|
params.onCheckoutBlocked?.({ blockedReason: reason });
|
|
47517
47813
|
}
|
|
47518
47814
|
);
|
|
47519
|
-
|
|
47815
|
+
useEffect80(() => {
|
|
47520
47816
|
if (blockedReason) {
|
|
47521
47817
|
onCheckoutBlockedEvent(blockedReason);
|
|
47522
47818
|
}
|
|
@@ -47622,7 +47918,7 @@ function FunCheckoutModalInner({
|
|
|
47622
47918
|
setModalState
|
|
47623
47919
|
};
|
|
47624
47920
|
const connectionStatus = useConnectionStatus();
|
|
47625
|
-
|
|
47921
|
+
useEffect81(() => {
|
|
47626
47922
|
if (!modalState.showWalletOptions) {
|
|
47627
47923
|
return;
|
|
47628
47924
|
}
|
|
@@ -47913,7 +48209,7 @@ function ModalProvider({ children }) {
|
|
|
47913
48209
|
onConnect: () => closeModals(isUnauthenticated),
|
|
47914
48210
|
onDisconnect: closeModals
|
|
47915
48211
|
});
|
|
47916
|
-
|
|
48212
|
+
useEffect82(() => {
|
|
47917
48213
|
if (isUnauthenticated) {
|
|
47918
48214
|
closeModals();
|
|
47919
48215
|
}
|
|
@@ -48018,7 +48314,7 @@ function useConnectModal(onClose) {
|
|
|
48018
48314
|
const { connectModalOpen, openConnectModal } = useContext19(ModalContext);
|
|
48019
48315
|
const { isWalletConnectModalOpen } = useWalletConnectOpenState();
|
|
48020
48316
|
const effectiveConnectModalOpen = connectModalOpen || isWalletConnectModalOpen;
|
|
48021
|
-
|
|
48317
|
+
useEffect82(() => {
|
|
48022
48318
|
if (!effectiveConnectModalOpen && onClose) {
|
|
48023
48319
|
onClose();
|
|
48024
48320
|
}
|
|
@@ -48170,7 +48466,7 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
48170
48466
|
},
|
|
48171
48467
|
[]
|
|
48172
48468
|
);
|
|
48173
|
-
|
|
48469
|
+
useEffect83(() => {
|
|
48174
48470
|
if (isNotNullish7(logoutSymbol)) {
|
|
48175
48471
|
setActiveCheckout(null);
|
|
48176
48472
|
}
|
|
@@ -48965,13 +49261,13 @@ function useFunkitCheckout(props) {
|
|
|
48965
49261
|
});
|
|
48966
49262
|
openWithdrawalModal?.({ withdrawalId, ...config });
|
|
48967
49263
|
});
|
|
48968
|
-
|
|
49264
|
+
useEffect83(() => {
|
|
48969
49265
|
if (isUserLoggedIn && pendingCheckoutConfig) {
|
|
48970
49266
|
setPendingCheckoutConfig(void 0);
|
|
48971
49267
|
beginCheckout(pendingCheckoutConfig);
|
|
48972
49268
|
}
|
|
48973
49269
|
}, [beginCheckout, isUserLoggedIn, pendingCheckoutConfig]);
|
|
48974
|
-
|
|
49270
|
+
useEffect83(() => {
|
|
48975
49271
|
if (pendingCheckoutConfig && !isUserLoggedIn && !connectModalOpen) {
|
|
48976
49272
|
setPendingCheckoutConfig(void 0);
|
|
48977
49273
|
}
|
|
@@ -49458,7 +49754,7 @@ var useWalletAssets = ({
|
|
|
49458
49754
|
} = {}) => {
|
|
49459
49755
|
const { address, isConnected } = useAccount();
|
|
49460
49756
|
const { apiKey } = useFunkitConfig();
|
|
49461
|
-
const { data, isLoading, isFetching } =
|
|
49757
|
+
const { data, isLoading, isFetching } = useQuery26({
|
|
49462
49758
|
queryKey: ["getWalletAssets", address, apiKey],
|
|
49463
49759
|
meta: stepQueryMeta({
|
|
49464
49760
|
name: "walletAssets",
|
|
@@ -49759,7 +50055,7 @@ function ConnectButton({
|
|
|
49759
50055
|
const connectionStatus = useConnectionStatus();
|
|
49760
50056
|
const { setShowBalance } = useShowBalance();
|
|
49761
50057
|
const [ready, setReady] = useState89(false);
|
|
49762
|
-
|
|
50058
|
+
useEffect84(() => {
|
|
49763
50059
|
setShowBalance(showBalance);
|
|
49764
50060
|
if (!ready) {
|
|
49765
50061
|
setReady(true);
|