tek-wallet 0.0.637 → 0.0.638

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.
Files changed (26) hide show
  1. package/dist/components/TekWallet/components/ui/CardFrom/index.d.ts +10 -0
  2. package/dist/components/TekWallet/components/ui/CardFrom/index.js +90 -0
  3. package/dist/components/TekWallet/components/ui/CardTo/index.d.ts +10 -0
  4. package/dist/components/TekWallet/components/ui/CardTo/index.js +39 -0
  5. package/dist/components/TekWallet/components/ui/CardToken/index.d.ts +11 -0
  6. package/dist/components/TekWallet/components/ui/CardToken/index.js +37 -0
  7. package/dist/components/TekWallet/components/ui/DetailSwap/index.d.ts +7 -0
  8. package/dist/components/TekWallet/components/ui/DetailSwap/index.js +51 -0
  9. package/dist/components/TekWallet/components/ui/DetailSwapResult/index.d.ts +8 -0
  10. package/dist/components/TekWallet/components/ui/DetailSwapResult/index.js +122 -0
  11. package/dist/components/TekWallet/components/ui/DrawerDrag/index.d.ts +21 -0
  12. package/dist/components/TekWallet/components/ui/DrawerDrag/index.js +25 -0
  13. package/dist/components/TekWallet/components/ui/Fees/index.js +2 -2
  14. package/dist/components/TekWallet/components/ui/ModalSelectToken/index.d.ts +9 -0
  15. package/dist/components/TekWallet/components/ui/ModalSelectToken/index.js +127 -0
  16. package/dist/components/TekWallet/components/ui/SwapFunction/index.d.ts +11 -0
  17. package/dist/components/TekWallet/components/ui/SwapFunction/index.js +195 -0
  18. package/dist/components/TekWallet/components/ui/SwapToken/index.d.ts +1 -0
  19. package/dist/components/TekWallet/components/ui/SwapToken/index.js +29 -9
  20. package/dist/components/TekWallet/components/views/AssetView/index.js +8 -5
  21. package/dist/components/TekWallet/components/views/HelpView/index.d.ts +2 -0
  22. package/dist/components/TekWallet/components/views/HelpView/index.js +7 -0
  23. package/dist/components/TekWallet/hooks/useBoolean.d.ts +9 -0
  24. package/dist/components/TekWallet/hooks/useBoolean.js +33 -0
  25. package/dist/components/TekWallet/services/axios/get-swap-tokens-list-service/type.d.ts +1 -0
  26. package/package.json +1 -1
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { SupportedToken } from "../../../services/axios/get-swap-tokens-list-service/type";
3
+ interface Props {
4
+ className?: string;
5
+ selectedToken?: SupportedToken;
6
+ number?: number;
7
+ onChange?: (e: React.ChangeEvent<HTMLInputElement>) => void;
8
+ }
9
+ declare const CardForm: ({ selectedToken, onChange, number }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export default CardForm;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var jsx_runtime_1 = require("react/jsx-runtime");
7
+ var material_1 = require("@mui/material");
8
+ var react_1 = require("react");
9
+ var Icon_1 = __importDefault(require("../Icon"));
10
+ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
11
+ var providers_1 = require("../../../providers");
12
+ var useWallet_1 = __importDefault(require("../../../hooks/useWallet"));
13
+ var useBoolean_1 = require("../../../hooks/useBoolean");
14
+ var Button_1 = __importDefault(require("../Button"));
15
+ var Text_1 = __importDefault(require("../Text"));
16
+ var getStandardNumber_1 = __importDefault(require("../../../utils/getStandardNumber"));
17
+ var CardForm = function (_a) {
18
+ var _b, _c, _d, _e, _f, _g;
19
+ var selectedToken = _a.selectedToken, onChange = _a.onChange, number = _a.number;
20
+ var selectTokenForm = (0, useBoolean_1.useBoolean)("selectTokenForm");
21
+ var _h = (0, useWallet_1.default)(), updateSwapTokens = _h.updateSwapTokens, fromTokens = _h.fromTokens;
22
+ var theme = (0, providers_1.useTheme)();
23
+ (0, react_1.useEffect)(function () {
24
+ if (!fromTokens) {
25
+ updateSwapTokens();
26
+ }
27
+ }, [fromTokens, updateSwapTokens]);
28
+ var displayToken = (0, react_1.useMemo)(function () {
29
+ return selectedToken;
30
+ }, [selectedToken]);
31
+ var handleClickGetMaxValue = function () {
32
+ if ((displayToken === null || displayToken === void 0 ? void 0 : displayToken.max_value) && onChange) {
33
+ var balance = Number(displayToken.balance);
34
+ var maxValue = Number(displayToken.max_value);
35
+ var minValue = Math.min(balance, maxValue);
36
+ onChange({
37
+ target: { value: minValue.toString() },
38
+ });
39
+ }
40
+ };
41
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { className: "p-4 rounded-16 backdrop-blur-[12px]", sx: {
42
+ border: "1px solid",
43
+ borderColor: "".concat((number && number < ((_b = displayToken === null || displayToken === void 0 ? void 0 : displayToken.min_value) !== null && _b !== void 0 ? _b : 0)) || (number && number > ((_c = displayToken === null || displayToken === void 0 ? void 0 : displayToken.max_value) !== null && _c !== void 0 ? _c : 0)) || (number && number > ((_d = Number(displayToken === null || displayToken === void 0 ? void 0 : displayToken.balance)) !== null && _d !== void 0 ? _d : 0)) ? "red" : "".concat(theme.palette.primary.main)),
44
+ }, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex justify-between", children: [(0, jsx_runtime_1.jsx)(Text_1.default, { component: "p", sx: {
45
+ color: theme.palette.text.blackContrast,
46
+ fontWeight: theme.typography.fontWeight600,
47
+ }, children: "From" }), (0, jsx_runtime_1.jsxs)(Text_1.default, { component: "p", sx: {
48
+ color: theme.palette.text.accent,
49
+ fontSize: theme.typography.fontSize12,
50
+ fontWeight: theme.typography.fontWeight400,
51
+ }, children: ["Balance:", " ", (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: {
52
+ color: theme.palette.text.blackContrast,
53
+ fontWeight: theme.typography.fontWeight500,
54
+ fontSize: theme.typography.fontSize12,
55
+ }, children: [(0, getStandardNumber_1.default)(Number(displayToken === null || displayToken === void 0 ? void 0 : displayToken.balance)), " ", displayToken === null || displayToken === void 0 ? void 0 : displayToken.full_name] })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex justify-between mt-5 mb-4", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center gap-1 cursor-pointer", onClick: function () { return selectTokenForm.setTrue(); }, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: displayToken === null || displayToken === void 0 ? void 0 : displayToken.link, width: 20, height: 20, className: "rounded-full" }), (0, jsx_runtime_1.jsx)(Text_1.default, { component: "p", sx: {
56
+ color: theme.palette.text.blackContrast,
57
+ fontWeight: theme.typography.fontWeight600,
58
+ }, children: (displayToken === null || displayToken === void 0 ? void 0 : displayToken.name) || (displayToken === null || displayToken === void 0 ? void 0 : displayToken.full_name) }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_black_drop") })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { className: "w-full flex justify-end items-end", children: (0, jsx_runtime_1.jsx)(material_1.InputBase, { type: "number", value: number === undefined || number === null ? "" : (0, getStandardNumber_1.default)(number), onChange: onChange, classes: {
59
+ input: "text-end text-contrast max-w-fit bg-transparent border-none outline-none text-16 leading-140 font-bold placeholder:text-accent-1",
60
+ }, sx: {
61
+ "input::placeholder": {
62
+ fontSize: "13px",
63
+ },
64
+ }, placeholder: "Min ".concat(displayToken === null || displayToken === void 0 ? void 0 : displayToken.min_value, " - Max ").concat(displayToken === null || displayToken === void 0 ? void 0 : displayToken.max_value, " ").concat(displayToken === null || displayToken === void 0 ? void 0 : displayToken.full_name) }) })] }), (number && number > ((_e = displayToken === null || displayToken === void 0 ? void 0 : displayToken.max_value) !== null && _e !== void 0 ? _e : 0)) ||
65
+ (number && number < ((_f = displayToken === null || displayToken === void 0 ? void 0 : displayToken.min_value) !== null && _f !== void 0 ? _f : 0)) ||
66
+ (number && number > ((_g = Number(displayToken === null || displayToken === void 0 ? void 0 : displayToken.balance)) !== null && _g !== void 0 ? _g : 0)) ? ((0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center justify-between", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center gap-1", children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("alert"), width: 14, height: 14 }), (0, jsx_runtime_1.jsx)(Text_1.default, { className: "text-red-500 font-normal text-12", children: "Insufficient balance" })] }), (0, jsx_runtime_1.jsx)(Button_1.default, { sx: {
67
+ textTransform: "capitalize",
68
+ backgroundColor: theme.palette.background.tertiary,
69
+ borderRadius: theme.mixins.customRadius.r8,
70
+ color: theme.palette.text.primary,
71
+ height: theme.typography.fontSize24,
72
+ padding: theme.mixins.customPadding.p12,
73
+ }, onClick: handleClickGetMaxValue, children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
74
+ color: theme.palette.primary.main,
75
+ fontWeight: theme.typography.fontWeight600,
76
+ fontSize: theme.typography.fontSize12,
77
+ }, children: "Max" }) })] })) : ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "flex justify-end", children: (0, jsx_runtime_1.jsx)(Button_1.default, { sx: {
78
+ textTransform: "capitalize",
79
+ backgroundColor: theme.palette.background.tertiary,
80
+ borderRadius: theme.mixins.customRadius.r8,
81
+ color: theme.palette.text.primary,
82
+ height: theme.typography.fontSize24,
83
+ padding: theme.mixins.customPadding.p12,
84
+ }, onClick: handleClickGetMaxValue, children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
85
+ color: theme.palette.primary.main,
86
+ fontWeight: theme.typography.fontWeight600,
87
+ fontSize: theme.typography.fontSize12,
88
+ }, children: "Max" }) }) }))] }));
89
+ };
90
+ exports.default = CardForm;
@@ -0,0 +1,10 @@
1
+ import { Output, SupportedToken } from "../../../services/axios/get-swap-tokens-list-service/type";
2
+ interface Props {
3
+ className?: string;
4
+ token?: SupportedToken;
5
+ selectedOutputToken?: Output;
6
+ value?: number;
7
+ onClick?: () => void;
8
+ }
9
+ declare const CardTo: ({ selectedOutputToken, token, value }: Props) => import("react/jsx-runtime").JSX.Element;
10
+ export default CardTo;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var jsx_runtime_1 = require("react/jsx-runtime");
7
+ var material_1 = require("@mui/material");
8
+ var Icon_1 = __importDefault(require("../Icon"));
9
+ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
10
+ var providers_1 = require("../../../providers");
11
+ var useBoolean_1 = require("../../../hooks/useBoolean");
12
+ var Text_1 = __importDefault(require("../Text"));
13
+ var roundToTwoSignificantDecimals_1 = __importDefault(require("../../../utils/roundToTwoSignificantDecimals"));
14
+ var CardTo = function (_a) {
15
+ var selectedOutputToken = _a.selectedOutputToken, token = _a.token, value = _a.value;
16
+ var selectTokenTo = (0, useBoolean_1.useBoolean)("selectTokenTo");
17
+ var cardFromUSDRate = Number(token === null || token === void 0 ? void 0 : token.usd_rate);
18
+ var cardToUSDRate = Number(selectedOutputToken === null || selectedOutputToken === void 0 ? void 0 : selectedOutputToken.usd_rate);
19
+ var totalAmount = (cardFromUSDRate * (value !== undefined ? value : 0)) / cardToUSDRate;
20
+ var theme = (0, providers_1.useTheme)();
21
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
22
+ padding: theme.mixins.customPadding.p12,
23
+ backgroundColor: theme.palette.background.tertiary,
24
+ borderRadius: theme.mixins.customRadius.r12,
25
+ }, children: [(0, jsx_runtime_1.jsx)(material_1.Box, { className: "flex justify-between", children: (0, jsx_runtime_1.jsx)(Text_1.default, { component: "p", sx: {
26
+ color: theme.palette.text.blackContrast,
27
+ fontWeight: theme.typography.fontWeight600,
28
+ }, children: "To" }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex justify-between mt-5 mb-4", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center gap-1 cursor-pointer", onClick: function () { return selectTokenTo.setTrue(); }, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: selectedOutputToken === null || selectedOutputToken === void 0 ? void 0 : selectedOutputToken.link, width: 20, height: 20, className: "rounded-full" }), (0, jsx_runtime_1.jsx)(Text_1.default, { component: "p", sx: {
29
+ color: theme.palette.text.blackContrast,
30
+ fontWeight: theme.typography.fontWeight600,
31
+ }, children: (selectedOutputToken === null || selectedOutputToken === void 0 ? void 0 : selectedOutputToken.name) || (selectedOutputToken === null || selectedOutputToken === void 0 ? void 0 : selectedOutputToken.full_name) }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_black_drop") })] }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
32
+ color: theme.palette.text.blackContrast,
33
+ fontWeight: theme.typography.fontWeight600,
34
+ fontSize: theme.typography.fontSize16,
35
+ }, children: (0, roundToTwoSignificantDecimals_1.default)(totalAmount) || ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
36
+ color: theme.palette.text.accent,
37
+ }, children: "--" })) })] })] }));
38
+ };
39
+ exports.default = CardTo;
@@ -0,0 +1,11 @@
1
+ interface Props {
2
+ className?: string;
3
+ icon?: string;
4
+ symbol?: string;
5
+ balance?: string;
6
+ price?: string;
7
+ rate?: string;
8
+ isActive?: boolean;
9
+ }
10
+ declare const CardToken: ({ icon, symbol, balance, price, rate, isActive }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export default CardToken;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var jsx_runtime_1 = require("react/jsx-runtime");
7
+ var material_1 = require("@mui/material");
8
+ var Icon_1 = __importDefault(require("../Icon"));
9
+ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
10
+ var providers_1 = require("../../../providers");
11
+ var Text_1 = __importDefault(require("../Text"));
12
+ var CardToken = function (_a) {
13
+ var icon = _a.icon, symbol = _a.symbol, balance = _a.balance, price = _a.price, rate = _a.rate, _b = _a.isActive, isActive = _b === void 0 ? false : _b;
14
+ var theme = (0, providers_1.useTheme)();
15
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
16
+ border: "1px solid",
17
+ borderColor: "".concat(isActive ? theme.palette.primary.main : theme.palette.border.accent3),
18
+ backgroundColor: "".concat(isActive ? theme.palette.background.tertiary : theme.palette.background.white),
19
+ }, className: "p-4 rounded-16", children: (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex justify-between items-center", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center gap-3", children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: icon || (0, getIcon_1.default)("".concat(icon)), width: 20, height: 20 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex flex-col justify-start", children: [(0, jsx_runtime_1.jsx)(Text_1.default, { component: "p", sx: {
20
+ color: theme.palette.text.blackContrast,
21
+ fontWeight: theme.typography.fontWeight400,
22
+ fontSize: theme.typography.fontSize14,
23
+ }, children: symbol }), (0, jsx_runtime_1.jsx)(Text_1.default, { component: "p", sx: {
24
+ color: theme.palette.text.accent,
25
+ fontWeight: theme.typography.fontWeight400,
26
+ fontSize: theme.typography.fontSize12,
27
+ }, children: balance })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex flex-col justify-end items-end", children: [(0, jsx_runtime_1.jsx)(Text_1.default, { component: "p", sx: {
28
+ color: theme.palette.text.blackContrast,
29
+ fontWeight: theme.typography.fontWeight500,
30
+ fontSize: theme.typography.fontSize14,
31
+ }, children: price }), (0, jsx_runtime_1.jsxs)(Text_1.default, { component: "p", sx: {
32
+ color: theme.palette.text.accent,
33
+ fontWeight: theme.typography.fontWeight400,
34
+ fontSize: theme.typography.fontSize12,
35
+ }, children: ["~$", rate] })] })] }) }));
36
+ };
37
+ exports.default = CardToken;
@@ -0,0 +1,7 @@
1
+ import { Output, SupportedToken } from "../../../services/axios/get-swap-tokens-list-service/type";
2
+ interface DetailSwapProps {
3
+ selectedToken?: SupportedToken;
4
+ selectOutputToken?: Output;
5
+ }
6
+ declare const DetailSwap: (props: DetailSwapProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default DetailSwap;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ var jsx_runtime_1 = require("react/jsx-runtime");
18
+ var material_1 = require("@mui/material");
19
+ var providers_1 = require("../../../providers");
20
+ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
21
+ var Icon_1 = __importDefault(require("../Icon"));
22
+ var LineValue_1 = __importDefault(require("../LineValue"));
23
+ var Text_1 = __importDefault(require("../Text"));
24
+ var DetailSwap = function (props) {
25
+ var _a, _b;
26
+ var theme = (0, providers_1.useTheme)();
27
+ var getOutputID = props.selectOutputToken &&
28
+ ((_a = props.selectedToken) === null || _a === void 0 ? void 0 : _a.outputs.find(function (output) { var _a; return output.id === Number((_a = props.selectOutputToken) === null || _a === void 0 ? void 0 : _a.id); }));
29
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.column), className: "gap-3 mt-2", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(Text_1.default, { className: "capitalize opacity-90", sx: {
30
+ color: theme.palette.text.accent2,
31
+ fontSize: theme.typography.fontSize13,
32
+ fontWeight: theme.typography.fontWeight400,
33
+ }, children: "Transaction summary:" }) }), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
34
+ color: theme.palette.text.accent,
35
+ fontSize: theme.typography.fontSize12,
36
+ fontWeight: theme.typography.fontWeight400,
37
+ }, children: "Best Price" }), value: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("ellipse"), width: 12, height: 12 }), (0, jsx_runtime_1.jsxs)(Text_1.default, { className: "truncate", sx: {
38
+ color: theme.palette.text.blackContrast,
39
+ fontSize: theme.typography.fontSize12,
40
+ fontWeight: theme.typography.fontWeight500,
41
+ }, children: ["1 ", (_b = props.selectedToken) === null || _b === void 0 ? void 0 : _b.full_name, " ~ ", getOutputID === null || getOutputID === void 0 ? void 0 : getOutputID.swap_amount, " ", getOutputID && getOutputID.full_name] })] }) }), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
42
+ color: theme.palette.text.accent,
43
+ fontSize: theme.typography.fontSize12,
44
+ fontWeight: theme.typography.fontWeight400,
45
+ }, className: "capitalize", children: "Powered by" }), value: (0, jsx_runtime_1.jsx)(Text_1.default, { className: "truncate", sx: {
46
+ color: theme.palette.text.blackContrast,
47
+ fontSize: theme.typography.fontSize12,
48
+ fontWeight: theme.typography.fontWeight500,
49
+ }, children: "Liquidity Protocol" }) })] }));
50
+ };
51
+ exports.default = DetailSwap;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import { SwapResponse } from "../../../services/axios/swap-service/type";
3
+ interface DetailSwapResultProps {
4
+ onClose?: () => void;
5
+ swapData?: SwapResponse;
6
+ }
7
+ declare const DetailSwapResult: React.FC<DetailSwapResultProps>;
8
+ export default DetailSwapResult;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ var jsx_runtime_1 = require("react/jsx-runtime");
18
+ var react_1 = require("react");
19
+ var useWallet_1 = __importDefault(require("../../../hooks/useWallet"));
20
+ var providers_1 = require("../../../providers");
21
+ var ChildPageLayout_1 = __importDefault(require("../../layouts/ChildPageLayout"));
22
+ var Button_1 = __importDefault(require("../Button"));
23
+ var Text_1 = __importDefault(require("../Text"));
24
+ var material_1 = require("@mui/material");
25
+ var Icon_1 = __importDefault(require("../Icon"));
26
+ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
27
+ var LineValue_1 = __importDefault(require("../LineValue"));
28
+ var formatDate_1 = __importDefault(require("../../../utils/formatDate"));
29
+ var roundToTwoSignificantDecimals_1 = __importDefault(require("../../../utils/roundToTwoSignificantDecimals"));
30
+ var DetailSwapResult = function (_a) {
31
+ var _b, _c;
32
+ var onClose = _a.onClose, swapData = _a.swapData;
33
+ var transaction = (0, useWallet_1.default)().transaction;
34
+ var theme = (0, providers_1.useTheme)();
35
+ var resultData = transaction || (swapData === null || swapData === void 0 ? void 0 : swapData.data);
36
+ var feeInfo = (0, react_1.useMemo)(function () {
37
+ var _a;
38
+ return (_a = resultData === null || resultData === void 0 ? void 0 : resultData.fee_info) === null || _a === void 0 ? void 0 : _a.fee_detail.map(function (item) { return item === null || item === void 0 ? void 0 : item.currency; });
39
+ }, [resultData]);
40
+ var getOutputs = feeInfo === null || feeInfo === void 0 ? void 0 : feeInfo.map(function (item) { return item === null || item === void 0 ? void 0 : item.outputs; });
41
+ var getDetailOutputs = getOutputs === null || getOutputs === void 0 ? void 0 : getOutputs[0].map(function (item) { return item; });
42
+ var getInfoDetailOutputs = (0, react_1.useMemo)(function () {
43
+ return getDetailOutputs === null || getDetailOutputs === void 0 ? void 0 : getDetailOutputs[0];
44
+ }, [getDetailOutputs]);
45
+ (0, react_1.useEffect)(function () { }, [resultData, resultData === null || resultData === void 0 ? void 0 : resultData.id]);
46
+ return ((0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { sx: __assign({ color: theme.palette.text.black }, theme.mixins.pagePadding), footer: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
47
+ px: theme.mixins.customPadding.p12,
48
+ position: "relative",
49
+ bottom: theme.typography.fontSize24,
50
+ }, children: (resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "processing" || (resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "failed" ? ((0, jsx_runtime_1.jsx)(Button_1.default.Primary, { onClick: onClose, sx: __assign(__assign({ gap: theme.mixins.gaps.g4 }, theme.mixins.row), { color: theme.palette.text.secondary, borderRadius: theme.mixins.customRadius.r12, height: "40px" }), fullWidth: true, children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
51
+ fontSize: theme.typography.fontSize12,
52
+ fontWeight: theme.typography.fontWeight600,
53
+ leading: theme.typography.leading160,
54
+ textTransform: "none",
55
+ color: theme.palette.secondary.main,
56
+ }, children: "Close" }) })) : ((resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "success" && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8, justifyContent: "center" }), children: [(0, jsx_runtime_1.jsx)(Button_1.default.Secondary, { onClick: onClose, sx: __assign(__assign({ gap: theme.mixins.gaps.g4 }, theme.mixins.row), { borderRadius: theme.mixins.customRadius.r12, borderColor: theme.palette.primary.main, backgroundColor: "transparent", maxWidth: "168px", height: "40px" }), fullWidth: true, children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
57
+ fontSize: theme.typography.fontSize13,
58
+ fontWeight: theme.typography.fontWeight600,
59
+ color: theme.palette.primary.main,
60
+ leading: theme.typography.leading160,
61
+ textTransform: "none",
62
+ }, children: "Close" }) }), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { onClick: onClose, sx: __assign(__assign({ gap: theme.mixins.gaps.g4 }, theme.mixins.row), { color: theme.palette.text.secondary, borderRadius: theme.mixins.customRadius.r12, maxWidth: "168px", height: "40px" }), fullWidth: true, children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
63
+ fontSize: theme.typography.fontSize13,
64
+ fontWeight: theme.typography.fontWeight600,
65
+ leading: theme.typography.leading160,
66
+ textTransform: "none",
67
+ color: theme.palette.secondary.main,
68
+ }, children: "View asset" }) })] }))) }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({ width: "100%" }, theme.mixins.column), { top: 0, transform: "translateY(30%)", gap: theme.mixins.gaps.g12, backgroundColor: theme.palette.background.tertiary, borderRadius: theme.mixins.customRadius.r16, padding: theme.mixins.customPadding.p16, paddingTop: "80px", alignItems: "flex-start", position: "relative", marginTop: "75px" }), children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.center), { top: 0, width: "fit-content", height: "fit-content", borderRadius: theme.mixins.customRadius.r12, padding: theme.mixins.customPadding.p8 }), children: (0, jsx_runtime_1.jsx)(Icon_1.default, { width: 100, height: 100, src: (0, getIcon_1.default)((resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "success"
69
+ ? "success"
70
+ : (resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "failed"
71
+ ? "failed"
72
+ : (resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "processing"
73
+ ? "processing"
74
+ : "") }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { mt: theme.mixins.customMargin.m8, textAlign: "center" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
75
+ color: theme.palette.text.accent2,
76
+ fontSize: theme.typography.fontSize14,
77
+ fontWeight: theme.typography.fontWeight400,
78
+ }, children: "Swapping Token" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
79
+ color: (resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "processing"
80
+ ? theme.palette.text.warningStatus
81
+ : (resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "failed"
82
+ ? theme.palette.text.errorStatus
83
+ : (resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status) == "success"
84
+ ? theme.palette.text.alertStatus
85
+ : theme.palette.text.warningStatus,
86
+ fontSize: theme.typography.fontSize24,
87
+ fontWeight: theme.typography.fontWeight600,
88
+ textTransform: "capitalize",
89
+ }, children: resultData === null || resultData === void 0 ? void 0 : resultData.transaction_status }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: {
90
+ width: "100%",
91
+ color: theme.palette.text.accent,
92
+ mt: theme.mixins.customMargin.m12,
93
+ } }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { justifyContent: "space-between", mt: theme.mixins.customMargin.m16 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (_b = resultData === null || resultData === void 0 ? void 0 : resultData.currency_data) === null || _b === void 0 ? void 0 : _b.link, width: 20, height: 20, className: "rounded-full" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
94
+ fontSize: theme.typography.fontSize14,
95
+ fontWeight: theme.typography.fontWeight700,
96
+ }, children: resultData === null || resultData === void 0 ? void 0 : resultData.amount })] }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("swap_horizontal"), width: 20, height: 20 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: getInfoDetailOutputs === null || getInfoDetailOutputs === void 0 ? void 0 : getInfoDetailOutputs.link, width: 20, height: 20, className: "rounded-full" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
97
+ fontSize: theme.typography.fontSize14,
98
+ fontWeight: theme.typography.fontWeight700,
99
+ }, children: (0, roundToTwoSignificantDecimals_1.default)((resultData === null || resultData === void 0 ? void 0 : resultData.amount) * (getInfoDetailOutputs === null || getInfoDetailOutputs === void 0 ? void 0 : getInfoDetailOutputs.swap_amount)) })] })] }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: {
100
+ width: "100%",
101
+ color: theme.palette.text.accent,
102
+ mt: theme.mixins.customMargin.m12,
103
+ } }), (0, jsx_runtime_1.jsx)(LineValue_1.default, { sx: {
104
+ mt: theme.mixins.customMargin.m16,
105
+ mb: theme.mixins.customMargin.m16,
106
+ }, field: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
107
+ fontSize: theme.typography.fontSize12,
108
+ color: theme.palette.text.blackContrast,
109
+ }, children: "Price" }), value: (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: {
110
+ fontSize: theme.typography.fontSize14,
111
+ fontWeight: theme.typography.fontWeight700,
112
+ ml: theme.mixins.customMargin.m8,
113
+ }, children: ["1 ", (_c = resultData === null || resultData === void 0 ? void 0 : resultData.currency_data) === null || _c === void 0 ? void 0 : _c.full_name, " ~ ", getInfoDetailOutputs === null || getInfoDetailOutputs === void 0 ? void 0 : getInfoDetailOutputs.swap_amount, " ", getInfoDetailOutputs === null || getInfoDetailOutputs === void 0 ? void 0 : getInfoDetailOutputs.full_name] }) }), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
114
+ fontSize: theme.typography.fontSize12,
115
+ color: theme.palette.text.blackContrast,
116
+ }, children: "Date time" }), value: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
117
+ fontSize: theme.typography.fontSize14,
118
+ fontWeight: theme.typography.fontWeight700,
119
+ ml: theme.mixins.customMargin.m8,
120
+ }, children: (0, formatDate_1.default)(resultData === null || resultData === void 0 ? void 0 : resultData.date_created) }) })] })] }) }));
121
+ };
122
+ exports.default = DetailSwapResult;
@@ -0,0 +1,21 @@
1
+ import { SxProps } from "@mui/material";
2
+ import React from "react";
3
+ export declare enum DRAWER_DIRECTION {
4
+ TOP = "top",
5
+ BOTTOM = "bottom",
6
+ LEFT = "left",
7
+ RIGHT = "right"
8
+ }
9
+ interface Props {
10
+ anchor?: DRAWER_DIRECTION;
11
+ open: boolean;
12
+ onClose: () => void;
13
+ onOpen: () => void;
14
+ className?: string;
15
+ content: React.ReactNode;
16
+ title?: React.ReactNode;
17
+ footer?: React.ReactNode;
18
+ sx?: SxProps;
19
+ }
20
+ declare const DrawerDrag: ({ anchor, open, onClose, onOpen, content, title, footer, sx }: Props) => import("react/jsx-runtime").JSX.Element;
21
+ export default DrawerDrag;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DRAWER_DIRECTION = void 0;
4
+ var jsx_runtime_1 = require("react/jsx-runtime");
5
+ var material_1 = require("@mui/material");
6
+ var providers_1 = require("../../../providers");
7
+ var DRAWER_DIRECTION;
8
+ (function (DRAWER_DIRECTION) {
9
+ DRAWER_DIRECTION["TOP"] = "top";
10
+ DRAWER_DIRECTION["BOTTOM"] = "bottom";
11
+ DRAWER_DIRECTION["LEFT"] = "left";
12
+ DRAWER_DIRECTION["RIGHT"] = "right";
13
+ })(DRAWER_DIRECTION || (exports.DRAWER_DIRECTION = DRAWER_DIRECTION = {}));
14
+ var DrawerDrag = function (_a) {
15
+ var anchor = _a.anchor, open = _a.open, onClose = _a.onClose, onOpen = _a.onOpen, content = _a.content, title = _a.title, footer = _a.footer, sx = _a.sx;
16
+ var theme = (0, providers_1.useTheme)();
17
+ return ((0, jsx_runtime_1.jsx)(material_1.SwipeableDrawer, { anchor: anchor || DRAWER_DIRECTION.BOTTOM, open: open, onClose: onClose || (function () { }), onOpen: onOpen, sx: sx
18
+ ? sx
19
+ : {
20
+ "& .MuiDrawer-paper": {
21
+ backgroundColor: "transparent",
22
+ },
23
+ }, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "\n \"w-full border-t border-".concat(theme.palette.border.accent3, " bg-").concat(theme.palette.background.tertiary, " blur-[50px]\",\n className,\n ").concat(anchor === DRAWER_DIRECTION.BOTTOM && "min-h-[33dvh]", "\n "), children: [title, content, footer] }) }));
24
+ };
25
+ exports.default = DrawerDrag;
@@ -127,12 +127,12 @@ exports.default = Fees;
127
127
  var FeeDetails = function (_a) {
128
128
  var feeName = _a.feeName, fee_in_currency = _a.fee_in_currency, fee_in_usd = _a.fee_in_usd, currencyName = _a.currencyName;
129
129
  var theme = (0, ThemeProvider_1.useTheme)();
130
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
130
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4, justifyContent: "space-between" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
131
131
  fontSize: theme.typography.fontSize11,
132
132
  fontWeight: theme.typography.fontWeight500,
133
133
  lineHeight: theme.typography.leading160,
134
134
  color: theme.palette.text.accent,
135
135
  pl: theme.mixins.gaps.g12,
136
136
  whiteSpace: "nowrap",
137
- }, children: feeName }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Formatter_1.default, { sx: __assign({}, theme.mixins.value), value: fee_in_currency, unit: " ".concat(currencyName) }), (0, jsx_runtime_1.jsx)(Formatter_1.default, { sx: __assign({}, theme.mixins.valueDescription), value: fee_in_usd, start: "~ $" })] })] }));
137
+ }, children: feeName }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { alignItems: "end", gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Formatter_1.default, { sx: __assign({}, theme.mixins.value), value: fee_in_currency, unit: " ".concat(currencyName) }), (0, jsx_runtime_1.jsx)(Formatter_1.default, { sx: __assign({}, theme.mixins.valueDescription), value: fee_in_usd, start: "~ $" })] })] }));
138
138
  };
@@ -0,0 +1,9 @@
1
+ import { Output, SupportedToken } from "../../../services/axios/get-swap-tokens-list-service/type";
2
+ interface ModalSelectTokenProps {
3
+ setSwapToken?: (token: SupportedToken) => void;
4
+ token?: SupportedToken;
5
+ outputToken?: Output;
6
+ setOutputToken?: (output: Output) => void;
7
+ }
8
+ declare const ModalSelectToken: (props: ModalSelectTokenProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default ModalSelectToken;
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || (function () {
30
+ var ownKeys = function(o) {
31
+ ownKeys = Object.getOwnPropertyNames || function (o) {
32
+ var ar = [];
33
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
34
+ return ar;
35
+ };
36
+ return ownKeys(o);
37
+ };
38
+ return function (mod) {
39
+ if (mod && mod.__esModule) return mod;
40
+ var result = {};
41
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
42
+ __setModuleDefault(result, mod);
43
+ return result;
44
+ };
45
+ })();
46
+ var __importDefault = (this && this.__importDefault) || function (mod) {
47
+ return (mod && mod.__esModule) ? mod : { "default": mod };
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ var jsx_runtime_1 = require("react/jsx-runtime");
51
+ var material_1 = require("@mui/material");
52
+ var react_1 = require("react");
53
+ var useBoolean_1 = require("../../../hooks/useBoolean");
54
+ var CardToken_1 = __importDefault(require("../CardToken"));
55
+ var useWallet_1 = __importDefault(require("../../../hooks/useWallet"));
56
+ var PageHeader_1 = __importDefault(require("../PageHeader"));
57
+ var useCustomRouter_1 = __importDefault(require("../../../hooks/useCustomRouter"));
58
+ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
59
+ var DrawerDrag_1 = __importStar(require("../DrawerDrag"));
60
+ var Icon_1 = __importDefault(require("../Icon"));
61
+ var Text_1 = __importDefault(require("../Text"));
62
+ var providers_1 = require("../../../providers");
63
+ var ModalSelectToken = function (props) {
64
+ var setSwapToken = props.setSwapToken;
65
+ var selectTokenForm = (0, useBoolean_1.useBoolean)("selectTokenForm");
66
+ var selectTokenTo = (0, useBoolean_1.useBoolean)("selectTokenTo");
67
+ var open = selectTokenForm.value ? selectTokenForm.value : selectTokenTo.value;
68
+ var onOpen = selectTokenForm.value ? selectTokenForm.setTrue : selectTokenTo.setTrue;
69
+ var onClose = selectTokenForm.value ? selectTokenForm.setFalse : selectTokenTo.setFalse;
70
+ var _a = (0, useWallet_1.default)(), fromTokens = _a.fromTokens, updateSwapTokens = _a.updateSwapTokens;
71
+ var theme = (0, providers_1.useTheme)();
72
+ var router = (0, useCustomRouter_1.default)();
73
+ (0, react_1.useEffect)(function () {
74
+ if (fromTokens && fromTokens.length > 0 && !props.token && setSwapToken) {
75
+ setSwapToken(fromTokens[0]);
76
+ }
77
+ }, [fromTokens, props.token, setSwapToken, updateSwapTokens]);
78
+ var handleSelectToken = function (token) {
79
+ if (setSwapToken) {
80
+ setSwapToken(token);
81
+ }
82
+ onClose();
83
+ };
84
+ var handleOutputToken = function (output) {
85
+ if (props.setOutputToken) {
86
+ props.setOutputToken(output);
87
+ }
88
+ onClose();
89
+ };
90
+ return ((0, jsx_runtime_1.jsx)(DrawerDrag_1.default, { sx: {
91
+ "& .MuiDrawer-paper": {
92
+ width: "100%",
93
+ },
94
+ }, className: "!bg-white !rounded-none !size-full", anchor: DrawerDrag_1.DRAWER_DIRECTION.RIGHT, open: open, onClose: onClose, onOpen: onOpen, title: (0, jsx_runtime_1.jsx)(material_1.Box, { children: (0, jsx_runtime_1.jsx)(PageHeader_1.default, { overrideBack: onClose, onClick: onClose, title: selectTokenForm.value === true ? "Select from token" : "Select to token", rightAdornment: (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex gap-1 items-center ml-auto", children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { onClick: function () { return router.push("/help"); }, src: (0, getIcon_1.default)("help") }), (0, jsx_runtime_1.jsx)(material_1.Divider, { orientation: "vertical", sx: {
95
+ height: "15px",
96
+ width: "1px",
97
+ backgroundColor: theme.palette.border.accent3,
98
+ marginLeft: theme.mixins.customMargin.m4,
99
+ marginRight: theme.mixins.customMargin.m4,
100
+ } }), (0, jsx_runtime_1.jsx)(Icon_1.default, { onClick: function () { return router.push("/history"); }, src: (0, getIcon_1.default)("history") })] }) }) }), content: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.pagePadding), children: [(0, jsx_runtime_1.jsx)(material_1.InputBase, { startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, { className: "size-5 text-black", position: "start", children: (0, jsx_runtime_1.jsx)(Icon_1.default, { className: "size-5", src: (0, getIcon_1.default)("search") }) }), placeholder: "Search", sx: {
101
+ "input::placeholder": {
102
+ fontSize: theme.typography.fontSize12,
103
+ color: theme.palette.text.black,
104
+ fontWeight: theme.typography.fontWeight500,
105
+ pl: theme.mixins.customPadding.p4,
106
+ },
107
+ }, className: "w-full flex items-center py-1 px-2 rounded-12 border border-".concat(theme.palette.border.accent3, " bg-white text-black") }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "py-4 mt-3 h-[50dvh] space-y-3", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex justify-between items-center", children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center gap-1", children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
108
+ color: theme.palette.text.accent,
109
+ fontSize: theme.typography.fontSize12,
110
+ fontWeight: theme.typography.fontWeight600,
111
+ }, children: "Token" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.column), className: "items-center gap-0.5", children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_drop_up") }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_drop_down") })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center gap-1", children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
112
+ color: theme.palette.text.accent,
113
+ fontSize: theme.typography.fontSize12,
114
+ fontWeight: theme.typography.fontWeight600,
115
+ }, children: "Balance" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { className: "flex items-center gap-0.5 flex-col", children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_drop_up") }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_drop_down") })] })] })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { className: "space-y-3", children: selectTokenForm.value
116
+ ? fromTokens === null || fromTokens === void 0 ? void 0 : fromTokens.map(function (token) {
117
+ var _a;
118
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { onClick: function () { return handleSelectToken(token); }, children: (0, jsx_runtime_1.jsx)(CardToken_1.default, { icon: token.link, symbol: token.full_name, price: "".concat(Number(token.balance).toFixed(2)), balance: token.name, rate: String(Number(token.usd_rate)), isActive: token.id === ((_a = props.token) === null || _a === void 0 ? void 0 : _a.id) }, token.id) }, token.id));
119
+ })
120
+ : selectTokenTo.value &&
121
+ props.token &&
122
+ props.token.outputs.map(function (output) {
123
+ var _a;
124
+ return ((0, jsx_runtime_1.jsx)(material_1.Box, { onClick: function () { return handleOutputToken(output); }, children: (0, jsx_runtime_1.jsx)(CardToken_1.default, { icon: output.link, symbol: output.full_name, price: "".concat(Number(output.balance).toFixed(2)), balance: output.name, rate: String(Number(output.usd_rate)), isActive: output.id === ((_a = props.outputToken) === null || _a === void 0 ? void 0 : _a.id) }, output.id) }, output.id));
125
+ }) })] })] }) }));
126
+ };
127
+ exports.default = ModalSelectToken;
@@ -0,0 +1,11 @@
1
+ import { GeneralProps, UnknownFunction } from "../../../types/ui";
2
+ interface SwapFunctionProps extends GeneralProps {
3
+ onClose?: UnknownFunction;
4
+ onOpen?: UnknownFunction;
5
+ }
6
+ export type SwapFunctionRef = {
7
+ open: () => void;
8
+ close: () => void;
9
+ };
10
+ export declare const SwapFunction: import("react").ForwardRefExoticComponent<SwapFunctionProps & import("react").RefAttributes<SwapFunctionRef>>;
11
+ export default SwapFunction;
@@ -0,0 +1,195 @@
1
+ "use strict";
2
+ "use client";
3
+ var __assign = (this && this.__assign) || function () {
4
+ __assign = Object.assign || function(t) {
5
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
6
+ s = arguments[i];
7
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
8
+ t[p] = s[p];
9
+ }
10
+ return t;
11
+ };
12
+ return __assign.apply(this, arguments);
13
+ };
14
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ var desc = Object.getOwnPropertyDescriptor(m, k);
17
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
18
+ desc = { enumerable: true, get: function() { return m[k]; } };
19
+ }
20
+ Object.defineProperty(o, k2, desc);
21
+ }) : (function(o, m, k, k2) {
22
+ if (k2 === undefined) k2 = k;
23
+ o[k2] = m[k];
24
+ }));
25
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
26
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
27
+ }) : function(o, v) {
28
+ o["default"] = v;
29
+ });
30
+ var __importStar = (this && this.__importStar) || (function () {
31
+ var ownKeys = function(o) {
32
+ ownKeys = Object.getOwnPropertyNames || function (o) {
33
+ var ar = [];
34
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
35
+ return ar;
36
+ };
37
+ return ownKeys(o);
38
+ };
39
+ return function (mod) {
40
+ if (mod && mod.__esModule) return mod;
41
+ var result = {};
42
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
43
+ __setModuleDefault(result, mod);
44
+ return result;
45
+ };
46
+ })();
47
+ var __importDefault = (this && this.__importDefault) || function (mod) {
48
+ return (mod && mod.__esModule) ? mod : { "default": mod };
49
+ };
50
+ var _a;
51
+ Object.defineProperty(exports, "__esModule", { value: true });
52
+ exports.SwapFunction = void 0;
53
+ var jsx_runtime_1 = require("react/jsx-runtime");
54
+ var react_1 = require("react");
55
+ var DrawerComponent_1 = __importStar(require("../DrawerComponent"));
56
+ var SwiperControlled_1 = __importDefault(require("../SwiperControlled"));
57
+ var react_2 = require("swiper/react");
58
+ var BackHeader_1 = __importDefault(require("../BackHeader"));
59
+ var Text_1 = __importDefault(require("../Text"));
60
+ var material_1 = require("@mui/material");
61
+ var Button_1 = __importDefault(require("../Button"));
62
+ var Icon_1 = __importDefault(require("../Icon"));
63
+ var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
64
+ var RequireConnect_1 = __importDefault(require("../RequireConnect"));
65
+ var ThemeProvider_1 = require("../../../providers/ThemeProvider");
66
+ var ChildPageLayout_1 = __importDefault(require("../../layouts/ChildPageLayout"));
67
+ var CardFrom_1 = __importDefault(require("../CardFrom"));
68
+ var CardTo_1 = __importDefault(require("../CardTo"));
69
+ var DetailSwap_1 = __importDefault(require("../DetailSwap"));
70
+ var ModalSelectToken_1 = __importDefault(require("../ModalSelectToken"));
71
+ var useCustomRouter_1 = __importDefault(require("../../../hooks/useCustomRouter"));
72
+ var SwapToken_1 = __importDefault(require("../SwapToken"));
73
+ var SwapStep;
74
+ (function (SwapStep) {
75
+ SwapStep[SwapStep["SELECT_SWAP"] = 0] = "SELECT_SWAP";
76
+ })(SwapStep || (SwapStep = {}));
77
+ var SWAP_STEP_NAME = (_a = {},
78
+ _a[SwapStep.SELECT_SWAP] = "Swap",
79
+ _a);
80
+ exports.SwapFunction = (0, react_1.forwardRef)(function (props, ref) {
81
+ var _a, _b, _c, _d, _e, _f, _g;
82
+ var drawerRef = (0, react_1.useRef)(null);
83
+ var swiperRef = (0, react_1.useRef)(null);
84
+ var theme = (0, ThemeProvider_1.useTheme)();
85
+ var _h = (0, react_1.useState)(SwapStep.SELECT_SWAP), currentStep = _h[0], setCurrentStep = _h[1];
86
+ var _j = (0, react_1.useState)(null), selectedToken = _j[0], setSelectedToken = _j[1];
87
+ var _k = (0, react_1.useState)(null), selectedOutputToken = _k[0], setSelectedOutputToken = _k[1];
88
+ var _l = (0, react_1.useState)(null), number = _l[0], setNumber = _l[1];
89
+ var router = (0, useCustomRouter_1.default)();
90
+ var onChange = (0, react_1.useCallback)(function (e) {
91
+ var value = e.target.value;
92
+ setNumber(value === "" ? null : Number(value));
93
+ }, []);
94
+ var handleBack = function () {
95
+ var _a;
96
+ gotoStep(currentStep - 1);
97
+ if (currentStep === SwapStep.SELECT_SWAP) {
98
+ (_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
99
+ setNumber(null);
100
+ }
101
+ };
102
+ var gotoStep = function (step) {
103
+ var _a;
104
+ if (step === SwapStep.SELECT_SWAP) {
105
+ }
106
+ setCurrentStep(step);
107
+ (_a = swiperRef.current) === null || _a === void 0 ? void 0 : _a.slideTo(step);
108
+ };
109
+ var handleSelectToken = function (token) {
110
+ if (!selectedToken || selectedToken.id !== token.id) {
111
+ setSelectedToken(token);
112
+ }
113
+ };
114
+ var handleSelectOutputToken = function (output) {
115
+ if (!selectedOutputToken || selectedOutputToken.id !== output.id) {
116
+ setSelectedOutputToken(output);
117
+ }
118
+ };
119
+ var handleOnClose = function () {
120
+ var _a;
121
+ (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
122
+ gotoStep(SwapStep.SELECT_SWAP);
123
+ };
124
+ var resetNumber = (0, react_1.useCallback)(function () {
125
+ setNumber(null);
126
+ }, []);
127
+ (0, react_1.useEffect)(function () {
128
+ if (selectedToken) {
129
+ var outputs = selectedToken.outputs;
130
+ if (outputs.length > 0) {
131
+ if (!selectedOutputToken || !outputs.some(function (t) { return t.id === selectedOutputToken.id; })) {
132
+ setSelectedOutputToken(outputs[0]);
133
+ }
134
+ }
135
+ else {
136
+ setSelectedOutputToken(null);
137
+ }
138
+ }
139
+ else {
140
+ setSelectedOutputToken(null);
141
+ }
142
+ }, [selectedToken, selectedOutputToken]);
143
+ (0, react_1.useImperativeHandle)(ref, function () { return ({
144
+ open: open,
145
+ close: close,
146
+ }); });
147
+ return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: drawerRef, trigger: props.children, onOpen: props.onOpen, onClose: handleOnClose, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, children: (0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { sx: {
148
+ padding: theme.mixins.pagePadding,
149
+ position: "relative",
150
+ }, header: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
151
+ mr: theme.mixins.customMargin.m12,
152
+ ml: theme.mixins.customMargin.m12,
153
+ mt: theme.mixins.customMargin.m10,
154
+ }, children: (0, jsx_runtime_1.jsx)(BackHeader_1.default, { sx: {
155
+ width: "100%",
156
+ display: "flex",
157
+ alignItems: "center",
158
+ minHeight: "2rem",
159
+ mb: theme.mixins.customMargin.m20,
160
+ }, overrideBack: handleBack, center: SWAP_STEP_NAME[currentStep], children: currentStep === SwapStep.SELECT_SWAP && ((0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("help"), width: 18, height: 18, sx: { marginLeft: "auto", mr: theme.mixins.customMargin.m12 }, onClick: function () { return router.push("/help"); } })) }) }), footer: currentStep === SwapStep.SELECT_SWAP && ((0, jsx_runtime_1.jsx)(material_1.Box, { className: "px-4 w-full relative bottom-6", children: (0, jsx_runtime_1.jsx)(SwapToken_1.default, { onResetNumber: resetNumber, sx: {
161
+ width: "100%",
162
+ }, sendData: {
163
+ amount: number !== null ? number.toString() : "",
164
+ currency_slug: (_a = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug) !== null && _a !== void 0 ? _a : "",
165
+ to_currency_slug: (_b = selectedOutputToken === null || selectedOutputToken === void 0 ? void 0 : selectedOutputToken.slug) !== null && _b !== void 0 ? _b : "",
166
+ network: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.network_data[0],
167
+ }, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { disabled: !number ||
168
+ number < ((_c = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.min_value) !== null && _c !== void 0 ? _c : 0) ||
169
+ number > ((_d = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.max_value) !== null && _d !== void 0 ? _d : 0) ||
170
+ number > Number(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.balance), sx: __assign(__assign({ gap: theme.mixins.gaps.g4 }, theme.mixins.row), { color: theme.palette.text.secondary, borderRadius: theme.mixins.customRadius.r12, height: "40px" }), fullWidth: true, children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
171
+ fontSize: theme.typography.fontSize12,
172
+ fontWeight: theme.typography.fontWeight600,
173
+ leading: theme.typography.leading160,
174
+ textTransform: "none",
175
+ color: "".concat((number && number < ((_e = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.min_value) !== null && _e !== void 0 ? _e : 0)) ||
176
+ (number && number > ((_f = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.max_value) !== null && _f !== void 0 ? _f : 0)) ||
177
+ (number && number > ((_g = Number(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.balance)) !== null && _g !== void 0 ? _g : 0)) ||
178
+ !number
179
+ ? theme.palette.text.accent
180
+ : theme.palette.secondary.main),
181
+ }, children: "Preview swap" }) }) }, "".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug, "-").concat(selectedOutputToken === null || selectedOutputToken === void 0 ? void 0 : selectedOutputToken.slug)) })), children: (0, jsx_runtime_1.jsx)(SwiperControlled_1.default, { ref: swiperRef, swiperProps: {
182
+ autoHeight: true,
183
+ spaceBetween: 32,
184
+ }, disableSwipe: true, initialActiveTab: currentStep, children: (0, jsx_runtime_1.jsxs)(react_2.SwiperSlide, { children: [(0, jsx_runtime_1.jsx)(CardFrom_1.default, { onChange: onChange, selectedToken: selectedToken !== null && selectedToken !== void 0 ? selectedToken : undefined, number: number !== null && number !== void 0 ? number : undefined }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", gap: 1, sx: {
185
+ mt: "1rem",
186
+ mb: "1rem",
187
+ }, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("swap_icon"), width: 18, height: 18 }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: {
188
+ width: "90%",
189
+ borderStyle: "dashed",
190
+ borderColor: "#A3A3A3",
191
+ opacity: 0.3,
192
+ } })] }), (0, jsx_runtime_1.jsx)(CardTo_1.default, { selectedOutputToken: selectedOutputToken !== null && selectedOutputToken !== void 0 ? selectedOutputToken : undefined, token: selectedToken !== null && selectedToken !== void 0 ? selectedToken : undefined, value: number !== null && number !== void 0 ? number : undefined }), (0, jsx_runtime_1.jsx)(DetailSwap_1.default, { selectedToken: selectedToken !== null && selectedToken !== void 0 ? selectedToken : undefined, selectOutputToken: selectedOutputToken !== null && selectedOutputToken !== void 0 ? selectedOutputToken : undefined }), (0, jsx_runtime_1.jsx)(ModalSelectToken_1.default, { setSwapToken: handleSelectToken, token: selectedToken !== null && selectedToken !== void 0 ? selectedToken : undefined, outputToken: selectedOutputToken !== null && selectedOutputToken !== void 0 ? selectedOutputToken : undefined, setOutputToken: handleSelectOutputToken })] }, SwapStep.SELECT_SWAP) }, selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.id) }) }) }));
193
+ });
194
+ exports.SwapFunction.displayName = "SwapFunction";
195
+ exports.default = exports.SwapFunction;
@@ -12,6 +12,7 @@ interface SwapTokenProps extends Omit<ConfirmLayoutProps, "action"> {
12
12
  initFeeData?: FeesDataType;
13
13
  onStart?: () => void;
14
14
  sx?: SxProps;
15
+ onResetNumber?: () => void;
15
16
  }
16
17
  export interface SwapTokenRef {
17
18
  open: () => void;
@@ -89,6 +89,8 @@ var jsx_runtime_1 = require("react/jsx-runtime");
89
89
  var material_1 = require("@mui/material");
90
90
  var ThemeProvider_1 = require("../../../providers/ThemeProvider");
91
91
  var Button_1 = __importStar(require("../Button"));
92
+ var DrawerComponent_1 = require("../DrawerComponent");
93
+ var DrawerComponent_2 = __importDefault(require("../DrawerComponent"));
92
94
  var ConfirmLayout_1 = __importDefault(require("../ConfirmLayout"));
93
95
  var LineValue_1 = __importDefault(require("../LineValue"));
94
96
  var Formatter_1 = __importDefault(require("../Formatter"));
@@ -106,6 +108,8 @@ var Icon_1 = __importDefault(require("../Icon"));
106
108
  var roundToTwoSignificantDecimals_1 = __importDefault(require("../../../utils/roundToTwoSignificantDecimals"));
107
109
  var getImage_1 = __importDefault(require("../../../utils/getImage"));
108
110
  var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
111
+ var DetailSwapResult_1 = __importDefault(require("../DetailSwapResult"));
112
+ var useWallet_1 = __importDefault(require("../../../hooks/useWallet"));
109
113
  var SwapTokenError;
110
114
  (function (SwapTokenError) {
111
115
  SwapTokenError["TOKEN_NOT_FOUND"] = "Token not found";
@@ -121,12 +125,15 @@ exports.SwapToken = (0, react_1.forwardRef)(function (props, ref) {
121
125
  var _b = (0, useSwapData_1.default)(), fromTokens = _b.fromTokens, updateSwapTokens = _b.updateSwapTokens;
122
126
  var isInitPasscode = (0, useWalletData_1.default)().isInitPasscode;
123
127
  var confirmLayoutDrawerRef = (0, react_1.useRef)(null);
128
+ var detailResultDrawerRef = (0, react_1.useRef)(null);
124
129
  var _c = (0, react_1.useState)(undefined), error = _c[0], setError = _c[1];
125
130
  var _d = (0, react_1.useState)(undefined), errorAmount = _d[0], setErrorAmount = _d[1];
126
131
  var _e = (0, react_1.useState)(Button_1.BUTTON_STATUS.ENABLED), buttonStatus = _e[0], setButtonStatus = _e[1];
127
132
  var _f = (0, react_1.useState)(props.initFeeData), estimateFee = _f[0], setEstimateFee = _f[1];
128
133
  var _g = (0, react_1.useState)(false), isLoadingEstimateFee = _g[0], setIsLoadingEstimateFee = _g[1];
129
134
  var activitiesRef = (0, react_1.useRef)(null);
135
+ var _h = (0, react_1.useState)(undefined), swapResult = _h[0], setSwapResult = _h[1];
136
+ var transaction = (0, useWallet_1.default)().transaction;
130
137
  var amount = props.sendData.amount;
131
138
  var network = props.sendData.network;
132
139
  var fromTokenSlug = props.sendData.currency_slug;
@@ -167,7 +174,7 @@ exports.SwapToken = (0, react_1.forwardRef)(function (props, ref) {
167
174
  return [2 /*return*/, true];
168
175
  }
169
176
  });
170
- }); }, [amount, fromTokenSlug]);
177
+ }); }, [amount, fromTokenSlug, toTokenSlug]);
171
178
  var token = (0, react_1.useMemo)(function () {
172
179
  return fromTokens === null || fromTokens === void 0 ? void 0 : fromTokens.find(function (token) { return token.slug === fromTokenSlug; });
173
180
  }, [fromTokenSlug, fromTokens]);
@@ -217,13 +224,18 @@ exports.SwapToken = (0, react_1.forwardRef)(function (props, ref) {
217
224
  case 1:
218
225
  response = _c.sent();
219
226
  if (response.success) {
227
+ setSwapResult(response);
220
228
  (_a = confirmLayoutDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
221
229
  setButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
230
+ setTimeout(function () {
231
+ var _a;
232
+ (_a = detailResultDrawerRef.current) === null || _a === void 0 ? void 0 : _a.open();
233
+ }, 300);
222
234
  (_b = props.onSuccess) === null || _b === void 0 ? void 0 : _b.call(props, response);
223
235
  setTimeout(function () {
224
236
  var _a;
225
237
  (_a = activitiesRef.current) === null || _a === void 0 ? void 0 : _a.openTab(0);
226
- }, 200);
238
+ }, 1000);
227
239
  }
228
240
  else {
229
241
  throw new Error("Swap internal failed");
@@ -254,6 +266,12 @@ exports.SwapToken = (0, react_1.forwardRef)(function (props, ref) {
254
266
  throw new Error("Please connect your wallet");
255
267
  (_a = confirmLayoutDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
256
268
  };
269
+ var handleDetailSwapClose = function () {
270
+ var _a, _b;
271
+ (_a = detailResultDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
272
+ (_b = props === null || props === void 0 ? void 0 : props.onResetNumber) === null || _b === void 0 ? void 0 : _b.call(props);
273
+ setSwapResult(undefined);
274
+ };
257
275
  (0, react_1.useImperativeHandle)(ref, function () { return ({
258
276
  open: handleOpen,
259
277
  close: handleClose,
@@ -268,11 +286,13 @@ exports.SwapToken = (0, react_1.forwardRef)(function (props, ref) {
268
286
  updateSwapTokens();
269
287
  }
270
288
  }, [isInitPasscode, fromTokens]);
271
- return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: (0, jsx_runtime_1.jsxs)(ConfirmLayout_1.default, { onOpen: validateAll, ref: confirmLayoutDrawerRef, action: transactionSlug, trigger: props.children, sx: sx, title: "You receive",
272
- // amount={estimateReceive}
273
- // link={toToken?.link}
274
- // currency={toToken?.full_name}
275
- confirmAction: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: transactionSlug, onConfirmSuccess: handleSwapToken, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: !!error || isLoadingEstimateFee ? Button_1.BUTTON_STATUS.DISABLED : buttonStatus, sx: { width: "100%" }, children: "Swap" }) }), children: [!!fromToken && !!toToken && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.paper), { backgroundColor: "transparent" }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { alignItems: "start", gap: theme.mixins.gaps.g12, backgroundColor: theme.palette.background.primary, backgroundImage: "url(".concat((0, getImage_1.default)("logo_transfer", "png"), ")"), backgroundPosition: "right", backgroundRepeat: "no-repeat", padding: theme.mixins.customPadding.p16, borderRadius: theme.mixins.customRadius.r16 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g16, width: "100%" }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g6 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: fromToken === null || fromToken === void 0 ? void 0 : fromToken.link, width: 20, height: 20, className: "rounded-full" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeight600, color: theme.palette.text.white }), children: fromToken === null || fromToken === void 0 ? void 0 : fromToken.name })] }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.bigValue), { ml: "auto", color: theme.palette.text.white }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: amount }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", gap: theme.mixins.gaps.g2, sx: {
289
+ return ((0, jsx_runtime_1.jsxs)(RequireConnect_1.default, { children: [(0, jsx_runtime_1.jsxs)(ConfirmLayout_1.default, { onOpen: validateAll, ref: confirmLayoutDrawerRef, action: transactionSlug, trigger: props.children, sx: sx, title: "You receive",
290
+ // amount={estimateReceive}
291
+ // link={toToken?.link}
292
+ // currency={toToken?.full_name}
293
+ confirmAction: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: transactionSlug, onConfirmSuccess: handleSwapToken, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: !!error || isLoadingEstimateFee || (estimateReceive && estimateReceive < 0)
294
+ ? Button_1.BUTTON_STATUS.DISABLED
295
+ : buttonStatus, sx: { width: "100%" }, children: "Swap" }) }), children: [!!fromToken && !!toToken && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { alignItems: "start", gap: theme.mixins.gaps.g12, backgroundColor: theme.palette.background.primary, backgroundImage: "url(".concat((0, getImage_1.default)("logo_transfer", "png"), ")"), backgroundPosition: "right", backgroundRepeat: "no-repeat", padding: theme.mixins.customPadding.p16, borderRadius: theme.mixins.customRadius.r16 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g16, width: "100%" }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g6 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: fromToken === null || fromToken === void 0 ? void 0 : fromToken.link, width: 20, height: 20, className: "rounded-full" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeight600, color: theme.palette.text.white }), children: fromToken === null || fromToken === void 0 ? void 0 : fromToken.name })] }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.bigValue), { ml: "auto", color: theme.palette.text.white }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: amount }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", gap: theme.mixins.gaps.g2, sx: {
276
296
  width: "100%",
277
297
  mt: theme.mixins.customMargin.m4,
278
298
  mb: theme.mixins.customMargin.m4,
@@ -284,14 +304,14 @@ exports.SwapToken = (0, react_1.forwardRef)(function (props, ref) {
284
304
  fontSize: theme.typography.fontSize18,
285
305
  fontWeight: theme.typography.fontWeight700,
286
306
  color: theme.palette.text.black,
287
- }, children: "Transfer Summary" }) }), ((_a = estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.fee_detail) === null || _a === void 0 ? void 0 : _a.length) && !!amount && ((0, jsx_runtime_1.jsx)(Fees_1.default, { isFeePaidByAmount: true, feesData: JSON.stringify(estimateFee), amount: +amount, tokenSlug: fromTokenSlug })), !estimateFee && !!amount && isLoadingEstimateFee && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8, width: "100%" }), children: [(0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 16, sx: { color: theme.palette.text.white } }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { color: "text.white" }, children: "Calculating fee" })] })), !!estimateReceive && !error && ((0, jsx_runtime_1.jsx)(LineValue_1.default, { value: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign(__assign({}, theme.mixins.row), theme.mixins.valueDescription), { width: "100%", justifyContent: "center", color: theme.palette.text.black, fontWeight: theme.typography.fontWeight500, gap: theme.mixins.gaps.g2 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("ellipse"), width: 12, height: 12 }), "1 ", fromToken === null || fromToken === void 0 ? void 0 : fromToken.name, " =", (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g2 }), children: [(0, jsx_runtime_1.jsx)(Formatter_1.default, { value: 1 / +(toToken === null || toToken === void 0 ? void 0 : toToken.usd_rate) }), " ", toToken === null || toToken === void 0 ? void 0 : toToken.name] })] }), field: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
307
+ }, children: "Transfer Summary" }) }), ((_a = estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.fee_detail) === null || _a === void 0 ? void 0 : _a.length) && !!amount && ((0, jsx_runtime_1.jsx)(Fees_1.default, { isFeePaidByAmount: true, feesData: JSON.stringify(estimateFee), amount: +amount, tokenSlug: fromTokenSlug })), !estimateFee && !!amount && isLoadingEstimateFee && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8, width: "100%" }), children: [(0, jsx_runtime_1.jsx)(material_1.CircularProgress, { size: 16, sx: { color: theme.palette.text.white } }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { color: "text.white" }, children: "Calculating fee" })] })), !!estimateReceive && !error && ((0, jsx_runtime_1.jsx)(LineValue_1.default, { value: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign(__assign({}, theme.mixins.row), theme.mixins.valueDescription), { width: "100%", justifyContent: "center", color: theme.palette.text.black, fontWeight: theme.typography.fontWeight500, gap: theme.mixins.gaps.g2 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("ellipse"), width: 12, height: 12 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g2, alignContent: "center" }), children: ["1 ", fromToken === null || fromToken === void 0 ? void 0 : fromToken.name, " =", (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: 1 / +(toToken === null || toToken === void 0 ? void 0 : toToken.usd_rate) }), " ", toToken === null || toToken === void 0 ? void 0 : toToken.name] })] }), field: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
288
308
  color: theme.palette.text.black,
289
309
  fontWeight: theme.typography.fontWeight600,
290
310
  }, children: "Best Price" }) })), !!estimateReceive && !error && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "100%", gap: theme.mixins.gaps.g8, mt: theme.mixins.customMargin.m8 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("warning"), width: 18, height: 18 }), (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: {
291
311
  color: theme.palette.text.primary,
292
312
  fontWeight: theme.typography.fontWeight600,
293
313
  fontSize: theme.typography.fontSize13,
294
- }, children: ["You will receive at least ", "".concat(estimateReceive, " ").concat(toToken === null || toToken === void 0 ? void 0 : toToken.name), " ", "(~".concat((0, roundToTwoSignificantDecimals_1.default)(estimateReceive), ")"), " or the transaction will refunded"] })] })), !!error && ((0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { mt: theme.mixins.customMargin.m6 }), children: [error, " ", !!errorAmount && (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: errorAmount, unit: " ".concat(token === null || token === void 0 ? void 0 : token.name) })] }))] }) })), (!fromToken || !toToken) && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.paper), { alignItems: "center", justifyContent: "center" }), children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { fontSize: theme.typography.fontSize16 }), children: SwapTokenError.TOKEN_NOT_FOUND }) }))] }) }));
314
+ }, children: ["You will receive at least ", "".concat(estimateReceive, " ").concat(toToken === null || toToken === void 0 ? void 0 : toToken.name), " ", "(~".concat((0, roundToTwoSignificantDecimals_1.default)(estimateReceive), ")"), " or the transaction will refunded"] })] })), !!error && ((0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { mt: theme.mixins.customMargin.m6 }), children: [error, " ", !!errorAmount && (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: errorAmount, unit: " ".concat(token === null || token === void 0 ? void 0 : token.name) })] }))] })), (!fromToken || !toToken) && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.paper), { alignItems: "center", justifyContent: "center" }), children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { fontSize: theme.typography.fontSize16 }), children: SwapTokenError.TOKEN_NOT_FOUND }) }))] }), swapResult && ((0, jsx_runtime_1.jsx)(DrawerComponent_2.default, { ref: detailResultDrawerRef, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, children: swapResult && transaction && (transaction === null || transaction === void 0 ? void 0 : transaction.id) && ((0, jsx_runtime_1.jsx)(DetailSwapResult_1.default, { swapData: swapResult, onClose: handleDetailSwapClose })) }))] }));
295
315
  });
296
316
  exports.SwapToken.displayName = "SwapToken";
297
317
  exports.default = exports.SwapToken;
@@ -28,6 +28,7 @@ var useWalletData_1 = __importDefault(require("../../../hooks/useWalletData"));
28
28
  var Text_1 = __importDefault(require("../../ui/Text"));
29
29
  var ThemeProvider_1 = require("../../../providers/ThemeProvider");
30
30
  var AmountGroupAndChart_1 = __importDefault(require("../../ui/AmountGroupAndChart"));
31
+ var SwapFunction_1 = __importDefault(require("../../ui/SwapFunction"));
31
32
  var AssetView = function (props) {
32
33
  var isInitPasscode = (0, useWalletData_1.default)().isInitPasscode;
33
34
  var theme = (0, ThemeProvider_1.useTheme)();
@@ -56,11 +57,13 @@ var AssetView = function (props) {
56
57
  borderRight: "1px solid ".concat(theme.palette.border.accent3),
57
58
  placeContent: "center",
58
59
  columnSpan: 1,
59
- }, children: (0, jsx_runtime_1.jsx)(FunctionItem_1.default, { icon: (0, getIcon_1.default)("withdraw"), label: "Withdraw", sx: { width: "100%" } }) }) }), (0, jsx_runtime_1.jsx)(material_1.ListItem, { sx: {
60
- borderRight: "1px solid ".concat(theme.palette.border.accent3),
61
- placeContent: "center",
62
- columnSpan: 1,
63
- }, children: (0, jsx_runtime_1.jsx)(FunctionItem_1.default, { icon: (0, getIcon_1.default)("fortune", "gif"), label: "Fortune", sx: { width: "100%" } }) }), (0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(FunctionItem_1.default, { icon: (0, getIcon_1.default)("p2p", "gif"), label: "P2P", sx: { width: "100%" } }) })] }), (0, jsx_runtime_1.jsx)(TokensBoard_1.default, {})] })))] }));
60
+ }, children: (0, jsx_runtime_1.jsx)(FunctionItem_1.default, { icon: (0, getIcon_1.default)("withdraw"), label: "Withdraw", sx: { width: "100%" } }) }) }), (0, jsx_runtime_1.jsx)(SwapFunction_1.default, { children: (0, jsx_runtime_1.jsx)(material_1.ListItem, { sx: {
61
+ borderRight: "1px solid ".concat(theme.palette.border.accent3),
62
+ placeContent: "center",
63
+ columnSpan: 1,
64
+ }, children: (0, jsx_runtime_1.jsx)(FunctionItem_1.default, { icon: (0, getIcon_1.default)("swap"), label: "Swap", sx: {
65
+ width: "100%",
66
+ } }) }) }), (0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(FunctionItem_1.default, { icon: (0, getIcon_1.default)("p2p", "gif"), label: "P2P", sx: { width: "100%" } }) })] }), (0, jsx_runtime_1.jsx)(TokensBoard_1.default, {})] })))] }));
64
67
  };
65
68
  exports.AssetView = AssetView;
66
69
  exports.default = exports.AssetView;
@@ -0,0 +1,2 @@
1
+ declare const HelpView: () => import("react/jsx-runtime").JSX.Element;
2
+ export default HelpView;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var jsx_runtime_1 = require("react/jsx-runtime");
4
+ var HelpView = function () {
5
+ return (0, jsx_runtime_1.jsx)("div", { children: "HelpView" });
6
+ };
7
+ exports.default = HelpView;
@@ -0,0 +1,9 @@
1
+ type BooleanState = {
2
+ value: boolean;
3
+ setValue: React.Dispatch<React.SetStateAction<boolean>>;
4
+ setTrue: () => void;
5
+ setFalse: () => void;
6
+ toggle: () => void;
7
+ };
8
+ export declare const useBoolean: (key: string) => BooleanState;
9
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useBoolean = void 0;
4
+ var react_1 = require("react");
5
+ var sharedState = {};
6
+ var listeners = {};
7
+ var useBoolean = function (key) {
8
+ var _a;
9
+ var _b = (0, react_1.useState)((_a = sharedState[key]) !== null && _a !== void 0 ? _a : false), value = _b[0], setValue = _b[1];
10
+ if (!listeners[key]) {
11
+ listeners[key] = new Set();
12
+ }
13
+ listeners[key].add(setValue);
14
+ var notifyAll = function (newVal) {
15
+ sharedState[key] = newVal;
16
+ listeners[key].forEach(function (listener) { return listener(newVal); });
17
+ };
18
+ var setTrue = (0, react_1.useCallback)(function () { return notifyAll(true); }, [key]);
19
+ var setFalse = (0, react_1.useCallback)(function () { return notifyAll(false); }, [key]);
20
+ var toggle = (0, react_1.useCallback)(function () { return notifyAll(!sharedState[key]); }, [key]);
21
+ return {
22
+ value: value,
23
+ setValue: function (val) {
24
+ var _a;
25
+ var newValue = typeof val === "function" ? val((_a = sharedState[key]) !== null && _a !== void 0 ? _a : false) : val;
26
+ notifyAll(newValue);
27
+ },
28
+ setTrue: setTrue,
29
+ setFalse: setFalse,
30
+ toggle: toggle,
31
+ };
32
+ };
33
+ exports.useBoolean = useBoolean;
@@ -48,4 +48,5 @@ export interface Output {
48
48
  icon_svg: string;
49
49
  network_data: NetworkData[];
50
50
  balance: string;
51
+ swap_amount: number;
51
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.637",
3
+ "version": "0.0.638",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",