rujira.ui 1.0.18 → 1.0.20
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/lib/cjs/components/AssetLabel.js +16 -5
- package/lib/cjs/components/bridges/DepositModal.js +18 -1
- package/lib/cjs/components/footer/Footer.js +21 -27
- package/lib/cjs/components/header/Accounts.js +26 -42
- package/lib/cjs/components/header/Header.js +3 -3
- package/lib/cjs/components/header/QuickLauncher.js +1 -1
- package/lib/cjs/components/icons/Icons.js +5 -2
- package/lib/cjs/components/numbers/Decimal.js +16 -10
- package/lib/cjs/components/numbers/Fiat.js +17 -11
- package/lib/cjs/helpers/index.js +58 -0
- package/lib/cjs/helpers/number.js +2 -2
- package/lib/cjs/i18n/config.js +9 -0
- package/lib/cjs/i18n/locales/de/borrow.json +24 -10
- package/lib/cjs/i18n/locales/de/common.json +10 -8
- package/lib/cjs/i18n/locales/de/header.json +13 -8
- package/lib/cjs/i18n/locales/de/home.json +3 -2
- package/lib/cjs/i18n/locales/de/leagues.json +1 -1
- package/lib/cjs/i18n/locales/de/lending.json +4 -0
- package/lib/cjs/i18n/locales/de/liquidate.json +4 -0
- package/lib/cjs/i18n/locales/de/portfolio.json +7 -4
- package/lib/cjs/i18n/locales/de/strategies.json +2 -0
- package/lib/cjs/i18n/locales/de/swap.json +6 -6
- package/lib/cjs/i18n/locales/de/trade.json +41 -31
- package/lib/cjs/i18n/locales/en/algorithmic.json +4 -0
- package/lib/cjs/i18n/locales/en/borrow.json +24 -10
- package/lib/cjs/i18n/locales/en/common.json +10 -6
- package/lib/cjs/i18n/locales/en/header.json +12 -7
- package/lib/cjs/i18n/locales/en/home.json +3 -2
- package/lib/cjs/i18n/locales/en/leagues.json +1 -1
- package/lib/cjs/i18n/locales/en/lending.json +4 -0
- package/lib/cjs/i18n/locales/en/liquidate.json +4 -0
- package/lib/cjs/i18n/locales/en/portfolio.json +7 -4
- package/lib/cjs/i18n/locales/en/strategies.json +2 -0
- package/lib/cjs/i18n/locales/en/swap.json +6 -6
- package/lib/cjs/i18n/locales/en/trade.json +41 -31
- package/lib/esm/components/AssetLabel.d.ts +10 -7
- package/lib/esm/components/AssetLabel.d.ts.map +1 -1
- package/lib/esm/components/AssetLabel.js +14 -4
- package/lib/esm/components/bridges/DepositModal.js +18 -1
- package/lib/esm/components/footer/Footer.d.ts.map +1 -1
- package/lib/esm/components/footer/Footer.js +21 -27
- package/lib/esm/components/header/Accounts.d.ts.map +1 -1
- package/lib/esm/components/header/Accounts.js +28 -44
- package/lib/esm/components/header/Header.d.ts.map +1 -1
- package/lib/esm/components/header/Header.js +4 -4
- package/lib/esm/components/header/QuickLauncher.js +1 -1
- package/lib/esm/components/icons/Icons.d.ts +1 -0
- package/lib/esm/components/icons/Icons.d.ts.map +1 -1
- package/lib/esm/components/icons/Icons.js +3 -0
- package/lib/esm/components/notices/Warning.d.ts +1 -1
- package/lib/esm/components/notices/Warning.d.ts.map +1 -1
- package/lib/esm/components/numbers/Decimal.d.ts +2 -1
- package/lib/esm/components/numbers/Decimal.d.ts.map +1 -1
- package/lib/esm/components/numbers/Decimal.js +18 -12
- package/lib/esm/components/numbers/Fiat.d.ts +2 -1
- package/lib/esm/components/numbers/Fiat.d.ts.map +1 -1
- package/lib/esm/components/numbers/Fiat.js +19 -13
- package/lib/esm/helpers/index.d.ts +6 -0
- package/lib/esm/helpers/index.d.ts.map +1 -1
- package/lib/esm/helpers/index.js +56 -0
- package/lib/esm/helpers/number.d.ts +1 -1
- package/lib/esm/helpers/number.d.ts.map +1 -1
- package/lib/esm/helpers/number.js +2 -2
- package/lib/esm/i18n/config.d.ts.map +1 -1
- package/lib/esm/i18n/config.js +9 -0
- package/lib/esm/i18n/locales/de/borrow.json +24 -10
- package/lib/esm/i18n/locales/de/common.json +10 -8
- package/lib/esm/i18n/locales/de/header.json +13 -8
- package/lib/esm/i18n/locales/de/home.json +3 -2
- package/lib/esm/i18n/locales/de/leagues.json +1 -1
- package/lib/esm/i18n/locales/de/lending.json +4 -0
- package/lib/esm/i18n/locales/de/liquidate.json +4 -0
- package/lib/esm/i18n/locales/de/portfolio.json +7 -4
- package/lib/esm/i18n/locales/de/strategies.json +2 -0
- package/lib/esm/i18n/locales/de/swap.json +6 -6
- package/lib/esm/i18n/locales/de/trade.json +41 -31
- package/lib/esm/i18n/locales/en/algorithmic.json +4 -0
- package/lib/esm/i18n/locales/en/borrow.json +24 -10
- package/lib/esm/i18n/locales/en/common.json +10 -6
- package/lib/esm/i18n/locales/en/header.json +12 -7
- package/lib/esm/i18n/locales/en/home.json +3 -2
- package/lib/esm/i18n/locales/en/leagues.json +1 -1
- package/lib/esm/i18n/locales/en/lending.json +4 -0
- package/lib/esm/i18n/locales/en/liquidate.json +4 -0
- package/lib/esm/i18n/locales/en/portfolio.json +7 -4
- package/lib/esm/i18n/locales/en/strategies.json +2 -0
- package/lib/esm/i18n/locales/en/swap.json +6 -6
- package/lib/esm/i18n/locales/en/trade.json +41 -31
- package/package.json +1 -1
- package/src/components/AssetLabel.tsx +21 -8
- package/src/components/bridges/DepositModal.tsx +32 -13
- package/src/components/footer/Footer.tsx +21 -27
- package/src/components/header/Accounts.tsx +82 -101
- package/src/components/header/Header.tsx +71 -33
- package/src/components/header/QuickLauncher.tsx +1 -1
- package/src/components/icons/Icons.tsx +9 -0
- package/src/components/notices/Warning.tsx +1 -1
- package/src/components/numbers/Decimal.tsx +37 -18
- package/src/components/numbers/Fiat.tsx +37 -21
- package/src/helpers/index.ts +58 -0
- package/src/helpers/number.ts +3 -3
- package/src/i18n/config.ts +10 -0
- package/src/i18n/locales/de/borrow.json +24 -10
- package/src/i18n/locales/de/common.json +10 -8
- package/src/i18n/locales/de/header.json +13 -8
- package/src/i18n/locales/de/home.json +3 -2
- package/src/i18n/locales/de/leagues.json +1 -1
- package/src/i18n/locales/de/lending.json +4 -0
- package/src/i18n/locales/de/liquidate.json +4 -0
- package/src/i18n/locales/de/portfolio.json +7 -4
- package/src/i18n/locales/de/strategies.json +2 -0
- package/src/i18n/locales/de/swap.json +6 -6
- package/src/i18n/locales/de/trade.json +41 -31
- package/src/i18n/locales/en/borrow.json +24 -10
- package/src/i18n/locales/en/common.json +10 -6
- package/src/i18n/locales/en/header.json +12 -7
- package/src/i18n/locales/en/home.json +3 -2
- package/src/i18n/locales/en/leagues.json +1 -1
- package/src/i18n/locales/en/lending.json +4 -0
- package/src/i18n/locales/en/liquidate.json +4 -0
- package/src/i18n/locales/en/portfolio.json +7 -4
- package/src/i18n/locales/en/strategies.json +2 -0
- package/src/i18n/locales/en/swap.json +6 -6
- package/src/i18n/locales/en/trade.json +41 -31
- package/src/scss/base/_display.scss +9 -2
- package/src/scss/components/_header.scss +81 -2
- package/src/scss/components/_warning.scss +10 -0
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AssetLabel = void 0;
|
|
3
|
+
exports.AssetLabel = exports.assetLabel = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const rujira_js_1 = require("rujira.js");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
// True when an asset uses an ambiguous symbol that needs its network appended
|
|
7
|
+
// to disambiguate it from the canonical token (e.g. a secured USDT that lives
|
|
8
|
+
// on a chain other than Ethereum).
|
|
9
|
+
const needsNetworkSuffix = (asset) => ((asset.metadata.symbol === "USDT" && asset.chain !== rujira_js_1.ETH) ||
|
|
10
|
+
(asset.metadata.symbol === "ETH" && asset.chain !== rujira_js_1.ETH) ||
|
|
11
|
+
(asset.metadata.symbol === "USDC" && asset.chain !== rujira_js_1.ETH)) &&
|
|
12
|
+
asset.type === "SECURED";
|
|
13
|
+
// String form of <AssetLabel> for contexts that require a plain string rather
|
|
14
|
+
// than JSX (e.g. the `symbol` prop of <Decimal>).
|
|
15
|
+
const assetLabel = (asset) => asset
|
|
16
|
+
? asset.metadata.symbol +
|
|
17
|
+
(needsNetworkSuffix(asset) ? `.${asset.chain}` : "")
|
|
18
|
+
: "";
|
|
19
|
+
exports.assetLabel = assetLabel;
|
|
20
|
+
const AssetLabel = ({ asset, Container }) => asset ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [asset.metadata.symbol, needsNetworkSuffix(asset) && (0, jsx_runtime_1.jsxs)(Container, { children: [".", asset.chain] })] })) : null;
|
|
10
21
|
exports.AssetLabel = AssetLabel;
|
|
@@ -68,6 +68,21 @@ const Confirm = ({ asset, balance, targets, target: target_, Submit, onSuccess,
|
|
|
68
68
|
const canSwap = asset.chain !== account?.asset.chain ||
|
|
69
69
|
asset.metadata.symbol !== account.asset.metadata.symbol;
|
|
70
70
|
const shouldSwap = canSwap && !direct;
|
|
71
|
+
const standardChain = (0, rujira_js_1.networkLabel)(asset.chain);
|
|
72
|
+
const directChain = account?.asset ? (0, rujira_js_1.networkLabel)(account.asset.chain) : "";
|
|
73
|
+
const directAsset = account?.asset.metadata.symbol || asset.metadata.symbol;
|
|
74
|
+
const directAssetChain = account?.asset.chain;
|
|
75
|
+
const nonStandardDepositWarning = direct
|
|
76
|
+
? t("directDepositWarning", {
|
|
77
|
+
asset: directAsset,
|
|
78
|
+
standardChain,
|
|
79
|
+
directChain,
|
|
80
|
+
})
|
|
81
|
+
: t("nonStandardDepositWarning", {
|
|
82
|
+
asset: directAsset,
|
|
83
|
+
standardChain,
|
|
84
|
+
directChain,
|
|
85
|
+
});
|
|
71
86
|
// Determine the actual destination address
|
|
72
87
|
const destination = target === "custom" ? custom : target;
|
|
73
88
|
const isCustomAddressInvalid = target === "custom" && custom !== "" && !(0, rujira_js_1.validateAddress)(rujira_js_1.THOR, custom);
|
|
@@ -130,7 +145,9 @@ const Confirm = ({ asset, balance, targets, target: target_, Submit, onSuccess,
|
|
|
130
145
|
"w-2 h-2": true,
|
|
131
146
|
"filter-grey": !hoverAd,
|
|
132
147
|
"filter-white": hoverAd,
|
|
133
|
-
}) }), advanced ? t("hideAdvancedOptions") : t("showAdvancedOptions")] })] }), advanced && ((0, jsx_runtime_1.jsxs)("div", { className: "br-1 p-2 bg-black mt-1 row wrap condensed fs-14 px-2 gap-y-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-4 text-center text-xs-left color-grey fw-500", children: t("destination") }), (0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-8 text-center text-xs-right", children: (0, jsx_runtime_1.jsxs)(Select_1.Select, { containerClassName: "fs-14", className: "select--inline text-right", value: target, onChange: (e) => setTarget(e.currentTarget.value), children: [targets.map((x) => ((0, jsx_runtime_1.jsx)("option", { value: x.address, className: "bg-darkGrey", children: x.address }, x.address))), (0, jsx_runtime_1.jsx)("option", { className: "bg-darkGrey", value: "custom", children: t("customAddress") })] }) }), target === "custom" && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-4 text-center text-xs-left color-grey fw-500", children: t("customDestination") }), (0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-8 text-center text-xs-right", children: (0, jsx_runtime_1.jsx)(Input_1.Input, { containerClassName: "fs-14", value: custom, onChange: (e) => setCustom(e.currentTarget.value), className: "input--inline text-right", innerRef: ref }) })] })), canSwap && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [asset.chain === rujira_js_1.THOR ? null : ((0, jsx_runtime_1.jsx)("div", { className: "col-12 text-center text-xs-right", children: (0, jsx_runtime_1.jsx)(__1.Toggle, { className: "toggle--xs",
|
|
148
|
+
}) }), advanced ? t("hideAdvancedOptions") : t("showAdvancedOptions")] })] }), advanced && ((0, jsx_runtime_1.jsxs)("div", { className: "br-1 p-2 bg-black mt-1 row wrap condensed fs-14 px-2 gap-y-1", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-4 text-center text-xs-left color-grey fw-500", children: t("destination") }), (0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-8 text-center text-xs-right", children: (0, jsx_runtime_1.jsxs)(Select_1.Select, { containerClassName: "fs-14", className: "select--inline text-right", value: target, onChange: (e) => setTarget(e.currentTarget.value), children: [targets.map((x) => ((0, jsx_runtime_1.jsx)("option", { value: x.address, className: "bg-darkGrey", children: x.address }, x.address))), (0, jsx_runtime_1.jsx)("option", { className: "bg-darkGrey", value: "custom", children: t("customAddress") })] }) }), target === "custom" && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-4 text-center text-xs-left color-grey fw-500", children: t("customDestination") }), (0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-8 text-center text-xs-right", children: (0, jsx_runtime_1.jsx)(Input_1.Input, { containerClassName: "fs-14", value: custom, onChange: (e) => setCustom(e.currentTarget.value), className: "input--inline text-right", innerRef: ref }) })] })), canSwap && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [asset.chain === rujira_js_1.THOR ? null : ((0, jsx_runtime_1.jsx)("div", { className: "col-12 text-center text-xs-right", children: (0, jsx_runtime_1.jsx)(__1.Toggle, { className: "toggle--xs", checked: direct, onChange: () => setDirect((prev) => !prev), children: (0, jsx_runtime_1.jsxs)("span", { className: "toggle__label", children: [t("depositAssetOnChain"), " ", directAsset, directAssetChain && ((0, jsx_runtime_1.jsxs)("span", { className: "color-grey", children: [".", directAssetChain] }))] }) }) })), asset.chain !== rujira_js_1.THOR && ((0, jsx_runtime_1.jsxs)(__1.Warning, { className: "warning--sm condensed flex ai-c mt-1", color: "orange", children: [(0, jsx_runtime_1.jsx)("img", { src: swap_gif_1.default, alt: "", className: "filter-orange block no-shrink", style: { width: "2.5rem", height: "2.5rem" } }), (0, jsx_runtime_1.jsx)("small", { className: "text-left fs-14", dangerouslySetInnerHTML: {
|
|
149
|
+
__html: nonStandardDepositWarning,
|
|
150
|
+
} })] }))] })), isCustomAddressInvalid && ((0, jsx_runtime_1.jsx)("div", { className: "flex dir-r jc-c grow mt-1", children: (0, jsx_runtime_1.jsxs)(__1.Warning, { color: "red", className: "condensed iflex grow", children: [(0, jsx_runtime_1.jsx)(__1.Icons.ExclamationTriangle, { className: "color-red" }), (0, jsx_runtime_1.jsx)("span", { className: "warning__msg", children: t("invalidThorAddress") })] }) }))] })), (0, jsx_runtime_1.jsx)(Submit, { selected: account, amount: amount, target: target !== "custom" ? target : custom, swapMemo: "memo", onSuccess: onSuccess, disabled: isCustomAddressInvalid, isDangerous: false, quote: quote, shouldSwap: shouldSwap })] }));
|
|
134
151
|
};
|
|
135
152
|
const Success = ({ tx, dismiss, }) => {
|
|
136
153
|
const { t } = (0, i18n_1.useTranslation)("common");
|
|
@@ -6,7 +6,6 @@ const clsx_1 = require("clsx");
|
|
|
6
6
|
const ResolveLink_1 = require("../header/ResolveLink");
|
|
7
7
|
const Icons_1 = require("../icons/Icons");
|
|
8
8
|
const RujiraLogo_1 = require("../logos/RujiraLogo");
|
|
9
|
-
const SITE_URL = "https://rujira.network";
|
|
10
9
|
const DOCS_URL = "https://docs.rujira.network";
|
|
11
10
|
const DISCORD_URL = "https://discord.com/invite/XPvsxhWKfb";
|
|
12
11
|
const TELEGRAM_URL = "https://t.me/Rujira_Community";
|
|
@@ -18,7 +17,7 @@ const footerSections = [
|
|
|
18
17
|
{ kind: "internal", label: "Cross-chain Swaps", to: "swap" },
|
|
19
18
|
{ kind: "internal", label: "Orderbook DEX", to: "trade" },
|
|
20
19
|
{ kind: "internal", label: "Earn Opportunities", to: "strategies" },
|
|
21
|
-
{ kind: "internal", label: "Money Market", to: "borrow" },
|
|
20
|
+
{ kind: "internal", label: "Money Market", to: "/borrow/BTC/USDC" },
|
|
22
21
|
{
|
|
23
22
|
kind: "internal",
|
|
24
23
|
label: "Automated Trading",
|
|
@@ -27,41 +26,33 @@ const footerSections = [
|
|
|
27
26
|
{
|
|
28
27
|
kind: "internal",
|
|
29
28
|
label: "bRUNE",
|
|
30
|
-
to: "/
|
|
29
|
+
to: "/stake/bRUNE",
|
|
31
30
|
},
|
|
32
31
|
{ kind: "internal", label: "Indices", to: "index" },
|
|
33
32
|
{ kind: "internal", label: "Recurring Buys", to: "trade" },
|
|
33
|
+
{ kind: "static", label: "Analytics", to: "/analytics" },
|
|
34
34
|
],
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
title: "Learn",
|
|
38
38
|
links: [
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
{ kind: "
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
kind: "external",
|
|
52
|
-
label: "Secured Assets",
|
|
53
|
-
href: `${SITE_URL}/secured-assets`,
|
|
54
|
-
},
|
|
55
|
-
{ kind: "internal", label: "FAQ", to: "faq" },
|
|
56
|
-
{ kind: "internal", label: "Articles", to: "articles" },
|
|
57
|
-
{ kind: "external", label: "Roadmap", href: `${SITE_URL}/roadmap` },
|
|
58
|
-
{ kind: "external", label: "Documentation", href: DOCS_URL },
|
|
39
|
+
{ kind: "static", label: "Discover Rujira", to: "/discover-rujira" },
|
|
40
|
+
{ kind: "static", label: "Architecture", to: "/architecture" },
|
|
41
|
+
{ kind: "static", label: "RUJI Token", to: "/ruji-token" },
|
|
42
|
+
{ kind: "static", label: "Enshrined Oracles", to: "/enshrined-oracles" },
|
|
43
|
+
{ kind: "static", label: "Secured Assets", to: "/secured-assets" },
|
|
44
|
+
{ kind: "static", label: "Cypherpunk", to: "/cypherpunk" },
|
|
45
|
+
{ kind: "static", label: "Omnichain", to: "/omnichain" },
|
|
46
|
+
{ kind: "static", label: "Security", to: "/security" },
|
|
47
|
+
{ kind: "static", label: "Articles", to: "/articles" },
|
|
48
|
+
{ kind: "static", label: "Roadmap", to: "/roadmap" },
|
|
49
|
+
{ kind: "external", label: "Product Docs", href: DOCS_URL },
|
|
59
50
|
],
|
|
60
51
|
},
|
|
61
52
|
{
|
|
62
53
|
title: "Ecosystem",
|
|
63
54
|
links: [
|
|
64
|
-
{ kind: "
|
|
55
|
+
{ kind: "static", label: "Ecosystem", to: "/ecosystem" },
|
|
65
56
|
{
|
|
66
57
|
kind: "external",
|
|
67
58
|
label: "Deving Zone",
|
|
@@ -95,8 +86,8 @@ const footerSections = [
|
|
|
95
86
|
},
|
|
96
87
|
{
|
|
97
88
|
kind: "external",
|
|
98
|
-
label: "
|
|
99
|
-
href: DOCS_URL
|
|
89
|
+
label: "Developer docs",
|
|
90
|
+
href: `${DOCS_URL}/developers`,
|
|
100
91
|
},
|
|
101
92
|
{
|
|
102
93
|
kind: "external",
|
|
@@ -113,7 +104,10 @@ const footerSections = [
|
|
|
113
104
|
{
|
|
114
105
|
title: "Support",
|
|
115
106
|
links: [
|
|
116
|
-
{ kind: "
|
|
107
|
+
{ kind: "static", label: "Get Started", to: "/get-started" },
|
|
108
|
+
{ kind: "static", label: "Knowledge Hub", to: "/support" },
|
|
109
|
+
{ kind: "static", label: "FAQ", to: "/faq" },
|
|
110
|
+
{ kind: "static", label: "Deposit", to: "/deposit" },
|
|
117
111
|
{
|
|
118
112
|
kind: "external",
|
|
119
113
|
label: "Developer Help",
|
|
@@ -18,24 +18,12 @@ const Icons_1 = require("../icons/Icons");
|
|
|
18
18
|
const NetworkIcon_1 = require("../icons/NetworkIcon");
|
|
19
19
|
const Fiat_1 = require("../numbers/Fiat");
|
|
20
20
|
const ResolveLink_1 = require("./ResolveLink");
|
|
21
|
-
let referral = typeof window !== "undefined" ? localStorage.getItem("referral") : null;
|
|
22
21
|
const Accounts = ({ provider, routingElement, wallets, ProviderIcon, getValue, customActions, }) => {
|
|
23
22
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
24
23
|
const { accounts: allAccounts, disconnectAll, selected } = provider;
|
|
25
24
|
const [showBlur, setShowBlur] = (0, react_2.useState)(false);
|
|
26
|
-
const { hideModal, showModal } = (0, GlobalModal_1.useGlobalModalContext)();
|
|
27
25
|
const [showBalance, setShowBalance] = (0, __1.useLocalStorage)("rujira-show-balance", "true");
|
|
28
26
|
const accounts = allAccounts?.filter((a) => (0, rujira_js_1.isThor)(a.address));
|
|
29
|
-
const ReferralModal = () => {
|
|
30
|
-
showModal({
|
|
31
|
-
title: t("referAndEarn"),
|
|
32
|
-
backgroundClose: true,
|
|
33
|
-
children: ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { className: "p balance", children: t("referralDescription") }), (0, jsx_runtime_1.jsx)("div", { className: "pointer", onClick: () => {
|
|
34
|
-
react_hot_toast_1.default.success(t("referralCopied"));
|
|
35
|
-
navigator.clipboard.writeText(`https://rujira.network/?ref=${referral}`);
|
|
36
|
-
}, children: (0, jsx_runtime_1.jsx)(__1.Input, { value: `https://rujira.network/?ref=${referral}`, readOnly: true, label: t("clickToCopy") }) }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 color-grey mt-2", children: t("referralValidUntil") }), (0, jsx_runtime_1.jsx)("div", { className: "modal__footer mt-4 px-3 py-2 text-right", children: (0, jsx_runtime_1.jsx)(__1.Button, { label: t("close"), onClick: hideModal }) })] })),
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
27
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: !accounts || accounts.length === 0 ? ((0, jsx_runtime_1.jsx)(ConnectAnimation, { routingElement: routingElement, children: (0, jsx_runtime_1.jsx)(exports.Wallets, { provider: provider, wallets: wallets, routingElement: routingElement }) })) : ((0, jsx_runtime_1.jsxs)(MyAccount, { routingElement: routingElement, provider: provider, value: selected ? getValue(rujira_js_1.Account.fromAddress(selected.address)) : false, onHide: () => setShowBlur(false), children: [selected ? ((0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, to: "portfolio", className: "balance", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex ai-b", children: showBalance === "true" ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Fiat_1.Fiat, { amount: getValue(rujira_js_1.Account.fromAddress(selected.address)), decimals: 12, symbol: "~$", padSymbol: false, className: "color-white fs-26 condensed" }), (0, jsx_runtime_1.jsx)("button", { className: "transparent ml-1 color-grey hover-white", onClick: (e) => {
|
|
40
28
|
e.stopPropagation();
|
|
41
29
|
e.preventDefault();
|
|
@@ -47,49 +35,45 @@ const Accounts = ({ provider, routingElement, wallets, ProviderIcon, getValue, c
|
|
|
47
35
|
setShowBalance("true");
|
|
48
36
|
return false;
|
|
49
37
|
}, style: { marginRight: "-1rem" }, children: (0, jsx_runtime_1.jsx)(Icons_1.EyeSlash, { className: "w-2 h-2" }) })] })) }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 condensed color-grey mt-0.5", children: t("viewPortfolio") })] })) : null, accounts.map((account) => ((0, jsx_runtime_1.jsx)(AddressC, { provider: provider, ProviderIcon: ProviderIcon, account: account, selected: selected?.address.address === account.address.address &&
|
|
50
|
-
selected.provider === account.provider }, `${account.address.address}:${account.provider}`))), (0, jsx_runtime_1.jsxs)("nav", { className: "actions", children: [
|
|
38
|
+
selected.provider === account.provider }, `${account.address.address}:${account.provider}`))), (0, jsx_runtime_1.jsxs)("nav", { className: "actions", children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, className: "action transparent", to: "connect", children: [(0, jsx_runtime_1.jsx)(Icons_1.Plus, {}), (0, jsx_runtime_1.jsx)("span", { children: t("connectAnotherWallet") })] }), customActions &&
|
|
51
39
|
customActions.map((e, index) => (0, react_2.cloneElement)(e, { key: index })), (0, jsx_runtime_1.jsxs)("button", { className: "action transparent", onClick: disconnectAll, children: [(0, jsx_runtime_1.jsx)(Icons_1.LinkDisconnect, {}), (0, jsx_runtime_1.jsx)("span", { children: t("disconnectAll") })] })] }), showBlur && (0, jsx_runtime_1.jsx)("div", { className: "blur" })] })) }));
|
|
52
40
|
};
|
|
53
41
|
exports.Accounts = Accounts;
|
|
54
|
-
|
|
55
|
-
return <Link {...props} ref={ref} />;
|
|
56
|
-
}); */
|
|
57
|
-
const ConnectAnimation = ({ children, routingElement }) => {
|
|
42
|
+
const ConnectAnimation = ({ children, routingElement, }) => {
|
|
58
43
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
59
44
|
const [show, setShow] = (0, react_2.useState)(false);
|
|
60
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative py-q1 no-underline", onMouseOver: () => setShow(true), onMouseOut: () => setShow(false), children: [(0, jsx_runtime_1.jsxs)("div", { className: "rujira-header__connect", children: [(0, jsx_runtime_1.jsx)("div", { className: "fs-14 fw-500 fs-15 condensed", children: t("connect") }), (0, jsx_runtime_1.jsx)("img", { className: "w-3 h-3 filter-white", src: show ? connect_gif_1.default : connect_png_1.default, alt: "Connect" })] }), (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: show && ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { className: "rujira-header__popup right condensed w-32 text-center p-2", initial: { opacity: 0, marginTop: -4 }, animate: { opacity: 1, marginTop: 4 }, exit: { opacity: 0, marginTop: -4 }, children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, className: "flex dir-c action transparent", to: "connect", children: [(0, jsx_runtime_1.jsx)("p", { className: "color-white", children: t("connectYourWallet") }), (0, jsx_runtime_1.jsx)("small", { className: "color-grey
|
|
45
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "relative py-q1 no-underline", onMouseOver: () => setShow(true), onMouseOut: () => setShow(false), children: [(0, jsx_runtime_1.jsxs)("div", { className: "rujira-header__connect", children: [(0, jsx_runtime_1.jsx)("div", { className: "fs-14 fw-500 fs-15 condensed", children: t("connect") }), (0, jsx_runtime_1.jsx)("img", { className: "w-3 h-3 filter-white", src: show ? connect_gif_1.default : connect_png_1.default, alt: "Connect" })] }), (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: show && ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { className: "rujira-header__popup right condensed w-32 text-center p-2", initial: { opacity: 0, marginTop: -4 }, animate: { opacity: 1, marginTop: 4 }, exit: { opacity: 0, marginTop: -4 }, children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, className: "flex dir-c action transparent", to: "connect", children: [(0, jsx_runtime_1.jsx)("p", { className: "color-white", children: t("connectYourWallet") }), (0, jsx_runtime_1.jsx)("small", { className: "color-grey", children: t("createOrConnectWallet") })] }), children] })) })] }));
|
|
61
46
|
};
|
|
62
47
|
const Wallets = ({ modalLayout = false, provider, wallets, routingElement, }) => {
|
|
63
48
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
64
49
|
const { connect, isAvailable } = provider;
|
|
65
50
|
const { hideModal } = (0, GlobalModal_1.useGlobalModalContext)();
|
|
66
|
-
const [
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { as: routingElement, to: "/tou", className: "terms mb-1", children: "By connecting a wallet, you agree to Rujira's Terms of Use." }), (0, jsx_runtime_1.jsx)("hr", { className: (0, clsx_1.default)({
|
|
51
|
+
const rujiraWalletOrder = ["vultisig", "keplr"];
|
|
52
|
+
const rujiraWallets = wallets
|
|
53
|
+
.filter((wallet) => rujiraWalletOrder.includes(wallet.key))
|
|
54
|
+
.sort((a, b) => rujiraWalletOrder.indexOf(a.key) - rujiraWalletOrder.indexOf(b.key));
|
|
55
|
+
const otherWallets = wallets.filter((wallet) => !rujiraWalletOrder.includes(wallet.key));
|
|
56
|
+
const walletButton = (wallet) => {
|
|
57
|
+
const disabled = wallet.provider ? !isAvailable(wallet.provider) : true;
|
|
58
|
+
return ((0, jsx_runtime_1.jsx)("button", { id: `connect-${wallet.label}`, "data-tooltip-content": wallet.label, "data-tooltip-id": "wallet-tip", className: (0, clsx_1.default)({
|
|
59
|
+
"transparent block pointer": true,
|
|
60
|
+
medium: modalLayout,
|
|
61
|
+
"desaturate opacity-10": disabled,
|
|
62
|
+
}), onClick: () => {
|
|
63
|
+
if (disabled && wallet.url) {
|
|
64
|
+
window.open(wallet.url, "_blank");
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
wallet.provider && connect(wallet.provider).then(hideModal);
|
|
68
|
+
}, children: wallet.icon }, wallet.label));
|
|
69
|
+
};
|
|
70
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: (0, clsx_1.default)("rujira-header__wallets", {
|
|
71
|
+
"rujira-header__wallets--modal": modalLayout,
|
|
72
|
+
}), children: [(0, jsx_runtime_1.jsx)("span", { className: "tag tag--borderless tag--primary no-shrink rujira-header__wallets-support", "data-support-tooltip": t("rujiraSupportTooltip"), children: t("rujiraSupport") }), (0, jsx_runtime_1.jsx)("div", { className: "rujira-header__wallets-row", children: rujiraWallets.map(walletButton) }), (0, jsx_runtime_1.jsx)("hr", { className: "rujira-header__wallets-divider" }), (0, jsx_runtime_1.jsx)("span", { className: "tag tag--borderless tag--orange no-shrink rujira-header__wallets-support", "data-support-tooltip": t("limitedSupportTooltip"), children: t("limitedSupport") }), (0, jsx_runtime_1.jsx)("div", { className: "rujira-header__wallets-row", children: otherWallets.map(walletButton) }), (0, jsx_runtime_1.jsx)("hr", { className: (0, clsx_1.default)({
|
|
89
73
|
hr: true,
|
|
90
74
|
"mt-0 mb-1": !modalLayout,
|
|
91
75
|
"my-2": modalLayout,
|
|
92
|
-
}) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { as: routingElement, to: "
|
|
76
|
+
}) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { as: routingElement, to: "/tou", className: "terms mb-1", children: "By connecting a wallet, you agree to Rujira's Terms of Use." }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { as: routingElement, to: "/connect", onClick: hideModal, children: t("needHelpDeciding") })] }), (0, jsx_runtime_1.jsx)(react_tooltip_1.Tooltip, { id: "wallet-tip", className: "tooltip" })] }));
|
|
93
77
|
};
|
|
94
78
|
exports.Wallets = Wallets;
|
|
95
79
|
const MyAccount = ({ provider, children, onHide, routingElement, value, }) => {
|
|
@@ -183,11 +183,11 @@ const SubTrade = ({ domain, routingElement, useRef, className, staticRoutes, })
|
|
|
183
183
|
};
|
|
184
184
|
const SubEarn = ({ domain, routingElement, useRef, className, staticRoutes, }) => {
|
|
185
185
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
186
|
-
return ((0, jsx_runtime_1.jsx)(Popup, { useRef: useRef, className: className, children: (0, jsx_runtime_1.jsxs)("div", { className: "grid w-60 mt-1", children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("
|
|
186
|
+
return ((0, jsx_runtime_1.jsx)(Popup, { useRef: useRef, className: className, children: (0, jsx_runtime_1.jsxs)("div", { className: "grid w-60 mt-1", children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("stake/RUJI"), domain: domain, to: "stake/RUJI", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Stake, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("stake") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("stakeDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("trade"), domain: domain, to: "/trade/BTC/USDC?orders=range", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Binary, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("algorithmicTrading") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("algorithmicTradingDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("lending"), domain: domain, to: "lend", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Lend, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("lending") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("lendingDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("liquidate"), domain: domain, to: "liquidate", className: "flex", children: [(0, jsx_runtime_1.jsx)(Icons_1.Gavel, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("liquidate") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("liquidateDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("strategies"), domain: domain, to: "strategies", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Building, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("strategies") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("strategiesDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("launchpad"), domain: domain, to: "launchpad", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Seedling, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600 flex ai-c", children: t("launchpad") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("launchpadDesc") })] })] })] }) }));
|
|
187
187
|
};
|
|
188
188
|
const SubBorrow = ({ domain, routingElement, useRef, className, staticRoutes, }) => {
|
|
189
189
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
190
|
-
return ((0, jsx_runtime_1.jsx)(Popup, { useRef: useRef, className: className, children: (0, jsx_runtime_1.jsxs)("div", { className: "grid w-60 mt-1", children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("borrow"), domain: domain, to: "borrow", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.MoneyTransfer, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600 flex ai-c", children: t("borrowMenu") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("borrowDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("mint"), domain: domain, to: "mint", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Deposit, { className: "color-grey h-a w-3 block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("mintStablecoin") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("mintStablecoinDesc") })] })] })] }) }));
|
|
190
|
+
return ((0, jsx_runtime_1.jsx)(Popup, { useRef: useRef, className: className, children: (0, jsx_runtime_1.jsxs)("div", { className: "grid w-60 mt-1", children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("borrow"), domain: domain, to: "/borrow/BTC/USDC", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.MoneyTransfer, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600 flex ai-c", children: t("borrowMenu") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("borrowDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("mint"), domain: domain, to: "mint", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Deposit, { className: "color-grey h-a w-3 block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("mintStablecoin") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("mintStablecoinDesc") })] })] })] }) }));
|
|
191
191
|
};
|
|
192
192
|
const SubUtilities = ({ domain, routingElement, useRef, className, staticRoutes, }) => {
|
|
193
193
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
@@ -199,5 +199,5 @@ const SubEntertainment = ({ domain, routingElement, useRef, className, staticRou
|
|
|
199
199
|
};
|
|
200
200
|
const SubLearn = ({ domain, routingElement, useRef, className, staticRoutes, }) => {
|
|
201
201
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
202
|
-
return ((0, jsx_runtime_1.jsx)(Popup, { useRef: useRef, className: className, children: (0, jsx_runtime_1.jsxs)("div", { className: "grid w-60 mt-1", children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic:
|
|
202
|
+
return ((0, jsx_runtime_1.jsx)(Popup, { useRef: useRef, className: className, children: (0, jsx_runtime_1.jsxs)("div", { className: "grid w-60 mt-1", children: [(0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: true, domain: domain, to: "/get-started", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Graduate, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("getStarted") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("getStartedDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: true, domain: domain, to: "/discover-rujira", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Home, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("discoverRujira") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("discoverRujiraDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("support"), domain: domain, to: "/support", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Support, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("support") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("educationDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("faq"), domain: domain, to: "/faq", className: "flex", children: [(0, jsx_runtime_1.jsx)(Icons_1.Info, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("commonQuestions") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("supportDesc") })] })] }), (0, jsx_runtime_1.jsxs)(ResolveLink_1.ResolveLink, { as: routingElement, isStatic: staticRoutes?.includes("articles"), domain: domain, to: "/articles", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.History, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h4", { className: "fs-14 fw-600", children: t("articles") }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("articlesDesc") })] })] }), (0, jsx_runtime_1.jsxs)("a", { href: "https://docs.rujira.network/", target: "_blank", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Code, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h4", { className: "fs-14 fw-600 flex ai-c", children: [t("documentation"), " ", (0, jsx_runtime_1.jsx)(Icons_1.External, { className: "h-1.5 w-a ml-1" })] }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("documentationDesc") })] })] }), (0, jsx_runtime_1.jsxs)("a", { href: "https://docs.rujira.network/developers/getting-started", target: "_blank", className: "flex ai-s", children: [(0, jsx_runtime_1.jsx)(Icons_1.Terminal, { className: "color-grey h-3.5 w-a block mr-2 no-shrink mt-0" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h4", { className: "fs-14 fw-600 flex ai-c", children: [t("developers"), (0, jsx_runtime_1.jsx)(Icons_1.External, { className: "h-1.5 w-a ml-1" })] }), (0, jsx_runtime_1.jsx)("p", { className: "fs-12 mt-0.5", children: t("developersDesc") })] })] })] }) }));
|
|
203
203
|
};
|
|
@@ -10,6 +10,6 @@ const ResolveLink_1 = require("./ResolveLink");
|
|
|
10
10
|
const QuickLauncher = ({ domain, routingElement, }) => {
|
|
11
11
|
const { t } = (0, i18n_1.useTranslation)("header");
|
|
12
12
|
const [showMenu, setShowMenu] = (0, react_2.useState)(false);
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "rujira-header__quick", onMouseOver: () => setShowMenu(true), onMouseOut: () => setShowMenu(false), children: [(0, jsx_runtime_1.jsx)(Icons_1.Grid, {}), (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: showMenu && ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { className: "rujira-header__popup sub-nav fw-400 px-2 py-1.5", initial: { opacity: 0, marginTop: -4 }, animate: { opacity: 1, marginTop: 0 }, exit: { opacity: 0, marginTop: -4 }, children: [(0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "buy", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("buyCrypto") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "swap", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("tokenSwap") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "trade", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("spotTrading") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "options", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("options") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "/perps", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("perps") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "rujira-header__quick", onMouseOver: () => setShowMenu(true), onMouseOut: () => setShowMenu(false), children: [(0, jsx_runtime_1.jsx)(Icons_1.Grid, {}), (0, jsx_runtime_1.jsx)(react_1.AnimatePresence, { children: showMenu && ((0, jsx_runtime_1.jsxs)(react_1.motion.div, { className: "rujira-header__popup sub-nav fw-400 px-2 py-1.5", initial: { opacity: 0, marginTop: -4 }, animate: { opacity: 1, marginTop: 0 }, exit: { opacity: 0, marginTop: -4 }, children: [(0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "buy", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("buyCrypto") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "swap", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("tokenSwap") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "trade", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("spotTrading") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "options", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("options") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "/perps", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("perps") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "stake/RUJI", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("stake") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "lp", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("liquidityPools") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "money-market", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("lendAndBorrow") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "liquidate", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("liquidate") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "ventures", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("ventures") }) }), (0, jsx_runtime_1.jsx)(ResolveLink_1.ResolveLink, { domain: domain, as: routingElement, to: "nfts", children: (0, jsx_runtime_1.jsx)("span", { className: "fs-12 fw-500", children: t("collections") }) })] })) })] }));
|
|
14
14
|
};
|
|
15
15
|
exports.QuickLauncher = QuickLauncher;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GitLab = exports.GitHub = exports.Gear = exports.Gavel = exports.Gamepad = exports.Eye = exports.EyeSlash = exports.ExclamationTriangle = exports.ExclamationCircle = exports.External = exports.Ellipsis = exports.Edit = exports.Earth = exports.Discord = exports.Deposit = exports.CreditCard = exports.Combine = exports.Copy = exports.Coins = exports.Code = exports.ClaimSolid = exports.ClaimAll = exports.Claim = exports.CirclesXMark = exports.CircleXMark = exports.CircleUser = exports.CirclePen = exports.Check = exports.ChartUser = exports.ChartUp = exports.ChartUpDown = exports.ChartMixed = exports.Chart = exports.Building = exports.Bolt = exports.Book = exports.BinarySlash = exports.Binary = exports.ArrowUpRight = exports.ArrowUp = exports.ArrowRight = exports.ArrowRightLeft = exports.ArrowLeft = exports.ArrowDown = exports.AngleUpDown = exports.AngleUp = exports.AnglesRight = exports.AngleRight = exports.AngleLeft = exports.AngleDown = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.Xmark = exports.X = exports.Withdraw = exports.Wink = exports.Window = exports.Wallet = exports.Users = exports.Unlocked = exports.Undo = exports.Trophy = exports.TrendUp = exports.TrendDown = exports.Tortoise = exports.Timer = exports.Terminal = exports.Telegram = exports.Swap = exports.Support = exports.Stopwatch = exports.StarAlt = void 0;
|
|
4
|
+
exports.StarSolid = exports.Stake = exports.StakePlus = exports.StakeMinus = exports.Split = exports.SortUp = exports.SortDown = exports.SortDesc = exports.Sliders = exports.Sort = exports.ShieldX = exports.ShieldCheck = exports.Share = exports.Seedling = exports.Rotate = exports.Rocket = exports.Rabbit = exports.Plus = exports.Play = exports.PieChart = exports.Pause = exports.Orca = exports.NFT = exports.NoGas = exports.Nodes = exports.MoneyTransfer = exports.MinusCircle = exports.Minus = exports.MessageCode = exports.Merge = exports.YouTube = exports.TikTok = exports.Reddit = exports.LinkedIn = exports.Instagram = exports.Medium = exports.Locked = exports.Lend = exports.LinkConnect = exports.LinkDisconnect = exports.LinkAngle = exports.Key = exports.Info = exports.Href = exports.Home = exports.History = exports.Grid = exports.Graduate = exports.Glass = exports.GlassChart = void 0;
|
|
5
|
+
exports.Xmark = exports.X = exports.Withdraw = exports.Wink = exports.Window = exports.Wallet = exports.Users = exports.Unlocked = exports.Undo = exports.Trophy = exports.TrendUp = exports.TrendDown = exports.Tortoise = exports.Timer = exports.Terminal = exports.Telegram = exports.Swap = exports.Support = exports.Stopwatch = exports.StarAlt = exports.Star = void 0;
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const SVG = ({ d, children, ...rest }) => ((0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 640 640", ...rest, children: [d && (0, jsx_runtime_1.jsx)("path", { fill: "currentColor", fillRule: "nonzero", d: d }), children] }));
|
|
@@ -192,6 +192,9 @@ exports.LinkDisconnect.displayName = "LinkDisconnect";
|
|
|
192
192
|
const _LinkConnect = (props) => ((0, jsx_runtime_1.jsx)(SVG, { ...props, d: "M128 128C57.3 128 0 185.3 0 256s57.3 128 128 128h32c8.8 0 16-7.2 16-16s-7.2-16-16-16h-32c-53 0-96-43-96-96s43-96 96-96h176.1c52.9 0 95.9 42.9 95.9 95.9 0 50.3-38.9 92-89 95.6l-8.1.6c-8.8.6-15.4 8.3-14.8 17.1.6 8.8 8.3 15.4 17.1 14.8l8.1-.6c66.9-4.8 118.7-60.5 118.7-127.5 0-70.7-57.2-127.9-127.9-127.9H128Zm384 384c70.7 0 128-57.3 128-128s-57.3-128-128-128h-32c-8.8 0-16 7.2-16 16s7.2 16 16 16h32c53 0 96 43 96 96s-43 96-96 96H335.9c-52.9 0-95.9-42.9-95.9-95.9 0-50.3 38.9-92 89-95.6l8.1-.6c8.8-.6 15.4-8.3 14.8-17.1-.6-8.8-8.3-15.4-17.1-14.8l-8.1.6C259.8 261.4 208 317.1 208 384.1c0 70.7 57.2 127.9 127.9 127.9H512Z" }));
|
|
193
193
|
exports.LinkConnect = (0, react_1.memo)(_LinkConnect);
|
|
194
194
|
exports.LinkConnect.displayName = "LinkConnect";
|
|
195
|
+
const _Lend = (props) => ((0, jsx_runtime_1.jsx)(SVG, { ...props, d: "M304 320c61.856 0 112-50.144 112-112S365.856 96 304 96s-112 50.144-112 112 50.144 112 112 112Zm0-256c79.529 0 144 64.471 144 144s-64.471 144-144 144-144-64.471-144-144S224.471 64 304 64Zm-23.2 111.4c-.4.7-.9 1.6-.8 3.6v.1c0 .4 0 1.9 4.8 4.5 5.6 3 13.5 5.2 23.9 8.2h.2c9.3 2.6 21.1 6 30.5 11.5 10.2 6 20 16.1 20.5 32.3.5 18.2-9.7 30.4-21.7 36.9-5.8 3.1-12.1 5.1-18.3 6.2v10.8c0 8.8-7.2 16-16 16s-16-7.2-16-16v-11.4c-8.6-1.7-16.7-4.3-23.7-6.6-1.7-.6-3.4-1.1-5-1.6-8.4-2.6-13.1-11.6-10.5-20 2.6-8.4 11.6-13.1 20-10.5 2 .6 3.9 1.2 5.8 1.8 11.5 3.6 20.4 6.5 29.9 6.8 6.7.2 13.8-1.1 18.5-3.6 2.2-1.2 3.4-2.4 4-3.3.5-.8 1.1-2.1 1-4.5 0-1.4-.2-3-4.7-5.6-5.3-3.1-12.9-5.4-23.2-8.3l-1.8-.5c-8.9-2.5-19.8-5.6-28.6-10.3-9.9-5.3-20.6-14.7-21.6-30.7-1.2-18.8 10-30.9 21.8-37.2 5.7-3.1 12-5.1 18-6.3v-9.5c0-8.8 7.2-16 16-16s16 7.2 16 16v9.4c6.3.9 12.3 2.3 17.9 3.7 8.6 2.1 13.8 10.8 11.7 19.4-2.1 8.6-10.8 13.8-19.4 11.7-9.3-2.3-18.2-4-26.4-4.1-6.2-.1-13.6 1.3-18.7 4-2.4 1.3-3.6 2.5-4.2 3.4l.1-.3Zm-97.8 206c13.1-8.8 28.6-13.4 44.4-13.4H376c30.9 0 56 25.1 56 56 0 8.6-1.9 16.7-5.4 24h5.6l94.7-56.4c8.3-4.9 17.8-7.6 27.5-7.6h1.3c28.9 0 52.3 23.4 52.3 52.3 0 17.7-9 34.2-23.8 43.8l-119.6 77.8c-18.2 11.8-39.4 18.1-61 18.1H48c-8.8 0-16-7.2-16-16s7.2-16 16-16h355.5c15.5 0 30.6-4.5 43.6-12.9l119.6-77.8c5.8-3.7 9.2-10.2 9.2-17 0-11.2-9.1-20.3-20.3-20.3h-1.3c-3.9 0-7.7 1.1-11.1 3l-98.5 58.7c-2.5 1.5-5.3 2.3-8.2 2.3H288c-8.8 0-16-7.2-16-16s7.2-16 16-16h88c13.3 0 24-10.7 24-24s-10.7-24-24-24H227.4c-9.5 0-18.7 2.8-26.6 8.1l-79.9 53.2c-2.6 1.8-5.7 2.7-8.9 2.7H48c-8.8 0-16-7.2-16-16s7.2-16 16-16h59.2l75.8-50.6Z" }));
|
|
196
|
+
exports.Lend = (0, react_1.memo)(_Lend);
|
|
197
|
+
exports.Lend.displayName = "Lend";
|
|
195
198
|
const _Locked = (props) => ((0, jsx_runtime_1.jsx)(SVG, { ...props, d: "M320 96c53 0 96 43 96 96v64H224v-64c0-53 43-96 96-96Zm-128 96v64h-16c-44.2 0-80 35.8-80 80v160c0 44.2 35.8 80 80 80h288c44.2 0 80-35.8 80-80V336c0-44.2-35.8-80-80-80h-16v-64c0-70.7-57.3-128-128-128s-128 57.3-128 128Zm-16 96h288c26.5 0 48 21.5 48 48v160c0 26.5-21.5 48-48 48H176c-26.5 0-48-21.5-48-48V336c0-26.5 21.5-48 48-48Zm160 88c0-8.8-7.2-16-16-16s-16 7.2-16 16v80c0 8.8 7.2 16 16 16s16-7.2 16-16v-80Z" }));
|
|
196
199
|
exports.Locked = (0, react_1.memo)(_Locked);
|
|
197
200
|
exports.Locked.displayName = "Locked";
|
|
@@ -4,9 +4,23 @@ exports.Decimal = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const clsx_1 = require("clsx");
|
|
6
6
|
const helpers_1 = require("../../helpers");
|
|
7
|
-
const Decimal = ({ amount, decimals = 8, round = 6, symbol, symbolLeft, padSymbol = true, className, onClick, as: Component = "div", symbolClassName, subscript, }) => {
|
|
7
|
+
const Decimal = ({ amount, decimals = 8, round = 6, symbol, symbolLeft, padSymbol = true, className, onClick, as: Component = "div", symbolClassName, subscript, clip = false, }) => {
|
|
8
8
|
const normalizedAmount = typeof amount === "bigint" ? amount : BigInt(amount || 0);
|
|
9
9
|
const normalizedDecimals = Number(decimals) || 0;
|
|
10
|
+
const componentClass = (0, clsx_1.default)({
|
|
11
|
+
decimal: true,
|
|
12
|
+
"decimal--label-left": symbolLeft,
|
|
13
|
+
"decimal--no-pad": !padSymbol,
|
|
14
|
+
[`${className}`]: className,
|
|
15
|
+
});
|
|
16
|
+
const symbolEl = symbol && ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)({
|
|
17
|
+
decimal__symbol: true,
|
|
18
|
+
[`${symbolClassName}`]: symbolClassName,
|
|
19
|
+
}), children: symbol }));
|
|
20
|
+
if (clip) {
|
|
21
|
+
const { intStr, sep, decStr } = (0, helpers_1.clipAmount)(normalizedAmount, normalizedDecimals);
|
|
22
|
+
return ((0, jsx_runtime_1.jsxs)(Component, { className: componentClass, onClick: onClick, children: [(0, jsx_runtime_1.jsxs)("span", { className: "decimal__int", children: [intStr, sep && (0, helpers_1.whatDecimalSeparator)()] }), sep && (0, jsx_runtime_1.jsx)("span", { className: "decimal__dec", children: decStr }), symbolEl] }));
|
|
23
|
+
}
|
|
10
24
|
const scale = 10n ** BigInt(normalizedDecimals);
|
|
11
25
|
const dec = normalizedAmount % scale;
|
|
12
26
|
const int = normalizedAmount / scale;
|
|
@@ -20,14 +34,6 @@ const Decimal = ({ amount, decimals = 8, round = 6, symbol, symbolLeft, padSymbo
|
|
|
20
34
|
}
|
|
21
35
|
const truncated = subscript && needsSubscript ? (0, helpers_1.compress)(padded) : padded;
|
|
22
36
|
const trimmed = truncated.substring(0, round);
|
|
23
|
-
return ((0, jsx_runtime_1.jsxs)(Component, { className: (0,
|
|
24
|
-
decimal: true,
|
|
25
|
-
"decimal--label-left": symbolLeft,
|
|
26
|
-
"decimal--no-pad": !padSymbol,
|
|
27
|
-
[`${className}`]: className,
|
|
28
|
-
}), onClick: onClick, children: [(0, jsx_runtime_1.jsxs)("span", { className: "decimal__int", children: [(int || "0").toLocaleString(), round > 0 && (0, helpers_1.whatDecimalSeparator)()] }), dec.toString().length && round > 0 && ((0, jsx_runtime_1.jsx)("span", { className: "decimal__dec", children: trimmed })), symbol && ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)({
|
|
29
|
-
decimal__symbol: true,
|
|
30
|
-
[`${symbolClassName}`]: symbolClassName,
|
|
31
|
-
}), children: symbol }))] }));
|
|
37
|
+
return ((0, jsx_runtime_1.jsxs)(Component, { className: componentClass, onClick: onClick, children: [(0, jsx_runtime_1.jsxs)("span", { className: "decimal__int", children: [(int || "0").toLocaleString(), round > 0 && (0, helpers_1.whatDecimalSeparator)()] }), dec.toString().length && round > 0 && ((0, jsx_runtime_1.jsx)("span", { className: "decimal__dec", children: trimmed })), symbolEl] }));
|
|
32
38
|
};
|
|
33
39
|
exports.Decimal = Decimal;
|
|
@@ -4,19 +4,25 @@ exports.Fiat = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const clsx_1 = require("clsx");
|
|
6
6
|
const helpers_1 = require("../../helpers");
|
|
7
|
-
const Fiat = ({ amount, decimals = 2, symbol, className, symbolRight = false, padSymbol = true, symbolSmall = false, as: Component = "div", }) => {
|
|
7
|
+
const Fiat = ({ amount, decimals = 2, symbol, className, symbolRight = false, padSymbol = true, symbolSmall = false, as: Component = "div", clip = false, }) => {
|
|
8
|
+
const componentClass = (0, clsx_1.default)({
|
|
9
|
+
fiat: true,
|
|
10
|
+
"fiat--symbol-right": symbolRight,
|
|
11
|
+
[`${className}`]: className,
|
|
12
|
+
});
|
|
13
|
+
const symbolEl = symbol && ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)({
|
|
14
|
+
fiat__symbol: true,
|
|
15
|
+
"fiat__symbol--small": symbolSmall,
|
|
16
|
+
"mr-0.5": padSymbol && !symbolRight,
|
|
17
|
+
"ml-0.5": padSymbol && symbolRight,
|
|
18
|
+
}), children: symbol }));
|
|
19
|
+
if (clip) {
|
|
20
|
+
const { intStr, sep, decStr } = (0, helpers_1.clipAmount)(amount, decimals);
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(Component, { className: componentClass, children: [(0, jsx_runtime_1.jsxs)("span", { className: "fiat__int", children: [intStr, sep && (0, helpers_1.whatDecimalSeparator)()] }), sep && (0, jsx_runtime_1.jsx)("span", { className: "fiat__dec", children: decStr }), symbolEl] }));
|
|
22
|
+
}
|
|
8
23
|
const dec = amount % BigInt(10 ** decimals);
|
|
9
24
|
const int = BigInt(Math.floor(Number(amount - dec) / 10 ** decimals));
|
|
10
25
|
const round = 2;
|
|
11
|
-
return ((0, jsx_runtime_1.jsxs)(Component, { className: (0,
|
|
12
|
-
fiat: true,
|
|
13
|
-
"fiat--symbol-right": symbolRight,
|
|
14
|
-
[`${className}`]: className,
|
|
15
|
-
}), children: [(0, jsx_runtime_1.jsxs)("span", { className: "fiat__int", children: [(int || "0").toLocaleString(), (0, helpers_1.whatDecimalSeparator)()] }), (0, jsx_runtime_1.jsx)("span", { className: "fiat__dec", children: dec.toString().padStart(decimals, "0").substring(0, round) }), symbol && ((0, jsx_runtime_1.jsx)("span", { className: (0, clsx_1.default)({
|
|
16
|
-
fiat__symbol: true,
|
|
17
|
-
"fiat__symbol--small": symbolSmall,
|
|
18
|
-
"mr-0.5": padSymbol && !symbolRight,
|
|
19
|
-
"ml-0.5": padSymbol && symbolRight,
|
|
20
|
-
}), children: symbol }))] }));
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(Component, { className: componentClass, children: [(0, jsx_runtime_1.jsxs)("span", { className: "fiat__int", children: [(int || "0").toLocaleString(), (0, helpers_1.whatDecimalSeparator)()] }), (0, jsx_runtime_1.jsx)("span", { className: "fiat__dec", children: dec.toString().padStart(decimals, "0").substring(0, round) }), symbolEl] }));
|
|
21
27
|
};
|
|
22
28
|
exports.Fiat = Fiat;
|
package/lib/cjs/helpers/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.bigIntToDecimalString = exports.floatToSubscript = exports.compress = exports.classApr = exports.formatApr = exports.nFormatterInt = exports.nFormatter = exports.uuidv4 = exports.isEmpty = exports.whatDecimalSeparator = exports.getLang = void 0;
|
|
4
|
+
exports.clipFloat = clipFloat;
|
|
5
|
+
exports.clipAmount = clipAmount;
|
|
4
6
|
const getLang = () => {
|
|
5
7
|
if (navigator.languages != undefined)
|
|
6
8
|
return navigator.languages[0];
|
|
@@ -151,6 +153,62 @@ const floatToSubscript = (floatValue, rounding, fractionDigits) => {
|
|
|
151
153
|
return intPart + separator + trimmed;
|
|
152
154
|
};
|
|
153
155
|
exports.floatToSubscript = floatToSubscript;
|
|
156
|
+
function clipFloat(value) {
|
|
157
|
+
if (!isFinite(value) || value === 0)
|
|
158
|
+
return "0";
|
|
159
|
+
const abs = Math.abs(value);
|
|
160
|
+
const sign = value < 0 ? "-" : "";
|
|
161
|
+
const sep = (0, exports.whatDecimalSeparator)();
|
|
162
|
+
if (abs >= 1000)
|
|
163
|
+
return sign + Math.round(abs).toLocaleString();
|
|
164
|
+
if (abs >= 100)
|
|
165
|
+
return sign + abs.toLocaleDecimal(1);
|
|
166
|
+
if (abs >= 10)
|
|
167
|
+
return sign + abs.toLocaleDecimal(2);
|
|
168
|
+
if (abs >= 1)
|
|
169
|
+
return sign + abs.toLocaleDecimal(3);
|
|
170
|
+
if (abs >= 0.1)
|
|
171
|
+
return sign + abs.toLocaleDecimal(4);
|
|
172
|
+
// < 0.1: 4 significant figures, subscript notation if > 3 leading zeros
|
|
173
|
+
const leadingZeros = Math.max(0, -Math.floor(Math.log10(abs)) - 1);
|
|
174
|
+
const totalDecimals = leadingZeros + 4;
|
|
175
|
+
const formatted = abs.toLocaleString(undefined, {
|
|
176
|
+
minimumFractionDigits: totalDecimals,
|
|
177
|
+
maximumFractionDigits: totalDecimals,
|
|
178
|
+
});
|
|
179
|
+
const [intPart, decPart] = formatted.split(sep);
|
|
180
|
+
return sign + (intPart ?? "0") + sep + (0, exports.compress)((decPart ?? "").replace(/0+$/, ""));
|
|
181
|
+
}
|
|
182
|
+
function clipAmount(amount, decimals) {
|
|
183
|
+
const scale = 10n ** BigInt(decimals);
|
|
184
|
+
const intPart = amount / scale;
|
|
185
|
+
const fracPart = amount % scale;
|
|
186
|
+
const fracStr = fracPart.toString().padStart(decimals, "0");
|
|
187
|
+
const intNum = Number(intPart);
|
|
188
|
+
const withDec = (raw, int = String(intNum)) => ({
|
|
189
|
+
intStr: int,
|
|
190
|
+
sep: true,
|
|
191
|
+
decStr: raw,
|
|
192
|
+
});
|
|
193
|
+
if (intNum >= 1000)
|
|
194
|
+
return { intStr: (intPart || "0").toLocaleString(), sep: false, decStr: "" };
|
|
195
|
+
if (intNum >= 100)
|
|
196
|
+
return withDec(fracStr.substring(0, 1));
|
|
197
|
+
if (intNum >= 10)
|
|
198
|
+
return withDec(fracStr.substring(0, 2));
|
|
199
|
+
if (intNum >= 1)
|
|
200
|
+
return withDec(fracStr.substring(0, 3));
|
|
201
|
+
if (fracPart === 0n)
|
|
202
|
+
return { intStr: "0", sep: false, decStr: "" };
|
|
203
|
+
const leadingZeros = (fracStr.match(/^(0*)/) ?? ["", ""])[1].length;
|
|
204
|
+
if (leadingZeros === 0)
|
|
205
|
+
return withDec(fracStr.substring(0, 4).replace(/0+$/, ""), "0");
|
|
206
|
+
// < 0.1: 4 significant figures, trailing zeros trimmed
|
|
207
|
+
const sigFigStr = fracStr.substring(0, leadingZeros + 4).replace(/0+$/, "");
|
|
208
|
+
if (leadingZeros > 3)
|
|
209
|
+
return { intStr: "0", sep: true, decStr: (0, exports.compress)(sigFigStr) };
|
|
210
|
+
return { intStr: "0", sep: true, decStr: sigFigStr };
|
|
211
|
+
}
|
|
154
212
|
/**
|
|
155
213
|
* A function that uses string manipulation to convert a bigint into a floating point number,
|
|
156
214
|
* avoiding the floating points maths issues that sometimes arise when generating this number
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Add the method to the Number prototype
|
|
3
|
-
Number.prototype.toLocaleDecimal = function (decimals = 0) {
|
|
3
|
+
Number.prototype.toLocaleDecimal = function (decimals = 0, shrink = false) {
|
|
4
4
|
return this.toLocaleString(undefined, {
|
|
5
5
|
maximumFractionDigits: decimals,
|
|
6
|
-
minimumFractionDigits: decimals,
|
|
6
|
+
minimumFractionDigits: shrink ? 0 : decimals,
|
|
7
7
|
});
|
|
8
8
|
};
|