rujira.ui 1.0.1 → 1.0.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/lib/esm/wallets/providers/ton.js +1 -1
- package/package.json +1 -1
- package/src/wallets/providers/ton.ts +1 -1
- package/lib/cjs/assets/tokens/index.js +0 -21
- package/lib/cjs/components/AssetLabel.js +0 -9
- package/lib/cjs/components/balance/OmniBalance.js +0 -28
- package/lib/cjs/components/bridges/BuyModal.js +0 -8
- package/lib/cjs/components/bridges/DepositModal.js +0 -131
- package/lib/cjs/components/buttons/Button.js +0 -52
- package/lib/cjs/components/buttons/Popout.js +0 -63
- package/lib/cjs/components/buttons/TxButton.js +0 -171
- package/lib/cjs/components/buttons/__Popout.js +0 -39
- package/lib/cjs/components/cards/Card.js +0 -12
- package/lib/cjs/components/cards/GradientCard.js +0 -12
- package/lib/cjs/components/cards/ShareCard.js +0 -16
- package/lib/cjs/components/chart/RangeLiquidityChart.js +0 -118
- package/lib/cjs/components/footer/Footer.js +0 -15
- package/lib/cjs/components/header/Accounts.js +0 -129
- package/lib/cjs/components/header/Header.js +0 -197
- package/lib/cjs/components/header/Pending.js +0 -47
- package/lib/cjs/components/header/QuickLauncher.js +0 -15
- package/lib/cjs/components/header/ResolveLink.js +0 -17
- package/lib/cjs/components/icons/IconDenom.js +0 -391
- package/lib/cjs/components/icons/Icons.js +0 -350
- package/lib/cjs/components/icons/NetworkIcon.js +0 -44
- package/lib/cjs/components/icons/Networks.js +0 -145
- package/lib/cjs/components/icons/Wallets.js +0 -140
- package/lib/cjs/components/inputs/Checkbox.js +0 -15
- package/lib/cjs/components/inputs/DecimalInput.js +0 -53
- package/lib/cjs/components/inputs/DenomInput.js +0 -29
- package/lib/cjs/components/inputs/Input.js +0 -29
- package/lib/cjs/components/inputs/Numeric.js +0 -24
- package/lib/cjs/components/inputs/Radio.js +0 -15
- package/lib/cjs/components/inputs/Select.js +0 -32
- package/lib/cjs/components/inputs/SwapSelect.js +0 -85
- package/lib/cjs/components/inputs/Textarea.js +0 -28
- package/lib/cjs/components/inputs/Toggle.js +0 -17
- package/lib/cjs/components/loader/Loader.js +0 -9
- package/lib/cjs/components/logos/RujiraLogo.js +0 -10
- package/lib/cjs/components/notices/Warning.js +0 -14
- package/lib/cjs/components/numbers/Decimal.js +0 -30
- package/lib/cjs/components/numbers/Fiat.js +0 -22
- package/lib/cjs/components/pagination/Pagination.js +0 -15
- package/lib/cjs/components/progress/Progress.js +0 -13
- package/lib/cjs/components/slider/Slider.js +0 -9
- package/lib/cjs/components/table/SortItem.js +0 -52
- package/lib/cjs/context/GlobalModal.js +0 -48
- package/lib/cjs/helpers/index.js +0 -167
- package/lib/cjs/helpers/number.js +0 -8
- package/lib/cjs/hooks/useClickOutside.js +0 -22
- package/lib/cjs/hooks/useEventCallback.js +0 -14
- package/lib/cjs/hooks/useEventListener.js +0 -57
- package/lib/cjs/hooks/useIsTouchDevice.js +0 -20
- package/lib/cjs/hooks/useIsomorphicLayoutEffect.js +0 -18
- package/lib/cjs/hooks/useLocalStorage.js +0 -123
- package/lib/cjs/hooks/useQueryParam.js +0 -36
- package/lib/cjs/hooks/useWindowSize.js +0 -51
- package/lib/cjs/i18n/I18nProvider.js +0 -54
- package/lib/cjs/i18n/TranslationProvider.js +0 -10
- package/lib/cjs/i18n/config.js +0 -101
- package/lib/cjs/i18n/index.js +0 -16
- package/lib/cjs/i18n/locales/de/borrow.json +0 -50
- package/lib/cjs/i18n/locales/de/common.json +0 -107
- package/lib/cjs/i18n/locales/de/ecosystem.json +0 -56
- package/lib/cjs/i18n/locales/de/header.json +0 -86
- package/lib/cjs/i18n/locales/de/index.json +0 -57
- package/lib/cjs/i18n/locales/de/leagues.json +0 -20
- package/lib/cjs/i18n/locales/de/merge.json +0 -41
- package/lib/cjs/i18n/locales/de/portfolio.json +0 -97
- package/lib/cjs/i18n/locales/de/strategies.json +0 -159
- package/lib/cjs/i18n/locales/de/swap.json +0 -30
- package/lib/cjs/i18n/locales/de/trade.json +0 -188
- package/lib/cjs/i18n/locales/en/borrow.json +0 -50
- package/lib/cjs/i18n/locales/en/common.json +0 -107
- package/lib/cjs/i18n/locales/en/ecosystem.json +0 -56
- package/lib/cjs/i18n/locales/en/header.json +0 -86
- package/lib/cjs/i18n/locales/en/index.json +0 -57
- package/lib/cjs/i18n/locales/en/leagues.json +0 -20
- package/lib/cjs/i18n/locales/en/merge.json +0 -41
- package/lib/cjs/i18n/locales/en/portfolio.json +0 -97
- package/lib/cjs/i18n/locales/en/strategies.json +0 -159
- package/lib/cjs/i18n/locales/en/swap.json +0 -30
- package/lib/cjs/i18n/locales/en/trade.json +0 -188
- package/lib/cjs/i18n/useTranslation.js +0 -21
- package/lib/cjs/index.js +0 -70
- package/lib/cjs/package.json +0 -3
- package/lib/cjs/wallets/config/gaia.js +0 -51
- package/lib/cjs/wallets/config/index.js +0 -9
- package/lib/cjs/wallets/config/kujira.js +0 -62
- package/lib/cjs/wallets/config/noble.js +0 -47
- package/lib/cjs/wallets/config/osmo.js +0 -51
- package/lib/cjs/wallets/config/thor.js +0 -50
- package/lib/cjs/wallets/index.js +0 -19
- package/lib/cjs/wallets/providers/brave.js +0 -4
- package/lib/cjs/wallets/providers/coinbase.js +0 -4
- package/lib/cjs/wallets/providers/cosmos.js +0 -152
- package/lib/cjs/wallets/providers/ctrl.js +0 -125
- package/lib/cjs/wallets/providers/daodao.js +0 -12
- package/lib/cjs/wallets/providers/eip1193.js +0 -155
- package/lib/cjs/wallets/providers/eip6963.js +0 -20
- package/lib/cjs/wallets/providers/eip712.js +0 -63
- package/lib/cjs/wallets/providers/index.js +0 -62
- package/lib/cjs/wallets/providers/keplr.js +0 -82
- package/lib/cjs/wallets/providers/leap.js +0 -36
- package/lib/cjs/wallets/providers/ledger/Modal.js +0 -23
- package/lib/cjs/wallets/providers/ledger.js +0 -93
- package/lib/cjs/wallets/providers/metamask.js +0 -4
- package/lib/cjs/wallets/providers/okx.js +0 -79
- package/lib/cjs/wallets/providers/rabby.js +0 -4
- package/lib/cjs/wallets/providers/station.js +0 -6
- package/lib/cjs/wallets/providers/ton.js +0 -57
- package/lib/cjs/wallets/providers/tronlink.js +0 -58
- package/lib/cjs/wallets/providers/trust.js +0 -4
- package/lib/cjs/wallets/providers/utils.js +0 -32
- package/lib/cjs/wallets/providers/utxo.js +0 -107
- package/lib/cjs/wallets/providers/vulticonnect.js +0 -157
- package/lib/cjs/wallets/providers/vultisig.js +0 -45
- package/lib/cjs/wallets/providers/xaman.js +0 -70
- package/lib/cjs/wallets/storage.js +0 -58
- package/lib/esm/package.json +0 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import TonConnect, { isWalletInfoCurrentlyEmbedded, isWalletInfoCurrentlyInjected, isWalletInfoRemote, } from "@tonconnect/sdk";
|
|
2
|
-
import { Address as TonAddress } from "ton-core
|
|
2
|
+
import { Address as TonAddress } from "ton-core";
|
|
3
3
|
class TonKeeper {
|
|
4
4
|
connector = new TonConnect({
|
|
5
5
|
manifestUrl: `https://next.rujira.network/tonconnect-manifest.json`,
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import TonConnect, {
|
|
|
5
5
|
Wallet,
|
|
6
6
|
} from "@tonconnect/sdk";
|
|
7
7
|
import { Address, Msg, Network, Signer, Simulation, TxResult } from "rujira.js";
|
|
8
|
-
import { Address as TonAddress } from "ton-core
|
|
8
|
+
import { Address as TonAddress } from "ton-core";
|
|
9
9
|
|
|
10
10
|
class TonKeeper implements Signer {
|
|
11
11
|
private connector = new TonConnect({
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wink = exports.rkuji = exports.nstk = exports.nami = exports.mnta = exports.lvn = exports.kuji = exports.fuzn = exports.auto = void 0;
|
|
4
|
-
const auto_png_1 = require("./auto.png");
|
|
5
|
-
exports.auto = auto_png_1.default;
|
|
6
|
-
const fuzn_png_1 = require("./fuzn.png");
|
|
7
|
-
exports.fuzn = fuzn_png_1.default;
|
|
8
|
-
const kuji_png_1 = require("./kuji.png");
|
|
9
|
-
exports.kuji = kuji_png_1.default;
|
|
10
|
-
const lvn_png_1 = require("./lvn.png");
|
|
11
|
-
exports.lvn = lvn_png_1.default;
|
|
12
|
-
const mnta_png_1 = require("./mnta.png");
|
|
13
|
-
exports.mnta = mnta_png_1.default;
|
|
14
|
-
const nami_png_1 = require("./nami.png");
|
|
15
|
-
exports.nami = nami_png_1.default;
|
|
16
|
-
const nstk_png_1 = require("./nstk.png");
|
|
17
|
-
exports.nstk = nstk_png_1.default;
|
|
18
|
-
const rkuji_png_1 = require("./rkuji.png");
|
|
19
|
-
exports.rkuji = rkuji_png_1.default;
|
|
20
|
-
const wink_png_1 = require("./wink.png");
|
|
21
|
-
exports.wink = wink_png_1.default;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AssetLabel = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const AssetLabel = ({ asset, Container }) => asset ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [asset.metadata.symbol, ((asset.metadata.symbol === "USDT" && asset.chain !== "ETH") ||
|
|
6
|
-
(asset.metadata.symbol === "ETH" && asset.chain !== "ETH") ||
|
|
7
|
-
(asset.metadata.symbol === "USDC" && asset.chain !== "ETH")) &&
|
|
8
|
-
asset.type === "SECURED" && (0, jsx_runtime_1.jsxs)(Container, { children: [".", asset.chain] })] })) : null;
|
|
9
|
-
exports.AssetLabel = AssetLabel;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OmniBalance = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const rujira_js_1 = require("rujira.js");
|
|
6
|
-
const helpers_1 = require("../../helpers");
|
|
7
|
-
const NetworkIcon_1 = require("../icons/NetworkIcon");
|
|
8
|
-
const Decimal_1 = require("../numbers/Decimal");
|
|
9
|
-
const accountSorter = (a, b) => {
|
|
10
|
-
const aIsSecured = a.asset.type === "SECURED";
|
|
11
|
-
const bIsSecured = b.asset.type === "SECURED";
|
|
12
|
-
if (aIsSecured && !bIsSecured)
|
|
13
|
-
return -1;
|
|
14
|
-
if (!aIsSecured && bIsSecured)
|
|
15
|
-
return 1;
|
|
16
|
-
return Number(b.balance - a.balance);
|
|
17
|
-
};
|
|
18
|
-
const OmniBalance = ({ balance, onClick, className, }) => {
|
|
19
|
-
const sortedAccounts = balance?.accounts
|
|
20
|
-
? [...balance.accounts].sort(accountSorter)
|
|
21
|
-
: [];
|
|
22
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "omni-balance", children: [(0, jsx_runtime_1.jsx)(Decimal_1.Decimal, { amount: balance?.balance || 0n, className: className, onClick: () => balance && onClick?.(balance) }), sortedAccounts.length > 1 && ((0, jsx_runtime_1.jsx)("div", { className: "omni-balance__networks", children: sortedAccounts.map((x) => {
|
|
23
|
-
const n = x.asset.type === "SECURED" ? "THOR" : x.asset.chain;
|
|
24
|
-
return ((0, jsx_runtime_1.jsx)("button", { "data-tooltip-id": "global-tip", "data-tooltip-html": `
|
|
25
|
-
<div class="condensed fs-16 fw-500">${(0, helpers_1.nFormatter)(x.balance, 6)}</div><div class="fs-14 lh-16 color-grey">on ${(0, rujira_js_1.networkLabel)(n)}</div>`, className: `omni-balance__network-button omni-balance__network-button--${n.toLowerCase()}`, onClick: () => onClick?.(x), children: (0, jsx_runtime_1.jsx)(NetworkIcon_1.NetworkIcon, { network: n }) }, n));
|
|
26
|
-
}) }))] }));
|
|
27
|
-
};
|
|
28
|
-
exports.OmniBalance = OmniBalance;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BuyModal = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const BuyModal = () => {
|
|
6
|
-
return (0, jsx_runtime_1.jsx)("h3", { className: "h3", children: "Buy Crypto" });
|
|
7
|
-
};
|
|
8
|
-
exports.BuyModal = BuyModal;
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DepositModal = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const rujira_js_1 = require("rujira.js");
|
|
7
|
-
const i18n_1 = require("../../i18n");
|
|
8
|
-
const IconDenom_1 = require("../icons/IconDenom");
|
|
9
|
-
const Icons_1 = require("../icons/Icons");
|
|
10
|
-
const Input_1 = require("../inputs/Input");
|
|
11
|
-
/* import { useClickOutside } from "../../hooks/useClickOutside";
|
|
12
|
-
import { BreakPoints, useWindowSize } from "../../hooks/useWindowSize";
|
|
13
|
-
import { AnimatePresence, motion } from "motion/react"; */
|
|
14
|
-
const clsx_1 = require("clsx");
|
|
15
|
-
const date_fns_1 = require("date-fns");
|
|
16
|
-
const react_hot_toast_1 = require("react-hot-toast");
|
|
17
|
-
const __1 = require("../..");
|
|
18
|
-
const deposited_gif_1 = require("../../assets/images/deposited.gif");
|
|
19
|
-
const filters_gif_1 = require("../../assets/images/filters.gif");
|
|
20
|
-
const filters_png_1 = require("../../assets/images/filters.png");
|
|
21
|
-
const swap_gif_1 = require("../../assets/images/swap.gif");
|
|
22
|
-
const Select_1 = require("../inputs/Select");
|
|
23
|
-
const DepositModal = ({ title = "deposit", options, targets, selected, dismiss, Submit, queryClient, amount, target, label, }) => {
|
|
24
|
-
const { t } = (0, i18n_1.useTranslation)("common");
|
|
25
|
-
const [token, setToken] = (0, react_1.useState)(selected ? selected.asset.metadata.symbol : undefined);
|
|
26
|
-
const [asset, setAsset] = (0, react_1.useState)(selected?.asset);
|
|
27
|
-
const [tx, setTx] = (0, react_1.useState)();
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "deposit-modal", children: [(token || asset) && !selected && !tx && ((0, jsx_runtime_1.jsxs)("button", { className: "transparent color-white hover-primary1 flex ai-c mb-1 fs-14 fw-500 pointer", onClick: () => {
|
|
29
|
-
setAsset(undefined);
|
|
30
|
-
setToken(undefined);
|
|
31
|
-
}, children: [(0, jsx_runtime_1.jsx)(Icons_1.AngleLeft, { className: "block w-2 h-2 mr-0.5" }), t("back")] })), (0, jsx_runtime_1.jsxs)("h3", { className: "h3 flex ai-b mb-0", children: [asset && ((0, jsx_runtime_1.jsx)(IconDenom_1.IconDenom, { denom: asset.metadata.symbol, className: "as-c w-4 h-4 mr-1" })), t(title), " ", asset && asset.metadata.symbol, asset && ((0, jsx_runtime_1.jsx)("small", { className: "ml-1 color-grey fw-400", children: t("toRujira") }))] }), label, (0, jsx_runtime_1.jsxs)("div", { className: "mt-3", children: [!token && ((0, jsx_runtime_1.jsx)(TokenSelect, { options: options, onSelect: (a) => {
|
|
32
|
-
setToken(a.metadata.symbol);
|
|
33
|
-
setAsset(a);
|
|
34
|
-
} })), asset && !tx && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(Confirm, { asset: asset, amount: amount, balance: selected ||
|
|
35
|
-
options.find((a) => a.asset.asset === asset.asset)?.balance, target: target, targets: targets, Submit: Submit, onSuccess: setTx, queryClient: queryClient }) })), tx && (0, jsx_runtime_1.jsx)(Success, { tx: tx, dismiss: dismiss })] })] }));
|
|
36
|
-
};
|
|
37
|
-
exports.DepositModal = DepositModal;
|
|
38
|
-
const TokenSelect = ({ options, onSelect }) => {
|
|
39
|
-
const { t } = (0, i18n_1.useTranslation)("common");
|
|
40
|
-
const [search, setSearch] = (0, react_1.useState)("");
|
|
41
|
-
const [all, setAll] = (0, react_1.useState)(!options.length);
|
|
42
|
-
const filtered = options.filter((i) => {
|
|
43
|
-
const q = i.asset.metadata.symbol
|
|
44
|
-
.toLowerCase()
|
|
45
|
-
.includes(search.toLowerCase());
|
|
46
|
-
return all ? q : q && i.balance;
|
|
47
|
-
});
|
|
48
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex", children: [(0, jsx_runtime_1.jsx)(Input_1.Input, { containerClassName: "grow", label: t("search"), value: search, onChange: (e) => setSearch(e.currentTarget.value), children: search !== "" && ((0, jsx_runtime_1.jsx)(Icons_1.MinusCircle, { className: "input-container__clear", onClick: () => setSearch("") })) }), (0, jsx_runtime_1.jsx)(__1.Toggle, { label: t("showAll"), className: "toggle--xs color-white as-c ml-1", checked: all, onChange: (e) => setAll(e.currentTarget.checked) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "deposit-modal__content row wrap pad-mini mt-1.5", children: [filtered.map((i) => ((0, jsx_runtime_1.jsx)("div", { className: "col-12 col-md-col-6", children: (0, jsx_runtime_1.jsxs)("button", { className: "card card--hover-border mt-0.5 mb-0.5 p-2 flex ai-c", onClick: () => {
|
|
49
|
-
onSelect(i.asset);
|
|
50
|
-
setSearch("");
|
|
51
|
-
}, children: [(0, jsx_runtime_1.jsx)(IconDenom_1.IconDenom, { denom: i.asset.metadata.symbol, className: "block w-4 h-4" }), (0, jsx_runtime_1.jsx)("p", { className: "ml-1 fw-600 color-white", children: i.asset.metadata.symbol }), (0, jsx_runtime_1.jsxs)("div", { className: "ml-a text-right", children: [i.balance ? ((0, jsx_runtime_1.jsx)("div", { className: "tag tag--teal tag--borderless", children: (0, jsx_runtime_1.jsx)(__1.Decimal, { amount: i.balance.balance, decimals: i.asset.metadata.decimals }) })) : null, (0, jsx_runtime_1.jsx)("br", {}), i.valueUsd ? ((0, jsx_runtime_1.jsx)("small", { className: "color-grey", children: (0, jsx_runtime_1.jsx)(__1.Fiat, { symbol: "$", className: "fs-12 mr-1", amount: i.valueUsd, decimals: i.asset.metadata.decimals }) })) : null] })] }) }, i.asset.asset))), filtered.length === 0 && ((0, jsx_runtime_1.jsx)("p", { className: "color-grey my-2 w-full text-center", children: t("noBalancesFound") }))] })] }));
|
|
52
|
-
};
|
|
53
|
-
const Confirm = ({ asset, balance, targets, target: target_, Submit, onSuccess, queryClient, amount: requestAmount, }) => {
|
|
54
|
-
const { t } = (0, i18n_1.useTranslation)("common");
|
|
55
|
-
const ref = (0, react_1.useRef)(null);
|
|
56
|
-
const [amount, setAmount] = (0, react_1.useState)(requestAmount || 0n);
|
|
57
|
-
const [target, setTarget] = (0, react_1.useState)(target_ || "");
|
|
58
|
-
const [custom, setCustom] = (0, react_1.useState)("");
|
|
59
|
-
const [direct, setDirect] = (0, react_1.useState)(false);
|
|
60
|
-
const [advanced, setAdvanced] = (0, react_1.useState)(false);
|
|
61
|
-
const [hoverAd, setHoverAd] = (0, react_1.useState)(false);
|
|
62
|
-
const [quote, setQuote] = (0, react_1.useState)();
|
|
63
|
-
const [account, setAccount] = (0, react_1.useState)(balance?.accounts[0]);
|
|
64
|
-
(0, react_1.useEffect)(() => {
|
|
65
|
-
if (ref.current && target === "custom") {
|
|
66
|
-
ref.current.focus();
|
|
67
|
-
}
|
|
68
|
-
}, [target, ref]);
|
|
69
|
-
const shouldSwap = asset.chain !== account?.asset.chain ||
|
|
70
|
-
asset.metadata.symbol !== account.asset.metadata.symbol;
|
|
71
|
-
// Determine the actual destination address
|
|
72
|
-
const destination = target === "custom" ? custom : target;
|
|
73
|
-
// Fetch swap quote when conditions are met
|
|
74
|
-
(0, react_1.useEffect)(() => {
|
|
75
|
-
setQuote(undefined);
|
|
76
|
-
if (!account)
|
|
77
|
-
return;
|
|
78
|
-
if (!shouldSwap)
|
|
79
|
-
return;
|
|
80
|
-
if (!amount)
|
|
81
|
-
return;
|
|
82
|
-
if (direct)
|
|
83
|
-
return;
|
|
84
|
-
setQuote("loading");
|
|
85
|
-
queryClient.thorchain
|
|
86
|
-
.getSwapQuote({
|
|
87
|
-
fromAsset: account.asset.asset,
|
|
88
|
-
toAsset: asset.asset,
|
|
89
|
-
amount: amount,
|
|
90
|
-
streamingInterval: 1n,
|
|
91
|
-
streamingQuantity: 0n,
|
|
92
|
-
destination,
|
|
93
|
-
})
|
|
94
|
-
.then(setQuote)
|
|
95
|
-
.catch(setQuote);
|
|
96
|
-
}, [account, amount, destination, asset, direct]);
|
|
97
|
-
const depositAmount = typeof quote === "object" && "memo" in quote
|
|
98
|
-
? quote.expectedAmountOut
|
|
99
|
-
: amount;
|
|
100
|
-
const depositFee = (typeof quote === "object" && "memo" in quote && quote.fees?.total) || 0n;
|
|
101
|
-
const price = asset.price?.current || 0n;
|
|
102
|
-
const feeValue = price ? (price * depositFee) / 10n ** 12n : 0n;
|
|
103
|
-
const receivedValue = price ? (price * depositAmount) / 10n ** 12n : 0n;
|
|
104
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [balance && balance.accounts.length > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h2", { className: "fs-14 fw-500 color-grey mb-1 ml-1", children: t("selectSourceAccount") }), (0, jsx_runtime_1.jsx)("div", { className: "br-1 p-2 bg-black mb-2 flex dir-c gap-y-1", children: balance.accounts.map((x) => ((0, jsx_runtime_1.jsxs)("div", { onClick: () => {
|
|
105
|
-
setAccount(x);
|
|
106
|
-
}, className: (0, clsx_1.default)({
|
|
107
|
-
"flex ai-c fs-14 condensed pointer": true,
|
|
108
|
-
"color-grey": account !== x,
|
|
109
|
-
"color-white": account === x,
|
|
110
|
-
}), children: [(0, jsx_runtime_1.jsx)(__1.Radio, { checked: account === x, readOnly: true }), (0, jsx_runtime_1.jsx)("div", { "data-tooltip-content": x.address, "data-tooltip-id": "modal-tip", onClick: () => {
|
|
111
|
-
react_hot_toast_1.default.success("Address copied to clipboard");
|
|
112
|
-
navigator.clipboard.writeText(x.address);
|
|
113
|
-
}, className: "inconsolata mx-1", children: x.address.substring(0, 6) + "…" + x.address.slice(-6) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex ai-c gap-0.5", children: [(0, jsx_runtime_1.jsx)(__1.NetworkIcon, { network: x.asset.chain, className: "w-2 h-2" }), (0, jsx_runtime_1.jsx)("span", { className: "", children: (0, rujira_js_1.networkLabel)(x.asset.chain) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex dir-r ai-e ml-a", children: [(0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)({
|
|
114
|
-
"tag tag--md ml-a": true,
|
|
115
|
-
"tag--teal": account === x,
|
|
116
|
-
}), children: (0, jsx_runtime_1.jsx)(__1.Decimal, { amount: x.balance, symbol: x.asset.metadata.symbol, symbolClassName: "condensed fw-500" }) }), x.valueUsd ? ((0, jsx_runtime_1.jsxs)("div", { className: "iflex ml-0.5 ml-sm-1 fs-13 color-grey", style: { marginBottom: "0.05rem" }, children: ["(", (0, jsx_runtime_1.jsx)(__1.Fiat, { amount: x.valueUsd, symbol: "$", decimals: 8, className: "fs-12 color-grey" }), ")"] })) : null] })] }, x.address + x.asset.chain))) })] })) : null, (0, jsx_runtime_1.jsx)(__1.DenomInput, { className: "mt-2.5 bg-black", symbol: asset.metadata.symbol, amount: amount, decimals: 8, onChangeAmount: setAmount, max: BigInt(account?.balance || 0), maxLabel: `${t("balance")}:`, fiat: { price, symbol: "$" } }), (0, jsx_runtime_1.jsxs)("div", { className: "row wrap mt-1.5 mt-sm-2 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("swapFee") }), (0, jsx_runtime_1.jsxs)("div", { className: "col-12 col-xs-8 text-center text-xs-right", children: [(0, jsx_runtime_1.jsx)(__1.Decimal, { amount: depositFee, symbol: direct ? account?.asset.metadata.symbol : asset.metadata.symbol, className: direct || !shouldSwap ? "color-grey" : undefined, symbolClassName: "color-grey fs-14 condensed fw-500" }), (0, jsx_runtime_1.jsxs)("div", { className: "iflex ml-1 fs-13 color-grey", children: ["(", (0, jsx_runtime_1.jsx)(__1.Fiat, { amount: feeValue ?? 0n, symbol: "$", decimals: 8, className: "numeric-input__value color-grey fs-12" }), ")"] })] }), (0, jsx_runtime_1.jsx)("div", { className: "col-12 col-xs-4 text-center text-xs-left color-grey fw-500", children: t("receivedAmount") }), (0, jsx_runtime_1.jsxs)("div", { className: "col-12 col-xs-8 text-center text-xs-right", children: [(0, jsx_runtime_1.jsx)(__1.Decimal, { amount: depositAmount, symbol: direct ? account?.asset.metadata.symbol : asset.metadata.symbol, symbolClassName: "color-grey fs-14 condensed fw-500" }), (0, jsx_runtime_1.jsxs)("div", { className: "iflex ml-1 fs-13 color-grey", children: ["(", (0, jsx_runtime_1.jsx)(__1.Fiat, { amount: receivedValue ?? 0n, symbol: "$", decimals: 8, className: "numeric-input__value color-grey fs-12" }), ")"] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex w-full jc-c ai-c gap-0.5 pointer color-grey hover-white", onMouseEnter: () => setHoverAd(true), onMouseLeave: () => setHoverAd(false), onClick: () => setAdvanced((prev) => !prev), children: [(0, jsx_runtime_1.jsx)("img", { src: hoverAd ? filters_gif_1.default : filters_png_1.default, className: (0, clsx_1.default)({
|
|
117
|
-
"w-2 h-2": true,
|
|
118
|
-
"filter-grey": !hoverAd,
|
|
119
|
-
"filter-white": hoverAd,
|
|
120
|
-
}) }), 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, className: "bg-darkGrey", children: x }, x))), (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 }) })] })), shouldSwap && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [asset.chain === "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", label: `Deposit ${account?.asset.chain}.${account?.asset.metadata.symbol} directly`, checked: direct, onChange: () => setDirect((prev) => !prev) }) })), direct && ((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.jsxs)("small", { className: "text-left fs-14", children: ["You are depositing a version of", " ", (0, jsx_runtime_1.jsx)("span", { className: "color-white", children: asset.metadata.symbol }), " ", "that is not the standard on Rujira. Our products use the", " ", (0, jsx_runtime_1.jsx)("span", { className: "color-white", children: "Ethereum" }), " version of", " ", (0, jsx_runtime_1.jsx)("span", { className: "color-white", children: asset.metadata.symbol }), "."] })] }))] }))] })), (0, jsx_runtime_1.jsx)(Submit, { selected: account, amount: amount, target: target !== "custom" ? target : custom, swapMemo: "memo", onSuccess: onSuccess, disabled: false, isDangerous: false, quote: quote, shouldSwap: shouldSwap })] }));
|
|
121
|
-
};
|
|
122
|
-
const Success = ({ tx, dismiss, }) => {
|
|
123
|
-
const { t } = (0, i18n_1.useTranslation)("common");
|
|
124
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "mt-2 flex ai-c br-2 bg-teal-10 p-2", children: [(0, jsx_runtime_1.jsx)("img", { src: deposited_gif_1.default, alt: "", className: "filter-teal block w-6 h-a no-shrink" }), (0, jsx_runtime_1.jsx)("span", { className: "color-teal fs-18 fw-600 mx-1", children: t("depositStarted") })] }), (0, jsx_runtime_1.jsx)("div", { className: "table table--no-hover mt-1", children: (0, jsx_runtime_1.jsxs)("tbody", { children: [(0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsxs)("td", { className: "color-grey", children: [(0, rujira_js_1.networkLabel)(tx.network), " ", t("depositEta")] }), (0, jsx_runtime_1.jsx)("td", { children: (0, date_fns_1.formatDuration)((0, date_fns_1.intervalToDuration)({
|
|
125
|
-
start: 0,
|
|
126
|
-
end: (0, rujira_js_1.networkConfirmationTime)(tx.network),
|
|
127
|
-
}), { format: ["hours", "minutes", "seconds"], zero: false }) })] }), (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { className: "color-grey", children: t("viewTx") }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsxs)("a", { href: (0, rujira_js_1.networkTxLink)(tx), target: "_blank", className: "color-white hover-primary1 no-underline", children: [(0, rujira_js_1.networkExplorerLabel)(tx.network), (0, jsx_runtime_1.jsx)(Icons_1.External, { className: "inline-block w-1.5 h-1.5 ml-0.5" })] }) })] }), (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { className: "color-grey", children: t("trackDeposit") }), (0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsxs)("a", { href: (0, rujira_js_1.networkTxLink)({
|
|
128
|
-
network: "THOR",
|
|
129
|
-
txHash: tx.txHash.replace(/^0x/, "").toUpperCase(),
|
|
130
|
-
}), target: "_blank", className: "color-white hover-primary1 no-underline", children: ["THORChain.net", (0, jsx_runtime_1.jsx)(Icons_1.External, { className: "inline-block w-1.5 h-1.5 ml-0.5" })] }) })] })] }) }), (0, jsx_runtime_1.jsx)("div", { className: "modal__footer p-3 text-right", children: (0, jsx_runtime_1.jsx)(__1.Button, { label: "Close", onClick: dismiss }) })] }));
|
|
131
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Button = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const clsx_1 = require("clsx");
|
|
6
|
-
const react_1 = require("motion/react");
|
|
7
|
-
const react_2 = require("react");
|
|
8
|
-
const fixedForwardRef = react_2.forwardRef;
|
|
9
|
-
const UnwrappedAnyComponent = (props, ref) => {
|
|
10
|
-
const { as: Comp = "button", label, children, className, ...rest } = props;
|
|
11
|
-
// Remove button--outline if button--waiting is present
|
|
12
|
-
const processedClassName = className?.includes("button--waiting")
|
|
13
|
-
? className.replace(/button--outline/g, "").trim()
|
|
14
|
-
: className;
|
|
15
|
-
const mouseX = (0, react_1.useMotionValue)(0);
|
|
16
|
-
const mouseY = (0, react_1.useMotionValue)(0);
|
|
17
|
-
function handleMouseMove({ currentTarget, clientX, clientY }) {
|
|
18
|
-
const { left, top } = currentTarget.getBoundingClientRect();
|
|
19
|
-
mouseX.set(clientX - left);
|
|
20
|
-
mouseY.set(clientY - top);
|
|
21
|
-
}
|
|
22
|
-
let gradient = "214, 21, 235, 1";
|
|
23
|
-
if (className?.includes("button--grey")) {
|
|
24
|
-
gradient = "96, 125, 139, 1";
|
|
25
|
-
}
|
|
26
|
-
else if (className?.includes("button--red")) {
|
|
27
|
-
gradient = "244, 81, 30, 1";
|
|
28
|
-
}
|
|
29
|
-
else if (className?.includes("button--blue")) {
|
|
30
|
-
gradient = "96, 251, 208, 1";
|
|
31
|
-
}
|
|
32
|
-
else if (className?.includes("button--dark")) {
|
|
33
|
-
gradient = "214, 21, 235, 0.25";
|
|
34
|
-
}
|
|
35
|
-
else if (className?.includes("button--orange")) {
|
|
36
|
-
gradient = "245, 123, 0, 0.25";
|
|
37
|
-
}
|
|
38
|
-
const buttonElement = ((0, jsx_runtime_1.jsxs)(Comp, { ...rest, ref: ref, onMouseMove: handleMouseMove, className: (0, clsx_1.default)({
|
|
39
|
-
button: !className?.includes("transparent"),
|
|
40
|
-
[`${processedClassName}`]: processedClassName,
|
|
41
|
-
}), children: [!className?.includes("transparent") && ((0, jsx_runtime_1.jsx)(react_1.motion.div, { className: "button__motion", style: {
|
|
42
|
-
background: (0, react_1.useMotionTemplate) `
|
|
43
|
-
radial-gradient(
|
|
44
|
-
150px circle at ${mouseX}px ${mouseY}px,
|
|
45
|
-
rgba(${gradient}),
|
|
46
|
-
transparent 100%
|
|
47
|
-
)
|
|
48
|
-
`,
|
|
49
|
-
} })), label && (0, jsx_runtime_1.jsx)("span", { children: label }), children] }));
|
|
50
|
-
return className?.includes("button--waiting") ? ((0, jsx_runtime_1.jsx)("div", { className: "button-container", children: buttonElement })) : (buttonElement);
|
|
51
|
-
};
|
|
52
|
-
exports.Button = fixedForwardRef(UnwrappedAnyComponent);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Popout = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const clsx_1 = require("clsx");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const Icons_1 = require("../icons/Icons");
|
|
8
|
-
const Button_1 = require("./Button");
|
|
9
|
-
const react_dom_1 = require("react-dom");
|
|
10
|
-
const Popout = ({ children, className, buttonClassName }) => {
|
|
11
|
-
const [open, setOpen] = (0, react_1.useState)(false);
|
|
12
|
-
const container = (0, react_1.useRef)(null);
|
|
13
|
-
const navElement = document.getElementById("popout");
|
|
14
|
-
(0, react_1.useEffect)(() => {
|
|
15
|
-
if (open) {
|
|
16
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
17
|
-
window.addEventListener("resize", position);
|
|
18
|
-
navElement.classList.add("open");
|
|
19
|
-
position();
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
23
|
-
}
|
|
24
|
-
return () => {
|
|
25
|
-
document.removeEventListener("mousedown", handleClickOutside);
|
|
26
|
-
window.removeEventListener("resize", position);
|
|
27
|
-
navElement.classList.remove("open");
|
|
28
|
-
};
|
|
29
|
-
}, [open]);
|
|
30
|
-
const handleClickOutside = (e) => {
|
|
31
|
-
if (navElement.contains(e.target)) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
setOpen(false);
|
|
35
|
-
e.stopPropagation();
|
|
36
|
-
e.stopImmediatePropagation();
|
|
37
|
-
return false;
|
|
38
|
-
};
|
|
39
|
-
const position = () => {
|
|
40
|
-
const containerElementElement = container.current;
|
|
41
|
-
if (navElement && containerElementElement) {
|
|
42
|
-
const rightPosition = window.scrollX +
|
|
43
|
-
window.innerWidth -
|
|
44
|
-
containerElementElement.getBoundingClientRect().left -
|
|
45
|
-
parseInt(getComputedStyle(containerElementElement).borderLeftWidth, 10);
|
|
46
|
-
const bottomPosition = -window.scrollY +
|
|
47
|
-
window.innerHeight -
|
|
48
|
-
containerElementElement.getBoundingClientRect().top -
|
|
49
|
-
parseInt(getComputedStyle(containerElementElement).borderTopWidth, 10) -
|
|
50
|
-
containerElementElement.offsetHeight;
|
|
51
|
-
navElement.style.right = `${rightPosition + 4}px`;
|
|
52
|
-
navElement.style.bottom = `${bottomPosition - 4}px`;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: container, className: (0, clsx_1.default)({
|
|
56
|
-
popout: true,
|
|
57
|
-
[`${className}`]: className,
|
|
58
|
-
}), children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: () => setOpen(!open), className: (0, clsx_1.default)({
|
|
59
|
-
"button--grey button--small": !buttonClassName,
|
|
60
|
-
[`${buttonClassName}`]: buttonClassName,
|
|
61
|
-
}), children: !open ? (0, jsx_runtime_1.jsx)(Icons_1.Ellipsis, {}) : (0, jsx_runtime_1.jsx)(Icons_1.AngleLeft, {}) }), open && (0, react_dom_1.createPortal)(children, navElement)] }));
|
|
62
|
-
};
|
|
63
|
-
exports.Popout = Popout;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TxButtonTip = exports.TxButton = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const clsx_1 = require("clsx");
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const react_hot_toast_1 = require("react-hot-toast");
|
|
8
|
-
const react_tooltip_1 = require("react-tooltip");
|
|
9
|
-
const rujira_js_1 = require("rujira.js");
|
|
10
|
-
const unlock_gif_1 = require("../../assets/images/unlock.gif");
|
|
11
|
-
const i18n_1 = require("../../i18n");
|
|
12
|
-
const Warning_1 = require("../notices/Warning");
|
|
13
|
-
const Decimal_1 = require("../numbers/Decimal");
|
|
14
|
-
const Button_1 = require("./Button");
|
|
15
|
-
const txsuccess_gif_1 = require("../../assets/images/txsuccess.gif");
|
|
16
|
-
const txfail_gif_1 = require("../../assets/images/txfail.gif");
|
|
17
|
-
const txsign_gif_1 = require("../../assets/images/txsign.gif");
|
|
18
|
-
const Loader_1 = require("../loader/Loader");
|
|
19
|
-
// Helper to identify spacing/layout classes
|
|
20
|
-
const SPACING_CLASS_REGEX = /^(m|p)(l|r|t|b|x|y)?-\d+$/;
|
|
21
|
-
const isSpacingClass = (className) => SPACING_CLASS_REGEX.test(className);
|
|
22
|
-
// Separate spacing classes from styling classes
|
|
23
|
-
const separateClasses = (className) => {
|
|
24
|
-
const classes = className?.split(" ") || [];
|
|
25
|
-
return {
|
|
26
|
-
spacing: classes.filter(isSpacingClass),
|
|
27
|
-
styling: classes.filter((c) => !isSpacingClass(c)),
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
const TxButton = (props) => {
|
|
31
|
-
const { t } = (0, i18n_1.useTranslation)("common");
|
|
32
|
-
const { accountProvider, msg, onSuccess, onError, SimulationComponent = DefaultSimulationComponent, children, toastOpts = {}, className, hideSimulation, onClick, ...rest } = props;
|
|
33
|
-
const [simulation, setSimulation] = (0, react_1.useState)();
|
|
34
|
-
const [simulationError, setSimulationError] = (0, react_1.useState)();
|
|
35
|
-
const { loading, success, error } = toastOpts;
|
|
36
|
-
const [isSigning, setIsSigning] = (0, react_1.useState)(false);
|
|
37
|
-
const [isSuccess, setIsSuccess] = (0, react_1.useState)(false);
|
|
38
|
-
const [isRejected, setIsRejected] = (0, react_1.useState)(false);
|
|
39
|
-
const doSimulate = (msg) => {
|
|
40
|
-
setSimulationError(undefined);
|
|
41
|
-
setSimulation(undefined);
|
|
42
|
-
if (msg) {
|
|
43
|
-
const signer = accountProvider.signer(msg.account.address);
|
|
44
|
-
signer
|
|
45
|
-
.simulate(msg)
|
|
46
|
-
.then(setSimulation)
|
|
47
|
-
.catch((err) => {
|
|
48
|
-
console.error(err);
|
|
49
|
-
setSimulationError(err);
|
|
50
|
-
onError && onError(new rujira_js_1.TxError(msg, err, "simulation"));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
(0, react_1.useEffect)(() => {
|
|
55
|
-
doSimulate(msg);
|
|
56
|
-
}, [msg]);
|
|
57
|
-
const handleSign = (e) => {
|
|
58
|
-
if (isSigning || isSuccess || isRejected)
|
|
59
|
-
return;
|
|
60
|
-
if (!simulation)
|
|
61
|
-
throw new Error(`Simulation required`);
|
|
62
|
-
if (!msg)
|
|
63
|
-
throw new Error(`Msg required`);
|
|
64
|
-
setIsSigning(true);
|
|
65
|
-
const signer = accountProvider.signer(msg.account.address);
|
|
66
|
-
if (onClick)
|
|
67
|
-
onClick(e);
|
|
68
|
-
const p = signer
|
|
69
|
-
.signAndBroadcast(simulation, msg)
|
|
70
|
-
.then((res) => {
|
|
71
|
-
onSuccess && onSuccess(res);
|
|
72
|
-
setIsSigning(false);
|
|
73
|
-
setIsSuccess(true);
|
|
74
|
-
setTimeout(() => {
|
|
75
|
-
setIsSuccess(false);
|
|
76
|
-
}, 3000);
|
|
77
|
-
return res;
|
|
78
|
-
})
|
|
79
|
-
.catch((err) => {
|
|
80
|
-
console.error(err);
|
|
81
|
-
onError && onError(new rujira_js_1.TxError(msg, err, "signAndBroadcast"));
|
|
82
|
-
setIsSigning(false);
|
|
83
|
-
setIsRejected(true);
|
|
84
|
-
setTimeout(() => {
|
|
85
|
-
setIsRejected(false);
|
|
86
|
-
}, 3000);
|
|
87
|
-
throw err;
|
|
88
|
-
});
|
|
89
|
-
react_hot_toast_1.default.promise(p, {
|
|
90
|
-
loading: loading || t("submittingTransaction"),
|
|
91
|
-
success: success || ((res) => successHandler(res, t)),
|
|
92
|
-
error: error ||
|
|
93
|
-
((err) => {
|
|
94
|
-
console.error(err);
|
|
95
|
-
const defaultError = t("errorSubmittingTransaction");
|
|
96
|
-
switch (typeof err) {
|
|
97
|
-
case "string":
|
|
98
|
-
return (0, rujira_js_1.translateError)(err) || defaultError;
|
|
99
|
-
case "object":
|
|
100
|
-
return "message" in err
|
|
101
|
-
? (0, rujira_js_1.translateError)(err.message) || defaultError
|
|
102
|
-
: defaultError;
|
|
103
|
-
default:
|
|
104
|
-
return defaultError;
|
|
105
|
-
}
|
|
106
|
-
}),
|
|
107
|
-
});
|
|
108
|
-
};
|
|
109
|
-
const disabled = !msg || !simulation || !!simulationError || rest.disabled;
|
|
110
|
-
// Separate spacing classes (always applied) from styling classes (conditionally applied)
|
|
111
|
-
const { spacing: spacingClasses, styling: stylingClasses } = separateClasses(className);
|
|
112
|
-
// Determine if tooltip should be shown
|
|
113
|
-
const showTooltip = simulationError && simulationError.message !== "";
|
|
114
|
-
const allowanceMsg = (0, react_1.useMemo)(() => {
|
|
115
|
-
if (!msg)
|
|
116
|
-
return null;
|
|
117
|
-
if (!simulationError)
|
|
118
|
-
return null;
|
|
119
|
-
if (!(simulationError instanceof rujira_js_1.InsufficientAllowanceError))
|
|
120
|
-
return null;
|
|
121
|
-
return new rujira_js_1.MsgErc20IncreaseAllowance(msg.account, simulationError);
|
|
122
|
-
}, [msg, simulationError]);
|
|
123
|
-
if (allowanceMsg)
|
|
124
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(exports.TxButton, { ...props, toastOpts: {
|
|
125
|
-
loading: t("increasingAllowance"),
|
|
126
|
-
success: t("allowanceIncreased"),
|
|
127
|
-
}, label: t("stepApprove"), msg: allowanceMsg, onSuccess: () => doSimulate(msg) }), (0, jsx_runtime_1.jsx)(InsufficientAllowanceWarning, {})] }));
|
|
128
|
-
const modProps = {
|
|
129
|
-
...rest,
|
|
130
|
-
...(rest.label && {
|
|
131
|
-
label: `${isSuccess
|
|
132
|
-
? t("success")
|
|
133
|
-
: isSigning
|
|
134
|
-
? t("waiting")
|
|
135
|
-
: isRejected
|
|
136
|
-
? t("rejected")
|
|
137
|
-
: rest.label}`,
|
|
138
|
-
}),
|
|
139
|
-
};
|
|
140
|
-
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Button_1.Button, { ...modProps, onClick: handleSign, className: (0, clsx_1.default)(stylingClasses.length > 0 ? stylingClasses : "button", spacingClasses, {
|
|
141
|
-
"button--grey": disabled && !stylingClasses.includes("transparent"),
|
|
142
|
-
"button--waiting": (isSigning || isRejected || isSuccess) &&
|
|
143
|
-
!className?.includes("transparent"),
|
|
144
|
-
"button--success": isSuccess,
|
|
145
|
-
"button--rejected": isRejected,
|
|
146
|
-
}), style: {
|
|
147
|
-
cursor: isSigning || isSuccess || isRejected ? "default" : undefined,
|
|
148
|
-
...rest.style,
|
|
149
|
-
}, disabled: disabled, "data-tooltip-id": "tx-button-tip", "data-tooltip-html": showTooltip
|
|
150
|
-
? `<p class="fs-12 lh-16 fw-400 w-36 mb-0.5">${(0, rujira_js_1.translateError)(simulationError.message)}</p>`
|
|
151
|
-
: undefined, children: [(isSuccess || isRejected || isSigning) &&
|
|
152
|
-
!className?.includes("transparent") && ((0, jsx_runtime_1.jsx)("img", { className: "w-4 h-4 filter-white big", src: isSigning ? txsign_gif_1.default : isSuccess ? txsuccess_gif_1.default : txfail_gif_1.default, alt: "lock" })), (isSigning || isRejected || isSuccess) &&
|
|
153
|
-
className?.includes("transparent") ? ((0, jsx_runtime_1.jsx)(Loader_1.Loader, { className: "w-full h-full" })) : (((!isSigning && !isRejected && !isSuccess) ||
|
|
154
|
-
className?.includes("transparent")) &&
|
|
155
|
-
children)] }), hideSimulation ? null : msg ? ((0, jsx_runtime_1.jsx)(SimulationComponent, { simulation: simulation, error: simulationError })) : ((0, jsx_runtime_1.jsx)("span", { children: "\u00A0" }))] }));
|
|
156
|
-
};
|
|
157
|
-
exports.TxButton = TxButton;
|
|
158
|
-
const TxButtonTip = () => ((0, jsx_runtime_1.jsx)(react_tooltip_1.Tooltip, { id: "tx-button-tip", className: "tooltip", float: true, style: { zIndex: 203 } }));
|
|
159
|
-
exports.TxButtonTip = TxButtonTip;
|
|
160
|
-
const DefaultSimulationComponent = ({ simulation, error, }) => {
|
|
161
|
-
const { t } = (0, i18n_1.useTranslation)("common");
|
|
162
|
-
if (error instanceof rujira_js_1.InsufficientAllowanceError) {
|
|
163
|
-
return (0, jsx_runtime_1.jsx)(InsufficientAllowanceWarning, {});
|
|
164
|
-
}
|
|
165
|
-
return ((0, jsx_runtime_1.jsx)("small", { className: "fs-12 text-center mt-1 color-grey block", children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [t("networkFee"), " ", simulation ? ((0, jsx_runtime_1.jsx)(Decimal_1.Decimal, { amount: simulation.amount, decimals: simulation.decimals, symbol: simulation.symbol, className: "color-white" })) : ((0, jsx_runtime_1.jsx)("span", { children: t("calculating") }))] }) }));
|
|
166
|
-
};
|
|
167
|
-
const InsufficientAllowanceWarning = () => {
|
|
168
|
-
const { t } = (0, i18n_1.useTranslation)("common");
|
|
169
|
-
return ((0, jsx_runtime_1.jsxs)(Warning_1.Warning, { className: "warning mt-2 condensed flex ai-c", color: "orange", children: [(0, jsx_runtime_1.jsx)("img", { src: unlock_gif_1.default, alt: "lock" }), (0, jsx_runtime_1.jsx)("div", { className: "text-left", children: t("insufficientAllowanceWarning") })] }));
|
|
170
|
-
};
|
|
171
|
-
const successHandler = (res, t) => res.label ? ((0, jsx_runtime_1.jsx)("p", { children: res.label })) : ((0, jsx_runtime_1.jsxs)("p", { children: [t("transactionSucceeded"), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)("a", { href: (0, rujira_js_1.networkTxLink)(res), target: "_blank", className: "color-white no-underline fs-12", children: res.txHash.slice(0, 8) + "..." + res.txHash.slice(-8) })] }));
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.usePopout = exports.Popout = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const react_dom_1 = require("react-dom");
|
|
7
|
-
const Popout = ({ children, position, visible }) => {
|
|
8
|
-
const node = (0, react_1.useRef)(null);
|
|
9
|
-
if (!visible)
|
|
10
|
-
return null;
|
|
11
|
-
return (0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("nav", { ref: node, className: "popout condensed", style: {
|
|
12
|
-
top: position.top - (node.current?.offsetHeight || 0) + 8,
|
|
13
|
-
left: position.left - (node.current?.offsetWidth || 0),
|
|
14
|
-
}, children: children }), document.body);
|
|
15
|
-
};
|
|
16
|
-
exports.Popout = Popout;
|
|
17
|
-
const usePopout = () => {
|
|
18
|
-
const [popoutState, setPopoutState] = (0, react_1.useState)({
|
|
19
|
-
content: "",
|
|
20
|
-
position: { top: 0, left: 0 },
|
|
21
|
-
visible: false,
|
|
22
|
-
});
|
|
23
|
-
const showPopout = (content, target) => {
|
|
24
|
-
const rect = target.getBoundingClientRect();
|
|
25
|
-
setPopoutState({
|
|
26
|
-
content,
|
|
27
|
-
position: {
|
|
28
|
-
top: rect.top + window.scrollY + rect.height,
|
|
29
|
-
left: rect.left + window.scrollX,
|
|
30
|
-
},
|
|
31
|
-
visible: true,
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
const hidePopout = () => {
|
|
35
|
-
setPopoutState((prev) => ({ ...prev, visible: false }));
|
|
36
|
-
};
|
|
37
|
-
return { popoutState, showPopout, hidePopout };
|
|
38
|
-
};
|
|
39
|
-
exports.usePopout = usePopout;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Card = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const clsx_1 = require("clsx");
|
|
6
|
-
const Card = ({ className, children }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)({
|
|
8
|
-
"card p-3 color-white": true,
|
|
9
|
-
[`${className}`]: className,
|
|
10
|
-
}), children: children }));
|
|
11
|
-
};
|
|
12
|
-
exports.Card = Card;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GradientCard = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const clsx_1 = require("clsx");
|
|
6
|
-
const GradientCard = ({ className, children }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)({
|
|
8
|
-
"gradient-card bg-black p-3 color-white": true,
|
|
9
|
-
[`${className}`]: className,
|
|
10
|
-
}), children: children }));
|
|
11
|
-
};
|
|
12
|
-
exports.GradientCard = GradientCard;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShareCard = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const clsx_1 = require("clsx");
|
|
6
|
-
const ShareCard = ({ className, backgroundImage, leftComponent, rightComponent, badgeComponent, }) => {
|
|
7
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, clsx_1.default)({
|
|
8
|
-
"share-card": true,
|
|
9
|
-
[`${className}`]: className,
|
|
10
|
-
}), style: {
|
|
11
|
-
backgroundImage: backgroundImage
|
|
12
|
-
? `url(${backgroundImage})`
|
|
13
|
-
: undefined,
|
|
14
|
-
}, children: [badgeComponent && ((0, jsx_runtime_1.jsx)("div", { className: "share-card__badge", children: badgeComponent })), (0, jsx_runtime_1.jsxs)("div", { className: "share-card__content", children: [(0, jsx_runtime_1.jsx)("div", { className: "share-card__left", children: leftComponent }), (0, jsx_runtime_1.jsx)("div", { className: "share-card__right", children: rightComponent })] })] }));
|
|
15
|
-
};
|
|
16
|
-
exports.ShareCard = ShareCard;
|