tek-wallet 0.0.752 → 0.0.753
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/TekWallet/components/index.d.ts +7 -0
- package/dist/components/TekWallet/components/index.js +7 -0
- package/dist/components/TekWallet/components/layouts/ChildPageLayout/index.js +14 -3
- package/dist/components/TekWallet/components/ui/BackHeader/index.js +5 -1
- package/dist/components/TekWallet/components/ui/BottomActionLayout/index.d.ts +3 -3
- package/dist/components/TekWallet/components/ui/BottomActionLayout/index.js +24 -6
- package/dist/components/TekWallet/components/ui/Button/index.js +2 -2
- package/dist/components/TekWallet/components/ui/ConfirmByPasscode/index.js +2 -6
- package/dist/components/TekWallet/components/ui/ConfirmSendExternal/index.d.ts +6 -2
- package/dist/components/TekWallet/components/ui/ConfirmSendExternal/index.js +92 -12
- package/dist/components/TekWallet/components/ui/ConfirmSendInternal/index.d.ts +4 -2
- package/dist/components/TekWallet/components/ui/ConfirmSendInternal/index.js +12 -4
- package/dist/components/TekWallet/components/ui/ConfirmSwapToken/Result.d.ts +8 -0
- package/dist/components/TekWallet/components/ui/ConfirmSwapToken/Result.js +112 -0
- package/dist/components/TekWallet/components/ui/ConfirmSwapToken/index.d.ts +18 -0
- package/dist/components/TekWallet/components/ui/ConfirmSwapToken/index.js +169 -0
- package/dist/components/TekWallet/components/ui/CopyableText/index.js +1 -1
- package/dist/components/TekWallet/components/ui/DetailSwap/index.js +1 -1
- package/dist/components/TekWallet/components/ui/Fees/index.d.ts +1 -1
- package/dist/components/TekWallet/components/ui/Fees/index.js +51 -41
- package/dist/components/TekWallet/components/ui/FeesAutoDebounce/index.d.ts +10 -0
- package/dist/components/TekWallet/components/ui/FeesAutoDebounce/index.js +223 -0
- package/dist/components/TekWallet/components/ui/FiatDeposit/components/shareAction.js +2 -2
- package/dist/components/TekWallet/components/ui/FiatDeposit/components/shareImage.js +13 -13
- package/dist/components/TekWallet/components/ui/FiatDeposit/index.js +6 -4
- package/dist/components/TekWallet/components/ui/Formatter/index.d.ts +1 -0
- package/dist/components/TekWallet/components/ui/Formatter/index.js +4 -2
- package/dist/components/TekWallet/components/ui/FunctionItem/index.js +5 -4
- package/dist/components/TekWallet/components/ui/Icon/index.d.ts +4 -2
- package/dist/components/TekWallet/components/ui/Icon/index.js +44 -3
- package/dist/components/TekWallet/components/ui/Input/index.js +3 -3
- package/dist/components/TekWallet/components/ui/ListItemCustom/index.d.ts +2 -1
- package/dist/components/TekWallet/components/ui/ListItemCustom/index.js +3 -3
- package/dist/components/TekWallet/components/ui/QRCode/index.js +1 -1
- package/dist/components/TekWallet/components/ui/SendExternalToken/index.js +1 -1
- package/dist/components/TekWallet/components/ui/SendExternalTokenWithdrawn/index.d.ts +2 -5
- package/dist/components/TekWallet/components/ui/SvgPath/index.d.ts +12 -0
- package/dist/components/TekWallet/components/ui/SvgPath/index.js +27 -15
- package/dist/components/TekWallet/components/ui/SwapFunction/index.js +4 -4
- package/dist/components/TekWallet/components/ui/SwapToken/index.d.ts +2 -3
- package/dist/components/TekWallet/components/ui/TokensBoard/index.js +1 -3
- package/dist/components/TekWallet/components/ui/ValidateWalletAddress/index.d.ts +5 -0
- package/dist/components/TekWallet/components/ui/ValidateWalletAddress/index.js +67 -0
- package/dist/components/TekWallet/components/ui/WaitingData/index.d.ts +1 -0
- package/dist/components/TekWallet/components/ui/WaitingData/index.js +10 -6
- package/dist/components/TekWallet/components/ui/WithdrawFunction/index.d.ts +1 -1
- package/dist/components/TekWallet/components/ui/WithdrawFunction/index.js +70 -32
- package/dist/components/TekWallet/components/views/AssetView/Menu.d.ts +7 -0
- package/dist/components/TekWallet/components/views/AssetView/Menu.js +25 -0
- package/dist/components/TekWallet/components/views/AssetView/index.js +25 -26
- package/dist/components/TekWallet/components/views/NotFoundView/index.d.ts +2 -0
- package/dist/components/TekWallet/components/views/NotFoundView/index.js +7 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/Form.d.ts +11 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/Form.js +450 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/Result.d.ts +14 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/Result.js +140 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/SelectNetwork.d.ts +10 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/SelectNetwork.js +34 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/SelectToken.d.ts +8 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/SelectToken.js +173 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/Summary.d.ts +12 -0
- package/dist/components/TekWallet/components/views/SendExternalView/components/Summary.js +131 -0
- package/dist/components/TekWallet/components/views/SendExternalView/index.d.ts +23 -0
- package/dist/components/TekWallet/components/views/SendExternalView/index.js +143 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/AmountForm.d.ts +11 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/AmountForm.js +380 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/Form.d.ts +11 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/Form.js +381 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/Result.d.ts +13 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/Result.js +128 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/SelectToken.d.ts +8 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/SelectToken.js +173 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/Summary.d.ts +11 -0
- package/dist/components/TekWallet/components/views/SendInternalView/components/Summary.js +126 -0
- package/dist/components/TekWallet/components/views/SendInternalView/index.d.ts +24 -0
- package/dist/components/TekWallet/components/views/SendInternalView/index.js +155 -0
- package/dist/components/TekWallet/components/views/SwapView/components/CardTo/index.d.ts +11 -0
- package/dist/components/TekWallet/components/views/SwapView/components/CardTo/index.js +111 -0
- package/dist/components/TekWallet/components/views/SwapView/components/FromCard/index.d.ts +14 -0
- package/dist/components/TekWallet/components/views/SwapView/components/FromCard/index.js +180 -0
- package/dist/components/TekWallet/components/views/SwapView/components/SelectToken.d.ts +9 -0
- package/dist/components/TekWallet/components/views/SwapView/components/SelectToken.js +173 -0
- package/dist/components/TekWallet/components/views/SwapView/components/Summary.d.ts +14 -0
- package/dist/components/TekWallet/components/views/SwapView/components/Summary.js +239 -0
- package/dist/components/TekWallet/components/views/SwapView/functions/convertTokensRate.d.ts +3 -0
- package/dist/components/TekWallet/components/views/SwapView/functions/convertTokensRate.js +14 -0
- package/dist/components/TekWallet/components/views/SwapView/index.d.ts +11 -0
- package/dist/components/TekWallet/components/views/SwapView/index.js +218 -0
- package/dist/components/TekWallet/components/views/TekWalletView/expose.d.ts +2 -0
- package/dist/components/TekWallet/components/views/TekWalletView/expose.js +18 -0
- package/dist/components/TekWallet/components/views/TekWalletView/index.d.ts +3 -0
- package/dist/components/TekWallet/components/views/TekWalletView/index.js +16 -0
- package/dist/components/TekWallet/components/views/TekWalletView/routes.d.ts +9 -0
- package/dist/components/TekWallet/components/views/TekWalletView/routes.js +74 -0
- package/dist/components/TekWallet/hooks/useValidateAmount.d.ts +26 -0
- package/dist/components/TekWallet/hooks/useValidateAmount.js +103 -0
- package/dist/components/TekWallet/providers/EventHandlerProvider/index.js +5 -0
- package/dist/components/TekWallet/providers/RealtimeProvider/index.js +2 -2
- package/dist/components/TekWallet/providers/TekWalletProvider/index.d.ts +3 -0
- package/dist/components/TekWallet/providers/TekWalletProvider/index.js +8 -2
- package/dist/components/TekWallet/providers/WithdrawProvider/index.js +36 -0
- package/dist/components/TekWallet/services/axios/get-est-fee-service/type.d.ts +5 -4
- package/dist/components/TekWallet/services/axios/send-external-service/type.d.ts +5 -30
- package/dist/components/TekWallet/services/axios/swap-service/type.d.ts +4 -0
- package/dist/components/TekWallet/services/axios/transfer-internal-service/type.d.ts +4 -32
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/components.js +3 -3
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/palette.js +3 -3
- package/dist/components/TekWallet/theme/mui/theme.js +9 -9
- package/dist/components/TekWallet/utils/stop.d.ts +3 -0
- package/dist/components/TekWallet/utils/stop.js +6 -0
- package/package.json +2 -2
- package/dist/components/TekWallet/components/ui/CardFrom/index.d.ts +0 -10
- package/dist/components/TekWallet/components/ui/CardFrom/index.js +0 -91
- package/dist/components/TekWallet/components/ui/CardTo/index.d.ts +0 -10
- package/dist/components/TekWallet/components/ui/CardTo/index.js +0 -39
- package/dist/components/TekWallet/components/ui/ConfirmLayout copy/index.d.ts +0 -7
- package/dist/components/TekWallet/components/ui/ConfirmLayout copy/index.js +0 -67
- package/dist/components/TekWallet/components/views/HelpView/index.d.ts +0 -2
- package/dist/components/TekWallet/components/views/HelpView/index.js +0 -7
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
40
|
+
var material_1 = require("@mui/material");
|
|
41
|
+
var react_1 = require("react");
|
|
42
|
+
var Icon_1 = __importDefault(require("../../../../ui/Icon"));
|
|
43
|
+
var providers_1 = require("../../../../../providers");
|
|
44
|
+
var useWallet_1 = __importDefault(require("../../../../../hooks/useWallet"));
|
|
45
|
+
var Button_1 = __importDefault(require("../../../../ui/Button"));
|
|
46
|
+
var Text_1 = __importDefault(require("../../../../ui/Text"));
|
|
47
|
+
var SvgPath_1 = require("../../../../ui/SvgPath");
|
|
48
|
+
var Formatter_1 = __importDefault(require("../../../../ui/Formatter"));
|
|
49
|
+
var DrawerComponent_1 = __importStar(require("../../../../ui/DrawerComponent"));
|
|
50
|
+
var SelectToken_1 = __importDefault(require("../SelectToken"));
|
|
51
|
+
var DefaultPageLayout_1 = __importDefault(require("../../../../layouts/DefaultPageLayout"));
|
|
52
|
+
var ChildPageLayout_1 = __importDefault(require("../../../../layouts/ChildPageLayout"));
|
|
53
|
+
var PageHeader_1 = __importDefault(require("../../../../ui/PageHeader"));
|
|
54
|
+
var useValidateAmount_1 = __importDefault(require("../../../../../hooks/useValidateAmount"));
|
|
55
|
+
var xhub_keyboard_1 = require("xhub-keyboard");
|
|
56
|
+
var CardForm = function (_a) {
|
|
57
|
+
var _b, _c, _d;
|
|
58
|
+
var selectedToken = _a.selectedToken, onChange = _a.onChange, amount = _a.amount, onChangeToken = _a.onChangeToken, setFromInfoIsReady = _a.setFromInfoIsReady, keyboardId = _a.keyboardId, _e = _a.amountWasChanged, amountWasChanged = _e === void 0 ? true : _e;
|
|
59
|
+
var _f = (0, useWallet_1.default)(), updateSwapTokens = _f.updateSwapTokens, fromTokens = _f.fromTokens, isInitPasscode = _f.isInitPasscode;
|
|
60
|
+
var theme = (0, providers_1.useTheme)();
|
|
61
|
+
var selectTokenRef = (0, react_1.useRef)(null);
|
|
62
|
+
var _g = (0, useValidateAmount_1.default)({
|
|
63
|
+
validationData: {
|
|
64
|
+
amount: +(amount !== null && amount !== void 0 ? amount : 0),
|
|
65
|
+
min: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.min_value,
|
|
66
|
+
max: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.max_value,
|
|
67
|
+
balance: +((_b = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.balance) !== null && _b !== void 0 ? _b : 0),
|
|
68
|
+
tokenName: (_c = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name) !== null && _c !== void 0 ? _c : "",
|
|
69
|
+
},
|
|
70
|
+
}), errorContent = _g.errorContent, placeholder = _g.placeholder;
|
|
71
|
+
var shouldShowError = (0, react_1.useMemo)(function () {
|
|
72
|
+
return amountWasChanged && !!errorContent;
|
|
73
|
+
}, [amountWasChanged, errorContent]);
|
|
74
|
+
var handleClickGetMaxValue = function () {
|
|
75
|
+
if ((selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.max_value) && onChange) {
|
|
76
|
+
var balance = Number(selectedToken.balance);
|
|
77
|
+
var maxValue = Number(selectedToken.max_value);
|
|
78
|
+
var minValue = Math.min(balance, maxValue);
|
|
79
|
+
onChange({
|
|
80
|
+
target: { value: minValue.toString() },
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
var closeSelectToken = function () {
|
|
85
|
+
var _a;
|
|
86
|
+
(_a = selectTokenRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
87
|
+
};
|
|
88
|
+
var handleSelectToken = function (token) {
|
|
89
|
+
onChangeToken === null || onChangeToken === void 0 ? void 0 : onChangeToken(token);
|
|
90
|
+
closeSelectToken();
|
|
91
|
+
};
|
|
92
|
+
(0, react_1.useEffect)(function () {
|
|
93
|
+
if (!fromTokens && isInitPasscode) {
|
|
94
|
+
updateSwapTokens();
|
|
95
|
+
}
|
|
96
|
+
}, [fromTokens, updateSwapTokens, isInitPasscode]);
|
|
97
|
+
(0, react_1.useEffect)(function () {
|
|
98
|
+
if (!fromTokens)
|
|
99
|
+
return;
|
|
100
|
+
var isSelectedTokenInFromTokens = fromTokens === null || fromTokens === void 0 ? void 0 : fromTokens.some(function (token) { return token.id === (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.id); });
|
|
101
|
+
if (!isSelectedTokenInFromTokens) {
|
|
102
|
+
onChangeToken === null || onChangeToken === void 0 ? void 0 : onChangeToken(fromTokens === null || fromTokens === void 0 ? void 0 : fromTokens[0]);
|
|
103
|
+
}
|
|
104
|
+
}, [fromTokens, onChangeToken, selectedToken]);
|
|
105
|
+
(0, react_1.useEffect)(function () {
|
|
106
|
+
setFromInfoIsReady === null || setFromInfoIsReady === void 0 ? void 0 : setFromInfoIsReady(!errorContent);
|
|
107
|
+
}, [errorContent, setFromInfoIsReady]);
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
109
|
+
border: "1px solid",
|
|
110
|
+
borderColor: "".concat(!!shouldShowError ? "red" : "".concat(theme.palette.primary.main)),
|
|
111
|
+
borderRadius: theme.mixins.customRadius.r16,
|
|
112
|
+
padding: theme.mixins.customPadding.p16,
|
|
113
|
+
backdropFilter: "blur(12px)",
|
|
114
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
115
|
+
display: "flex",
|
|
116
|
+
justifyContent: "space-between",
|
|
117
|
+
}, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
118
|
+
color: theme.palette.text.blackContrast,
|
|
119
|
+
fontWeight: theme.typography.fontWeight600,
|
|
120
|
+
}, children: "From" }), (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: {
|
|
121
|
+
color: theme.palette.text.accent,
|
|
122
|
+
fontSize: theme.typography.fontSize12,
|
|
123
|
+
fontWeight: theme.typography.fontWeight400,
|
|
124
|
+
}, children: ["Balance:", " ", (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
125
|
+
color: theme.palette.text.blackContrast,
|
|
126
|
+
fontWeight: theme.typography.fontWeight500,
|
|
127
|
+
fontSize: theme.typography.fontSize12,
|
|
128
|
+
}, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.balance, unit: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name }) })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
129
|
+
display: "flex",
|
|
130
|
+
justifyContent: "space-between",
|
|
131
|
+
mt: theme.mixins.customMargin.m20,
|
|
132
|
+
mb: theme.mixins.customMargin.m16,
|
|
133
|
+
}, children: [(0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: selectTokenRef, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, trigger: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
134
|
+
display: "flex",
|
|
135
|
+
alignItems: "center",
|
|
136
|
+
gap: theme.mixins.gaps.g4,
|
|
137
|
+
cursor: "pointer",
|
|
138
|
+
width: "fit-content",
|
|
139
|
+
}, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.link, width: 20, height: 20, sx: { borderRadius: "9999px" } }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
140
|
+
color: theme.palette.text.blackContrast,
|
|
141
|
+
fontWeight: theme.typography.fontWeight600,
|
|
142
|
+
}, children: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name) || (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.full_name) }), (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: 10, height: 10 }, children: SvgPath_1.IC_ARROW_BLACK_DROP })] }), children: (0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { header: (0, jsx_runtime_1.jsx)(PageHeader_1.default, { title: "Select Token", overrideBack: closeSelectToken }), children: (0, jsx_runtime_1.jsx)(DefaultPageLayout_1.default, { sx: {
|
|
143
|
+
width: "100dvw",
|
|
144
|
+
height: "100dvh",
|
|
145
|
+
}, children: (0, jsx_runtime_1.jsx)(SelectToken_1.default, { tokens: fromTokens, selectedToken: selectedToken, onChangeToken: handleSelectToken }) }) }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
146
|
+
width: "100%",
|
|
147
|
+
display: "flex",
|
|
148
|
+
justifyContent: "flex-end",
|
|
149
|
+
alignItems: "flex-end",
|
|
150
|
+
flex: 1,
|
|
151
|
+
}, children: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Label, { htmlFor: keyboardId !== null && keyboardId !== void 0 ? keyboardId : "", children: (0, jsx_runtime_1.jsx)(xhub_keyboard_1.Input, { autoFocus: true, elementsAcceptIds: ["form-amount-keyboard-id"], value: (_d = amount === null || amount === void 0 ? void 0 : amount.toString()) !== null && _d !== void 0 ? _d : "", placeholder: placeholder, displayType: xhub_keyboard_1.DisplayType.Double, styles: {
|
|
152
|
+
container: {
|
|
153
|
+
padding: "0",
|
|
154
|
+
border: "none",
|
|
155
|
+
},
|
|
156
|
+
input: {
|
|
157
|
+
display: "flex",
|
|
158
|
+
justifyContent: "flex-end",
|
|
159
|
+
paddingRight: "2px",
|
|
160
|
+
},
|
|
161
|
+
} }) }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
162
|
+
display: "flex",
|
|
163
|
+
alignItems: "center",
|
|
164
|
+
justifyContent: "space-between",
|
|
165
|
+
}, children: [!!shouldShowError && errorContent, (0, jsx_runtime_1.jsx)(Button_1.default, { sx: {
|
|
166
|
+
textTransform: "capitalize",
|
|
167
|
+
backgroundColor: theme.palette.background.tertiary,
|
|
168
|
+
borderRadius: theme.mixins.customRadius.r8,
|
|
169
|
+
color: theme.palette.text.primary,
|
|
170
|
+
px: theme.mixins.customPadding.p16,
|
|
171
|
+
py: theme.mixins.customPadding.p3,
|
|
172
|
+
marginLeft: "auto",
|
|
173
|
+
}, onClick: handleClickGetMaxValue, children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
174
|
+
color: theme.palette.primary.main,
|
|
175
|
+
fontWeight: theme.typography.fontWeight600,
|
|
176
|
+
fontSize: theme.typography.fontSize12,
|
|
177
|
+
lineHeight: theme.typography.leading100,
|
|
178
|
+
}, children: "Max" }) })] })] }));
|
|
179
|
+
};
|
|
180
|
+
exports.default = CardForm;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Output, SupportedToken } from "../../../../services/axios/get-swap-tokens-list-service/type";
|
|
2
|
+
export type OptionToken = SupportedToken | Output;
|
|
3
|
+
export interface SelectTokenProps {
|
|
4
|
+
tokens?: OptionToken[];
|
|
5
|
+
selectedToken?: OptionToken;
|
|
6
|
+
onChangeToken?: (token: OptionToken) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const SelectToken: (props: SelectTokenProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default SelectToken;
|
|
@@ -0,0 +1,173 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
47
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
48
|
+
if (ar || !(i in from)) {
|
|
49
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
50
|
+
ar[i] = from[i];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
54
|
+
};
|
|
55
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
56
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
57
|
+
};
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
60
|
+
var material_1 = require("@mui/material");
|
|
61
|
+
var providers_1 = require("../../../../providers");
|
|
62
|
+
var TokenSelection_1 = __importDefault(require("../../../ui/TokenSelection"));
|
|
63
|
+
var SvgPath_1 = require("../../../ui/SvgPath");
|
|
64
|
+
var EmptyData_1 = __importDefault(require("../../../ui/EmptyData"));
|
|
65
|
+
var WaitingData_1 = __importDefault(require("../../../ui/WaitingData"));
|
|
66
|
+
var react_1 = require("react");
|
|
67
|
+
var lodash_1 = require("lodash");
|
|
68
|
+
var SortGroup_1 = __importStar(require("../../../ui/ReceiveFunction/components/SortGroup"));
|
|
69
|
+
var SortTool_1 = require("../../../ui/ReceiveFunction/components/SortTool");
|
|
70
|
+
var searchDebounce = (0, lodash_1.debounce)(function (callback) {
|
|
71
|
+
callback();
|
|
72
|
+
}, 500, { leading: true, trailing: true });
|
|
73
|
+
var SelectToken = function (props) {
|
|
74
|
+
var theme = (0, providers_1.useTheme)();
|
|
75
|
+
var _a = (0, react_1.useState)(""), searchValue = _a[0], setSearchValue = _a[1];
|
|
76
|
+
var _b = (0, react_1.useState)(), searchedReceiveTokens = _b[0], setSearchedReceiveTokens = _b[1];
|
|
77
|
+
var _c = (0, react_1.useState)([]), tokenRender = _c[0], setTokenRender = _c[1];
|
|
78
|
+
var tokens = props.tokens, selectedToken = props.selectedToken, onChangeToken = props.onChangeToken;
|
|
79
|
+
var isSearching = (0, react_1.useMemo)(function () {
|
|
80
|
+
return searchValue.length > 0;
|
|
81
|
+
}, [searchValue]);
|
|
82
|
+
var isLoadingDepositTokens = (0, react_1.useMemo)(function () {
|
|
83
|
+
return !tokens;
|
|
84
|
+
}, [tokens]);
|
|
85
|
+
var isEmptyDepositTokens = (0, react_1.useMemo)(function () {
|
|
86
|
+
return !isLoadingDepositTokens && (tokens === null || tokens === void 0 ? void 0 : tokens.length) === 0;
|
|
87
|
+
}, [isLoadingDepositTokens, tokens]);
|
|
88
|
+
var isEmptySearch = (0, react_1.useMemo)(function () {
|
|
89
|
+
return isSearching && (searchedReceiveTokens === null || searchedReceiveTokens === void 0 ? void 0 : searchedReceiveTokens.length) === 0;
|
|
90
|
+
}, [isSearching, searchedReceiveTokens]);
|
|
91
|
+
var handleClearSearch = function () {
|
|
92
|
+
setSearchValue("");
|
|
93
|
+
};
|
|
94
|
+
var handleSelectToken = function (token) {
|
|
95
|
+
onChangeToken === null || onChangeToken === void 0 ? void 0 : onChangeToken(token);
|
|
96
|
+
};
|
|
97
|
+
var handleSearch = function (e) {
|
|
98
|
+
var searchValue = e.target.value;
|
|
99
|
+
setSearchValue(searchValue);
|
|
100
|
+
searchDebounce(function () {
|
|
101
|
+
if (searchValue.length > 0) {
|
|
102
|
+
var filteredTokens = tokens === null || tokens === void 0 ? void 0 : tokens.filter(function (item) {
|
|
103
|
+
return item.name.toLowerCase().includes(searchValue.toLowerCase());
|
|
104
|
+
});
|
|
105
|
+
setSearchedReceiveTokens(filteredTokens || []);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
setSearchedReceiveTokens(tokens);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
var handleSort = function (sortBy, sortOrder) {
|
|
113
|
+
var sortedTokens = __spreadArray([], tokenRender, true);
|
|
114
|
+
sortedTokens.sort(function (a, b) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
if (sortBy === SortGroup_1.SortByType.Name) {
|
|
117
|
+
return sortOrder === SortTool_1.SortOrder.ASC
|
|
118
|
+
? ((_a = a === null || a === void 0 ? void 0 : a.name) === null || _a === void 0 ? void 0 : _a.localeCompare((b === null || b === void 0 ? void 0 : b.name) || "")) || 0
|
|
119
|
+
: ((_b = b === null || b === void 0 ? void 0 : b.name) === null || _b === void 0 ? void 0 : _b.localeCompare((a === null || a === void 0 ? void 0 : a.name) || "")) || 0;
|
|
120
|
+
}
|
|
121
|
+
return sortOrder === SortTool_1.SortOrder.ASC
|
|
122
|
+
? +((a === null || a === void 0 ? void 0 : a.balance) || 0) - +((b === null || b === void 0 ? void 0 : b.balance) || 0)
|
|
123
|
+
: +((b === null || b === void 0 ? void 0 : b.balance) || 0) - +((a === null || a === void 0 ? void 0 : a.balance) || 0);
|
|
124
|
+
});
|
|
125
|
+
setTokenRender(sortedTokens);
|
|
126
|
+
};
|
|
127
|
+
(0, react_1.useEffect)(function () {
|
|
128
|
+
if (isSearching) {
|
|
129
|
+
setTokenRender(searchedReceiveTokens || []);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
setTokenRender(tokens || []);
|
|
133
|
+
}
|
|
134
|
+
}, [isSearching, searchedReceiveTokens, tokens]);
|
|
135
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, height: "fit-content" }), children: [!isEmptyDepositTokens && !isLoadingDepositTokens && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
136
|
+
position: "sticky",
|
|
137
|
+
backgroundColor: theme.palette.background.white,
|
|
138
|
+
zIndex: 100,
|
|
139
|
+
top: "0px",
|
|
140
|
+
pb: theme.mixins.customPadding.p12,
|
|
141
|
+
}, children: [(0, jsx_runtime_1.jsx)(material_1.InputBase, { onChange: handleSearch, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "start", children: (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: 20, height: 20 }, children: SvgPath_1.IC_SEARCH }) }), value: searchValue, placeholder: "Search", sx: {
|
|
142
|
+
borderRadius: theme.mixins.customRadius.r12,
|
|
143
|
+
border: "1px solid",
|
|
144
|
+
borderColor: theme.palette.border.accent3,
|
|
145
|
+
background: theme.palette.background.white,
|
|
146
|
+
color: theme.palette.text.black,
|
|
147
|
+
py: theme.mixins.customPadding.p6,
|
|
148
|
+
px: theme.mixins.customPadding.p12,
|
|
149
|
+
fontSize: theme.typography.fontSize16,
|
|
150
|
+
width: "100%",
|
|
151
|
+
lineHeight: "100%",
|
|
152
|
+
"input::placeholder": {
|
|
153
|
+
fontSize: theme.typography.fontSize12,
|
|
154
|
+
pl: theme.mixins.customPadding.p4,
|
|
155
|
+
fontWeight: theme.typography.fontWeight500,
|
|
156
|
+
color: theme.palette.text.black,
|
|
157
|
+
lineHeight: "100%",
|
|
158
|
+
},
|
|
159
|
+
}, endAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, { position: "end", sx: {
|
|
160
|
+
visibility: isSearching ? "visible" : "hidden",
|
|
161
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: {
|
|
162
|
+
width: 20,
|
|
163
|
+
height: 20,
|
|
164
|
+
p: theme.mixins.customPadding.p4,
|
|
165
|
+
cursor: "pointer",
|
|
166
|
+
}, onClick: handleClearSearch, children: SvgPath_1.IC_CLOSE }) }) }), (tokenRender === null || tokenRender === void 0 ? void 0 : tokenRender.length) > 0 && (0, jsx_runtime_1.jsx)(SortGroup_1.default, { onChange: handleSort })] })), isLoadingDepositTokens && (0, jsx_runtime_1.jsx)(WaitingData_1.default, { numberOfSkeleton: 8 }), isEmptyDepositTokens && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { sx: { py: "4rem" }, title: "No deposit tokens", description: "No deposit tokens" })), isSearching && isEmptySearch && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { sx: { py: "4rem" }, title: "No search results", description: "Let's try again with a different search" })), tokenRender === null || tokenRender === void 0 ? void 0 : tokenRender.map(function (item, index) {
|
|
167
|
+
var stringifiedTokenData = JSON.stringify(item);
|
|
168
|
+
if (!item)
|
|
169
|
+
return null;
|
|
170
|
+
return ((0, jsx_runtime_1.jsx)(TokenSelection_1.default, { onClick: handleSelectToken, tokenData: stringifiedTokenData, active: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.id) === item.id }, "token_".concat(item.id, "_").concat(index)));
|
|
171
|
+
})] }));
|
|
172
|
+
};
|
|
173
|
+
exports.default = SelectToken;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FeesDataType } from "../../../../services/axios/get-est-fee-service/type";
|
|
2
|
+
import { Output, SupportedToken } from "../../../../services/axios/get-swap-tokens-list-service/type";
|
|
3
|
+
import { ConfirmSwapTokenProps } from "../../../ui/ConfirmSwapToken";
|
|
4
|
+
interface SummaryProps {
|
|
5
|
+
estimateFee?: FeesDataType;
|
|
6
|
+
fromToken?: SupportedToken;
|
|
7
|
+
toToken?: Output;
|
|
8
|
+
confirmProps?: Omit<ConfirmSwapTokenProps, "payload">;
|
|
9
|
+
receiveAmountEstimate?: number;
|
|
10
|
+
fromAmount?: number;
|
|
11
|
+
isActiveStep?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export default function Summary(props: SummaryProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export type { SummaryProps };
|
|
@@ -0,0 +1,239 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
47
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
48
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
49
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
50
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
51
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
52
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
56
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
57
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
58
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
59
|
+
function step(op) {
|
|
60
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
61
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
62
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
63
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
64
|
+
switch (op[0]) {
|
|
65
|
+
case 0: case 1: t = op; break;
|
|
66
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
67
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
68
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
69
|
+
default:
|
|
70
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
71
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
72
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
73
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
74
|
+
if (t[2]) _.ops.pop();
|
|
75
|
+
_.trys.pop(); continue;
|
|
76
|
+
}
|
|
77
|
+
op = body.call(thisArg, _);
|
|
78
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
79
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
83
|
+
var t = {};
|
|
84
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
85
|
+
t[p] = s[p];
|
|
86
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
87
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
88
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
89
|
+
t[p[i]] = s[p[i]];
|
|
90
|
+
}
|
|
91
|
+
return t;
|
|
92
|
+
};
|
|
93
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
94
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
95
|
+
};
|
|
96
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
97
|
+
exports.default = Summary;
|
|
98
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
99
|
+
var material_1 = require("@mui/material");
|
|
100
|
+
var Text_1 = __importDefault(require("../../../ui/Text"));
|
|
101
|
+
var Fees_1 = __importStar(require("../../../ui/Fees"));
|
|
102
|
+
var react_1 = require("react");
|
|
103
|
+
var Button_1 = __importStar(require("../../../ui/Button"));
|
|
104
|
+
var providers_1 = require("../../../../providers");
|
|
105
|
+
var Formatter_1 = __importDefault(require("../../../ui/Formatter"));
|
|
106
|
+
var Icon_1 = __importDefault(require("../../../ui/Icon"));
|
|
107
|
+
var ConfirmSwapToken_1 = __importDefault(require("../../../ui/ConfirmSwapToken"));
|
|
108
|
+
var get_est_fee_service_1 = __importDefault(require("../../../../services/axios/get-est-fee-service"));
|
|
109
|
+
var type_1 = require("../../../../services/axios/get-activities-service/type");
|
|
110
|
+
var convertTokensRate_1 = __importDefault(require("../functions/convertTokensRate"));
|
|
111
|
+
function Summary(props) {
|
|
112
|
+
var _this = this;
|
|
113
|
+
var fromToken = props.fromToken, toToken = props.toToken, confirmProps = props.confirmProps, receiveAmountEstimate = props.receiveAmountEstimate, fromAmount = props.fromAmount, isActiveStep = props.isActiveStep;
|
|
114
|
+
var _a = confirmProps || {}, onSuccess = _a.onSuccess, onError = _a.onError, onStart = _a.onStart, onFinally = _a.onFinally, confirmPropsRest = __rest(_a, ["onSuccess", "onError", "onStart", "onFinally"]);
|
|
115
|
+
var theme = (0, providers_1.useTheme)();
|
|
116
|
+
var _b = (0, react_1.useState)(false), isEstimatingFee = _b[0], setIsLoadingEstimateFee = _b[1];
|
|
117
|
+
var _c = (0, react_1.useState)(), estimateFee = _c[0], setEstimateFee = _c[1];
|
|
118
|
+
var _d = (0, react_1.useState)(false), isEnoughBalanceToPayFee = _d[0], setIsEnoughBalanceToPayFee = _d[1];
|
|
119
|
+
var _e = (0, react_1.useState)(""), someError = _e[0], setSomeError = _e[1];
|
|
120
|
+
var toTokenRate = (0, react_1.useMemo)(function () {
|
|
121
|
+
if (!fromToken || !toToken)
|
|
122
|
+
return 0;
|
|
123
|
+
return (0, convertTokensRate_1.default)(fromToken, toToken, 1);
|
|
124
|
+
}, [fromToken, toToken]);
|
|
125
|
+
var _f = (0, react_1.useState)(Button_1.BUTTON_STATUS.ENABLED), confirmButtonStatus = _f[0], setContinueButtonStatus = _f[1];
|
|
126
|
+
var payload = (0, react_1.useMemo)(function () {
|
|
127
|
+
return {
|
|
128
|
+
amount: (fromAmount === null || fromAmount === void 0 ? void 0 : fromAmount.toString()) || "",
|
|
129
|
+
currency_slug: (fromToken === null || fromToken === void 0 ? void 0 : fromToken.slug) || "",
|
|
130
|
+
to_currency_slug: (toToken === null || toToken === void 0 ? void 0 : toToken.slug) || "",
|
|
131
|
+
extraTransactions: null,
|
|
132
|
+
};
|
|
133
|
+
}, [fromToken, toToken, fromAmount]);
|
|
134
|
+
var getEstimateFee = (0, react_1.useCallback)(function (amount) { return __awaiter(_this, void 0, void 0, function () {
|
|
135
|
+
var response, error_1;
|
|
136
|
+
return __generator(this, function (_a) {
|
|
137
|
+
switch (_a.label) {
|
|
138
|
+
case 0:
|
|
139
|
+
_a.trys.push([0, 2, 3, 4]);
|
|
140
|
+
if (!fromToken || !amount) {
|
|
141
|
+
setIsLoadingEstimateFee(false);
|
|
142
|
+
setIsEnoughBalanceToPayFee(false);
|
|
143
|
+
return [2 /*return*/];
|
|
144
|
+
}
|
|
145
|
+
setIsLoadingEstimateFee(true);
|
|
146
|
+
return [4 /*yield*/, (0, get_est_fee_service_1.default)({
|
|
147
|
+
amount: "".concat(amount),
|
|
148
|
+
transaction_type: type_1.TransactionSlug.SWAP,
|
|
149
|
+
currency: (fromToken === null || fromToken === void 0 ? void 0 : fromToken.slug) || "",
|
|
150
|
+
to_currency_slug: (toToken === null || toToken === void 0 ? void 0 : toToken.slug) || "",
|
|
151
|
+
})];
|
|
152
|
+
case 1:
|
|
153
|
+
response = _a.sent();
|
|
154
|
+
setIsLoadingEstimateFee(false);
|
|
155
|
+
setEstimateFee(response === null || response === void 0 ? void 0 : response.data);
|
|
156
|
+
return [3 /*break*/, 4];
|
|
157
|
+
case 2:
|
|
158
|
+
error_1 = _a.sent();
|
|
159
|
+
setSomeError(error_1);
|
|
160
|
+
return [3 /*break*/, 4];
|
|
161
|
+
case 3:
|
|
162
|
+
setIsLoadingEstimateFee(false);
|
|
163
|
+
return [7 /*endfinally*/];
|
|
164
|
+
case 4: return [2 /*return*/];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}); }, [fromToken, toToken === null || toToken === void 0 ? void 0 : toToken.slug]);
|
|
168
|
+
var handleOnSuccessSwap = function (res) {
|
|
169
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(res);
|
|
170
|
+
};
|
|
171
|
+
(0, react_1.useEffect)(function () {
|
|
172
|
+
if (!isActiveStep || !fromAmount)
|
|
173
|
+
return;
|
|
174
|
+
getEstimateFee(fromAmount);
|
|
175
|
+
}, [fromAmount, getEstimateFee, isActiveStep]);
|
|
176
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
177
|
+
display: "flex",
|
|
178
|
+
flexDirection: "column",
|
|
179
|
+
alignItems: "center",
|
|
180
|
+
height: "100%",
|
|
181
|
+
color: theme.palette.text.accent2,
|
|
182
|
+
gap: theme.mixins.gaps.g24,
|
|
183
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { alignItems: "center", gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: "You Receive" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.bigValue), { color: theme.palette.text.primary }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: receiveAmountEstimate, unit: toToken === null || toToken === void 0 ? void 0 : toToken.name }) })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
184
|
+
width: "100%",
|
|
185
|
+
position: "relative",
|
|
186
|
+
}, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
187
|
+
display: "flex",
|
|
188
|
+
flexDirection: "column",
|
|
189
|
+
gap: theme.mixins.gaps.g16,
|
|
190
|
+
zIndex: 1,
|
|
191
|
+
backgroundColor: theme.palette.background.primary,
|
|
192
|
+
padding: theme.mixins.customPadding.p16,
|
|
193
|
+
borderRadius: theme.mixins.customRadius.r16,
|
|
194
|
+
color: theme.palette.text.white,
|
|
195
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
196
|
+
display: "flex",
|
|
197
|
+
alignItems: "center",
|
|
198
|
+
gap: theme.mixins.gaps.g4,
|
|
199
|
+
position: "relative",
|
|
200
|
+
zIndex: 1,
|
|
201
|
+
}, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: fromToken === null || fromToken === void 0 ? void 0 : fromToken.link, sx: {
|
|
202
|
+
width: 20,
|
|
203
|
+
height: 20,
|
|
204
|
+
borderRadius: "999px",
|
|
205
|
+
} }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { color: "inherit" }), children: fromToken === null || fromToken === void 0 ? void 0 : fromToken.name }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { color: "inherit", marginLeft: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: fromAmount }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: "flex", alignItems: "center", gap: theme.mixins.gaps.g4 }, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { iconKey: "IC_SWAP_SECONDARY", sx: {
|
|
206
|
+
width: 16,
|
|
207
|
+
height: 16,
|
|
208
|
+
} }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
209
|
+
flex: 1,
|
|
210
|
+
borderTop: "1px dashed ".concat(theme.palette.border.secondary),
|
|
211
|
+
opacity: 0.2,
|
|
212
|
+
} })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { display: "flex", alignItems: "center", gap: theme.mixins.gaps.g4 }, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: toToken === null || toToken === void 0 ? void 0 : toToken.link, sx: {
|
|
213
|
+
width: 20,
|
|
214
|
+
height: 20,
|
|
215
|
+
borderRadius: "999px",
|
|
216
|
+
} }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { color: "inherit" }), children: toToken === null || toToken === void 0 ? void 0 : toToken.name }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { color: "inherit", marginLeft: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: receiveAmountEstimate }) })] })] }) }), !!toTokenRate && ((0, jsx_runtime_1.jsxs)(Text_1.default, { sx: {
|
|
217
|
+
fontSize: theme.typography.fontSize12,
|
|
218
|
+
fontWeight: theme.typography.fontWeight500,
|
|
219
|
+
color: theme.palette.text.blackContrast,
|
|
220
|
+
alignSelf: "center",
|
|
221
|
+
}, children: ["1 ", fromToken === null || fromToken === void 0 ? void 0 : fromToken.name, " ~ ", (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: toTokenRate, unit: toToken === null || toToken === void 0 ? void 0 : toToken.name })] })), !!someError && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: { color: theme.mixins.validationError, alignSelf: "flex-start" }, children: "Something went wrong, please try again" })), !!isActiveStep && ((0, jsx_runtime_1.jsx)(Fees_1.default, { isFeePaidByAmount: true, feesData: estimateFee, amount: +(fromAmount || 0), tokenSlug: (fromToken === null || fromToken === void 0 ? void 0 : fromToken.slug) || "", feesStyle: Fees_1.FeesStyle.DEFAULT, setIsEnoughBalanceToPayFee: setIsEnoughBalanceToPayFee })), (0, jsx_runtime_1.jsx)(ConfirmSwapToken_1.default, __assign({ sx: {
|
|
222
|
+
width: "100%",
|
|
223
|
+
marginTop: "auto",
|
|
224
|
+
}, payload: payload }, confirmPropsRest, { onSuccess: function (res) {
|
|
225
|
+
setContinueButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
|
|
226
|
+
handleOnSuccessSwap(res);
|
|
227
|
+
}, onError: function (err) {
|
|
228
|
+
setContinueButtonStatus(Button_1.BUTTON_STATUS.DISABLED);
|
|
229
|
+
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
230
|
+
}, onStart: function () {
|
|
231
|
+
setContinueButtonStatus(Button_1.BUTTON_STATUS.LOADING);
|
|
232
|
+
onStart === null || onStart === void 0 ? void 0 : onStart();
|
|
233
|
+
}, onFinally: function () {
|
|
234
|
+
setContinueButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
|
|
235
|
+
onFinally === null || onFinally === void 0 ? void 0 : onFinally();
|
|
236
|
+
}, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { loading: confirmButtonStatus === Button_1.BUTTON_STATUS.LOADING, status: !fromAmount || isEstimatingFee || !isEnoughBalanceToPayFee || !!someError
|
|
237
|
+
? Button_1.BUTTON_STATUS.DISABLED
|
|
238
|
+
: confirmButtonStatus, sx: { width: "100%" }, children: "Confirm" }) }))] }));
|
|
239
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function convertTokensRate(fromToken, toToken, fromAmount) {
|
|
4
|
+
try {
|
|
5
|
+
var fromUSDRate = Number(fromToken.usd_rate);
|
|
6
|
+
var toUSDRate = Number(toToken.usd_rate);
|
|
7
|
+
return (fromUSDRate * fromAmount) / toUSDRate;
|
|
8
|
+
}
|
|
9
|
+
catch (error) {
|
|
10
|
+
console.warn("🚀 ~ convertTokensRate ~ error:", error);
|
|
11
|
+
return 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = convertTokensRate;
|