tek-wallet 0.0.402 → 0.0.404
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.
|
@@ -45,24 +45,27 @@ function Fees(props) {
|
|
|
45
45
|
var _a;
|
|
46
46
|
var result = [];
|
|
47
47
|
(_a = feesData === null || feesData === void 0 ? void 0 : feesData.feeDetail) === null || _a === void 0 ? void 0 : _a.forEach(function (fee) {
|
|
48
|
-
var _a, _b, _c, _d;
|
|
48
|
+
var _a, _b, _c, _d, _e;
|
|
49
49
|
var index = result === null || result === void 0 ? void 0 : result.findIndex(function (feeDetail) { var _a, _b; return ((_a = feeDetail.currency) === null || _a === void 0 ? void 0 : _a.slug) === ((_b = fee === null || fee === void 0 ? void 0 : fee.currency) === null || _b === void 0 ? void 0 : _b.slug); });
|
|
50
50
|
if (index === -1) {
|
|
51
51
|
result.push(fee);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
|
-
|
|
54
|
+
var rate = fee.feeInUSD / fee.feeInCurrency;
|
|
55
55
|
result[index].feeFixed += fee.feeFixed;
|
|
56
56
|
result[index].feeInCurrency += fee.feeInCurrency;
|
|
57
57
|
result[index].feeInUSD += fee.feeInUSD;
|
|
58
58
|
result[index].feePercent += fee.feePercent;
|
|
59
59
|
result[index].feePercentInCurrency =
|
|
60
60
|
((_a = result[index].feeInCurrency) !== null && _a !== void 0 ? _a : 0) + amount * (fee.feePercent / 100);
|
|
61
|
-
|
|
62
|
-
((
|
|
61
|
+
result[index].feePercentInUSD =
|
|
62
|
+
((_b = result[index].feeInUSD) !== null && _b !== void 0 ? _b : 0) +
|
|
63
|
+
amount * (fee.feePercent / 100) * rate;
|
|
64
|
+
var totalFeeInCurrency = ((_c = result[index].feeInCurrency) !== null && _c !== void 0 ? _c : 0) +
|
|
65
|
+
((_d = result[index].feePercentInCurrency) !== null && _d !== void 0 ? _d : 0);
|
|
63
66
|
var token = tokens === null || tokens === void 0 ? void 0 : tokens.find(function (token) { var _a; return token.currency_slug === ((_a = fee === null || fee === void 0 ? void 0 : fee.currency) === null || _a === void 0 ? void 0 : _a.slug); });
|
|
64
67
|
result[index].isEnoughBalanceToPay =
|
|
65
|
-
+((
|
|
68
|
+
+((_e = token === null || token === void 0 ? void 0 : token.current_value) !== null && _e !== void 0 ? _e : 0) >= totalFeeInCurrency;
|
|
66
69
|
}
|
|
67
70
|
});
|
|
68
71
|
console.warn("🚀 ~ consttokensFee:FeeDetailType[]=useMemo ~ result:", result);
|
|
@@ -78,6 +81,9 @@ function Fees(props) {
|
|
|
78
81
|
var isEnoughBalanceToPayFee = (0, react_1.useMemo)(function () {
|
|
79
82
|
return feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.some(function (fee) { return !fee.isEnoughBalanceToPay; });
|
|
80
83
|
}, [feeCheckedBalance]);
|
|
84
|
+
var totalFeeInUSD = (0, react_1.useMemo)(function () {
|
|
85
|
+
return tokensFee === null || tokensFee === void 0 ? void 0 : tokensFee.reduce(function (acc, fee) { var _a, _b; return acc + ((_a = fee.feeInUSD) !== null && _a !== void 0 ? _a : 0) + ((_b = fee.feePercentInUSD) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
86
|
+
}, [tokensFee]);
|
|
81
87
|
return ((0, jsx_runtime_1.jsxs)(material_1.Accordion, __assign({ defaultExpanded: true }, rest, { sx: __assign({ "&.MuiAccordion-root": {
|
|
82
88
|
backgroundColor: "transparent",
|
|
83
89
|
margin: 0,
|
|
@@ -96,7 +102,7 @@ function Fees(props) {
|
|
|
96
102
|
}, "& .MuiAccordionDetails-root": {
|
|
97
103
|
paddingLeft: theme.mixins.customPadding.p12,
|
|
98
104
|
paddingRight: theme.mixins.customPadding.p12,
|
|
99
|
-
} }, sx), children: [(0, jsx_runtime_1.jsx)(material_1.AccordionSummary, { expandIcon: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_down"), width: 20 }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "100%" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Total fees" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value:
|
|
105
|
+
} }, sx), children: [(0, jsx_runtime_1.jsx)(material_1.AccordionSummary, { expandIcon: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("arrow_down"), width: 20 }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "100%" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Total fees" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: totalFeeInUSD, start: "~ $" }) })] }) }), (0, jsx_runtime_1.jsx)(material_1.AccordionDetails, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g8 }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { alignItems: "stretch" }), children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g8, alignItems: "center" }), children: feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.map(function (item, index) {
|
|
100
106
|
var _a;
|
|
101
107
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_2.Fragment, { children: [index !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
102
108
|
borderRight: "1px dashed ".concat(theme.palette.border.white24),
|
|
@@ -116,6 +116,10 @@ var Formatter_1 = __importDefault(require("../Formatter"));
|
|
|
116
116
|
var send_internal_service_1 = __importDefault(require("../../../services/axios/send-internal-service"));
|
|
117
117
|
var get_est_fee_service_1 = __importDefault(require("../../../services/axios/get-est-fee-service"));
|
|
118
118
|
var Fees_1 = __importDefault(require("../Fees"));
|
|
119
|
+
var ConfirmLayout_1 = __importDefault(require("../ConfirmLayout"));
|
|
120
|
+
var type_1 = require("../ConfirmLayout/type");
|
|
121
|
+
var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
|
|
122
|
+
var LineValue_1 = __importDefault(require("../LineValue"));
|
|
119
123
|
var SendMethods;
|
|
120
124
|
(function (SendMethods) {
|
|
121
125
|
SendMethods["SCAN_QR_CODE"] = "scan qr code";
|
|
@@ -621,17 +625,19 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
621
625
|
placeholder: "Enter memo",
|
|
622
626
|
value: memo,
|
|
623
627
|
onChange: handleChangeMemo,
|
|
624
|
-
} })] })), ((_a = estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeDetail) === null || _a === void 0 ? void 0 : _a.length) && !!amount && ((0, jsx_runtime_1.jsx)(Fees_1.default, { feesData: JSON.stringify(estimateFee), amount: +amount })), estimateReceive !== undefined && !amountError && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.row), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Estimate receive" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: estimateReceive }) })] })), (0, jsx_runtime_1.jsx)(
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
628
|
+
} })] })), ((_a = estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeDetail) === null || _a === void 0 ? void 0 : _a.length) && !!amount && ((0, jsx_runtime_1.jsx)(Fees_1.default, { feesData: JSON.stringify(estimateFee), amount: +amount })), estimateReceive !== undefined && !amountError && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.row), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.fieldTitle), children: "Estimate receive" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { ml: "auto" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: estimateReceive }) })] })), (0, jsx_runtime_1.jsx)(ConfirmLayout_1.default
|
|
629
|
+
// ref={confirmByPasscodeDrawerRef}
|
|
630
|
+
, {
|
|
631
|
+
// ref={confirmByPasscodeDrawerRef}
|
|
632
|
+
action: type_1.ActionConfirm.LOCK, trigger: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, onClick: handleSend, status: !!amountError ||
|
|
633
|
+
!!recipientAddressError ||
|
|
634
|
+
!recipientAddress ||
|
|
635
|
+
!amount ||
|
|
636
|
+
!selectedToken ||
|
|
637
|
+
isLoadingEstimateFee ||
|
|
638
|
+
isValidatingAddress
|
|
639
|
+
? Button_1.BUTTON_STATUS.DISABLED
|
|
640
|
+
: Button_1.BUTTON_STATUS.ENABLED, children: "Continue" }), children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign({}, theme.mixins.paper), children: (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Amount", value: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: amount, unit: selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name }) }) }), (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: ["Your balance is", " "] }), (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: type_1.ActionConfirm.LOCK, onConfirmSuccess: function () { return console.warn("confirm success"); }, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: Button_1.BUTTON_STATUS.ENABLED, sx: { width: "100%" }, children: "Confirm" }) })] }) })] }) }, WithdrawStep.FORM)] }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAddressQrCodeRef, onResult: handleScanAddressQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: backDropRef }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { overrideOpen: !!infoDialogContent, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
635
641
|
textAlign: "center",
|
|
636
642
|
display: "inline-block",
|
|
637
643
|
width: "100%",
|