@funkit/connect 5.5.13-next.1 → 5.5.13-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/domains/meld.d.ts +19 -0
- package/dist/index.js +115 -120
- package/dist/providers/FunkitCheckoutContext.d.ts +3 -2
- 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 +60 -60
- 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 +3 -3
- package/dist/wallets/walletConnectors/chunk-25VW5TZP.js +0 -92
- package/dist/wallets/walletConnectors/chunk-3NC26XLM.js +0 -92
- package/dist/wallets/walletConnectors/chunk-3U3BMEH5.js +0 -94
- package/dist/wallets/walletConnectors/chunk-4UM4GTKZ.js +0 -103
- package/dist/wallets/walletConnectors/chunk-545L7Y4M.js +0 -69
- package/dist/wallets/walletConnectors/chunk-6LPM6LUQ.js +0 -110
- package/dist/wallets/walletConnectors/chunk-7GSNBOD3.js +0 -99
- package/dist/wallets/walletConnectors/chunk-ETTNDQQG.js +0 -100
- package/dist/wallets/walletConnectors/chunk-FRGSRLTS.js +0 -93
- package/dist/wallets/walletConnectors/chunk-HKV7EMYZ.js +0 -96
- package/dist/wallets/walletConnectors/chunk-IPOC2VJX.js +0 -106
- package/dist/wallets/walletConnectors/chunk-JXP2QPW7.js +0 -95
- package/dist/wallets/walletConnectors/chunk-KFFJPS5R.js +0 -96
- package/dist/wallets/walletConnectors/chunk-LEXSM5KI.js +0 -87
- package/dist/wallets/walletConnectors/chunk-MOOBCMMB.js +0 -70
- package/dist/wallets/walletConnectors/chunk-N2NIIUW6.js +0 -146
- package/dist/wallets/walletConnectors/chunk-W5O4YSZN.js +0 -98
- package/dist/wallets/walletConnectors/chunk-XYBEMO3C.js +0 -66
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @funkit/connect
|
|
2
2
|
|
|
3
|
+
## 5.5.13-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 17e47e1: move withdrawSourceBalance to top level config
|
|
8
|
+
- df1b830: chore: deprecate dydx fee handling
|
|
9
|
+
- 9ce2ee3: chore(connect): add meld util tests
|
|
10
|
+
|
|
3
11
|
## 5.5.13-next.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type MeldQuote } from '@funkit/api-base';
|
|
2
|
+
/**
|
|
3
|
+
* Auto-pick the best quote for the user.
|
|
4
|
+
* 1. Pick the quote with the highest customerScore, at least >= 30
|
|
5
|
+
* 2. If no quote has customerScore >= 30, pick either Coinbase or Binance
|
|
6
|
+
* 2a. If both are available, pick the one with the highest destinationAmount
|
|
7
|
+
* 2b. If only one is available, pick it
|
|
8
|
+
* 3. If no quote has customerScore >= 30 and no Coinbase or Binance is available, pick the quote with the highest destinationAmount
|
|
9
|
+
* @param quotes - the quotes to pick from
|
|
10
|
+
* @returns the best quote based on the criteria
|
|
11
|
+
*/
|
|
12
|
+
export declare function autoPickBestQuote(quotes: MeldQuote[]): MeldQuote | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Check if the quote is the best price quote.
|
|
15
|
+
* @param sourceQuotes - the quotes to check
|
|
16
|
+
* @param targetQuote - the quote to check
|
|
17
|
+
* @returns true if the quote is the best price quote, false otherwise
|
|
18
|
+
*/
|
|
19
|
+
export declare function isBestPriceQuote(sourceQuotes: MeldQuote[] | undefined, targetQuote: MeldQuote | undefined): boolean;
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
darkTheme
|
|
4
|
-
} from "./chunk-ICCAQZHZ.js";
|
|
5
2
|
import {
|
|
6
3
|
lightTheme
|
|
7
4
|
} from "./chunk-RN4I4Y57.js";
|
|
5
|
+
import {
|
|
6
|
+
darkTheme
|
|
7
|
+
} from "./chunk-ICCAQZHZ.js";
|
|
8
8
|
import {
|
|
9
9
|
systemFontStack
|
|
10
10
|
} from "./chunk-R2UFCJL7.js";
|
|
@@ -2864,14 +2864,14 @@ var flagConfig = {
|
|
|
2864
2864
|
}
|
|
2865
2865
|
]
|
|
2866
2866
|
},
|
|
2867
|
-
//
|
|
2867
|
+
// 20% rollout to Ostium and Polymarket users
|
|
2868
2868
|
{
|
|
2869
2869
|
value: true,
|
|
2870
2870
|
if_all: [
|
|
2871
2871
|
{
|
|
2872
2872
|
key: "userId",
|
|
2873
2873
|
type: "pctRollout",
|
|
2874
|
-
pct:
|
|
2874
|
+
pct: 20
|
|
2875
2875
|
},
|
|
2876
2876
|
{
|
|
2877
2877
|
key: "apiKey",
|
|
@@ -6275,14 +6275,15 @@ function FunkitCheckoutProvider({ children }) {
|
|
|
6275
6275
|
);
|
|
6276
6276
|
const initNewWithdrawal = useCallback10(
|
|
6277
6277
|
(props) => {
|
|
6278
|
-
const { onWithdrawalConfirmation, onWithdrawalError } = props;
|
|
6278
|
+
const { onWithdrawalConfirmation, onWithdrawalError, config } = props;
|
|
6279
6279
|
const newWithdrawalId = uuid();
|
|
6280
6280
|
const newActiveWithdrawalItem = {
|
|
6281
6281
|
id: newWithdrawalId,
|
|
6282
6282
|
initSettings: {
|
|
6283
6283
|
onWithdrawalConfirmation,
|
|
6284
6284
|
onWithdrawalError
|
|
6285
|
-
}
|
|
6285
|
+
},
|
|
6286
|
+
withdrawalSourceTokenBalance: config.withdrawalSourceTokenBalance ?? (() => 0)
|
|
6286
6287
|
};
|
|
6287
6288
|
setActiveWithdrawal(newActiveWithdrawalItem);
|
|
6288
6289
|
logger.log("withdrawalStarted", newActiveWithdrawalItem);
|
|
@@ -11439,7 +11440,7 @@ function renderRelayFee(relayQuote) {
|
|
|
11439
11440
|
]
|
|
11440
11441
|
};
|
|
11441
11442
|
}
|
|
11442
|
-
var extractFeeItems = (fees, totalUsd
|
|
11443
|
+
var extractFeeItems = (fees, totalUsd) => {
|
|
11443
11444
|
const marketMakerFee = {
|
|
11444
11445
|
label: "Market maker gas costs",
|
|
11445
11446
|
value: formatCurrencyAndStringify2(fees.marketMakerFeeUsd),
|
|
@@ -11457,13 +11458,13 @@ var extractFeeItems = (fees, totalUsd, isDydx) => {
|
|
|
11457
11458
|
return renderRelayFee(fees.relayQuote);
|
|
11458
11459
|
}
|
|
11459
11460
|
if (fees.paymentMethod === "balance" /* ACCOUNT_BALANCE */) {
|
|
11460
|
-
const { eoaWalletFeeUsd
|
|
11461
|
+
const { eoaWalletFeeUsd } = fees;
|
|
11461
11462
|
const fillGasCost = formatDynamicFeeUsd(eoaWalletFeeUsd, totalUsd, {
|
|
11462
11463
|
percentThreshold: null
|
|
11463
11464
|
});
|
|
11464
11465
|
return {
|
|
11465
11466
|
collapsed: {
|
|
11466
|
-
value:
|
|
11467
|
+
value: fillGasCost,
|
|
11467
11468
|
valueIcon: /* @__PURE__ */ React87.createElement(GasIcon, null)
|
|
11468
11469
|
},
|
|
11469
11470
|
expanded: [
|
|
@@ -11478,12 +11479,9 @@ var extractFeeItems = (fees, totalUsd, isDydx) => {
|
|
|
11478
11479
|
};
|
|
11479
11480
|
}
|
|
11480
11481
|
if (fees.paymentMethod === "card" /* CARD */) {
|
|
11481
|
-
const {
|
|
11482
|
+
const { cardProcessingFeeUsd, moonpayCostUsd } = fees;
|
|
11482
11483
|
return {
|
|
11483
|
-
collapsed:
|
|
11484
|
-
value: formatCurrencyAndStringify2(marketMakerFeeUsd),
|
|
11485
|
-
valueIcon: /* @__PURE__ */ React87.createElement(GasIcon, null)
|
|
11486
|
-
} : null,
|
|
11484
|
+
collapsed: null,
|
|
11487
11485
|
expanded: [
|
|
11488
11486
|
marketMakerFee,
|
|
11489
11487
|
lpCostFee,
|
|
@@ -11502,12 +11500,9 @@ var extractFeeItems = (fees, totalUsd, isDydx) => {
|
|
|
11502
11500
|
};
|
|
11503
11501
|
}
|
|
11504
11502
|
if (fees.paymentMethod === "brokerage" /* BROKERAGE */) {
|
|
11505
|
-
const {
|
|
11503
|
+
const { exchangeFeeUsd, meshCostUsd } = fees;
|
|
11506
11504
|
return {
|
|
11507
|
-
collapsed:
|
|
11508
|
-
value: formatCurrencyAndStringify2(marketMakerFeeUsd),
|
|
11509
|
-
valueIcon: /* @__PURE__ */ React87.createElement(GasIcon, null)
|
|
11510
|
-
} : null,
|
|
11505
|
+
collapsed: null,
|
|
11511
11506
|
expanded: [
|
|
11512
11507
|
marketMakerFee,
|
|
11513
11508
|
lpCostFee,
|
|
@@ -11526,7 +11521,6 @@ function PaymentFeesSummary({
|
|
|
11526
11521
|
quote,
|
|
11527
11522
|
fallbackFees
|
|
11528
11523
|
}) {
|
|
11529
|
-
const { apiKey } = useFunkitConfig();
|
|
11530
11524
|
const controls = useAnimationControls();
|
|
11531
11525
|
const [isExpanded, setIsExpanded] = useState22(false);
|
|
11532
11526
|
const toggleIsExpanded = async () => {
|
|
@@ -11540,13 +11534,12 @@ function PaymentFeesSummary({
|
|
|
11540
11534
|
setIsExpanded(true);
|
|
11541
11535
|
}
|
|
11542
11536
|
};
|
|
11543
|
-
const isDydx = isDydxCustomer(apiKey);
|
|
11544
11537
|
const { collapsed: collapsedItem, expanded: expandedItems } = useMemo10(() => {
|
|
11545
11538
|
const fees = quote?.finalFeesBreakdown ?? fallbackFees;
|
|
11546
11539
|
if (!fees) return NO_DATA;
|
|
11547
11540
|
const totalUsd = Number(quote?.finalTotalUsd ?? "0");
|
|
11548
|
-
return extractFeeItems(fees, totalUsd
|
|
11549
|
-
}, [quote,
|
|
11541
|
+
return extractFeeItems(fees, totalUsd);
|
|
11542
|
+
}, [quote, fallbackFees]);
|
|
11550
11543
|
const isExpandable = expandedItems.length > 0 && !isLoading;
|
|
11551
11544
|
return /* @__PURE__ */ React87.createElement(Box, null, /* @__PURE__ */ React87.createElement(
|
|
11552
11545
|
Box,
|
|
@@ -11707,7 +11700,7 @@ var WithdrawContent = ({
|
|
|
11707
11700
|
config,
|
|
11708
11701
|
withdrawalItem
|
|
11709
11702
|
}) => {
|
|
11710
|
-
const
|
|
11703
|
+
const sourceTokenBalance = withdrawalItem?.withdrawalSourceTokenBalance?.() || 0;
|
|
11711
11704
|
const token = config.sourceTokenSymbol;
|
|
11712
11705
|
const [receiveAddress, setReceiveAddress] = useState23("");
|
|
11713
11706
|
const [amount, setAmount] = useState23("");
|
|
@@ -18684,7 +18677,6 @@ import {
|
|
|
18684
18677
|
round as round3
|
|
18685
18678
|
} from "@funkit/utils";
|
|
18686
18679
|
import React167, { useMemo as useMemo23 } from "react";
|
|
18687
|
-
import { MeldServiceProvider } from "@funkit/api-base";
|
|
18688
18680
|
|
|
18689
18681
|
// src/components/CurrencySelector/CurrencySelector.tsx
|
|
18690
18682
|
import React156 from "react";
|
|
@@ -19738,65 +19730,43 @@ var YouPayYouReceiveBottomBarLayoutWrapper = ({
|
|
|
19738
19730
|
);
|
|
19739
19731
|
};
|
|
19740
19732
|
|
|
19741
|
-
// src/
|
|
19742
|
-
import
|
|
19743
|
-
|
|
19744
|
-
|
|
19745
|
-
|
|
19746
|
-
|
|
19747
|
-
|
|
19748
|
-
|
|
19749
|
-
viewBox: "0 0 15 14",
|
|
19750
|
-
fill: "none",
|
|
19751
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
19752
|
-
},
|
|
19753
|
-
/* @__PURE__ */ React164.createElement(
|
|
19754
|
-
"path",
|
|
19755
|
-
{
|
|
19756
|
-
fillRule: "evenodd",
|
|
19757
|
-
clipRule: "evenodd",
|
|
19758
|
-
d: "M0.96967 4.86358C0.676777 4.57069 0.676777 4.09582 0.96967 3.80292L3.63634 1.13626C3.92923 0.843363 4.4041 0.843363 4.697 1.13626L7.36366 3.80292C7.65656 4.09582 7.65656 4.57069 7.36366 4.86358C7.07077 5.15648 6.5959 5.15648 6.303 4.86358L4.91667 3.47725L4.91667 12.3333C4.91667 12.7475 4.58088 13.0833 4.16667 13.0833C3.75245 13.0833 3.41667 12.7475 3.41667 12.3333L3.41667 3.47725L2.03033 4.86358C1.73744 5.15648 1.26256 5.15648 0.96967 4.86358ZM7.63634 9.13626C7.92923 8.84336 8.4041 8.84336 8.697 9.13626L10.0833 10.5226V1.66659C10.0833 1.25237 10.4191 0.916586 10.8333 0.916586C11.2475 0.916586 11.5833 1.25237 11.5833 1.66659V10.5226L12.9697 9.13626C13.2626 8.84336 13.7374 8.84336 14.0303 9.13626C14.3232 9.42915 14.3232 9.90402 14.0303 10.1969L11.3637 12.8636C11.0708 13.1565 10.5959 13.1565 10.303 12.8636L7.63634 10.1969C7.34344 9.90402 7.34344 9.42915 7.63634 9.13626Z",
|
|
19759
|
-
fill: "currentColor"
|
|
19760
|
-
}
|
|
19761
|
-
)
|
|
19733
|
+
// src/domains/meld.ts
|
|
19734
|
+
import { MeldServiceProvider } from "@funkit/api-base";
|
|
19735
|
+
function autoPickBestQuote(quotes) {
|
|
19736
|
+
if (!quotes || quotes.length === 0) {
|
|
19737
|
+
return void 0;
|
|
19738
|
+
}
|
|
19739
|
+
const sortedByScore = [...quotes].sort(
|
|
19740
|
+
(a, b) => (b.customerScore ?? 0) - (a.customerScore ?? 0)
|
|
19762
19741
|
);
|
|
19763
|
-
|
|
19764
|
-
|
|
19765
|
-
|
|
19766
|
-
|
|
19767
|
-
|
|
19768
|
-
|
|
19769
|
-
|
|
19770
|
-
|
|
19771
|
-
|
|
19772
|
-
|
|
19773
|
-
|
|
19774
|
-
|
|
19775
|
-
|
|
19776
|
-
|
|
19777
|
-
|
|
19778
|
-
|
|
19779
|
-
|
|
19780
|
-
|
|
19781
|
-
|
|
19782
|
-
|
|
19783
|
-
|
|
19784
|
-
|
|
19785
|
-
|
|
19786
|
-
|
|
19787
|
-
|
|
19788
|
-
|
|
19789
|
-
|
|
19790
|
-
|
|
19791
|
-
} else if (fontSize < max && textWidth < maxWidth - ALLOWANCE) {
|
|
19792
|
-
setFontSize((prevSize) => prevSize + SIZE_STEP);
|
|
19793
|
-
}
|
|
19794
|
-
};
|
|
19795
|
-
resizeText();
|
|
19796
|
-
}, [max, min, inputValue, fontSize]);
|
|
19797
|
-
const resetText = useCallback29(() => setFontSize(max), [max]);
|
|
19798
|
-
return { ref: inputRef, fontSize, resetText };
|
|
19799
|
-
};
|
|
19742
|
+
if ((sortedByScore[0].customerScore ?? 0) >= 30) {
|
|
19743
|
+
return sortedByScore[0];
|
|
19744
|
+
}
|
|
19745
|
+
const coinbaseOrBinance = quotes.filter(
|
|
19746
|
+
(q) => q.serviceProvider === MeldServiceProvider.COINBASEPAY || q.serviceProvider === MeldServiceProvider.BINANCECONNECT
|
|
19747
|
+
);
|
|
19748
|
+
if (coinbaseOrBinance.length > 0) {
|
|
19749
|
+
const sortedByDestAmount2 = [...coinbaseOrBinance].sort(
|
|
19750
|
+
(a, b) => (b.destinationAmount ?? 0) - (a.destinationAmount ?? 0)
|
|
19751
|
+
);
|
|
19752
|
+
return sortedByDestAmount2[0];
|
|
19753
|
+
}
|
|
19754
|
+
const sortedByDestAmount = [...quotes].sort(
|
|
19755
|
+
(a, b) => (b.destinationAmount ?? 0) - (a.destinationAmount ?? 0)
|
|
19756
|
+
);
|
|
19757
|
+
return sortedByDestAmount[0];
|
|
19758
|
+
}
|
|
19759
|
+
function isBestPriceQuote(sourceQuotes, targetQuote) {
|
|
19760
|
+
if (!sourceQuotes || sourceQuotes.length === 0 || !targetQuote) {
|
|
19761
|
+
return false;
|
|
19762
|
+
}
|
|
19763
|
+
for (const q of sourceQuotes) {
|
|
19764
|
+
if (q.destinationAmount > targetQuote.destinationAmount) {
|
|
19765
|
+
return false;
|
|
19766
|
+
}
|
|
19767
|
+
}
|
|
19768
|
+
return true;
|
|
19769
|
+
}
|
|
19800
19770
|
|
|
19801
19771
|
// src/modals/CheckoutModal/MeldQuotes/useMeldLink.tsx
|
|
19802
19772
|
import { startMeldSession } from "@funkit/api-base";
|
|
@@ -19892,6 +19862,66 @@ var useMeldQuotes = (sourceAmount, fiatCurrency) => {
|
|
|
19892
19862
|
};
|
|
19893
19863
|
};
|
|
19894
19864
|
|
|
19865
|
+
// src/components/Icons/SwitchIcon.tsx
|
|
19866
|
+
import React164 from "react";
|
|
19867
|
+
var SwitchIcon = () => {
|
|
19868
|
+
return /* @__PURE__ */ React164.createElement(
|
|
19869
|
+
"svg",
|
|
19870
|
+
{
|
|
19871
|
+
width: "15",
|
|
19872
|
+
height: "14",
|
|
19873
|
+
viewBox: "0 0 15 14",
|
|
19874
|
+
fill: "none",
|
|
19875
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
19876
|
+
},
|
|
19877
|
+
/* @__PURE__ */ React164.createElement(
|
|
19878
|
+
"path",
|
|
19879
|
+
{
|
|
19880
|
+
fillRule: "evenodd",
|
|
19881
|
+
clipRule: "evenodd",
|
|
19882
|
+
d: "M0.96967 4.86358C0.676777 4.57069 0.676777 4.09582 0.96967 3.80292L3.63634 1.13626C3.92923 0.843363 4.4041 0.843363 4.697 1.13626L7.36366 3.80292C7.65656 4.09582 7.65656 4.57069 7.36366 4.86358C7.07077 5.15648 6.5959 5.15648 6.303 4.86358L4.91667 3.47725L4.91667 12.3333C4.91667 12.7475 4.58088 13.0833 4.16667 13.0833C3.75245 13.0833 3.41667 12.7475 3.41667 12.3333L3.41667 3.47725L2.03033 4.86358C1.73744 5.15648 1.26256 5.15648 0.96967 4.86358ZM7.63634 9.13626C7.92923 8.84336 8.4041 8.84336 8.697 9.13626L10.0833 10.5226V1.66659C10.0833 1.25237 10.4191 0.916586 10.8333 0.916586C11.2475 0.916586 11.5833 1.25237 11.5833 1.66659V10.5226L12.9697 9.13626C13.2626 8.84336 13.7374 8.84336 14.0303 9.13626C14.3232 9.42915 14.3232 9.90402 14.0303 10.1969L11.3637 12.8636C11.0708 13.1565 10.5959 13.1565 10.303 12.8636L7.63634 10.1969C7.34344 9.90402 7.34344 9.42915 7.63634 9.13626Z",
|
|
19883
|
+
fill: "currentColor"
|
|
19884
|
+
}
|
|
19885
|
+
)
|
|
19886
|
+
);
|
|
19887
|
+
};
|
|
19888
|
+
|
|
19889
|
+
// src/hooks/useDynamicFont.ts
|
|
19890
|
+
import { useCallback as useCallback29, useEffect as useEffect30, useRef as useRef13, useState as useState40 } from "react";
|
|
19891
|
+
var SIZE_STEP = 1;
|
|
19892
|
+
var ALLOWANCE = 20;
|
|
19893
|
+
var BASE_FONT_SIZE = 57;
|
|
19894
|
+
var useDynamicFont = (inputValue, max = BASE_FONT_SIZE, min = 16) => {
|
|
19895
|
+
const [fontSize, setFontSize] = useState40(max);
|
|
19896
|
+
const inputRef = useRef13(null);
|
|
19897
|
+
const canvasRef = useRef13(document.createElement("canvas"));
|
|
19898
|
+
useEffect30(() => {
|
|
19899
|
+
const measureTextWidth = (text) => {
|
|
19900
|
+
if (!inputRef.current) return void 0;
|
|
19901
|
+
const context = canvasRef.current.getContext("2d");
|
|
19902
|
+
if (!context) return void 0;
|
|
19903
|
+
const fontSize2 = inputRef.current.style.fontSize;
|
|
19904
|
+
const fontFamily = window.getComputedStyle(inputRef.current).fontFamily;
|
|
19905
|
+
context.font = `${fontSize2} ${fontFamily}`;
|
|
19906
|
+
return Math.ceil(context.measureText(` ${text}`).width);
|
|
19907
|
+
};
|
|
19908
|
+
const resizeText = () => {
|
|
19909
|
+
if (!inputRef.current) return;
|
|
19910
|
+
const textWidth = measureTextWidth(inputValue);
|
|
19911
|
+
if (textWidth === void 0) return;
|
|
19912
|
+
const maxWidth = inputRef.current.getBoundingClientRect().width;
|
|
19913
|
+
if (fontSize > min && textWidth >= maxWidth) {
|
|
19914
|
+
setFontSize((prevSize) => prevSize - SIZE_STEP);
|
|
19915
|
+
} else if (fontSize < max && textWidth < maxWidth - ALLOWANCE) {
|
|
19916
|
+
setFontSize((prevSize) => prevSize + SIZE_STEP);
|
|
19917
|
+
}
|
|
19918
|
+
};
|
|
19919
|
+
resizeText();
|
|
19920
|
+
}, [max, min, inputValue, fontSize]);
|
|
19921
|
+
const resetText = useCallback29(() => setFontSize(max), [max]);
|
|
19922
|
+
return { ref: inputRef, fontSize, resetText };
|
|
19923
|
+
};
|
|
19924
|
+
|
|
19895
19925
|
// src/modals/CheckoutModal/InputAmount/InputAmountLayout.tsx
|
|
19896
19926
|
import { isMobile as isMobile5 } from "@funkit/utils";
|
|
19897
19927
|
import React165 from "react";
|
|
@@ -20334,41 +20364,6 @@ function useAmountInput(options) {
|
|
|
20334
20364
|
}
|
|
20335
20365
|
|
|
20336
20366
|
// src/modals/CheckoutModal/InputAmount/InputAmountLoaded.tsx
|
|
20337
|
-
function autoPickBestQuote(quotes) {
|
|
20338
|
-
if (!quotes || quotes.length === 0) {
|
|
20339
|
-
return void 0;
|
|
20340
|
-
}
|
|
20341
|
-
const sortedByScore = [...quotes].sort(
|
|
20342
|
-
(a, b) => (b.customerScore ?? 0) - (a.customerScore ?? 0)
|
|
20343
|
-
);
|
|
20344
|
-
if ((sortedByScore[0].customerScore ?? 0) >= 30) {
|
|
20345
|
-
return sortedByScore[0];
|
|
20346
|
-
}
|
|
20347
|
-
const coinbaseOrBinance = quotes.filter(
|
|
20348
|
-
(q) => q.serviceProvider === MeldServiceProvider.COINBASEPAY || q.serviceProvider === MeldServiceProvider.BINANCECONNECT
|
|
20349
|
-
);
|
|
20350
|
-
if (coinbaseOrBinance.length > 0) {
|
|
20351
|
-
const sortedByDestAmount2 = [...coinbaseOrBinance].sort(
|
|
20352
|
-
(a, b) => (b.destinationAmount ?? 0) - (a.destinationAmount ?? 0)
|
|
20353
|
-
);
|
|
20354
|
-
return sortedByDestAmount2[0];
|
|
20355
|
-
}
|
|
20356
|
-
const sortedByDestAmount = [...quotes].sort(
|
|
20357
|
-
(a, b) => (b.destinationAmount ?? 0) - (a.destinationAmount ?? 0)
|
|
20358
|
-
);
|
|
20359
|
-
return sortedByDestAmount[0];
|
|
20360
|
-
}
|
|
20361
|
-
function isBestPriceQuote(quotes, quote) {
|
|
20362
|
-
if (!quotes || quotes.length === 0 || !quote) {
|
|
20363
|
-
return false;
|
|
20364
|
-
}
|
|
20365
|
-
for (const q of quotes) {
|
|
20366
|
-
if (q.destinationAmount > quote.destinationAmount) {
|
|
20367
|
-
return false;
|
|
20368
|
-
}
|
|
20369
|
-
}
|
|
20370
|
-
return true;
|
|
20371
|
-
}
|
|
20372
20367
|
function useMeld(manuallySelectedQuote, usdAmount, fiatCurrency) {
|
|
20373
20368
|
const { query: meldQuotesQuery } = useMeldQuotes(usdAmount, fiatCurrency);
|
|
20374
20369
|
const { mutateAsync, isPending: isMeldLinkPending } = useMeldLink(
|
|
@@ -31589,7 +31584,7 @@ function setFunkitConnectVersion({ version }) {
|
|
|
31589
31584
|
localStorage.setItem(storageKey5, version);
|
|
31590
31585
|
}
|
|
31591
31586
|
function getCurrentSdkVersion() {
|
|
31592
|
-
return "5.5.13-next.
|
|
31587
|
+
return "5.5.13-next.2";
|
|
31593
31588
|
}
|
|
31594
31589
|
function useFingerprint() {
|
|
31595
31590
|
const fingerprint = useCallback50(() => {
|
|
@@ -37,6 +37,8 @@ export interface FunkitCheckoutConfig extends Omit<ApiFunkitCheckoutConfig, 'gen
|
|
|
37
37
|
checkoutItemTitle: string;
|
|
38
38
|
/** @deprecated use targetAssetAmount **/
|
|
39
39
|
checkoutItemAmount?: number;
|
|
40
|
+
/** amount of source token. it is not baseUnit **/
|
|
41
|
+
withdrawalSourceTokenBalance?: () => number;
|
|
40
42
|
/** *****************************
|
|
41
43
|
* Miscellaneous configurations *
|
|
42
44
|
********************************/
|
|
@@ -59,8 +61,6 @@ export interface FunkitWithdrawalConfig {
|
|
|
59
61
|
sourceChainId: string;
|
|
60
62
|
/** source token id to withdraw **/
|
|
61
63
|
sourceTokenAddress: Address;
|
|
62
|
-
/** amount of source token. it is not baseUnit **/
|
|
63
|
-
sourceTokenBalance: number;
|
|
64
64
|
/** whether to show connected as preferred withdrawal destination*/
|
|
65
65
|
showConnectedWalletAsPreferredRecipient?: boolean;
|
|
66
66
|
/** Wallet instance used to execute the quote */
|
|
@@ -138,6 +138,7 @@ export interface FunkitActiveWithdrawalItem {
|
|
|
138
138
|
id: string;
|
|
139
139
|
/** Final settings the withdrawal was init-ed with **/
|
|
140
140
|
initSettings: Partial<UseFunkitCheckoutPropsWithFullConfig>;
|
|
141
|
+
withdrawalSourceTokenBalance: () => number;
|
|
141
142
|
}
|
|
142
143
|
interface FunkitCheckoutContextInterface {
|
|
143
144
|
checkoutItem: FunkitActiveCheckoutItem | null;
|