tek-wallet 0.0.806 → 0.0.807
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 +2 -1
- package/dist/components/TekWallet/components/index.js +2 -1
- package/dist/components/TekWallet/components/layouts/ChildPageLayout/index.js +3 -3
- package/dist/components/TekWallet/components/layouts/DefaultPageLayout/index.js +3 -3
- package/dist/components/TekWallet/components/ui/ActivitiesTypeSlice/index.js +12 -8
- package/dist/components/TekWallet/components/ui/ActivityDetail/index.js +17 -19
- package/dist/components/TekWallet/components/ui/ActivityItem/index.js +13 -13
- package/dist/components/TekWallet/components/ui/AmountGroupAndChart/index.js +3 -3
- package/dist/components/TekWallet/components/ui/AnalyticGroup/index.js +20 -20
- package/dist/components/TekWallet/components/ui/AnalyticGroupCenter/index.js +9 -8
- package/dist/components/TekWallet/components/ui/AppBackDrop/index.js +3 -3
- package/dist/components/TekWallet/components/ui/AppDialog/index.js +3 -3
- package/dist/components/TekWallet/components/ui/AssetViewHeader/index.js +9 -8
- package/dist/components/TekWallet/components/ui/BackHeader/index.js +6 -6
- package/dist/components/TekWallet/components/ui/BottomActionLayout/index.js +3 -3
- package/dist/components/TekWallet/components/ui/Button/index.js +4 -4
- package/dist/components/TekWallet/components/ui/CardToken/index.js +8 -8
- package/dist/components/TekWallet/components/ui/Column/index.js +3 -3
- package/dist/components/TekWallet/components/ui/ConfirmByPasscode/index.js +6 -4
- package/dist/components/TekWallet/components/ui/ConfirmLayout/index.js +3 -3
- package/dist/components/TekWallet/components/ui/ConfirmSwapToken/Result.js +17 -17
- package/dist/components/TekWallet/components/ui/ConfirmTransfer/index.js +3 -3
- package/dist/components/TekWallet/components/ui/CopyTextComponent/index.js +6 -6
- package/dist/components/TekWallet/components/ui/CustomTooltip/index.js +4 -2
- package/dist/components/TekWallet/components/ui/DetailSwap/index.js +9 -9
- package/dist/components/TekWallet/components/ui/DialogContentLayout/index.js +6 -6
- package/dist/components/TekWallet/components/ui/DrawerDrag/index.js +3 -3
- package/dist/components/TekWallet/components/ui/EmptyData/index.js +3 -3
- package/dist/components/TekWallet/components/ui/Fees/index.js +25 -25
- package/dist/components/TekWallet/components/ui/FeesAutoDebounce/index.js +24 -25
- package/dist/components/TekWallet/components/ui/FiatDeposit/components/shareAction.js +4 -6
- package/dist/components/TekWallet/components/ui/FiatDeposit/components/shareDrawer.js +2 -5
- package/dist/components/TekWallet/components/ui/FiatDeposit/components/shareImage.js +1 -2
- package/dist/components/TekWallet/components/ui/FiatDeposit/index.js +28 -26
- package/dist/components/TekWallet/components/ui/Formatter/index.js +3 -0
- package/dist/components/TekWallet/components/ui/FunctionItem/index.js +4 -5
- package/dist/components/TekWallet/components/ui/Icon/index.js +1 -1
- package/dist/components/TekWallet/components/ui/IconText/index.js +3 -3
- package/dist/components/TekWallet/components/ui/IncomeWallet/components/AnalyticGroup.js +19 -20
- package/dist/components/TekWallet/components/ui/IncomeWallet/components/BalanceChart.js +5 -5
- package/dist/components/TekWallet/components/ui/IncomeWallet/components/FunctionItem.js +3 -3
- package/dist/components/TekWallet/components/ui/IncomeWallet/components/HistoryItem.js +3 -3
- package/dist/components/TekWallet/components/ui/IncomeWallet/components/WealthDeposit.js +3 -1
- package/dist/components/TekWallet/components/ui/IncomeWallet/components/WealthWithdraw.js +3 -1
- package/dist/components/TekWallet/components/ui/IncomeWallet/components/history/index.js +3 -3
- package/dist/components/TekWallet/components/ui/IncomeWallet/index.js +10 -10
- package/dist/components/TekWallet/components/ui/InlineTitleValue/index.js +3 -3
- package/dist/components/TekWallet/components/ui/Input/index.js +5 -5
- package/dist/components/TekWallet/components/ui/LineValue/index.js +3 -3
- package/dist/components/TekWallet/components/ui/ListItemCustom/index.js +8 -6
- package/dist/components/TekWallet/components/ui/LoadingLayout/index.js +3 -3
- package/dist/components/TekWallet/components/ui/LockToken/index.js +4 -4
- package/dist/components/TekWallet/components/ui/ModalCheckboxToken/index.js +22 -22
- package/dist/components/TekWallet/components/ui/ModalDateFilter/index.js +11 -11
- package/dist/components/TekWallet/components/ui/ModalLayout/index.js +3 -3
- package/dist/components/TekWallet/components/ui/ModalSelectToken/index.js +12 -12
- package/dist/components/TekWallet/components/ui/ModalStatusFilter/index.js +16 -16
- package/dist/components/TekWallet/components/ui/ModalTitle/index.js +3 -3
- package/dist/components/TekWallet/components/ui/NeonLineChart/index.js +4 -4
- package/dist/components/TekWallet/components/ui/NetworkSelection/index.js +5 -5
- package/dist/components/TekWallet/components/ui/OTP/index.js +24 -18
- package/dist/components/TekWallet/components/ui/PageHeader/index.js +3 -3
- package/dist/components/TekWallet/components/ui/QRCode/index.js +3 -1
- package/dist/components/TekWallet/components/ui/QrCodeReader/index.js +2 -3
- package/dist/components/TekWallet/components/ui/ReceiveDirectly/index.d.ts +26 -0
- package/dist/components/TekWallet/components/ui/ReceiveDirectly/index.js +365 -0
- package/dist/components/TekWallet/components/ui/ReceiveFunction/components/HelpView.js +4 -4
- package/dist/components/TekWallet/components/ui/ReceiveFunction/components/SortGroup.js +4 -4
- package/dist/components/TekWallet/components/ui/ReceiveFunction/components/SortTool.js +7 -12
- package/dist/components/TekWallet/components/ui/ReceiveFunction/index.js +39 -56
- package/dist/components/TekWallet/components/ui/ReceiveHistory/ReceiveCardHistory.js +13 -13
- package/dist/components/TekWallet/components/ui/ReceiveHistory/ReceiveHistoryDetails.js +22 -29
- package/dist/components/TekWallet/components/ui/ReceiveHistory/index.js +19 -19
- package/dist/components/TekWallet/components/ui/Row/index.js +3 -3
- package/dist/components/TekWallet/components/ui/ScanQRToSend/index.js +7 -7
- package/dist/components/TekWallet/components/ui/SearchBar.d.ts +10 -0
- package/dist/components/TekWallet/components/ui/SearchBar.js +42 -0
- package/dist/components/TekWallet/components/ui/SendExternalToken/index.js +7 -7
- package/dist/components/TekWallet/components/ui/SendInternalToken/index.js +5 -5
- package/dist/components/TekWallet/components/ui/SmartList/index.js +3 -3
- package/dist/components/TekWallet/components/ui/StatusDisplay/index.js +7 -7
- package/dist/components/TekWallet/components/ui/SvgPath/index.js +27 -27
- package/dist/components/TekWallet/components/ui/SwiperControlled/index.js +1 -3
- package/dist/components/TekWallet/components/ui/TimeFilter/index.js +9 -8
- package/dist/components/TekWallet/components/ui/TimeText/index.js +1 -1
- package/dist/components/TekWallet/components/ui/TokenItem/index.js +7 -15
- package/dist/components/TekWallet/components/ui/TokenSelection/index.js +5 -5
- package/dist/components/TekWallet/components/ui/TokensBoard/index.js +12 -12
- package/dist/components/TekWallet/components/ui/TransferConfirmation/index.js +3 -3
- package/dist/components/TekWallet/components/ui/TransferInternal/index.js +3 -3
- package/dist/components/TekWallet/components/ui/UpdateLockToken/index.js +4 -4
- package/dist/components/TekWallet/components/ui/UserInfo/index.js +4 -4
- package/dist/components/TekWallet/components/ui/WaitingData/index.js +13 -12
- package/dist/components/TekWallet/components/ui/WithdrawFunction/components/selectToken.js +11 -11
- package/dist/components/TekWallet/components/ui/WithdrawFunction/components/sendForm.js +30 -30
- package/dist/components/TekWallet/components/ui/WithdrawFunction/components/sortByBalance.js +3 -3
- package/dist/components/TekWallet/components/ui/WithdrawFunction/components/sortByToken.js +3 -3
- package/dist/components/TekWallet/components/ui/WithdrawFunction/components/summary/infoSummary.js +8 -8
- package/dist/components/TekWallet/components/ui/WithdrawFunction/index.js +9 -9
- package/dist/components/TekWallet/components/views/ActivityView/index.js +4 -4
- package/dist/components/TekWallet/components/views/AssetView/Menu.js +3 -3
- package/dist/components/TekWallet/components/views/AssetView/index.js +12 -12
- package/dist/components/TekWallet/components/views/AuthView/index.js +4 -4
- package/dist/components/TekWallet/components/views/AuthViewSignIn/index.js +4 -4
- package/dist/components/TekWallet/components/views/ChangePasscodeView/index.js +8 -6
- package/dist/components/TekWallet/components/views/CreateWalletView/index.js +4 -4
- package/dist/components/TekWallet/components/views/DetailActivityView/LoadingView.js +4 -4
- package/dist/components/TekWallet/components/views/GetSeedPhraseWalletView/index.js +7 -7
- package/dist/components/TekWallet/components/views/ImportWalletView/index.js +4 -7
- package/dist/components/TekWallet/components/views/SendExternalView/components/Form.js +32 -37
- package/dist/components/TekWallet/components/views/SendExternalView/components/Result.js +16 -16
- package/dist/components/TekWallet/components/views/SendExternalView/components/SelectNetwork.js +3 -3
- package/dist/components/TekWallet/components/views/SendExternalView/components/SelectToken.js +7 -32
- package/dist/components/TekWallet/components/views/SendExternalView/components/Summary.js +12 -12
- package/dist/components/TekWallet/components/views/SendExternalView/index.js +3 -3
- package/dist/components/TekWallet/components/views/SendInternalView/components/AmountForm.js +26 -24
- package/dist/components/TekWallet/components/views/SendInternalView/components/Form.js +27 -33
- package/dist/components/TekWallet/components/views/SendInternalView/components/Result.js +14 -14
- package/dist/components/TekWallet/components/views/SendInternalView/components/SelectToken.js +7 -32
- package/dist/components/TekWallet/components/views/SendInternalView/components/Summary.js +10 -10
- package/dist/components/TekWallet/components/views/SendInternalView/index.js +3 -3
- package/dist/components/TekWallet/components/views/SettingView/index.js +4 -13
- package/dist/components/TekWallet/components/views/SwapView/components/FromCard/FromCardSkeleton.js +7 -8
- package/dist/components/TekWallet/components/views/SwapView/components/FromCard/index.js +20 -25
- package/dist/components/TekWallet/components/views/SwapView/components/SelectToken.js +7 -32
- package/dist/components/TekWallet/components/views/SwapView/components/Summary.js +36 -39
- package/dist/components/TekWallet/components/views/SwapView/components/ToCard/index.js +7 -7
- package/dist/components/TekWallet/components/views/SwapView/index.js +12 -10
- package/dist/components/TekWallet/hooks/useValidateAmount.js +3 -3
- package/dist/components/TekWallet/hooks/useWarningWrongPasscode.js +5 -5
- package/dist/components/TekWallet/index.d.ts +2 -0
- package/dist/components/TekWallet/index.js +2 -12
- package/dist/components/TekWallet/layouts/ChildPageLayout/index.js +3 -3
- package/dist/components/TekWallet/providers/RealtimeProvider/index.js +15 -13
- package/dist/components/TekWallet/providers/TekWalletProvider/index.d.ts +9 -1
- package/dist/components/TekWallet/providers/TekWalletProvider/index.js +11 -4
- package/dist/components/TekWallet/providers/index.d.ts +0 -1
- package/dist/components/TekWallet/providers/index.js +0 -1
- package/dist/components/TekWallet/theme/mui/components/index.d.ts +133 -0
- package/dist/components/TekWallet/theme/mui/components/index.js +14 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/Button.d.ts +142 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/Button.js +84 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/Drawer.d.ts +4 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/Drawer.js +9 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/Paper.d.ts +3 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/Paper.js +15 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/SnackBar.d.ts +3 -0
- package/dist/components/TekWallet/theme/mui/components/overrides/SnackBar.js +32 -0
- package/dist/components/TekWallet/theme/mui/fixed-mixins.d.ts +2 -0
- package/dist/components/TekWallet/theme/mui/fixed-mixins.js +218 -0
- package/dist/components/TekWallet/theme/mui/index.d.ts +3 -3
- package/dist/components/TekWallet/theme/mui/index.js +16 -32
- package/dist/components/TekWallet/theme/mui/palette.d.ts +34 -0
- package/dist/components/TekWallet/theme/mui/palette.js +133 -0
- package/dist/components/TekWallet/theme/mui/shadows/index.d.ts +3 -0
- package/dist/components/TekWallet/theme/mui/shadows/index.js +64 -0
- package/dist/components/TekWallet/theme/mui/spacing.d.ts +1 -0
- package/dist/components/TekWallet/theme/mui/spacing.js +5 -0
- package/dist/components/TekWallet/theme/mui/theme.d.ts +9 -442
- package/dist/components/TekWallet/theme/mui/theme.js +38 -415
- package/dist/components/TekWallet/theme/mui/type.d.ts +5 -0
- package/dist/components/TekWallet/theme/mui/type.js +9 -0
- package/dist/components/TekWallet/theme/mui/typography.d.ts +27 -0
- package/dist/components/TekWallet/theme/mui/typography.js +30 -0
- package/dist/components/TekWallet/theme/mui/utils/deepMergeTheme.d.ts +2 -0
- package/dist/components/TekWallet/theme/mui/utils/deepMergeTheme.js +7 -0
- package/dist/components/TekWallet/utils/getContractColor.d.ts +1 -0
- package/dist/components/TekWallet/utils/getContractColor.js +30 -0
- package/package.json +1 -1
- package/dist/components/TekWallet/components/ui/CardHistorySwap/index.d.ts +0 -12
- package/dist/components/TekWallet/components/ui/CardHistorySwap/index.js +0 -75
- package/dist/components/TekWallet/components/ui/DetailSwapResult/index.d.ts +0 -8
- package/dist/components/TekWallet/components/ui/DetailSwapResult/index.js +0 -122
- package/dist/components/TekWallet/components/ui/HistorySwap/index.d.ts +0 -16
- package/dist/components/TekWallet/components/ui/HistorySwap/index.js +0 -434
- package/dist/components/TekWallet/components/ui/SwapFunction/index.d.ts +0 -16
- package/dist/components/TekWallet/components/ui/SwapFunction/index.js +0 -271
- package/dist/components/TekWallet/components/ui/SwapToken/index.d.ts +0 -31
- package/dist/components/TekWallet/components/ui/SwapToken/index.js +0 -293
- package/dist/components/TekWallet/providers/ThemeProvider/index.d.ts +0 -8
- package/dist/components/TekWallet/providers/ThemeProvider/index.js +0 -43
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/components.d.ts +0 -3
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/components.js +0 -158
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/palette.d.ts +0 -55
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/palette.js +0 -45
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/theme.d.ts +0 -2
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/theme.js +0 -13
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/typography.d.ts +0 -39
- package/dist/components/TekWallet/theme/mui/deposit-fiat-theme/typography.js +0 -65
|
@@ -1,271 +0,0 @@
|
|
|
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 = exports.SwapPage = 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 material_1 = require("@mui/material");
|
|
59
|
-
var Button_1 = __importDefault(require("../Button"));
|
|
60
|
-
var ThemeProvider_1 = require("../../../providers/ThemeProvider");
|
|
61
|
-
var ChildPageLayout_1 = __importDefault(require("../../layouts/ChildPageLayout"));
|
|
62
|
-
var FromCard_1 = __importDefault(require("../../views/SwapView/components/FromCard"));
|
|
63
|
-
var ToCard_1 = __importDefault(require("../../views/SwapView/components/ToCard"));
|
|
64
|
-
var DetailSwap_1 = __importDefault(require("../DetailSwap"));
|
|
65
|
-
var ModalSelectToken_1 = __importDefault(require("../ModalSelectToken"));
|
|
66
|
-
var useCustomRouter_1 = __importDefault(require("../../../hooks/useCustomRouter"));
|
|
67
|
-
var SwapToken_1 = __importDefault(require("../SwapToken"));
|
|
68
|
-
var HistorySwap_1 = __importDefault(require("../HistorySwap"));
|
|
69
|
-
var navigation_1 = require("next/navigation");
|
|
70
|
-
var PageHeader_1 = __importDefault(require("../PageHeader"));
|
|
71
|
-
var BottomActionLayout_1 = __importDefault(require("../BottomActionLayout"));
|
|
72
|
-
var SvgPath_1 = require("../SvgPath");
|
|
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
|
-
var SwapPage;
|
|
81
|
-
(function (SwapPage) {
|
|
82
|
-
SwapPage["SWAP"] = "swap";
|
|
83
|
-
SwapPage["SWAP_HISTORY"] = "swap_history";
|
|
84
|
-
SwapPage["SWAP_HISTORY_DETAIL"] = "swap_history_detail";
|
|
85
|
-
})(SwapPage || (exports.SwapPage = SwapPage = {}));
|
|
86
|
-
exports.SwapFunction = (0, react_1.forwardRef)(function (props, ref) {
|
|
87
|
-
var _a, _b, _c, _d;
|
|
88
|
-
var drawerRef = (0, react_1.useRef)(null);
|
|
89
|
-
var historyRef = (0, react_1.useRef)(null);
|
|
90
|
-
var swiperRef = (0, react_1.useRef)(null);
|
|
91
|
-
var sx = props.sx, className = props.className;
|
|
92
|
-
var theme = (0, ThemeProvider_1.useTheme)();
|
|
93
|
-
var _e = (0, react_1.useState)(SwapStep.SELECT_SWAP), currentStep = _e[0], setCurrentStep = _e[1];
|
|
94
|
-
var _f = (0, react_1.useState)(null), selectedToken = _f[0], setSelectedToken = _f[1];
|
|
95
|
-
var _g = (0, react_1.useState)(null), selectedOutputToken = _g[0], setSelectedOutputToken = _g[1];
|
|
96
|
-
var _h = (0, react_1.useState)(null), number = _h[0], setNumber = _h[1];
|
|
97
|
-
var router = (0, useCustomRouter_1.default)();
|
|
98
|
-
var searchParams = (0, navigation_1.useSearchParams)();
|
|
99
|
-
var isSwapPage = searchParams.get("is_swap_page") === "true";
|
|
100
|
-
var isHistoryPage = searchParams.get("is_history_page") === "true";
|
|
101
|
-
var isHistoryDetailPage = searchParams.get("is_history_detail_page") === "true";
|
|
102
|
-
var onChange = (0, react_1.useCallback)(function (e) {
|
|
103
|
-
var value = e.target.value;
|
|
104
|
-
setNumber(value === "" ? null : Number(value));
|
|
105
|
-
}, []);
|
|
106
|
-
var handleBack = function () {
|
|
107
|
-
gotoStep(currentStep - 1);
|
|
108
|
-
if (currentStep === SwapStep.SELECT_SWAP) {
|
|
109
|
-
closeSwapPage();
|
|
110
|
-
setNumber(null);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
var gotoStep = (0, react_1.useCallback)(function (step) {
|
|
114
|
-
var _a;
|
|
115
|
-
if (step === SwapStep.SELECT_SWAP) {
|
|
116
|
-
}
|
|
117
|
-
setCurrentStep(step);
|
|
118
|
-
(_a = swiperRef.current) === null || _a === void 0 ? void 0 : _a.slideTo(step);
|
|
119
|
-
}, []);
|
|
120
|
-
var handleSelectToken = function (token) {
|
|
121
|
-
if (!selectedToken || selectedToken.id !== token.id) {
|
|
122
|
-
setSelectedToken(token);
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var handleSelectOutputToken = function (output) {
|
|
126
|
-
if (!selectedOutputToken || selectedOutputToken.id !== output.id) {
|
|
127
|
-
setSelectedOutputToken(output);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
var rememberCurrentPage = (0, react_1.useCallback)(function (page) {
|
|
131
|
-
var currentParams = new URLSearchParams(searchParams.toString());
|
|
132
|
-
switch (page) {
|
|
133
|
-
case SwapPage.SWAP:
|
|
134
|
-
currentParams.set("is_swap_page", "true");
|
|
135
|
-
break;
|
|
136
|
-
case SwapPage.SWAP_HISTORY:
|
|
137
|
-
currentParams.set("is_history_page", "true");
|
|
138
|
-
break;
|
|
139
|
-
case SwapPage.SWAP_HISTORY_DETAIL:
|
|
140
|
-
currentParams.set("is_history_detail_page", "true");
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
router.replace("?".concat(currentParams.toString()));
|
|
144
|
-
}, [searchParams, router]);
|
|
145
|
-
var forgetCurrentPage = (0, react_1.useCallback)(function (page) {
|
|
146
|
-
var currentParams = new URLSearchParams(searchParams.toString());
|
|
147
|
-
switch (page) {
|
|
148
|
-
case SwapPage.SWAP:
|
|
149
|
-
currentParams.delete("is_swap_page");
|
|
150
|
-
currentParams.delete("is_history_page");
|
|
151
|
-
currentParams.delete("is_history_detail_page");
|
|
152
|
-
break;
|
|
153
|
-
case SwapPage.SWAP_HISTORY:
|
|
154
|
-
currentParams.delete("is_history_page");
|
|
155
|
-
currentParams.delete("is_history_detail_page");
|
|
156
|
-
break;
|
|
157
|
-
case SwapPage.SWAP_HISTORY_DETAIL:
|
|
158
|
-
currentParams.delete("is_history_detail_page");
|
|
159
|
-
break;
|
|
160
|
-
}
|
|
161
|
-
router.replace("?".concat(currentParams.toString()));
|
|
162
|
-
}, [searchParams, router]);
|
|
163
|
-
var handleOnCloseSwap = (0, react_1.useCallback)(function () {
|
|
164
|
-
var _a;
|
|
165
|
-
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
166
|
-
gotoStep(SwapStep.SELECT_SWAP);
|
|
167
|
-
forgetCurrentPage(SwapPage.SWAP);
|
|
168
|
-
}, [forgetCurrentPage, props]);
|
|
169
|
-
var handleOnOpenSwap = (0, react_1.useCallback)(function () {
|
|
170
|
-
var _a;
|
|
171
|
-
(_a = props.onOpen) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
172
|
-
rememberCurrentPage(SwapPage.SWAP);
|
|
173
|
-
}, [rememberCurrentPage]);
|
|
174
|
-
var openSwapPage = (0, react_1.useCallback)(function () {
|
|
175
|
-
var _a;
|
|
176
|
-
(_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
177
|
-
handleOnOpenSwap();
|
|
178
|
-
}, [handleOnOpenSwap]);
|
|
179
|
-
var closeSwapPage = (0, react_1.useCallback)(function () {
|
|
180
|
-
var _a;
|
|
181
|
-
(_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
182
|
-
handleOnCloseSwap();
|
|
183
|
-
}, [handleOnCloseSwap]);
|
|
184
|
-
var handleOnOpenHistory = (0, react_1.useCallback)(function () {
|
|
185
|
-
rememberCurrentPage(SwapPage.SWAP_HISTORY);
|
|
186
|
-
}, [rememberCurrentPage]);
|
|
187
|
-
var handleOnCloseHistory = (0, react_1.useCallback)(function () {
|
|
188
|
-
gotoStep(SwapStep.SELECT_SWAP);
|
|
189
|
-
forgetCurrentPage(SwapPage.SWAP_HISTORY);
|
|
190
|
-
}, [forgetCurrentPage, gotoStep]);
|
|
191
|
-
var openHistory = (0, react_1.useCallback)(function () {
|
|
192
|
-
setTimeout(function () {
|
|
193
|
-
var _a;
|
|
194
|
-
(_a = historyRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
195
|
-
handleOnOpenHistory();
|
|
196
|
-
}, 0);
|
|
197
|
-
}, [handleOnOpenHistory]);
|
|
198
|
-
var closeHistory = (0, react_1.useCallback)(function () {
|
|
199
|
-
var _a;
|
|
200
|
-
(_a = historyRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
201
|
-
handleOnCloseHistory();
|
|
202
|
-
}, [handleOnCloseHistory]);
|
|
203
|
-
(0, react_1.useEffect)(function () {
|
|
204
|
-
if (selectedToken) {
|
|
205
|
-
var outputs = selectedToken.outputs;
|
|
206
|
-
if (outputs.length > 0) {
|
|
207
|
-
if (!selectedOutputToken || !outputs.some(function (t) { return t.id === selectedOutputToken.id; })) {
|
|
208
|
-
setSelectedOutputToken(outputs[0]);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
setSelectedOutputToken(null);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
else {
|
|
216
|
-
setSelectedOutputToken(null);
|
|
217
|
-
}
|
|
218
|
-
}, [selectedToken, selectedOutputToken]);
|
|
219
|
-
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
220
|
-
open: openSwapPage,
|
|
221
|
-
close: closeSwapPage,
|
|
222
|
-
}); });
|
|
223
|
-
(0, react_1.useEffect)(function () {
|
|
224
|
-
if (isSwapPage) {
|
|
225
|
-
openSwapPage();
|
|
226
|
-
}
|
|
227
|
-
if (isSwapPage && isHistoryPage) {
|
|
228
|
-
openHistory();
|
|
229
|
-
}
|
|
230
|
-
if (isSwapPage && isHistoryPage && isHistoryDetailPage) {
|
|
231
|
-
openHistory();
|
|
232
|
-
}
|
|
233
|
-
}, [isSwapPage, isHistoryPage, isHistoryDetailPage]);
|
|
234
|
-
return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { className: className, sx: sx, ref: drawerRef, trigger: props.children, onOpen: handleOnOpenSwap, onDone: handleOnCloseSwap, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, children: (0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { header: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(PageHeader_1.default, { title: SWAP_STEP_NAME[currentStep], overrideBack: handleBack, children: currentStep === SwapStep.SELECT_SWAP && ((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)(material_1.SvgIcon, { sx: { width: 18, height: 18 }, children: SvgPath_1.IC_HELP }), (0, jsx_runtime_1.jsx)(material_1.Divider, { orientation: "vertical", sx: {
|
|
235
|
-
height: "1rem",
|
|
236
|
-
width: "1px",
|
|
237
|
-
backgroundColor: theme.palette.border.accent3,
|
|
238
|
-
marginLeft: theme.mixins.customMargin.m4,
|
|
239
|
-
marginRight: theme.mixins.customMargin.m4,
|
|
240
|
-
} }), (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: historyRef, trigger: (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: 18, height: 18 }, children: SvgPath_1.IC_HISTORY }), direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, onOpen: handleOnOpenHistory, onDone: handleOnCloseHistory, children: (0, jsx_runtime_1.jsx)(HistorySwap_1.default, { onClose: closeHistory }) })] })) }) }), footer: currentStep === SwapStep.SELECT_SWAP && ((0, jsx_runtime_1.jsx)(BottomActionLayout_1.default, { children: (0, jsx_runtime_1.jsx)(SwapToken_1.default
|
|
241
|
-
// onResetNumber={resetNumber}
|
|
242
|
-
, {
|
|
243
|
-
// onResetNumber={resetNumber}
|
|
244
|
-
sx: {
|
|
245
|
-
width: "100%",
|
|
246
|
-
}, sendData: {
|
|
247
|
-
amount: number !== null ? number.toString() : "",
|
|
248
|
-
currency_slug: (_a = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug) !== null && _a !== void 0 ? _a : "",
|
|
249
|
-
to_currency_slug: (_b = selectedOutputToken === null || selectedOutputToken === void 0 ? void 0 : selectedOutputToken.slug) !== null && _b !== void 0 ? _b : "",
|
|
250
|
-
extraTransactions: null,
|
|
251
|
-
}, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { disabled: !number ||
|
|
252
|
-
number < ((_c = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.min_value) !== null && _c !== void 0 ? _c : 0) ||
|
|
253
|
-
number > ((_d = selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.max_value) !== null && _d !== void 0 ? _d : 0) ||
|
|
254
|
-
number > Number(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.balance), fullWidth: true, 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)(material_1.Box, { sx: {
|
|
255
|
-
padding: theme.mixins.pagePadding,
|
|
256
|
-
position: "relative",
|
|
257
|
-
}, children: (0, jsx_runtime_1.jsx)(SwiperControlled_1.default, { ref: swiperRef, swiperProps: {
|
|
258
|
-
autoHeight: true,
|
|
259
|
-
spaceBetween: 32,
|
|
260
|
-
}, disableSwipe: true, initialActiveTab: currentStep, children: (0, jsx_runtime_1.jsxs)(react_2.SwiperSlide, { children: [(0, jsx_runtime_1.jsx)(FromCard_1.default, { onChange: onChange, selectedToken: selectedToken !== null && selectedToken !== void 0 ? selectedToken : undefined, amount: number !== null && number !== void 0 ? number : undefined }), (0, jsx_runtime_1.jsxs)(material_1.Stack, { direction: "row", alignItems: "center", gap: 1, sx: {
|
|
261
|
-
mt: "1rem",
|
|
262
|
-
mb: "1rem",
|
|
263
|
-
}, children: [(0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: 18, height: 18 }, children: SvgPath_1.IC_SWAP }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: {
|
|
264
|
-
width: "90%",
|
|
265
|
-
borderStyle: "dashed",
|
|
266
|
-
borderColor: "#A3A3A3",
|
|
267
|
-
opacity: 0.3,
|
|
268
|
-
} })] }), (0, jsx_runtime_1.jsx)(ToCard_1.default, { selectedToToken: selectedOutputToken !== null && selectedOutputToken !== void 0 ? selectedOutputToken : undefined, selectedFromToken: selectedToken !== null && selectedToken !== void 0 ? selectedToken : undefined, fromAmount: 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) }) }) }));
|
|
269
|
-
});
|
|
270
|
-
exports.SwapFunction.displayName = "SwapFunction";
|
|
271
|
-
exports.default = exports.SwapFunction;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SxProps } from "@mui/material";
|
|
2
|
-
import { ConfirmLayoutProps } from "../ConfirmLayout";
|
|
3
|
-
import { FeesDataType } from "../../../services/axios/get-est-fee-service/type";
|
|
4
|
-
import { SwapResponse } from "../../../services/axios/swap-service/type";
|
|
5
|
-
import { SwapDataType } from "../ConfirmSwapToken";
|
|
6
|
-
interface SwapTokenProps extends Omit<ConfirmLayoutProps, "action"> {
|
|
7
|
-
sendData: SwapDataType;
|
|
8
|
-
onSuccess?: (data: SwapResponse) => any;
|
|
9
|
-
initFeeData?: FeesDataType;
|
|
10
|
-
onStart?: () => void;
|
|
11
|
-
onFinish?: () => void;
|
|
12
|
-
onError?: (error: Error | unknown) => void;
|
|
13
|
-
sx?: SxProps;
|
|
14
|
-
btnConfirm?: React.ReactNode;
|
|
15
|
-
children?: React.ReactNode;
|
|
16
|
-
trigger?: React.ReactNode;
|
|
17
|
-
overrideHeader?: React.ReactNode;
|
|
18
|
-
}
|
|
19
|
-
export interface SwapTokenRef {
|
|
20
|
-
open: () => void;
|
|
21
|
-
close: () => void;
|
|
22
|
-
}
|
|
23
|
-
export declare enum SwapTokenError {
|
|
24
|
-
TOKEN_NOT_FOUND = "Token not found",
|
|
25
|
-
NOT_ENOUGH_BALANCE = "Not enough balance",
|
|
26
|
-
MAX_AMOUNT = "Max amount",
|
|
27
|
-
MIN_AMOUNT = "Min amount",
|
|
28
|
-
FAILED = "Failed"
|
|
29
|
-
}
|
|
30
|
-
export declare const SwapToken: import("react").ForwardRefExoticComponent<Omit<SwapTokenProps, "ref"> & import("react").RefAttributes<SwapTokenRef>>;
|
|
31
|
-
export default SwapToken;
|
|
@@ -1,293 +0,0 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
48
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
51
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
52
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
53
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
57
|
-
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);
|
|
58
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
59
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
60
|
-
function step(op) {
|
|
61
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
63
|
-
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;
|
|
64
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65
|
-
switch (op[0]) {
|
|
66
|
-
case 0: case 1: t = op; break;
|
|
67
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
68
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
69
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
70
|
-
default:
|
|
71
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
72
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
73
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
74
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
75
|
-
if (t[2]) _.ops.pop();
|
|
76
|
-
_.trys.pop(); continue;
|
|
77
|
-
}
|
|
78
|
-
op = body.call(thisArg, _);
|
|
79
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
80
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
84
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
85
|
-
};
|
|
86
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
87
|
-
exports.SwapToken = exports.SwapTokenError = void 0;
|
|
88
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
89
|
-
var material_1 = require("@mui/material");
|
|
90
|
-
var ThemeProvider_1 = require("../../../providers/ThemeProvider");
|
|
91
|
-
var Button_1 = __importStar(require("../Button"));
|
|
92
|
-
var ConfirmLayout_1 = __importDefault(require("../ConfirmLayout"));
|
|
93
|
-
var LineValue_1 = __importDefault(require("../LineValue"));
|
|
94
|
-
var Formatter_1 = __importDefault(require("../Formatter"));
|
|
95
|
-
var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
|
|
96
|
-
var react_1 = require("react");
|
|
97
|
-
var Text_1 = __importDefault(require("../Text"));
|
|
98
|
-
var RequireConnect_1 = __importDefault(require("../RequireConnect"));
|
|
99
|
-
var useWalletData_1 = __importDefault(require("../../../hooks/useWalletData"));
|
|
100
|
-
var Fees_1 = __importDefault(require("../Fees"));
|
|
101
|
-
var get_est_fee_service_1 = __importDefault(require("../../../services/axios/get-est-fee-service"));
|
|
102
|
-
var type_1 = require("../../../services/axios/get-activities-service/type");
|
|
103
|
-
var useSwapData_1 = __importDefault(require("../../../hooks/useSwapData"));
|
|
104
|
-
var swap_service_1 = __importDefault(require("../../../services/axios/swap-service"));
|
|
105
|
-
var Icon_1 = __importDefault(require("../Icon"));
|
|
106
|
-
var roundToTwoSignificantDecimals_1 = __importDefault(require("../../../utils/roundToTwoSignificantDecimals"));
|
|
107
|
-
var getImage_1 = __importDefault(require("../../../utils/getImage"));
|
|
108
|
-
var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
|
|
109
|
-
var SwapTokenError;
|
|
110
|
-
(function (SwapTokenError) {
|
|
111
|
-
SwapTokenError["TOKEN_NOT_FOUND"] = "Token not found";
|
|
112
|
-
SwapTokenError["NOT_ENOUGH_BALANCE"] = "Not enough balance";
|
|
113
|
-
SwapTokenError["MAX_AMOUNT"] = "Max amount";
|
|
114
|
-
SwapTokenError["MIN_AMOUNT"] = "Min amount";
|
|
115
|
-
SwapTokenError["FAILED"] = "Failed";
|
|
116
|
-
})(SwapTokenError || (exports.SwapTokenError = SwapTokenError = {}));
|
|
117
|
-
var transactionSlug = type_1.TransactionSlug.SWAP;
|
|
118
|
-
exports.SwapToken = (0, react_1.forwardRef)(function (props, ref) {
|
|
119
|
-
var _a;
|
|
120
|
-
var theme = (0, ThemeProvider_1.useTheme)();
|
|
121
|
-
var _b = (0, useSwapData_1.default)(), fromTokens = _b.fromTokens, updateSwapTokens = _b.updateSwapTokens;
|
|
122
|
-
var isInitPasscode = (0, useWalletData_1.default)().isInitPasscode;
|
|
123
|
-
var confirmLayoutDrawerRef = (0, react_1.useRef)(null);
|
|
124
|
-
var _c = (0, react_1.useState)(undefined), error = _c[0], setError = _c[1];
|
|
125
|
-
var _d = (0, react_1.useState)(undefined), errorAmount = _d[0], setErrorAmount = _d[1];
|
|
126
|
-
var _e = (0, react_1.useState)(Button_1.BUTTON_STATUS.ENABLED), buttonStatus = _e[0], setButtonStatus = _e[1];
|
|
127
|
-
var _f = (0, react_1.useState)(props.initFeeData), estimateFee = _f[0], setEstimateFee = _f[1];
|
|
128
|
-
var _g = (0, react_1.useState)(false), isLoadingEstimateFee = _g[0], setIsLoadingEstimateFee = _g[1];
|
|
129
|
-
var amount = props.sendData.amount;
|
|
130
|
-
var fromTokenSlug = props.sendData.currency_slug;
|
|
131
|
-
var toTokenSlug = props.sendData.to_currency_slug;
|
|
132
|
-
var sx = props.sx, children = props.children, btnConfirm = props.btnConfirm, trigger = props.trigger, overrideHeader = props.overrideHeader;
|
|
133
|
-
var fromToken = (0, react_1.useMemo)(function () {
|
|
134
|
-
return fromTokens === null || fromTokens === void 0 ? void 0 : fromTokens.find(function (token) { return token.slug === fromTokenSlug; });
|
|
135
|
-
}, [fromTokenSlug, fromTokens]);
|
|
136
|
-
var toToken = (0, react_1.useMemo)(function () {
|
|
137
|
-
var _a;
|
|
138
|
-
if (!fromToken)
|
|
139
|
-
return undefined;
|
|
140
|
-
return (_a = fromToken.outputs) === null || _a === void 0 ? void 0 : _a.find(function (token) { return token.slug === toTokenSlug; });
|
|
141
|
-
}, [toTokenSlug, fromToken]);
|
|
142
|
-
var toAmount = (0, react_1.useMemo)(function () {
|
|
143
|
-
if (!toToken)
|
|
144
|
-
return undefined;
|
|
145
|
-
return +amount / +toToken.usd_rate;
|
|
146
|
-
}, [toToken, amount]);
|
|
147
|
-
var getEstimateFee = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
148
|
-
var response;
|
|
149
|
-
return __generator(this, function (_a) {
|
|
150
|
-
switch (_a.label) {
|
|
151
|
-
case 0:
|
|
152
|
-
if (!fromTokenSlug)
|
|
153
|
-
return [2 /*return*/];
|
|
154
|
-
setIsLoadingEstimateFee(true);
|
|
155
|
-
return [4 /*yield*/, (0, get_est_fee_service_1.default)({
|
|
156
|
-
amount: "".concat(amount),
|
|
157
|
-
transaction_type: transactionSlug,
|
|
158
|
-
currency: fromTokenSlug || "",
|
|
159
|
-
to_currency_slug: toTokenSlug || "",
|
|
160
|
-
})];
|
|
161
|
-
case 1:
|
|
162
|
-
response = _a.sent();
|
|
163
|
-
setIsLoadingEstimateFee(false);
|
|
164
|
-
setEstimateFee(response === null || response === void 0 ? void 0 : response.data);
|
|
165
|
-
return [2 /*return*/, true];
|
|
166
|
-
}
|
|
167
|
-
});
|
|
168
|
-
}); }, [amount, fromTokenSlug]);
|
|
169
|
-
var token = (0, react_1.useMemo)(function () {
|
|
170
|
-
return fromTokens === null || fromTokens === void 0 ? void 0 : fromTokens.find(function (token) { return token.slug === fromTokenSlug; });
|
|
171
|
-
}, [fromTokenSlug, fromTokens]);
|
|
172
|
-
var validateAmount = (0, react_1.useCallback)(function () {
|
|
173
|
-
if (!token) {
|
|
174
|
-
setError(SwapTokenError.TOKEN_NOT_FOUND);
|
|
175
|
-
return false;
|
|
176
|
-
}
|
|
177
|
-
if (+amount > token.max_value) {
|
|
178
|
-
setError(SwapTokenError.MAX_AMOUNT);
|
|
179
|
-
setErrorAmount(token.max_value);
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
if (+amount < token.min_value) {
|
|
183
|
-
setError(SwapTokenError.MIN_AMOUNT);
|
|
184
|
-
setErrorAmount(token.min_value);
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
if (+amount > +token.balance) {
|
|
188
|
-
setError(SwapTokenError.NOT_ENOUGH_BALANCE);
|
|
189
|
-
setErrorAmount(token.balance);
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
setError(undefined);
|
|
193
|
-
setErrorAmount(undefined);
|
|
194
|
-
return true;
|
|
195
|
-
}, [amount, token]);
|
|
196
|
-
var validateAll = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
197
|
-
var isAmountValid;
|
|
198
|
-
return __generator(this, function (_a) {
|
|
199
|
-
isAmountValid = validateAmount();
|
|
200
|
-
if (!isAmountValid)
|
|
201
|
-
return [2 /*return*/, false];
|
|
202
|
-
getEstimateFee();
|
|
203
|
-
return [2 /*return*/];
|
|
204
|
-
});
|
|
205
|
-
}); }, [validateAmount, getEstimateFee]);
|
|
206
|
-
var handleSwapToken = function (passcode) { return __awaiter(void 0, void 0, void 0, function () {
|
|
207
|
-
var response, err_1;
|
|
208
|
-
var _a, _b, _c, _d, _e;
|
|
209
|
-
return __generator(this, function (_f) {
|
|
210
|
-
switch (_f.label) {
|
|
211
|
-
case 0:
|
|
212
|
-
_f.trys.push([0, 2, 3, 4]);
|
|
213
|
-
(_a = props.onStart) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
214
|
-
setButtonStatus(Button_1.BUTTON_STATUS.LOADING);
|
|
215
|
-
return [4 /*yield*/, (0, swap_service_1.default)(__assign(__assign({}, props.sendData), { passcode: passcode }))];
|
|
216
|
-
case 1:
|
|
217
|
-
response = _f.sent();
|
|
218
|
-
if (response.success) {
|
|
219
|
-
(_b = confirmLayoutDrawerRef.current) === null || _b === void 0 ? void 0 : _b.close();
|
|
220
|
-
setButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
|
|
221
|
-
(_c = props.onSuccess) === null || _c === void 0 ? void 0 : _c.call(props, response);
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
throw new Error("Swap internal failed");
|
|
225
|
-
}
|
|
226
|
-
return [3 /*break*/, 4];
|
|
227
|
-
case 2:
|
|
228
|
-
err_1 = _f.sent();
|
|
229
|
-
(_d = props.onError) === null || _d === void 0 ? void 0 : _d.call(props, err_1);
|
|
230
|
-
setButtonStatus(Button_1.BUTTON_STATUS.ERROR);
|
|
231
|
-
setTimeout(function () {
|
|
232
|
-
setButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
|
|
233
|
-
}, 1200);
|
|
234
|
-
return [3 /*break*/, 4];
|
|
235
|
-
case 3:
|
|
236
|
-
(_e = props.onFinish) === null || _e === void 0 ? void 0 : _e.call(props);
|
|
237
|
-
return [7 /*endfinally*/];
|
|
238
|
-
case 4: return [2 /*return*/];
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}); };
|
|
242
|
-
var handleOpen = function () {
|
|
243
|
-
var _a;
|
|
244
|
-
if (!isInitPasscode)
|
|
245
|
-
throw new Error("Please connect your wallet");
|
|
246
|
-
(_a = confirmLayoutDrawerRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
247
|
-
validateAll();
|
|
248
|
-
};
|
|
249
|
-
var handleClose = function () {
|
|
250
|
-
var _a;
|
|
251
|
-
if (!isInitPasscode)
|
|
252
|
-
throw new Error("Please connect your wallet");
|
|
253
|
-
(_a = confirmLayoutDrawerRef.current) === null || _a === void 0 ? void 0 : _a.close();
|
|
254
|
-
};
|
|
255
|
-
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
256
|
-
open: handleOpen,
|
|
257
|
-
close: handleClose,
|
|
258
|
-
}); });
|
|
259
|
-
var estimateReceive = (0, react_1.useMemo)(function () {
|
|
260
|
-
if (!estimateFee || !amount || !(toToken === null || toToken === void 0 ? void 0 : toToken.usd_rate))
|
|
261
|
-
return undefined;
|
|
262
|
-
return (+amount - +(estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.fee_in_currency)) / +(toToken === null || toToken === void 0 ? void 0 : toToken.usd_rate);
|
|
263
|
-
}, [estimateFee, toToken, amount]);
|
|
264
|
-
(0, react_1.useEffect)(function () {
|
|
265
|
-
if (isInitPasscode && !fromTokens) {
|
|
266
|
-
updateSwapTokens();
|
|
267
|
-
}
|
|
268
|
-
}, [isInitPasscode, fromTokens]);
|
|
269
|
-
return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: (0, jsx_runtime_1.jsx)(ConfirmLayout_1.default, { onOpen: validateAll, trigger: trigger, ref: confirmLayoutDrawerRef, action: transactionSlug, header: {
|
|
270
|
-
title: overrideHeader,
|
|
271
|
-
}, sx: sx, confirmAction: (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: transactionSlug, onConfirmSuccess: handleSwapToken, children: btnConfirm !== null && btnConfirm !== void 0 ? btnConfirm : ((0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: !!error || isLoadingEstimateFee ? Button_1.BUTTON_STATUS.DISABLED : buttonStatus, sx: { width: "100%" }, children: "Swap" })) }), children: children !== null && children !== void 0 ? children : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { 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: { display: "flex", gap: theme.mixins.gaps.g12, flexDirection: "column" }, 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: {
|
|
272
|
-
width: "100%",
|
|
273
|
-
mt: theme.mixins.customMargin.m4,
|
|
274
|
-
mb: theme.mixins.customMargin.m4,
|
|
275
|
-
}, children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("swap_up"), width: 18, height: 18, color: theme.palette.text.primary }), (0, jsx_runtime_1.jsx)(material_1.Divider, { sx: {
|
|
276
|
-
width: "95%",
|
|
277
|
-
borderStyle: "dashed",
|
|
278
|
-
borderColor: theme.palette.border.white16,
|
|
279
|
-
} })] }), (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: toToken === null || toToken === void 0 ? void 0 : toToken.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: toToken === null || toToken === void 0 ? void 0 : toToken.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: toAmount }) })] })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { mt: theme.mixins.customMargin.m12 }), children: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
280
|
-
fontSize: theme.typography.fontSize18,
|
|
281
|
-
fontWeight: theme.typography.fontWeight700,
|
|
282
|
-
color: theme.palette.text.black,
|
|
283
|
-
}, 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: 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: {
|
|
284
|
-
color: theme.palette.text.black,
|
|
285
|
-
fontWeight: theme.typography.fontWeight600,
|
|
286
|
-
}, 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: {
|
|
287
|
-
color: theme.palette.text.primary,
|
|
288
|
-
fontWeight: theme.typography.fontWeight600,
|
|
289
|
-
fontSize: theme.typography.fontSize13,
|
|
290
|
-
}, 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 }) }))] })) }) }));
|
|
291
|
-
});
|
|
292
|
-
exports.SwapToken.displayName = "SwapToken";
|
|
293
|
-
exports.default = exports.SwapToken;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Theme } from "@mui/material";
|
|
3
|
-
type ThemeProviderProps = {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
};
|
|
6
|
-
export declare function CustomThemeProvider({ children }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export declare const useTheme: () => Theme;
|
|
8
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// CustomThemeProvider.tsx
|
|
3
|
-
"use client";
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.useTheme = void 0;
|
|
9
|
-
exports.CustomThemeProvider = CustomThemeProvider;
|
|
10
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
|
-
var react_1 = require("react");
|
|
12
|
-
var theme_1 = __importDefault(require("../../theme/mui/theme")); // file bạn tạo custom theme
|
|
13
|
-
var ThemeContext = (0, react_1.createContext)(undefined);
|
|
14
|
-
// function mergeObjects(obj1: any, obj2: any) {
|
|
15
|
-
// const result = { ...obj1 };
|
|
16
|
-
// for (const key in obj2) {
|
|
17
|
-
// if (
|
|
18
|
-
// obj2[key] &&
|
|
19
|
-
// typeof obj2[key] === "object" &&
|
|
20
|
-
// !Array.isArray(obj2[key]) &&
|
|
21
|
-
// obj1[key] &&
|
|
22
|
-
// typeof obj1[key] === "object" &&
|
|
23
|
-
// !Array.isArray(obj1[key])
|
|
24
|
-
// ) {
|
|
25
|
-
// result[key] = mergeObjects(obj1[key], obj2[key]);
|
|
26
|
-
// } else {
|
|
27
|
-
// result[key] = obj2[key];
|
|
28
|
-
// }
|
|
29
|
-
// }
|
|
30
|
-
// return result;
|
|
31
|
-
// }
|
|
32
|
-
function CustomThemeProvider(_a) {
|
|
33
|
-
var children = _a.children;
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(ThemeContext.Provider, { value: theme_1.default, children: children }));
|
|
35
|
-
}
|
|
36
|
-
var useTheme = function () {
|
|
37
|
-
var context = (0, react_1.useContext)(ThemeContext);
|
|
38
|
-
if (context === undefined) {
|
|
39
|
-
throw new Error("useTheme must be used within a CustomThemeProvider");
|
|
40
|
-
}
|
|
41
|
-
return context;
|
|
42
|
-
};
|
|
43
|
-
exports.useTheme = useTheme;
|