tek-wallet 0.0.355 → 0.0.357

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,5 @@
1
- import { GeneralProps } from "../../../types/ui";
2
- interface BackArrowProps extends GeneralProps {
1
+ import { IconProps } from "../Icon";
2
+ interface BackArrowProps extends IconProps {
3
3
  }
4
4
  declare const BackArrow: (props: BackArrowProps) => import("react/jsx-runtime").JSX.Element;
5
5
  export default BackArrow;
@@ -38,9 +38,9 @@ var Button = function (props) {
38
38
  };
39
39
  Button.displayName = "Button";
40
40
  Button.Primary = function (props) {
41
- var sx = props.sx, rest = __rest(props, ["sx"]);
41
+ var sx = props.sx, children = props.children, rest = __rest(props, ["sx", "children"]);
42
42
  var theme = (0, material_1.useTheme)();
43
- return ((0, jsx_runtime_1.jsx)(Button, __assign({}, rest, { variant: "contained", color: "primary", sx: __assign({ borderRadius: theme.mixins.theBorderRadius.full }, sx) })));
43
+ return ((0, jsx_runtime_1.jsx)(Button, __assign({}, rest, { variant: "contained", color: "primary", sx: __assign({ borderRadius: theme.mixins.theBorderRadius.full }, sx), children: children })));
44
44
  };
45
45
  Button.Primary.displayName = "Button.Primary";
46
46
  Button.Secondary = function (props) {
@@ -1,9 +1,10 @@
1
- import { GeneralProps } from "../../../types/ui";
2
- export interface IconProps extends Omit<GeneralProps, "onClick">, React.ImgHTMLAttributes<HTMLImageElement> {
1
+ import { SxProps } from "@mui/material";
2
+ export interface IconProps extends React.ImgHTMLAttributes<HTMLImageElement> {
3
3
  src?: string;
4
4
  alt?: string;
5
5
  width?: number;
6
6
  height?: number;
7
+ sx?: SxProps;
7
8
  }
8
9
  declare const Icon: (props: IconProps) => import("react/jsx-runtime").JSX.Element;
9
10
  export default Icon;
@@ -26,11 +26,11 @@ var jsx_runtime_1 = require("react/jsx-runtime");
26
26
  var material_1 = require("@mui/material");
27
27
  var Icon = function (props) {
28
28
  var _a, _b;
29
- var src = props.src, alt = props.alt, onClick = props.onClick, width = props.width, height = props.height, rest = __rest(props, ["src", "alt", "onClick", "width", "height"]);
29
+ var src = props.src, alt = props.alt, onClick = props.onClick, width = props.width, height = props.height, sx = props.sx, rest = __rest(props, ["src", "alt", "onClick", "width", "height", "sx"]);
30
30
  return ((0, jsx_runtime_1.jsx)(material_1.Box, __assign({ component: "img", src: src, alt: alt, onClick: onClick }, rest, { sx: __assign({ display: "block", width: ((_a = width !== null && width !== void 0 ? width : height) !== null && _a !== void 0 ? _a : false)
31
31
  ? "".concat((width || height || 0) / 16, "rem")
32
32
  : "auto", height: ((_b = height !== null && height !== void 0 ? height : width) !== null && _b !== void 0 ? _b : false)
33
33
  ? "".concat((height || width || 0) / 16, "rem")
34
- : "auto" }, props.sx) })));
34
+ : "auto" }, sx) })));
35
35
  };
36
36
  exports.default = Icon;
@@ -1,5 +1,5 @@
1
- import { GeneralProps } from "../../../types/ui";
2
- interface ImageProps extends GeneralProps {
1
+ import { BoxProps } from "@mui/material";
2
+ interface ImageProps extends BoxProps {
3
3
  src?: string;
4
4
  alt?: string;
5
5
  }
@@ -10,14 +10,15 @@ type WithdrawFunctionRef = {
10
10
  };
11
11
  export declare enum SendMethods {
12
12
  SCAN_QR_CODE = "scan qr code",
13
- TRANSFER_INTERNAL = "transfer internal",
14
- TRANSFER_EXTERNAL = "transfer external"
13
+ TRANSFER_INTERNAL = "send internal",
14
+ TRANSFER_EXTERNAL = "send external"
15
15
  }
16
16
  export declare enum WithdrawStep {
17
17
  SELECT_METHOD = 0,
18
18
  SELECT_TOKEN = 1,
19
19
  SELECT_NETWORK = 2,
20
- CONFIRM = 3
20
+ FORM = 3,
21
+ CONFIRM = 4
21
22
  }
22
23
  export declare enum AmountError {
23
24
  INSUFFICIENT_BALANCE = "Your balance is insufficient",
@@ -113,23 +113,26 @@ var AppBackDrop_1 = __importDefault(require("../AppBackDrop"));
113
113
  var DialogContentLayout_1 = __importDefault(require("../DialogContentLayout"));
114
114
  var AppDialog_1 = __importDefault(require("../AppDialog"));
115
115
  var Formatter_1 = __importDefault(require("../Formatter"));
116
+ var send_internal_service_1 = __importDefault(require("../../../services/axios/send-internal-service"));
116
117
  var SendMethods;
117
118
  (function (SendMethods) {
118
119
  SendMethods["SCAN_QR_CODE"] = "scan qr code";
119
- SendMethods["TRANSFER_INTERNAL"] = "transfer internal";
120
- SendMethods["TRANSFER_EXTERNAL"] = "transfer external";
120
+ SendMethods["TRANSFER_INTERNAL"] = "send internal";
121
+ SendMethods["TRANSFER_EXTERNAL"] = "send external";
121
122
  })(SendMethods || (exports.SendMethods = SendMethods = {}));
122
123
  var WithdrawStep;
123
124
  (function (WithdrawStep) {
124
125
  WithdrawStep[WithdrawStep["SELECT_METHOD"] = 0] = "SELECT_METHOD";
125
126
  WithdrawStep[WithdrawStep["SELECT_TOKEN"] = 1] = "SELECT_TOKEN";
126
127
  WithdrawStep[WithdrawStep["SELECT_NETWORK"] = 2] = "SELECT_NETWORK";
127
- WithdrawStep[WithdrawStep["CONFIRM"] = 3] = "CONFIRM";
128
+ WithdrawStep[WithdrawStep["FORM"] = 3] = "FORM";
129
+ WithdrawStep[WithdrawStep["CONFIRM"] = 4] = "CONFIRM";
128
130
  })(WithdrawStep || (exports.WithdrawStep = WithdrawStep = {}));
129
131
  var WITHDRAW_STEP_NAME = (_a = {},
130
132
  _a[WithdrawStep.SELECT_METHOD] = "Select method",
131
133
  _a[WithdrawStep.SELECT_TOKEN] = "Select token",
132
134
  _a[WithdrawStep.SELECT_NETWORK] = "Select network",
135
+ _a[WithdrawStep.FORM] = "Form",
133
136
  _a[WithdrawStep.CONFIRM] = "Confirm",
134
137
  _a);
135
138
  var AmountError;
@@ -284,7 +287,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
284
287
  }
285
288
  else {
286
289
  setSelectedToken(tokenSet);
287
- gotoStep(WithdrawStep.CONFIRM);
290
+ gotoStep(WithdrawStep.FORM);
288
291
  }
289
292
  };
290
293
  var handleSelectContinueTransferExternal = function (dataPromptly) {
@@ -304,7 +307,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
304
307
  else {
305
308
  setSelectedToken(tokenSet);
306
309
  setSelectedNetwork(tokenSet === null || tokenSet === void 0 ? void 0 : tokenSet.network_data);
307
- gotoStep(WithdrawStep.CONFIRM);
310
+ gotoStep(WithdrawStep.FORM);
308
311
  }
309
312
  setAmount(getAmountAfterDecimal((data === null || data === void 0 ? void 0 : data.amount) || 0, (tokenSet === null || tokenSet === void 0 ? void 0 : tokenSet.decimal) || 0));
310
313
  setMemo(data === null || data === void 0 ? void 0 : data.text);
@@ -339,7 +342,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
339
342
  return amountNumber || "";
340
343
  };
341
344
  var handleBack = function () {
342
- if (currentStep === WithdrawStep.CONFIRM &&
345
+ if (currentStep === WithdrawStep.FORM &&
343
346
  selectedMethod === SendMethods.TRANSFER_INTERNAL) {
344
347
  gotoStep(WithdrawStep.SELECT_TOKEN);
345
348
  return;
@@ -351,7 +354,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
351
354
  setSelectedToken(token);
352
355
  if (!!token) {
353
356
  if (selectedMethod === SendMethods.TRANSFER_INTERNAL) {
354
- gotoStep(WithdrawStep.CONFIRM);
357
+ gotoStep(WithdrawStep.FORM);
355
358
  }
356
359
  else {
357
360
  gotoStep(WithdrawStep.SELECT_NETWORK);
@@ -361,7 +364,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
361
364
  var handleSelectNetwork = function (network) {
362
365
  console.warn("network", selectedNetwork);
363
366
  setSelectedNetwork(network);
364
- gotoStep(WithdrawStep.CONFIRM);
367
+ gotoStep(WithdrawStep.FORM);
365
368
  };
366
369
  var handleValidateWalletAddress = function (address, network) { return __awaiter(void 0, void 0, void 0, function () {
367
370
  var validateWalletAddress;
@@ -461,6 +464,40 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
461
464
  return [2 /*return*/];
462
465
  });
463
466
  }); };
467
+ var handleSendInternal = function () { return __awaiter(void 0, void 0, void 0, function () {
468
+ var response;
469
+ return __generator(this, function (_a) {
470
+ switch (_a.label) {
471
+ case 0:
472
+ console.warn("withdraw internal");
473
+ return [4 /*yield*/, (0, send_internal_service_1.default)({
474
+ amount: "".concat(amount),
475
+ to_address: recipientAddress || "",
476
+ currency_slug: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.slug) || "",
477
+ passcode: "111111",
478
+ })];
479
+ case 1:
480
+ response = _a.sent();
481
+ console.warn("🚀 ~ handleSendInternal ~ response:", response);
482
+ return [2 /*return*/];
483
+ }
484
+ });
485
+ }); };
486
+ var handleSendExternal = function () {
487
+ console.warn("withdraw external");
488
+ };
489
+ var handleSend = function () {
490
+ switch (selectedMethod) {
491
+ case SendMethods.TRANSFER_INTERNAL:
492
+ handleSendInternal();
493
+ break;
494
+ case SendMethods.TRANSFER_EXTERNAL:
495
+ handleSendExternal();
496
+ break;
497
+ default:
498
+ break;
499
+ }
500
+ };
464
501
  (0, react_1.useEffect)(function () {
465
502
  if (isAuthenticated && !withdrawTokens) {
466
503
  console.warn("🚀 ~ updateWithdrawToken ~ isAuthenticated:", isAuthenticated);
@@ -476,7 +513,7 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
476
513
  alignItems: "center",
477
514
  minHeight: "2rem",
478
515
  mb: theme.mixins.customMargin.m20,
479
- }, overrideBack: handleBack, hideBack: currentStep === WithdrawStep.SELECT_METHOD, center: currentStep === WithdrawStep.CONFIRM
516
+ }, overrideBack: handleBack, hideBack: currentStep === WithdrawStep.SELECT_METHOD, center: currentStep === WithdrawStep.FORM
480
517
  ? "Send ".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name, " ").concat(selectedMethod === SendMethods.TRANSFER_EXTERNAL ? "externally" : "internally")
481
518
  : WITHDRAW_STEP_NAME[currentStep], children: (0, jsx_runtime_1.jsx)(CloseModal_1.default, { sx: { marginLeft: "auto" }, onClick: close }) }), children: [(0, jsx_runtime_1.jsxs)(SwiperControlled_1.default, { ref: swiperRef, swiperProps: {
482
519
  autoHeight: true,
@@ -517,13 +554,13 @@ var WithdrawFunction = (0, react_1.forwardRef)(function (props, ref) {
517
554
  placeholder: "Enter memo",
518
555
  value: memo,
519
556
  onChange: handleChangeMemo,
520
- } })] })), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, status: !!amountError ||
557
+ } })] })), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { sx: { width: "100%" }, onClick: handleSend, status: !!amountError ||
521
558
  !recipientAddress ||
522
559
  !amount ||
523
560
  !selectedToken ||
524
561
  !!recipientAddressError
525
562
  ? Button_1.BUTTON_STATUS.DISABLED
526
- : Button_1.BUTTON_STATUS.ENABLED, children: "Confirm" })] }) }, WithdrawStep.CONFIRM)] }, withdrawTokens === null || withdrawTokens === void 0 ? void 0 : withdrawTokens.length), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAddressQrCodeRef, onResult: handleScanAddressQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: backDropRef }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { overrideOpen: !!infoDialogContent, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
563
+ : Button_1.BUTTON_STATUS.ENABLED, children: "Continue" })] }) }, WithdrawStep.FORM)] }, withdrawTokens === null || withdrawTokens === void 0 ? void 0 : withdrawTokens.length), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAllQrCodeRef, onResult: handleScanAllQrCode }), (0, jsx_runtime_1.jsx)(QrCodeReader_1.default, { ref: scannerAddressQrCodeRef, onResult: handleScanAddressQrCode }), (0, jsx_runtime_1.jsx)(AppBackDrop_1.default, { ref: backDropRef }), (0, jsx_runtime_1.jsx)(AppDialog_1.default, { overrideOpen: !!infoDialogContent, children: (0, jsx_runtime_1.jsx)(DialogContentLayout_1.default, { content: (0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
527
564
  textAlign: "center",
528
565
  display: "inline-block",
529
566
  width: "100%",
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { RealtimeProviderDataType } from "./type";
3
+ import { VariantType } from "notistack";
4
+ export declare const initialRealtime: RealtimeProviderDataType;
5
+ export interface Notification {
6
+ message: string;
7
+ variant: VariantType;
8
+ }
9
+ export declare const RealtimeContext: React.Context<RealtimeProviderDataType>;
10
+ declare function RealtimeProvider({ children }: {
11
+ children: React.ReactNode;
12
+ }): import("react/jsx-runtime").JSX.Element;
13
+ export default RealtimeProvider;
@@ -0,0 +1,112 @@
1
+ "use strict";
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
+ };
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
48
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
49
+ if (ar || !(i in from)) {
50
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
51
+ ar[i] = from[i];
52
+ }
53
+ }
54
+ return to.concat(ar || Array.prototype.slice.call(from));
55
+ };
56
+ var __importDefault = (this && this.__importDefault) || function (mod) {
57
+ return (mod && mod.__esModule) ? mod : { "default": mod };
58
+ };
59
+ Object.defineProperty(exports, "__esModule", { value: true });
60
+ exports.RealtimeContext = exports.initialRealtime = void 0;
61
+ var jsx_runtime_1 = require("react/jsx-runtime");
62
+ var react_1 = __importStar(require("react"));
63
+ var useWalletData_1 = __importDefault(require("../../hooks/useWalletData"));
64
+ var ably_service_1 = require("../../services/ably/ably.service");
65
+ var material_1 = require("@mui/material");
66
+ var notistack_1 = require("notistack");
67
+ var Slide_1 = __importDefault(require("@mui/material/Slide"));
68
+ exports.initialRealtime = {
69
+ transaction: undefined,
70
+ isConnected: false,
71
+ pushNotification: function () { },
72
+ };
73
+ function SlideTransition(props) {
74
+ return (0, jsx_runtime_1.jsx)(Slide_1.default, __assign({}, props, { direction: "up" }));
75
+ }
76
+ exports.RealtimeContext = react_1.default.createContext(exports.initialRealtime);
77
+ function RealtimeProvider(_a) {
78
+ var children = _a.children;
79
+ var masterWallet = (0, useWalletData_1.default)().masterWallet;
80
+ var _b = (0, react_1.useState)(exports.initialRealtime.isConnected), isConnected = _b[0], setIsConnected = _b[1];
81
+ var _c = (0, react_1.useState)(exports.initialRealtime.transaction), transaction = _c[0], setTransaction = _c[1];
82
+ var _d = (0, react_1.useState)([]), notifications = _d[0], setNotifications = _d[1];
83
+ var pushNotification = function (notification) {
84
+ setNotifications(function (prev) { return __spreadArray(__spreadArray([], prev, true), [notification], false); });
85
+ };
86
+ (0, react_1.useEffect)(function () {
87
+ try {
88
+ if (!masterWallet)
89
+ return;
90
+ var ablyService = new ably_service_1.AblyService();
91
+ console.warn("Connecting to realtime");
92
+ ablyService.listenMessage(masterWallet, function (message) {
93
+ // eslint-disable-next-line no-console
94
+ console.log("🚀 ~ ablyService.listenMessage ~ message:", message);
95
+ setIsConnected(true);
96
+ setTransaction(message);
97
+ });
98
+ }
99
+ catch (error) {
100
+ console.error("🚀 ~ TEK-WALLET: Error connecting to realtime", error);
101
+ }
102
+ }, [masterWallet]);
103
+ return ((0, jsx_runtime_1.jsxs)(exports.RealtimeContext.Provider, { value: {
104
+ isConnected: isConnected,
105
+ transaction: transaction,
106
+ pushNotification: pushNotification,
107
+ }, children: [children, (0, jsx_runtime_1.jsx)(notistack_1.SnackbarProvider, { maxSnack: 2, children: notifications.map(function (notification) {
108
+ var _a;
109
+ return ((0, jsx_runtime_1.jsx)(material_1.Snackbar, { open: true, onClose: function () { }, slots: { transition: SlideTransition }, message: notification.message, autoHideDuration: (_a = notification.duration) !== null && _a !== void 0 ? _a : 2000 }, notification.id));
110
+ }) })] }));
111
+ }
112
+ exports.default = RealtimeProvider;
@@ -0,0 +1,11 @@
1
+ export interface RealtimeProviderDataType {
2
+ transaction: any;
3
+ isConnected: boolean;
4
+ pushNotification: (notification: NotificationType) => void;
5
+ }
6
+ export interface NotificationType {
7
+ message: string;
8
+ type: "success" | "error" | "warning" | "info";
9
+ duration?: number;
10
+ id: string;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -10,8 +10,9 @@ var mui_1 = __importDefault(require("../../theme/mui"));
10
10
  var DepositProvider_1 = __importDefault(require("../DepositProvider"));
11
11
  var LockTokenProvider_1 = __importDefault(require("../LockTokenProvider"));
12
12
  var WithdrawProvider_1 = __importDefault(require("../WithdrawProvider"));
13
+ var RealtimeProvider_1 = __importDefault(require("../RealtimeProvider"));
13
14
  function TekWalletProvider(_a) {
14
15
  var children = _a.children;
15
- return ((0, jsx_runtime_1.jsx)(WalletDataProvider_1.default, { children: (0, jsx_runtime_1.jsx)(DepositProvider_1.default, { children: (0, jsx_runtime_1.jsx)(LockTokenProvider_1.default, { children: (0, jsx_runtime_1.jsx)(WithdrawProvider_1.default, { children: (0, jsx_runtime_1.jsx)(mui_1.default, { children: children }) }) }) }) }));
16
+ return ((0, jsx_runtime_1.jsx)(WalletDataProvider_1.default, { children: (0, jsx_runtime_1.jsx)(RealtimeProvider_1.default, { children: (0, jsx_runtime_1.jsx)(DepositProvider_1.default, { children: (0, jsx_runtime_1.jsx)(LockTokenProvider_1.default, { children: (0, jsx_runtime_1.jsx)(WithdrawProvider_1.default, { children: (0, jsx_runtime_1.jsx)(mui_1.default, { children: children }) }) }) }) }) }));
16
17
  }
17
18
  exports.default = TekWalletProvider;
@@ -0,0 +1,13 @@
1
+ import * as Ably from "ably";
2
+ import { Message } from "ably";
3
+ export declare class AblyService {
4
+ private readonly ably;
5
+ private readonly channels;
6
+ constructor();
7
+ getChannels(): Map<string, Ably.RealtimeChannel>;
8
+ getClient(): Ably.Realtime;
9
+ listenMessage(walletAddress: string, onMessage: (message: Message) => void): Promise<void>;
10
+ publish(channel: string, event: string, data: any): Promise<void>;
11
+ subscribe(channel: string, event: string, callback: (message: any) => void): Promise<void>;
12
+ cleanup(walletAddress: string): Promise<void>;
13
+ }
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __generator = (this && this.__generator) || function (thisArg, body) {
45
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
46
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
47
+ function verb(n) { return function (v) { return step([n, v]); }; }
48
+ function step(op) {
49
+ if (f) throw new TypeError("Generator is already executing.");
50
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
51
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
52
+ if (y = 0, t) op = [op[0] & 2, t.value];
53
+ switch (op[0]) {
54
+ case 0: case 1: t = op; break;
55
+ case 4: _.label++; return { value: op[1], done: false };
56
+ case 5: _.label++; y = op[1]; op = [0]; continue;
57
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
58
+ default:
59
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
60
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
61
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
62
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
63
+ if (t[2]) _.ops.pop();
64
+ _.trys.pop(); continue;
65
+ }
66
+ op = body.call(thisArg, _);
67
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
68
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
69
+ }
70
+ };
71
+ Object.defineProperty(exports, "__esModule", { value: true });
72
+ exports.AblyService = void 0;
73
+ var Ably = __importStar(require("ably"));
74
+ var type_1 = require("./type");
75
+ var AblyService = /** @class */ (function () {
76
+ function AblyService() {
77
+ this.channels = new Map();
78
+ this.ably = new Ably.Realtime({
79
+ key: process.env.NEXT_PUBLIC_TEK_WALLET_ABLY_API_KEY,
80
+ clientId: "".concat(process.env.NEXT_PUBLIC_TEK_WALLET_APP_SLUG, "-FE"),
81
+ });
82
+ }
83
+ AblyService.prototype.getChannels = function () {
84
+ return this.channels;
85
+ };
86
+ AblyService.prototype.getClient = function () {
87
+ return this.ably;
88
+ };
89
+ AblyService.prototype.listenMessage = function (walletAddress, onMessage) {
90
+ return __awaiter(this, void 0, void 0, function () {
91
+ var channel, error_1;
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0:
95
+ _a.trys.push([0, 2, , 3]);
96
+ channel = this.ably.channels.get(walletAddress);
97
+ return [4 /*yield*/, channel.subscribe(type_1.ABLY_CHANNELS_NAME.TRANSACTION, function (message) {
98
+ onMessage(message);
99
+ })];
100
+ case 1:
101
+ _a.sent();
102
+ return [3 /*break*/, 3];
103
+ case 2:
104
+ error_1 = _a.sent();
105
+ console.error("Test failed for wallet ".concat(walletAddress, ":"), error_1);
106
+ return [3 /*break*/, 3];
107
+ case 3: return [2 /*return*/];
108
+ }
109
+ });
110
+ });
111
+ };
112
+ AblyService.prototype.publish = function (channel, event, data) {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var message;
115
+ return __generator(this, function (_a) {
116
+ message = {
117
+ name: event,
118
+ data: data,
119
+ };
120
+ return [2 /*return*/, this.ably.channels.get(channel).publish(message)];
121
+ });
122
+ });
123
+ };
124
+ AblyService.prototype.subscribe = function (channel, event, callback) {
125
+ return __awaiter(this, void 0, void 0, function () {
126
+ return __generator(this, function (_a) {
127
+ switch (_a.label) {
128
+ case 0: return [4 /*yield*/, this.ably.channels.get(channel).subscribe(event, callback)];
129
+ case 1:
130
+ _a.sent();
131
+ return [2 /*return*/];
132
+ }
133
+ });
134
+ });
135
+ };
136
+ AblyService.prototype.cleanup = function (walletAddress) {
137
+ return __awaiter(this, void 0, void 0, function () {
138
+ var channel;
139
+ return __generator(this, function (_a) {
140
+ channel = this.channels.get(walletAddress);
141
+ if (channel) {
142
+ channel.unsubscribe();
143
+ this.channels.delete(walletAddress);
144
+ // eslint-disable-next-line no-console
145
+ console.log("Unsubscribed from wallet ".concat(walletAddress));
146
+ }
147
+ return [2 /*return*/];
148
+ });
149
+ });
150
+ };
151
+ return AblyService;
152
+ }());
153
+ exports.AblyService = AblyService;
@@ -0,0 +1,3 @@
1
+ export declare enum ABLY_CHANNELS_NAME {
2
+ TRANSACTION = "transaction"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ABLY_CHANNELS_NAME = void 0;
4
+ var ABLY_CHANNELS_NAME;
5
+ (function (ABLY_CHANNELS_NAME) {
6
+ ABLY_CHANNELS_NAME["TRANSACTION"] = "transaction";
7
+ })(ABLY_CHANNELS_NAME || (exports.ABLY_CHANNELS_NAME = ABLY_CHANNELS_NAME = {}));
@@ -0,0 +1,3 @@
1
+ import { SendExternalBody, SendExternalResponse } from "./type";
2
+ declare const sendExternalService: (body: SendExternalBody) => Promise<SendExternalResponse>;
3
+ export default sendExternalService;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var userClientRequest_1 = __importDefault(require("../clients/userClientRequest"));
43
+ var sendExternalService = function (body) { return __awaiter(void 0, void 0, void 0, function () {
44
+ var response;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, userClientRequest_1.default.post("/transaction/withdrawn", body, {
48
+ headers: {
49
+ "c-payload-signature": "text",
50
+ },
51
+ })];
52
+ case 1:
53
+ response = _a.sent();
54
+ return [2 /*return*/, response.data];
55
+ }
56
+ });
57
+ }); };
58
+ exports.default = sendExternalService;
@@ -0,0 +1,13 @@
1
+ export interface SendExternalBody {
2
+ amount: string;
3
+ currency_slug: string;
4
+ passcode: string;
5
+ to_address: string;
6
+ network: string;
7
+ memo: string;
8
+ }
9
+ export interface SendExternalResponse {
10
+ success: boolean;
11
+ message: string;
12
+ timestamp: string;
13
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ import { SendInternalBody, SendInternalResponse } from "./type";
2
+ declare const sendInternalService: (body: SendInternalBody) => Promise<SendInternalResponse>;
3
+ export default sendInternalService;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ var userClientRequest_1 = __importDefault(require("../clients/userClientRequest"));
43
+ var sendInternalService = function (body) { return __awaiter(void 0, void 0, void 0, function () {
44
+ var response;
45
+ return __generator(this, function (_a) {
46
+ switch (_a.label) {
47
+ case 0: return [4 /*yield*/, userClientRequest_1.default.post("/transaction/transfer-internal", body, {
48
+ headers: {
49
+ "c-payload-signature": "text",
50
+ },
51
+ })];
52
+ case 1:
53
+ response = _a.sent();
54
+ return [2 /*return*/, response.data];
55
+ }
56
+ });
57
+ }); };
58
+ exports.default = sendInternalService;
@@ -0,0 +1,11 @@
1
+ export interface SendInternalBody {
2
+ amount: string;
3
+ to_address: string;
4
+ currency_slug: string;
5
+ passcode: string;
6
+ }
7
+ export interface SendInternalResponse {
8
+ success: boolean;
9
+ message: string;
10
+ timestamp: string;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tek-wallet",
3
- "version": "0.0.355",
3
+ "version": "0.0.357",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,6 +32,7 @@
32
32
  "@mui/material": "^6.4.7",
33
33
  "@mui/system": "^7.0.2",
34
34
  "@yudiel/react-qr-scanner": "^2.2.1",
35
+ "ably": "^2.7.0",
35
36
  "axios": "^1.8.4",
36
37
  "clsx": "^2.1.1",
37
38
  "date-fns": "^4.1.0",
@@ -42,6 +43,7 @@
42
43
  "html-to-image": "^1.11.13",
43
44
  "jsonwebtoken": "^9.0.2",
44
45
  "next": "^15.2.4",
46
+ "notistack": "^3.0.2",
45
47
  "qrcode.react": "^4.2.0",
46
48
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
47
49
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",