tek-wallet 0.0.774 → 0.0.775

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.
@@ -67,7 +67,7 @@ var AssetViewHeader = function () {
67
67
  var options = (0, TekWalletProvider_1.useWalletSetup)().options;
68
68
  var theme = (0, ThemeProvider_1.useTheme)();
69
69
  var modalRef = (0, react_1.useRef)(null);
70
- return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { justifyContent: "center", position: "relative", boxShadow: "0 0 1px 2px rgba(0, 0, 0, 0.03)" }), children: [(0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: modalRef, trigger: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign(__assign({}, theme.mixins.row), { alignItems: "center", justifyContent: "center", textAlign: "center", gap: theme.mixins.gaps.g4, py: theme.mixins.customPadding.p8 }), theme.mixins.value), children: [(0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: "1.25rem", height: "1.25rem" }, children: SvgPath_1.WALLET }), (0, compactWalletAddress_1.default)(masterWallet), (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: "0.625rem", height: "0.625rem" }, children: SvgPath_1.ARROW_DROP_DOWN })] }), direction: DrawerComponent_1.DRAWER_DIRECTION.TOP, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
70
+ return ((0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { justifyContent: "start", position: "relative", boxShadow: "0 0 1px 2px rgba(0, 0, 0, 0.03)", px: theme.mixins.customPadding.p16 }), children: [(0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: modalRef, trigger: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign(__assign({}, theme.mixins.row), { alignItems: "center", justifyContent: "start", textAlign: "center", gap: theme.mixins.gaps.g4, py: theme.mixins.customPadding.p8 }), theme.mixins.value), children: [(0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: "1.25rem", height: "1.25rem" }, children: SvgPath_1.WALLET }), (0, compactWalletAddress_1.default)(masterWallet), (0, jsx_runtime_1.jsx)(material_1.SvgIcon, { sx: { width: "0.625rem", height: "0.625rem" }, children: SvgPath_1.ARROW_DROP_DOWN })] }), direction: DrawerComponent_1.DRAWER_DIRECTION.TOP, children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
71
71
  width: "100%",
72
72
  height: "fit-content",
73
73
  backgroundColor: "white",
@@ -11,8 +11,10 @@ var Formatter_1 = __importDefault(require("../components/ui/Formatter"));
11
11
  var Text_1 = __importDefault(require("../components/ui/Text"));
12
12
  var useWallet_1 = __importDefault(require("./useWallet"));
13
13
  var useEventHandler = function () {
14
- var _a = (0, useWallet_1.default)(), updateLockToken = _a.updateLockToken, updateReceiveExternalToken = _a.updateReceiveExternalToken, updateReceiveInternalToken = _a.updateReceiveInternalToken, updateSendInternalToken = _a.updateSendInternalToken, updateSwapTokens = _a.updateSwapTokens, updateWalletDetail = _a.updateWalletDetail, updateWithdrawToken = _a.updateWithdrawToken, updateLockedToken = _a.updateLockedToken, updateActivities = _a.updateActivities;
15
- var updateData = (0, react_1.useCallback)(function (transactionType, showActivities) {
14
+ var _a = (0, useWallet_1.default)(), updateLockToken = _a.updateLockToken, updateReceiveExternalToken = _a.updateReceiveExternalToken, updateReceiveInternalToken = _a.updateReceiveInternalToken, updateSendInternalToken = _a.updateSendInternalToken, updateSwapTokens = _a.updateSwapTokens, updateWalletDetail = _a.updateWalletDetail, updateWithdrawToken = _a.updateWithdrawToken, updateLockedToken = _a.updateLockedToken,
15
+ // updateActivities,
16
+ insertActivities = _a.insertActivities;
17
+ var updateData = (0, react_1.useCallback)(function (transaction, showActivities) {
16
18
  updateWithdrawToken();
17
19
  updateSendInternalToken();
18
20
  updateReceiveInternalToken();
@@ -22,7 +24,8 @@ var useEventHandler = function () {
22
24
  updateLockedToken();
23
25
  showActivities === null || showActivities === void 0 ? void 0 : showActivities();
24
26
  updateWalletDetail();
25
- updateActivities();
27
+ // updateActivities();
28
+ insertActivities(transaction);
26
29
  }, [
27
30
  updateWalletDetail,
28
31
  updateWithdrawToken,
@@ -32,7 +35,8 @@ var useEventHandler = function () {
32
35
  updateSwapTokens,
33
36
  updateLockToken,
34
37
  updateLockedToken,
35
- updateActivities,
38
+ // updateActivities,
39
+ insertActivities,
36
40
  ]);
37
41
  var transactionHandler = function (messageEvent, showActivities) {
38
42
  var _a, _b, _c;
@@ -67,7 +71,7 @@ var useEventHandler = function () {
67
71
  default:
68
72
  break;
69
73
  }
70
- updateData(type, showActivities);
74
+ updateData(messageEvent, showActivities);
71
75
  return {
72
76
  message: notificationMessage,
73
77
  type: notificationType,
@@ -77,9 +81,7 @@ var useEventHandler = function () {
77
81
  var walletInfoHandler = function (messageEvent) {
78
82
  if (!messageEvent)
79
83
  return undefined;
80
- var type = messageEvent.transaction_type || "unknown";
81
- console.warn("🚀 ~ useEventHandler ~ type:", type);
82
- updateData(type);
84
+ updateData(messageEvent);
83
85
  };
84
86
  return { transactionHandler: transactionHandler, walletInfoHandler: walletInfoHandler };
85
87
  };
@@ -112,6 +112,7 @@ exports.initialActivities = {
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
  }); }); },
115
+ insertActivities: function () { },
115
116
  };
116
117
  exports.ActivitiesContext = react_1.default.createContext(exports.initialActivities);
117
118
  function ActivitiesProvider(_a) {
@@ -145,6 +146,24 @@ function ActivitiesProvider(_a) {
145
146
  }
146
147
  });
147
148
  }); }, []);
149
+ var insertActivities = (0, react_1.useCallback)(function (activity) {
150
+ var _a, _b, _c, _d, _e;
151
+ var slug = (_a = activity === null || activity === void 0 ? void 0 : activity.transaction_type) === null || _a === void 0 ? void 0 : _a.slug;
152
+ if (!slug)
153
+ return;
154
+ var remainActivities = (_c = (_b = activities === null || activities === void 0 ? void 0 : activities[slug]) === null || _b === void 0 ? void 0 : _b.filter(function (item) {
155
+ return item.id !== activity.id;
156
+ })) !== null && _c !== void 0 ? _c : [];
157
+ var remainActivitiesAllSlug = (_e = (_d = activities === null || activities === void 0 ? void 0 : activities[const_1.ACTIVITIES_TYPE_ALL.slug]) === null || _d === void 0 ? void 0 : _d.filter(function (item) {
158
+ return item.id !== activity.id;
159
+ })) !== null && _e !== void 0 ? _e : [];
160
+ var newActivities = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], remainActivities, true), [activity], false));
161
+ var newActivitiesAllSlug = (0, sortActivity_1.default)(__spreadArray(__spreadArray([], remainActivitiesAllSlug, true), [activity], false));
162
+ setActivities(function (prev) {
163
+ var _a;
164
+ return (__assign(__assign({}, prev), (_a = {}, _a[slug] = newActivities, _a[const_1.ACTIVITIES_TYPE_ALL.slug] = newActivitiesAllSlug, _a)));
165
+ });
166
+ }, [activities]);
148
167
  var updateActivities = (0, react_1.useCallback)(function (query) { return __awaiter(_this, void 0, void 0, function () {
149
168
  var slug, response_1, loadedActivities_1, error_1;
150
169
  var _a, _b, _c;
@@ -267,6 +286,7 @@ function ActivitiesProvider(_a) {
267
286
  activityTypes: activityTypes,
268
287
  loadOutActivityType: loadOutActivityType,
269
288
  loadActivities: loadActivities,
289
+ insertActivities: insertActivities,
270
290
  }, children: children }));
271
291
  }
272
292
  exports.default = ActivitiesProvider;
@@ -7,6 +7,7 @@ export interface ActivitiesProviderDataType {
7
7
  activityTypes: ActivityTypes[] | undefined;
8
8
  loadActivities: (slug: TransactionSlug) => Promise<void>;
9
9
  loadOutActivityType: Partial<Record<TransactionSlug, boolean>>;
10
+ insertActivities: (activity: Transaction) => void;
10
11
  }
11
12
  export type Activities = Partial<Record<TransactionSlug, Transaction[]>>;
12
13
  export interface ActivityTypes extends TransactionType {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.774",
3
+ "version": "0.0.775",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",