tek-wallet 0.0.573 → 0.0.575

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.
@@ -24,10 +24,11 @@ var Formatter_1 = __importDefault(require("../Formatter"));
24
24
  var Text_1 = __importDefault(require("../Text"));
25
25
  var formatDate_1 = __importDefault(require("../../../utils/formatDate"));
26
26
  var CopyTextComponent_1 = __importDefault(require("../CopyTextComponent"));
27
+ var useWalletData_1 = __importDefault(require("../../../hooks/useWalletData"));
27
28
  function ActivityDetail(props) {
28
- var _a, _b;
29
29
  var theme = (0, material_1.useTheme)();
30
30
  var activityData = props.activityData;
31
+ var masterWallet = (0, useWalletData_1.default)().masterWallet;
31
32
  var status = activityData === null || activityData === void 0 ? void 0 : activityData.transaction_status;
32
33
  var type = (0, react_2.useMemo)(function () {
33
34
  return activityData === null || activityData === void 0 ? void 0 : activityData.transaction_type;
@@ -41,9 +42,20 @@ function ActivityDetail(props) {
41
42
  var isReceive = (0, react_2.useMemo)(function () {
42
43
  return slug === type_1.TransactionSlug.Receive || slug === type_1.TransactionSlug.Deposit;
43
44
  }, [slug]);
44
- var isSend = (0, react_2.useMemo)(function () {
45
- return (slug === type_1.TransactionSlug.Send || slug === type_1.TransactionSlug.Withdrawn || slug === type_1.TransactionSlug.TransferInternal);
45
+ var isSwap = (0, react_2.useMemo)(function () {
46
+ return slug === type_1.TransactionSlug.Swap;
46
47
  }, [slug]);
48
+ var currency = (0, react_2.useMemo)(function () {
49
+ return activityData === null || activityData === void 0 ? void 0 : activityData.currency_data;
50
+ }, [activityData]);
51
+ var swapToCurrency = (0, react_2.useMemo)(function () {
52
+ return activityData === null || activityData === void 0 ? void 0 : activityData.to_currency_data;
53
+ }, [activityData]);
54
+ var toAddress = (0, react_2.useMemo)(function () {
55
+ if (isSwap)
56
+ return masterWallet;
57
+ return activityData === null || activityData === void 0 ? void 0 : activityData.to_address;
58
+ }, [activityData, isSwap, masterWallet]);
47
59
  var getStatusColor = (0, react_1.useCallback)(function () {
48
60
  switch (status) {
49
61
  case type_1.TransactionStatus.Processing:
@@ -63,10 +75,13 @@ function ActivityDetail(props) {
63
75
  }, [isIncrease, theme]);
64
76
  if (!activityData)
65
77
  return null;
66
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g16, alignItems: "center" }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: (_a = activityData.currency_data) === null || _a === void 0 ? void 0 : _a.link, width: 64 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g4, alignItems: "center" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, fontSize: theme.typography.fontSize24, color: getAmountColor() }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: isIncrease ? "+" : "-", value: activityData.amount, unit: " ".concat((_b = activityData.currency_data) === null || _b === void 0 ? void 0 : _b.name) }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: (0, formatDate_1.default)(activityData.date_created) }), 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: {
78
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g16, alignItems: "center" }), children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: "-0.5rem" }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { src: currency === null || currency === void 0 ? void 0 : currency.link, width: 64, sx: {
79
+ borderRadius: theme.mixins.customRadius.full,
80
+ border: "2px white solid",
81
+ } }), (swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.link) && ((0, jsx_runtime_1.jsx)(Icon_1.default, { src: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.link, width: 64, sx: { borderRadius: theme.mixins.customRadius.full, border: "2px white solid" } }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { width: "fit-content", gap: theme.mixins.gaps.g4, alignItems: "center" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, fontSize: theme.typography.fontSize24, color: getAmountColor(), opacity: isSwap ? 0.5 : 1 }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: isIncrease ? "+" : "-", value: activityData.amount, unit: " ".concat(currency === null || currency === void 0 ? void 0 : currency.name) }) }), isSwap && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, fontSize: theme.typography.fontSize24, color: theme.palette.text.successStatus }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: "+", value: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.swap_total_amount, unit: " ".concat(swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.name) }) })), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: (0, formatDate_1.default)(activityData.date_created) }), 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: {
67
82
  fontSize: theme.typography.fontSize12,
68
83
  textTransform: "capitalize",
69
84
  color: getStatusColor(),
70
- }, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.paper), { p: theme.mixins.gaps.g12, width: "100%" }), children: [isReceive && ((0, jsx_runtime_1.jsx)(CopyTextComponent_1.default, { value: activityData === null || activityData === void 0 ? void 0 : activityData.from_address, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: "From" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { wordBreak: "break-all", textAlign: "left" }), children: activityData === null || activityData === void 0 ? void 0 : activityData.from_address })] }) })), isSend && ((0, jsx_runtime_1.jsx)(CopyTextComponent_1.default, { value: activityData === null || activityData === void 0 ? void 0 : activityData.to_address, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: "To" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { wordBreak: "break-all", textAlign: "left" }), children: activityData === null || activityData === void 0 ? void 0 : activityData.to_address })] }) }))] })] }));
85
+ }, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.paper), { p: theme.mixins.gaps.g12, width: "100%" }), children: [isReceive && ((0, jsx_runtime_1.jsx)(CopyTextComponent_1.default, { value: activityData === null || activityData === void 0 ? void 0 : activityData.from_address, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: "From" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { wordBreak: "break-all", textAlign: "left" }), children: activityData === null || activityData === void 0 ? void 0 : activityData.from_address })] }) })), !!toAddress && ((0, jsx_runtime_1.jsx)(CopyTextComponent_1.default, { value: toAddress, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g4 }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: "Recipient address" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { wordBreak: "break-all", textAlign: "left" }), children: toAddress })] }) }))] })] }));
71
86
  }
72
87
  exports.default = ActivityDetail;
@@ -36,7 +36,6 @@ var Formatter_1 = __importDefault(require("../Formatter"));
36
36
  var formatDate_1 = __importDefault(require("../../../utils/formatDate"));
37
37
  var compactWalletAddress_1 = __importDefault(require("../../../utils/compactWalletAddress"));
38
38
  function ActivityItem(props) {
39
- var _a;
40
39
  var sx = props.sx, data = props.data, rest = __rest(props, ["sx", "data"]);
41
40
  var theme = (0, material_1.useTheme)();
42
41
  var activityData = (0, react_1.useMemo)(function () {
@@ -54,6 +53,12 @@ function ActivityItem(props) {
54
53
  var isIncrease = (0, react_1.useMemo)(function () {
55
54
  return slug === type_1.TransactionSlug.Deposit;
56
55
  }, [slug]);
56
+ var currency = (0, react_1.useMemo)(function () {
57
+ return activityData === null || activityData === void 0 ? void 0 : activityData.currency_data;
58
+ }, [activityData]);
59
+ var swapToCurrency = (0, react_1.useMemo)(function () {
60
+ return activityData === null || activityData === void 0 ? void 0 : activityData.to_currency_data;
61
+ }, [activityData]);
57
62
  var descriptionElement = (0, react_1.useMemo)(function () {
58
63
  var isReceive = slug === type_1.TransactionSlug.Receive || slug === type_1.TransactionSlug.Deposit;
59
64
  if (isReceive) {
@@ -91,6 +96,6 @@ function ActivityItem(props) {
91
96
  fontSize: theme.typography.fontSize12,
92
97
  textTransform: "capitalize",
93
98
  color: getStatusColor(),
94
- }, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g2, 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: " ".concat((_a = activityData.currency_data) === null || _a === void 0 ? void 0 : _a.name) }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.valueDescription), { textAlign: "right" }), children: (0, formatDate_1.default)(activityData.date_created) })] })] })));
99
+ }, children: status })] }))] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g2, width: "fit-content", alignItems: "flex-end", ml: "auto" }), children: [slug === type_1.TransactionSlug.Swap && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { fontWeight: theme.typography.fontWeightBold, color: theme.palette.text.successStatus, textAlign: "right" }), children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { start: "+", value: swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.swap_total_amount, unit: " ".concat(swapToCurrency === null || swapToCurrency === void 0 ? void 0 : swapToCurrency.name) }) })), (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: " ".concat(currency === null || currency === void 0 ? void 0 : currency.name) }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.valueDescription), { textAlign: "right" }), children: (0, formatDate_1.default)(activityData.date_created) })] })] })));
95
100
  }
96
101
  exports.default = ActivityItem;
@@ -46,7 +46,7 @@ var useEventHandler = function () {
46
46
  }
47
47
  }, [updateActivities, updateWalletDetail, updateWithdrawToken, updateSendInternalToken]);
48
48
  var handler = function (messageEvent, showActivities) {
49
- var _a, _b;
49
+ var _a, _b, _c;
50
50
  if (!messageEvent)
51
51
  return undefined;
52
52
  var type = messageEvent.transaction_type;
@@ -73,7 +73,7 @@ var useEventHandler = function () {
73
73
  case type_1.TransactionSlug.Swap:
74
74
  var toCurrency = (_b = messageEvent.to_currency_data) === null || _b === void 0 ? void 0 : _b.name;
75
75
  console.warn("🚀 ~ useEventHandler ~ toCurrency:", toCurrency);
76
- var toAmount = messageEvent.to_amount;
76
+ var toAmount = (_c = messageEvent.to_currency_data) === null || _c === void 0 ? void 0 : _c.swap_total_amount;
77
77
  notificationMessage = ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: { textTransform: "capitalize" }, children: type === null || type === void 0 ? void 0 : type.name }), " ", (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: amount, unit: " ".concat(currency) }), " to ", (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: toAmount, unit: " ".concat(toCurrency) }), " ", "is ", status] }));
78
78
  break;
79
79
  default:
@@ -118,7 +118,7 @@ function LockTokensProvider(_a) {
118
118
  });
119
119
  }); }, [isAuthenticated, isLoadingLockToken]);
120
120
  (0, react_1.useEffect)(function () {
121
- if (!!lockTokens)
121
+ if (!!lockTokens || !isAuthenticated)
122
122
  return;
123
123
  updateLockToken();
124
124
  }, [isAuthenticated, lockTokens]);
@@ -1,4 +1,4 @@
1
- import { Paginated, Currency } from "../type";
1
+ import { Paginated, Currency, NetworkData } from "../type";
2
2
  export interface GetActivitiesServiceQuery {
3
3
  page?: number;
4
4
  take?: number;
@@ -36,9 +36,29 @@ export interface Transaction {
36
36
  from_locked_balance: null;
37
37
  to_locked_balance: null;
38
38
  currency_data: Currency;
39
- to_currency_data?: Currency;
39
+ to_currency_data?: ToCurrencyData;
40
40
  to_amount?: string;
41
41
  }
42
+ export interface ToCurrencyData {
43
+ address: string;
44
+ decimal: number;
45
+ full_name: string;
46
+ icon: string;
47
+ icon_svg: string;
48
+ id: number;
49
+ is_crypto_token: boolean;
50
+ is_native_token: boolean;
51
+ name: string;
52
+ network: number;
53
+ network_data: NetworkData;
54
+ root_project: null;
55
+ slug: string;
56
+ status: string;
57
+ swap_amount: number;
58
+ usd_rate: string;
59
+ swap_total_amount: number;
60
+ link: string;
61
+ }
42
62
  export interface TransactionType {
43
63
  id: number;
44
64
  status: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.573",
3
+ "version": "0.0.575",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",