tek-wallet 0.0.618 → 0.0.620

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.
@@ -3,7 +3,8 @@ import { DrawerComponentProps, DrawerComponentRef } from "../DrawerComponent";
3
3
  import { TransactionSlug } from "../../../services/axios/get-activities-service/type";
4
4
  interface ConfirmByPasscodeProps extends Omit<GeneralProps, "onclick" | "sx" | "onClick">, DrawerComponentProps {
5
5
  onConfirmSuccess?: (passcode: string) => any;
6
- action: TransactionSlug;
6
+ action?: TransactionSlug;
7
+ customAction?: string;
7
8
  }
8
9
  export interface ConfirmByPasscodeRef extends Omit<DrawerComponentRef, "trigger"> {
9
10
  clearData: () => void;
@@ -114,7 +114,7 @@ var handleVerifyPasscode = function (data) { return __awaiter(void 0, void 0, vo
114
114
  }); };
115
115
  var passcodeLength = 6;
116
116
  var ConfirmByPasscode = (0, react_1.forwardRef)(function (props, ref) {
117
- var action = props.action, onConfirmSuccess = props.onConfirmSuccess;
117
+ var action = props.action, onConfirmSuccess = props.onConfirmSuccess, customAction = props.customAction;
118
118
  var theme = (0, ThemeProvider_1.useTheme)();
119
119
  var _a = (0, react_1.useState)(""), otp = _a[0], setOtp = _a[1];
120
120
  var loadingRef = (0, react_1.useRef)(null);
@@ -200,7 +200,7 @@ var ConfirmByPasscode = (0, react_1.forwardRef)(function (props, ref) {
200
200
  fontSize: theme.typography.fontSize13,
201
201
  fontWeight: theme.typography.fontWeight500,
202
202
  color: theme.palette.text.darkContrast,
203
- }, children: ["Enter your passcode to confirm ", (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { fontWeight: theme.typography.fontWeight600 }, children: action })] }), (0, jsx_runtime_1.jsx)(OTP_1.default, { value: otp, onChange: handleOtpChange, numInputs: passcodeLength, otpInputType: OTP_1.OtpInputType.PASSWORD }), !!authError && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { alignSelf: "flex-start" }), children: authError }))] }) }) }) }));
203
+ }, children: ["Enter your passcode to confirm", " ", (0, jsx_runtime_1.jsx)(Text_1.default, { sx: { fontWeight: theme.typography.fontWeight600 }, children: customAction || action })] }), (0, jsx_runtime_1.jsx)(OTP_1.default, { value: otp, onChange: handleOtpChange, numInputs: passcodeLength, otpInputType: OTP_1.OtpInputType.PASSWORD }), !!authError && ((0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.validationError), { alignSelf: "flex-start" }), children: authError }))] }) }) }) }));
204
204
  });
205
205
  ConfirmByPasscode.displayName = "ConfirmByPasscode";
206
206
  exports.default = ConfirmByPasscode;
@@ -0,0 +1,14 @@
1
+ import React, { PropsWithChildren, HTMLAttributes } from "react";
2
+ import { BUTTON_STATUS } from "../Button";
3
+ import { InstructionBody } from "../../../services/axios/instructions-service/type";
4
+ import { GeneralProps } from "../../../types/ui";
5
+ type ConfirmTransactionProps = {
6
+ transactionSlug: string;
7
+ transactionData: Omit<InstructionBody, "passcode">;
8
+ renderChildren: (props: PropsWithChildren<HTMLAttributes<HTMLElement>> & {
9
+ status: BUTTON_STATUS;
10
+ }) => React.ReactElement<any>;
11
+ onTransferSuccess?: (data: any) => void;
12
+ } & GeneralProps;
13
+ declare function ConfirmTransaction({ renderChildren, transactionSlug, transactionData, onTransferSuccess, }: ConfirmTransactionProps): import("react/jsx-runtime").JSX.Element;
14
+ export default ConfirmTransaction;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ 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);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
52
+ Object.defineProperty(exports, "__esModule", { value: true });
53
+ var jsx_runtime_1 = require("react/jsx-runtime");
54
+ var react_1 = require("react");
55
+ var ConfirmByPasscode_1 = __importDefault(require("../ConfirmByPasscode"));
56
+ var Button_1 = require("../Button");
57
+ var instructions_service_1 = __importDefault(require("../../../services/axios/instructions-service"));
58
+ function ConfirmTransaction(_a) {
59
+ var _this = this;
60
+ var renderChildren = _a.renderChildren, transactionSlug = _a.transactionSlug, transactionData = _a.transactionData, onTransferSuccess = _a.onTransferSuccess;
61
+ var _b = (0, react_1.useState)(Button_1.BUTTON_STATUS.ENABLED), buttonStatus = _b[0], setButtonStatus = _b[1];
62
+ var handleComfirmPasscode = function (passcode) { return __awaiter(_this, void 0, void 0, function () {
63
+ var response, err_1;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0:
67
+ _a.trys.push([0, 2, , 3]);
68
+ setButtonStatus(Button_1.BUTTON_STATUS.LOADING);
69
+ return [4 /*yield*/, (0, instructions_service_1.default)(__assign(__assign({}, transactionData), { passcode: passcode }))];
70
+ case 1:
71
+ response = _a.sent();
72
+ if (response.success) {
73
+ setButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
74
+ onTransferSuccess === null || onTransferSuccess === void 0 ? void 0 : onTransferSuccess(response);
75
+ }
76
+ else {
77
+ throw new Error("Send internal failed");
78
+ }
79
+ return [3 /*break*/, 3];
80
+ case 2:
81
+ err_1 = _a.sent();
82
+ console.error(err_1);
83
+ setButtonStatus(Button_1.BUTTON_STATUS.ERROR);
84
+ setTimeout(function () {
85
+ setButtonStatus(Button_1.BUTTON_STATUS.ENABLED);
86
+ }, 1200);
87
+ return [3 /*break*/, 3];
88
+ case 3: return [2 /*return*/];
89
+ }
90
+ });
91
+ }); };
92
+ return ((0, jsx_runtime_1.jsx)(ConfirmByPasscode_1.default, { customAction: transactionSlug, onConfirmSuccess: handleComfirmPasscode, children: renderChildren({ status: buttonStatus }) }));
93
+ }
94
+ exports.default = ConfirmTransaction;
@@ -1,7 +1,8 @@
1
- import { GeneralProps, UnknownFunction } from "../../../types/ui";
2
- export interface RequireConnectProps extends GeneralProps {
1
+ import { UnknownFunction } from "../../../types/ui";
2
+ import { BoxProps } from "@mui/material";
3
+ export interface RequireConnectProps extends BoxProps {
3
4
  children: React.ReactNode;
4
5
  signIn?: UnknownFunction;
5
6
  }
6
- export declare function RequireConnect({ children, signIn }: RequireConnectProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function RequireConnect({ children, signIn, component }: RequireConnectProps): import("react/jsx-runtime").JSX.Element;
7
8
  export default RequireConnect;
@@ -47,7 +47,7 @@ var material_1 = require("@mui/material");
47
47
  var AuthViewSignIn_1 = __importDefault(require("../../views/AuthViewSignIn"));
48
48
  var ChangePasscodeView_1 = __importDefault(require("../../views/ChangePasscodeView"));
49
49
  function RequireConnect(_a) {
50
- var children = _a.children, signIn = _a.signIn;
50
+ var children = _a.children, signIn = _a.signIn, component = _a.component;
51
51
  var authViewRef = (0, react_1.useRef)(null);
52
52
  var _b = (0, useWalletData_1.default)(), isInitPasscode = _b.isInitPasscode, isSSO = _b.isSSO, isAuthenticated = _b.isAuthenticated;
53
53
  var backAuthView = function () {
@@ -63,10 +63,10 @@ function RequireConnect(_a) {
63
63
  (_a = authViewRef.current) === null || _a === void 0 ? void 0 : _a.open();
64
64
  };
65
65
  if (!isAuthenticated) {
66
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { position: "relative" }, children: [children, (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { position: "absolute", inset: 0, zIndex: 10 }, onClick: handleOpenAuthView })] }), (0, jsx_runtime_1.jsxs)(DrawerComponent_1.default, { ref: authViewRef, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, onClick: stopPropagation, children: [isSSO && (0, jsx_runtime_1.jsx)(AuthViewSignIn_1.default, { onBack: backAuthView, onSignIn: signIn }), !isSSO && (0, jsx_runtime_1.jsx)(AuthView_1.default, { onBack: backAuthView })] })] }));
66
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { position: "relative" }, component: component || "div", children: [children, (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { position: "absolute", inset: 0, zIndex: 10 }, onClick: handleOpenAuthView, children: (0, jsx_runtime_1.jsxs)(DrawerComponent_1.default, { ref: authViewRef, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, onClick: stopPropagation, children: [isSSO && (0, jsx_runtime_1.jsx)(AuthViewSignIn_1.default, { onBack: backAuthView, onSignIn: signIn }), !isSSO && (0, jsx_runtime_1.jsx)(AuthView_1.default, { onBack: backAuthView })] }) })] }) }));
67
67
  }
68
68
  if (!isInitPasscode) {
69
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { position: "relative" }, children: [children, (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { position: "absolute", inset: 0, zIndex: 10 }, onClick: handleOpenAuthView })] }), (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: authViewRef, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, onClick: stopPropagation, children: (0, jsx_runtime_1.jsx)(ChangePasscodeView_1.default, { onBack: backAuthView, isInitPasscode: true }) })] }));
69
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: { position: "relative" }, component: component || "div", children: [children, (0, jsx_runtime_1.jsx)(material_1.Box, { sx: { position: "absolute", inset: 0, zIndex: 10 }, onClick: handleOpenAuthView, children: (0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: authViewRef, direction: DrawerComponent_1.DRAWER_DIRECTION.RIGHT, onClick: stopPropagation, children: (0, jsx_runtime_1.jsx)(ChangePasscodeView_1.default, { onBack: backAuthView, isInitPasscode: true }) }) })] }) }));
70
70
  }
71
71
  return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
72
72
  }
@@ -0,0 +1,3 @@
1
+ import { InstructionBody, InstructionResponse } from "./type";
2
+ declare const instructionsService: (body: InstructionBody) => Promise<InstructionResponse>;
3
+ export default instructionsService;
@@ -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 instructionsService = 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.put("/transaction/instructions", 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 = instructionsService;
@@ -0,0 +1,20 @@
1
+ export interface InstructionBody {
2
+ passcode: string;
3
+ metadata?: string;
4
+ await_completion?: boolean;
5
+ instructions: Instruction[];
6
+ order_id?: string;
7
+ }
8
+ export interface Instruction {
9
+ master_wallet_address: string;
10
+ currency_update_info: CurrencyUpdateInfo[];
11
+ }
12
+ export interface CurrencyUpdateInfo {
13
+ amount: number;
14
+ currency_slug: string;
15
+ }
16
+ export interface InstructionResponse {
17
+ success: boolean;
18
+ message: string;
19
+ timestamp: string;
20
+ }
@@ -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.618",
3
+ "version": "0.0.620",
4
4
  "description": "A custom React provider with TypeScript support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",