@fluent.xyz/connect 0.8.1-rc.1 → 0.8.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/dist/fluent-connect.css +1 -1
- package/dist/index.js +229 -110
- package/dist/index.js.map +1 -1
- package/docs/concepts.md +3 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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.2";
|
|
5630
5630
|
|
|
5631
5631
|
// src/core/analytics.ts
|
|
5632
5632
|
var INSTANCE_NAME = "fluent";
|
|
@@ -8566,16 +8566,27 @@ function SummaryRow({
|
|
|
8566
8566
|
tooltip,
|
|
8567
8567
|
valueTitle
|
|
8568
8568
|
}) {
|
|
8569
|
+
const [tipOpen, setTipOpen] = useState(false);
|
|
8569
8570
|
return /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-5 text-sm", children: [
|
|
8570
8571
|
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1 text-foreground/80", children: [
|
|
8571
8572
|
label,
|
|
8572
|
-
tooltip ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8573
|
+
tooltip ? /* @__PURE__ */ jsxs(Tooltip, { open: tipOpen, onOpenChange: setTipOpen, children: [
|
|
8573
8574
|
/* @__PURE__ */ jsx(
|
|
8574
8575
|
TooltipTrigger,
|
|
8575
8576
|
{
|
|
8576
|
-
tabIndex: 0,
|
|
8577
8577
|
"aria-label": `About the ${label.toLowerCase()}`,
|
|
8578
|
-
render:
|
|
8578
|
+
render: (
|
|
8579
|
+
// `!` against an App's own `button` rule, as on `ConsentLink`. A press only
|
|
8580
|
+
// opens: hover has opened it already on a desktop, and a tap elsewhere closes it.
|
|
8581
|
+
/* @__PURE__ */ jsx(
|
|
8582
|
+
"button",
|
|
8583
|
+
{
|
|
8584
|
+
type: "button",
|
|
8585
|
+
className: "inline-flex cursor-help appearance-none rounded-sm border-0! bg-transparent! p-0! text-inherit!",
|
|
8586
|
+
onClick: () => setTipOpen(true)
|
|
8587
|
+
}
|
|
8588
|
+
)
|
|
8589
|
+
),
|
|
8579
8590
|
children: /* @__PURE__ */ jsx(Info, { className: "size-4 text-foreground/45" })
|
|
8580
8591
|
}
|
|
8581
8592
|
),
|
|
@@ -13922,6 +13933,118 @@ function useFluentSwapQuote({
|
|
|
13922
13933
|
error: ready && query.error && !noRoute ? query.error.message : void 0
|
|
13923
13934
|
};
|
|
13924
13935
|
}
|
|
13936
|
+
var ORDER_DEPOSIT_MIN_TOKENS = "2";
|
|
13937
|
+
function getOrderDepositMinimum(decimals) {
|
|
13938
|
+
return parseUnits(ORDER_DEPOSIT_MIN_TOKENS, decimals);
|
|
13939
|
+
}
|
|
13940
|
+
function readOrderDepositApproval(payload) {
|
|
13941
|
+
try {
|
|
13942
|
+
const decoded = decodeFunctionData({ abi: erc20Abi, data: payload.data });
|
|
13943
|
+
if (decoded.functionName !== "approve") return void 0;
|
|
13944
|
+
const [spender, amount] = decoded.args;
|
|
13945
|
+
return { token: payload.to, spender, amount };
|
|
13946
|
+
} catch {
|
|
13947
|
+
return void 0;
|
|
13948
|
+
}
|
|
13949
|
+
}
|
|
13950
|
+
function hasAddressWord(data, address) {
|
|
13951
|
+
const wanted = padHex(address, { size: 32 }).slice(2).toLowerCase();
|
|
13952
|
+
const words = data.slice(10).toLowerCase();
|
|
13953
|
+
for (let offset = 0; offset + 64 <= words.length; offset += 64) {
|
|
13954
|
+
if (words.slice(offset, offset + 64) === wanted) return true;
|
|
13955
|
+
}
|
|
13956
|
+
return false;
|
|
13957
|
+
}
|
|
13958
|
+
function findOrderDepositQuoteFault({
|
|
13959
|
+
quote,
|
|
13960
|
+
sourceChainId,
|
|
13961
|
+
tokenIn,
|
|
13962
|
+
amountIn,
|
|
13963
|
+
recipient
|
|
13964
|
+
}) {
|
|
13965
|
+
if (quote.amountIn !== amountIn) return "it is for another amount";
|
|
13966
|
+
if (quote.amountOut <= 0n) return "it delivers nothing";
|
|
13967
|
+
if (quote.payloads.some((payload) => payload.chainId !== sourceChainId)) {
|
|
13968
|
+
return "it has a transaction on another chain";
|
|
13969
|
+
}
|
|
13970
|
+
if (quote.payloads.some((payload) => payload.value !== 0n)) return "it spends ETH";
|
|
13971
|
+
const order = quote.payloads[quote.payloads.length - 1];
|
|
13972
|
+
const approvals = quote.payloads.slice(0, -1);
|
|
13973
|
+
if (!order || approvals.length > 1) return "it is not an approval and an order";
|
|
13974
|
+
if (readOrderDepositApproval(order) || order.to.toLowerCase() === tokenIn.toLowerCase()) {
|
|
13975
|
+
return "its last transaction is not an order";
|
|
13976
|
+
}
|
|
13977
|
+
if (!hasAddressWord(order.data, recipient)) return "its order does not name the recipient";
|
|
13978
|
+
for (const payload of approvals) {
|
|
13979
|
+
const approval = readOrderDepositApproval(payload);
|
|
13980
|
+
if (!approval) return "its first transaction is not an approval";
|
|
13981
|
+
if (approval.token.toLowerCase() !== tokenIn.toLowerCase()) {
|
|
13982
|
+
return "it approves another token";
|
|
13983
|
+
}
|
|
13984
|
+
if (approval.amount > amountIn) return "it approves more than the amount sent";
|
|
13985
|
+
if (approval.spender.toLowerCase() !== order.to.toLowerCase()) {
|
|
13986
|
+
return "it approves a contract the order does not go to";
|
|
13987
|
+
}
|
|
13988
|
+
}
|
|
13989
|
+
return void 0;
|
|
13990
|
+
}
|
|
13991
|
+
async function sendOrderDeposit({
|
|
13992
|
+
quote,
|
|
13993
|
+
account,
|
|
13994
|
+
signer,
|
|
13995
|
+
onStep
|
|
13996
|
+
}) {
|
|
13997
|
+
const steps = [];
|
|
13998
|
+
for (const payload of quote.payloads) {
|
|
13999
|
+
const approval = readOrderDepositApproval(payload);
|
|
14000
|
+
if (approval) {
|
|
14001
|
+
const allowance = await signer.readAllowance(approval.token, account, approval.spender).catch(() => void 0);
|
|
14002
|
+
if (allowance !== void 0 && allowance >= approval.amount) continue;
|
|
14003
|
+
}
|
|
14004
|
+
steps.push({ payload, approval: Boolean(approval) });
|
|
14005
|
+
}
|
|
14006
|
+
let hash;
|
|
14007
|
+
for (const [index, step] of steps.entries()) {
|
|
14008
|
+
onStep?.(step.approval ? "approval" : "order");
|
|
14009
|
+
hash = await signer.sendTransaction(step.payload);
|
|
14010
|
+
if (index === steps.length - 1) break;
|
|
14011
|
+
if (await signer.waitForReceipt(hash) !== "success") {
|
|
14012
|
+
throw new Error("The approval transaction reverted");
|
|
14013
|
+
}
|
|
14014
|
+
}
|
|
14015
|
+
if (!hash) throw new Error("The quote has no transaction to sign");
|
|
14016
|
+
return hash;
|
|
14017
|
+
}
|
|
14018
|
+
var ORDER_DEPOSIT_ORDER_GAS = 250000n;
|
|
14019
|
+
async function estimateOrderDepositGas({
|
|
14020
|
+
quote,
|
|
14021
|
+
account,
|
|
14022
|
+
allowance,
|
|
14023
|
+
estimateGas
|
|
14024
|
+
}) {
|
|
14025
|
+
let total = 0n;
|
|
14026
|
+
for (const payload of quote.payloads) {
|
|
14027
|
+
const approval = readOrderDepositApproval(payload);
|
|
14028
|
+
if (approval) {
|
|
14029
|
+
if (allowance !== void 0 && allowance >= approval.amount) continue;
|
|
14030
|
+
total += await estimateGas({ ...payload, account });
|
|
14031
|
+
continue;
|
|
14032
|
+
}
|
|
14033
|
+
total += await estimateGas({ ...payload, account }).catch(() => ORDER_DEPOSIT_ORDER_GAS);
|
|
14034
|
+
}
|
|
14035
|
+
return total;
|
|
14036
|
+
}
|
|
14037
|
+
function getOrderDepositFeeShare(quote) {
|
|
14038
|
+
if (quote.amountIn <= 0n || quote.amountOut > quote.amountIn) return void 0;
|
|
14039
|
+
const bps = (quote.amountIn - quote.amountOut) * 10000n / quote.amountIn;
|
|
14040
|
+
return Number(bps) / 1e4;
|
|
14041
|
+
}
|
|
14042
|
+
var ORDER_DEPOSIT_FEE_SHARE_WARNING = 0.05;
|
|
14043
|
+
function formatFeeShare(share) {
|
|
14044
|
+
const percent = share * 100;
|
|
14045
|
+
const rounded = Math.round(percent * 10) / 10;
|
|
14046
|
+
return `${Number.isInteger(rounded) ? rounded.toFixed(0) : rounded.toFixed(1)}%`;
|
|
14047
|
+
}
|
|
13925
14048
|
|
|
13926
14049
|
// src/bridge/abi.ts
|
|
13927
14050
|
var nativeGatewayAbi = [
|
|
@@ -14052,6 +14175,42 @@ var swapFacilityAbi = [
|
|
|
14052
14175
|
]
|
|
14053
14176
|
}
|
|
14054
14177
|
];
|
|
14178
|
+
function describeDepositError({
|
|
14179
|
+
error,
|
|
14180
|
+
chainName,
|
|
14181
|
+
fallback: fallback2
|
|
14182
|
+
}) {
|
|
14183
|
+
if (isInsufficientFunds(error)) {
|
|
14184
|
+
return `Not enough ETH on ${chainName} to pay the network fee. Add ETH to your wallet, or let the wallet pay gas another way, and try again.`;
|
|
14185
|
+
}
|
|
14186
|
+
if (error instanceof BaseError) return error.shortMessage;
|
|
14187
|
+
if (error instanceof Error) return error.message;
|
|
14188
|
+
return fallback2;
|
|
14189
|
+
}
|
|
14190
|
+
var INSUFFICIENT_FUNDS_TEXTS = ["insufficient funds", "exceeds the balance of the account"];
|
|
14191
|
+
function isInsufficientFunds(error) {
|
|
14192
|
+
return errorTexts(error).some((text) => {
|
|
14193
|
+
const lowered = text.toLowerCase();
|
|
14194
|
+
return INSUFFICIENT_FUNDS_TEXTS.some((needle) => lowered.includes(needle));
|
|
14195
|
+
});
|
|
14196
|
+
}
|
|
14197
|
+
function errorTexts(error) {
|
|
14198
|
+
const texts = [];
|
|
14199
|
+
let current = error;
|
|
14200
|
+
for (let depth = 0; depth < 10 && current !== void 0 && current !== null; depth += 1) {
|
|
14201
|
+
if (current instanceof BaseError) {
|
|
14202
|
+
texts.push(current.shortMessage, current.details, ...current.metaMessages ?? []);
|
|
14203
|
+
}
|
|
14204
|
+
if (current instanceof Error) {
|
|
14205
|
+
texts.push(current.message);
|
|
14206
|
+
current = current.cause;
|
|
14207
|
+
continue;
|
|
14208
|
+
}
|
|
14209
|
+
if (typeof current === "string") texts.push(current);
|
|
14210
|
+
break;
|
|
14211
|
+
}
|
|
14212
|
+
return texts.filter((text) => typeof text === "string" && text.length > 0);
|
|
14213
|
+
}
|
|
14055
14214
|
|
|
14056
14215
|
// src/bridge/fastPathFee.ts
|
|
14057
14216
|
var TOKEN_PAYLOAD_TYPE = 0;
|
|
@@ -14090,88 +14249,6 @@ async function readFastPathFeeWei(client2, portal, destinationChainId) {
|
|
|
14090
14249
|
throw error;
|
|
14091
14250
|
}
|
|
14092
14251
|
}
|
|
14093
|
-
var ORDER_DEPOSIT_MIN_TOKENS = "2";
|
|
14094
|
-
function getOrderDepositMinimum(decimals) {
|
|
14095
|
-
return parseUnits(ORDER_DEPOSIT_MIN_TOKENS, decimals);
|
|
14096
|
-
}
|
|
14097
|
-
function readOrderDepositApproval(payload) {
|
|
14098
|
-
try {
|
|
14099
|
-
const decoded = decodeFunctionData({ abi: erc20Abi, data: payload.data });
|
|
14100
|
-
if (decoded.functionName !== "approve") return void 0;
|
|
14101
|
-
const [spender, amount] = decoded.args;
|
|
14102
|
-
return { token: payload.to, spender, amount };
|
|
14103
|
-
} catch {
|
|
14104
|
-
return void 0;
|
|
14105
|
-
}
|
|
14106
|
-
}
|
|
14107
|
-
function hasAddressWord(data, address) {
|
|
14108
|
-
const wanted = padHex(address, { size: 32 }).slice(2).toLowerCase();
|
|
14109
|
-
const words = data.slice(10).toLowerCase();
|
|
14110
|
-
for (let offset = 0; offset + 64 <= words.length; offset += 64) {
|
|
14111
|
-
if (words.slice(offset, offset + 64) === wanted) return true;
|
|
14112
|
-
}
|
|
14113
|
-
return false;
|
|
14114
|
-
}
|
|
14115
|
-
function findOrderDepositQuoteFault({
|
|
14116
|
-
quote,
|
|
14117
|
-
sourceChainId,
|
|
14118
|
-
tokenIn,
|
|
14119
|
-
amountIn,
|
|
14120
|
-
recipient
|
|
14121
|
-
}) {
|
|
14122
|
-
if (quote.amountIn !== amountIn) return "it is for another amount";
|
|
14123
|
-
if (quote.amountOut <= 0n) return "it delivers nothing";
|
|
14124
|
-
if (quote.payloads.some((payload) => payload.chainId !== sourceChainId)) {
|
|
14125
|
-
return "it has a transaction on another chain";
|
|
14126
|
-
}
|
|
14127
|
-
if (quote.payloads.some((payload) => payload.value !== 0n)) return "it spends ETH";
|
|
14128
|
-
const order = quote.payloads[quote.payloads.length - 1];
|
|
14129
|
-
const approvals = quote.payloads.slice(0, -1);
|
|
14130
|
-
if (!order || approvals.length > 1) return "it is not an approval and an order";
|
|
14131
|
-
if (readOrderDepositApproval(order) || order.to.toLowerCase() === tokenIn.toLowerCase()) {
|
|
14132
|
-
return "its last transaction is not an order";
|
|
14133
|
-
}
|
|
14134
|
-
if (!hasAddressWord(order.data, recipient)) return "its order does not name the recipient";
|
|
14135
|
-
for (const payload of approvals) {
|
|
14136
|
-
const approval = readOrderDepositApproval(payload);
|
|
14137
|
-
if (!approval) return "its first transaction is not an approval";
|
|
14138
|
-
if (approval.token.toLowerCase() !== tokenIn.toLowerCase()) {
|
|
14139
|
-
return "it approves another token";
|
|
14140
|
-
}
|
|
14141
|
-
if (approval.amount > amountIn) return "it approves more than the amount sent";
|
|
14142
|
-
if (approval.spender.toLowerCase() !== order.to.toLowerCase()) {
|
|
14143
|
-
return "it approves a contract the order does not go to";
|
|
14144
|
-
}
|
|
14145
|
-
}
|
|
14146
|
-
return void 0;
|
|
14147
|
-
}
|
|
14148
|
-
async function sendOrderDeposit({
|
|
14149
|
-
quote,
|
|
14150
|
-
account,
|
|
14151
|
-
signer,
|
|
14152
|
-
onStep
|
|
14153
|
-
}) {
|
|
14154
|
-
const steps = [];
|
|
14155
|
-
for (const payload of quote.payloads) {
|
|
14156
|
-
const approval = readOrderDepositApproval(payload);
|
|
14157
|
-
if (approval) {
|
|
14158
|
-
const allowance = await signer.readAllowance(approval.token, account, approval.spender).catch(() => void 0);
|
|
14159
|
-
if (allowance !== void 0 && allowance >= approval.amount) continue;
|
|
14160
|
-
}
|
|
14161
|
-
steps.push({ payload, approval: Boolean(approval) });
|
|
14162
|
-
}
|
|
14163
|
-
let hash;
|
|
14164
|
-
for (const [index, step] of steps.entries()) {
|
|
14165
|
-
onStep?.(step.approval ? "approval" : "order");
|
|
14166
|
-
hash = await signer.sendTransaction(step.payload);
|
|
14167
|
-
if (index === steps.length - 1) break;
|
|
14168
|
-
if (await signer.waitForReceipt(hash) !== "success") {
|
|
14169
|
-
throw new Error("The approval transaction reverted");
|
|
14170
|
-
}
|
|
14171
|
-
}
|
|
14172
|
-
if (!hash) throw new Error("The quote has no transaction to sign");
|
|
14173
|
-
return hash;
|
|
14174
|
-
}
|
|
14175
14252
|
var ORDER_DEPOSIT_PREVIEW_ACCOUNT = "0x000000000000000000000000000000000000dEaD";
|
|
14176
14253
|
var ORDER_DEPOSIT_PROBE_TOKENS = "100";
|
|
14177
14254
|
var ORDER_DEPOSIT_PROBE_STALE_MS = 5 * 6e4;
|
|
@@ -14547,7 +14624,10 @@ function useBridgeDeposit({
|
|
|
14547
14624
|
address,
|
|
14548
14625
|
recipient,
|
|
14549
14626
|
amountWei?.toString(),
|
|
14550
|
-
fee?.toString()
|
|
14627
|
+
fee?.toString(),
|
|
14628
|
+
isOrder,
|
|
14629
|
+
orderQuote.quote?.payloads.map((payload) => payload.data).join(),
|
|
14630
|
+
allowance?.toString()
|
|
14551
14631
|
],
|
|
14552
14632
|
queryFn: async () => {
|
|
14553
14633
|
const missing = (name) => {
|
|
@@ -14558,7 +14638,17 @@ function useBridgeDeposit({
|
|
|
14558
14638
|
const to = recipient ?? missing("recipient");
|
|
14559
14639
|
const amount2 = amountWei ?? missing("amountWei");
|
|
14560
14640
|
const value = fee ?? missing("fee");
|
|
14561
|
-
const gas =
|
|
14641
|
+
const gas = isOrder ? await estimateOrderDepositGas({
|
|
14642
|
+
quote: orderQuote.quote ?? missing("orderQuote"),
|
|
14643
|
+
account,
|
|
14644
|
+
allowance,
|
|
14645
|
+
estimateGas: (payload) => client2.estimateGas({
|
|
14646
|
+
account: payload.account,
|
|
14647
|
+
to: payload.to,
|
|
14648
|
+
data: payload.data,
|
|
14649
|
+
value: payload.value
|
|
14650
|
+
})
|
|
14651
|
+
}) : deliveredToken.route === "native" ? await client2.estimateContractGas({
|
|
14562
14652
|
account,
|
|
14563
14653
|
address: route.nativeGateway,
|
|
14564
14654
|
abi: nativeGatewayAbi,
|
|
@@ -14591,11 +14681,12 @@ function useBridgeDeposit({
|
|
|
14591
14681
|
return gas * await client2.getGasPrice();
|
|
14592
14682
|
},
|
|
14593
14683
|
enabled: Boolean(
|
|
14594
|
-
publicClient && address && recipient && amountWei !== void 0 && fee !== void 0 && !isSwap && !needsApproval
|
|
14684
|
+
publicClient && address && recipient && amountWei !== void 0 && fee !== void 0 && (isOrder ? Boolean(orderQuote.quote) : !isSwap && !needsApproval)
|
|
14595
14685
|
),
|
|
14596
14686
|
staleTime: 15e3,
|
|
14597
14687
|
retry: false
|
|
14598
14688
|
});
|
|
14689
|
+
const gasFeeShort = isConnected && !wrongChain && ethBalance !== void 0 && gasEstimate.data !== void 0 && ethBalance.value < gasEstimate.data;
|
|
14599
14690
|
const setMax = useCallback(() => {
|
|
14600
14691
|
if (spendable === void 0 || spendable === 0n) return;
|
|
14601
14692
|
setAmount(formatUnits(spendable, token.decimals));
|
|
@@ -14614,23 +14705,26 @@ function useBridgeDeposit({
|
|
|
14614
14705
|
setState({ phase: "idle", slow: false });
|
|
14615
14706
|
setAmount("");
|
|
14616
14707
|
}, []);
|
|
14617
|
-
const fail = useCallback(
|
|
14618
|
-
|
|
14619
|
-
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14708
|
+
const fail = useCallback(
|
|
14709
|
+
(error, fallback2) => {
|
|
14710
|
+
if (isUserRejection(error)) {
|
|
14711
|
+
setState({ phase: "idle", slow: false });
|
|
14712
|
+
toast.add({
|
|
14713
|
+
type: "info",
|
|
14714
|
+
title: "Transaction cancelled",
|
|
14715
|
+
description: "Nothing was sent from your wallet."
|
|
14716
|
+
});
|
|
14717
|
+
return;
|
|
14718
|
+
}
|
|
14719
|
+
debugError("[FluentBridge] deposit failed", error);
|
|
14720
|
+
setState({
|
|
14721
|
+
phase: "error",
|
|
14722
|
+
slow: false,
|
|
14723
|
+
message: describeDepositError({ error, chainName: route.source.name, fallback: fallback2 })
|
|
14624
14724
|
});
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
setState({
|
|
14629
|
-
phase: "error",
|
|
14630
|
-
slow: false,
|
|
14631
|
-
message: error instanceof Error ? error.message : fallback2
|
|
14632
|
-
});
|
|
14633
|
-
}, []);
|
|
14725
|
+
},
|
|
14726
|
+
[route.source.name]
|
|
14727
|
+
);
|
|
14634
14728
|
const approve = useCallback(() => {
|
|
14635
14729
|
if (!address || !publicClient || amountWei === void 0) return;
|
|
14636
14730
|
if (isSwap || !isErc20 || !token.l1Address || !bridgeSpender) return;
|
|
@@ -15056,6 +15150,7 @@ function useBridgeDeposit({
|
|
|
15056
15150
|
order: isOrder ? {
|
|
15057
15151
|
quoteLoading: orderQuote.loading,
|
|
15058
15152
|
solverFee: orderQuote.quote && token.decimals === deliveredToken.decimals && orderQuote.quote.amountIn >= orderQuote.quote.amountOut ? orderQuote.quote.amountIn - orderQuote.quote.amountOut : void 0,
|
|
15153
|
+
solverFeeShare: orderQuote.quote && token.decimals === deliveredToken.decimals ? getOrderDepositFeeShare(orderQuote.quote) : void 0,
|
|
15059
15154
|
fillSeconds: orderQuote.quote?.fillSeconds
|
|
15060
15155
|
} : void 0,
|
|
15061
15156
|
wrongChain,
|
|
@@ -15078,6 +15173,8 @@ function useBridgeDeposit({
|
|
|
15078
15173
|
fee,
|
|
15079
15174
|
gasFee: gasEstimate.data,
|
|
15080
15175
|
gasFeeLoading: gasEstimate.isLoading,
|
|
15176
|
+
gasFeeShort,
|
|
15177
|
+
ethBalance: ethBalance?.value,
|
|
15081
15178
|
needsApproval,
|
|
15082
15179
|
approve,
|
|
15083
15180
|
approving,
|
|
@@ -15114,6 +15211,12 @@ function formatFeeUsd(wei, usdPrice) {
|
|
|
15114
15211
|
}
|
|
15115
15212
|
var SLIPPAGE_LABEL = `${Number(FLUENT_SWAP_SLIPPAGE_BPS) / 100}%`;
|
|
15116
15213
|
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({ children }) {
|
|
15215
|
+
return /* @__PURE__ */ jsxs("p", { className: "flex gap-2 rounded-xl bg-amber-400/10 p-3 text-xs text-amber-300", role: "status", children: [
|
|
15216
|
+
/* @__PURE__ */ jsx(AlertTriangle, { className: "mt-0.5 size-4 shrink-0" }),
|
|
15217
|
+
/* @__PURE__ */ jsx("span", { children })
|
|
15218
|
+
] });
|
|
15219
|
+
}
|
|
15117
15220
|
function TokenChip({ symbol }) {
|
|
15118
15221
|
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: [
|
|
15119
15222
|
/* @__PURE__ */ jsx(TokenChainIcon, { symbol, chain: "destination" }),
|
|
@@ -15167,6 +15270,7 @@ function StatusView({
|
|
|
15167
15270
|
route,
|
|
15168
15271
|
bridge,
|
|
15169
15272
|
onOpenPortal,
|
|
15273
|
+
onGoHome,
|
|
15170
15274
|
swap
|
|
15171
15275
|
}) {
|
|
15172
15276
|
const { state, token, deliveredToken } = bridge;
|
|
@@ -15202,7 +15306,17 @@ function StatusView({
|
|
|
15202
15306
|
"\u2026"
|
|
15203
15307
|
] }) : null,
|
|
15204
15308
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-2", children: [
|
|
15205
|
-
settled ? /* @__PURE__ */ jsx(Button, { className: "w-full", onClick:
|
|
15309
|
+
settled && onGoHome ? /* @__PURE__ */ jsx(Button, { className: "w-full", onClick: onGoHome, children: "Back to wallet" }) : null,
|
|
15310
|
+
settled ? /* @__PURE__ */ jsx(
|
|
15311
|
+
Button,
|
|
15312
|
+
{
|
|
15313
|
+
variant: onGoHome ? "ghost" : "default",
|
|
15314
|
+
className: "w-full",
|
|
15315
|
+
onClick: bridge.reset,
|
|
15316
|
+
children: "Make another deposit"
|
|
15317
|
+
}
|
|
15318
|
+
) : null,
|
|
15319
|
+
state.phase === "relaying" && onGoHome ? /* @__PURE__ */ jsx(Button, { variant: "ghost", className: "w-full", onClick: onGoHome, children: "Back to wallet" }) : null,
|
|
15206
15320
|
state.phase === "relaying" && state.slow ? /* @__PURE__ */ jsx(Button, { variant: "ghost", className: "w-full", onClick: onOpenPortal, children: "Check status on Fluent Portal" }) : null,
|
|
15207
15321
|
explorerLink ? /* @__PURE__ */ jsxs(
|
|
15208
15322
|
Button,
|
|
@@ -15431,6 +15545,7 @@ function BridgeForm({
|
|
|
15431
15545
|
route,
|
|
15432
15546
|
bridge,
|
|
15433
15547
|
onOpenPortal,
|
|
15548
|
+
onGoHome,
|
|
15434
15549
|
swap: twoStep && swapTarget ? { target: swapTarget.symbol } : void 0
|
|
15435
15550
|
}
|
|
15436
15551
|
);
|
|
@@ -15591,7 +15706,8 @@ function BridgeForm({
|
|
|
15591
15706
|
{
|
|
15592
15707
|
label: "Network fee",
|
|
15593
15708
|
value: formatFee(bridge.gasFee, ethSymbol, bridge.gasFeeLoading),
|
|
15594
|
-
secondary: formatFeeUsd(bridge.gasFee, ethUsdPrice)
|
|
15709
|
+
secondary: formatFeeUsd(bridge.gasFee, ethUsdPrice),
|
|
15710
|
+
tooltip: bridge.order ? `What ${route.source.name} charges to sign the approval and the order at the current gas price, paid in ${ethSymbol}. A wallet that pays gas with a token adds its own charge on top.` : void 0
|
|
15595
15711
|
}
|
|
15596
15712
|
),
|
|
15597
15713
|
bridge.fee !== void 0 && bridge.fee > 0n ? /* @__PURE__ */ jsx(
|
|
@@ -15610,7 +15726,8 @@ function BridgeForm({
|
|
|
15610
15726
|
{
|
|
15611
15727
|
label: "Solver fee",
|
|
15612
15728
|
value: `${formatAmount(bridge.order.solverFee, token.decimals, token.symbol)} ` + token.symbol,
|
|
15613
|
-
|
|
15729
|
+
secondary: bridge.order.solverFeeShare !== void 0 ? `${formatFeeShare(bridge.order.solverFeeShare)} of the amount` : void 0,
|
|
15730
|
+
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."
|
|
15614
15731
|
}
|
|
15615
15732
|
) : null
|
|
15616
15733
|
) : /* @__PURE__ */ jsx(
|
|
@@ -15654,6 +15771,8 @@ function BridgeForm({
|
|
|
15654
15771
|
] }) : null,
|
|
15655
15772
|
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
|
|
15656
15773
|
] }) }),
|
|
15774
|
+
bridge.order?.solverFeeShare !== void 0 && bridge.order.solverFeeShare > ORDER_DEPOSIT_FEE_SHARE_WARNING ? /* @__PURE__ */ jsx(Notice2, { children: `The solver fee takes ${formatFeeShare(bridge.order.solverFeeShare)} of this deposit. A larger deposit pays the same fee.` }) : null,
|
|
15775
|
+
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,
|
|
15657
15776
|
state.phase === "error" ? /* @__PURE__ */ jsx("span", { className: "text-xs text-destructive", children: state.message }) : null,
|
|
15658
15777
|
bridge.restoring ? /* @__PURE__ */ jsxs(Button, { className: "w-full", disabled: true, children: [
|
|
15659
15778
|
/* @__PURE__ */ jsx(Spinner, { className: "size-4" }),
|
|
@@ -17039,13 +17158,13 @@ var FLUENT_FEE_REJECTION_MESSAGES = [
|
|
|
17039
17158
|
];
|
|
17040
17159
|
function isFluentFeeRejection(err) {
|
|
17041
17160
|
const needles = FLUENT_FEE_REJECTION_MESSAGES.map((message2) => message2.toLowerCase());
|
|
17042
|
-
for (const text of
|
|
17161
|
+
for (const text of errorTexts2(err)) {
|
|
17043
17162
|
const lowered = text.toLowerCase();
|
|
17044
17163
|
if (needles.some((needle) => lowered.includes(needle))) return true;
|
|
17045
17164
|
}
|
|
17046
17165
|
return false;
|
|
17047
17166
|
}
|
|
17048
|
-
function
|
|
17167
|
+
function errorTexts2(err) {
|
|
17049
17168
|
const texts = [];
|
|
17050
17169
|
let current = err;
|
|
17051
17170
|
for (let depth = 0; depth < 10 && current !== void 0 && current !== null; depth += 1) {
|