@funkit/connect 11.3.0 → 11.4.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 +34 -0
- package/dist/clients/{chunk-46L2KJJ4.js → chunk-3Y5EIONT.js} +5 -5
- package/dist/clients/{chunk-DGBIV3ZS.js → chunk-B7UU2ETA.js} +0 -13
- package/dist/clients/{chunk-QQEGNLGD.js → chunk-EQFVPSR2.js} +1 -1
- package/dist/clients/internal/nado/withdrawalCallback.js +3 -3
- package/dist/clients/internal/nado/withdrawalConfig.d.ts +2 -0
- package/dist/clients/internal/nado/withdrawalConfig.js +2 -2
- package/dist/clients/internal/nado/withdrawalForm.js +10 -55
- package/dist/clients/lighter.d.ts +0 -31
- package/dist/clients/lighter.js +5 -93
- package/dist/clients/nado.d.ts +2 -0
- package/dist/clients/nado.js +6 -5
- package/dist/clients/polymarket/PolymarketDepositAccountDropdown.js +4 -4
- package/dist/clients/polymarket/index.js +9 -9
- package/dist/domains/checkout.d.ts +6 -1
- package/dist/hooks/track/analytics/events.d.ts +5 -6
- package/dist/hooks/track/analytics/useTrackExecutionProgressEvents.d.ts +2 -33
- package/dist/hooks/track/useTrackV2.d.ts +2 -0
- package/dist/hooks/useAssetPrice.d.ts +1 -6
- package/dist/index.js +377 -537
- package/dist/providers/FunkitStatsigProvider.d.ts +1 -1
- package/dist/utils/withdrawal.d.ts +1 -21
- 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 +46 -46
- 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 +4 -4
- package/dist/clients/{chunk-L2XMI4EX.js → chunk-XJTRLB7W.js} +8 -8
- package/dist/wallets/walletConnectors/{chunk-W2LCLDPX.js → chunk-2VP2F6EK.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-IULPZP2Q.js → chunk-4T6ZSRJF.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-WAHGI5L7.js → chunk-6BW3HLBG.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-YO2K4MBH.js → chunk-CCQV2ZET.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-TKB2OY6G.js → chunk-CPI4TD43.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-OX37G4YT.js → chunk-F5XEEVG6.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-JPN6TWIT.js → chunk-HNRB7KJU.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-WKNQMP4A.js → chunk-HTHAK6XB.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-GUQM4QSL.js → chunk-MIQTHJ6X.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-4NV5BYRP.js → chunk-RB3HR4R2.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-SWFF3TWJ.js → chunk-RVOY537T.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-KI5Y2BBF.js → chunk-STVVP43G.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-OEEGYENV.js → chunk-UK7C2JXW.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-YQFGVZGR.js → chunk-VAPGUPHO.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-XCNHV3HS.js → chunk-VTM6EECM.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-NR2OGDHQ.js → chunk-X6CGV36L.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-AVDUNQUW.js → chunk-YEZM4CK4.js} +3 -3
- package/dist/wallets/walletConnectors/{chunk-KCRO2AGO.js → chunk-ZNX4EMPB.js} +3 -3
package/dist/index.js
CHANGED
|
@@ -5838,7 +5838,7 @@ import {
|
|
|
5838
5838
|
isEVMAddressEquivalent as isEVMAddressEquivalent6,
|
|
5839
5839
|
round as round4
|
|
5840
5840
|
} from "@funkit/utils";
|
|
5841
|
-
import * as
|
|
5841
|
+
import * as dnum11 from "dnum";
|
|
5842
5842
|
import { erc20Abi as erc20Abi8, formatUnits as formatUnits7, isAddress as isAddress2 } from "viem";
|
|
5843
5843
|
|
|
5844
5844
|
// src/wagmi/actions.ts
|
|
@@ -5908,7 +5908,7 @@ import {
|
|
|
5908
5908
|
import { isEVMAddressEquivalent as isEVMAddressEquivalent5, isNotNullish as isNotNullish7 } from "@funkit/utils";
|
|
5909
5909
|
import React306, {
|
|
5910
5910
|
createContext as createContext21,
|
|
5911
|
-
useCallback as
|
|
5911
|
+
useCallback as useCallback66,
|
|
5912
5912
|
useContext as useContext21,
|
|
5913
5913
|
useEffect as useEffect91,
|
|
5914
5914
|
useRef as useRef46,
|
|
@@ -6780,7 +6780,7 @@ function setFunkitConnectVersion({ version }) {
|
|
|
6780
6780
|
localStorage.setItem(storageKey, version);
|
|
6781
6781
|
}
|
|
6782
6782
|
function getCurrentSdkVersion() {
|
|
6783
|
-
return "11.
|
|
6783
|
+
return "11.4.0";
|
|
6784
6784
|
}
|
|
6785
6785
|
function useFingerprint() {
|
|
6786
6786
|
const fingerprint = useCallback3(() => {
|
|
@@ -10345,42 +10345,7 @@ import {
|
|
|
10345
10345
|
// src/utils/withdrawal.ts
|
|
10346
10346
|
import { chainMetadataById as chainMetadataById2 } from "@funkit/chains";
|
|
10347
10347
|
import { isEVMAddressEquivalent, isTokenEquivalent as isTokenEquivalent3 } from "@funkit/utils";
|
|
10348
|
-
import * as dnum3 from "dnum";
|
|
10349
10348
|
import { parseUnits } from "viem";
|
|
10350
|
-
function deductFlatFee(inputAmount, feeTokens) {
|
|
10351
|
-
if (!feeTokens || feeTokens <= 0) {
|
|
10352
|
-
return inputAmount;
|
|
10353
|
-
}
|
|
10354
|
-
try {
|
|
10355
|
-
const net = dnum3.subtract(inputAmount || "0", feeTokens);
|
|
10356
|
-
return dnum3.greaterThan(net, 0) ? dnum3.toString(net) : "0";
|
|
10357
|
-
} catch {
|
|
10358
|
-
return "0";
|
|
10359
|
-
}
|
|
10360
|
-
}
|
|
10361
|
-
function resolveWithdrawalSourceTokenBalance(fn, params) {
|
|
10362
|
-
if (!fn) {
|
|
10363
|
-
return void 0;
|
|
10364
|
-
}
|
|
10365
|
-
let raw;
|
|
10366
|
-
try {
|
|
10367
|
-
raw = fn(params);
|
|
10368
|
-
} catch (err) {
|
|
10369
|
-
logger.warn("withdrawal:sourceTokenBalanceThrew", {
|
|
10370
|
-
error: err instanceof Error ? err.message : String(err)
|
|
10371
|
-
});
|
|
10372
|
-
return "0";
|
|
10373
|
-
}
|
|
10374
|
-
if (raw == null) {
|
|
10375
|
-
return "0";
|
|
10376
|
-
}
|
|
10377
|
-
const str = String(raw);
|
|
10378
|
-
if (str === "" || Number.isNaN(Number(str)) || Number(str) < 0) {
|
|
10379
|
-
logger.warn("withdrawal:invalidSourceTokenBalance", { raw });
|
|
10380
|
-
return "0";
|
|
10381
|
-
}
|
|
10382
|
-
return str;
|
|
10383
|
-
}
|
|
10384
10349
|
function isWalletWithdrawalConfig(config) {
|
|
10385
10350
|
return "wallet" in config;
|
|
10386
10351
|
}
|
|
@@ -11265,10 +11230,10 @@ var useFunkitPostCheckoutInternal = (checkoutId) => {
|
|
|
11265
11230
|
// src/providers/ModalContext.tsx
|
|
11266
11231
|
import React305, {
|
|
11267
11232
|
createContext as createContext20,
|
|
11268
|
-
useCallback as
|
|
11233
|
+
useCallback as useCallback65,
|
|
11269
11234
|
useContext as useContext20,
|
|
11270
11235
|
useEffect as useEffect90,
|
|
11271
|
-
useMemo as
|
|
11236
|
+
useMemo as useMemo67,
|
|
11272
11237
|
useState as useState91
|
|
11273
11238
|
} from "react";
|
|
11274
11239
|
|
|
@@ -11286,7 +11251,8 @@ var topbarFadeWrapper = "_1r8f577";
|
|
|
11286
11251
|
var topbarOverflowContent = "_1r8f576 _1rsrm2fq3 _1rsrm2fs4";
|
|
11287
11252
|
|
|
11288
11253
|
// src/modals/WithdrawalModal/WithdrawalModal.tsx
|
|
11289
|
-
import
|
|
11254
|
+
import { resolveWithdrawalSourceTokenBalance as resolveWithdrawalSourceTokenBalance3 } from "@funkit/connect-core";
|
|
11255
|
+
import React151, { useCallback as useCallback33, useEffect as useEffect53, useState as useState47 } from "react";
|
|
11290
11256
|
import { mainnet as mainnet8 } from "viem/chains";
|
|
11291
11257
|
|
|
11292
11258
|
// src/clients/internal/nado/encoding.ts
|
|
@@ -11906,11 +11872,13 @@ function checkFeatureGate(name) {
|
|
|
11906
11872
|
}
|
|
11907
11873
|
|
|
11908
11874
|
// src/domains/checkout.ts
|
|
11909
|
-
var hasRisk = async (apiKey, walletAddress, customRecipient) => {
|
|
11875
|
+
var hasRisk = async (apiKey, walletAddress, customRecipient, chainIds) => {
|
|
11910
11876
|
const screeningDisabled = checkFeatureGate("disable-frontend-chainalysis");
|
|
11911
11877
|
const { isRisky } = await screenAddressesForRisk({
|
|
11912
11878
|
senderAddress: walletAddress,
|
|
11913
11879
|
recipientAddress: customRecipient,
|
|
11880
|
+
senderChainId: chainIds?.sourceChainId,
|
|
11881
|
+
recipientChainId: chainIds?.targetChainId,
|
|
11914
11882
|
apiKey,
|
|
11915
11883
|
logger,
|
|
11916
11884
|
screeningDisabled
|
|
@@ -15136,7 +15104,7 @@ function wrapResolveHealthFactor(resolve) {
|
|
|
15136
15104
|
// src/domains/quote.ts
|
|
15137
15105
|
import { getCheckoutQuote as getApiCheckoutQuote } from "@funkit/api-base";
|
|
15138
15106
|
import { RELAY_LIGHTER_CHAIN_ID } from "@funkit/fun-relay";
|
|
15139
|
-
import * as
|
|
15107
|
+
import * as dnum3 from "dnum";
|
|
15140
15108
|
import { formatUnits as formatUnits5 } from "viem";
|
|
15141
15109
|
|
|
15142
15110
|
// src/domains/fees.ts
|
|
@@ -15490,11 +15458,11 @@ async function checkAssetAmount(checkoutItem, finalEstimation, wagmiConfig, wall
|
|
|
15490
15458
|
0
|
|
15491
15459
|
);
|
|
15492
15460
|
const margin = 0.01;
|
|
15493
|
-
const minTargetAssetAmount =
|
|
15461
|
+
const minTargetAssetAmount = dnum3.from(
|
|
15494
15462
|
minSourceAssetAmount * exchangeRate * (1 + margin),
|
|
15495
15463
|
targetAssetDecimals
|
|
15496
15464
|
);
|
|
15497
|
-
const maxTargetAssetAmount =
|
|
15465
|
+
const maxTargetAssetAmount = dnum3.from(
|
|
15498
15466
|
maxSourceAssetAmount * exchangeRate * (1 - margin),
|
|
15499
15467
|
targetAssetDecimals
|
|
15500
15468
|
);
|
|
@@ -15611,7 +15579,7 @@ import React53, {
|
|
|
15611
15579
|
} from "react";
|
|
15612
15580
|
|
|
15613
15581
|
// src/domains/quoteMode/exactOut.ts
|
|
15614
|
-
import * as
|
|
15582
|
+
import * as dnum4 from "dnum";
|
|
15615
15583
|
|
|
15616
15584
|
// src/domains/feeEstimate.ts
|
|
15617
15585
|
import { mainnet as mainnet3 } from "viem/chains";
|
|
@@ -15666,10 +15634,10 @@ function createExactOutBuilder(isStablecoin) {
|
|
|
15666
15634
|
assetChainId,
|
|
15667
15635
|
paymentMethod
|
|
15668
15636
|
);
|
|
15669
|
-
const feeTokens =
|
|
15670
|
-
const maxAmount =
|
|
15671
|
-
const zero =
|
|
15672
|
-
return
|
|
15637
|
+
const feeTokens = dnum4.from(feeUsd / unitPrice, tokenBalanceBaseUnit[1]);
|
|
15638
|
+
const maxAmount = dnum4.subtract(tokenBalanceBaseUnit, feeTokens);
|
|
15639
|
+
const zero = dnum4.from(0, tokenBalanceBaseUnit[1]);
|
|
15640
|
+
return dnum4.greaterThan(maxAmount, zero) ? maxAmount : zero;
|
|
15673
15641
|
},
|
|
15674
15642
|
buildQuoteRequest({
|
|
15675
15643
|
tokenAmountBaseUnit
|
|
@@ -15681,7 +15649,7 @@ function createExactOutBuilder(isStablecoin) {
|
|
|
15681
15649
|
},
|
|
15682
15650
|
handleRetry({ error }) {
|
|
15683
15651
|
if (error.reason === "insufficientBalance" /* INSUFFICIENT_BALANCE */ && error.maxTargetAssetAmount !== void 0) {
|
|
15684
|
-
if (error.minTargetAssetAmount !== void 0 &&
|
|
15652
|
+
if (error.minTargetAssetAmount !== void 0 && dnum4.greaterThan(
|
|
15685
15653
|
error.minTargetAssetAmount,
|
|
15686
15654
|
error.maxTargetAssetAmount
|
|
15687
15655
|
)) {
|
|
@@ -15737,7 +15705,7 @@ function createExactOutBuilder(isStablecoin) {
|
|
|
15737
15705
|
}
|
|
15738
15706
|
|
|
15739
15707
|
// src/domains/quoteMode/exactIn.ts
|
|
15740
|
-
import * as
|
|
15708
|
+
import * as dnum5 from "dnum";
|
|
15741
15709
|
function createExactInBuilder() {
|
|
15742
15710
|
return {
|
|
15743
15711
|
mode: "EXACT_IN" /* EXACT_IN */,
|
|
@@ -15755,10 +15723,10 @@ function createExactInBuilder() {
|
|
|
15755
15723
|
if (!isNativeToken) {
|
|
15756
15724
|
return tokenBalanceBaseUnit;
|
|
15757
15725
|
}
|
|
15758
|
-
const gasBuffer = gasEstimateWei ??
|
|
15759
|
-
const zero =
|
|
15760
|
-
const maxAmount =
|
|
15761
|
-
return
|
|
15726
|
+
const gasBuffer = gasEstimateWei ?? dnum5.from(0, tokenBalanceBaseUnit[1]);
|
|
15727
|
+
const zero = dnum5.from(0, tokenBalanceBaseUnit[1]);
|
|
15728
|
+
const maxAmount = dnum5.subtract(tokenBalanceBaseUnit, gasBuffer);
|
|
15729
|
+
return dnum5.greaterThan(maxAmount, zero) ? maxAmount : zero;
|
|
15762
15730
|
},
|
|
15763
15731
|
buildQuoteRequest({
|
|
15764
15732
|
tokenAmountBaseUnit
|
|
@@ -15810,7 +15778,7 @@ function createExactInBuilder() {
|
|
|
15810
15778
|
return { type: "setFiatAmount" /* SET_FIAT_AMOUNT */, fiatAmount: percentage };
|
|
15811
15779
|
}
|
|
15812
15780
|
const base6 = maxSendableAmount ?? tokenBalanceBaseUnit;
|
|
15813
|
-
const fraction =
|
|
15781
|
+
const fraction = dnum5.multiply(base6, percentage / 100);
|
|
15814
15782
|
return {
|
|
15815
15783
|
type: "setTokenAmount" /* SET_TOKEN_AMOUNT */,
|
|
15816
15784
|
tokenAmountBaseUnit: fraction,
|
|
@@ -20426,7 +20394,7 @@ var STATUS_COPY = {
|
|
|
20426
20394
|
};
|
|
20427
20395
|
|
|
20428
20396
|
// src/modals/WithdrawalModal/WithdrawalCallbackSuccess.tsx
|
|
20429
|
-
import React120, { useMemo as
|
|
20397
|
+
import React120, { useMemo as useMemo35 } from "react";
|
|
20430
20398
|
|
|
20431
20399
|
// src/components/FunCheckoutHistory/PendingSuccessScreen.tsx
|
|
20432
20400
|
import {
|
|
@@ -23668,8 +23636,34 @@ var PendingSuccessScreen = ({
|
|
|
23668
23636
|
);
|
|
23669
23637
|
};
|
|
23670
23638
|
|
|
23671
|
-
// src/hooks/track/
|
|
23672
|
-
import {
|
|
23639
|
+
// src/hooks/track/useTrackV2.ts
|
|
23640
|
+
import { useCallback as useCallback26 } from "react";
|
|
23641
|
+
function useTrackV2() {
|
|
23642
|
+
const { logEventV2 } = useTrack();
|
|
23643
|
+
const { checkoutItem } = useCheckoutContext();
|
|
23644
|
+
const { apiKey } = useFunkitConfig();
|
|
23645
|
+
const { userInfo } = useGeneralWallet();
|
|
23646
|
+
const checkoutId = checkoutItem?.id;
|
|
23647
|
+
const isWithdrawal = !!checkoutItem?.isWithdrawal;
|
|
23648
|
+
const connectorName = userInfo.isConnected ? userInfo.typeLabel : null;
|
|
23649
|
+
const userId = userInfo.isConnected && userInfo.id !== "0x" ? userInfo.id : null;
|
|
23650
|
+
return useCallback26(
|
|
23651
|
+
(event, buildMetadata) => {
|
|
23652
|
+
if (!checkoutId) {
|
|
23653
|
+
return;
|
|
23654
|
+
}
|
|
23655
|
+
logEventV2(event, () => ({
|
|
23656
|
+
api_key: apiKey,
|
|
23657
|
+
checkout_id: checkoutId,
|
|
23658
|
+
connector_name: connectorName || null,
|
|
23659
|
+
flow: isWithdrawal ? "withdraw" : "deposit",
|
|
23660
|
+
user_id: userId || null,
|
|
23661
|
+
...buildMetadata()
|
|
23662
|
+
}));
|
|
23663
|
+
},
|
|
23664
|
+
[apiKey, checkoutId, connectorName, isWithdrawal, logEventV2, userId]
|
|
23665
|
+
);
|
|
23666
|
+
}
|
|
23673
23667
|
|
|
23674
23668
|
// src/hooks/track/analytics/resolveExecutionProgressContext.ts
|
|
23675
23669
|
import {
|
|
@@ -23861,7 +23855,7 @@ var eventNames = {
|
|
|
23861
23855
|
succeeded: "fc_withdrawal_succeeded" /* WITHDRAWAL_SUCCEEDED */
|
|
23862
23856
|
}
|
|
23863
23857
|
};
|
|
23864
|
-
function buildExecutionTransactionSnapshotProperties(args,
|
|
23858
|
+
function buildExecutionTransactionSnapshotProperties(args, connectorId) {
|
|
23865
23859
|
return {
|
|
23866
23860
|
...resolvePaymentMethodProperties(args, connectorId),
|
|
23867
23861
|
checkout_id: args.historicalCheckoutId,
|
|
@@ -23878,38 +23872,22 @@ function buildExecutionTransactionSnapshotProperties(args, connectedUserId, conn
|
|
|
23878
23872
|
target_asset_ticker: args.target.ticker,
|
|
23879
23873
|
trade_type: args.tradeType,
|
|
23880
23874
|
tx_hash: args.txHash,
|
|
23881
|
-
user_id: args.historicalUserId
|
|
23875
|
+
...args.historicalUserId ? { user_id: args.historicalUserId } : {},
|
|
23882
23876
|
...resolveVisibleQuoteFeeProperties(args.quote)
|
|
23883
23877
|
};
|
|
23884
23878
|
}
|
|
23885
23879
|
function useTrackExecutionProgressEvents(flow) {
|
|
23886
|
-
const
|
|
23887
|
-
const {
|
|
23888
|
-
const { connectorId, userInfo } = useGeneralWallet();
|
|
23880
|
+
const logEventV2 = useTrackV2();
|
|
23881
|
+
const { connectorId } = useGeneralWallet();
|
|
23889
23882
|
const names = eventNames[flow];
|
|
23890
|
-
const connectorName = userInfo.isConnected ? userInfo.typeLabel || null : null;
|
|
23891
|
-
const userId = userInfo.isConnected && userInfo.id !== "0x" ? userInfo.id || null : null;
|
|
23892
|
-
const commonProperties = useMemo35(
|
|
23893
|
-
() => ({
|
|
23894
|
-
api_key: apiKey,
|
|
23895
|
-
connector_name: connectorName,
|
|
23896
|
-
flow,
|
|
23897
|
-
user_id: userId
|
|
23898
|
-
}),
|
|
23899
|
-
[apiKey, connectorName, flow, userId]
|
|
23900
|
-
);
|
|
23901
23883
|
const trackExecutionTransactionSubmitted = useEffectEvent(
|
|
23902
23884
|
(args, claimKey) => {
|
|
23903
23885
|
if (!claimAnalyticsEvent(names.submitted, claimKey)) {
|
|
23904
23886
|
return;
|
|
23905
23887
|
}
|
|
23906
23888
|
logEventV2(names.submitted, () => ({
|
|
23907
|
-
|
|
23908
|
-
...buildExecutionTransactionSnapshotProperties(
|
|
23909
|
-
args,
|
|
23910
|
-
userId,
|
|
23911
|
-
connectorId
|
|
23912
|
-
),
|
|
23889
|
+
flow,
|
|
23890
|
+
...buildExecutionTransactionSnapshotProperties(args, connectorId),
|
|
23913
23891
|
est_fulfillment_time_ms: args.quote?.finalTimeEstimationMs ?? null
|
|
23914
23892
|
}));
|
|
23915
23893
|
}
|
|
@@ -23920,12 +23898,8 @@ function useTrackExecutionProgressEvents(flow) {
|
|
|
23920
23898
|
return;
|
|
23921
23899
|
}
|
|
23922
23900
|
logEventV2(names.succeeded, () => ({
|
|
23923
|
-
|
|
23924
|
-
...buildExecutionTransactionSnapshotProperties(
|
|
23925
|
-
args,
|
|
23926
|
-
userId,
|
|
23927
|
-
connectorId
|
|
23928
|
-
),
|
|
23901
|
+
flow,
|
|
23902
|
+
...buildExecutionTransactionSnapshotProperties(args, connectorId),
|
|
23929
23903
|
fulfillment_time_ms: args.fulfillmentTimeMs
|
|
23930
23904
|
}));
|
|
23931
23905
|
}
|
|
@@ -23936,12 +23910,8 @@ function useTrackExecutionProgressEvents(flow) {
|
|
|
23936
23910
|
return;
|
|
23937
23911
|
}
|
|
23938
23912
|
logEventV2(names.failed, () => ({
|
|
23939
|
-
|
|
23940
|
-
...buildExecutionTransactionSnapshotProperties(
|
|
23941
|
-
args,
|
|
23942
|
-
userId,
|
|
23943
|
-
connectorId
|
|
23944
|
-
),
|
|
23913
|
+
flow,
|
|
23914
|
+
...buildExecutionTransactionSnapshotProperties(args, connectorId),
|
|
23945
23915
|
error_code: args.errorCode
|
|
23946
23916
|
}));
|
|
23947
23917
|
}
|
|
@@ -23980,7 +23950,7 @@ var WithdrawalCallbackSuccess = ({
|
|
|
23980
23950
|
}) => {
|
|
23981
23951
|
const { t } = useFunkitTranslation();
|
|
23982
23952
|
const { trackExecutionProgressEvents } = useTrackExecutionProgressEvents("withdraw");
|
|
23983
|
-
const customTextConfigSteps =
|
|
23953
|
+
const customTextConfigSteps = useMemo35(() => {
|
|
23984
23954
|
return {
|
|
23985
23955
|
...getDefaultTextConfigSteps(t),
|
|
23986
23956
|
1: ({ textCustomizations }) => ({
|
|
@@ -24005,12 +23975,16 @@ var WithdrawalCallbackSuccess = ({
|
|
|
24005
23975
|
};
|
|
24006
23976
|
|
|
24007
23977
|
// src/modals/WithdrawalModal/WithdrawalContent.tsx
|
|
24008
|
-
import {
|
|
23978
|
+
import {
|
|
23979
|
+
deductFlatFee,
|
|
23980
|
+
extractRelayFeeInfo as extractRelayFeeInfo3,
|
|
23981
|
+
resolveWithdrawalSourceTokenBalance
|
|
23982
|
+
} from "@funkit/connect-core";
|
|
24009
23983
|
import {
|
|
24010
23984
|
formatCryptoAndStringify as formatCryptoAndStringify4,
|
|
24011
23985
|
formatCurrencyAndStringify as formatCurrencyAndStringify6
|
|
24012
23986
|
} from "@funkit/utils";
|
|
24013
|
-
import React138, { useEffect as useEffect45, useMemo as
|
|
23987
|
+
import React138, { useEffect as useEffect45, useMemo as useMemo40, useState as useState44 } from "react";
|
|
24014
23988
|
import { createPortal as createPortal5 } from "react-dom";
|
|
24015
23989
|
import { useDebounce } from "use-debounce";
|
|
24016
23990
|
import { isAddress } from "viem";
|
|
@@ -24018,7 +23992,7 @@ import { mainnet as mainnet7 } from "viem/chains";
|
|
|
24018
23992
|
|
|
24019
23993
|
// src/clients/internal/nado/hooks.ts
|
|
24020
23994
|
import { skipToken, useQuery as useQuery13, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
24021
|
-
import { useCallback as
|
|
23995
|
+
import { useCallback as useCallback27, useEffect as useEffect37, useReducer as useReducer3 } from "react";
|
|
24022
23996
|
|
|
24023
23997
|
// src/clients/internal/nado/errors.ts
|
|
24024
23998
|
var NadoGatewayError = class extends Error {
|
|
@@ -24221,7 +24195,7 @@ function useNadoMaxWithdrawable(params) {
|
|
|
24221
24195
|
}
|
|
24222
24196
|
function useInvalidateNadoMaxWithdrawable() {
|
|
24223
24197
|
const queryClient = useQueryClient3();
|
|
24224
|
-
return
|
|
24198
|
+
return useCallback27(() => {
|
|
24225
24199
|
queryClient.invalidateQueries({ queryKey: [MAX_WITHDRAWABLE_QUERY_KEY] });
|
|
24226
24200
|
}, [queryClient]);
|
|
24227
24201
|
}
|
|
@@ -24235,60 +24209,12 @@ function useNadoFeeRates(sender) {
|
|
|
24235
24209
|
}
|
|
24236
24210
|
|
|
24237
24211
|
// src/clients/internal/nado/withdrawalForm.ts
|
|
24238
|
-
import { useEffect as useEffect38, useMemo as
|
|
24212
|
+
import { useEffect as useEffect38, useMemo as useMemo36, useState as useState35 } from "react";
|
|
24239
24213
|
import { formatUnits as formatUnits6 } from "viem";
|
|
24240
24214
|
|
|
24241
24215
|
// src/hooks/useAssetPrice.ts
|
|
24242
|
-
import {
|
|
24243
|
-
getAssetPriceInfo as getAssetPriceInfo3
|
|
24244
|
-
} from "@funkit/api-base";
|
|
24245
|
-
import {
|
|
24246
|
-
convertFunToRelayTokenAddress,
|
|
24247
|
-
getRelayAssetPriceInfo
|
|
24248
|
-
} from "@funkit/fun-relay";
|
|
24216
|
+
import { getAssetPriceInfoWithFallback } from "@funkit/connect-core";
|
|
24249
24217
|
import { skipToken as skipToken2, useQuery as useQuery14 } from "@tanstack/react-query";
|
|
24250
|
-
async function getFormattedRelayAssetPriceInfo({
|
|
24251
|
-
chainId: chainId2,
|
|
24252
|
-
assetTokenAddress
|
|
24253
|
-
}) {
|
|
24254
|
-
try {
|
|
24255
|
-
const relayResponse = await getRelayAssetPriceInfo({
|
|
24256
|
-
chainId: chainId2,
|
|
24257
|
-
address: convertFunToRelayTokenAddress(
|
|
24258
|
-
assetTokenAddress,
|
|
24259
|
-
Number(chainId2)
|
|
24260
|
-
)
|
|
24261
|
-
});
|
|
24262
|
-
return {
|
|
24263
|
-
unitPrice: relayResponse.price,
|
|
24264
|
-
amount: 1,
|
|
24265
|
-
total: 1
|
|
24266
|
-
};
|
|
24267
|
-
} catch (error) {
|
|
24268
|
-
logger.error("Unable to fetch token price from Relay", error);
|
|
24269
|
-
throw error;
|
|
24270
|
-
}
|
|
24271
|
-
}
|
|
24272
|
-
async function getAssetPriceInfoWithFallback({
|
|
24273
|
-
apiKey,
|
|
24274
|
-
chainId: chainId2,
|
|
24275
|
-
assetTokenAddress
|
|
24276
|
-
}) {
|
|
24277
|
-
try {
|
|
24278
|
-
return await getAssetPriceInfo3({
|
|
24279
|
-
apiKey,
|
|
24280
|
-
assetTokenAddress,
|
|
24281
|
-
chainId: chainId2,
|
|
24282
|
-
logger
|
|
24283
|
-
});
|
|
24284
|
-
} catch (primaryError) {
|
|
24285
|
-
logger.warn(
|
|
24286
|
-
"Unable to fetch token price from Primary provider, trying fallback",
|
|
24287
|
-
{ primaryError }
|
|
24288
|
-
);
|
|
24289
|
-
return await getFormattedRelayAssetPriceInfo({ chainId: chainId2, assetTokenAddress });
|
|
24290
|
-
}
|
|
24291
|
-
}
|
|
24292
24218
|
function useAssetAddressPrice({
|
|
24293
24219
|
chainId: chainId2,
|
|
24294
24220
|
assetTokenAddress,
|
|
@@ -24304,7 +24230,8 @@ function useAssetAddressPrice({
|
|
|
24304
24230
|
queryFn: enabled && chainId2 && assetTokenAddress ? () => getAssetPriceInfoWithFallback({
|
|
24305
24231
|
apiKey,
|
|
24306
24232
|
chainId: chainId2,
|
|
24307
|
-
assetTokenAddress
|
|
24233
|
+
assetTokenAddress,
|
|
24234
|
+
logger
|
|
24308
24235
|
}) : skipToken2,
|
|
24309
24236
|
refetchInterval
|
|
24310
24237
|
});
|
|
@@ -24364,18 +24291,20 @@ function useNadoWithdrawalForm(config, selectedSourceToken) {
|
|
|
24364
24291
|
const isNado = !!nadoConfig;
|
|
24365
24292
|
const subaccount = nadoConfig?.customerConfig.subaccount;
|
|
24366
24293
|
const { t } = useFunkitTranslation();
|
|
24367
|
-
const [spotLeverage, setSpotLeverage] = useState35(
|
|
24294
|
+
const [spotLeverage, setSpotLeverage] = useState35(
|
|
24295
|
+
() => nadoConfig?.defaultSpotLeverage ?? false
|
|
24296
|
+
);
|
|
24368
24297
|
const { data: feeRates } = useNadoFeeRates(subaccount);
|
|
24369
24298
|
useEffect38(() => {
|
|
24370
|
-
setSpotLeverage(false);
|
|
24371
|
-
}, [subaccount]);
|
|
24299
|
+
setSpotLeverage(nadoConfig?.defaultSpotLeverage ?? false);
|
|
24300
|
+
}, [subaccount, nadoConfig?.defaultSpotLeverage]);
|
|
24372
24301
|
const amountToggle = {
|
|
24373
24302
|
label: t("withdrawal.enableBorrowing"),
|
|
24374
24303
|
tooltip: t("withdrawal.enableBorrowingTooltip"),
|
|
24375
24304
|
checked: spotLeverage,
|
|
24376
24305
|
onChange: setSpotLeverage
|
|
24377
24306
|
};
|
|
24378
|
-
const sourceOptions =
|
|
24307
|
+
const sourceOptions = useMemo36(
|
|
24379
24308
|
() => (nadoConfig?.sourceTokens ?? []).filter(isNadoSourceToken).map(({ asset, customData, symbol, iconSrc }) => ({
|
|
24380
24309
|
productId: customData.productId,
|
|
24381
24310
|
symbol,
|
|
@@ -24440,12 +24369,12 @@ function useNadoWithdrawalForm(config, selectedSourceToken) {
|
|
|
24440
24369
|
import React130 from "react";
|
|
24441
24370
|
|
|
24442
24371
|
// src/components/Dropdown/ChainDropdown.tsx
|
|
24443
|
-
import React128, { useMemo as
|
|
24372
|
+
import React128, { useMemo as useMemo38 } from "react";
|
|
24444
24373
|
|
|
24445
24374
|
// src/components/Dropdown/BaseDropdown.tsx
|
|
24446
24375
|
import { isMobile as isMobile4 } from "@funkit/utils";
|
|
24447
24376
|
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
24448
|
-
import React126, { useCallback as
|
|
24377
|
+
import React126, { useCallback as useCallback28, useEffect as useEffect39, useMemo as useMemo37, useRef as useRef18, useState as useState36 } from "react";
|
|
24449
24378
|
|
|
24450
24379
|
// src/components/FunNoResults/FunNoResults.tsx
|
|
24451
24380
|
import React123 from "react";
|
|
@@ -24912,7 +24841,7 @@ function BaseDropdown({
|
|
|
24912
24841
|
const [isOpened, setIsOpened] = useState36(false);
|
|
24913
24842
|
const [searchInput, setSearchInput] = useState36("");
|
|
24914
24843
|
const { ref: scrollRef, hasTopDivider, isAtBottom } = useScrollDivider();
|
|
24915
|
-
const allOptions =
|
|
24844
|
+
const allOptions = useMemo37(
|
|
24916
24845
|
() => buildAllOptions(options, allowUnselect, unselectLabel),
|
|
24917
24846
|
[options, allowUnselect, unselectLabel]
|
|
24918
24847
|
);
|
|
@@ -24922,11 +24851,11 @@ function BaseDropdown({
|
|
|
24922
24851
|
const handleSearch = (event) => {
|
|
24923
24852
|
setSearchInput(event.target.value);
|
|
24924
24853
|
};
|
|
24925
|
-
const filteredOptions =
|
|
24854
|
+
const filteredOptions = useMemo37(
|
|
24926
24855
|
() => filterOptions(allOptions, searchInput),
|
|
24927
24856
|
[allOptions, searchInput]
|
|
24928
24857
|
);
|
|
24929
|
-
const { organizedGroups, organizedOptions } =
|
|
24858
|
+
const { organizedGroups, organizedOptions } = useMemo37(
|
|
24930
24859
|
() => organizeDropdownGroups(
|
|
24931
24860
|
filteredOptions,
|
|
24932
24861
|
groups,
|
|
@@ -24935,7 +24864,7 @@ function BaseDropdown({
|
|
|
24935
24864
|
),
|
|
24936
24865
|
[additionalGroup, additionalGroupLabel, filteredOptions, groups]
|
|
24937
24866
|
);
|
|
24938
|
-
const handleOpenChange =
|
|
24867
|
+
const handleOpenChange = useCallback28(
|
|
24939
24868
|
(open) => {
|
|
24940
24869
|
setIsOpened(open);
|
|
24941
24870
|
if (open) {
|
|
@@ -25243,20 +25172,20 @@ var ChainDropdown = ({
|
|
|
25243
25172
|
}) => {
|
|
25244
25173
|
const { t } = useFunkitTranslation();
|
|
25245
25174
|
const getChainMetadata = useChainMetadata();
|
|
25246
|
-
const chainIds =
|
|
25175
|
+
const chainIds = useMemo38(() => {
|
|
25247
25176
|
const availableChainIds = new Set(Object.keys(assets).map(Number));
|
|
25248
25177
|
const priorityIds = (chainIdSortOrder ?? []).filter(
|
|
25249
25178
|
(id) => availableChainIds.has(id)
|
|
25250
25179
|
);
|
|
25251
25180
|
return [.../* @__PURE__ */ new Set([...priorityIds, ...availableChainIds])];
|
|
25252
25181
|
}, [assets, chainIdSortOrder]);
|
|
25253
|
-
const options =
|
|
25182
|
+
const options = useMemo38(() => {
|
|
25254
25183
|
return chainIds.map((chainId2) => ({
|
|
25255
25184
|
label: getChainMetadata(chainId2)?.name ?? "",
|
|
25256
25185
|
value: chainId2.toString()
|
|
25257
25186
|
}));
|
|
25258
25187
|
}, [chainIds, getChainMetadata]);
|
|
25259
|
-
const preloadIconUrls =
|
|
25188
|
+
const preloadIconUrls = useMemo38(
|
|
25260
25189
|
() => chainIds.map((id) => getChainMetadata(id)?.iconUrl).filter((url) => typeof url === "string"),
|
|
25261
25190
|
[chainIds, getChainMetadata]
|
|
25262
25191
|
);
|
|
@@ -25353,7 +25282,7 @@ var ChainDropdown = ({
|
|
|
25353
25282
|
};
|
|
25354
25283
|
|
|
25355
25284
|
// src/components/Dropdown/TokenDropdown.tsx
|
|
25356
|
-
import React129, { useMemo as
|
|
25285
|
+
import React129, { useMemo as useMemo39, useState as useState37 } from "react";
|
|
25357
25286
|
var TOKEN_ICON_SIZE = 16;
|
|
25358
25287
|
var useNewTokens = () => {
|
|
25359
25288
|
const bannerData = useNewTokenBanner();
|
|
@@ -25379,7 +25308,7 @@ var TokenDropdown = ({
|
|
|
25379
25308
|
const enabledTokens = selectedChainId ? assets[selectedChainId] : void 0;
|
|
25380
25309
|
const [isTouched, setIsTouched] = useState37(false);
|
|
25381
25310
|
const [selectedSymbol, setSelectedSymbol] = useState37(selectedToken);
|
|
25382
|
-
const allTokens =
|
|
25311
|
+
const allTokens = useMemo39(() => {
|
|
25383
25312
|
const tokens = new Set(Object.values(assets).flat());
|
|
25384
25313
|
const sortedTokens = [...tokens].sort((a, b) => a.localeCompare(b));
|
|
25385
25314
|
const validPriorityTokens = priorityTokenSymbols?.filter(
|
|
@@ -25391,13 +25320,13 @@ var TokenDropdown = ({
|
|
|
25391
25320
|
return sortedTokens;
|
|
25392
25321
|
}, [assets, priorityTokenSymbols]);
|
|
25393
25322
|
const { newTokens, newSymbol } = useNewTokens();
|
|
25394
|
-
const options =
|
|
25323
|
+
const options = useMemo39(() => {
|
|
25395
25324
|
return allTokens.map((symbol) => ({
|
|
25396
25325
|
label: symbol,
|
|
25397
25326
|
value: symbol
|
|
25398
25327
|
}));
|
|
25399
25328
|
}, [allTokens]);
|
|
25400
|
-
const groups =
|
|
25329
|
+
const groups = useMemo39(() => {
|
|
25401
25330
|
if (!popularTokenSymbols?.length) {
|
|
25402
25331
|
return [];
|
|
25403
25332
|
}
|
|
@@ -26069,11 +25998,10 @@ import { isWithdrawalRisky } from "@funkit/connect-core";
|
|
|
26069
25998
|
import { useQuery as useQuery16 } from "@tanstack/react-query";
|
|
26070
25999
|
var useWithdrawalRisk = (apiKey, receiveAddress, chainId2) => {
|
|
26071
26000
|
return useQuery16({
|
|
26072
|
-
|
|
26073
|
-
// the fetcher doesn't use it — chainId only gates `enabled` below.
|
|
26074
|
-
queryKey: ["withdrawal", "addressRisk", apiKey, receiveAddress],
|
|
26001
|
+
queryKey: ["withdrawal", "addressRisk", apiKey, receiveAddress, chainId2],
|
|
26075
26002
|
queryFn: () => isWithdrawalRisky({
|
|
26076
26003
|
address: receiveAddress,
|
|
26004
|
+
chainId: chainId2?.toString(),
|
|
26077
26005
|
apiKey,
|
|
26078
26006
|
logger,
|
|
26079
26007
|
screeningDisabled: checkFeatureGate("disable-frontend-chainalysis")
|
|
@@ -26092,30 +26020,18 @@ var useWithdrawalRisk = (apiKey, receiveAddress, chainId2) => {
|
|
|
26092
26020
|
};
|
|
26093
26021
|
|
|
26094
26022
|
// src/hooks/track/analytics/useWithdrawalAnalytics.ts
|
|
26095
|
-
import { useCallback as
|
|
26023
|
+
import { useCallback as useCallback29 } from "react";
|
|
26096
26024
|
function useWithdrawalAnalytics() {
|
|
26097
|
-
const
|
|
26025
|
+
const logEventV2 = useTrackV2();
|
|
26098
26026
|
const { checkoutItem } = useCheckoutContext();
|
|
26099
|
-
const { apiKey } = useFunkitConfig();
|
|
26100
|
-
const { connectorId, userInfo } = useGeneralWallet();
|
|
26101
26027
|
const checkoutId = checkoutItem?.id;
|
|
26102
|
-
const
|
|
26103
|
-
() => ({
|
|
26104
|
-
api_key: apiKey,
|
|
26105
|
-
connector_name: connectorId ? userInfo.typeLabel || null : null,
|
|
26106
|
-
flow: "withdraw",
|
|
26107
|
-
user_id: userInfo.id && userInfo.id !== "0x" ? userInfo.id : null
|
|
26108
|
-
}),
|
|
26109
|
-
[apiKey, connectorId, userInfo]
|
|
26110
|
-
);
|
|
26111
|
-
const trackWithdrawalAmountConfirmed = useCallback28(
|
|
26028
|
+
const trackWithdrawalAmountConfirmed = useCallback29(
|
|
26112
26029
|
(args) => {
|
|
26113
26030
|
if (!checkoutId) {
|
|
26114
26031
|
return;
|
|
26115
26032
|
}
|
|
26116
26033
|
logEventV2("fc_withdrawal_amount_confirmed" /* WITHDRAWAL_AMOUNT_CONFIRMED */, () => ({
|
|
26117
|
-
|
|
26118
|
-
checkout_id: checkoutId,
|
|
26034
|
+
flow: "withdraw",
|
|
26119
26035
|
payment_method: PaymentMethod.ACCOUNT_BALANCE,
|
|
26120
26036
|
provider: null,
|
|
26121
26037
|
select_type: args.selectType,
|
|
@@ -26130,7 +26046,7 @@ function useWithdrawalAnalytics() {
|
|
|
26130
26046
|
trade_type: "EXACT_IN" /* EXACT_IN */
|
|
26131
26047
|
}));
|
|
26132
26048
|
},
|
|
26133
|
-
[
|
|
26049
|
+
[logEventV2]
|
|
26134
26050
|
);
|
|
26135
26051
|
return { trackWithdrawalAmountConfirmed };
|
|
26136
26052
|
}
|
|
@@ -26816,7 +26732,7 @@ function getRelayOutputCurrencyAmount(quote, fallback2) {
|
|
|
26816
26732
|
}
|
|
26817
26733
|
|
|
26818
26734
|
// src/modals/WithdrawalModal/withdrawalHooks.tsx
|
|
26819
|
-
import { useCallback as
|
|
26735
|
+
import { useCallback as useCallback30, useEffect as useEffect43, useRef as useRef20 } from "react";
|
|
26820
26736
|
|
|
26821
26737
|
// src/hooks/useTokenAndChainDropdown.ts
|
|
26822
26738
|
import { useEffect as useEffect42, useState as useState41 } from "react";
|
|
@@ -27025,7 +26941,7 @@ var useFrozenSourceTokenBalance = ({
|
|
|
27025
26941
|
frozenSourceTokenBalanceRef.current = null;
|
|
27026
26942
|
}
|
|
27027
26943
|
const displayedSourceTokenBalance = frozenSourceTokenBalanceRef.current ?? sourceTokenBalance;
|
|
27028
|
-
const freezeDisplayedSourceTokenBalance =
|
|
26944
|
+
const freezeDisplayedSourceTokenBalance = useCallback30((balance) => {
|
|
27029
26945
|
frozenSourceTokenBalanceRef.current = balance;
|
|
27030
26946
|
}, []);
|
|
27031
26947
|
return {
|
|
@@ -27127,7 +27043,7 @@ function useWithdrawalLogging({
|
|
|
27127
27043
|
import { useState as useState43 } from "react";
|
|
27128
27044
|
|
|
27129
27045
|
// src/hooks/useAutoClearState.ts
|
|
27130
|
-
import { useCallback as
|
|
27046
|
+
import { useCallback as useCallback31, useEffect as useEffect44, useRef as useRef21, useState as useState42 } from "react";
|
|
27131
27047
|
function useAutoClearState(initialValue = null) {
|
|
27132
27048
|
const [state, setState] = useState42(initialValue);
|
|
27133
27049
|
const timeoutRef = useRef21(void 0);
|
|
@@ -27140,7 +27056,7 @@ function useAutoClearState(initialValue = null) {
|
|
|
27140
27056
|
}, []);
|
|
27141
27057
|
return [
|
|
27142
27058
|
state,
|
|
27143
|
-
|
|
27059
|
+
useCallback31((newState, durationMs) => {
|
|
27144
27060
|
if (timeoutRef.current) {
|
|
27145
27061
|
clearTimeout(timeoutRef.current);
|
|
27146
27062
|
timeoutRef.current = void 0;
|
|
@@ -27697,7 +27613,8 @@ function usePostClientCommonWithdrawalFlow({
|
|
|
27697
27613
|
},
|
|
27698
27614
|
// Same precedence: a declared option describes itself, else the client does.
|
|
27699
27615
|
customData: selectedOption?.customData ?? clientSourceCustomData
|
|
27700
|
-
}
|
|
27616
|
+
},
|
|
27617
|
+
logger
|
|
27701
27618
|
);
|
|
27702
27619
|
const sourceTokenBalance = integratorBalance ?? clientSourceTokenBalance ?? "0";
|
|
27703
27620
|
const { displayedSourceTokenBalance, freezeDisplayedSourceTokenBalance } = useFrozenSourceTokenBalance({
|
|
@@ -27923,7 +27840,7 @@ function usePostClientCommonWithdrawalFlow({
|
|
|
27923
27840
|
selectedChainName,
|
|
27924
27841
|
t
|
|
27925
27842
|
});
|
|
27926
|
-
const errorNotification =
|
|
27843
|
+
const errorNotification = useMemo40(
|
|
27927
27844
|
() => getErrorNotification({
|
|
27928
27845
|
quoteErrorObject,
|
|
27929
27846
|
withdrawalError,
|
|
@@ -28301,7 +28218,7 @@ import React144 from "react";
|
|
|
28301
28218
|
// src/hooks/queries/useWithdrawFops.ts
|
|
28302
28219
|
import { RailConfigType as RailConfigType3, getFops as getFops3 } from "@funkit/api-base";
|
|
28303
28220
|
import { useQuery as useQuery17 } from "@tanstack/react-query";
|
|
28304
|
-
import { useMemo as
|
|
28221
|
+
import { useMemo as useMemo41 } from "react";
|
|
28305
28222
|
import {
|
|
28306
28223
|
buildSwappedSellLimits,
|
|
28307
28224
|
buildSwappedThirdPartyPaymentConfigs as buildSwappedThirdPartyPaymentConfigs2,
|
|
@@ -28319,7 +28236,7 @@ var useWithdrawFops = (params) => {
|
|
|
28319
28236
|
} = useSwappedDefaultCurrency();
|
|
28320
28237
|
const fopPriority = useDynamicConfig("foppriority");
|
|
28321
28238
|
const sourceOverrides = useDynamicConfig("swappedwithdrawalsourceoverrides");
|
|
28322
|
-
const sourceOverride =
|
|
28239
|
+
const sourceOverride = useMemo41(
|
|
28323
28240
|
() => findSwappedSourceOverride(sourceOverrides, {
|
|
28324
28241
|
chainId: params.sourceChainId,
|
|
28325
28242
|
tokenAddress: params.sourceTokenAddress
|
|
@@ -28330,7 +28247,7 @@ var useWithdrawFops = (params) => {
|
|
|
28330
28247
|
chainId: sourceOverride.use.chainId,
|
|
28331
28248
|
address: sourceOverride.use.tokenAddress
|
|
28332
28249
|
} : { chainId: params.sourceChainId, address: params.sourceTokenAddress };
|
|
28333
|
-
const themeConfig =
|
|
28250
|
+
const themeConfig = useMemo41(
|
|
28334
28251
|
() => buildSwappedThemeQueryParams(resolveObjectCssVars(activeTheme)),
|
|
28335
28252
|
[activeTheme]
|
|
28336
28253
|
);
|
|
@@ -29102,7 +29019,8 @@ function useSwappedIframeLifecycle({
|
|
|
29102
29019
|
import { getCheckoutQuoteV2 as getCheckoutQuoteV22 } from "@funkit/api-base";
|
|
29103
29020
|
import { useEffect as useEffect48, useRef as useRef24 } from "react";
|
|
29104
29021
|
import {
|
|
29105
|
-
findSwappedSourceOverride as findSwappedSourceOverride2
|
|
29022
|
+
findSwappedSourceOverride as findSwappedSourceOverride2,
|
|
29023
|
+
resolveWithdrawalSourceTokenBalance as resolveWithdrawalSourceTokenBalance2
|
|
29106
29024
|
} from "@funkit/connect-core";
|
|
29107
29025
|
function resolveSwappedWithdrawalLegs(config, override) {
|
|
29108
29026
|
const sourceChainId = Number(config.sourceChainId);
|
|
@@ -29300,14 +29218,15 @@ function useFiatWithdrawal({
|
|
|
29300
29218
|
const { quote, estimation } = await quoteOrderExactOut(quoteContext);
|
|
29301
29219
|
let finalQuote = quote;
|
|
29302
29220
|
let finalEstimation = estimation;
|
|
29303
|
-
const balance =
|
|
29221
|
+
const balance = resolveWithdrawalSourceTokenBalance2(
|
|
29304
29222
|
withdrawalItem?.withdrawalSourceTokenBalance,
|
|
29305
29223
|
{
|
|
29306
29224
|
sourceAsset: {
|
|
29307
29225
|
tokenAddress: legs.sourceTokenAddress,
|
|
29308
29226
|
tokenChainId: String(legs.sourceChainId)
|
|
29309
29227
|
}
|
|
29310
|
-
}
|
|
29228
|
+
},
|
|
29229
|
+
logger
|
|
29311
29230
|
) ?? "0";
|
|
29312
29231
|
if (Number(balance) > 0) {
|
|
29313
29232
|
const sourceDecimals = await getTokenDecimals(
|
|
@@ -29564,7 +29483,7 @@ import React149 from "react";
|
|
|
29564
29483
|
import React148, { useEffect as useEffect51 } from "react";
|
|
29565
29484
|
|
|
29566
29485
|
// src/components/FunCheckoutHistory/FunCheckoutHistoryDetail.tsx
|
|
29567
|
-
import React147, { useCallback as
|
|
29486
|
+
import React147, { useCallback as useCallback32, useMemo as useMemo42, useState as useState46 } from "react";
|
|
29568
29487
|
import { createPortal as createPortal6 } from "react-dom";
|
|
29569
29488
|
|
|
29570
29489
|
// src/hooks/useFunListeners.ts
|
|
@@ -29609,7 +29528,7 @@ function FunCheckoutHistoryDetail({
|
|
|
29609
29528
|
useCheckoutHistoryListener(isProcessing, checkoutHistoryInfo?.depositAddr);
|
|
29610
29529
|
useWalletAssets({ enableRefetchInterval: isProcessing || isCompleted });
|
|
29611
29530
|
const { beginCheckout } = useFunkitCheckout({});
|
|
29612
|
-
const handleNewCheckout =
|
|
29531
|
+
const handleNewCheckout = useCallback32(
|
|
29613
29532
|
(fromCheckout) => {
|
|
29614
29533
|
onClose({ isNewDeposit: true });
|
|
29615
29534
|
const historicalCheckout = fromCheckout.clientMetadata;
|
|
@@ -29628,7 +29547,7 @@ function FunCheckoutHistoryDetail({
|
|
|
29628
29547
|
isActiveCheckout
|
|
29629
29548
|
]
|
|
29630
29549
|
);
|
|
29631
|
-
const primaryButtonProps =
|
|
29550
|
+
const primaryButtonProps = useMemo42(() => {
|
|
29632
29551
|
if (!isCheckoutLoaded) {
|
|
29633
29552
|
return void 0;
|
|
29634
29553
|
}
|
|
@@ -29835,11 +29754,10 @@ function WithdrawalTypeSelect({
|
|
|
29835
29754
|
// src/modals/WithdrawalModal/useTrackWithdrawalEvents.ts
|
|
29836
29755
|
import { useEffect as useEffect52 } from "react";
|
|
29837
29756
|
function useTrackWithdrawalEvents() {
|
|
29838
|
-
const
|
|
29757
|
+
const logEventV2 = useTrackV2();
|
|
29839
29758
|
const { checkoutItem } = useCheckoutContext();
|
|
29840
|
-
const { apiKey } = useFunkitConfig();
|
|
29841
29759
|
const { authorizedConnections } = useFunkitBrokerageContext();
|
|
29842
|
-
const { connectorId,
|
|
29760
|
+
const { connectorId, walletAddress } = useGeneralWallet();
|
|
29843
29761
|
const trackModalOpened = useEffectEvent(() => {
|
|
29844
29762
|
if (!checkoutItem) {
|
|
29845
29763
|
return;
|
|
@@ -29847,22 +29765,17 @@ function useTrackWithdrawalEvents() {
|
|
|
29847
29765
|
const config = checkoutItem.initSettings.config;
|
|
29848
29766
|
const sourceAsset = checkoutItem.selectedSourceAssetInfo;
|
|
29849
29767
|
const exchanges = Object.keys(authorizedConnections);
|
|
29850
|
-
const userId = userInfo.id && userInfo.id !== "0x" ? userInfo.id : null;
|
|
29851
29768
|
logEventV2("fc_modal_opened" /* MODAL_OPENED */, () => ({
|
|
29852
|
-
api_key: apiKey,
|
|
29853
|
-
checkout_id: checkoutItem.id,
|
|
29854
|
-
connector_name: connectorId ? userInfo.typeLabel || null : null,
|
|
29855
|
-
flow: "withdraw",
|
|
29856
|
-
tab: "withdraw",
|
|
29857
|
-
user_id: userId,
|
|
29858
29769
|
custom_recipient: config.customRecipient || null,
|
|
29859
29770
|
dynamic_routing_id: config.dynamicRoutingId || null,
|
|
29860
29771
|
exchange_count: exchanges.length,
|
|
29772
|
+
flow: "withdraw",
|
|
29861
29773
|
primary_exchange: exchanges[0] || null,
|
|
29862
29774
|
primary_wallet: walletAddress ? connectorId || null : null,
|
|
29863
29775
|
source_asset: sourceAsset.address,
|
|
29864
29776
|
source_asset_ticker: sourceAsset.symbol || null,
|
|
29865
29777
|
source_chain: sourceAsset.chainId,
|
|
29778
|
+
tab: "withdraw",
|
|
29866
29779
|
// Target asset is not yet known when withdrawal modal is opened
|
|
29867
29780
|
target_asset: null,
|
|
29868
29781
|
target_asset_ticker: null,
|
|
@@ -29929,7 +29842,7 @@ function WithdrawalModal({
|
|
|
29929
29842
|
animate(() => setStep(nextStep), { reverse: opts?.reverseAnimation });
|
|
29930
29843
|
}
|
|
29931
29844
|
};
|
|
29932
|
-
const onCloseWrapper =
|
|
29845
|
+
const onCloseWrapper = useCallback33(() => {
|
|
29933
29846
|
logEvent({
|
|
29934
29847
|
eventName: "fw::modal_closed" /* MODAL_CLOSED */,
|
|
29935
29848
|
metadata: {
|
|
@@ -29962,7 +29875,7 @@ function WithdrawalModal({
|
|
|
29962
29875
|
withTopDivider: modalTitleMeta ? "always" : "scroll",
|
|
29963
29876
|
scrollableContent: WITHDRAWAL_MODAL_CONTENT_ID
|
|
29964
29877
|
});
|
|
29965
|
-
const handleNewWithdrawal =
|
|
29878
|
+
const handleNewWithdrawal = useCallback33(() => {
|
|
29966
29879
|
resetForNewWithdrawal();
|
|
29967
29880
|
setSelectedMethodId(null);
|
|
29968
29881
|
navigateToStep(
|
|
@@ -30085,14 +29998,15 @@ function WithdrawalModal({
|
|
|
30085
29998
|
sourceChainId: activeConfig.sourceChainId,
|
|
30086
29999
|
sourceTokenAddress: activeConfig.sourceTokenAddress,
|
|
30087
30000
|
usdBalance: Number(
|
|
30088
|
-
|
|
30001
|
+
resolveWithdrawalSourceTokenBalance3(
|
|
30089
30002
|
withdrawalItem?.withdrawalSourceTokenBalance,
|
|
30090
30003
|
{
|
|
30091
30004
|
sourceAsset: {
|
|
30092
30005
|
tokenAddress: activeConfig.sourceTokenAddress,
|
|
30093
30006
|
tokenChainId: activeConfig.sourceChainId
|
|
30094
30007
|
}
|
|
30095
|
-
}
|
|
30008
|
+
},
|
|
30009
|
+
logger
|
|
30096
30010
|
) ?? "0"
|
|
30097
30011
|
),
|
|
30098
30012
|
onCryptoSelect: () => {
|
|
@@ -30175,9 +30089,9 @@ import React284 from "react";
|
|
|
30175
30089
|
// src/modals/ProfileDetails/ActivityTraversalContext.tsx
|
|
30176
30090
|
import React152, {
|
|
30177
30091
|
createContext as createContext19,
|
|
30178
|
-
useCallback as
|
|
30092
|
+
useCallback as useCallback34,
|
|
30179
30093
|
useContext as useContext19,
|
|
30180
|
-
useMemo as
|
|
30094
|
+
useMemo as useMemo43,
|
|
30181
30095
|
useState as useState48
|
|
30182
30096
|
} from "react";
|
|
30183
30097
|
var ActivityTraversalContext = createContext19({
|
|
@@ -30197,7 +30111,7 @@ var ActivityTraversalProvider = ({
|
|
|
30197
30111
|
const [returnViewPresets, setReturnViewPresets] = useState48(
|
|
30198
30112
|
{}
|
|
30199
30113
|
);
|
|
30200
|
-
const onSelectActivity =
|
|
30114
|
+
const onSelectActivity = useCallback34(
|
|
30201
30115
|
({
|
|
30202
30116
|
checkoutId,
|
|
30203
30117
|
initialPage,
|
|
@@ -30215,12 +30129,12 @@ var ActivityTraversalProvider = ({
|
|
|
30215
30129
|
},
|
|
30216
30130
|
[]
|
|
30217
30131
|
);
|
|
30218
|
-
const resetActivityTraversal =
|
|
30132
|
+
const resetActivityTraversal = useCallback34(() => {
|
|
30219
30133
|
setSelectedPurchaseId(void 0);
|
|
30220
30134
|
setSelectedPurchaseInitView(void 0);
|
|
30221
30135
|
setReturnView(void 0);
|
|
30222
30136
|
}, []);
|
|
30223
|
-
const contextValue =
|
|
30137
|
+
const contextValue = useMemo43(
|
|
30224
30138
|
() => ({
|
|
30225
30139
|
selectedPurchaseId,
|
|
30226
30140
|
selectedPurchaseInitView,
|
|
@@ -30245,25 +30159,25 @@ var useActivityTraversal = () => {
|
|
|
30245
30159
|
};
|
|
30246
30160
|
|
|
30247
30161
|
// src/modals/ProfileDetails/ProfileDetails.tsx
|
|
30248
|
-
import React283, { useCallback as
|
|
30162
|
+
import React283, { useCallback as useCallback61, useState as useState85 } from "react";
|
|
30249
30163
|
|
|
30250
30164
|
// src/components/ModalHeightAnimationLayer/FunCheckoutModalHeightAnimationWrapper.tsx
|
|
30251
30165
|
import React270 from "react";
|
|
30252
30166
|
|
|
30253
30167
|
// src/modals/CheckoutModal/stepTransition.ts
|
|
30254
30168
|
import {
|
|
30255
|
-
useCallback as
|
|
30169
|
+
useCallback as useCallback59,
|
|
30256
30170
|
useEffect as useEffect78,
|
|
30257
30171
|
useRef as useRef40,
|
|
30258
30172
|
useState as useState82
|
|
30259
30173
|
} from "react";
|
|
30260
30174
|
|
|
30261
30175
|
// src/hooks/useCheckoutQuoteNotification.ts
|
|
30262
|
-
import { useMemo as
|
|
30176
|
+
import { useMemo as useMemo44 } from "react";
|
|
30263
30177
|
function useCheckoutQuoteNotification() {
|
|
30264
30178
|
const { clearCheckoutQuoteMessages } = useQuoteContext();
|
|
30265
30179
|
const { quoteErrorMessage, quoteStepMessage } = useQuoteContext();
|
|
30266
|
-
const quoteNotification =
|
|
30180
|
+
const quoteNotification = useMemo44(() => {
|
|
30267
30181
|
if (quoteErrorMessage) {
|
|
30268
30182
|
return {
|
|
30269
30183
|
messageType: "error",
|
|
@@ -30513,7 +30427,7 @@ import {
|
|
|
30513
30427
|
BridgeCustomerStatus as BridgeCustomerStatus4
|
|
30514
30428
|
} from "@funkit/api-base";
|
|
30515
30429
|
import { exhaustiveCheck as exhaustiveCheck3 } from "@funkit/utils";
|
|
30516
|
-
import React162, { useCallback as
|
|
30430
|
+
import React162, { useCallback as useCallback35, useState as useState50 } from "react";
|
|
30517
30431
|
import { createPortal as createPortal8 } from "react-dom";
|
|
30518
30432
|
|
|
30519
30433
|
// src/components/Icons/HomeIcon.tsx
|
|
@@ -31147,7 +31061,7 @@ var VerifyAccountScreen = ({
|
|
|
31147
31061
|
const kycUninitialized = !isSoftRejected2 && customerStatus && isKycUninitialized(customerStatus);
|
|
31148
31062
|
const canStartKyc = kycUninitialized || isSoftRejected2;
|
|
31149
31063
|
const handleCreateVirtualFiatAccount = useCreateVirtualBankAccount();
|
|
31150
|
-
const onClick =
|
|
31064
|
+
const onClick = useCallback35(async () => {
|
|
31151
31065
|
if (customerStatus === BridgeCustomerStatus4.ACTIVE) {
|
|
31152
31066
|
setCreating(true);
|
|
31153
31067
|
const result = await handleCreateVirtualFiatAccount();
|
|
@@ -31673,7 +31587,7 @@ import {
|
|
|
31673
31587
|
useQuery as useQuery18,
|
|
31674
31588
|
useQueryClient as useQueryClient5
|
|
31675
31589
|
} from "@tanstack/react-query";
|
|
31676
|
-
import * as
|
|
31590
|
+
import * as dnum6 from "dnum";
|
|
31677
31591
|
var DEFAULT_BALANCE_REFETCH_MS = 1e3;
|
|
31678
31592
|
var polymarketAccountBalanceQueryKey = (address) => ["polymarket", "accountBalanceUsd", address ?? null];
|
|
31679
31593
|
var polymarketBalanceSettleUntilQueryKey = (address) => ["polymarket", "accountBalanceSettleUntil", address];
|
|
@@ -31681,8 +31595,8 @@ var PUSD_DECIMALS = 6;
|
|
|
31681
31595
|
var SETTLEMENT_WINDOW_MS = 3e4;
|
|
31682
31596
|
function applyOptimisticTransferBalances(queryClient, transfer) {
|
|
31683
31597
|
const { fromAddress, toAddress, amountUsd } = transfer;
|
|
31684
|
-
const amount =
|
|
31685
|
-
shiftBalance(queryClient, fromAddress,
|
|
31598
|
+
const amount = dnum6.from(amountUsd, PUSD_DECIMALS);
|
|
31599
|
+
shiftBalance(queryClient, fromAddress, dnum6.multiply(amount, -1));
|
|
31686
31600
|
shiftBalance(queryClient, toAddress, amount);
|
|
31687
31601
|
}
|
|
31688
31602
|
function shiftBalance(queryClient, address, deltaUsd) {
|
|
@@ -31698,7 +31612,7 @@ function shiftBalance(queryClient, address, deltaUsd) {
|
|
|
31698
31612
|
);
|
|
31699
31613
|
queryClient.setQueryData(
|
|
31700
31614
|
balanceKey,
|
|
31701
|
-
Math.max(0,
|
|
31615
|
+
Math.max(0, dnum6.toNumber(dnum6.add(displayedUsd, deltaUsd, PUSD_DECIMALS)))
|
|
31702
31616
|
);
|
|
31703
31617
|
}
|
|
31704
31618
|
async function fetchAccountBalance(queryClient, getBalanceUsd, queryKey) {
|
|
@@ -31754,7 +31668,7 @@ function usePolymarketAccountBalances(accounts, options) {
|
|
|
31754
31668
|
}
|
|
31755
31669
|
|
|
31756
31670
|
// src/modals/PolymarketPerpsTransfer/useRecordPerpsTransfer.ts
|
|
31757
|
-
import { useCallback as
|
|
31671
|
+
import { useCallback as useCallback36 } from "react";
|
|
31758
31672
|
|
|
31759
31673
|
// src/modals/PolymarketPerpsTransfer/recordPerpsTransfer.ts
|
|
31760
31674
|
import { DirectExecutionType as DirectExecutionType4, createDirectExecution as createDirectExecution2 } from "@funkit/api-base";
|
|
@@ -31836,7 +31750,7 @@ function useRecordPerpsTransfer() {
|
|
|
31836
31750
|
const { checkoutItem } = useCheckoutContext();
|
|
31837
31751
|
const { apiKey } = useFunkitConfig();
|
|
31838
31752
|
const userInfo = useFunkitUserInfo();
|
|
31839
|
-
return
|
|
31753
|
+
return useCallback36(
|
|
31840
31754
|
async ({
|
|
31841
31755
|
direction,
|
|
31842
31756
|
sourceAddress,
|
|
@@ -32497,7 +32411,7 @@ import React182 from "react";
|
|
|
32497
32411
|
|
|
32498
32412
|
// src/modals/CheckoutModal/Brokerage/components/BrokerageSuccess.tsx
|
|
32499
32413
|
import { capitalizeFirstLetter } from "@funkit/utils";
|
|
32500
|
-
import React181, { useMemo as
|
|
32414
|
+
import React181, { useMemo as useMemo45 } from "react";
|
|
32501
32415
|
var BrokerageSuccess = ({
|
|
32502
32416
|
bottomBarId,
|
|
32503
32417
|
onClose,
|
|
@@ -32505,7 +32419,7 @@ var BrokerageSuccess = ({
|
|
|
32505
32419
|
}) => {
|
|
32506
32420
|
const { t } = useFunkitTranslation();
|
|
32507
32421
|
const { exchangeType } = useBluvo();
|
|
32508
|
-
const customTextConfigSteps =
|
|
32422
|
+
const customTextConfigSteps = useMemo45(() => {
|
|
32509
32423
|
if (exchangeType) {
|
|
32510
32424
|
return {
|
|
32511
32425
|
...getDefaultTextConfigSteps(t),
|
|
@@ -32580,7 +32494,7 @@ import { bluvoExecuteWithdrawal as bluvoExecuteWithdrawal2 } from "@funkit/api-b
|
|
|
32580
32494
|
|
|
32581
32495
|
// src/components/FunInput/FunTwoFaInput.tsx
|
|
32582
32496
|
import React183, {
|
|
32583
|
-
useCallback as
|
|
32497
|
+
useCallback as useCallback37,
|
|
32584
32498
|
useEffect as useEffect56,
|
|
32585
32499
|
useRef as useRef27,
|
|
32586
32500
|
useState as useState53
|
|
@@ -32607,12 +32521,12 @@ var FunTwoFaInput = ({
|
|
|
32607
32521
|
setFocusIndex(0);
|
|
32608
32522
|
}
|
|
32609
32523
|
}, [value]);
|
|
32610
|
-
const ensureFocus =
|
|
32524
|
+
const ensureFocus = useCallback37((nextIndex) => {
|
|
32611
32525
|
setTimeout(() => {
|
|
32612
32526
|
inputRefs.current[nextIndex]?.focus();
|
|
32613
32527
|
}, 10);
|
|
32614
32528
|
}, []);
|
|
32615
|
-
const handleBackspace =
|
|
32529
|
+
const handleBackspace = useCallback37(
|
|
32616
32530
|
(index) => {
|
|
32617
32531
|
if (index === maxInputLength - 1 && value.length === maxInputLength) {
|
|
32618
32532
|
onChange(value.slice(0, index));
|
|
@@ -32636,7 +32550,7 @@ var FunTwoFaInput = ({
|
|
|
32636
32550
|
},
|
|
32637
32551
|
[currentLength, initialInputLength, maxInputLength, onChange, value]
|
|
32638
32552
|
);
|
|
32639
|
-
const handleChange =
|
|
32553
|
+
const handleChange = useCallback37(
|
|
32640
32554
|
(changeEvent) => {
|
|
32641
32555
|
changeEvent.stopPropagation();
|
|
32642
32556
|
const nativeEvent = changeEvent.nativeEvent;
|
|
@@ -33182,7 +33096,7 @@ var TwoFactorIcon = () => /* @__PURE__ */ React184.createElement(
|
|
|
33182
33096
|
);
|
|
33183
33097
|
|
|
33184
33098
|
// src/modals/CheckoutModal/Brokerage/ConnectExchange.tsx
|
|
33185
|
-
import React188, { useCallback as
|
|
33099
|
+
import React188, { useCallback as useCallback38, useEffect as useEffect57, useState as useState55 } from "react";
|
|
33186
33100
|
import { createPortal as createPortal12 } from "react-dom";
|
|
33187
33101
|
|
|
33188
33102
|
// src/components/FunMessage/FunMessage.tsx
|
|
@@ -33318,7 +33232,7 @@ function ConnectExchange({
|
|
|
33318
33232
|
navigateToBrokerage();
|
|
33319
33233
|
}
|
|
33320
33234
|
}, [isConnected]);
|
|
33321
|
-
const onClickContinue =
|
|
33235
|
+
const onClickContinue = useCallback38(async () => {
|
|
33322
33236
|
try {
|
|
33323
33237
|
setIsLoadingBluvoModal(true);
|
|
33324
33238
|
setAuthError("");
|
|
@@ -33375,7 +33289,7 @@ function ConnectExchange({
|
|
|
33375
33289
|
}
|
|
33376
33290
|
|
|
33377
33291
|
// src/modals/CheckoutModal/Brokerage/SelectBrokerage.tsx
|
|
33378
|
-
import React191, { useCallback as
|
|
33292
|
+
import React191, { useCallback as useCallback40, useState as useState56 } from "react";
|
|
33379
33293
|
import { createPortal as createPortal13 } from "react-dom";
|
|
33380
33294
|
|
|
33381
33295
|
// src/components/FunSelectBrokerage/FunSelectBrokerage.tsx
|
|
@@ -33490,7 +33404,7 @@ function FunSelectBrokerage({
|
|
|
33490
33404
|
}
|
|
33491
33405
|
|
|
33492
33406
|
// src/hooks/track/analytics/useDepositAnalytics.ts
|
|
33493
|
-
import { useCallback as
|
|
33407
|
+
import { useCallback as useCallback39 } from "react";
|
|
33494
33408
|
function buildDepositQuoteSnapshotProperties(args, connectorId) {
|
|
33495
33409
|
return {
|
|
33496
33410
|
...resolvePaymentMethodProperties(args, connectorId),
|
|
@@ -33512,28 +33426,15 @@ function buildDepositQuoteSnapshotProperties(args, connectorId) {
|
|
|
33512
33426
|
};
|
|
33513
33427
|
}
|
|
33514
33428
|
function useDepositAnalytics() {
|
|
33515
|
-
const
|
|
33429
|
+
const logEventV2 = useTrackV2();
|
|
33516
33430
|
const { checkoutItem } = useCheckoutContext();
|
|
33517
|
-
const {
|
|
33518
|
-
const { connectorId, userInfo, walletAddress } = useGeneralWallet();
|
|
33431
|
+
const { connectorId, walletAddress } = useGeneralWallet();
|
|
33519
33432
|
const checkoutId = checkoutItem?.id;
|
|
33520
|
-
const
|
|
33521
|
-
|
|
33522
|
-
|
|
33523
|
-
connector_name: userInfo.isConnected ? userInfo.typeLabel || null : null,
|
|
33524
|
-
flow: "deposit",
|
|
33525
|
-
user_id: userInfo.isConnected ? userInfo.id : null
|
|
33526
|
-
}),
|
|
33527
|
-
[apiKey, userInfo]
|
|
33528
|
-
);
|
|
33529
|
-
const trackDepositAssetSelected = useCallback38(
|
|
33433
|
+
const config = checkoutItem?.initSettings.config;
|
|
33434
|
+
const paymentMethodInfo = checkoutItem?.selectedPaymentMethodInfo;
|
|
33435
|
+
const trackDepositAssetSelected = useCallback39(
|
|
33530
33436
|
(args) => {
|
|
33531
|
-
if (!checkoutId) {
|
|
33532
|
-
return;
|
|
33533
|
-
}
|
|
33534
33437
|
logEventV2("fc_deposit_asset_selected" /* DEPOSIT_ASSET_SELECTED */, () => ({
|
|
33535
|
-
...commonDepositProperties,
|
|
33536
|
-
checkout_id: checkoutId,
|
|
33537
33438
|
...resolvePaymentMethodProperties(args, connectorId),
|
|
33538
33439
|
source_chain: args.source.chainId,
|
|
33539
33440
|
source_asset: args.source.tokenAddress,
|
|
@@ -33545,16 +33446,11 @@ function useDepositAnalytics() {
|
|
|
33545
33446
|
is_default_token: args.isDefaultToken
|
|
33546
33447
|
}));
|
|
33547
33448
|
},
|
|
33548
|
-
[
|
|
33449
|
+
[connectorId, logEventV2]
|
|
33549
33450
|
);
|
|
33550
|
-
const trackDepositTransferInteracted =
|
|
33451
|
+
const trackDepositTransferInteracted = useCallback39(
|
|
33551
33452
|
(args) => {
|
|
33552
|
-
if (!checkoutId) {
|
|
33553
|
-
return;
|
|
33554
|
-
}
|
|
33555
33453
|
logEventV2("fc_deposit_transfer_interacted" /* DEPOSIT_TRANSFER_INTERACTED */, () => ({
|
|
33556
|
-
...commonDepositProperties,
|
|
33557
|
-
checkout_id: checkoutId,
|
|
33558
33454
|
action: args.action,
|
|
33559
33455
|
deposit_address: args.depositAddress,
|
|
33560
33456
|
est_price_impact: args.estPriceImpact,
|
|
@@ -33572,16 +33468,11 @@ function useDepositAnalytics() {
|
|
|
33572
33468
|
target_chain: args.target.chainId
|
|
33573
33469
|
}));
|
|
33574
33470
|
},
|
|
33575
|
-
[
|
|
33471
|
+
[logEventV2]
|
|
33576
33472
|
);
|
|
33577
|
-
const trackDepositAmountConfirmed =
|
|
33473
|
+
const trackDepositAmountConfirmed = useCallback39(
|
|
33578
33474
|
(args) => {
|
|
33579
|
-
if (!checkoutId) {
|
|
33580
|
-
return;
|
|
33581
|
-
}
|
|
33582
33475
|
logEventV2("fc_deposit_amount_confirmed" /* DEPOSIT_AMOUNT_CONFIRMED */, () => ({
|
|
33583
|
-
...commonDepositProperties,
|
|
33584
|
-
checkout_id: checkoutId,
|
|
33585
33476
|
...resolvePaymentMethodProperties(args, connectorId),
|
|
33586
33477
|
source_chain: args.source?.chainId ?? null,
|
|
33587
33478
|
source_asset: args.source?.tokenAddress ?? null,
|
|
@@ -33596,16 +33487,14 @@ function useDepositAnalytics() {
|
|
|
33596
33487
|
target_amount: formatAnalyticsAmount(args.targetAmount)
|
|
33597
33488
|
}));
|
|
33598
33489
|
},
|
|
33599
|
-
[
|
|
33490
|
+
[connectorId, logEventV2]
|
|
33600
33491
|
);
|
|
33601
|
-
const trackDepositMethodSelected =
|
|
33492
|
+
const trackDepositMethodSelected = useCallback39(
|
|
33602
33493
|
(args) => {
|
|
33603
|
-
|
|
33604
|
-
if (!checkoutId || !config) {
|
|
33494
|
+
if (!config) {
|
|
33605
33495
|
return;
|
|
33606
33496
|
}
|
|
33607
33497
|
logEventV2("fc_deposit_method_selected" /* DEPOSIT_METHOD_SELECTED */, () => ({
|
|
33608
|
-
...commonDepositProperties,
|
|
33609
33498
|
checkout_id: checkoutId,
|
|
33610
33499
|
payment_method: args.paymentMethod,
|
|
33611
33500
|
payment_rail: args.paymentRail || null,
|
|
@@ -33623,36 +33512,23 @@ function useDepositAnalytics() {
|
|
|
33623
33512
|
target_asset_ticker: config.targetAssetTicker || null
|
|
33624
33513
|
}));
|
|
33625
33514
|
},
|
|
33626
|
-
[
|
|
33627
|
-
checkoutId,
|
|
33628
|
-
checkoutItem,
|
|
33629
|
-
commonDepositProperties,
|
|
33630
|
-
connectorId,
|
|
33631
|
-
logEventV2
|
|
33632
|
-
]
|
|
33515
|
+
[config, connectorId, logEventV2]
|
|
33633
33516
|
);
|
|
33634
|
-
const trackDepositQuoteDisplayed =
|
|
33517
|
+
const trackDepositQuoteDisplayed = useCallback39(
|
|
33635
33518
|
(args) => {
|
|
33636
|
-
|
|
33637
|
-
|
|
33638
|
-
|
|
33639
|
-
|
|
33640
|
-
...commonDepositProperties,
|
|
33641
|
-
checkout_id: checkoutId,
|
|
33642
|
-
...buildDepositQuoteSnapshotProperties(args, connectorId)
|
|
33643
|
-
}));
|
|
33519
|
+
logEventV2(
|
|
33520
|
+
"fc_deposit_quote_displayed" /* DEPOSIT_QUOTE_DISPLAYED */,
|
|
33521
|
+
() => buildDepositQuoteSnapshotProperties(args, connectorId)
|
|
33522
|
+
);
|
|
33644
33523
|
},
|
|
33645
|
-
[
|
|
33524
|
+
[connectorId, logEventV2]
|
|
33646
33525
|
);
|
|
33647
|
-
const trackDepositMeldQuoteDisplayed =
|
|
33526
|
+
const trackDepositMeldQuoteDisplayed = useCallback39(
|
|
33648
33527
|
({ quote, numQuoteRefreshes }) => {
|
|
33649
|
-
|
|
33650
|
-
const paymentMethodInfo = checkoutItem?.selectedPaymentMethodInfo;
|
|
33651
|
-
if (!checkoutId || !config || paymentMethodInfo?.paymentMethod !== PaymentMethod.CARD) {
|
|
33528
|
+
if (!config || paymentMethodInfo?.paymentMethod !== PaymentMethod.CARD) {
|
|
33652
33529
|
return;
|
|
33653
33530
|
}
|
|
33654
33531
|
logEventV2("fc_deposit_quote_displayed" /* DEPOSIT_QUOTE_DISPLAYED */, () => ({
|
|
33655
|
-
...commonDepositProperties,
|
|
33656
33532
|
checkout_id: checkoutId,
|
|
33657
33533
|
...resolveVisibleQuoteFeeProperties(null),
|
|
33658
33534
|
...resolvePaymentMethodProperties(
|
|
@@ -33678,27 +33554,16 @@ function useDepositAnalytics() {
|
|
|
33678
33554
|
trade_type: "EXACT_IN" /* EXACT_IN */
|
|
33679
33555
|
}));
|
|
33680
33556
|
},
|
|
33681
|
-
[
|
|
33682
|
-
checkoutId,
|
|
33683
|
-
checkoutItem,
|
|
33684
|
-
commonDepositProperties,
|
|
33685
|
-
connectorId,
|
|
33686
|
-
logEventV2,
|
|
33687
|
-
walletAddress
|
|
33688
|
-
]
|
|
33557
|
+
[config, connectorId, logEventV2, paymentMethodInfo, walletAddress]
|
|
33689
33558
|
);
|
|
33690
|
-
const trackDepositQuoteConfirmed =
|
|
33559
|
+
const trackDepositQuoteConfirmed = useCallback39(
|
|
33691
33560
|
(args) => {
|
|
33692
|
-
|
|
33693
|
-
|
|
33694
|
-
|
|
33695
|
-
|
|
33696
|
-
...commonDepositProperties,
|
|
33697
|
-
checkout_id: checkoutId,
|
|
33698
|
-
...buildDepositQuoteSnapshotProperties(args, connectorId)
|
|
33699
|
-
}));
|
|
33561
|
+
logEventV2(
|
|
33562
|
+
"fc_deposit_quote_confirmed" /* DEPOSIT_QUOTE_CONFIRMED */,
|
|
33563
|
+
() => buildDepositQuoteSnapshotProperties(args, connectorId)
|
|
33564
|
+
);
|
|
33700
33565
|
},
|
|
33701
|
-
[
|
|
33566
|
+
[connectorId, logEventV2]
|
|
33702
33567
|
);
|
|
33703
33568
|
return {
|
|
33704
33569
|
trackDepositAssetSelected,
|
|
@@ -33819,7 +33684,7 @@ function SelectBrokerage({
|
|
|
33819
33684
|
const { options, isPlaceholderData } = useExchangeOptions({ iconSize });
|
|
33820
33685
|
const [selectedKey, setSelectedKey] = useState56();
|
|
33821
33686
|
const bottomSectionRef = useBottomSectionRef();
|
|
33822
|
-
const handleSelect =
|
|
33687
|
+
const handleSelect = useCallback40(
|
|
33823
33688
|
async (option) => {
|
|
33824
33689
|
if (isPlaceholderData && option.kind === "swapped" /* SWAPPED */) {
|
|
33825
33690
|
return;
|
|
@@ -33907,11 +33772,11 @@ function SelectBrokerage({
|
|
|
33907
33772
|
import React192 from "react";
|
|
33908
33773
|
|
|
33909
33774
|
// src/modals/CheckoutModal/CheckoutComplete/useLogCheckoutCompletion.ts
|
|
33910
|
-
import { useCallback as
|
|
33775
|
+
import { useCallback as useCallback41 } from "react";
|
|
33911
33776
|
function useLogCheckoutCompletion() {
|
|
33912
33777
|
const { latestQuote } = useQuoteContext();
|
|
33913
33778
|
const { checkoutItem } = useCheckoutContext();
|
|
33914
|
-
const logCheckoutCompletion =
|
|
33779
|
+
const logCheckoutCompletion = useCallback41(
|
|
33915
33780
|
(depositAddress) => {
|
|
33916
33781
|
if (depositAddress) {
|
|
33917
33782
|
logger.log("checkoutFundingCompleted", {
|
|
@@ -33972,8 +33837,8 @@ function CheckoutComplete({
|
|
|
33972
33837
|
}
|
|
33973
33838
|
|
|
33974
33839
|
// src/modals/CheckoutModal/ConfirmationStep/ConfirmationStep.tsx
|
|
33975
|
-
import * as
|
|
33976
|
-
import React206, { useEffect as useEffect62, useMemo as
|
|
33840
|
+
import * as dnum8 from "dnum";
|
|
33841
|
+
import React206, { useEffect as useEffect62, useMemo as useMemo50, useState as useState66 } from "react";
|
|
33977
33842
|
import { createPortal as createPortal15 } from "react-dom";
|
|
33978
33843
|
import { DirectExecutionType as DirectExecutionType7 } from "@funkit/api-base";
|
|
33979
33844
|
|
|
@@ -34009,7 +33874,7 @@ import {
|
|
|
34009
33874
|
} from "@funkit/utils";
|
|
34010
33875
|
import NumberFlow from "@number-flow/react";
|
|
34011
33876
|
import { motion as motion11 } from "motion/react";
|
|
34012
|
-
import React194, { useMemo as
|
|
33877
|
+
import React194, { useMemo as useMemo46 } from "react";
|
|
34013
33878
|
import { LIGHTER_CHAIN_ID } from "@funkit/chains";
|
|
34014
33879
|
|
|
34015
33880
|
// src/consts/design.ts
|
|
@@ -34074,7 +33939,7 @@ function PaymentAmountSummary({
|
|
|
34074
33939
|
const feeBreakdown = quote?.baseQuote.metadata?.feeBreakdown;
|
|
34075
33940
|
return checkoutConfig?.generateActionsParams ? feeBreakdown?.swapImpact || 0 : 0;
|
|
34076
33941
|
})();
|
|
34077
|
-
const receiveTokenUsdAmount =
|
|
33942
|
+
const receiveTokenUsdAmount = useMemo46(() => {
|
|
34078
33943
|
if (!quote) {
|
|
34079
33944
|
return void 0;
|
|
34080
33945
|
}
|
|
@@ -34412,8 +34277,8 @@ import { permitTypedData, reserve, supply } from "@aave/client/actions";
|
|
|
34412
34277
|
import { sendWith, signERC20PermitWith } from "@aave/client/viem";
|
|
34413
34278
|
import { DirectExecutionType as DirectExecutionType5, createDirectExecution as createDirectExecution3 } from "@funkit/api-base";
|
|
34414
34279
|
import { useQuery as useQuery19 } from "@tanstack/react-query";
|
|
34415
|
-
import * as
|
|
34416
|
-
import { useCallback as
|
|
34280
|
+
import * as dnum7 from "dnum";
|
|
34281
|
+
import { useCallback as useCallback42, useState as useState57 } from "react";
|
|
34417
34282
|
import { erc20Abi as erc20Abi5 } from "viem";
|
|
34418
34283
|
|
|
34419
34284
|
// src/utils/isMainnetUsdt.ts
|
|
@@ -34436,7 +34301,7 @@ var aaveClient = AaveClient.create({ environment: production });
|
|
|
34436
34301
|
// src/modals/CheckoutModal/InputAmount/useAaveNativeSupply.ts
|
|
34437
34302
|
function formatSupplyAmount(tokenAmountBaseUnit, fallbackAssetAmount) {
|
|
34438
34303
|
if (tokenAmountBaseUnit) {
|
|
34439
|
-
return
|
|
34304
|
+
return dnum7.toString(tokenAmountBaseUnit);
|
|
34440
34305
|
}
|
|
34441
34306
|
return String(fallbackAssetAmount ?? 0);
|
|
34442
34307
|
}
|
|
@@ -34722,7 +34587,7 @@ function useAaveNativeSupply() {
|
|
|
34722
34587
|
const targetChainStr = config?.targetChain;
|
|
34723
34588
|
const targetAsset = config?.targetAsset;
|
|
34724
34589
|
const market = targetChainStr ? AAVE_MARKET_ADDRESS_BY_CHAIN[targetChainStr] : void 0;
|
|
34725
|
-
const submit =
|
|
34590
|
+
const submit = useCallback42(
|
|
34726
34591
|
async (amount) => {
|
|
34727
34592
|
setError(null);
|
|
34728
34593
|
const fail = async (err) => {
|
|
@@ -34873,7 +34738,7 @@ import { DirectExecutionType as DirectExecutionType6, createDirectExecution as c
|
|
|
34873
34738
|
import {
|
|
34874
34739
|
isTokenEquivalent as isTokenEquivalent9
|
|
34875
34740
|
} from "@funkit/utils";
|
|
34876
|
-
import { useCallback as
|
|
34741
|
+
import { useCallback as useCallback43, useRef as useRef28, useState as useState58 } from "react";
|
|
34877
34742
|
import { erc20Abi as erc20Abi6 } from "viem";
|
|
34878
34743
|
function getTransferAmountBaseUnit(tokenAmountBaseUnit, fallbackAssetAmount, decimals) {
|
|
34879
34744
|
if (tokenAmountBaseUnit) {
|
|
@@ -34990,7 +34855,7 @@ function useIsNadoDirectTransferSource() {
|
|
|
34990
34855
|
const { data: wrappedTokenAddress } = useXstocksWrappedTokenAddress();
|
|
34991
34856
|
const config = checkoutItem?.initSettings.config;
|
|
34992
34857
|
const isXstockTarget = isXStockAsset(getActiveDynamicTargetAsset(config));
|
|
34993
|
-
return
|
|
34858
|
+
return useCallback43(
|
|
34994
34859
|
(source) => config != null && isNadoDirectTransferContext({
|
|
34995
34860
|
apiKey,
|
|
34996
34861
|
sourceAsset: source,
|
|
@@ -35022,7 +34887,7 @@ function useNadoDirectTransfer() {
|
|
|
35022
34887
|
chainId: sourceAsset.chainId,
|
|
35023
34888
|
address: sourceAsset.address
|
|
35024
34889
|
});
|
|
35025
|
-
const submit =
|
|
34890
|
+
const submit = useCallback43(async () => {
|
|
35026
34891
|
if (isSubmittingRef.current) {
|
|
35027
34892
|
return null;
|
|
35028
34893
|
}
|
|
@@ -35168,11 +35033,11 @@ import React201 from "react";
|
|
|
35168
35033
|
|
|
35169
35034
|
// src/components/AnimatedDollarValue/AnimatedDollarValue.tsx
|
|
35170
35035
|
import NumberFlow2 from "@number-flow/react";
|
|
35171
|
-
import React199, { forwardRef as forwardRef5, useMemo as
|
|
35036
|
+
import React199, { forwardRef as forwardRef5, useMemo as useMemo47 } from "react";
|
|
35172
35037
|
var AnimatedDollarValue = forwardRef5((props, ref) => {
|
|
35173
35038
|
const { value, dynamicMinFractionDigits, ...restProps } = props;
|
|
35174
35039
|
const minimumFractionDigits = typeof value === "number" && !Number.isInteger(value) || !dynamicMinFractionDigits ? 2 : 0;
|
|
35175
|
-
const formatOptions =
|
|
35040
|
+
const formatOptions = useMemo47(
|
|
35176
35041
|
() => ({
|
|
35177
35042
|
style: "currency",
|
|
35178
35043
|
currency: "USD",
|
|
@@ -35312,7 +35177,7 @@ function CheckoutPrimaryInfo({
|
|
|
35312
35177
|
}
|
|
35313
35178
|
|
|
35314
35179
|
// src/modals/CheckoutModal/ConfirmationStep/DisclaimerText.tsx
|
|
35315
|
-
import React202, { useMemo as
|
|
35180
|
+
import React202, { useMemo as useMemo48 } from "react";
|
|
35316
35181
|
var FunLinkButtonComponent = ({
|
|
35317
35182
|
children,
|
|
35318
35183
|
href
|
|
@@ -35358,7 +35223,7 @@ var DisclaimerText = ({
|
|
|
35358
35223
|
};
|
|
35359
35224
|
function useCardDisclaimer(checkoutItem, finalConvertedAssetName) {
|
|
35360
35225
|
const { t } = useFunkitTranslation();
|
|
35361
|
-
const cardDisclaimer =
|
|
35226
|
+
const cardDisclaimer = useMemo48(() => {
|
|
35362
35227
|
if (!checkoutItem || !finalConvertedAssetName) {
|
|
35363
35228
|
return null;
|
|
35364
35229
|
}
|
|
@@ -35427,7 +35292,10 @@ function useCheckoutConfirmation({
|
|
|
35427
35292
|
walletAddress,
|
|
35428
35293
|
customRecipient
|
|
35429
35294
|
});
|
|
35430
|
-
const isRisky = await hasRisk(apiKey, walletAddress, customRecipient
|
|
35295
|
+
const isRisky = await hasRisk(apiKey, walletAddress, customRecipient, {
|
|
35296
|
+
sourceChainId: checkoutItem.selectedSourceAssetInfo.chainId,
|
|
35297
|
+
targetChainId: checkoutItem.initSettings.config.targetChain
|
|
35298
|
+
});
|
|
35431
35299
|
const isCheckoutRisky = isRisky || isWalletBlacklisted || isCustomRecipientBlacklisted;
|
|
35432
35300
|
if (isCheckoutRisky) {
|
|
35433
35301
|
throw new Error("RISK_ERROR" /* RISK_ERROR */);
|
|
@@ -35638,7 +35506,7 @@ import React203, { useState as useState62 } from "react";
|
|
|
35638
35506
|
|
|
35639
35507
|
// src/modals/CheckoutModal/ConfirmationStep/useAccountBalanceTransfer.ts
|
|
35640
35508
|
import { USDT_ABI } from "@funkit/utils";
|
|
35641
|
-
import { useCallback as
|
|
35509
|
+
import { useCallback as useCallback44 } from "react";
|
|
35642
35510
|
import { erc20Abi as erc20Abi7 } from "viem";
|
|
35643
35511
|
function useWeb3AccountBalancePostCheckout(setPostCheckoutStepMessage) {
|
|
35644
35512
|
const { t } = useFunkitTranslation();
|
|
@@ -35648,7 +35516,7 @@ function useWeb3AccountBalancePostCheckout(setPostCheckoutStepMessage) {
|
|
|
35648
35516
|
const { sendTransactionAsync } = useSendTransaction();
|
|
35649
35517
|
const { cancelCheckout, checkoutItem } = useCheckoutContext();
|
|
35650
35518
|
const { latestQuote } = useQuoteContext();
|
|
35651
|
-
const handleWeb3AccountBalancePostCheckout =
|
|
35519
|
+
const handleWeb3AccountBalancePostCheckout = useCallback44(
|
|
35652
35520
|
async (depositAddress) => {
|
|
35653
35521
|
const WEB3_ACCOUNT_BALANCE_MESSAGE = getWeb3AccountBalanceMessage(t);
|
|
35654
35522
|
if (!latestQuote?.baseQuote.estTotalFromAmountBaseUnit) {
|
|
@@ -35756,7 +35624,7 @@ function useWeb3AccountBalancePostCheckout(setPostCheckoutStepMessage) {
|
|
|
35756
35624
|
function useAccountBalancePostCheckout(setPostCheckoutStepMessage) {
|
|
35757
35625
|
const { loginType } = useGeneralWallet();
|
|
35758
35626
|
const handleWeb3AccountBalancePostCheckout = useWeb3AccountBalancePostCheckout(setPostCheckoutStepMessage);
|
|
35759
|
-
const handleAccountBalancePostCheckout =
|
|
35627
|
+
const handleAccountBalancePostCheckout = useCallback44(
|
|
35760
35628
|
async (depositAddress) => {
|
|
35761
35629
|
if (loginType === "web3" /* Web3 */) {
|
|
35762
35630
|
await handleWeb3AccountBalancePostCheckout(depositAddress);
|
|
@@ -35906,15 +35774,15 @@ function usePostCheckout({
|
|
|
35906
35774
|
}
|
|
35907
35775
|
|
|
35908
35776
|
// src/modals/CheckoutModal/ConfirmationStep/useQuoteRefresh.ts
|
|
35909
|
-
import { useCallback as
|
|
35777
|
+
import { useCallback as useCallback47, useEffect as useEffect60, useMemo as useMemo49, useRef as useRef29, useState as useState65 } from "react";
|
|
35910
35778
|
|
|
35911
35779
|
// src/hooks/useCountdown.tsx
|
|
35912
35780
|
import React205 from "react";
|
|
35913
|
-
import { useCallback as
|
|
35781
|
+
import { useCallback as useCallback46, useState as useState64 } from "react";
|
|
35914
35782
|
|
|
35915
35783
|
// src/components/FunCountdown/FunCountdown.tsx
|
|
35916
35784
|
import { noop as noop5 } from "@funkit/utils";
|
|
35917
|
-
import React204, { useCallback as
|
|
35785
|
+
import React204, { useCallback as useCallback45, useEffect as useEffect59, useState as useState63 } from "react";
|
|
35918
35786
|
|
|
35919
35787
|
// src/components/FunCountdown/FunCountdown.css.ts
|
|
35920
35788
|
var backgroundRing = "_1t0bc111 _1rsrm2f2mm";
|
|
@@ -35950,7 +35818,7 @@ var FunCountdown = ({
|
|
|
35950
35818
|
const onCountdownEndedOnce = useEffectEvent(onCountdownEnded);
|
|
35951
35819
|
const onBeforeCountdownEndsOnce = useEffectEvent(onBeforeCountdownEnds);
|
|
35952
35820
|
const onCountdownLastSecondOnce = useEffectEvent(onCountdownLastSecond);
|
|
35953
|
-
const handleInterval =
|
|
35821
|
+
const handleInterval = useCallback45(() => {
|
|
35954
35822
|
if (isPaused) {
|
|
35955
35823
|
return;
|
|
35956
35824
|
}
|
|
@@ -36068,7 +35936,7 @@ function useCountdown({
|
|
|
36068
35936
|
}) {
|
|
36069
35937
|
const [countdownKey, setCountdownKey] = useState64(0);
|
|
36070
35938
|
const [isLastSecond, setIsLastSecond] = useState64(false);
|
|
36071
|
-
const restartCountdown =
|
|
35939
|
+
const restartCountdown = useCallback46(() => {
|
|
36072
35940
|
setIsLastSecond(false);
|
|
36073
35941
|
setCountdownKey((key) => key + 1);
|
|
36074
35942
|
}, []);
|
|
@@ -36133,7 +36001,7 @@ function useQuoteRefresh({
|
|
|
36133
36001
|
preloadedQuoteRef.current = data;
|
|
36134
36002
|
}
|
|
36135
36003
|
);
|
|
36136
|
-
const preloadQuote =
|
|
36004
|
+
const preloadQuote = useCallback47(() => {
|
|
36137
36005
|
if (!isSourceAssetConfirming) {
|
|
36138
36006
|
logger.log("quote:trigger", {
|
|
36139
36007
|
quoteReason: "refresh",
|
|
@@ -36151,7 +36019,7 @@ function useQuoteRefresh({
|
|
|
36151
36019
|
onBeforeCountdownEnds: preloadQuote,
|
|
36152
36020
|
onCountdownEnded: () => refreshQuote()
|
|
36153
36021
|
});
|
|
36154
|
-
const refreshQuote =
|
|
36022
|
+
const refreshQuote = useCallback47(
|
|
36155
36023
|
async (forceHardRefresh = false) => {
|
|
36156
36024
|
if (isOnHold) {
|
|
36157
36025
|
setIsPendingRefresh(true);
|
|
@@ -36188,7 +36056,7 @@ function useQuoteRefresh({
|
|
|
36188
36056
|
},
|
|
36189
36057
|
[isOnHold, restartCountdown, setCheckoutQuote, triggerAssetConfirm]
|
|
36190
36058
|
);
|
|
36191
|
-
const quoteError =
|
|
36059
|
+
const quoteError = useMemo49(() => {
|
|
36192
36060
|
if (quoteErrorMessage && !isQuoting) {
|
|
36193
36061
|
return {
|
|
36194
36062
|
message: quoteErrorMessage,
|
|
@@ -36215,7 +36083,7 @@ function useQuoteRefresh({
|
|
|
36215
36083
|
}
|
|
36216
36084
|
|
|
36217
36085
|
// src/modals/CheckoutModal/ConfirmationStep/useTrackDepositQuoteEvents.ts
|
|
36218
|
-
import { useCallback as
|
|
36086
|
+
import { useCallback as useCallback48, useEffect as useEffect61, useRef as useRef30 } from "react";
|
|
36219
36087
|
function buildQuoteEventArgs({
|
|
36220
36088
|
checkoutConfig,
|
|
36221
36089
|
checkoutItem,
|
|
@@ -36313,7 +36181,7 @@ function useTrackDepositQuoteEvents({
|
|
|
36313
36181
|
trackDepositQuoteDisplayed,
|
|
36314
36182
|
walletAddress
|
|
36315
36183
|
]);
|
|
36316
|
-
const trackQuoteConfirmed =
|
|
36184
|
+
const trackQuoteConfirmed = useCallback48(() => {
|
|
36317
36185
|
if (!checkoutItem?.finalDollarValue || !checkoutConfig || !latestQuote || isQuoteLoading) {
|
|
36318
36186
|
return null;
|
|
36319
36187
|
}
|
|
@@ -36456,8 +36324,8 @@ function ConfirmationStep({
|
|
|
36456
36324
|
onFailure: (error2) => {
|
|
36457
36325
|
console.error(error2);
|
|
36458
36326
|
if (error2.reason === "insufficientBalance" && error2.maxTargetAssetAmount !== void 0) {
|
|
36459
|
-
const zero =
|
|
36460
|
-
if (
|
|
36327
|
+
const zero = dnum8.from(0, error2.maxTargetAssetAmount[1]);
|
|
36328
|
+
if (dnum8.greaterThan(error2.maxTargetAssetAmount, zero) && (error2.minTargetAssetAmount === void 0 || !dnum8.lessThan(
|
|
36461
36329
|
error2.maxTargetAssetAmount,
|
|
36462
36330
|
error2.minTargetAssetAmount
|
|
36463
36331
|
))) {
|
|
@@ -36489,7 +36357,7 @@ function ConfirmationStep({
|
|
|
36489
36357
|
})
|
|
36490
36358
|
);
|
|
36491
36359
|
const error = confirmationError ?? postCheckoutError ?? quoteError ?? aaveSupply.error ?? nadoDirectTransfer.error;
|
|
36492
|
-
const stepMessage =
|
|
36360
|
+
const stepMessage = useMemo50(() => {
|
|
36493
36361
|
if (initialQuoteStep) {
|
|
36494
36362
|
return initialQuoteStep;
|
|
36495
36363
|
}
|
|
@@ -36610,7 +36478,7 @@ function ConfirmationStep({
|
|
|
36610
36478
|
};
|
|
36611
36479
|
const isStepLoading = isInitialQuoting || isContinuing || isRefreshing || aaveSupply.isPending || nadoDirectTransfer.isPending;
|
|
36612
36480
|
const customRecipient = checkoutItem?.initSettings.config.customRecipient;
|
|
36613
|
-
const displayAmounts =
|
|
36481
|
+
const displayAmounts = useMemo50(() => {
|
|
36614
36482
|
if (!latestQuote || !checkoutConfig?.targetAssetAmount) {
|
|
36615
36483
|
return null;
|
|
36616
36484
|
}
|
|
@@ -36626,7 +36494,7 @@ function ConfirmationStep({
|
|
|
36626
36494
|
quoteBuilder
|
|
36627
36495
|
]);
|
|
36628
36496
|
const supplyHumanAmount = displayAmounts?.receiveAmount ?? (checkoutConfig?.targetAssetAmount != null ? String(checkoutConfig.targetAssetAmount) : null);
|
|
36629
|
-
const resolveHealthFactor =
|
|
36497
|
+
const resolveHealthFactor = useMemo50(
|
|
36630
36498
|
() => wrapResolveHealthFactor(checkoutConfig?.resolveHealthFactor),
|
|
36631
36499
|
[checkoutConfig?.resolveHealthFactor]
|
|
36632
36500
|
);
|
|
@@ -36973,9 +36841,9 @@ import {
|
|
|
36973
36841
|
isTokenEquivalent as isTokenEquivalent11,
|
|
36974
36842
|
round as round3
|
|
36975
36843
|
} from "@funkit/utils";
|
|
36976
|
-
import * as
|
|
36844
|
+
import * as dnum10 from "dnum";
|
|
36977
36845
|
import { motion as motion13 } from "motion/react";
|
|
36978
|
-
import React219, { useEffect as useEffect65, useMemo as
|
|
36846
|
+
import React219, { useEffect as useEffect65, useMemo as useMemo54, useState as useState70 } from "react";
|
|
36979
36847
|
|
|
36980
36848
|
// src/components/AnimatedWidthWrapper/AnimatedWidthWrapper.tsx
|
|
36981
36849
|
import { motion as motion12 } from "motion/react";
|
|
@@ -37018,7 +36886,7 @@ function AnimatedWidthWrapper({ children }) {
|
|
|
37018
36886
|
}
|
|
37019
36887
|
|
|
37020
36888
|
// src/components/ApprovalMethodToggle/ApprovalMethodToggle.tsx
|
|
37021
|
-
import React208, { useCallback as
|
|
36889
|
+
import React208, { useCallback as useCallback49, useMemo as useMemo51, useRef as useRef32 } from "react";
|
|
37022
36890
|
function ApprovalMethodToggle({
|
|
37023
36891
|
value,
|
|
37024
36892
|
onChange,
|
|
@@ -37027,7 +36895,7 @@ function ApprovalMethodToggle({
|
|
|
37027
36895
|
}) {
|
|
37028
36896
|
const { t } = useFunkitTranslation();
|
|
37029
36897
|
const tooltipAnchorRef = useRef32(null);
|
|
37030
|
-
const options =
|
|
36898
|
+
const options = useMemo51(
|
|
37031
36899
|
() => [
|
|
37032
36900
|
{ label: t("approvalMethodToggle.signedMessage"), value: "sign" },
|
|
37033
36901
|
{
|
|
@@ -37037,7 +36905,7 @@ function ApprovalMethodToggle({
|
|
|
37037
36905
|
],
|
|
37038
36906
|
[t]
|
|
37039
36907
|
);
|
|
37040
|
-
const handleSelect =
|
|
36908
|
+
const handleSelect = useCallback49(
|
|
37041
36909
|
(next) => {
|
|
37042
36910
|
if (!disabled && next !== value) {
|
|
37043
36911
|
onChange(next);
|
|
@@ -38257,18 +38125,18 @@ var useCheckoutAmountLimits = ({
|
|
|
38257
38125
|
|
|
38258
38126
|
// src/modals/CheckoutModal/InputAmount/useAmountInput.ts
|
|
38259
38127
|
import {
|
|
38260
|
-
useCallback as
|
|
38261
|
-
useMemo as
|
|
38128
|
+
useCallback as useCallback51,
|
|
38129
|
+
useMemo as useMemo52,
|
|
38262
38130
|
useReducer as useReducer4,
|
|
38263
38131
|
useRef as useRef33,
|
|
38264
38132
|
useState as useState69
|
|
38265
38133
|
} from "react";
|
|
38266
38134
|
|
|
38267
38135
|
// src/hooks/useTextMeasurer.ts
|
|
38268
|
-
import { useCallback as
|
|
38136
|
+
import { useCallback as useCallback50, useState as useState68 } from "react";
|
|
38269
38137
|
function useTextMeasurer(inputRef) {
|
|
38270
38138
|
const [temp] = useState68(() => document.createElement("span"));
|
|
38271
|
-
const measureText =
|
|
38139
|
+
const measureText = useCallback50(
|
|
38272
38140
|
(text, fontSize) => {
|
|
38273
38141
|
if (!inputRef.current) {
|
|
38274
38142
|
return void 0;
|
|
@@ -38302,7 +38170,7 @@ function useTextMeasurer(inputRef) {
|
|
|
38302
38170
|
|
|
38303
38171
|
// src/modals/CheckoutModal/InputAmount/state.ts
|
|
38304
38172
|
import { isEVMAddressEquivalent as isEVMAddressEquivalent4, isTokenEquivalent as isTokenEquivalent10, round as round2 } from "@funkit/utils";
|
|
38305
|
-
import * as
|
|
38173
|
+
import * as dnum9 from "dnum";
|
|
38306
38174
|
import { mainnet as mainnet10 } from "viem/chains";
|
|
38307
38175
|
function resolveUnitPrice(isExactIn, sourceHolding, targetUnitPrice) {
|
|
38308
38176
|
if (!isExactIn) {
|
|
@@ -38387,9 +38255,9 @@ function isAmountAboveAvailable({
|
|
|
38387
38255
|
}
|
|
38388
38256
|
const limit = maxSendableAmount ?? tokenBalanceBaseUnit;
|
|
38389
38257
|
if (tokenAmountBaseUnit !== null) {
|
|
38390
|
-
return
|
|
38258
|
+
return dnum9.greaterThan(tokenAmountBaseUnit, limit);
|
|
38391
38259
|
}
|
|
38392
|
-
return
|
|
38260
|
+
return dnum9.greaterThan(toBaseUnits(assetAmount, limit[1]), limit);
|
|
38393
38261
|
}
|
|
38394
38262
|
function computeInitialTokenAmount(isExactIn, assetAmount, tokenDecimals, tokenBalanceBaseUnit, maxSendableAmount) {
|
|
38395
38263
|
if (!isExactIn || assetAmount === void 0 || tokenDecimals === null) {
|
|
@@ -38399,7 +38267,7 @@ function computeInitialTokenAmount(isExactIn, assetAmount, tokenDecimals, tokenB
|
|
|
38399
38267
|
toBaseUnits(assetAmount, tokenDecimals),
|
|
38400
38268
|
tokenBalanceBaseUnit
|
|
38401
38269
|
);
|
|
38402
|
-
if (clampedToBalance !== null && maxSendableAmount !== null &&
|
|
38270
|
+
if (clampedToBalance !== null && maxSendableAmount !== null && dnum9.greaterThan(clampedToBalance, maxSendableAmount)) {
|
|
38403
38271
|
return maxSendableAmount;
|
|
38404
38272
|
}
|
|
38405
38273
|
return clampedToBalance;
|
|
@@ -38409,7 +38277,7 @@ function parseTokenBalance(sourceHolding) {
|
|
|
38409
38277
|
if (!sourceHolding?.tokenBalanceRaw || decimals === null) {
|
|
38410
38278
|
return null;
|
|
38411
38279
|
}
|
|
38412
|
-
return
|
|
38280
|
+
return dnum9.from([BigInt(sourceHolding.tokenBalanceRaw), decimals]);
|
|
38413
38281
|
}
|
|
38414
38282
|
function tokenToFiat(tokenAmountBaseUnit, frozenUnitPrice, decimals = ASSET_DECIMALS) {
|
|
38415
38283
|
return mulByPriceRoundedDown(tokenAmountBaseUnit, frozenUnitPrice, decimals);
|
|
@@ -38418,7 +38286,7 @@ function clampToBalance(computed, tokenBalanceBaseUnit) {
|
|
|
38418
38286
|
if (computed === null || tokenBalanceBaseUnit === null) {
|
|
38419
38287
|
return computed;
|
|
38420
38288
|
}
|
|
38421
|
-
if (
|
|
38289
|
+
if (dnum9.greaterThan(computed, tokenBalanceBaseUnit) && dnum9.subtract(computed, tokenBalanceBaseUnit)[0] < 1000n) {
|
|
38422
38290
|
return tokenBalanceBaseUnit;
|
|
38423
38291
|
}
|
|
38424
38292
|
return computed;
|
|
@@ -39070,7 +38938,7 @@ function useAmountInput(options) {
|
|
|
39070
38938
|
quickOptions,
|
|
39071
38939
|
paymentMethodInfo
|
|
39072
38940
|
} = options;
|
|
39073
|
-
const derivedState =
|
|
38941
|
+
const derivedState = useMemo52(
|
|
39074
38942
|
() => getDerivedState(state, checkoutConfig.targetAssetTicker),
|
|
39075
38943
|
[state, checkoutConfig]
|
|
39076
38944
|
);
|
|
@@ -39112,7 +38980,7 @@ function useAmountInput(options) {
|
|
|
39112
38980
|
const isCardCheckout = paymentMethodInfo.paymentMethod === PaymentMethod.CARD;
|
|
39113
38981
|
const isMeldFlow = isCardCheckout && isMeldEnabled;
|
|
39114
38982
|
const unitPrice = realUnitPrice;
|
|
39115
|
-
const dispatchAndGetNewState =
|
|
38983
|
+
const dispatchAndGetNewState = useCallback51(
|
|
39116
38984
|
(action) => {
|
|
39117
38985
|
dispatch(action);
|
|
39118
38986
|
return getDerivedState(
|
|
@@ -39128,7 +38996,7 @@ function useAmountInput(options) {
|
|
|
39128
38996
|
}
|
|
39129
38997
|
return attachInputNormalization(inputRef.current, inputDecimals, locale);
|
|
39130
38998
|
}, [inputDecimals, locale, inputRef.current]);
|
|
39131
|
-
const onChange =
|
|
38999
|
+
const onChange = useCallback51(
|
|
39132
39000
|
(event) => {
|
|
39133
39001
|
dispatch({
|
|
39134
39002
|
type: "setInputValue",
|
|
@@ -39163,7 +39031,7 @@ function useAmountInput(options) {
|
|
|
39163
39031
|
});
|
|
39164
39032
|
}
|
|
39165
39033
|
}, [defaultAmount]);
|
|
39166
|
-
const setAssetAmount =
|
|
39034
|
+
const setAssetAmount = useCallback51(
|
|
39167
39035
|
(assetAmount) => {
|
|
39168
39036
|
const newState = dispatchAndGetNewState({
|
|
39169
39037
|
type: "setAssetAmount",
|
|
@@ -39175,7 +39043,7 @@ function useAmountInput(options) {
|
|
|
39175
39043
|
},
|
|
39176
39044
|
[dispatchAndGetNewState, unitPrice]
|
|
39177
39045
|
);
|
|
39178
|
-
const setFiatAmount =
|
|
39046
|
+
const setFiatAmount = useCallback51(
|
|
39179
39047
|
(fiatAmount) => {
|
|
39180
39048
|
const newState = dispatchAndGetNewState({
|
|
39181
39049
|
type: "setFiatAmount",
|
|
@@ -39187,7 +39055,7 @@ function useAmountInput(options) {
|
|
|
39187
39055
|
},
|
|
39188
39056
|
[dispatchAndGetNewState, unitPrice]
|
|
39189
39057
|
);
|
|
39190
|
-
const setTokenAmount =
|
|
39058
|
+
const setTokenAmount = useCallback51(
|
|
39191
39059
|
(tokenAmountBaseUnit, frozenUnitPrice) => {
|
|
39192
39060
|
const newState = dispatchAndGetNewState({
|
|
39193
39061
|
type: "setTokenAmount",
|
|
@@ -39199,7 +39067,7 @@ function useAmountInput(options) {
|
|
|
39199
39067
|
},
|
|
39200
39068
|
[dispatchAndGetNewState]
|
|
39201
39069
|
);
|
|
39202
|
-
const toggleInputInFiat =
|
|
39070
|
+
const toggleInputInFiat = useCallback51(() => {
|
|
39203
39071
|
dispatch({ type: "toggleInputInFiat" });
|
|
39204
39072
|
inputRef.current?.focus();
|
|
39205
39073
|
}, []);
|
|
@@ -39222,7 +39090,7 @@ function useAmountInput(options) {
|
|
|
39222
39090
|
}
|
|
39223
39091
|
|
|
39224
39092
|
// src/modals/CheckoutModal/InputAmount/useMeld.tsx
|
|
39225
|
-
import React218, { useCallback as
|
|
39093
|
+
import React218, { useCallback as useCallback52 } from "react";
|
|
39226
39094
|
|
|
39227
39095
|
// src/components/SourceMeldQuoteItem/SourceMeldQuoteItem.tsx
|
|
39228
39096
|
import React217 from "react";
|
|
@@ -39496,7 +39364,7 @@ import {
|
|
|
39496
39364
|
useQuery as useQuery23,
|
|
39497
39365
|
useQueryClient as useQueryClient7
|
|
39498
39366
|
} from "@tanstack/react-query";
|
|
39499
|
-
import { useEffect as useEffect64, useMemo as
|
|
39367
|
+
import { useEffect as useEffect64, useMemo as useMemo53 } from "react";
|
|
39500
39368
|
import { useDebounce as useDebounce2 } from "use-debounce";
|
|
39501
39369
|
var DEBOUNCE_DELAY = 500;
|
|
39502
39370
|
var COUNTDOWN_INTERVAL_SEC = 60;
|
|
@@ -39512,7 +39380,7 @@ var useMeldQuotes = (sourceAmount, fiatCurrency, meldEnabled = true) => {
|
|
|
39512
39380
|
const checkoutId = checkoutItem?.id ?? null;
|
|
39513
39381
|
const destinationCurrencyCode = useMeldCryptoCurrencyCode();
|
|
39514
39382
|
const sourceCurrencyCode = fiatCurrency || "USD";
|
|
39515
|
-
const queryKey =
|
|
39383
|
+
const queryKey = useMemo53(
|
|
39516
39384
|
() => [
|
|
39517
39385
|
"meld",
|
|
39518
39386
|
"quotes",
|
|
@@ -39685,7 +39553,7 @@ function useMeld(meldEnabled, manuallySelectedQuote, usdAmount, fiatCurrency) {
|
|
|
39685
39553
|
(quote) => quote.serviceProvider === selectedQuote?.serviceProvider
|
|
39686
39554
|
);
|
|
39687
39555
|
const isMeldContinueDisabled = meldEnabled && (!!meldLimitError || isMeldLinkPending || !!meldQuotesQuery.error || meldQuotesQuery.isFetching || isSelectedQuoteUnavailable);
|
|
39688
|
-
const getMeldError =
|
|
39556
|
+
const getMeldError = useCallback52(
|
|
39689
39557
|
function getMeldError2() {
|
|
39690
39558
|
if (isSelectedQuoteUnavailable) {
|
|
39691
39559
|
return {
|
|
@@ -39841,7 +39709,7 @@ function InputAmountLoaded({
|
|
|
39841
39709
|
const { tokenBalanceBaseUnit, frozenUnitPrice } = amountInputResult;
|
|
39842
39710
|
if (isExactIn && !isFixedFiatQuickOptions && tokenBalanceBaseUnit != null && frozenUnitPrice != null) {
|
|
39843
39711
|
const base6 = amountInputResult.maxSendableAmount ?? tokenBalanceBaseUnit;
|
|
39844
|
-
const amount = option === 100 ? base6 :
|
|
39712
|
+
const amount = option === 100 ? base6 : dnum10.multiply(base6, option / 100);
|
|
39845
39713
|
amountInputResult.setTokenAmount(amount, frozenUnitPrice);
|
|
39846
39714
|
return null;
|
|
39847
39715
|
}
|
|
@@ -39886,7 +39754,7 @@ function InputAmountLoaded({
|
|
|
39886
39754
|
fiatCurrency,
|
|
39887
39755
|
onNext
|
|
39888
39756
|
});
|
|
39889
|
-
const error =
|
|
39757
|
+
const error = useMemo54(() => {
|
|
39890
39758
|
if (isCardCheckout) {
|
|
39891
39759
|
const meldError = getMeldError();
|
|
39892
39760
|
if (meldError) {
|
|
@@ -40381,7 +40249,7 @@ function YouPayYouReceiveWrapper({
|
|
|
40381
40249
|
|
|
40382
40250
|
// src/modals/CheckoutModal/InputAmount/InputAmountLoading.tsx
|
|
40383
40251
|
import { formatCryptoAndStringify as formatCryptoAndStringify7 } from "@funkit/utils";
|
|
40384
|
-
import React220, { useMemo as
|
|
40252
|
+
import React220, { useMemo as useMemo55 } from "react";
|
|
40385
40253
|
function InputAmountLoading({
|
|
40386
40254
|
modalState,
|
|
40387
40255
|
sourceHoldingError,
|
|
@@ -40404,7 +40272,7 @@ function InputAmountLoading({
|
|
|
40404
40272
|
isExactIn,
|
|
40405
40273
|
sourceTokenSymbol: sourceAsset?.symbol
|
|
40406
40274
|
});
|
|
40407
|
-
const error =
|
|
40275
|
+
const error = useMemo55(() => {
|
|
40408
40276
|
if (sourceHoldingError) {
|
|
40409
40277
|
return {
|
|
40410
40278
|
message: /* @__PURE__ */ React220.createElement("div", null, t("inputAmount.unableToRetrieveBalance"), " "),
|
|
@@ -40512,7 +40380,7 @@ function getLoadingAmountOptions(paymentMethod) {
|
|
|
40512
40380
|
}
|
|
40513
40381
|
|
|
40514
40382
|
// src/modals/CheckoutModal/InputAmount/useAvailableBalanceForCheckout.ts
|
|
40515
|
-
import { useMemo as
|
|
40383
|
+
import { useMemo as useMemo56 } from "react";
|
|
40516
40384
|
function useAvailableBalanceForCheckout(paymentMethodInfo, targetChainId, assetChainId, assetSymbol) {
|
|
40517
40385
|
const paymentMethod = paymentMethodInfo.paymentMethod;
|
|
40518
40386
|
const isBrokerage = paymentMethod === PaymentMethod.BROKERAGE;
|
|
@@ -40529,7 +40397,7 @@ function useAvailableBalanceForCheckout(paymentMethodInfo, targetChainId, assetC
|
|
|
40529
40397
|
[PaymentMethod.VIRTUAL_BANK]: null
|
|
40530
40398
|
}[paymentMethod];
|
|
40531
40399
|
const isLoading = isBrokerage ? isLoadingBrokerageBalance : isLoadingWalletAssetHoldings;
|
|
40532
|
-
const holdingItem =
|
|
40400
|
+
const holdingItem = useMemo56(() => {
|
|
40533
40401
|
if (!assetSymbol || !holdings) {
|
|
40534
40402
|
return;
|
|
40535
40403
|
}
|
|
@@ -40713,13 +40581,13 @@ import { createPortal as createPortal17 } from "react-dom";
|
|
|
40713
40581
|
|
|
40714
40582
|
// src/components/CopyAddress/CopyInputDisplayedAddress.tsx
|
|
40715
40583
|
import { truncateMiddleOfAddress } from "@funkit/utils";
|
|
40716
|
-
import React222, { useCallback as
|
|
40584
|
+
import React222, { useCallback as useCallback54, useState as useState72 } from "react";
|
|
40717
40585
|
|
|
40718
40586
|
// src/hooks/useCopyToClipboard.ts
|
|
40719
|
-
import { useCallback as
|
|
40587
|
+
import { useCallback as useCallback53, useEffect as useEffect67, useState as useState71 } from "react";
|
|
40720
40588
|
var useCopyToClipboard = (text, delay = 1500) => {
|
|
40721
40589
|
const [isCopied, setCopied] = useState71(false);
|
|
40722
|
-
const handleCopy =
|
|
40590
|
+
const handleCopy = useCallback53(() => {
|
|
40723
40591
|
if (!text) {
|
|
40724
40592
|
return;
|
|
40725
40593
|
}
|
|
@@ -40762,7 +40630,7 @@ function CopyInputDisplayedAddressEN({
|
|
|
40762
40630
|
const { handleCopy } = useCopyToClipboard(address);
|
|
40763
40631
|
const [isActive, setIsActive] = useState72(null);
|
|
40764
40632
|
const displayAddress = truncateAddress ? truncateMiddleOfAddress(address, 40, 24, 8) : address;
|
|
40765
|
-
const handleClick =
|
|
40633
|
+
const handleClick = useCallback54(() => {
|
|
40766
40634
|
if (isActive) {
|
|
40767
40635
|
return;
|
|
40768
40636
|
}
|
|
@@ -40819,7 +40687,7 @@ function CopyInputDisplayedAddressI18n({
|
|
|
40819
40687
|
const copyLabel = label === "invoice" ? t("common.copyInvoice") : t("common.copyAddress");
|
|
40820
40688
|
const buttonText = isActive ? t("common.copied") : copyLabel;
|
|
40821
40689
|
const displayAddress = truncateAddress ? truncateMiddleOfAddress(address, 40, 24, 8) : address;
|
|
40822
|
-
const handleClick =
|
|
40690
|
+
const handleClick = useCallback54(() => {
|
|
40823
40691
|
if (isActive) {
|
|
40824
40692
|
return;
|
|
40825
40693
|
}
|
|
@@ -40851,6 +40719,7 @@ import {
|
|
|
40851
40719
|
getLightningQuote
|
|
40852
40720
|
} from "@funkit/api-base";
|
|
40853
40721
|
import { LIGHTNING_MAINNET_CHAIN_ID, bitcoinChain as bitcoinChain4 } from "@funkit/chains";
|
|
40722
|
+
import { getAssetPriceInfoWithFallback as getAssetPriceInfoWithFallback2 } from "@funkit/connect-core";
|
|
40854
40723
|
import { keepPreviousData as keepPreviousData3, useQuery as useQuery24 } from "@tanstack/react-query";
|
|
40855
40724
|
import { useEffect as useEffect68, useRef as useRef34, useState as useState73 } from "react";
|
|
40856
40725
|
import { parseUnits as parseUnits5 } from "viem";
|
|
@@ -40908,10 +40777,11 @@ var useLightningQuote = ({
|
|
|
40908
40777
|
if (!depositAddr || !walletAddress || !targetChain || !targetAsset || !fiatAmount) {
|
|
40909
40778
|
throw new Error("useLightningQuote: missing required params");
|
|
40910
40779
|
}
|
|
40911
|
-
const btcPrice = await
|
|
40780
|
+
const btcPrice = await getAssetPriceInfoWithFallback2({
|
|
40912
40781
|
apiKey,
|
|
40913
40782
|
chainId: bitcoinChain4.id.toString(),
|
|
40914
|
-
assetTokenAddress: NATIVE_TOKEN
|
|
40783
|
+
assetTokenAddress: NATIVE_TOKEN,
|
|
40784
|
+
logger
|
|
40915
40785
|
});
|
|
40916
40786
|
const fromAmountSats = usdToSats(fiatAmount, btcPrice.unitPrice);
|
|
40917
40787
|
if (fromAmountSats === void 0) {
|
|
@@ -40969,7 +40839,7 @@ import React225 from "react";
|
|
|
40969
40839
|
|
|
40970
40840
|
// src/components/QRCode/QRCode.tsx
|
|
40971
40841
|
import QRCodeUtil from "qrcode";
|
|
40972
|
-
import React223, { useMemo as
|
|
40842
|
+
import React223, { useMemo as useMemo57 } from "react";
|
|
40973
40843
|
var generateMatrix = (value, errorCorrectionLevel) => {
|
|
40974
40844
|
const { data } = QRCodeUtil.create(value, { errorCorrectionLevel }).modules;
|
|
40975
40845
|
const sqrt = Math.sqrt(data.length);
|
|
@@ -40997,7 +40867,7 @@ function QRCode({
|
|
|
40997
40867
|
}) {
|
|
40998
40868
|
const { activeTheme } = useActiveTheme();
|
|
40999
40869
|
const size = sizeProp - Number.parseInt(outsidePadding, 10) * 2;
|
|
41000
|
-
const dots =
|
|
40870
|
+
const dots = useMemo57(() => {
|
|
41001
40871
|
const dots2 = [];
|
|
41002
40872
|
const matrix = generateMatrix(uri, ecl);
|
|
41003
40873
|
const cellSize = size / matrix.length;
|
|
@@ -41555,7 +41425,7 @@ var CheckoutTopAnnouncementBanner = () => {
|
|
|
41555
41425
|
};
|
|
41556
41426
|
|
|
41557
41427
|
// src/hooks/usePaymentMethodTabs.ts
|
|
41558
|
-
import { useMemo as
|
|
41428
|
+
import { useMemo as useMemo58 } from "react";
|
|
41559
41429
|
function usePaymentMethodTabs({
|
|
41560
41430
|
isCashier
|
|
41561
41431
|
}) {
|
|
@@ -41565,7 +41435,7 @@ function usePaymentMethodTabs({
|
|
|
41565
41435
|
);
|
|
41566
41436
|
const isWithdrawalTabEnabled = useDynamicConfig("enablecashierformfactor") && isCashier;
|
|
41567
41437
|
const defaultTab = isSavedCardDefaultsToFiatTabEnabled && hasSavedFops ? "fiat" : "crypto";
|
|
41568
|
-
const tabOrder =
|
|
41438
|
+
const tabOrder = useMemo58(() => {
|
|
41569
41439
|
const tabs2 = [];
|
|
41570
41440
|
if (defaultTab === "fiat") {
|
|
41571
41441
|
tabs2.push("fiat", "crypto");
|
|
@@ -42134,7 +42004,7 @@ function LoadingAccount({
|
|
|
42134
42004
|
|
|
42135
42005
|
// src/modals/CheckoutModal/MeldCurrencySelect/MeldCurrencySelect.tsx
|
|
42136
42006
|
import clsx21 from "clsx";
|
|
42137
|
-
import React236, { useMemo as
|
|
42007
|
+
import React236, { useMemo as useMemo59, useState as useState74 } from "react";
|
|
42138
42008
|
|
|
42139
42009
|
// src/modals/CheckoutModal/MeldCurrencySelect/currenciesWithMultipleCountries.ts
|
|
42140
42010
|
var currenciesWithMultipleCountries = {
|
|
@@ -42195,7 +42065,7 @@ function MeldCurrencySelect({
|
|
|
42195
42065
|
const [selectedCurrency, setSelectedCurrency] = useState74(
|
|
42196
42066
|
defaultCurrency
|
|
42197
42067
|
);
|
|
42198
|
-
const filteredOptions =
|
|
42068
|
+
const filteredOptions = useMemo59(() => {
|
|
42199
42069
|
const newOptions = data?.filter(
|
|
42200
42070
|
({ name, currencyCode }) => currencyCode.toLowerCase().includes(query.toLowerCase()) || name.toLowerCase().includes(query.toLowerCase())
|
|
42201
42071
|
) ?? [];
|
|
@@ -42400,14 +42270,14 @@ import { isTokenEquivalent as isTokenEquivalent12 } from "@funkit/utils";
|
|
|
42400
42270
|
import React242, {
|
|
42401
42271
|
useEffect as useEffect71,
|
|
42402
42272
|
useLayoutEffect as useLayoutEffect2,
|
|
42403
|
-
useMemo as
|
|
42273
|
+
useMemo as useMemo61,
|
|
42404
42274
|
useState as useState75
|
|
42405
42275
|
} from "react";
|
|
42406
42276
|
import { createPortal as createPortal20 } from "react-dom";
|
|
42407
42277
|
import { mainnet as mainnet11 } from "viem/chains";
|
|
42408
42278
|
|
|
42409
42279
|
// src/hooks/useDynamicRoutes.ts
|
|
42410
|
-
import { useMemo as
|
|
42280
|
+
import { useMemo as useMemo60 } from "react";
|
|
42411
42281
|
import { DYNAMIC_ROUTES, initDynamicRouting } from "@funkit/fun-relay";
|
|
42412
42282
|
var toMutable = (obj) => {
|
|
42413
42283
|
return obj;
|
|
@@ -42417,7 +42287,7 @@ var useDynamicRoutes = (_dynamicRoutingId) => {
|
|
|
42417
42287
|
const { checkoutItem } = useCheckoutContext();
|
|
42418
42288
|
const config = checkoutItem?.initSettings.config;
|
|
42419
42289
|
const dynamicRoutingId = _dynamicRoutingId || config?.dynamicRoutingId;
|
|
42420
|
-
const findPath =
|
|
42290
|
+
const findPath = useMemo60(() => {
|
|
42421
42291
|
if (!dynamicRoutingId) {
|
|
42422
42292
|
return () => null;
|
|
42423
42293
|
}
|
|
@@ -42663,7 +42533,7 @@ function useEnrichedAccountHoldings({
|
|
|
42663
42533
|
const minTransferLimits = useDynamicConfig("mintokentransfervalue");
|
|
42664
42534
|
const isDynamicRoutingEnabled = useIsDynamicRoutingEnabled();
|
|
42665
42535
|
const isNadoDirectTransferSource = useIsNadoDirectTransferSource();
|
|
42666
|
-
const enrichedAccountHoldings =
|
|
42536
|
+
const enrichedAccountHoldings = useMemo61(() => {
|
|
42667
42537
|
if (!checkoutConfig) {
|
|
42668
42538
|
return [];
|
|
42669
42539
|
}
|
|
@@ -42725,7 +42595,7 @@ function useAssetOptions({
|
|
|
42725
42595
|
const { t } = useFunkitTranslation();
|
|
42726
42596
|
const { findPath } = useDynamicRoutes();
|
|
42727
42597
|
const isNadoDirectTransferSource = useIsNadoDirectTransferSource();
|
|
42728
|
-
const assetOptions =
|
|
42598
|
+
const assetOptions = useMemo61(() => {
|
|
42729
42599
|
return enrichedAccountHoldings.map(({ asset, usableForCheckout }) => {
|
|
42730
42600
|
const { isUsable, reason } = usableForCheckout;
|
|
42731
42601
|
const isKnown = isKnownAsset(asset);
|
|
@@ -42833,7 +42703,7 @@ function AccountSelectAsset({
|
|
|
42833
42703
|
const { setSelectedBrokerageAsset } = useFunkitBrokerageContext();
|
|
42834
42704
|
const [explicitlySelectedChainTokenSymbol, setSelectedChainTokenSymbol] = useState75("");
|
|
42835
42705
|
const checkoutConfig = checkoutItem?.initSettings.config;
|
|
42836
|
-
const defaultTargetAsset =
|
|
42706
|
+
const defaultTargetAsset = useMemo61(
|
|
42837
42707
|
() => getDefaultDynamicTargetAsset(checkoutConfig),
|
|
42838
42708
|
[checkoutConfig]
|
|
42839
42709
|
);
|
|
@@ -42938,7 +42808,7 @@ function AccountSelectAsset({
|
|
|
42938
42808
|
});
|
|
42939
42809
|
onFinish();
|
|
42940
42810
|
});
|
|
42941
|
-
const defaultSelectedChainTokenSymbol =
|
|
42811
|
+
const defaultSelectedChainTokenSymbol = useMemo61(() => {
|
|
42942
42812
|
if (checkoutItem?.selectedSourceAssetInfo.symbol) {
|
|
42943
42813
|
const key = combineChainSymbolOrAddress({
|
|
42944
42814
|
chainId: checkoutItem.selectedSourceAssetInfo.chainId,
|
|
@@ -42954,7 +42824,7 @@ function AccountSelectAsset({
|
|
|
42954
42824
|
const usableOptions = assetOptions.filter((option) => !option.isDisabled);
|
|
42955
42825
|
return usableOptions[0]?.asset.chainSymbolKey;
|
|
42956
42826
|
}, [assetOptions, checkoutItem?.selectedSourceAssetInfo]);
|
|
42957
|
-
const selectedChainTokenSymbol =
|
|
42827
|
+
const selectedChainTokenSymbol = useMemo61(() => {
|
|
42958
42828
|
if (explicitlySelectedChainTokenSymbol) {
|
|
42959
42829
|
const assetExists = assetOptions.some(
|
|
42960
42830
|
({ asset }) => asset.chainSymbolKey === explicitlySelectedChainTokenSymbol
|
|
@@ -43149,10 +43019,11 @@ import { LIGHTER_CHAIN_ID as LIGHTER_CHAIN_ID3, lightningChain as lightningChain
|
|
|
43149
43019
|
import {
|
|
43150
43020
|
createSyntheticFop,
|
|
43151
43021
|
isSavedFormOfPaymentType as isSavedFormOfPaymentType2,
|
|
43152
|
-
isSyntheticFop as isSyntheticFop3
|
|
43022
|
+
isSyntheticFop as isSyntheticFop3,
|
|
43023
|
+
resolveWithdrawalSourceTokenBalance as resolveWithdrawalSourceTokenBalance4
|
|
43153
43024
|
} from "@funkit/connect-core";
|
|
43154
43025
|
import { isTokenEquivalent as isTokenEquivalent13, noop as noop6 } from "@funkit/utils";
|
|
43155
|
-
import React251, { useEffect as useEffect74, useMemo as
|
|
43026
|
+
import React251, { useEffect as useEffect74, useMemo as useMemo62, useRef as useRef36, useState as useState76 } from "react";
|
|
43156
43027
|
import { createPortal as createPortal21 } from "react-dom";
|
|
43157
43028
|
|
|
43158
43029
|
// src/components/Dropdown/ReceiveTokenDropdown.tsx
|
|
@@ -43429,7 +43300,7 @@ function GroupedList({
|
|
|
43429
43300
|
|
|
43430
43301
|
// src/modals/CheckoutModal/SourceChange/PayPal.tsx
|
|
43431
43302
|
import { MeldServiceProvider as MeldServiceProvider2 } from "@funkit/api-base";
|
|
43432
|
-
import React248, { useCallback as
|
|
43303
|
+
import React248, { useCallback as useCallback55 } from "react";
|
|
43433
43304
|
function PayPal() {
|
|
43434
43305
|
const { apiKey } = useFunkitConfig();
|
|
43435
43306
|
const { data: defaultCurrency } = useMeldDefaultCurrency(PaymentMethod.CARD);
|
|
@@ -43441,7 +43312,7 @@ function PayPal() {
|
|
|
43441
43312
|
const isMeldEnabled = useIsMeldEnabled();
|
|
43442
43313
|
const { checkoutItem } = useCheckoutContext();
|
|
43443
43314
|
const isPaypalReady = false;
|
|
43444
|
-
const onClick =
|
|
43315
|
+
const onClick = useCallback55(() => {
|
|
43445
43316
|
if (isMeldEnabled && isPaypalReady) {
|
|
43446
43317
|
openMeldPopup(() => mutateAsync(MeldServiceProvider2.PAYPAL));
|
|
43447
43318
|
} else {
|
|
@@ -43585,10 +43456,10 @@ function SourceList({
|
|
|
43585
43456
|
|
|
43586
43457
|
// src/hooks/useStartBitcoinLightning.ts
|
|
43587
43458
|
import { lightningChain as lightningChain3 } from "@funkit/chains";
|
|
43588
|
-
import { useCallback as
|
|
43459
|
+
import { useCallback as useCallback56 } from "react";
|
|
43589
43460
|
function useStartBitcoinLightning() {
|
|
43590
43461
|
const { updateSelectedPaymentMethodInfo, updateSourceAsset } = useCheckoutContext();
|
|
43591
|
-
return
|
|
43462
|
+
return useCallback56(() => {
|
|
43592
43463
|
const paymentMethodInfo = createPaymentMethodInfo({
|
|
43593
43464
|
paymentMethod: PaymentMethod.BITCOIN_LIGHTNING
|
|
43594
43465
|
});
|
|
@@ -43608,11 +43479,10 @@ import { useEffect as useEffect73, useRef as useRef35 } from "react";
|
|
|
43608
43479
|
function useTrackSourceChangeEvents({
|
|
43609
43480
|
tab
|
|
43610
43481
|
}) {
|
|
43611
|
-
const
|
|
43482
|
+
const logEventV2 = useTrackV2();
|
|
43612
43483
|
const { checkoutItem } = useCheckoutContext();
|
|
43613
|
-
const { apiKey } = useFunkitConfig();
|
|
43614
43484
|
const { authorizedConnections } = useFunkitBrokerageContext();
|
|
43615
|
-
const { connectorId,
|
|
43485
|
+
const { connectorId, walletAddress } = useGeneralWallet();
|
|
43616
43486
|
const tabSwitchCountRef = useRef35(0);
|
|
43617
43487
|
const trackModalOpened = useEffectEvent(() => {
|
|
43618
43488
|
if (!checkoutItem) {
|
|
@@ -43620,22 +43490,17 @@ function useTrackSourceChangeEvents({
|
|
|
43620
43490
|
}
|
|
43621
43491
|
const config = checkoutItem.initSettings.config;
|
|
43622
43492
|
const exchanges = Object.keys(authorizedConnections);
|
|
43623
|
-
const userId = userInfo.id && userInfo.id !== "0x" ? userInfo.id : null;
|
|
43624
43493
|
logEventV2("fc_modal_opened" /* MODAL_OPENED */, () => ({
|
|
43625
|
-
api_key: apiKey,
|
|
43626
|
-
checkout_id: checkoutItem.id,
|
|
43627
|
-
connector_name: connectorId ? userInfo.typeLabel || null : null,
|
|
43628
|
-
flow: tab === "withdraw" ? "withdraw" : "deposit",
|
|
43629
|
-
tab,
|
|
43630
|
-
user_id: userId,
|
|
43631
43494
|
custom_recipient: config.customRecipient ?? null,
|
|
43632
43495
|
dynamic_routing_id: config.dynamicRoutingId ?? null,
|
|
43633
43496
|
exchange_count: exchanges.length,
|
|
43497
|
+
flow: tab === "withdraw" ? "withdraw" : "deposit",
|
|
43634
43498
|
primary_exchange: exchanges[0] ?? null,
|
|
43635
43499
|
primary_wallet: walletAddress ? connectorId ?? null : null,
|
|
43636
43500
|
source_asset: checkoutItem.selectedSourceAssetInfo.address,
|
|
43637
43501
|
source_asset_ticker: checkoutItem.selectedSourceAssetInfo.symbol || null,
|
|
43638
43502
|
source_chain: checkoutItem.selectedSourceAssetInfo.chainId,
|
|
43503
|
+
tab,
|
|
43639
43504
|
target_asset: config.targetAsset,
|
|
43640
43505
|
target_asset_ticker: config.targetAssetTicker || null,
|
|
43641
43506
|
target_chain: config.targetChain,
|
|
@@ -43653,21 +43518,16 @@ function useTrackSourceChangeEvents({
|
|
|
43653
43518
|
fromTab,
|
|
43654
43519
|
tab: nextTab
|
|
43655
43520
|
}) => {
|
|
43656
|
-
if (
|
|
43521
|
+
if (fromTab === nextTab) {
|
|
43657
43522
|
return;
|
|
43658
43523
|
}
|
|
43659
43524
|
const switchCount = tabSwitchCountRef.current + 1;
|
|
43660
43525
|
tabSwitchCountRef.current = switchCount;
|
|
43661
|
-
const userId = userInfo.id && userInfo.id !== "0x" ? userInfo.id : null;
|
|
43662
43526
|
logEventV2("fc_tab_switched" /* TAB_SWITCHED */, () => ({
|
|
43663
|
-
api_key: apiKey,
|
|
43664
|
-
checkout_id: checkoutItem.id,
|
|
43665
|
-
connector_name: connectorId ? userInfo.typeLabel || null : null,
|
|
43666
43527
|
flow: nextTab === "withdraw" ? "withdraw" : "deposit",
|
|
43667
43528
|
from_tab: fromTab,
|
|
43668
43529
|
switch_count: switchCount,
|
|
43669
|
-
tab: nextTab
|
|
43670
|
-
user_id: userId
|
|
43530
|
+
tab: nextTab
|
|
43671
43531
|
}));
|
|
43672
43532
|
}
|
|
43673
43533
|
);
|
|
@@ -43843,7 +43703,7 @@ function SourceChange({
|
|
|
43843
43703
|
const { isUnifiedTradingMode: isLighterUnifiedAccount } = useLighterAccounts({
|
|
43844
43704
|
address: walletAddress
|
|
43845
43705
|
});
|
|
43846
|
-
const dynamicTargetAssets =
|
|
43706
|
+
const dynamicTargetAssets = useMemo62(() => {
|
|
43847
43707
|
const candidates = checkoutConfig?.dynamicTargetAssetCandidates;
|
|
43848
43708
|
if (!candidates || !isLighterUnifiedAccount) {
|
|
43849
43709
|
return candidates;
|
|
@@ -43891,7 +43751,7 @@ function SourceChange({
|
|
|
43891
43751
|
});
|
|
43892
43752
|
}
|
|
43893
43753
|
const [connectedSource, setConnectedSource] = useState76(paymentMethodInfo);
|
|
43894
|
-
const syntheticFops =
|
|
43754
|
+
const syntheticFops = useMemo62(
|
|
43895
43755
|
() => isCashAppLightningEnabled ? [createSyntheticFop(PaymentMethod.CASH_APP_LIGHTNING)] : [],
|
|
43896
43756
|
[isCashAppLightningEnabled]
|
|
43897
43757
|
);
|
|
@@ -43916,7 +43776,7 @@ function SourceChange({
|
|
|
43916
43776
|
const { trackTabSwitched } = useTrackSourceChangeEvents({
|
|
43917
43777
|
tab: paymentMethodTab
|
|
43918
43778
|
});
|
|
43919
|
-
const nativeHolding =
|
|
43779
|
+
const nativeHolding = useMemo62(() => {
|
|
43920
43780
|
if (!checkoutConfig || !walletHoldings || !isCustomerNativeFastPathEnabled(apiKey)) {
|
|
43921
43781
|
return void 0;
|
|
43922
43782
|
}
|
|
@@ -43930,7 +43790,7 @@ function SourceChange({
|
|
|
43930
43790
|
);
|
|
43931
43791
|
return holding && holding.usdAmount != null && holding.usdAmount > 0 ? holding : void 0;
|
|
43932
43792
|
}, [apiKey, walletHoldings, checkoutConfig]);
|
|
43933
|
-
const connectedWallet =
|
|
43793
|
+
const connectedWallet = useMemo62(
|
|
43934
43794
|
() => preferred.find(
|
|
43935
43795
|
(s) => isConnectablePaymentMethodInfo(s) && s.paymentMethod === PaymentMethod.ACCOUNT_BALANCE
|
|
43936
43796
|
),
|
|
@@ -44330,14 +44190,15 @@ function SourceChange({
|
|
|
44330
44190
|
onCryptoSelect: handleWithdrawCryptoSelect,
|
|
44331
44191
|
onCashFopSelect: handleFiatItemSelect,
|
|
44332
44192
|
usdBalance: Number(
|
|
44333
|
-
|
|
44193
|
+
resolveWithdrawalSourceTokenBalance4(
|
|
44334
44194
|
resolvedWithdrawalConfig?.withdrawalSourceTokenBalance ?? checkoutConfig?.withdrawalSourceTokenBalance,
|
|
44335
44195
|
{
|
|
44336
44196
|
sourceAsset: {
|
|
44337
44197
|
tokenAddress: resolvedWithdrawalConfig.sourceTokenAddress,
|
|
44338
44198
|
tokenChainId: resolvedWithdrawalConfig.sourceChainId
|
|
44339
44199
|
}
|
|
44340
|
-
}
|
|
44200
|
+
},
|
|
44201
|
+
logger
|
|
44341
44202
|
) ?? "0"
|
|
44342
44203
|
),
|
|
44343
44204
|
hideSectionLabels: true
|
|
@@ -45269,7 +45130,7 @@ var TransferTokenDetails = ({
|
|
|
45269
45130
|
};
|
|
45270
45131
|
|
|
45271
45132
|
// src/modals/CheckoutModal/TransferToken/useTransferTokenTracking.ts
|
|
45272
|
-
import { useCallback as
|
|
45133
|
+
import { useCallback as useCallback57, useEffect as useEffect76, useRef as useRef38, useState as useState78 } from "react";
|
|
45273
45134
|
|
|
45274
45135
|
// src/modals/CheckoutModal/TransferToken/CheckoutNotifications.track.ts
|
|
45275
45136
|
function getNotificationId(item) {
|
|
@@ -45377,7 +45238,7 @@ function useTransferTokenTracking({
|
|
|
45377
45238
|
const nextInteractionIdRef = useRef38(0);
|
|
45378
45239
|
const lastEmittedInteractionIdRef = useRef38(0);
|
|
45379
45240
|
const interactionCountRef = useRef38(0);
|
|
45380
|
-
const queueTransferInteraction =
|
|
45241
|
+
const queueTransferInteraction = useCallback57(
|
|
45381
45242
|
(interaction) => {
|
|
45382
45243
|
const id = nextInteractionIdRef.current + 1;
|
|
45383
45244
|
nextInteractionIdRef.current = id;
|
|
@@ -45433,7 +45294,7 @@ function useTransferTokenTracking({
|
|
|
45433
45294
|
});
|
|
45434
45295
|
}
|
|
45435
45296
|
}, [depositAddress, fromChainId, toChainId, toTokenAddress]);
|
|
45436
|
-
const trackAddressCopied =
|
|
45297
|
+
const trackAddressCopied = useCallback57(() => {
|
|
45437
45298
|
logEvent({
|
|
45438
45299
|
eventName: "fc::deposit::transfer::address::copied" /* DEPOSIT_TRANSFER_ADDRESS_COPIED */,
|
|
45439
45300
|
metadata: {
|
|
@@ -45450,7 +45311,7 @@ function useTransferTokenTracking({
|
|
|
45450
45311
|
});
|
|
45451
45312
|
}
|
|
45452
45313
|
}, [fromChainId, fromTokenSymbol, logEvent, queueTransferInteraction]);
|
|
45453
|
-
const trackImpactExpanded =
|
|
45314
|
+
const trackImpactExpanded = useCallback57(
|
|
45454
45315
|
(estPriceImpactPct) => {
|
|
45455
45316
|
logEvent({
|
|
45456
45317
|
eventName: "fc::deposit::transfer::impact::viewed" /* DEPOSIT_TRANSFER_IMPACT_VIEWED */,
|
|
@@ -45463,7 +45324,7 @@ function useTransferTokenTracking({
|
|
|
45463
45324
|
},
|
|
45464
45325
|
[fromChainId, fromTokenSymbol, logEvent]
|
|
45465
45326
|
);
|
|
45466
|
-
const trackSourceChainChange =
|
|
45327
|
+
const trackSourceChainChange = useCallback57(
|
|
45467
45328
|
(newChainId, newTokenSymbol, shouldQueueInteraction = true) => {
|
|
45468
45329
|
if (newChainId === fromChainId) {
|
|
45469
45330
|
return;
|
|
@@ -45497,7 +45358,7 @@ function useTransferTokenTracking({
|
|
|
45497
45358
|
queueTransferInteraction
|
|
45498
45359
|
]
|
|
45499
45360
|
);
|
|
45500
|
-
const trackSourceTokenChange =
|
|
45361
|
+
const trackSourceTokenChange = useCallback57(
|
|
45501
45362
|
(newTokenSymbol, newChainId, shouldQueueInteraction = true) => {
|
|
45502
45363
|
const isSameResolvedSource = newChainId !== void 0 && newTokenSymbol === fromTokenSymbol && String(newChainId) === fromChainId;
|
|
45503
45364
|
if (newTokenSymbol !== fromTokenSymbol) {
|
|
@@ -45543,56 +45404,35 @@ function useNotificationTracking({
|
|
|
45543
45404
|
item,
|
|
45544
45405
|
status
|
|
45545
45406
|
}) {
|
|
45546
|
-
const
|
|
45547
|
-
const {
|
|
45548
|
-
const { connectorId
|
|
45407
|
+
const logEventV2 = useTrackV2();
|
|
45408
|
+
const { logEvent } = useTrack();
|
|
45409
|
+
const { connectorId } = useGeneralWallet();
|
|
45549
45410
|
const depositNotificationDisplayRef = useRef38(null);
|
|
45550
|
-
const buildNotificationProperties = (item2, notificationStatus) => {
|
|
45551
|
-
const context = resolveExecutionProgressContext(item2, "deposit");
|
|
45552
|
-
if (!context) {
|
|
45553
|
-
return null;
|
|
45554
|
-
}
|
|
45555
|
-
const userId = userInfo.isConnected && userInfo.id !== "0x" ? userInfo.id || null : null;
|
|
45556
|
-
return {
|
|
45557
|
-
api_key: apiKey,
|
|
45558
|
-
connector_name: userInfo.isConnected ? userInfo.typeLabel || null : null,
|
|
45559
|
-
flow: "deposit",
|
|
45560
|
-
...buildExecutionTransactionSnapshotProperties(
|
|
45561
|
-
context,
|
|
45562
|
-
userId,
|
|
45563
|
-
connectorId
|
|
45564
|
-
),
|
|
45565
|
-
status: notificationStatus
|
|
45566
|
-
};
|
|
45567
|
-
};
|
|
45568
45411
|
const trackDepositNotificationDisplayed = useEffectEvent(
|
|
45569
45412
|
(notification, notificationStatus) => {
|
|
45570
|
-
const
|
|
45571
|
-
|
|
45572
|
-
|
|
45573
|
-
);
|
|
45574
|
-
if (!properties) {
|
|
45575
|
-
return;
|
|
45413
|
+
const context = resolveExecutionProgressContext(notification, "deposit");
|
|
45414
|
+
if (!context) {
|
|
45415
|
+
return null;
|
|
45576
45416
|
}
|
|
45577
|
-
logEventV2(
|
|
45578
|
-
"
|
|
45579
|
-
()
|
|
45580
|
-
|
|
45417
|
+
logEventV2("fc_deposit_notification_displayed" /* DEPOSIT_NOTIFICATION_DISPLAYED */, () => ({
|
|
45418
|
+
flow: "deposit",
|
|
45419
|
+
...buildExecutionTransactionSnapshotProperties(context, connectorId),
|
|
45420
|
+
status: notificationStatus
|
|
45421
|
+
}));
|
|
45581
45422
|
}
|
|
45582
45423
|
);
|
|
45583
45424
|
const trackDepositNotificationInteracted = useEffectEvent(
|
|
45584
45425
|
(notification, interaction) => {
|
|
45585
|
-
const
|
|
45586
|
-
|
|
45587
|
-
|
|
45588
|
-
);
|
|
45589
|
-
if (!properties) {
|
|
45590
|
-
return;
|
|
45426
|
+
const context = resolveExecutionProgressContext(notification, "deposit");
|
|
45427
|
+
if (!context) {
|
|
45428
|
+
return null;
|
|
45591
45429
|
}
|
|
45592
45430
|
logEventV2("fc_deposit_notification_interacted" /* DEPOSIT_NOTIFICATION_INTERACTED */, () => ({
|
|
45593
|
-
|
|
45431
|
+
flow: "deposit",
|
|
45432
|
+
...buildExecutionTransactionSnapshotProperties(context, connectorId),
|
|
45594
45433
|
action: interaction.action,
|
|
45595
|
-
ms_since_displayed: interaction.msSinceDisplayed
|
|
45434
|
+
ms_since_displayed: interaction.msSinceDisplayed,
|
|
45435
|
+
status: interaction.status
|
|
45596
45436
|
}));
|
|
45597
45437
|
}
|
|
45598
45438
|
);
|
|
@@ -45668,7 +45508,7 @@ function useNotificationTracking({
|
|
|
45668
45508
|
}
|
|
45669
45509
|
}
|
|
45670
45510
|
}, [logEvent, status]);
|
|
45671
|
-
const trackDismissal =
|
|
45511
|
+
const trackDismissal = useCallback57(() => {
|
|
45672
45512
|
if (!itemRef.current || !notificationDisplayedAtRef.current) {
|
|
45673
45513
|
return;
|
|
45674
45514
|
}
|
|
@@ -45689,7 +45529,7 @@ function useNotificationTracking({
|
|
|
45689
45529
|
}
|
|
45690
45530
|
reasonRef.current = "dismissed";
|
|
45691
45531
|
}, [logEvent, trackDepositNotificationInteracted]);
|
|
45692
|
-
const trackShowMore =
|
|
45532
|
+
const trackShowMore = useCallback57(() => {
|
|
45693
45533
|
if (!itemRef.current || !notificationDisplayedAtRef.current) {
|
|
45694
45534
|
return;
|
|
45695
45535
|
}
|
|
@@ -46577,9 +46417,9 @@ var FiatAccountDetail = {
|
|
|
46577
46417
|
|
|
46578
46418
|
// src/modals/CheckoutModal/VirtualFiatAccount/KycIframe.tsx
|
|
46579
46419
|
import { BridgeCustomerStatus as BridgeCustomerStatus7 } from "@funkit/api-base";
|
|
46580
|
-
import React267, { useCallback as
|
|
46420
|
+
import React267, { useCallback as useCallback58, useEffect as useEffect77, useMemo as useMemo63, useState as useState81 } from "react";
|
|
46581
46421
|
function useIframeListener(listeners, expectedOrigin) {
|
|
46582
|
-
const handleMessage =
|
|
46422
|
+
const handleMessage = useCallback58(
|
|
46583
46423
|
(event) => {
|
|
46584
46424
|
if (!expectedOrigin || event.origin !== expectedOrigin) {
|
|
46585
46425
|
return;
|
|
@@ -46634,14 +46474,14 @@ function KycIframe({
|
|
|
46634
46474
|
const { clearVirtualFiatAccounts } = useClearFrogAccountsCache();
|
|
46635
46475
|
const { data: kycLink, isLoading: isLinkLoading } = useLoadKycLink(modalState);
|
|
46636
46476
|
const [iframeLoading, setIframeLoading] = useState81(true);
|
|
46637
|
-
const kycOrigin =
|
|
46477
|
+
const kycOrigin = useMemo63(() => {
|
|
46638
46478
|
try {
|
|
46639
46479
|
return kycLink ? new URL(kycLink).origin : null;
|
|
46640
46480
|
} catch {
|
|
46641
46481
|
return null;
|
|
46642
46482
|
}
|
|
46643
46483
|
}, [kycLink]);
|
|
46644
|
-
const listeners =
|
|
46484
|
+
const listeners = useMemo63(
|
|
46645
46485
|
() => ({
|
|
46646
46486
|
load: () => {
|
|
46647
46487
|
logger.info("KYC iframe loaded");
|
|
@@ -46908,7 +46748,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
46908
46748
|
useEffect78(() => {
|
|
46909
46749
|
ensureLoadingAccountScreen();
|
|
46910
46750
|
}, [ensureLoadingAccountScreen]);
|
|
46911
|
-
const trackNextState =
|
|
46751
|
+
const trackNextState = useCallback59(
|
|
46912
46752
|
(nextState) => {
|
|
46913
46753
|
const trackEvent = trackEventFromNextState(nextState);
|
|
46914
46754
|
if (trackEvent) {
|
|
@@ -46924,7 +46764,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
46924
46764
|
const { clearCheckoutQuoteMessages } = useCheckoutQuoteNotification();
|
|
46925
46765
|
const { getCheckoutProgress } = useCheckoutContext();
|
|
46926
46766
|
const { softHide } = useSoftHiddenCheckout();
|
|
46927
|
-
const onCloseWrapper =
|
|
46767
|
+
const onCloseWrapper = useCallback59(
|
|
46928
46768
|
(options) => {
|
|
46929
46769
|
const normalizedIsNewDeposit = !!options?.isNewDeposit;
|
|
46930
46770
|
const metadata = {
|
|
@@ -46968,7 +46808,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
46968
46808
|
const [stateHistory, setHistory] = useState82([]);
|
|
46969
46809
|
const prevStep = useRef40(null);
|
|
46970
46810
|
const hasHistoryEntry = stateHistory.length > 1;
|
|
46971
|
-
const onNext =
|
|
46811
|
+
const onNext = useCallback59(
|
|
46972
46812
|
(payload) => {
|
|
46973
46813
|
if (prevStep.current === modalState.step) {
|
|
46974
46814
|
return;
|
|
@@ -47012,7 +46852,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
47012
46852
|
ensureStepQueries
|
|
47013
46853
|
]
|
|
47014
46854
|
);
|
|
47015
|
-
const onStepChange =
|
|
46855
|
+
const onStepChange = useCallback59(
|
|
47016
46856
|
(nextState) => {
|
|
47017
46857
|
if (prevStep.current === modalState.step) {
|
|
47018
46858
|
return;
|
|
@@ -47027,7 +46867,7 @@ function useCheckoutModalTransition(checkoutItem, onClose) {
|
|
|
47027
46867
|
},
|
|
47028
46868
|
[modalState, animate, trackNextState, ensureStepQueries]
|
|
47029
46869
|
);
|
|
47030
|
-
const onBack =
|
|
46870
|
+
const onBack = useCallback59(() => {
|
|
47031
46871
|
clearCheckoutQuoteMessages();
|
|
47032
46872
|
const backStepOverride = checkoutBackMap[modalState.step];
|
|
47033
46873
|
const prevState = [...stateHistory].reverse().find((s) => s.step === backStepOverride) ?? stateHistory[stateHistory.length - 1];
|
|
@@ -47142,7 +46982,7 @@ function useCheckoutModalTitle(depositAddress, defaultTitle) {
|
|
|
47142
46982
|
import { IN_PROGRESS_CHECKOUT_STATES as IN_PROGRESS_CHECKOUT_STATES2 } from "@funkit/api-base";
|
|
47143
46983
|
import { formatTimestampToDate, fullMonthNames } from "@funkit/utils";
|
|
47144
46984
|
import clsx23 from "clsx";
|
|
47145
|
-
import React279, { useEffect as useEffect80, useMemo as
|
|
46985
|
+
import React279, { useEffect as useEffect80, useMemo as useMemo64, useRef as useRef42, useState as useState84 } from "react";
|
|
47146
46986
|
import { Virtuoso } from "react-virtuoso";
|
|
47147
46987
|
|
|
47148
46988
|
// src/consts/layout.ts
|
|
@@ -47501,7 +47341,7 @@ var HomeTokenBalanceDisplayRowSkeleton = () => {
|
|
|
47501
47341
|
|
|
47502
47342
|
// src/modals/ProfileDetails/FunProfileViews/Home/ProfileTitleSection.tsx
|
|
47503
47343
|
import React278 from "react";
|
|
47504
|
-
import { useCallback as
|
|
47344
|
+
import { useCallback as useCallback60, useState as useState83 } from "react";
|
|
47505
47345
|
|
|
47506
47346
|
// src/components/FunSelect/FunClickOutside.tsx
|
|
47507
47347
|
import React275 from "react";
|
|
@@ -47594,7 +47434,7 @@ var ProfileTitleSection = ({
|
|
|
47594
47434
|
}) => {
|
|
47595
47435
|
const { t } = useFunkitTranslation();
|
|
47596
47436
|
const [isDisconnectExpanded, setIsDisconnectExpanded] = useState83(false);
|
|
47597
|
-
const collapseDisconnect =
|
|
47437
|
+
const collapseDisconnect = useCallback60(
|
|
47598
47438
|
() => setIsDisconnectExpanded(false),
|
|
47599
47439
|
[]
|
|
47600
47440
|
);
|
|
@@ -47698,7 +47538,7 @@ function Home({
|
|
|
47698
47538
|
const virtuosoDiv = virtuosoParentRef.current?.firstChild;
|
|
47699
47539
|
virtuosoDiv?.classList.add(animateVirtuosoInClass);
|
|
47700
47540
|
}, []);
|
|
47701
|
-
const AssetsList =
|
|
47541
|
+
const AssetsList = useMemo64(() => {
|
|
47702
47542
|
if (walletAssets && !Object.keys(walletAssets).length) {
|
|
47703
47543
|
return /* @__PURE__ */ React279.createElement(EmptyTabAlert, null);
|
|
47704
47544
|
}
|
|
@@ -47725,7 +47565,7 @@ function Home({
|
|
|
47725
47565
|
}
|
|
47726
47566
|
));
|
|
47727
47567
|
}, [walletAssets]);
|
|
47728
|
-
const CheckoutsList =
|
|
47568
|
+
const CheckoutsList = useMemo64(() => {
|
|
47729
47569
|
if (checkoutHistoryList.length === 0 && isCheckoutHistoryInited) {
|
|
47730
47570
|
return /* @__PURE__ */ React279.createElement(EmptyTabAlert, null);
|
|
47731
47571
|
}
|
|
@@ -47988,13 +47828,13 @@ function ProfileDetails({ onClose, defaultTab }) {
|
|
|
47988
47828
|
DEFAULT_CHECKOUT_HISTORY_DETAIL_TITLE
|
|
47989
47829
|
);
|
|
47990
47830
|
const singleActivityPage = "detail" /* DETAIL */;
|
|
47991
|
-
const resetView =
|
|
47831
|
+
const resetView = useCallback61(() => {
|
|
47992
47832
|
setView(returnView ?? 0 /* HOME */);
|
|
47993
47833
|
setSelectedHomeTab("checkouts" /* CHECKOUTS */);
|
|
47994
47834
|
resetActivityTraversal();
|
|
47995
47835
|
}, [resetActivityTraversal, returnView]);
|
|
47996
47836
|
const { animation, animate } = useAnimatedNavigation(void 0);
|
|
47997
|
-
const onSelectActivityWrapper =
|
|
47837
|
+
const onSelectActivityWrapper = useCallback61(
|
|
47998
47838
|
(activity) => {
|
|
47999
47839
|
onSelectActivity({
|
|
48000
47840
|
...activity,
|
|
@@ -48024,7 +47864,7 @@ function ProfileDetails({ onClose, defaultTab }) {
|
|
|
48024
47864
|
const isSingleActivityView = view === 3 /* SINGLE_ACTIVITY */;
|
|
48025
47865
|
const isCheckoutDetailView = isSingleActivityView && singleActivityPage === "detail" /* DETAIL */;
|
|
48026
47866
|
const withDivider = isSingleActivityView ? "always" : void 0;
|
|
48027
|
-
const handleHelp =
|
|
47867
|
+
const handleHelp = useCallback61(() => {
|
|
48028
47868
|
window.open(CONTACT_US_LINK, "_blank", "noopener");
|
|
48029
47869
|
}, []);
|
|
48030
47870
|
const { onScroll, topbar, withTopDivider } = useCustomStatusAnimationAboveTopbar({
|
|
@@ -48427,7 +48267,7 @@ function ChainModal({ onClose, open }) {
|
|
|
48427
48267
|
import React303, { useEffect as useEffect89, useLayoutEffect as useLayoutEffect3, useRef as useRef45 } from "react";
|
|
48428
48268
|
|
|
48429
48269
|
// src/components/FunConnectOptions/FunConnectOptions.tsx
|
|
48430
|
-
import React295, { useCallback as
|
|
48270
|
+
import React295, { useCallback as useCallback62, useMemo as useMemo65, useState as useState88 } from "react";
|
|
48431
48271
|
|
|
48432
48272
|
// src/components/FunConnectOptions/FunConnectResultStep.tsx
|
|
48433
48273
|
import React290, { useEffect as useEffect81 } from "react";
|
|
@@ -48795,7 +48635,7 @@ function FunConnectOptions({
|
|
|
48795
48635
|
const [step, setStep] = useState88(INITIAL_STEP);
|
|
48796
48636
|
const [selectedWallet, setSelectedWallet] = useState88();
|
|
48797
48637
|
const [qrCodeUri, setQrCodeUri] = useState88("");
|
|
48798
|
-
const changeStep =
|
|
48638
|
+
const changeStep = useCallback62((newStep) => {
|
|
48799
48639
|
setStep(newStep);
|
|
48800
48640
|
if (isSignIn(newStep)) {
|
|
48801
48641
|
setSelectedWallet(void 0);
|
|
@@ -48806,7 +48646,7 @@ function FunConnectOptions({
|
|
|
48806
48646
|
navigateTo(0 /* SIGNIN_PRIMARY */, { reverse: true });
|
|
48807
48647
|
};
|
|
48808
48648
|
const walletConnectors = usePreparedWalletConnectors();
|
|
48809
|
-
const onRegenerateQrCode =
|
|
48649
|
+
const onRegenerateQrCode = useCallback62(
|
|
48810
48650
|
async (wallet) => {
|
|
48811
48651
|
const sWallet = walletConnectors.find((w) => wallet.id === w.id);
|
|
48812
48652
|
const uri = await sWallet?.getQrCodeUri?.();
|
|
@@ -48814,7 +48654,7 @@ function FunConnectOptions({
|
|
|
48814
48654
|
},
|
|
48815
48655
|
[walletConnectors]
|
|
48816
48656
|
);
|
|
48817
|
-
const connectToWallet =
|
|
48657
|
+
const connectToWallet = useCallback62(
|
|
48818
48658
|
async (wallet) => {
|
|
48819
48659
|
if (!wallet.ready) {
|
|
48820
48660
|
return;
|
|
@@ -48833,7 +48673,7 @@ function FunConnectOptions({
|
|
|
48833
48673
|
},
|
|
48834
48674
|
[changeStep, onRegenerateQrCode]
|
|
48835
48675
|
);
|
|
48836
|
-
const handleRetry =
|
|
48676
|
+
const handleRetry = useCallback62(() => {
|
|
48837
48677
|
if (selectedWallet) {
|
|
48838
48678
|
changeStep(1 /* PENDING_WALLET */);
|
|
48839
48679
|
connectToWallet(selectedWallet);
|
|
@@ -48869,7 +48709,7 @@ function FunConnectOptions({
|
|
|
48869
48709
|
}
|
|
48870
48710
|
}
|
|
48871
48711
|
};
|
|
48872
|
-
const stepComponent =
|
|
48712
|
+
const stepComponent = useMemo65(() => {
|
|
48873
48713
|
switch (step) {
|
|
48874
48714
|
case 0 /* SIGNIN_PRIMARY */:
|
|
48875
48715
|
return /* @__PURE__ */ React295.createElement(
|
|
@@ -49005,7 +48845,7 @@ function CheckoutModalPrefetchedHooks() {
|
|
|
49005
48845
|
|
|
49006
48846
|
// src/modals/CheckoutModal/TransferToken/CheckoutNotifications.tsx
|
|
49007
48847
|
import clsx26 from "clsx";
|
|
49008
|
-
import React302, { useCallback as
|
|
48848
|
+
import React302, { useCallback as useCallback64, useEffect as useEffect87, useMemo as useMemo66, useState as useState90 } from "react";
|
|
49009
48849
|
|
|
49010
48850
|
// src/components/FunNotificationBanner/FunNotificationShowMoreButton.tsx
|
|
49011
48851
|
import React297 from "react";
|
|
@@ -49133,7 +48973,7 @@ var showMoreButtonStyle = "_4yitd93 _1rsrm2f1r4 _1rsrm2f1i _1rsrm2f1f _1rsrm2f11
|
|
|
49133
48973
|
// src/components/FunNotificationBanner/FunNotificationBannerIcon.tsx
|
|
49134
48974
|
import clsx24 from "clsx";
|
|
49135
48975
|
import { motion as motion18, useAnimate as useAnimate3 } from "motion/react";
|
|
49136
|
-
import React298, { useCallback as
|
|
48976
|
+
import React298, { useCallback as useCallback63, useEffect as useEffect84, useRef as useRef43 } from "react";
|
|
49137
48977
|
|
|
49138
48978
|
// src/components/FunNotificationBanner/FunNotificationBannerIcon.css.ts
|
|
49139
48979
|
var STATUS_SPINNER_BOTTOM_POSITION = -5;
|
|
@@ -49382,7 +49222,7 @@ var FunNotificationBannerIcon = ({
|
|
|
49382
49222
|
fallbackIconUrl = FALLBACK_ASSET
|
|
49383
49223
|
}) => {
|
|
49384
49224
|
const [animationScope, animate] = useAnimate3();
|
|
49385
|
-
const triggerAnimationProcessingToCompleted =
|
|
49225
|
+
const triggerAnimationProcessingToCompleted = useCallback63(async () => {
|
|
49386
49226
|
const completedIconPath = document.querySelector(
|
|
49387
49227
|
`.${generateAnimationPrefixClassName("icon-wrapper-completed")} path`
|
|
49388
49228
|
);
|
|
@@ -49489,7 +49329,7 @@ var FunNotificationBannerIcon = ({
|
|
|
49489
49329
|
)
|
|
49490
49330
|
]);
|
|
49491
49331
|
}, [animate]);
|
|
49492
|
-
const triggerAnimationDelayedToFailed =
|
|
49332
|
+
const triggerAnimationDelayedToFailed = useCallback63(async () => {
|
|
49493
49333
|
await Promise.all([
|
|
49494
49334
|
animate(
|
|
49495
49335
|
`.${generateAnimationPrefixClassName("icon-wrapper")}`,
|
|
@@ -50235,7 +50075,7 @@ var CheckoutNotifications = ({
|
|
|
50235
50075
|
const [closedNotifications, setClosedNotifications] = useState90([]);
|
|
50236
50076
|
const { data: checkouts } = useRecentCheckouts({ isVisible });
|
|
50237
50077
|
const { data: directExecutions } = useRecentDeposits({ isVisible });
|
|
50238
|
-
const mergedDirectExecutions =
|
|
50078
|
+
const mergedDirectExecutions = useMemo66(
|
|
50239
50079
|
() => processRecentDepositsForNotifications2(directExecutions, {
|
|
50240
50080
|
variant
|
|
50241
50081
|
}),
|
|
@@ -50253,7 +50093,7 @@ var CheckoutNotifications = ({
|
|
|
50253
50093
|
}
|
|
50254
50094
|
setInitialDirectExecutions(directExecutions);
|
|
50255
50095
|
}, [initialDirectExecutions, directExecutions]);
|
|
50256
|
-
const displayedDirectExecutions =
|
|
50096
|
+
const displayedDirectExecutions = useMemo66(() => {
|
|
50257
50097
|
if (!mergedDirectExecutions || !initialDirectExecutions) {
|
|
50258
50098
|
return [];
|
|
50259
50099
|
}
|
|
@@ -50265,13 +50105,13 @@ var CheckoutNotifications = ({
|
|
|
50265
50105
|
return !closedNotifications.includes(notificationKey);
|
|
50266
50106
|
}).slice(0, MAX_COUNT);
|
|
50267
50107
|
}, [initialDirectExecutions, mergedDirectExecutions, closedNotifications]);
|
|
50268
|
-
const displayedCheckouts =
|
|
50108
|
+
const displayedCheckouts = useMemo66(() => {
|
|
50269
50109
|
if (!checkouts || !initialCheckouts) {
|
|
50270
50110
|
return [];
|
|
50271
50111
|
}
|
|
50272
50112
|
return getUpdatedCheckouts(checkouts, initialCheckouts).filter(({ depositAddr }) => !closedNotifications.includes(depositAddr)).slice(0, MAX_COUNT);
|
|
50273
50113
|
}, [initialCheckouts, checkouts, closedNotifications]);
|
|
50274
|
-
const combinedNotifications =
|
|
50114
|
+
const combinedNotifications = useMemo66(() => {
|
|
50275
50115
|
return [
|
|
50276
50116
|
...displayedDirectExecutions.map(
|
|
50277
50117
|
(item) => ({ ...item, isDirectExecution: true })
|
|
@@ -50282,12 +50122,12 @@ var CheckoutNotifications = ({
|
|
|
50282
50122
|
].sort((a, b) => b.createdTimeMs - a.createdTimeMs);
|
|
50283
50123
|
}, [displayedDirectExecutions, displayedCheckouts]);
|
|
50284
50124
|
useTrackDepositNotificationEvents(combinedNotifications);
|
|
50285
|
-
const displayedNotifications =
|
|
50125
|
+
const displayedNotifications = useMemo66(() => {
|
|
50286
50126
|
return isExpanded ? combinedNotifications : combinedNotifications.slice(0, COLLAPSED_COUNT);
|
|
50287
50127
|
}, [isExpanded, combinedNotifications]);
|
|
50288
50128
|
const handleNotificationClose = (id) => setClosedNotifications((prev) => [...prev, id]);
|
|
50289
50129
|
const { logEvent } = useTrack();
|
|
50290
|
-
const handleNewNotification =
|
|
50130
|
+
const handleNewNotification = useCallback64(
|
|
50291
50131
|
(item) => {
|
|
50292
50132
|
const trackEvent = trackEventFromNotification(item);
|
|
50293
50133
|
logEvent(trackEvent);
|
|
@@ -50697,16 +50537,16 @@ function ConnectModal({ onClose, open }) {
|
|
|
50697
50537
|
function useModalStateValue() {
|
|
50698
50538
|
const [isModalOpen, setModalOpen] = useState91(false);
|
|
50699
50539
|
return {
|
|
50700
|
-
closeModal:
|
|
50540
|
+
closeModal: useCallback65(() => setModalOpen(false), []),
|
|
50701
50541
|
isModalOpen,
|
|
50702
|
-
openModal:
|
|
50542
|
+
openModal: useCallback65(() => setModalOpen(true), [])
|
|
50703
50543
|
};
|
|
50704
50544
|
}
|
|
50705
50545
|
function useModalStateValueWithProp() {
|
|
50706
50546
|
const [isModalOpen, setModalOpen] = useState91(false);
|
|
50707
50547
|
const [prop, setProp] = useState91(null);
|
|
50708
50548
|
return {
|
|
50709
|
-
closeModal:
|
|
50549
|
+
closeModal: useCallback65(() => {
|
|
50710
50550
|
setTimeout(
|
|
50711
50551
|
() => {
|
|
50712
50552
|
setProp(null);
|
|
@@ -50717,7 +50557,7 @@ function useModalStateValueWithProp() {
|
|
|
50717
50557
|
}, []),
|
|
50718
50558
|
isModalOpen,
|
|
50719
50559
|
prop,
|
|
50720
|
-
openModal:
|
|
50560
|
+
openModal: useCallback65((prop2) => {
|
|
50721
50561
|
if (prop2 != null) {
|
|
50722
50562
|
setProp(prop2);
|
|
50723
50563
|
}
|
|
@@ -50762,19 +50602,19 @@ function ModalProvider({ children }) {
|
|
|
50762
50602
|
prop: funCheckoutModalId
|
|
50763
50603
|
} = useModalStateValueWithProp();
|
|
50764
50604
|
const [softHiddenCheckoutId, setSoftHiddenCheckoutId] = useState91(null);
|
|
50765
|
-
const softHideFunCheckoutModal =
|
|
50605
|
+
const softHideFunCheckoutModal = useCallback65(() => {
|
|
50766
50606
|
if (funCheckoutModalId) {
|
|
50767
50607
|
setSoftHiddenCheckoutId(funCheckoutModalId);
|
|
50768
50608
|
}
|
|
50769
50609
|
closeFunCheckoutModal();
|
|
50770
50610
|
}, [funCheckoutModalId, closeFunCheckoutModal]);
|
|
50771
|
-
const resumeSoftHiddenCheckout =
|
|
50611
|
+
const resumeSoftHiddenCheckout = useCallback65(() => {
|
|
50772
50612
|
if (softHiddenCheckoutId) {
|
|
50773
50613
|
openFunCheckoutModal(softHiddenCheckoutId);
|
|
50774
50614
|
setSoftHiddenCheckoutId(null);
|
|
50775
50615
|
}
|
|
50776
50616
|
}, [softHiddenCheckoutId, openFunCheckoutModal]);
|
|
50777
|
-
const discardSoftHiddenCheckout =
|
|
50617
|
+
const discardSoftHiddenCheckout = useCallback65(() => {
|
|
50778
50618
|
setSoftHiddenCheckoutId(null);
|
|
50779
50619
|
}, []);
|
|
50780
50620
|
const {
|
|
@@ -50807,7 +50647,7 @@ function ModalProvider({ children }) {
|
|
|
50807
50647
|
return /* @__PURE__ */ React305.createElement(
|
|
50808
50648
|
ModalContext.Provider,
|
|
50809
50649
|
{
|
|
50810
|
-
value:
|
|
50650
|
+
value: useMemo67(
|
|
50811
50651
|
() => ({
|
|
50812
50652
|
accountModalOpen,
|
|
50813
50653
|
accountModalTab,
|
|
@@ -51044,13 +50884,13 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
51044
50884
|
activeCheckout?.initSettings.config?.dynamicRoutingId
|
|
51045
50885
|
);
|
|
51046
50886
|
const [checkoutsProgress, setCheckoutsProgress] = useState92({});
|
|
51047
|
-
const getCheckoutProgress =
|
|
50887
|
+
const getCheckoutProgress = useCallback66(
|
|
51048
50888
|
(checkoutId) => {
|
|
51049
50889
|
return checkoutsProgress[checkoutId];
|
|
51050
50890
|
},
|
|
51051
50891
|
[checkoutsProgress]
|
|
51052
50892
|
);
|
|
51053
|
-
const setCheckoutProgress =
|
|
50893
|
+
const setCheckoutProgress = useCallback66(
|
|
51054
50894
|
(checkoutId, progress) => {
|
|
51055
50895
|
setCheckoutsProgress((data) => ({ ...data, [checkoutId]: progress }));
|
|
51056
50896
|
},
|
|
@@ -51072,7 +50912,7 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
51072
50912
|
});
|
|
51073
50913
|
}
|
|
51074
50914
|
);
|
|
51075
|
-
const initNewWithdrawal =
|
|
50915
|
+
const initNewWithdrawal = useCallback66(
|
|
51076
50916
|
(props, checkoutConfig) => {
|
|
51077
50917
|
const { onWithdrawalConfirmation, onWithdrawalError, config } = props;
|
|
51078
50918
|
const newWithdrawalId = uuid4();
|
|
@@ -51101,7 +50941,7 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
51101
50941
|
},
|
|
51102
50942
|
[logEvent, startMeasuredEvent]
|
|
51103
50943
|
);
|
|
51104
|
-
const initNewCheckout =
|
|
50944
|
+
const initNewCheckout = useCallback66(
|
|
51105
50945
|
({ config, ...initSettings }) => {
|
|
51106
50946
|
const newCheckoutId = uuid4();
|
|
51107
50947
|
const newActiveCheckoutItem = {
|
|
@@ -51191,7 +51031,7 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
51191
51031
|
});
|
|
51192
51032
|
}
|
|
51193
51033
|
);
|
|
51194
|
-
const startDirectExecutionCheckout =
|
|
51034
|
+
const startDirectExecutionCheckout = useCallback66(
|
|
51195
51035
|
async ({
|
|
51196
51036
|
stepMessageSetter,
|
|
51197
51037
|
latestQuote,
|
|
@@ -51351,7 +51191,7 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
51351
51191
|
udaParams
|
|
51352
51192
|
]
|
|
51353
51193
|
);
|
|
51354
|
-
const startRegularCheckout =
|
|
51194
|
+
const startRegularCheckout = useCallback66(
|
|
51355
51195
|
async ({
|
|
51356
51196
|
stepMessageSetter,
|
|
51357
51197
|
latestQuote,
|
|
@@ -51718,14 +51558,14 @@ function useFunkitCheckout(props) {
|
|
|
51718
51558
|
resume: resumeSoftHiddenCheckout,
|
|
51719
51559
|
discard: discardSoftHiddenCheckout
|
|
51720
51560
|
} = useSoftHiddenCheckout();
|
|
51721
|
-
const onErrorWrapper =
|
|
51561
|
+
const onErrorWrapper = useCallback66(
|
|
51722
51562
|
(payload) => {
|
|
51723
51563
|
logger.warn(payload.message, payload);
|
|
51724
51564
|
onError?.(payload);
|
|
51725
51565
|
},
|
|
51726
51566
|
[onError]
|
|
51727
51567
|
);
|
|
51728
|
-
const onOpenWrapper =
|
|
51568
|
+
const onOpenWrapper = useCallback66(
|
|
51729
51569
|
(newId) => {
|
|
51730
51570
|
props?.onOpen?.();
|
|
51731
51571
|
openFunCheckoutModal?.(newId);
|
|
@@ -52060,8 +51900,8 @@ function getMaxTargetAssetAmountEstimate(sourceAssetBalance, config, quoteResult
|
|
|
52060
51900
|
const sourceAssetFees = getQuoteTotalFeesFromAmount(quoteResult);
|
|
52061
51901
|
const maxSourceAssetAmount = Math.max(sourceAssetBalance - sourceAssetFees, 0);
|
|
52062
51902
|
const maxTargetAssetAmount = maxSourceAssetAmount * exchangeRate;
|
|
52063
|
-
return
|
|
52064
|
-
|
|
51903
|
+
return dnum11.multiply(
|
|
51904
|
+
dnum11.from(maxTargetAssetAmount, targetAssetDecimals),
|
|
52065
51905
|
0.99
|
|
52066
51906
|
);
|
|
52067
51907
|
}
|