tek-wallet 0.0.754 → 0.0.756

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.
Files changed (63) hide show
  1. package/README.md +83 -32
  2. package/dist/components/TekWallet/components/ui/ActivitiesTypeSlice/index.d.ts +3 -0
  3. package/dist/components/TekWallet/components/ui/ActivitiesTypeSlice/index.js +7 -7
  4. package/dist/components/TekWallet/components/ui/ActivityDetail/index.js +5 -5
  5. package/dist/components/TekWallet/components/ui/ActivityItem/index.js +9 -4
  6. package/dist/components/TekWallet/components/ui/AmountGroupAndChart/index.js +103 -101
  7. package/dist/components/TekWallet/components/ui/AnalyticGroup/index.d.ts +2 -1
  8. package/dist/components/TekWallet/components/ui/AnalyticGroup/index.js +47 -32
  9. package/dist/components/TekWallet/components/ui/FiatDeposit/index.js +5 -3
  10. package/dist/components/TekWallet/components/ui/HistorySwap/index.js +1 -2
  11. package/dist/components/TekWallet/components/ui/NeonLineChart/index.d.ts +6 -5
  12. package/dist/components/TekWallet/components/ui/NeonLineChart/index.js +2 -2
  13. package/dist/components/TekWallet/components/ui/ReceiveHistory/index.js +1 -2
  14. package/dist/components/TekWallet/components/ui/SmartList/index.d.ts +0 -1
  15. package/dist/components/TekWallet/components/ui/SmartList/index.js +5 -4
  16. package/dist/components/TekWallet/components/ui/SvgPath/index.d.ts +1 -0
  17. package/dist/components/TekWallet/components/ui/SvgPath/index.js +3 -2
  18. package/dist/components/TekWallet/components/ui/SwapToken/index.js +0 -5
  19. package/dist/components/TekWallet/components/ui/SwapToken copy/index.d.ts +32 -0
  20. package/dist/components/TekWallet/components/ui/SwapToken copy/index.js +293 -0
  21. package/dist/components/TekWallet/components/ui/SwiperControlled/index.js +5 -1
  22. package/dist/components/TekWallet/components/ui/TimeFilter/index.d.ts +4 -3
  23. package/dist/components/TekWallet/components/ui/TimeFilter/index.js +27 -30
  24. package/dist/components/TekWallet/components/ui/TokenItem/index.js +11 -6
  25. package/dist/components/TekWallet/components/ui/TokensBoard/index.js +1 -3
  26. package/dist/components/TekWallet/components/views/ActivityView/index.d.ts +10 -0
  27. package/dist/components/TekWallet/components/views/ActivityView/index.js +64 -0
  28. package/dist/components/TekWallet/components/views/AssetView/index.js +69 -6
  29. package/dist/components/TekWallet/components/views/TekWalletView/index.js +1 -1
  30. package/dist/components/TekWallet/components/views/TekWalletView/routes.d.ts +5 -4
  31. package/dist/components/TekWallet/components/views/TekWalletView/routes.js +11 -5
  32. package/dist/components/TekWallet/const/app.config.d.ts +1 -0
  33. package/dist/components/TekWallet/const/app.config.js +4 -0
  34. package/dist/components/TekWallet/index.d.ts +1 -1
  35. package/dist/components/TekWallet/index.js +1 -1
  36. package/dist/components/TekWallet/providers/ActivitiesProvider/const.d.ts +1 -1
  37. package/dist/components/TekWallet/providers/ActivitiesProvider/const.js +1 -1
  38. package/dist/components/TekWallet/providers/ActivitiesProvider/functions/sortActivity.d.ts +3 -0
  39. package/dist/components/TekWallet/providers/ActivitiesProvider/functions/sortActivity.js +8 -0
  40. package/dist/components/TekWallet/providers/ActivitiesProvider/index.js +55 -51
  41. package/dist/components/TekWallet/providers/ActivitiesProvider/type.d.ts +1 -1
  42. package/dist/components/TekWallet/providers/WalletDataProvider/index.js +2 -0
  43. package/dist/components/TekWallet/providers/WalletDataProviderNoImport/index.js +41 -6
  44. package/dist/components/TekWallet/services/axios/get-activities-service/index.js +0 -3
  45. package/dist/components/TekWallet/services/axios/get-activities-service/type.d.ts +4 -4
  46. package/dist/components/TekWallet/services/axios/get-balance-analytic/index.d.ts +3 -0
  47. package/dist/components/TekWallet/services/axios/get-balance-analytic/index.js +56 -0
  48. package/dist/components/TekWallet/services/axios/get-balance-analytic/type.d.ts +18 -0
  49. package/dist/components/TekWallet/services/axios/get-balance-analytic/type.js +2 -0
  50. package/dist/components/TekWallet/store/balance/index.d.ts +15 -0
  51. package/dist/components/TekWallet/store/balance/index.js +24 -0
  52. package/dist/components/TekWallet/store/balance/type.d.ts +9 -0
  53. package/dist/components/TekWallet/store/balance/type.js +2 -0
  54. package/dist/components/TekWallet/store/createStorage.d.ts +3 -0
  55. package/dist/components/TekWallet/store/createStorage.js +17 -0
  56. package/dist/components/TekWallet/store/user/index.d.ts +15 -0
  57. package/dist/components/TekWallet/store/user/index.js +52 -0
  58. package/dist/components/TekWallet/store/user/type.d.ts +38 -0
  59. package/dist/components/TekWallet/store/user/type.js +9 -0
  60. package/dist/components/TekWallet/types/expose-type.d.ts +3 -0
  61. package/package.json +3 -2
  62. package/dist/components/TekWallet/components/ui/Activities/index.d.ts +0 -12
  63. package/dist/components/TekWallet/components/ui/Activities/index.js +0 -117
@@ -11,6 +11,50 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  return __assign.apply(this, arguments);
13
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 __rest = (this && this.__rest) || function (s, e) {
48
+ var t = {};
49
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50
+ t[p] = s[p];
51
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
52
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
53
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
54
+ t[p[i]] = s[p[i]];
55
+ }
56
+ return t;
57
+ };
14
58
  var __importDefault = (this && this.__importDefault) || function (mod) {
15
59
  return (mod && mod.__esModule) ? mod : { "default": mod };
16
60
  };
@@ -28,20 +72,22 @@ var AmountGroupAndChart_1 = __importDefault(require("../../ui/AmountGroupAndChar
28
72
  var link_1 = __importDefault(require("next/link"));
29
73
  var react_1 = require("react");
30
74
  var TekWalletProvider_1 = require("../../../providers/TekWalletProvider");
31
- var ReceiveFunction_1 = __importDefault(require("../../ui/ReceiveFunction"));
75
+ var ReceiveFunction_1 = __importStar(require("../../ui/ReceiveFunction"));
32
76
  var ChildPageLayout_1 = __importDefault(require("../../layouts/ChildPageLayout"));
33
77
  var Menu_1 = __importDefault(require("./Menu"));
78
+ var ActivitiesTypeSlice_1 = __importDefault(require("../../ui/ActivitiesTypeSlice"));
79
+ var const_1 = require("../../../providers/ActivitiesProvider/const");
80
+ var Icon_1 = __importDefault(require("../../ui/Icon"));
34
81
  var AssetView = function (props) {
82
+ var sx = props.sx, rest = __rest(props, ["sx"]);
35
83
  var isInitPasscode = (0, useWalletData_1.default)().isInitPasscode;
36
84
  var theme = (0, ThemeProvider_1.useTheme)();
37
85
  var options = (0, TekWalletProvider_1.useWalletConfig)().options;
38
86
  var basePath = (0, react_1.useMemo)(function () {
39
87
  return (options === null || options === void 0 ? void 0 : options.basePath) || "";
40
88
  }, [options]);
41
- return ((0, jsx_runtime_1.jsxs)(ChildPageLayout_1.default, { children: [!isInitPasscode && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.sessionDescription), children: "Please connect your wallet to get asset information" })), !!isInitPasscode && ((0, jsx_runtime_1.jsxs)(DefaultPageLayout_1.default, __assign({}, props, { children: [(0, jsx_runtime_1.jsx)(AmountGroupAndChart_1.default, {}), (0, jsx_runtime_1.jsx)(Menu_1.default, { sx: {
42
- mb: theme.mixins.customMargin.m20,
43
- }, items: [
44
- (0, jsx_runtime_1.jsx)(ReceiveFunction_1.default, { children: (0, jsx_runtime_1.jsx)(material_1.ListItem, { sx: {
89
+ return ((0, jsx_runtime_1.jsxs)(ChildPageLayout_1.default, { children: [!isInitPasscode && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.sessionDescription), children: "Please connect your wallet to get asset information" })), !!isInitPasscode && ((0, jsx_runtime_1.jsxs)(DefaultPageLayout_1.default, __assign({}, rest, { sx: __assign({ display: "flex", flexDirection: "column", gap: theme.mixins.gaps.g20 }, sx), children: [(0, jsx_runtime_1.jsx)(AmountGroupAndChart_1.default, {}), (0, jsx_runtime_1.jsx)(Menu_1.default, { items: [
90
+ (0, jsx_runtime_1.jsx)(ReceiveFunction_1.default, { functionsList: Object.values(ReceiveFunction_1.ReceiveMethods), children: (0, jsx_runtime_1.jsx)(material_1.ListItem, { sx: {
45
91
  borderRight: "1px solid ".concat(theme.palette.border.accent3),
46
92
  placeContent: "center",
47
93
  columnSpan: 1,
@@ -62,7 +108,24 @@ var AssetView = function (props) {
62
108
  placeContent: "center",
63
109
  columnSpan: 1,
64
110
  }, children: (0, jsx_runtime_1.jsx)(FunctionItem_1.default, { icon: "IC_SWAP_FC", label: "Swap", sx: { width: "100%" } }) }) }, "swap"),
65
- ] }), (0, jsx_runtime_1.jsx)(TokensBoard_1.default, {})] })))] }));
111
+ ] }), (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: {
112
+ display: "flex",
113
+ gap: theme.mixins.gaps.g20,
114
+ }, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.sessionTitle), children: "Activity" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: link_1.default, href: "".concat(basePath, "/tek-wallet/activity"), sx: {
115
+ marginLeft: "auto",
116
+ display: "flex",
117
+ alignItems: "center",
118
+ }, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
119
+ fontSize: theme.typography.fontSize13,
120
+ fontWeight: theme.typography.fontWeight400,
121
+ color: theme.palette.text.black,
122
+ cursor: "pointer",
123
+ }, children: "View all" }), (0, jsx_runtime_1.jsx)(Icon_1.default, { iconKey: "IC_ARROW_RIGHT", width: 18, height: 18 })] })] }), (0, jsx_runtime_1.jsx)(ActivitiesTypeSlice_1.default, { type: const_1.ACTIVITIES_TYPE_ALL, limitItems: 4, isActive: true, sx: {
124
+ paddingBottom: 0,
125
+ paddingTop: 0,
126
+ paddingLeft: 0,
127
+ paddingRight: 0,
128
+ } })] }), (0, jsx_runtime_1.jsx)(TokensBoard_1.default, {})] })))] }));
66
129
  };
67
130
  exports.AssetView = AssetView;
68
131
  exports.default = exports.AssetView;
@@ -11,6 +11,6 @@ function TekWalletView() {
11
11
  var pathnameArray = (0, react_1.useMemo)(function () { return (typeof pathname === "string" ? [pathname] : pathname); }, [pathname]);
12
12
  var pathnameFull = (0, react_1.useMemo)(function () { return pathnameArray === null || pathnameArray === void 0 ? void 0 : pathnameArray.join("/"); }, [pathnameArray]);
13
13
  console.warn("🚀 ~ TekWalletView ~ pathnameFull:", pathname, pathnameFull);
14
- var View = (0, react_1.useMemo)(function () { return (pathname === undefined ? (0, routes_1.getView)("/") : (0, routes_1.getView)(pathnameFull || "")); }, [pathnameFull, pathname]);
14
+ var View = (0, react_1.useMemo)(function () { return (pathname === undefined ? (0, routes_1.getView)("/") : (0, routes_1.getView)("/".concat(pathnameFull))); }, [pathnameFull, pathname]);
15
15
  return (0, jsx_runtime_1.jsx)(View, {});
16
16
  }
@@ -1,9 +1,10 @@
1
1
  import { ComponentType } from "react";
2
2
  export declare enum TekWalletViewRoutes {
3
- SEND_INTERNAL = "send/internal",
4
- SEND_EXTERNAL = "send/external",
5
- SWAP = "swap",
3
+ SEND_INTERNAL = "/send/internal",
4
+ SEND_EXTERNAL = "/send/external",
5
+ SWAP = "/swap",
6
6
  ASSET = "/",
7
- NOT_FOUND = "not-found"
7
+ NOT_FOUND = "/not-found",
8
+ ACTIVITY = "/activity"
8
9
  }
9
10
  export declare const getView: (path: string) => ComponentType;
@@ -40,11 +40,12 @@ exports.getView = exports.TekWalletViewRoutes = void 0;
40
40
  var dynamic_1 = __importDefault(require("next/dynamic"));
41
41
  var TekWalletViewRoutes;
42
42
  (function (TekWalletViewRoutes) {
43
- TekWalletViewRoutes["SEND_INTERNAL"] = "send/internal";
44
- TekWalletViewRoutes["SEND_EXTERNAL"] = "send/external";
45
- TekWalletViewRoutes["SWAP"] = "swap";
43
+ TekWalletViewRoutes["SEND_INTERNAL"] = "/send/internal";
44
+ TekWalletViewRoutes["SEND_EXTERNAL"] = "/send/external";
45
+ TekWalletViewRoutes["SWAP"] = "/swap";
46
46
  TekWalletViewRoutes["ASSET"] = "/";
47
- TekWalletViewRoutes["NOT_FOUND"] = "not-found";
47
+ TekWalletViewRoutes["NOT_FOUND"] = "/not-found";
48
+ TekWalletViewRoutes["ACTIVITY"] = "/activity";
48
49
  })(TekWalletViewRoutes || (exports.TekWalletViewRoutes = TekWalletViewRoutes = {}));
49
50
  var getView = function (path) {
50
51
  if (path.startsWith(TekWalletViewRoutes.SEND_INTERNAL)) {
@@ -62,11 +63,16 @@ var getView = function (path) {
62
63
  ssr: false,
63
64
  });
64
65
  }
65
- if (path.startsWith(TekWalletViewRoutes.ASSET)) {
66
+ if (path === TekWalletViewRoutes.ASSET) {
66
67
  return (0, dynamic_1.default)(function () { return Promise.resolve().then(function () { return __importStar(require("../AssetView")); }); }, {
67
68
  ssr: false,
68
69
  });
69
70
  }
71
+ if (path.startsWith(TekWalletViewRoutes.ACTIVITY)) {
72
+ return (0, dynamic_1.default)(function () { return Promise.resolve().then(function () { return __importStar(require("../ActivityView")); }); }, {
73
+ ssr: false,
74
+ });
75
+ }
70
76
  return (0, dynamic_1.default)(function () { return Promise.resolve().then(function () { return __importStar(require("../NotFoundView")); }); }, {
71
77
  ssr: false,
72
78
  });
@@ -0,0 +1 @@
1
+ export declare const APP_NAME = "TekWallet";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APP_NAME = void 0;
4
+ exports.APP_NAME = "TekWallet";
@@ -5,7 +5,7 @@ export * from "./components/ui/ReceiveFunction";
5
5
  export * from "./components/ui/LockToken";
6
6
  export * from "./components/views/AssetView";
7
7
  export * from "./hooks/useWallet";
8
- export * from "./components/ui/Activities";
8
+ export * from "./components/views/ActivityView";
9
9
  export * from "./components/ui/SwapToken";
10
10
  export * from "./components/ui/TransferInternal";
11
11
  export * from "./components/ui/WithdrawFunction";
@@ -21,7 +21,7 @@ __exportStar(require("./components/ui/ReceiveFunction"), exports);
21
21
  __exportStar(require("./components/ui/LockToken"), exports);
22
22
  __exportStar(require("./components/views/AssetView"), exports);
23
23
  __exportStar(require("./hooks/useWallet"), exports);
24
- __exportStar(require("./components/ui/Activities"), exports);
24
+ __exportStar(require("./components/views/ActivityView"), exports);
25
25
  __exportStar(require("./components/ui/SwapToken"), exports);
26
26
  __exportStar(require("./components/ui/TransferInternal"), exports);
27
27
  __exportStar(require("./components/ui/WithdrawFunction"), exports);
@@ -1,3 +1,3 @@
1
1
  import { TransactionType } from "../../services/axios/get-activities-service/type";
2
- export declare const ACTIVITIES_PAGE_SIZE = 10;
2
+ export declare const ACTIVITIES_PAGE_SIZE = 4;
3
3
  export declare const ACTIVITIES_TYPE_ALL: TransactionType;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ACTIVITIES_TYPE_ALL = exports.ACTIVITIES_PAGE_SIZE = void 0;
4
4
  var type_1 = require("../../services/axios/get-activities-service/type");
5
- exports.ACTIVITIES_PAGE_SIZE = 10;
5
+ exports.ACTIVITIES_PAGE_SIZE = 4;
6
6
  exports.ACTIVITIES_TYPE_ALL = {
7
7
  id: -1,
8
8
  status: "all",
@@ -0,0 +1,3 @@
1
+ import { Transaction } from "../../../services/axios/get-activities-service/type";
2
+ declare function sortActivity(activities: Transaction[]): Transaction[];
3
+ export default sortActivity;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function sortActivity(activities) {
4
+ return activities.sort(function (a, b) {
5
+ return new Date(b.date_created).getTime() - new Date(a.date_created).getTime();
6
+ });
7
+ }
8
+ exports.default = sortActivity;
@@ -98,9 +98,9 @@ exports.ActivitiesProvider = ActivitiesProvider;
98
98
  var jsx_runtime_1 = require("react/jsx-runtime");
99
99
  var react_1 = __importStar(require("react"));
100
100
  var useWalletData_1 = __importDefault(require("../../hooks/useWalletData"));
101
- var type_1 = require("./type");
102
101
  var get_activities_service_1 = __importDefault(require("../../services/axios/get-activities-service"));
103
102
  var const_1 = require("./const");
103
+ var sortActivity_1 = __importDefault(require("./functions/sortActivity"));
104
104
  exports.initialActivities = {
105
105
  isLoadingActivities: {},
106
106
  activities: undefined,
@@ -108,7 +108,7 @@ exports.initialActivities = {
108
108
  return [2 /*return*/];
109
109
  }); }); },
110
110
  activityTypes: [const_1.ACTIVITIES_TYPE_ALL],
111
- pages: {},
111
+ loadOutActivityType: {},
112
112
  loadActivities: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
113
113
  return [2 /*return*/];
114
114
  }); }); },
@@ -121,15 +121,21 @@ function ActivitiesProvider(_a) {
121
121
  var _b = (0, react_1.useState)(exports.initialActivities.isLoadingActivities), isLoadingActivities = _b[0], setIsLoadingActivities = _b[1];
122
122
  var _c = react_1.default.useState(exports.initialActivities.activities), activities = _c[0], setActivities = _c[1];
123
123
  var _d = react_1.default.useState(exports.initialActivities.activityTypes), activityTypes = _d[0], setActivityTypes = _d[1];
124
- var _e = (0, react_1.useState)(exports.initialActivities.pages), pages = _e[0], setPages = _e[1];
124
+ var _e = (0, react_1.useState)(exports.initialActivities.loadOutActivityType), loadOutActivityType = _e[0], setLoadOutActivityType = _e[1];
125
+ var getLatestDateCreated = (0, react_1.useCallback)(function (slug) {
126
+ var _a;
127
+ var currentLastActivity = (_a = activities === null || activities === void 0 ? void 0 : activities[slug]) === null || _a === void 0 ? void 0 : _a.at(-1);
128
+ if (!currentLastActivity)
129
+ return null;
130
+ return currentLastActivity === null || currentLastActivity === void 0 ? void 0 : currentLastActivity.date_created;
131
+ }, [activities]);
125
132
  var updateActivityTypes = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
126
133
  var response, newActivityTypes;
127
134
  var _a, _b;
128
135
  return __generator(this, function (_c) {
129
136
  switch (_c.label) {
130
137
  case 0: return [4 /*yield*/, (0, get_activities_service_1.default)({
131
- page: 1,
132
- take: 1,
138
+ limit: 1,
133
139
  })];
134
140
  case 1:
135
141
  response = _c.sent();
@@ -140,17 +146,17 @@ function ActivitiesProvider(_a) {
140
146
  });
141
147
  }); }, []);
142
148
  var updateActivities = (0, react_1.useCallback)(function (query) { return __awaiter(_this, void 0, void 0, function () {
143
- var slug, response_1, maxPage_1, error_1;
144
- var _a, _b, _c, _d, _e, _f;
145
- return __generator(this, function (_g) {
146
- switch (_g.label) {
149
+ var slug, response_1, loadedActivities_1, error_1;
150
+ var _a, _b, _c;
151
+ return __generator(this, function (_d) {
152
+ switch (_d.label) {
147
153
  case 0:
148
154
  slug = (_a = query === null || query === void 0 ? void 0 : query.transaction_types) !== null && _a !== void 0 ? _a : const_1.ACTIVITIES_TYPE_ALL.slug;
149
- if (pages[slug] === type_1.MAX_PAGE)
155
+ if (loadOutActivityType[slug])
150
156
  return [2 /*return*/];
151
- _g.label = 1;
157
+ _d.label = 1;
152
158
  case 1:
153
- _g.trys.push([1, 3, , 4]);
159
+ _d.trys.push([1, 3, , 4]);
154
160
  if (!isInitPasscode) {
155
161
  throw new Error("Authenticate to get receive tokens");
156
162
  }
@@ -160,26 +166,21 @@ function ActivitiesProvider(_a) {
160
166
  var _a;
161
167
  return (__assign(__assign({}, prev), (_a = {}, _a[slug] = true, _a)));
162
168
  });
163
- return [4 /*yield*/, (0, get_activities_service_1.default)(query)];
169
+ return [4 /*yield*/, (0, get_activities_service_1.default)(__assign({}, query))];
164
170
  case 2:
165
- response_1 = _g.sent();
166
- maxPage_1 = Math.ceil(((_d = (_c = (_b = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _b === void 0 ? void 0 : _b.paginated) === null || _c === void 0 ? void 0 : _c.number_records) !== null && _d !== void 0 ? _d : 0) / const_1.ACTIVITIES_PAGE_SIZE);
167
- setActivityTypes(__spreadArray([const_1.ACTIVITIES_TYPE_ALL], ((_f = (_e = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _e === void 0 ? void 0 : _e.transaction_types) !== null && _f !== void 0 ? _f : []), true));
171
+ response_1 = _d.sent();
172
+ loadedActivities_1 = (_c = (_b = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _b === void 0 ? void 0 : _b.transactions) !== null && _c !== void 0 ? _c : [];
168
173
  setActivities(function (prev) {
169
174
  var _a;
170
- var _b, _c, _d, _e;
171
- var newestActivities = (_d = ((_c = (_b = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _b === void 0 ? void 0 : _b.transactions) !== null && _c !== void 0 ? _c : [])) === null || _d === void 0 ? void 0 : _d.filter(function (activity) {
172
- var _a;
173
- return !((_a = prev === null || prev === void 0 ? void 0 : prev[slug]) === null || _a === void 0 ? void 0 : _a.some(function (prevActivity) { return prevActivity.id === activity.id; }));
175
+ var _b, _c, _d, _e, _f;
176
+ var retainedActivities = (_c = ((_b = prev === null || prev === void 0 ? void 0 : prev[slug]) !== null && _b !== void 0 ? _b : [])) === null || _c === void 0 ? void 0 : _c.filter(function (activity) {
177
+ return !(loadedActivities_1 === null || loadedActivities_1 === void 0 ? void 0 : loadedActivities_1.some(function (item) { return item.id === activity.id; }));
174
178
  });
175
- var newActivities = __spreadArray(__spreadArray([], ((_e = prev === null || prev === void 0 ? void 0 : prev[slug]) !== null && _e !== void 0 ? _e : []), true), newestActivities, true);
176
- var page = Math.floor(newActivities.length / const_1.ACTIVITIES_PAGE_SIZE);
177
- if (page >= maxPage_1) {
178
- page = type_1.MAX_PAGE;
179
- }
180
- setPages(function (prev) {
179
+ var newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], retainedActivities, true), loadedActivities_1, true));
180
+ var isLoadOutActivityType = newActivities.length >= ((_f = (_e = (_d = response_1 === null || response_1 === void 0 ? void 0 : response_1.data) === null || _d === void 0 ? void 0 : _d.paginated) === null || _e === void 0 ? void 0 : _e.number_records) !== null && _f !== void 0 ? _f : 0);
181
+ setLoadOutActivityType(function (prev) {
181
182
  var _a;
182
- return (__assign(__assign({}, prev), (_a = {}, _a[slug] = page, _a)));
183
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = isLoadOutActivityType, _a)));
183
184
  });
184
185
  return __assign(__assign({}, (prev !== null && prev !== void 0 ? prev : {})), (_a = {}, _a[slug] = newActivities, _a));
185
186
  });
@@ -189,7 +190,7 @@ function ActivitiesProvider(_a) {
189
190
  });
190
191
  return [3 /*break*/, 4];
191
192
  case 3:
192
- error_1 = _g.sent();
193
+ error_1 = _d.sent();
193
194
  console.error("🚀 ~ getBalance ~ error:", error_1);
194
195
  setIsLoadingActivities(function (prev) {
195
196
  var _a;
@@ -199,16 +200,16 @@ function ActivitiesProvider(_a) {
199
200
  case 4: return [2 /*return*/];
200
201
  }
201
202
  });
202
- }); }, [isInitPasscode]);
203
+ }); }, [isInitPasscode, isLoadingActivities, loadOutActivityType]);
203
204
  var loadActivities = (0, react_1.useCallback)(function (slug) { return __awaiter(_this, void 0, void 0, function () {
204
- var page, response, activitiesLoaded, exceptedActivities, newActivities, newPage;
205
- var _a, _b, _c, _d;
206
- return __generator(this, function (_e) {
207
- switch (_e.label) {
205
+ var lastDateCreated, response, activitiesLoaded, numOfRecords, retainedActivities, newActivities;
206
+ var _a, _b, _c, _d, _e, _f, _g;
207
+ return __generator(this, function (_h) {
208
+ switch (_h.label) {
208
209
  case 0:
209
210
  if (!isInitPasscode)
210
211
  return [2 /*return*/];
211
- if (pages[slug] === type_1.MAX_PAGE)
212
+ if (loadOutActivityType[slug])
212
213
  return [2 /*return*/];
213
214
  if (isLoadingActivities[slug])
214
215
  return [2 /*return*/];
@@ -216,40 +217,43 @@ function ActivitiesProvider(_a) {
216
217
  var _a;
217
218
  return (__assign(__assign({}, prev), (_a = {}, _a[slug] = true, _a)));
218
219
  });
219
- page = ((_a = pages[slug]) !== null && _a !== void 0 ? _a : 0) + 1;
220
+ lastDateCreated = getLatestDateCreated(slug);
220
221
  return [4 /*yield*/, (0, get_activities_service_1.default)({
221
- page: page,
222
- take: const_1.ACTIVITIES_PAGE_SIZE,
222
+ limit: const_1.ACTIVITIES_PAGE_SIZE,
223
223
  transaction_types: slug,
224
+ last_date_created: lastDateCreated,
224
225
  })];
225
226
  case 1:
226
- response = _e.sent();
227
- activitiesLoaded = (_c = (_b = response === null || response === void 0 ? void 0 : response.data) === null || _b === void 0 ? void 0 : _b.transactions) !== null && _c !== void 0 ? _c : [];
228
- exceptedActivities = (_d = activitiesLoaded === null || activitiesLoaded === void 0 ? void 0 : activitiesLoaded.filter(function (loadedActivity) {
227
+ response = _h.sent();
228
+ setIsLoadingActivities(function (prev) {
229
229
  var _a;
230
- return !((_a = activities === null || activities === void 0 ? void 0 : activities[slug]) === null || _a === void 0 ? void 0 : _a.some(function (activity) { return loadedActivity.id === activity.id; }));
231
- })) !== null && _d !== void 0 ? _d : [];
232
- newActivities = __spreadArray(__spreadArray([], (exceptedActivities !== null && exceptedActivities !== void 0 ? exceptedActivities : []), true), exceptedActivities, true);
233
- newPage = Math.floor(newActivities.length / const_1.ACTIVITIES_PAGE_SIZE);
230
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = false, _a)));
231
+ });
232
+ activitiesLoaded = (_b = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.transactions) !== null && _b !== void 0 ? _b : [];
233
+ numOfRecords = (_e = (_d = (_c = response === null || response === void 0 ? void 0 : response.data) === null || _c === void 0 ? void 0 : _c.paginated) === null || _d === void 0 ? void 0 : _d.number_records) !== null && _e !== void 0 ? _e : 0;
234
+ retainedActivities = (_g = (_f = activities === null || activities === void 0 ? void 0 : activities[slug]) === null || _f === void 0 ? void 0 : _f.filter(function (item) {
235
+ return !(activitiesLoaded === null || activitiesLoaded === void 0 ? void 0 : activitiesLoaded.some(function (activity) { return item.id === activity.id; }));
236
+ })) !== null && _g !== void 0 ? _g : [];
237
+ newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], retainedActivities, true), activitiesLoaded, true));
234
238
  setActivities(function (prev) {
235
239
  var _a;
236
240
  return (__assign(__assign({}, prev), (_a = {}, _a[slug] = newActivities, _a)));
237
241
  });
238
- if (exceptedActivities.length < const_1.ACTIVITIES_PAGE_SIZE) {
239
- setPages(function (prev) {
242
+ if (newActivities.length >= numOfRecords) {
243
+ setLoadOutActivityType(function (prev) {
240
244
  var _a;
241
- return (__assign(__assign({}, prev), (_a = {}, _a[slug] = type_1.MAX_PAGE, _a)));
245
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = true, _a)));
242
246
  });
243
247
  return [2 /*return*/];
244
248
  }
245
- setPages(function (prev) {
249
+ setLoadOutActivityType(function (prev) {
246
250
  var _a;
247
- return (__assign(__assign({}, prev), (_a = {}, _a[slug] = newPage, _a)));
251
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = false, _a)));
248
252
  });
249
253
  return [2 /*return*/];
250
254
  }
251
255
  });
252
- }); }, [isInitPasscode, activities, pages, isLoadingActivities]);
256
+ }); }, [isInitPasscode, loadOutActivityType, isLoadingActivities, getLatestDateCreated, activities]);
253
257
  (0, react_1.useEffect)(function () {
254
258
  if (!isInitPasscode)
255
259
  return;
@@ -261,7 +265,7 @@ function ActivitiesProvider(_a) {
261
265
  activities: activities,
262
266
  updateActivities: updateActivities,
263
267
  activityTypes: activityTypes,
264
- pages: pages,
268
+ loadOutActivityType: loadOutActivityType,
265
269
  loadActivities: loadActivities,
266
270
  }, children: children }));
267
271
  }
@@ -5,8 +5,8 @@ export interface ActivitiesProviderDataType {
5
5
  activities: Activities | undefined;
6
6
  updateActivities: (query?: GetActivitiesServiceQuery) => Promise<void>;
7
7
  activityTypes: ActivityTypes[] | undefined;
8
- pages: Partial<Record<TransactionSlug, number | typeof MAX_PAGE>>;
9
8
  loadActivities: (slug: TransactionSlug) => Promise<void>;
9
+ loadOutActivityType: Partial<Record<TransactionSlug, boolean>>;
10
10
  }
11
11
  export type Activities = Partial<Record<TransactionSlug, Transaction[]>>;
12
12
  export interface ActivityTypes extends TransactionType {
@@ -101,6 +101,7 @@ exports.initialWalletData = {
101
101
  createWallet: function () { return Promise.resolve({}); },
102
102
  importWallet: function () { return Promise.resolve({}); },
103
103
  getSeedPhrase: function () { return Promise.resolve({}); },
104
+ updateBalanceAnalytic: function () { return Promise.resolve(null); },
104
105
  };
105
106
  exports.WalletDataContext = react_1.default.createContext(exports.initialWalletData);
106
107
  function WalletDataProvider(props) {
@@ -334,6 +335,7 @@ function WalletDataProvider(props) {
334
335
  createWallet: createWallet,
335
336
  importWallet: importWallet,
336
337
  getSeedPhrase: getSeedPhrase,
338
+ updateBalanceAnalytic: exports.initialWalletData.updateBalanceAnalytic,
337
339
  }, children: children }));
338
340
  }
339
341
  exports.default = WalletDataProvider;
@@ -90,6 +90,9 @@ var jsx_runtime_1 = require("react/jsx-runtime");
90
90
  var react_1 = __importStar(require("react"));
91
91
  var userClientRequest_1 = require("../../services/axios/clients/userClientRequest");
92
92
  var getBalanceService_1 = __importDefault(require("../../services/axios/get-balance-service/getBalanceService"));
93
+ var get_balance_analytic_1 = __importDefault(require("../../services/axios/get-balance-analytic"));
94
+ var balance_1 = __importDefault(require("../../store/balance"));
95
+ var user_1 = __importDefault(require("../../store/user"));
93
96
  exports.initialWalletDataNoImport = {
94
97
  isSSO: true,
95
98
  isAuthenticated: false,
@@ -107,6 +110,7 @@ exports.initialWalletDataNoImport = {
107
110
  createWallet: function () { return Promise.resolve({}); },
108
111
  importWallet: function () { return Promise.resolve({}); },
109
112
  getSeedPhrase: function () { return Promise.resolve({}); },
113
+ updateBalanceAnalytic: function () { return Promise.resolve(null); },
110
114
  };
111
115
  //
112
116
  exports.WalletDataNoImportContext = react_1.default.createContext(exports.initialWalletDataNoImport);
@@ -116,12 +120,42 @@ function WalletDataProviderNoImport(_a) {
116
120
  var _b = react_1.default.useState(!!accessToken), isAuthenticated = _b[0], setIsAuthenticated = _b[1];
117
121
  var _c = react_1.default.useState(exports.initialWalletDataNoImport.isInitPasscode), isInitPasscode = _c[0], setIsInitPasscode = _c[1];
118
122
  var _d = react_1.default.useState(exports.initialWalletDataNoImport.isTokensLoading), isTokensLoading = _d[0], setIsTokensLoading = _d[1];
119
- var _e = react_1.default.useState(exports.initialWalletDataNoImport.tokens), tokens = _e[0], setTokens = _e[1];
123
+ var _e = react_1.default.useState(exports.initialWalletDataNoImport.tokens), tokens = _e[0], setTokensState = _e[1];
120
124
  var _f = react_1.default.useState(exports.initialWalletDataNoImport.masterWallet), masterWallet = _f[0], setMasterWallet = _f[1];
121
125
  var _g = react_1.default.useState(exports.initialWalletDataNoImport.policyInfo), policyInfo = _g[0], setPolicyInfo = _g[1];
122
126
  var _h = react_1.default.useState(exports.initialWalletDataNoImport.blockchainWallets), blockchainWallets = _h[0], setBlockchainWallets = _h[1];
123
- var updateWalletDetail = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
127
+ var setBalanceAnalytic = (0, balance_1.default)(function (state) { return state.setAnalytic; });
128
+ var setTokensStore = (0, balance_1.default)(function (state) { return state.setTokens; });
129
+ var timeRangeTracking = (0, user_1.default)(function (state) { return state.settings.balance.timeRangeTracking; });
130
+ var setTokens = (0, react_1.useCallback)(function (tokens) {
131
+ setTokensState(tokens);
132
+ setTokensStore(tokens);
133
+ }, [setTokensState, setTokensStore]);
134
+ var updateBalanceAnalytic = (0, react_1.useCallback)(function (reportPeriod) { return __awaiter(_this, void 0, void 0, function () {
124
135
  var response, error_1;
136
+ return __generator(this, function (_a) {
137
+ switch (_a.label) {
138
+ case 0:
139
+ _a.trys.push([0, 2, , 3]);
140
+ return [4 /*yield*/, (0, get_balance_analytic_1.default)({
141
+ report_period: reportPeriod,
142
+ })];
143
+ case 1:
144
+ response = _a.sent();
145
+ if (response === null || response === void 0 ? void 0 : response.success) {
146
+ setBalanceAnalytic(response);
147
+ }
148
+ return [2 /*return*/, response];
149
+ case 2:
150
+ error_1 = _a.sent();
151
+ console.error("🚀 ~ updateBalanceAnalytic ~ error:", error_1);
152
+ return [2 /*return*/, null];
153
+ case 3: return [2 /*return*/];
154
+ }
155
+ });
156
+ }); }, [setBalanceAnalytic]);
157
+ var updateWalletDetail = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
158
+ var response, error_2;
125
159
  return __generator(this, function (_a) {
126
160
  switch (_a.label) {
127
161
  case 0:
@@ -141,16 +175,17 @@ function WalletDataProviderNoImport(_a) {
141
175
  }); }));
142
176
  setPolicyInfo(response === null || response === void 0 ? void 0 : response.policy_info);
143
177
  setIsTokensLoading(false);
178
+ updateBalanceAnalytic(timeRangeTracking);
144
179
  return [3 /*break*/, 3];
145
180
  case 2:
146
- error_1 = _a.sent();
147
- console.error("🚀 ~ getBalance ~ error:", error_1);
181
+ error_2 = _a.sent();
182
+ console.error("🚀 ~ getBalance ~ error:", error_2);
148
183
  setIsTokensLoading(false);
149
184
  return [3 /*break*/, 3];
150
185
  case 3: return [2 /*return*/];
151
186
  }
152
187
  });
153
- }); }, [isTokensLoading]);
188
+ }); }, [isTokensLoading, setTokens, updateBalanceAnalytic, timeRangeTracking]);
154
189
  react_1.default.useEffect(function () {
155
190
  setIsAuthenticated(!!accessToken);
156
191
  }, [accessToken]);
@@ -165,6 +200,6 @@ function WalletDataProviderNoImport(_a) {
165
200
  setTokens(undefined);
166
201
  }
167
202
  }, [isAuthenticated]);
168
- return ((0, jsx_runtime_1.jsx)(exports.WalletDataNoImportContext.Provider, { value: __assign(__assign({}, exports.initialWalletDataNoImport), { isAuthenticated: isAuthenticated, isInitPasscode: isInitPasscode, tokens: tokens, isTokensLoading: isTokensLoading, masterWallet: masterWallet, blockchainWallets: blockchainWallets, policyInfo: policyInfo, updateWalletDetail: updateWalletDetail }), children: children }));
203
+ return ((0, jsx_runtime_1.jsx)(exports.WalletDataNoImportContext.Provider, { value: __assign(__assign({}, exports.initialWalletDataNoImport), { isAuthenticated: isAuthenticated, isInitPasscode: isInitPasscode, tokens: tokens, isTokensLoading: isTokensLoading, masterWallet: masterWallet, blockchainWallets: blockchainWallets, policyInfo: policyInfo, updateWalletDetail: updateWalletDetail, updateBalanceAnalytic: updateBalanceAnalytic }), children: children }));
169
204
  }
170
205
  exports.default = WalletDataProviderNoImport;
@@ -51,9 +51,6 @@ var getActivitiesServices = function (query) { return __awaiter(void 0, void 0,
51
51
  }
52
52
  return [4 /*yield*/, userClientRequest_1.default.get("/transaction/list", {
53
53
  params: query,
54
- paramsSerializer: {
55
- indexes: null,
56
- },
57
54
  })];
58
55
  case 1:
59
56
  response = _a.sent();
@@ -1,11 +1,11 @@
1
1
  import { Paginated, Currency, NetworkData } from "../type";
2
2
  export interface GetActivitiesServiceQuery {
3
- page?: number;
4
- take?: number;
5
- from_date?: string;
6
- to_date?: string;
3
+ limit?: number;
4
+ last_date_created?: string | null;
7
5
  transaction_types?: TransactionSlug;
8
6
  transaction_status?: TransactionStatus | TransactionStatus[];
7
+ from_date?: string;
8
+ to_date?: string;
9
9
  }
10
10
  export interface GetActivitiesServiceResponse {
11
11
  success: boolean;
@@ -0,0 +1,3 @@
1
+ import { GetBalanceAnalyticQuery, GetBalanceAnalyticResponse } from "./type";
2
+ declare const getBalanceAnalytic: (query?: GetBalanceAnalyticQuery) => Promise<GetBalanceAnalyticResponse>;
3
+ export default getBalanceAnalytic;