@velora-dex/widget 0.7.0 → 0.7.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/components/ui/tooltip.js +1 -1
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/components/widget/AppHeader/AppHeader.d.ts.map +1 -1
- package/dist/components/widget/AppHeader/AppHeader.js +45 -41
- package/dist/components/widget/AppHeader/AppHeader.js.map +1 -1
- package/dist/components/widget/AppHeader/TradeModeSwitcher.d.ts +3 -1
- package/dist/components/widget/AppHeader/TradeModeSwitcher.d.ts.map +1 -1
- package/dist/components/widget/AppHeader/TradeModeSwitcher.js +69 -34
- package/dist/components/widget/AppHeader/TradeModeSwitcher.js.map +1 -1
- package/dist/components/widget/SwapRate/SwapRate.d.ts +2 -1
- package/dist/components/widget/SwapRate/SwapRate.d.ts.map +1 -1
- package/dist/components/widget/SwapRate/SwapRate.js +25 -37
- package/dist/components/widget/SwapRate/SwapRate.js.map +1 -1
- package/dist/components/widget/SwapRate/SwapRateWithTooltip.d.ts +3 -0
- package/dist/components/widget/SwapRate/SwapRateWithTooltip.d.ts.map +1 -0
- package/dist/components/widget/SwapRate/SwapRateWithTooltip.js +42 -0
- package/dist/components/widget/SwapRate/SwapRateWithTooltip.js.map +1 -0
- package/dist/components/widget/SwapRate/utils.d.ts +3 -0
- package/dist/components/widget/SwapRate/utils.d.ts.map +1 -0
- package/dist/components/widget/SwapRate/utils.js +26 -0
- package/dist/components/widget/SwapRate/utils.js.map +1 -0
- package/dist/components/widget/SwapRateWithPriceImpactRow/SwapRateWithPriceImpactRow.d.ts.map +1 -1
- package/dist/components/widget/SwapRateWithPriceImpactRow/SwapRateWithPriceImpactRow.js +20 -27
- package/dist/components/widget/SwapRateWithPriceImpactRow/SwapRateWithPriceImpactRow.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +134 -131
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.d.ts +2 -2
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +8 -2
- package/dist/core/logger.js.map +1 -1
- package/dist/core/screen/hooks/useRunOnMount.d.ts +10 -0
- package/dist/core/screen/hooks/useRunOnMount.d.ts.map +1 -1
- package/dist/core/screen/hooks/useRunOnMount.js +6 -1
- package/dist/core/screen/hooks/useRunOnMount.js.map +1 -1
- package/dist/core/state/configActionsAtom.d.ts.map +1 -1
- package/dist/core/state/configActionsAtom.js +8 -8
- package/dist/core/state/configActionsAtom.js.map +1 -1
- package/dist/core/state/configAtom.d.ts +4 -2
- package/dist/core/state/configAtom.d.ts.map +1 -1
- package/dist/core/state/configAtom.js +7 -4
- package/dist/core/state/configAtom.js.map +1 -1
- package/dist/core/state/validatedReferrerConfigAtom.d.ts +3 -0
- package/dist/core/state/validatedReferrerConfigAtom.d.ts.map +1 -0
- package/dist/core/state/validatedReferrerConfigAtom.js +12 -0
- package/dist/core/state/validatedReferrerConfigAtom.js.map +1 -0
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js +203 -201
- package/dist/hooks/swap/tradeFlow/useDeltaFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js +85 -82
- package/dist/hooks/swap/tradeFlow/useLimitOrderFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js +156 -154
- package/dist/hooks/swap/tradeFlow/useMarketFlow.js.map +1 -1
- package/dist/hooks/swap/tradeFlow/useTwapFlow.d.ts.map +1 -1
- package/dist/hooks/swap/tradeFlow/useTwapFlow.js +230 -228
- package/dist/hooks/swap/tradeFlow/useTwapFlow.js.map +1 -1
- package/dist/hooks/useReferrer.d.ts +2 -0
- package/dist/hooks/useReferrer.d.ts.map +1 -0
- package/dist/hooks/useReferrer.js +8 -0
- package/dist/hooks/useReferrer.js.map +1 -0
- package/dist/lib/utils/logger.d.ts +7 -4
- package/dist/lib/utils/logger.d.ts.map +1 -1
- package/dist/lib/utils/logger.js +70 -33
- package/dist/lib/utils/logger.js.map +1 -1
- package/dist/lib/web3/privy/config.js +1 -1
- package/dist/lib/web3/privy/config.js.map +1 -1
- package/dist/lib/web3/wagmi/config.js +1 -1
- package/dist/lib/web3/wagmi/config.js.map +1 -1
- package/dist/lib/web3/wagmi/isInsideSafeIframe.js +11 -11
- package/dist/lib/web3/wagmi/isInsideSafeIframe.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/tokens/utils/transferAmountsFromReceipt.js +14 -14
- package/dist/tokens/utils/transferAmountsFromReceipt.js.map +1 -1
- package/dist/transactions/queries/ensureTxReceipt.js +8 -8
- package/dist/transactions/queries/ensureTxReceipt.js.map +1 -1
- package/package.json +7 -7
|
@@ -39,7 +39,7 @@ function l(t) {
|
|
|
39
39
|
let f = d === void 0 ? 0 : d, p;
|
|
40
40
|
o[6] === c ? p = o[7] : (p = e("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs max-w-[300px]", c), o[6] = c, o[7] = p);
|
|
41
41
|
let m;
|
|
42
|
-
o[8] === Symbol.for("react.memo_cache_sentinel") ? (m = /* @__PURE__ */ r(a.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50
|
|
42
|
+
o[8] === Symbol.for("react.memo_cache_sentinel") ? (m = /* @__PURE__ */ r(a.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]" }), o[8] = m) : m = o[8];
|
|
43
43
|
let h;
|
|
44
44
|
o[9] !== s || o[10] !== u || o[11] !== f || o[12] !== p ? (h = /* @__PURE__ */ i(a.Content, {
|
|
45
45
|
"data-slot": "tooltip-content",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooltip.js","names":["React","TooltipPrimitive","cn","TooltipPortalProps","useContainerAtom","TooltipProvider","t0","$","_c","props","t1","delayDuration","undefined","t2","Tooltip","TooltipTrigger","TooltipContentBase","children","className","container","sideOffset","t3","Symbol","for","t4","t5","TooltipContent"],"sources":["../../../src/components/ui/tooltip.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\n\nimport { cn } from \"@/lib/utils\";\nimport type { TooltipPortalProps } from \"@radix-ui/react-tooltip\";\nimport { useContainerAtom } from \"@/core/state/containerAtom\";\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n );\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n );\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContentBase({\n className,\n sideOffset = 0,\n children,\n container,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content> &\n Pick<TooltipPortalProps, \"container\">) {\n return (\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n className={cn(\n \"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs max-w-[300px]\",\n className\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50
|
|
1
|
+
{"version":3,"file":"tooltip.js","names":["React","TooltipPrimitive","cn","TooltipPortalProps","useContainerAtom","TooltipProvider","t0","$","_c","props","t1","delayDuration","undefined","t2","Tooltip","TooltipTrigger","TooltipContentBase","children","className","container","sideOffset","t3","Symbol","for","t4","t5","TooltipContent"],"sources":["../../../src/components/ui/tooltip.tsx"],"sourcesContent":["import * as React from \"react\";\nimport * as TooltipPrimitive from \"@radix-ui/react-tooltip\";\n\nimport { cn } from \"@/lib/utils\";\nimport type { TooltipPortalProps } from \"@radix-ui/react-tooltip\";\nimport { useContainerAtom } from \"@/core/state/containerAtom\";\n\nfunction TooltipProvider({\n delayDuration = 0,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Provider>) {\n return (\n <TooltipPrimitive.Provider\n data-slot=\"tooltip-provider\"\n delayDuration={delayDuration}\n {...props}\n />\n );\n}\n\nfunction Tooltip({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Root>) {\n return (\n <TooltipProvider>\n <TooltipPrimitive.Root data-slot=\"tooltip\" {...props} />\n </TooltipProvider>\n );\n}\n\nfunction TooltipTrigger({\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Trigger>) {\n return <TooltipPrimitive.Trigger data-slot=\"tooltip-trigger\" {...props} />;\n}\n\nfunction TooltipContentBase({\n className,\n sideOffset = 0,\n children,\n container,\n ...props\n}: React.ComponentProps<typeof TooltipPrimitive.Content> &\n Pick<TooltipPortalProps, \"container\">) {\n return (\n <TooltipPrimitive.Portal container={container}>\n <TooltipPrimitive.Content\n data-slot=\"tooltip-content\"\n sideOffset={sideOffset}\n className={cn(\n \"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs max-w-[300px]\",\n className\n )}\n {...props}\n >\n {children}\n <TooltipPrimitive.Arrow className=\"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]\" />\n </TooltipPrimitive.Content>\n </TooltipPrimitive.Portal>\n );\n}\n\nfunction TooltipContent(\n props: React.ComponentProps<typeof TooltipPrimitive.Content>\n) {\n const container = useContainerAtom();\n return <TooltipContentBase {...props} container={container} />;\n}\n\nexport {\n Tooltip,\n TooltipTrigger,\n TooltipContent,\n TooltipContentBase,\n TooltipProvider,\n};\n"],"mappings":";;;;;;;AAOA,SAAAK,EAAAC,GAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,EAAAC,GAAAC;AAAA,CAAAH,EAAA,OAAAD,KAGyDG,IAAAF,EAAA,IAAAG,IAAAH,EAAA,OAHhC,CAAAI,eAAAD,MAAAD,KAAAH,GAGgCC,EAAA,KAAAD,GAAAC,EAAA,KAAAE,GAAAF,EAAA,KAAAG;CAFvD,IAAAC,IAAAD,MAAAE,KAAAA,IAAA,IAAAF,GAAiBG;AAQb,QARaN,EAAA,OAAAI,KAAAJ,EAAA,OAAAE,KAIfI,IAAA,kBAAA,EAAA,UAAA;EACY,aAAA;EACKF;EAAa,GACxBF;EACJ,CAAA,EAAAF,EAAA,KAAAI,GAAAJ,EAAA,KAAAE,GAAAF,EAAA,KAAAM,KAAAA,IAAA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.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAevD,eAAO,MAAM,SAAS,GAAI,aAAa,WAAW,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"AppHeader.d.ts","sourceRoot":"","sources":["../../../../src/components/widget/AppHeader/AppHeader.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAevD,eAAO,MAAM,SAAS,GAAI,aAAa,WAAW,CAAC,MAAM,CAAC,4CAgEzD,CAAC"}
|
|
@@ -16,7 +16,7 @@ import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
|
16
16
|
import { useAccount as g } from "wagmi";
|
|
17
17
|
//#region src/components/widget/AppHeader/AppHeader.tsx
|
|
18
18
|
var _ = (_) => {
|
|
19
|
-
let v = f(
|
|
19
|
+
let v = f(42), { classes: y } = _, { address: b } = g(), x = a(), [S, C] = p(!1), w;
|
|
20
20
|
v[0] === x ? w = v[1] : (w = {
|
|
21
21
|
drawerId: "trade-parameters-drawer",
|
|
22
22
|
onOpen: x
|
|
@@ -24,58 +24,62 @@ var _ = (_) => {
|
|
|
24
24
|
let T = r(w), E, D;
|
|
25
25
|
v[2] === T ? (E = v[3], D = v[4]) : ({onOpen: D, ...E} = T, v[2] = T, v[3] = E, v[4] = D);
|
|
26
26
|
let O = s(), k = e(n), A;
|
|
27
|
-
v[5] ===
|
|
27
|
+
v[5] === k ? A = v[6] : (A = k.includes("wallet-management"), v[5] = k, v[6] = A);
|
|
28
|
+
let j = A, M;
|
|
29
|
+
v[7] === k ? M = v[8] : (M = k.includes("activities"), v[7] = k, v[8] = M);
|
|
30
|
+
let N = M, P = !j, F = !!b && !N, I = P, L;
|
|
31
|
+
v[9] === D ? L = v[10] : (L = () => {
|
|
28
32
|
C(!1), D();
|
|
29
|
-
}, v[
|
|
30
|
-
let
|
|
31
|
-
v[
|
|
32
|
-
let
|
|
33
|
-
v[
|
|
33
|
+
}, v[9] = D, v[10] = L);
|
|
34
|
+
let R = L, z = S ? "Activate Degen Mode" : "Trading Parameters", B = !S, V;
|
|
35
|
+
v[11] === Symbol.for("react.memo_cache_sentinel") ? (V = () => C(!1), v[11] = V) : V = v[11];
|
|
36
|
+
let H;
|
|
37
|
+
v[12] !== E.onClose || v[13] !== R || v[14] !== S ? (H = /* @__PURE__ */ m(o, {
|
|
34
38
|
onCloseDrawer: E.onClose,
|
|
35
|
-
onOpenDrawer:
|
|
39
|
+
onOpenDrawer: R,
|
|
36
40
|
showDegenConfirmation: S,
|
|
37
41
|
setShowDegenConfirmation: C
|
|
38
|
-
}), v[
|
|
39
|
-
let
|
|
40
|
-
v[
|
|
42
|
+
}), v[12] = E.onClose, v[13] = R, v[14] = S, v[15] = H) : H = v[15];
|
|
43
|
+
let U;
|
|
44
|
+
v[16] !== E || v[17] !== S || v[18] !== z || v[19] !== B || v[20] !== H ? (U = /* @__PURE__ */ m(i, {
|
|
41
45
|
...E,
|
|
42
|
-
title:
|
|
43
|
-
showCloseButton:
|
|
46
|
+
title: z,
|
|
47
|
+
showCloseButton: B,
|
|
44
48
|
showGoBackButton: S,
|
|
45
|
-
onGoBack:
|
|
46
|
-
children:
|
|
47
|
-
}), v[
|
|
48
|
-
let
|
|
49
|
-
v[
|
|
50
|
-
let
|
|
51
|
-
v[
|
|
52
|
-
let
|
|
53
|
-
v[
|
|
54
|
-
let
|
|
55
|
-
v[
|
|
56
|
-
let
|
|
57
|
-
v[
|
|
58
|
-
onClick:
|
|
49
|
+
onGoBack: V,
|
|
50
|
+
children: H
|
|
51
|
+
}), v[16] = E, v[17] = S, v[18] = z, v[19] = B, v[20] = H, v[21] = U) : U = v[21];
|
|
52
|
+
let W = U, G = y?.root, K;
|
|
53
|
+
v[22] === G ? K = v[23] : (K = t("flex items-center justify-between gap-2", G), v[22] = G, v[23] = K);
|
|
54
|
+
let q;
|
|
55
|
+
v[24] === I ? q = v[25] : (q = /* @__PURE__ */ m(u, { asDropdown: I }), v[24] = I, v[25] = q);
|
|
56
|
+
let J;
|
|
57
|
+
v[26] === P ? J = v[27] : (J = P && /* @__PURE__ */ m(c, {}), v[26] = P, v[27] = J);
|
|
58
|
+
let Y;
|
|
59
|
+
v[28] === F ? Y = v[29] : (Y = F && /* @__PURE__ */ m(l, {}), v[28] = F, v[29] = Y);
|
|
60
|
+
let X;
|
|
61
|
+
v[30] !== R || v[31] !== O ? (X = /* @__PURE__ */ m(d, {
|
|
62
|
+
onClick: R,
|
|
59
63
|
showEllipseIcon: O
|
|
60
|
-
}), v[
|
|
61
|
-
let
|
|
62
|
-
v[
|
|
64
|
+
}), v[30] = R, v[31] = O, v[32] = X) : X = v[32];
|
|
65
|
+
let Z;
|
|
66
|
+
v[33] !== J || v[34] !== Y || v[35] !== X ? (Z = /* @__PURE__ */ h("div", {
|
|
63
67
|
className: "flex items-center gap-2",
|
|
64
68
|
children: [
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
J,
|
|
70
|
+
Y,
|
|
71
|
+
X
|
|
68
72
|
]
|
|
69
|
-
}), v[
|
|
70
|
-
let
|
|
71
|
-
return v[
|
|
72
|
-
className:
|
|
73
|
+
}), v[33] = J, v[34] = Y, v[35] = X, v[36] = Z) : Z = v[36];
|
|
74
|
+
let Q;
|
|
75
|
+
return v[37] !== W || v[38] !== K || v[39] !== q || v[40] !== Z ? (Q = /* @__PURE__ */ h("div", {
|
|
76
|
+
className: K,
|
|
73
77
|
children: [
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
q,
|
|
79
|
+
Z,
|
|
80
|
+
W
|
|
77
81
|
]
|
|
78
|
-
}), v[
|
|
82
|
+
}), v[37] = W, v[38] = K, v[39] = q, v[40] = Z, v[41] = Q) : Q = v[41], Q;
|
|
79
83
|
};
|
|
80
84
|
//#endregion
|
|
81
85
|
export { _ as AppHeader };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppHeader.js","names":["useState","WithClasses","cn","useDrawerControls","ControlledDrawer","TradeParameters","useIsNotDefaultAnyParameter","AccountButton","ActivityButton","TradeModeSwitcher","useAccount","useAtomValue","excludeUIAtom","SettingsButton","useResetDraftBridgePreferences","AppHeader","t0","$","_c","classes","address","account","resetDraftBridgePreferences","showDegenConfirmation","setShowDegenConfirmation","t1","drawerId","onOpen","t2","drawerProps","isNotDefaultAnyParameter","excludeUI","t3","
|
|
1
|
+
{"version":3,"file":"AppHeader.js","names":["useState","WithClasses","cn","useDrawerControls","ControlledDrawer","TradeParameters","useIsNotDefaultAnyParameter","AccountButton","ActivityButton","TradeModeSwitcher","useAccount","useAtomValue","excludeUIAtom","SettingsButton","useResetDraftBridgePreferences","AppHeader","t0","$","_c","classes","address","account","resetDraftBridgePreferences","showDegenConfirmation","setShowDegenConfirmation","t1","drawerId","onOpen","t2","drawerProps","isNotDefaultAnyParameter","excludeUI","t3","includes","excludeWalletManagement","t4","excludeActivities","showWalletButton","showActivityButton","tradeModeSwitcherAsDropdown","t5","handleOpen","t6","t7","t8","Symbol","for","t9","onClose","t10","drawer","t11","root","t12","t13","t14","t15","t16","t17","t18"],"sources":["../../../../src/components/widget/AppHeader/AppHeader.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { WithClasses } from \"@/types/withClasses\";\nimport { cn } from \"@/lib/utils\";\nimport { useDrawerControls } from \"../Drawer/state/useDrawerControls\";\nimport { ControlledDrawer } from \"../Drawer\";\nimport { TradeParameters } from \"../TradeParameters/TradeParameters\";\nimport { useIsNotDefaultAnyParameter } from \"../TradeParameters/hooks/useIsNotDefaultAnyParameter\";\nimport { AccountButton } from \"@/components/web3/AccountButton\";\nimport { ActivityButton } from \"./ActivityButton\";\nimport { TradeModeSwitcher } from \"./TradeModeSwitcher\";\nimport { useAccount } from \"wagmi\";\nimport { useAtomValue } from \"@/core/store\";\nimport { excludeUIAtom } from \"@/core/state/configAtom\";\nimport { SettingsButton } from \"../SettingsButton/SettingsButton\";\nimport { useResetDraftBridgePreferences } from \"../TradeParameters/state/bridgePreferences/useBridgePreferences\";\n\nexport const AppHeader = ({ classes }: WithClasses<\"root\">) => {\n const { address: account } = useAccount();\n\n const resetDraftBridgePreferences = useResetDraftBridgePreferences();\n const [showDegenConfirmation, setShowDegenConfirmation] = useState(false);\n\n const { onOpen, ...drawerProps } = useDrawerControls({\n drawerId: \"trade-parameters-drawer\",\n onOpen: resetDraftBridgePreferences,\n });\n const isNotDefaultAnyParameter = useIsNotDefaultAnyParameter();\n const excludeUI = useAtomValue(excludeUIAtom);\n\n const excludeWalletManagement = excludeUI.includes(\"wallet-management\");\n const excludeActivities = excludeUI.includes(\"activities\");\n\n const showWalletButton = !excludeWalletManagement;\n const showActivityButton = !!account && !excludeActivities;\n\n // If wallet management is excluded, we have more space in the header, so we can show the trade mode switcher as a row instead of a dropdown\n // If wallet management is included, we show the trade mode switcher as a dropdown to save space\n // Need to revisit this when adding another trade mode\n const tradeModeSwitcherAsDropdown = showWalletButton;\n\n const handleOpen = () => {\n setShowDegenConfirmation(false);\n onOpen();\n };\n\n const drawer = (\n <ControlledDrawer\n {...drawerProps}\n title={\n showDegenConfirmation ? \"Activate Degen Mode\" : \"Trading Parameters\"\n }\n showCloseButton={!showDegenConfirmation}\n showGoBackButton={showDegenConfirmation}\n onGoBack={() => setShowDegenConfirmation(false)}\n >\n <TradeParameters\n onCloseDrawer={drawerProps.onClose}\n onOpenDrawer={handleOpen}\n showDegenConfirmation={showDegenConfirmation}\n setShowDegenConfirmation={setShowDegenConfirmation}\n />\n </ControlledDrawer>\n );\n\n return (\n <div\n className={cn(\"flex items-center justify-between gap-2\", classes?.root)}\n >\n <TradeModeSwitcher asDropdown={tradeModeSwitcherAsDropdown} />\n <div className=\"flex items-center gap-2\">\n {showWalletButton && <AccountButton />}\n {showActivityButton && <ActivityButton />}\n <SettingsButton\n onClick={handleOpen}\n showEllipseIcon={isNotDefaultAnyParameter}\n />\n </div>\n {drawer}\n </div>\n );\n};\n"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[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TradeModeSwitcher.d.ts","sourceRoot":"","sources":["../../../../src/components/widget/AppHeader/TradeModeSwitcher.tsx"],"names":[],"mappings":"AAoBA,eAAO,MAAM,iBAAiB,GAAI,gBAAgB;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,4CA2BzE,CAAC"}
|
|
@@ -2,51 +2,86 @@ import { useAtomValue as e, useSetAtom as t } from "../../../core/store.js";
|
|
|
2
2
|
import { cn as n } from "../../../lib/utils/index.js";
|
|
3
3
|
import { enabledTradeModesAtom as r } from "../../../core/state/enabledTradeModesAtom.js";
|
|
4
4
|
import { tradeModeAtom as i, userTradeModeAtom as a } from "../../../core/state/tradeModeAtom.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { c } from "
|
|
8
|
-
import {
|
|
5
|
+
import { Button as o } from "../../ui/button.js";
|
|
6
|
+
import { DropdownWithItems as s } from "../Dropdown/DropdownWithItems.js";
|
|
7
|
+
import { ChevronIcon as c } from "../Icon/ChevronIcon.js";
|
|
8
|
+
import { c as l } from "react-compiler-runtime";
|
|
9
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
9
10
|
//#region src/components/widget/AppHeader/TradeModeSwitcher.tsx
|
|
10
|
-
var
|
|
11
|
+
var f = {
|
|
11
12
|
swap: "Swap",
|
|
12
13
|
limit: "Limit",
|
|
13
14
|
otc: "OTC",
|
|
14
15
|
twap: "TWAP"
|
|
15
|
-
},
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
}, p = (n) => {
|
|
17
|
+
let o = l(18), { asDropdown: c } = n, d = t(a), p = e(i), g = e(r), _ = g.length <= 1;
|
|
18
|
+
if (_) {
|
|
19
|
+
let e;
|
|
20
|
+
return o[0] !== _ || o[1] !== p ? (e = /* @__PURE__ */ u(m, {
|
|
21
|
+
tradeMode: p,
|
|
22
|
+
isDisabled: _
|
|
23
|
+
}), o[0] = _, o[1] = p, o[2] = e) : e = o[2], e;
|
|
24
|
+
}
|
|
25
|
+
let v;
|
|
26
|
+
if (o[3] !== g || o[4] !== d || o[5] !== p) {
|
|
27
|
+
let e;
|
|
28
|
+
o[7] !== d || o[8] !== p ? (e = (e) => ({
|
|
29
|
+
label: f[e],
|
|
30
|
+
onSelect: () => d(e),
|
|
31
|
+
selected: p === e
|
|
32
|
+
}), o[7] = d, o[8] = p, o[9] = e) : e = o[9], v = g.map(e), o[3] = g, o[4] = d, o[5] = p, o[6] = v;
|
|
33
|
+
} else v = o[6];
|
|
34
|
+
let y = v;
|
|
35
|
+
if (c) {
|
|
36
|
+
let e;
|
|
37
|
+
o[10] !== _ || o[11] !== p ? (e = /* @__PURE__ */ u(m, {
|
|
38
|
+
tradeMode: p,
|
|
39
|
+
isDisabled: _
|
|
40
|
+
}), o[10] = _, o[11] = p, o[12] = e) : e = o[12];
|
|
41
|
+
let t;
|
|
42
|
+
return o[13] !== y || o[14] !== e ? (t = /* @__PURE__ */ u(s, {
|
|
43
|
+
menuTrigger: e,
|
|
44
|
+
items: y
|
|
45
|
+
}), o[13] = y, o[14] = e, o[15] = t) : t = o[15], t;
|
|
46
|
+
}
|
|
47
|
+
let b;
|
|
48
|
+
return o[16] === y ? b = o[17] : (b = /* @__PURE__ */ u(h, { tradeModeItems: y }), o[16] = y, o[17] = b), b;
|
|
49
|
+
}, m = (e) => {
|
|
50
|
+
let t = l(8), { tradeMode: r, isDisabled: i } = e, a = !i, o;
|
|
51
|
+
t[0] === a ? o = t[1] : (o = n("flex items-center gap-2 font-medium text-contrast-3 dark:text-contrast-8", { "cursor-pointer": a }), t[0] = a, t[1] = o);
|
|
52
|
+
let s = f[r], p;
|
|
53
|
+
t[2] === i ? p = t[3] : (p = !i && /* @__PURE__ */ u(c, {
|
|
20
54
|
width: 8,
|
|
21
55
|
className: "pt-[2px] dark:text-contrast-5"
|
|
22
|
-
}),
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
className:
|
|
56
|
+
}), t[2] = i, t[3] = p);
|
|
57
|
+
let m;
|
|
58
|
+
return t[4] !== o || t[5] !== s || t[6] !== p ? (m = /* @__PURE__ */ d("div", {
|
|
59
|
+
className: o,
|
|
26
60
|
children: [
|
|
27
|
-
|
|
61
|
+
s,
|
|
28
62
|
" ",
|
|
29
|
-
|
|
63
|
+
p
|
|
30
64
|
]
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
selected: m === e
|
|
41
|
-
}), f[12] = p, f[13] = m, f[14] = e) : e = f[14], C = h.map(e), f[8] = h, f[9] = p, f[10] = m, f[11] = C;
|
|
42
|
-
} else C = f[11];
|
|
43
|
-
let w = C, T;
|
|
44
|
-
return f[15] !== w || f[16] !== S ? (T = /* @__PURE__ */ l(o, {
|
|
45
|
-
menuTrigger: S,
|
|
46
|
-
items: w
|
|
47
|
-
}), f[15] = w, f[16] = S, f[17] = T) : T = f[17], T;
|
|
65
|
+
}), t[4] = o, t[5] = s, t[6] = p, t[7] = m) : m = t[7], m;
|
|
66
|
+
}, h = (e) => {
|
|
67
|
+
let t = l(4), { tradeModeItems: n } = e, r;
|
|
68
|
+
t[0] === n ? r = t[1] : (r = n.map(g), t[0] = n, t[1] = r);
|
|
69
|
+
let i;
|
|
70
|
+
return t[2] === r ? i = t[3] : (i = /* @__PURE__ */ u("div", {
|
|
71
|
+
className: "flex items-center gap-6",
|
|
72
|
+
children: r
|
|
73
|
+
}), t[2] = r, t[3] = i), i;
|
|
48
74
|
};
|
|
75
|
+
function g(e) {
|
|
76
|
+
let { selected: t, label: r, onSelect: i } = e;
|
|
77
|
+
return /* @__PURE__ */ u(o, {
|
|
78
|
+
variant: "ghost",
|
|
79
|
+
className: n("cursor-pointer text-contrast-5 font-medium text-base p-0 hover:bg-transparent dark:hover:bg-transparent h-min", { "text-contrast-3 dark:text-contrast-9": t }),
|
|
80
|
+
onClick: i,
|
|
81
|
+
children: r
|
|
82
|
+
}, r);
|
|
83
|
+
}
|
|
49
84
|
//#endregion
|
|
50
|
-
export {
|
|
85
|
+
export { p as TradeModeSwitcher };
|
|
51
86
|
|
|
52
87
|
//# sourceMappingURL=TradeModeSwitcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TradeModeSwitcher.js","names":["tradeModeAtom","userTradeModeAtom","TradeMode","useAtomValue","useSetAtom","DropdownWithItems","ChevronIcon","DropdownItem","enabledTradeModesAtom","cn","tradeModeLabel","Record","swap","limit","otc","twap","TradeModeSwitcher","$","_c","setTradeMode","tradeMode","enabledTradeModes","isDisabled","length","
|
|
1
|
+
{"version":3,"file":"TradeModeSwitcher.js","names":["tradeModeAtom","userTradeModeAtom","TradeMode","useAtomValue","useSetAtom","DropdownWithItems","ChevronIcon","DropdownItem","enabledTradeModesAtom","cn","Button","tradeModeLabel","Record","swap","limit","otc","twap","TradeModeSwitcher","t0","$","_c","asDropdown","setTradeMode","tradeMode","enabledTradeModes","isDisabled","length","t1","t2","mode","label","onSelect","selected","map","items","t3","MenuTrigger","t4","t5","RelaxedDropdownItem","Omit","TradeModesRow","tradeModeItems","_temp"],"sources":["../../../../src/components/widget/AppHeader/TradeModeSwitcher.tsx"],"sourcesContent":["import {\n tradeModeAtom,\n userTradeModeAtom,\n type TradeMode,\n} from \"@/core/state/tradeModeAtom\";\nimport { useAtomValue, useSetAtom } from \"@/core/store\";\nimport { DropdownWithItems } from \"../Dropdown/DropdownWithItems\";\nimport { ChevronIcon } from \"../Icon/ChevronIcon\";\nimport type { DropdownItem } from \"../Dropdown/types\";\nimport { enabledTradeModesAtom } from \"@/core/state/enabledTradeModesAtom\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/components/ui/button\";\n\nconst tradeModeLabel: Record<TradeMode, string> = {\n swap: \"Swap\",\n limit: \"Limit\",\n otc: \"OTC\",\n twap: \"TWAP\",\n};\n\nexport const TradeModeSwitcher = ({ asDropdown }: { asDropdown?: boolean }) => {\n const setTradeMode = useSetAtom(userTradeModeAtom);\n const tradeMode = useAtomValue(tradeModeAtom);\n const enabledTradeModes = useAtomValue(enabledTradeModesAtom);\n const isDisabled = enabledTradeModes.length <= 1;\n\n if (isDisabled)\n return <MenuTrigger tradeMode={tradeMode} isDisabled={isDisabled} />;\n\n const items = enabledTradeModes.map((mode) => ({\n label: tradeModeLabel[mode],\n onSelect: () => setTradeMode(mode),\n selected: tradeMode === mode,\n })) satisfies DropdownItem[];\n\n if (asDropdown) {\n return (\n <DropdownWithItems\n menuTrigger={\n <MenuTrigger tradeMode={tradeMode} isDisabled={isDisabled} />\n }\n items={items}\n />\n );\n }\n\n return <TradeModesRow tradeModeItems={items} />;\n};\n\nconst MenuTrigger = ({\n tradeMode,\n isDisabled,\n}: {\n tradeMode: TradeMode;\n isDisabled: boolean;\n}) => {\n return (\n <div\n className={cn(\n \"flex items-center gap-2 font-medium text-contrast-3 dark:text-contrast-8\",\n {\n \"cursor-pointer\": !isDisabled,\n }\n )}\n >\n {tradeModeLabel[tradeMode]}{\" \"}\n {!isDisabled && (\n <ChevronIcon width={8} className=\"pt-[2px] dark:text-contrast-5\" />\n )}\n </div>\n );\n};\n\ntype RelaxedDropdownItem = Omit<DropdownItem, \"label\" | \"onSelect\"> & {\n label: string; // allows to pass key={label}\n onSelect: () => void; // allows to pass onClick={onSelect}\n};\n\nconst TradeModesRow = ({\n tradeModeItems,\n}: {\n tradeModeItems: RelaxedDropdownItem[];\n}) => {\n return (\n <div className=\"flex items-center gap-6\">\n {tradeModeItems.map(({ selected, label, onSelect }) => (\n <Button\n variant=\"ghost\"\n key={label}\n className={cn(\n \"cursor-pointer text-contrast-5 font-medium text-base p-0 hover:bg-transparent dark:hover:bg-transparent h-min\",\n { \"text-contrast-3 dark:text-contrast-9\": selected }\n )}\n onClick={onSelect}\n >\n {label}\n </Button>\n ))}\n </div>\n );\n};\n"],"mappings":";;;;;;;;;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,IAAAR,EAAA,MAZDQ,IAAAe,EAAcT,IAAKU,EAYlB,EAAAxB,EAAA,KAAAuB,GAAAvB,EAAA,KAAAQ;CAAA,IAAAC;AACE,QADFT,EAAA,OAAAQ,IACEC,IAAAT,EAAA,MAdNS,IAAA,kBAAA,OAAA;EAAe,WAAA;YACZD;EAaG,CAAA,EAAAR,EAAA,KAAAQ,GAAAR,EAAA,KAAAS,IAdNA;;AANkB,SAAAe,EAAAzB,GAAA;CAOK,IAAA,EAAAc,aAAAF,UAAAC,gBAAAb;AAA6B,QAChD,kBAAC,GAAD;EACU,SAAA;EAEG,WAAAT,EACT,iHACA,EAAA,wCAA0CuB,GAC5C,CAAA;EACSD,SAAAA;YAERD;EACM,EARFA,EAQE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { SwapRateProps } from './types';
|
|
2
|
-
|
|
2
|
+
import { JSX } from 'react';
|
|
3
|
+
export declare const SwapRate: ({ isLoading, ...props }: SwapRateProps) => JSX.Element | null;
|
|
3
4
|
//# sourceMappingURL=SwapRate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapRate.d.ts","sourceRoot":"","sources":["../../../../src/components/widget/SwapRate/SwapRate.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SwapRate.d.ts","sourceRoot":"","sources":["../../../../src/components/widget/SwapRate/SwapRate.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC,eAAO,MAAM,QAAQ,GAAI,yBAGtB,aAAa,KAAG,GAAG,CAAC,OAAO,GAAG,IAmBhC,CAAC"}
|
|
@@ -1,56 +1,44 @@
|
|
|
1
1
|
import { Skeleton as e } from "../../ui/skeleton.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getRateString as t } from "./utils.js";
|
|
3
3
|
import { c as n } from "react-compiler-runtime";
|
|
4
|
-
import {
|
|
5
|
-
import { formatUnits as a } from "viem";
|
|
4
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
6
5
|
//#region src/components/widget/SwapRate/SwapRate.tsx
|
|
7
6
|
var o = (o) => {
|
|
8
|
-
let s = n(
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
if (s[0] !== d || s[1] !== l || s[2] !== u || s[3] !== c || s[4] !== f || s[5] !== m || s[6] !== p) {
|
|
12
|
-
v = Symbol.for("react.early_return_sentinel");
|
|
7
|
+
let s = n(6), c, l;
|
|
8
|
+
if (s[0] !== o) {
|
|
9
|
+
l = Symbol.for("react.early_return_sentinel");
|
|
13
10
|
bb0: {
|
|
14
|
-
let {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
destAmountWei: d
|
|
24
|
-
};
|
|
25
|
-
if (g = n, h = o, f) {
|
|
26
|
-
let t = `1 ${g.symbol ?? g.address} =`, n;
|
|
27
|
-
s[11] === Symbol.for("react.memo_cache_sentinel") ? (n = /* @__PURE__ */ r(e, { className: "w-[42px] h-[12px] bg-contrast-6 dark:bg-contrast-5" }), s[11] = n) : n = s[11];
|
|
28
|
-
let a;
|
|
29
|
-
s[12] !== m || s[13] !== t ? (a = /* @__PURE__ */ i("div", {
|
|
11
|
+
let { isLoading: n, ...r } = o, { destToken: u, srcAmountWei: d, destAmountWei: f, reverse: p, prefix: m } = r;
|
|
12
|
+
if (!u) {
|
|
13
|
+
l = null;
|
|
14
|
+
break bb0;
|
|
15
|
+
}
|
|
16
|
+
let h = p ? u : r.srcToken;
|
|
17
|
+
if (n) {
|
|
18
|
+
let t;
|
|
19
|
+
s[3] === Symbol.for("react.memo_cache_sentinel") ? (t = /* @__PURE__ */ i(e, { className: "w-[42px] h-[12px] bg-contrast-6 dark:bg-contrast-5" }), s[3] = t) : t = s[3], l = /* @__PURE__ */ a("div", {
|
|
30
20
|
className: "flex items-center gap-1",
|
|
31
21
|
children: [
|
|
32
22
|
m,
|
|
33
23
|
" ",
|
|
34
|
-
|
|
24
|
+
`1 ${h.symbol ?? h.address} =`,
|
|
35
25
|
" ",
|
|
36
|
-
|
|
26
|
+
t
|
|
37
27
|
]
|
|
38
|
-
})
|
|
28
|
+
});
|
|
39
29
|
break bb0;
|
|
40
30
|
}
|
|
41
|
-
if (
|
|
42
|
-
|
|
31
|
+
if (d === void 0 || f === void 0) {
|
|
32
|
+
l = null;
|
|
43
33
|
break bb0;
|
|
44
34
|
}
|
|
45
|
-
|
|
35
|
+
c = t(r) || "-";
|
|
46
36
|
}
|
|
47
|
-
s[0] =
|
|
48
|
-
} else
|
|
49
|
-
if (
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
let b = `1 ${g.symbol ?? g.address} = ${y} ${h.symbol ?? h.address}`;
|
|
53
|
-
return m ? `${m} ${b}` : b;
|
|
37
|
+
s[0] = o, s[1] = c, s[2] = l;
|
|
38
|
+
} else c = s[1], l = s[2];
|
|
39
|
+
if (l !== Symbol.for("react.early_return_sentinel")) return l;
|
|
40
|
+
let u = c, d;
|
|
41
|
+
return s[4] === u ? d = s[5] : (d = /* @__PURE__ */ i(r, { children: u }), s[4] = u, s[5] = d), d;
|
|
54
42
|
};
|
|
55
43
|
//#endregion
|
|
56
44
|
export { o as SwapRate };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwapRate.js","names":["Skeleton","
|
|
1
|
+
{"version":3,"file":"SwapRate.js","names":["Skeleton","SwapRateProps","getRateString","JSX","SwapRate","t0","$","_c","t1","t2","Symbol","for","bb0","isLoading","props","destToken","srcAmountWei","destAmountWei","reverse","prefix","srcToken","t3","symbol","address","undefined","rateString"],"sources":["../../../../src/components/widget/SwapRate/SwapRate.tsx"],"sourcesContent":["import { Skeleton } from \"@/components/ui/skeleton\";\nimport type { SwapRateProps } from \"./types\";\nimport { getRateString } from \"./utils\";\nimport type { JSX } from \"react\";\n\nexport const SwapRate = ({\n isLoading,\n ...props\n}: SwapRateProps): JSX.Element | null => {\n const { destToken, srcAmountWei, destAmountWei, reverse, prefix } = props;\n if (!destToken) return null;\n\n const srcToken = reverse ? destToken : props.srcToken;\n\n if (isLoading)\n return (\n <div className=\"flex items-center gap-1\">\n {prefix} {`1 ${srcToken.symbol ?? srcToken.address} =`}{\" \"}\n <Skeleton className=\"w-[42px] h-[12px] bg-contrast-6 dark:bg-contrast-5\" />\n </div>\n );\n\n if (srcAmountWei === undefined || destAmountWei === undefined) return null;\n\n const rateString = getRateString(props) || \"-\";\n\n return <>{rateString}</>;\n};\n"],"mappings":";;;;;AAKA,IAAaI,KAAWC,MAAA;CAAA,IAAAC,IAAAC,EAAA,EAAA,EAAAC,GAAAC;AAAA,KAAAH,EAAA,OAAAD,GAAA;AAKCI,MAAAC,OAAIC,IAAJ,8BAAI;AAAAC,OAAA;GALJ,IAAA,EAAAC,cAAA,GAAAC,MAAAT,GAIvB,EAAAU,cAAAC,iBAAAC,kBAAAC,YAAAC,cAAoEL;AACpE,OAAI,CAACC,GAAS;AAASN,QAAA;AAAA,UAAAG;;GAEvB,IAAAQ,IAAiBF,IAAAH,IAAsBD,EAAKM;AAE5C,OAAIP,GAAS;IAAA,IAAAQ;AAETZ,IAFSH,EAAA,OAAAI,OAAAC,IAAA,4BAAA,IAIPU,IAAA,kBAAC,GAAD,EAAoB,WAAA,sDAAuD,CAAA,EAAAf,EAAA,KAAAe,KAAAA,IAAAf,EAAA,IAF7EG,IAAA,kBAAA,OAAA;KAAe,WAAA;eAAf;MACGU;MAAO;MAAE,KAAKC,EAAQE,UAAWF,EAAQG,QAAQ;MAAM;MACxDF;MACI;;AAHN,UAAAT;;AAMJ,OAAII,MAAiBQ,KAAAA,KAAaP,MAAkBO,KAAAA,GAAS;AAASf,QAAA;AAAA,UAAAG;;AAEnDJ,OAAAN,EAAcY,EAAa,IAA3B;;AAA2BR,EAAAA,EAAA,KAAAD,GAAAC,EAAA,KAAAE,GAAAF,EAAA,KAAAG;OAAAA,CAAAD,IAAAF,EAAA,IAAAG,IAAAH,EAAA;AAAA,KAAAG,MAAAC,OAAAC,IAAA,8BAAA,CAAA,QAAAF;CAA9C,IAAAgB,IAAmBjB,GAA4Ba;AAEvB,QAFuBf,EAAA,OAAAmB,IAEvBJ,IAAAf,EAAA,MAAjBe,IAAA,kBAAA,GAAA,EAAA,UAAGI,GAAc,CAAA,EAAAnB,EAAA,KAAAmB,GAAAnB,EAAA,KAAAe,IAAjBA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapRateWithTooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/widget/SwapRate/SwapRateWithTooltip.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,eAAO,MAAM,mBAAmB,GAAI,yBAAyB,aAAa,4CAoBzE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Tooltip as e, TooltipContent as t, TooltipTrigger as n } from "../../ui/tooltip.js";
|
|
2
|
+
import { getRateString as r } from "./utils.js";
|
|
3
|
+
import { SwapRate as i } from "./SwapRate.js";
|
|
4
|
+
import { c as a } from "react-compiler-runtime";
|
|
5
|
+
import { useState as o } from "react";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/widget/SwapRate/SwapRateWithTooltip.tsx
|
|
8
|
+
var l = (l) => {
|
|
9
|
+
let d = a(14), { isLoading: f, ...p } = l, [m, h] = o(!!p.reverse), g = r({
|
|
10
|
+
...p,
|
|
11
|
+
reverse: !m
|
|
12
|
+
}), _;
|
|
13
|
+
d[0] === h ? _ = d[1] : (_ = (e) => {
|
|
14
|
+
e.stopPropagation(), h(u);
|
|
15
|
+
}, d[0] = h, d[1] = _);
|
|
16
|
+
let v;
|
|
17
|
+
d[2] !== f || d[3] !== m || d[4] !== p ? (v = /* @__PURE__ */ s(i, {
|
|
18
|
+
isLoading: f,
|
|
19
|
+
...p,
|
|
20
|
+
reverse: m
|
|
21
|
+
}), d[2] = f, d[3] = m, d[4] = p, d[5] = v) : v = d[5];
|
|
22
|
+
let y;
|
|
23
|
+
d[6] !== _ || d[7] !== v ? (y = /* @__PURE__ */ s(n, {
|
|
24
|
+
asChild: !0,
|
|
25
|
+
children: /* @__PURE__ */ s("div", {
|
|
26
|
+
className: "cursor-pointer",
|
|
27
|
+
onClick: _,
|
|
28
|
+
children: v
|
|
29
|
+
})
|
|
30
|
+
}), d[6] = _, d[7] = v, d[8] = y) : y = d[8];
|
|
31
|
+
let b;
|
|
32
|
+
d[9] === g ? b = d[10] : (b = g && /* @__PURE__ */ s(t, { children: g }), d[9] = g, d[10] = b);
|
|
33
|
+
let x;
|
|
34
|
+
return d[11] !== y || d[12] !== b ? (x = /* @__PURE__ */ c(e, { children: [y, b] }), d[11] = y, d[12] = b, d[13] = x) : x = d[13], x;
|
|
35
|
+
};
|
|
36
|
+
function u(e) {
|
|
37
|
+
return !e;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { l as SwapRateWithTooltip };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=SwapRateWithTooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapRateWithTooltip.js","names":["Tooltip","TooltipContent","TooltipTrigger","SwapRate","SwapRateProps","useState","getRateString","SwapRateWithTooltip","t0","$","_c","isLoading","props","isReversed","setIsReversed","reverse","reversedRate","t1","event","stopPropagation","_temp","t2","t3","t4","t5","prev"],"sources":["../../../../src/components/widget/SwapRate/SwapRateWithTooltip.tsx"],"sourcesContent":["import {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"@/components/ui/tooltip\";\nimport { SwapRate } from \"./SwapRate\";\nimport type { SwapRateProps } from \"./types\";\nimport { useState } from \"react\";\nimport { getRateString } from \"./utils\";\n\nexport const SwapRateWithTooltip = ({ isLoading, ...props }: SwapRateProps) => {\n const [isReversed, setIsReversed] = useState(!!props.reverse);\n\n const reversedRate = getRateString({ ...props, reverse: !isReversed });\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <div\n className=\"cursor-pointer\"\n onClick={(event) => {\n event.stopPropagation();\n setIsReversed((prev) => !prev);\n }}\n >\n <SwapRate isLoading={isLoading} {...props} reverse={isReversed} />\n </div>\n </TooltipTrigger>\n {reversedRate && <TooltipContent>{reversedRate}</TooltipContent>}\n </Tooltip>\n );\n};\n"],"mappings":";;;;;;;AAUA,IAAaO,KAAsBC,MAAA;CAAA,IAAAC,IAAAC,EAAA,GAAA,EAAC,EAAAC,cAAA,GAAAC,MAAAJ,GAClC,CAAAK,GAAAC,KAAoCT,EAAS,CAAC,CAACO,EAAKG,QAAS,EAE7DC,IAAqBV,EAAc;EAAA,GAAKM;EAAKG,SAAW,CAACF;EAAY,CAAC,EAACI;AAAA,CAAAR,EAAA,OAAAK,IAS9DG,IAAAR,EAAA,MAHQQ,KAAAC,MAAA;AAEPJ,EADAI,EAAKC,iBAAkB,EACvBL,EAAcM,EAAgB;IAC/BX,EAAA,KAAAK,GAAAL,EAAA,KAAAQ;CAAA,IAAAI;AAAA,CAAAZ,EAAA,OAAAE,KAAAF,EAAA,OAAAI,KAAAJ,EAAA,OAAAG,KAEDS,IAAA,kBAAC,GAAD;EAAqBV;EAAS,GAAMC;EAAgBC,SAAAA;EAAc,CAAA,EAAAJ,EAAA,KAAAE,GAAAF,EAAA,KAAAI,GAAAJ,EAAA,KAAAG,GAAAH,EAAA,KAAAY,KAAAA,IAAAZ,EAAA;CAAA,IAAAa;AAAA,CAAAb,EAAA,OAAAQ,KAAAR,EAAA,OAAAY,KARtEC,IAAA,kBAAC,GAAD;EAAgB,SAAA;YACd,kBAAA,OAAA;GACY,WAAA;GACD,SAAAL;aAKTI;GAEJ,CAAA;EAAiB,CAAA,EAAAZ,EAAA,KAAAQ,GAAAR,EAAA,KAAAY,GAAAZ,EAAA,KAAAa,KAAAA,IAAAb,EAAA;CAAA,IAAAc;AAAA,CAAAd,EAAA,OAAAO,IAC+CO,IAAAd,EAAA,OAA/Dc,IAAAP,KAAgB,kBAAC,GAAD,EAAA,UAAiBA,GAA8B,CAAA,EAAAP,EAAA,KAAAO,GAAAP,EAAA,MAAAc;CAAA,IAAAC;AACxD,QADwDf,EAAA,QAAAa,KAAAb,EAAA,QAAAc,KAZlEC,IAAA,kBAAC,GAAD,EAAA,UAAA,CACEF,GAWCC,EACO,EAAA,CAAA,EAAAd,EAAA,MAAAa,GAAAb,EAAA,MAAAc,GAAAd,EAAA,MAAAe,KAAAA,IAAAf,EAAA,KAbVe;;AAL+B,SAAAJ,EAAAK,GAAA;AAAA,QAWC,CAACA"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SwapRateProps } from './types';
|
|
2
|
+
export declare function getRateString({ srcToken: _srcToken, destToken: _destToken, srcAmountWei: _srcAmountWei, destAmountWei: _destAmountWei, reverse, prefix, }: Omit<SwapRateProps, "isLoading">): string | null;
|
|
3
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/components/widget/SwapRate/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAG7C,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,aAAa,EAC3B,aAAa,EAAE,cAAc,EAC7B,OAAO,EACP,MAAM,GACP,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,CAAC,GAAG,MAAM,GAAG,IAAI,CAmClD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { calcRate as e } from "../../../lib/utils/rate.js";
|
|
2
|
+
import { formatUnits as t } from "viem";
|
|
3
|
+
//#region src/components/widget/SwapRate/utils.ts
|
|
4
|
+
function n({ srcToken: n, destToken: r, srcAmountWei: i, destAmountWei: a, reverse: o, prefix: s }) {
|
|
5
|
+
if (!r) return null;
|
|
6
|
+
let { srcToken: c, destToken: l, srcAmountWei: u, destAmountWei: d } = o ? {
|
|
7
|
+
srcToken: r,
|
|
8
|
+
destToken: n,
|
|
9
|
+
srcAmountWei: a,
|
|
10
|
+
destAmountWei: i
|
|
11
|
+
} : {
|
|
12
|
+
srcToken: n,
|
|
13
|
+
destToken: r,
|
|
14
|
+
srcAmountWei: i,
|
|
15
|
+
destAmountWei: a
|
|
16
|
+
};
|
|
17
|
+
if (u === void 0 || d === void 0) return null;
|
|
18
|
+
let f = e(t(BigInt(u), c.decimals), t(BigInt(d), l.decimals))?.rateFormatted;
|
|
19
|
+
if (!f) return null;
|
|
20
|
+
let p = `1 ${c.symbol ?? c.address} = ${f} ${l.symbol ?? l.address}`;
|
|
21
|
+
return s ? `${s} ${p}` : p;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { n as getRateString };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["formatUnits","SwapRateProps","calcRate","getRateString","srcToken","_srcToken","destToken","_destToken","srcAmountWei","_srcAmountWei","destAmountWei","_destAmountWei","reverse","prefix","Omit","undefined","srcUnits","BigInt","decimals","destUnits","rateFormatted","rateText","symbol","address"],"sources":["../../../../src/components/widget/SwapRate/utils.ts"],"sourcesContent":["import { formatUnits } from \"viem\";\nimport type { SwapRateProps } from \"./types\";\nimport { calcRate } from \"@/lib/utils/rate\";\n\nexport function getRateString({\n srcToken: _srcToken,\n destToken: _destToken,\n srcAmountWei: _srcAmountWei,\n destAmountWei: _destAmountWei,\n reverse,\n prefix,\n}: Omit<SwapRateProps, \"isLoading\">): string | null {\n if (!_destToken) return null;\n\n const { srcToken, destToken, srcAmountWei, destAmountWei } = reverse\n ? {\n srcToken: _destToken,\n destToken: _srcToken,\n srcAmountWei: _destAmountWei,\n destAmountWei: _srcAmountWei,\n }\n : {\n srcToken: _srcToken,\n destToken: _destToken,\n srcAmountWei: _srcAmountWei,\n destAmountWei: _destAmountWei,\n };\n\n if (srcAmountWei === undefined || destAmountWei === undefined) return null;\n\n const srcUnits = formatUnits(BigInt(srcAmountWei), srcToken.decimals);\n const destUnits = formatUnits(BigInt(destAmountWei), destToken.decimals);\n\n const rateFormatted = calcRate(srcUnits, destUnits)?.rateFormatted;\n if (!rateFormatted) {\n // will happen when destAmount is not yet filled from the first price fetch (=\"0\")\n return null;\n }\n\n const rateText = `1 ${srcToken.symbol ?? srcToken.address} = ${rateFormatted} ${destToken.symbol ?? destToken.address}`;\n\n if (prefix) {\n return `${prefix} ${rateText}`;\n }\n\n return rateText;\n}\n"],"mappings":";;;AAIA,SAAgBG,EAAc,EAC5BC,UAAUC,GACVC,WAAWC,GACXC,cAAcC,GACdC,eAAeC,GACfC,YACAC,aACkD;AAClD,KAAI,CAACN,EAAY,QAAO;CAExB,IAAM,EAAEH,aAAUE,cAAWE,iBAAcE,qBAAkBE,IACzD;EACER,UAAUG;EACVD,WAAWD;EACXG,cAAcG;EACdD,eAAeD;EAChB,GACD;EACEL,UAAUC;EACVC,WAAWC;EACXC,cAAcC;EACdC,eAAeC;EAChB;AAEL,KAAIH,MAAiBO,KAAAA,KAAaL,MAAkBK,KAAAA,EAAW,QAAO;CAKtE,IAAMK,IAAgBlB,EAHLF,EAAYiB,OAAOT,EAAa,EAAEJ,EAASc,SAAS,EACnDlB,EAAYiB,OAAOP,EAAc,EAAEJ,EAAUY,SAAS,CAErB,EAAEE;AACrD,KAAI,CAACA,EAEH,QAAO;CAGT,IAAMC,IAAW,KAAKjB,EAASkB,UAAUlB,EAASmB,QAAO,KAAMH,EAAa,GAAId,EAAUgB,UAAUhB,EAAUiB;AAM9G,QAJIV,IACK,GAAGA,EAAM,GAAIQ,MAGfA"}
|