tek-wallet 0.0.83 → 0.0.85
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.
|
@@ -44,42 +44,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
44
|
return result;
|
|
45
45
|
};
|
|
46
46
|
})();
|
|
47
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
48
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
49
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
50
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
51
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
52
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
53
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
57
|
-
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);
|
|
58
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
59
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
60
|
-
function step(op) {
|
|
61
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
62
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
63
|
-
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;
|
|
64
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
65
|
-
switch (op[0]) {
|
|
66
|
-
case 0: case 1: t = op; break;
|
|
67
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
68
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
69
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
70
|
-
default:
|
|
71
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
72
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
73
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
74
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
75
|
-
if (t[2]) _.ops.pop();
|
|
76
|
-
_.trys.pop(); continue;
|
|
77
|
-
}
|
|
78
|
-
op = body.call(thisArg, _);
|
|
79
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
80
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
47
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
84
48
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
85
49
|
};
|
|
@@ -96,7 +60,6 @@ var react_2 = require("react");
|
|
|
96
60
|
var Text_1 = __importDefault(require("../../../components/ui/Text"));
|
|
97
61
|
var useWalletData_1 = __importDefault(require("../../../hooks/useWalletData"));
|
|
98
62
|
var material_1 = require("@mui/material");
|
|
99
|
-
var createWalletInternalService_1 = __importDefault(require("../../../services/axios/create-wallet-service/createWalletInternalService"));
|
|
100
63
|
var CreateWalletViewStep;
|
|
101
64
|
(function (CreateWalletViewStep) {
|
|
102
65
|
CreateWalletViewStep[CreateWalletViewStep["CREATE_PASSCODE"] = 0] = "CREATE_PASSCODE";
|
|
@@ -109,7 +72,7 @@ var CreateWalletView = function (props) {
|
|
|
109
72
|
var swiperControlledRef = (0, react_2.useRef)(null);
|
|
110
73
|
var childPageLayoutRef = (0, react_2.useRef)(null);
|
|
111
74
|
var _c = (0, react_2.useState)(CreateWalletViewStep.CREATE_PASSCODE), currentStep = _c[0], setCurrentStep = _c[1];
|
|
112
|
-
var
|
|
75
|
+
var createWallet = (0, useWalletData_1.default)().createWallet;
|
|
113
76
|
var gotoStep = function (step) {
|
|
114
77
|
var _a;
|
|
115
78
|
setCurrentStep(step);
|
|
@@ -150,41 +113,21 @@ var CreateWalletView = function (props) {
|
|
|
150
113
|
* validate otp here
|
|
151
114
|
*/
|
|
152
115
|
if (value.length === passcodeLength) {
|
|
153
|
-
|
|
116
|
+
createWallet({
|
|
154
117
|
passcode: value,
|
|
155
118
|
appSlug: process.env.NEXT_PUBLIC_TEK_WALLET_APP_SLUG || "",
|
|
119
|
+
}, function () {
|
|
120
|
+
var _a;
|
|
121
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showLoading();
|
|
122
|
+
}, function () {
|
|
123
|
+
var _a;
|
|
124
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showSuccess();
|
|
125
|
+
}, function () {
|
|
126
|
+
var _a;
|
|
127
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showError();
|
|
156
128
|
});
|
|
157
129
|
}
|
|
158
130
|
};
|
|
159
|
-
var handleCreateWallet = function (body) { return __awaiter(void 0, void 0, void 0, function () {
|
|
160
|
-
var delay, response;
|
|
161
|
-
var _a;
|
|
162
|
-
return __generator(this, function (_b) {
|
|
163
|
-
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showLoading();
|
|
164
|
-
delay = new Promise(function (resolve) { return setTimeout(resolve, 1000); });
|
|
165
|
-
response = (0, createWalletInternalService_1.default)(body);
|
|
166
|
-
Promise.allSettled([delay, response]).then(function (result) { return __awaiter(void 0, void 0, void 0, function () {
|
|
167
|
-
var data;
|
|
168
|
-
var _a, _b;
|
|
169
|
-
return __generator(this, function (_c) {
|
|
170
|
-
if (result[1].status === "fulfilled") {
|
|
171
|
-
data = result[1].value;
|
|
172
|
-
if (data.success) {
|
|
173
|
-
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showSuccess();
|
|
174
|
-
setTimeout(function () {
|
|
175
|
-
updateLogin();
|
|
176
|
-
}, 1000);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
(_b = childPageLayoutRef.current) === null || _b === void 0 ? void 0 : _b.showError();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return [2 /*return*/];
|
|
183
|
-
});
|
|
184
|
-
}); });
|
|
185
|
-
return [2 /*return*/];
|
|
186
|
-
});
|
|
187
|
-
}); };
|
|
188
131
|
return ((0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { ref: childPageLayoutRef, header: (0, jsx_runtime_1.jsx)(PageHeader_1.default, { overrideBack: handleBack, title: "Passcode" }), children: (0, jsx_runtime_1.jsx)(DefaultPageLayout_1.default, { sx: __assign({ display: "flex", flexDirection: "column", gap: "1rem", height: "100%" }, props.sx), children: (0, jsx_runtime_1.jsxs)(SwiperControlled_1.default, { ref: swiperControlledRef, disableSwipe: true, sx: { height: "100%" }, children: [(0, jsx_runtime_1.jsx)(react_1.SwiperSlide, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
189
132
|
display: "flex",
|
|
190
133
|
flexDirection: "column",
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
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
|
+
};
|
|
3
14
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
15
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
16
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -45,7 +56,6 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
45
56
|
var DefaultPageLayout_1 = __importDefault(require("../../../components/layouts/DefaultPageLayout"));
|
|
46
57
|
var SwiperControlled_1 = __importDefault(require("../../../components/ui/SwiperControlled"));
|
|
47
58
|
var react_1 = require("swiper/react");
|
|
48
|
-
var TheBackground_1 = __importDefault(require("../../../components/ui/TheBackground"));
|
|
49
59
|
var ChildPageLayout_1 = __importDefault(require("../../../components/layouts/ChildPageLayout"));
|
|
50
60
|
var PageHeader_1 = __importDefault(require("../../../components/ui/PageHeader"));
|
|
51
61
|
var react_2 = require("react");
|
|
@@ -96,36 +106,25 @@ var ImportWalletView = function (props) {
|
|
|
96
106
|
}
|
|
97
107
|
});
|
|
98
108
|
}); };
|
|
99
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
hFull: "100%",
|
|
115
|
-
gap: "1rem",
|
|
116
|
-
}, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
117
|
-
color: "text.white",
|
|
118
|
-
fontWeight: "500",
|
|
119
|
-
fontSize: "16px",
|
|
120
|
-
}, children: "Your seed phrase" }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
109
|
+
return ((0, jsx_runtime_1.jsx)(ChildPageLayout_1.default, { ref: childPageLayoutRef, header: (0, jsx_runtime_1.jsx)(PageHeader_1.default, { overrideBack: props.onBack, title: "Import wallet" }), children: (0, jsx_runtime_1.jsx)(DefaultPageLayout_1.default, { sx: __assign({ display: "flex", flexDirection: "column", gap: "1rem", height: "100%" }, props.sx), children: (0, jsx_runtime_1.jsx)(SwiperControlled_1.default, { ref: swiperControlledRef, disableSwipe: true, sx: { height: "100%" }, children: (0, jsx_runtime_1.jsx)(react_1.SwiperSlide, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
110
|
+
display: "flex",
|
|
111
|
+
flexDirection: "column",
|
|
112
|
+
justifyContent: "center",
|
|
113
|
+
alignItems: "center",
|
|
114
|
+
height: "100%",
|
|
115
|
+
gap: "1rem",
|
|
116
|
+
}, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
117
|
+
color: "text.white",
|
|
118
|
+
fontWeight: "500",
|
|
119
|
+
fontSize: "16px",
|
|
120
|
+
}, children: "Your seed phrase" }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
121
|
+
width: "100%",
|
|
122
|
+
height: "fit-content",
|
|
123
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.TextareaAutosize, { value: seedPhrase, onChange: handleChangeSeedPhrase, minRows: 8, maxRows: 8, placeholder: "Enter your seed phrase", style: {
|
|
121
124
|
width: "100%",
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
backgroundColor: "ui.background.primary",
|
|
127
|
-
borderRadius: "lg",
|
|
128
|
-
padding: "4px",
|
|
129
|
-
} }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { className: "text-ui-text-white font-400 text-13 text-center", children: "Your seed phrase is a list of words that are used to create your wallet. It is important to keep it safe and private." }), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { className: "w-full mt-auto", onClick: handleImportWallet, children: "Import" })] }) }) }) }) }) }));
|
|
125
|
+
backgroundColor: "ui.background.primary",
|
|
126
|
+
borderRadius: "lg",
|
|
127
|
+
padding: "1rem",
|
|
128
|
+
} }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { className: "text-ui-text-white font-400 text-13 text-center", children: "Your seed phrase is a list of words that are used to create your wallet. It is important to keep it safe and private." }), (0, jsx_runtime_1.jsx)(Button_1.default.Primary, { className: "w-full mt-auto", onClick: handleImportWallet, children: "Import" })] }) }) }) }) }));
|
|
130
129
|
};
|
|
131
130
|
exports.default = ImportWalletView;
|
|
@@ -81,6 +81,7 @@ var userClientRequest_1 = require("../../services/axios/clients/userClientReques
|
|
|
81
81
|
var getBalanceService_1 = __importDefault(require("../../services/axios/get-balance-service/getBalanceService"));
|
|
82
82
|
var loginIntenalService_2 = __importDefault(require("../../services/axios/sign-out-internal/loginIntenalService"));
|
|
83
83
|
var const_1 = require("../../handlers/const");
|
|
84
|
+
var createWalletInternalService_1 = __importDefault(require("../../services/axios/create-wallet-service/createWalletInternalService"));
|
|
84
85
|
exports.initialWalletData = {
|
|
85
86
|
isAuthenticated: false,
|
|
86
87
|
session: undefined,
|
|
@@ -92,6 +93,7 @@ exports.initialWalletData = {
|
|
|
92
93
|
},
|
|
93
94
|
updateBalance: function () { },
|
|
94
95
|
disconnect: function () { },
|
|
96
|
+
createWallet: function () { return Promise.resolve({}); },
|
|
95
97
|
};
|
|
96
98
|
exports.WalletDataContext = react_1.default.createContext(exports.initialWalletData);
|
|
97
99
|
function WalletDataProvider(_a) {
|
|
@@ -159,6 +161,40 @@ function WalletDataProvider(_a) {
|
|
|
159
161
|
}
|
|
160
162
|
});
|
|
161
163
|
}); }, []);
|
|
164
|
+
var createWallet = function (body, onStart, onSuccess, onError) { return __awaiter(_this, void 0, void 0, function () {
|
|
165
|
+
var delay, response;
|
|
166
|
+
var _this = this;
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
// childPageLayoutRef.current?.showLoading();
|
|
169
|
+
onStart === null || onStart === void 0 ? void 0 : onStart();
|
|
170
|
+
delay = new Promise(function (resolve) { return setTimeout(resolve, 1000); });
|
|
171
|
+
response = (0, createWalletInternalService_1.default)(body);
|
|
172
|
+
Promise.allSettled([delay, response]).then(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
173
|
+
var data;
|
|
174
|
+
return __generator(this, function (_a) {
|
|
175
|
+
if (result[1].status === "fulfilled") {
|
|
176
|
+
data = result[1].value;
|
|
177
|
+
if (data.success) {
|
|
178
|
+
// childPageLayoutRef.current?.showSuccess();
|
|
179
|
+
setTimeout(function () {
|
|
180
|
+
updateLogin();
|
|
181
|
+
}, 1000);
|
|
182
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
// childPageLayoutRef.current?.showError();
|
|
186
|
+
onError === null || onError === void 0 ? void 0 : onError(new Error("Create wallet failed"));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
onError === null || onError === void 0 ? void 0 : onError(new Error("Create wallet failed"));
|
|
191
|
+
}
|
|
192
|
+
return [2 /*return*/];
|
|
193
|
+
});
|
|
194
|
+
}); });
|
|
195
|
+
return [2 /*return*/, response];
|
|
196
|
+
});
|
|
197
|
+
}); };
|
|
162
198
|
var disconnect = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
163
199
|
var response, error_3;
|
|
164
200
|
return __generator(this, function (_a) {
|
|
@@ -219,6 +255,7 @@ function WalletDataProvider(_a) {
|
|
|
219
255
|
updateLogin: updateLogin,
|
|
220
256
|
updateBalance: updateBalance,
|
|
221
257
|
disconnect: disconnect,
|
|
258
|
+
createWallet: createWallet,
|
|
222
259
|
}, children: children }));
|
|
223
260
|
}
|
|
224
261
|
exports.default = WalletDataProvider;
|
|
@@ -58,6 +58,7 @@ export interface WalletProviderDataType {
|
|
|
58
58
|
updateLogin: () => void;
|
|
59
59
|
updateBalance: () => void;
|
|
60
60
|
disconnect: () => void;
|
|
61
|
+
createWallet: (body: CreateWalletServiceBody, onStart?: () => void, onSuccess?: (data?: CreateWalletServiceResponse) => void, onError?: (error?: Error) => void) => Promise<CreateWalletServiceResponse>;
|
|
61
62
|
}
|
|
62
63
|
export interface LoginInfo {
|
|
63
64
|
accessToken: string;
|