tek-wallet 0.0.607 → 0.0.609
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/ui/Fees/index.js +13 -14
- package/dist/components/TekWallet/components/ui/SendExternalToken/index.js +12 -9
- package/dist/components/TekWallet/components/ui/WithdrawFunction/index.js +1 -0
- package/dist/components/TekWallet/services/axios/send-external-service/type.d.ts +3 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -50,12 +50,9 @@ function Fees(props) {
|
|
|
50
50
|
return +((_a = tokenMustBePaidFee === null || tokenMustBePaidFee === void 0 ? void 0 : tokenMustBePaidFee.current_value) !== null && _a !== void 0 ? _a : 0);
|
|
51
51
|
}, [isFeePaidByAmount, amount, tokenSlug, tokens]);
|
|
52
52
|
var feeCheckedBalance = (0, react_1.useMemo)(function () {
|
|
53
|
-
var _a, _b
|
|
53
|
+
var _a, _b;
|
|
54
54
|
var feeDetail = (_a = feesData === null || feesData === void 0 ? void 0 : feesData.feeDetail) !== null && _a !== void 0 ? _a : [];
|
|
55
|
-
|
|
56
|
-
(_b = props.onEnoughBalanceToPayFee) === null || _b === void 0 ? void 0 : _b.call(props, true);
|
|
57
|
-
}
|
|
58
|
-
return ((_c = feeDetail === null || feeDetail === void 0 ? void 0 : feeDetail.map(function (fee, index, array) {
|
|
55
|
+
return ((_b = feeDetail === null || feeDetail === void 0 ? void 0 : feeDetail.map(function (fee, index, array) {
|
|
59
56
|
var _a, _b;
|
|
60
57
|
var totalFeeInCurrency = array === null || array === void 0 ? void 0 : array.reduce(function (acc, feeDetail) {
|
|
61
58
|
var _a, _b;
|
|
@@ -65,15 +62,15 @@ function Fees(props) {
|
|
|
65
62
|
return acc;
|
|
66
63
|
}, 0);
|
|
67
64
|
var balanceUseToPaidFee = getBalanceUseToPaidFee((_b = (_a = fee === null || fee === void 0 ? void 0 : fee.currency) === null || _a === void 0 ? void 0 : _a.slug) !== null && _b !== void 0 ? _b : "");
|
|
68
|
-
var
|
|
69
|
-
return __assign(__assign({}, fee), { isEnoughBalanceToPay:
|
|
70
|
-
})) !== null &&
|
|
65
|
+
var payable = balanceUseToPaidFee >= totalFeeInCurrency;
|
|
66
|
+
return __assign(__assign({}, fee), { isEnoughBalanceToPay: payable });
|
|
67
|
+
})) !== null && _b !== void 0 ? _b : []);
|
|
71
68
|
}, [feesData === null || feesData === void 0 ? void 0 : feesData.feeDetail, getBalanceUseToPaidFee]);
|
|
72
|
-
var
|
|
69
|
+
var isNotEnoughBalanceToPayFee = (0, react_1.useMemo)(function () {
|
|
73
70
|
var _a;
|
|
74
|
-
var
|
|
75
|
-
(_a = props.onEnoughBalanceToPayFee) === null || _a === void 0 ? void 0 : _a.call(props,
|
|
76
|
-
return
|
|
71
|
+
var isNotEnoughBalanceToPay = feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.some(function (fee) { return !fee.isEnoughBalanceToPay; });
|
|
72
|
+
(_a = props.onEnoughBalanceToPayFee) === null || _a === void 0 ? void 0 : _a.call(props, !isNotEnoughBalanceToPay);
|
|
73
|
+
return isNotEnoughBalanceToPay;
|
|
77
74
|
}, [feeCheckedBalance]);
|
|
78
75
|
var totalFeeInUSD = (0, react_1.useMemo)(function () {
|
|
79
76
|
return feesData === null || feesData === void 0 ? void 0 : feesData.feeInUSD;
|
|
@@ -83,6 +80,8 @@ function Fees(props) {
|
|
|
83
80
|
margin: 0,
|
|
84
81
|
padding: 0,
|
|
85
82
|
borderRadius: 0,
|
|
83
|
+
border: "none",
|
|
84
|
+
boxShadow: "none",
|
|
86
85
|
}, "&.MuiAccordion-root::before": {
|
|
87
86
|
display: "none",
|
|
88
87
|
}, "& .MuiAccordionSummary-root": {
|
|
@@ -110,7 +109,7 @@ function Fees(props) {
|
|
|
110
109
|
width: "100%",
|
|
111
110
|
ml: theme.mixins.gaps.g8,
|
|
112
111
|
mr: theme.mixins.gaps.g8,
|
|
113
|
-
} }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(
|
|
112
|
+
} }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: totalFeeInUSD, start: "~ $", disableTooltip: true }) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { width: "0.5rem" }) })] }) }), (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, pt: theme.mixins.gaps.g12 }), 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", justifyContent: "center" }), children: feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.map(function (item, index) {
|
|
114
113
|
var _a;
|
|
115
114
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_2.Fragment, { children: [index !== 0 && ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
116
115
|
borderRight: "1px dashed ".concat(theme.palette.border.white24),
|
|
@@ -119,7 +118,7 @@ function Fees(props) {
|
|
|
119
118
|
}) }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { flex: 1, gap: theme.mixins.gaps.g8 }), children: feeCheckedBalance === null || feeCheckedBalance === void 0 ? void 0 : feeCheckedBalance.map(function (item) {
|
|
120
119
|
var _a, _b, _c;
|
|
121
120
|
return ((0, jsx_runtime_1.jsx)(FeeDetail, { feeName: (_a = item.feeType) === null || _a === void 0 ? void 0 : _a.name, feeInCurrency: item.feeInCurrency, feeInUSD: item.feeInUSD, currencyName: (_b = item.currency) === null || _b === void 0 ? void 0 : _b.name }, (_c = item.feeType) === null || _c === void 0 ? void 0 : _c.name));
|
|
122
|
-
}) })] }),
|
|
121
|
+
}) })] }), isNotEnoughBalanceToPayFee && ((0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign({}, theme.mixins.validationError), children: ["You don't have enough balance to pay the fee, please ", " ", (0, jsx_runtime_1.jsxs)(ReceiveFunction_1.default, { children: [" ", (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
123
122
|
textDecoration: "underline",
|
|
124
123
|
cursor: "pointer",
|
|
125
124
|
fontWeight: theme.typography.fontWeight600,
|
|
@@ -104,7 +104,6 @@ var get_est_fee_service_1 = __importDefault(require("../../../services/axios/get
|
|
|
104
104
|
var type_1 = require("../../../services/axios/get-activities-service/type");
|
|
105
105
|
var validate_wallet_address_service_1 = __importDefault(require("../../../services/axios/validate-wallet-address-service"));
|
|
106
106
|
var type_2 = require("../../../services/axios/validate-wallet-address-service/type");
|
|
107
|
-
var CopyableText_1 = __importDefault(require("../CopyableText"));
|
|
108
107
|
var SendExternalTokenError;
|
|
109
108
|
(function (SendExternalTokenError) {
|
|
110
109
|
SendExternalTokenError["TOKEN_NOT_FOUND"] = "Token not found";
|
|
@@ -127,6 +126,7 @@ var SendExternalToken = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
127
126
|
var _f = (0, react_1.useState)(false), isValidatingAddress = _f[0], setIsValidatingAddress = _f[1];
|
|
128
127
|
var _g = (0, react_1.useState)(props.initFeeData), estimateFee = _g[0], setEstimateFee = _g[1];
|
|
129
128
|
var _h = (0, react_1.useState)(false), isLoadingEstimateFee = _h[0], setIsLoadingEstimateFee = _h[1];
|
|
129
|
+
var _j = (0, react_1.useState)(false), isEnoughBalanceToPayFee = _j[0], setIsEnoughBalanceToPayFee = _j[1];
|
|
130
130
|
var amount = props.sendExternalData.amount;
|
|
131
131
|
var network = props.sendExternalData.network;
|
|
132
132
|
var memo = props.sendExternalData.memo;
|
|
@@ -262,16 +262,19 @@ var SendExternalToken = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
262
262
|
open: handleOpen,
|
|
263
263
|
close: handleClose,
|
|
264
264
|
}); });
|
|
265
|
-
var
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
265
|
+
var estimateReceive = (0, react_1.useMemo)(function () {
|
|
266
|
+
if (!estimateFee || !amount)
|
|
267
|
+
return undefined;
|
|
268
|
+
return +amount - +(estimateFee === null || estimateFee === void 0 ? void 0 : estimateFee.feeInCurrency);
|
|
269
|
+
}, [estimateFee, amount]);
|
|
270
|
+
return ((0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: (0, jsx_runtime_1.jsx)(ConfirmLayout_1.default, { onOpen: validateAll, ref: confirmLayoutDrawerRef, action: transactionSlug, trigger: props.children, 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.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.paper), children: [(0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Recipient address", value: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
269
271
|
wordBreak: "break-all",
|
|
270
|
-
}, children: (0, jsx_runtime_1.jsx)(
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
}, children: toAddress }), valueDescription: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.validationError), children: errorAddress }) }), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Network", value: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g6, ml: "auto" }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { width: 20, src: network === null || network === void 0 ? void 0 : network.icon }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: network === null || network === void 0 ? void 0 : network.name })] }) }), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Amount", value: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: amount, unit: " ".concat(token === null || token === void 0 ? void 0 : token.name) }) }), !!memo && (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: "Memo", value: memo }), ((_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, { isFeePaidByAmount: true, feesData: JSON.stringify(estimateFee), amount: +amount, tokenSlug: tokenSlug, onEnoughBalanceToPayFee: setIsEnoughBalanceToPayFee })), (0, jsx_runtime_1.jsx)(LineValue_1.default, { field: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: "Receive amount estimated" }), value: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
273
|
+
fontWeight: theme.typography.fontWeight600,
|
|
274
|
+
fontSize: theme.typography.fontSize16,
|
|
275
|
+
}, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: estimateReceive, unit: " ".concat(token === null || token === void 0 ? void 0 : token.name) }) }) }), !!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) })] }))] }), (0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { action: transactionSlug, onConfirmSuccess: handleSendExternalToken, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { status: !!error || isLoadingEstimateFee || isValidatingAddress || errorAddress || !isEnoughBalanceToPayFee
|
|
273
276
|
? Button_1.BUTTON_STATUS.DISABLED
|
|
274
|
-
: buttonStatus, children: "Confirm" }) }) })
|
|
277
|
+
: buttonStatus, sx: { width: "100%" }, children: "Confirm" }) })] }) }) }));
|
|
275
278
|
});
|
|
276
279
|
SendExternalToken.displayName = "SendExternalToken";
|
|
277
280
|
exports.default = SendExternalToken;
|
|
@@ -591,6 +591,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
591
591
|
to_address: recipientAddress || "",
|
|
592
592
|
network: selectedNetwork,
|
|
593
593
|
memo: memo || "",
|
|
594
|
+
network_address: (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.address) || "",
|
|
594
595
|
}, onSuccess: close, children: (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, status: !!amountError ||
|
|
595
596
|
!!recipientAddressError ||
|
|
596
597
|
!recipientAddress ||
|
package/dist/index.js
CHANGED