tek-wallet 0.0.438 → 0.0.439
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.
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
+
};
|
|
3
14
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
15
|
if (k2 === undefined) k2 = k;
|
|
5
16
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -48,8 +59,10 @@ var SwiperControlled_1 = __importDefault(require("../SwiperControlled"));
|
|
|
48
59
|
var useActivities_1 = __importDefault(require("../../../hooks/useActivities"));
|
|
49
60
|
var material_1 = require("@mui/material");
|
|
50
61
|
var react_2 = require("swiper/react");
|
|
51
|
-
var Text_1 = __importDefault(require("../Text"));
|
|
52
62
|
var ActivityItem_1 = __importDefault(require("../ActivityItem"));
|
|
63
|
+
var EmptyData_1 = __importDefault(require("../EmptyData"));
|
|
64
|
+
var getIcon_1 = __importDefault(require("../../../utils/getIcon"));
|
|
65
|
+
var prefix = "activities_";
|
|
53
66
|
var Activities = (0, react_1.forwardRef)(function (props, ref) {
|
|
54
67
|
var drawerRef = (0, react_1.useRef)(null);
|
|
55
68
|
var theme = (0, material_1.useTheme)();
|
|
@@ -96,14 +109,14 @@ var Activities = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
96
109
|
flex: 1,
|
|
97
110
|
}, children: activityTypes === null || activityTypes === void 0 ? void 0 : activityTypes.map(function (type, index) {
|
|
98
111
|
var activitiesByType = activities === null || activities === void 0 ? void 0 : activities[type.slug];
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
112
|
+
var isEmpty = !(activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.length);
|
|
113
|
+
return ((0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: [isEmpty && ((0, jsx_runtime_1.jsx)(EmptyData_1.default, { icon: (0, getIcon_1.default)(prefix + "empty_" + type.slug), title: "No ".concat(type.name, " activities") })), !isEmpty &&
|
|
114
|
+
(activitiesByType === null || activitiesByType === void 0 ? void 0 : activitiesByType.map(function (activity, index) {
|
|
115
|
+
if (!activity)
|
|
116
|
+
return null;
|
|
117
|
+
var dataAsJson = JSON.stringify(activity);
|
|
118
|
+
return (0, jsx_runtime_1.jsx)(ActivityItem_1.default, { data: dataAsJson }, index);
|
|
119
|
+
}))] }) }, index));
|
|
107
120
|
}) }) }) }) }) }));
|
|
108
121
|
});
|
|
109
122
|
Activities.displayName = "Activities";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
interface ActivityItemProps extends
|
|
1
|
+
import { ListItemButtonProps } from "@mui/material";
|
|
2
|
+
interface ActivityItemProps extends ListItemButtonProps {
|
|
3
3
|
data?: string;
|
|
4
4
|
}
|
|
5
5
|
declare function ActivityItem(props: ActivityItemProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -34,6 +34,7 @@ var Icon_1 = __importDefault(require("../Icon"));
|
|
|
34
34
|
var Text_1 = __importDefault(require("../Text"));
|
|
35
35
|
var Formatter_1 = __importDefault(require("../Formatter"));
|
|
36
36
|
var formatDate_1 = __importDefault(require("../../../utils/formatDate"));
|
|
37
|
+
var compactWalletAddress_1 = __importDefault(require("../../../utils/compactWalletAddress"));
|
|
37
38
|
function ActivityItem(props) {
|
|
38
39
|
var sx = props.sx, data = props.data, rest = __rest(props, ["sx", "data"]);
|
|
39
40
|
var theme = (0, material_1.useTheme)();
|
|
@@ -44,6 +45,20 @@ function ActivityItem(props) {
|
|
|
44
45
|
}, [data]);
|
|
45
46
|
var type = activityData === null || activityData === void 0 ? void 0 : activityData.transaction_type;
|
|
46
47
|
var status = activityData === null || activityData === void 0 ? void 0 : activityData.transaction_status;
|
|
48
|
+
var isIncrease = (0, react_1.useMemo)(function () {
|
|
49
|
+
return type === type_1.TransactionSlug.Deposit;
|
|
50
|
+
}, [type]);
|
|
51
|
+
var descriptionElement = (0, react_1.useMemo)(function () {
|
|
52
|
+
var isReceive = type === type_1.TransactionSlug.Receive || type === type_1.TransactionSlug.Deposit;
|
|
53
|
+
if (isReceive) {
|
|
54
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["From: ", (0, compactWalletAddress_1.default)(activityData === null || activityData === void 0 ? void 0 : activityData.from_address)] });
|
|
55
|
+
}
|
|
56
|
+
var isSend = type === type_1.TransactionSlug.Send || type === type_1.TransactionSlug.Withdrawn;
|
|
57
|
+
if (isSend) {
|
|
58
|
+
return (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: ["To: ", (0, compactWalletAddress_1.default)(activityData === null || activityData === void 0 ? void 0 : activityData.to_address)] });
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}, [status]);
|
|
47
62
|
var getStatusColor = (0, react_1.useCallback)(function () {
|
|
48
63
|
switch (status) {
|
|
49
64
|
case type_1.TransactionStatus.Processing:
|
|
@@ -57,20 +72,19 @@ function ActivityItem(props) {
|
|
|
57
72
|
}
|
|
58
73
|
}, [status, theme]);
|
|
59
74
|
var getAmountColor = (0, react_1.useCallback)(function () {
|
|
60
|
-
var isIncrease = type === type_1.TransactionSlug.Deposit;
|
|
61
75
|
if (isIncrease)
|
|
62
76
|
return theme.palette.text.successStatus;
|
|
63
77
|
return theme.palette.text.white;
|
|
64
|
-
}, [
|
|
78
|
+
}, [isIncrease, theme]);
|
|
65
79
|
if (!activityData)
|
|
66
80
|
return null;
|
|
67
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.
|
|
81
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.ListItemButton, __assign({ sx: __assign(__assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g8, backgroundColor: theme.palette.background.white16, borderRadius: theme.mixins.customRadius.r16, p: theme.mixins.customPadding.p12 }), sx) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
68
82
|
width: "fit-content",
|
|
69
83
|
height: "fit-content",
|
|
70
|
-
}, children: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: activityData.icon, width: 24 }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.activityTitle, children: activityData.transaction_type }), status !== type_1.TransactionStatus.Success && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [status === type_1.TransactionStatus.Processing && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "secondary", size: 16 })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
84
|
+
}, children: (0, jsx_runtime_1.jsx)(Icon_1.default, { src: activityData.icon, width: 24 }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.activityTitle, children: activityData.transaction_type }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.activityDescription, children: descriptionElement }), status !== type_1.TransactionStatus.Success && ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g4 }), children: [status === type_1.TransactionStatus.Processing && ((0, jsx_runtime_1.jsx)(material_1.CircularProgress, { color: "secondary", size: 16 })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
71
85
|
fontSize: theme.typography.fontSize12,
|
|
72
86
|
textTransform: "capitalize",
|
|
73
87
|
color: getStatusColor(),
|
|
74
|
-
}, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", ml: "auto" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { color: getAmountColor() }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: activityData.amount, unit: activityData.currency_slug }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.valueDescription, children: (0, formatDate_1.default)(activityData.date_created) })] })] })));
|
|
88
|
+
}, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", alignItems: "flex-end", ml: "auto" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, color: getAmountColor(), textAlign: "right" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: isIncrease ? "+" : "-", value: activityData.amount, unit: activityData.currency_slug }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.valueDescription), { textAlign: "right" }), children: (0, formatDate_1.default)(activityData.date_created) })] })] })));
|
|
75
89
|
}
|
|
76
90
|
exports.default = ActivityItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function compactWalletAddress(walletAddress?: string, isLinkAff?: boolean): string | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = compactWalletAddress;
|
|
4
|
+
function compactWalletAddress(walletAddress, isLinkAff) {
|
|
5
|
+
try {
|
|
6
|
+
if (!walletAddress)
|
|
7
|
+
return undefined;
|
|
8
|
+
if ((walletAddress === null || walletAddress === void 0 ? void 0 : walletAddress.length) <= 8) {
|
|
9
|
+
return walletAddress;
|
|
10
|
+
}
|
|
11
|
+
return ((walletAddress === null || walletAddress === void 0 ? void 0 : walletAddress.slice(0, !isLinkAff ? 3 : 15)) +
|
|
12
|
+
"..." +
|
|
13
|
+
(walletAddress === null || walletAddress === void 0 ? void 0 : walletAddress.slice(!isLinkAff ? -3 : -10)));
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
console.error("🚀 ~ compactWalletAddress ~ err:", err);
|
|
17
|
+
return walletAddress;
|
|
18
|
+
}
|
|
19
|
+
}
|