@fluent.xyz/connect 0.8.2 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -0
- package/dist/index.js +61 -14
- package/dist/index.js.map +1 -1
- package/docs/api.md +2 -0
- package/docs/concepts.md +9 -5
- package/docs/experimental.md +21 -0
- package/docs/getting-started.md +3 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -656,6 +656,20 @@ type FluentWidgetRenderContext = {
|
|
|
656
656
|
openConnect: () => void;
|
|
657
657
|
/** Opens the account drawer, as the connect button does once a Widget account is connected. */
|
|
658
658
|
openAccount: () => void;
|
|
659
|
+
/**
|
|
660
|
+
* Renders the drawer's Swap page, where a Deposit is made, as the App's own element: in a
|
|
661
|
+
* modal or a page of its own, shown when the App decides. It is the page the drawer shows, on
|
|
662
|
+
* both Networks and for either account kind, in the widget's own style scope so it draws as
|
|
663
|
+
* in the drawer inside any element, and it connects the External wallet that pays by itself.
|
|
664
|
+
* `onClose` is called by the page's own ways back to the wallet: "Back to wallet" once
|
|
665
|
+
* a Deposit has landed or while its funds are on their way, and "Back to Home" on a Two-step
|
|
666
|
+
* deposit's status screen. The form itself offers no way back, which the App's own element
|
|
667
|
+
* provides.
|
|
668
|
+
*
|
|
669
|
+
* @experimental May change or be removed in a minor release: an App that draws the Swap page
|
|
670
|
+
* itself is not a 0.8.3 commitment.
|
|
671
|
+
*/
|
|
672
|
+
renderBridge: (onClose: () => void) => ReactNode;
|
|
659
673
|
/**
|
|
660
674
|
* Disconnects the Widget account, the same teardown the account menu's "Disconnect" runs. The
|
|
661
675
|
* Widget session and the stored identity token are cleared before it resolves, so an App can
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { clsx } from 'clsx';
|
|
|
11
11
|
import { twMerge } from 'tailwind-merge';
|
|
12
12
|
import { Button as Button$1 } from '@base-ui/react/button';
|
|
13
13
|
import { cva } from 'class-variance-authority';
|
|
14
|
-
import { X, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Layers, Trash2, RefreshCw, ChevronDownIcon, CheckIcon, AlertTriangle, Plus, Loader2Icon, Loader2, LogIn, Send, RotateCw, KeyRound, Mail, Wallet, XIcon, Check,
|
|
14
|
+
import { X, ChevronLeft, ExternalLink, Copy, Settings, LogOut, Layers, Trash2, RefreshCw, ChevronDownIcon, CheckIcon, AlertTriangle, Plus, Loader2Icon, Loader2, LogIn, Send, RotateCw, KeyRound, Mail, Wallet, XIcon, Check, Search, ChevronDown, Info, ChevronUpIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, OctagonXIcon } from 'lucide-react';
|
|
15
15
|
import { WagmiAdapter } from '@reown/appkit-adapter-wagmi';
|
|
16
16
|
import { createAppKit } from '@reown/appkit/react';
|
|
17
17
|
import { WagmiContext, WagmiProvider, useAccount, useDisconnect, useWalletClient, useSwitchChain, useConnect, useConfig, usePublicClient, useBalance, useReadContract, useWriteContract, useSendTransaction, useWaitForTransactionReceipt } from 'wagmi';
|
|
@@ -5626,7 +5626,7 @@ function createFluentConnectForWidget(config) {
|
|
|
5626
5626
|
}
|
|
5627
5627
|
|
|
5628
5628
|
// package.json
|
|
5629
|
-
var version = "0.8.
|
|
5629
|
+
var version = "0.8.4";
|
|
5630
5630
|
|
|
5631
5631
|
// src/core/analytics.ts
|
|
5632
5632
|
var INSTANCE_NAME = "fluent";
|
|
@@ -9346,6 +9346,10 @@ var TOKENS_BY_NETWORK = {
|
|
|
9346
9346
|
function getBridgeTokens(network) {
|
|
9347
9347
|
return TOKENS_BY_NETWORK[network];
|
|
9348
9348
|
}
|
|
9349
|
+
function getDefaultBridgeToken(network) {
|
|
9350
|
+
const usdc = getBridgeToken(network, "USDC");
|
|
9351
|
+
return isBridgeTokenAvailable(usdc) ? usdc : getBridgeToken(network, "ETH");
|
|
9352
|
+
}
|
|
9349
9353
|
function getBridgeToken(network, symbol) {
|
|
9350
9354
|
const token = TOKENS_BY_NETWORK[network].find((t) => t.symbol === symbol);
|
|
9351
9355
|
if (!token) throw new Error(`Unknown bridge token ${symbol}`);
|
|
@@ -14040,10 +14044,11 @@ function getOrderDepositFeeShare(quote) {
|
|
|
14040
14044
|
return Number(bps) / 1e4;
|
|
14041
14045
|
}
|
|
14042
14046
|
var ORDER_DEPOSIT_FEE_SHARE_WARNING = 0.05;
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
+
var ORDER_DEPOSIT_FEE_SHARE_HINT = 0.02;
|
|
14048
|
+
function getOrderDepositFeeNotice(share) {
|
|
14049
|
+
if (share > ORDER_DEPOSIT_FEE_SHARE_WARNING) return "warning";
|
|
14050
|
+
if (share > ORDER_DEPOSIT_FEE_SHARE_HINT) return "hint";
|
|
14051
|
+
return void 0;
|
|
14047
14052
|
}
|
|
14048
14053
|
|
|
14049
14054
|
// src/bridge/abi.ts
|
|
@@ -15211,11 +15216,21 @@ function formatFeeUsd(wei, usdPrice) {
|
|
|
15211
15216
|
}
|
|
15212
15217
|
var SLIPPAGE_LABEL = `${Number(FLUENT_SWAP_SLIPPAGE_BPS) / 100}%`;
|
|
15213
15218
|
var SLIPPAGE_TOOLTIP = `The swap may settle up to ${SLIPPAGE_LABEL} below its quote. Below that the pool rejects it, and nothing is swapped.`;
|
|
15214
|
-
function Notice2({
|
|
15215
|
-
|
|
15216
|
-
|
|
15217
|
-
|
|
15218
|
-
|
|
15219
|
+
function Notice2({
|
|
15220
|
+
tone = "warning",
|
|
15221
|
+
children
|
|
15222
|
+
}) {
|
|
15223
|
+
return /* @__PURE__ */ jsxs(
|
|
15224
|
+
"p",
|
|
15225
|
+
{
|
|
15226
|
+
className: `flex gap-2 rounded-xl p-3 text-xs ${tone === "warning" ? "bg-amber-400/10 text-amber-300" : "bg-foreground/[0.06] text-foreground/60"}`,
|
|
15227
|
+
role: "status",
|
|
15228
|
+
children: [
|
|
15229
|
+
tone === "warning" ? /* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0" }) : null,
|
|
15230
|
+
/* @__PURE__ */ jsx("span", { children })
|
|
15231
|
+
]
|
|
15232
|
+
}
|
|
15233
|
+
);
|
|
15219
15234
|
}
|
|
15220
15235
|
function TokenChip({ symbol }) {
|
|
15221
15236
|
return /* @__PURE__ */ jsxs("span", { className: "flex h-11 shrink-0 items-center gap-2 rounded-full bg-foreground/[0.06] pl-2 pr-3.5 text-foreground", children: [
|
|
@@ -15455,7 +15470,9 @@ function BridgeForm({
|
|
|
15455
15470
|
onGoHome
|
|
15456
15471
|
}) {
|
|
15457
15472
|
const tokens = getBridgeTokens(network);
|
|
15458
|
-
const [symbol, setSymbol] = useState(
|
|
15473
|
+
const [symbol, setSymbol] = useState(
|
|
15474
|
+
() => getDefaultBridgeToken(network).symbol
|
|
15475
|
+
);
|
|
15459
15476
|
const token = getBridgeToken(network, symbol);
|
|
15460
15477
|
const handOver = useRef(void 0);
|
|
15461
15478
|
const bridge = useBridgeDeposit({
|
|
@@ -15619,6 +15636,11 @@ function BridgeForm({
|
|
|
15619
15636
|
const fillMinutes = Math.max(1, Math.round((bridge.order?.fillSeconds ?? 60) / 60));
|
|
15620
15637
|
const fillTime = fillMinutes === 1 ? "about a minute" : `about ${fillMinutes} minutes`;
|
|
15621
15638
|
const minimumOut = twoStep && quote ? applyFluentSwapSlippage(quote.amountOut, FLUENT_SWAP_SLIPPAGE_BPS) : void 0;
|
|
15639
|
+
const feeNoticeTone = bridge.order?.solverFeeShare !== void 0 ? getOrderDepositFeeNotice(bridge.order.solverFeeShare) : void 0;
|
|
15640
|
+
const feeNotice = feeNoticeTone && bridge.order?.solverFee !== void 0 ? {
|
|
15641
|
+
tone: feeNoticeTone,
|
|
15642
|
+
text: `Flat ${formatAmount(bridge.order.solverFee, token.decimals, token.symbol)} ${token.symbol} fee. Bridge more to pay a smaller share.`
|
|
15643
|
+
} : void 0;
|
|
15622
15644
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-4 flex-1", children: [
|
|
15623
15645
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
15624
15646
|
/* @__PURE__ */ jsxs(AmountCard, { label: "Send", children: [
|
|
@@ -15726,7 +15748,7 @@ function BridgeForm({
|
|
|
15726
15748
|
{
|
|
15727
15749
|
label: "Solver fee",
|
|
15728
15750
|
value: `${formatAmount(bridge.order.solverFee, token.decimals, token.symbol)} ` + token.symbol,
|
|
15729
|
-
secondary:
|
|
15751
|
+
secondary: "flat fee",
|
|
15730
15752
|
tooltip: "The solver that fills the order keeps this out of the amount you send. What you receive is already net of it. The fee is flat, so a larger deposit pays the same."
|
|
15731
15753
|
}
|
|
15732
15754
|
) : null
|
|
@@ -15771,7 +15793,7 @@ function BridgeForm({
|
|
|
15771
15793
|
] }) : null,
|
|
15772
15794
|
bridge.order ? /* @__PURE__ */ jsx("span", { className: "text-xs text-foreground/60", children: `${token.symbol} is sent as a limit order on ${route.source.name}: a solver pays ${deliveredToken.symbol} to your Fluent account, usually in ${fillTime}. Gas is paid in ${ethSymbol}.` }) : isSwap && !bridge.routeLoading ? /* @__PURE__ */ jsx("span", { className: "text-xs text-foreground/60", children: `${token.symbol} is swapped 1:1 to ${deliveredToken.symbol} on ${route.source.name}, then bridged to Fluent. Fees are paid in ${ethSymbol}. Expect up to 4 confirmations.` }) : null
|
|
15773
15795
|
] }) }),
|
|
15774
|
-
|
|
15796
|
+
feeNotice ? /* @__PURE__ */ jsx(Notice2, { tone: feeNotice.tone, children: feeNotice.text }) : null,
|
|
15775
15797
|
bridge.gasFeeShort && bridge.ethBalance !== void 0 ? /* @__PURE__ */ jsx(Notice2, { children: `Your wallet holds ${formatAmount(bridge.ethBalance, 18)} ${ethSymbol} on ${route.source.name}, less than the network fee. Add ${ethSymbol}, or let your wallet pay gas with a token.` }) : null,
|
|
15776
15798
|
state.phase === "error" ? /* @__PURE__ */ jsx("span", { className: "text-xs text-destructive", children: state.message }) : null,
|
|
15777
15799
|
bridge.restoring ? /* @__PURE__ */ jsxs(Button, { className: "w-full", disabled: true, children: [
|
|
@@ -22528,6 +22550,25 @@ function FluentWidgetContent({
|
|
|
22528
22550
|
widget: appWidgetApi,
|
|
22529
22551
|
openConnect,
|
|
22530
22552
|
openAccount: openAccountMenu,
|
|
22553
|
+
// The drawer's Swap page with the drawer's own props, so a Deposit started here is the
|
|
22554
|
+
// same Deposit the drawer follows; the App's `onClose` stands where the drawer goes home.
|
|
22555
|
+
renderBridge: (onClose) => (
|
|
22556
|
+
// In the widget's own style scope, as the drawer is: the App's element sits outside it,
|
|
22557
|
+
// and the package's layout rules and theme colours hold under `.fluent-root` alone. The
|
|
22558
|
+
// scope draws no box of its own, so the page fills the element the App gives it.
|
|
22559
|
+
/* @__PURE__ */ jsx("div", { className: WIDGET_STYLE_SCOPE, children: /* @__PURE__ */ jsx(
|
|
22560
|
+
BridgeScreen,
|
|
22561
|
+
{
|
|
22562
|
+
config,
|
|
22563
|
+
recipient: fluentAccountAddress,
|
|
22564
|
+
onSignIn: signInWithFluent,
|
|
22565
|
+
track,
|
|
22566
|
+
depositSwap: bridgeDepositSwap,
|
|
22567
|
+
onDepositSent: addSentDeposit,
|
|
22568
|
+
onGoHome: onClose
|
|
22569
|
+
}
|
|
22570
|
+
) })
|
|
22571
|
+
),
|
|
22531
22572
|
disconnect: requestDisconnect,
|
|
22532
22573
|
hasConnectedAccount,
|
|
22533
22574
|
status,
|
|
@@ -22544,6 +22585,12 @@ function FluentWidgetContent({
|
|
|
22544
22585
|
appWidgetApi,
|
|
22545
22586
|
openConnect,
|
|
22546
22587
|
openAccountMenu,
|
|
22588
|
+
config,
|
|
22589
|
+
fluentAccountAddress,
|
|
22590
|
+
signInWithFluent,
|
|
22591
|
+
track,
|
|
22592
|
+
bridgeDepositSwap,
|
|
22593
|
+
addSentDeposit,
|
|
22547
22594
|
requestDisconnect,
|
|
22548
22595
|
hasConnectedAccount,
|
|
22549
22596
|
status,
|