tek-wallet 0.0.84 → 0.0.87
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.
- package/dist/components/ui/Image/index.js +12 -3
- package/dist/components/ui/StatusDisplay/index.js +1 -1
- package/dist/components/views/CreateWalletView/index.js +9 -4
- package/dist/components/views/ImportWalletView/index.js +49 -50
- package/dist/providers/WalletDataProvider/index.js +35 -2
- package/dist/types/expose-type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,10 +1,19 @@
|
|
|
1
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
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
15
|
var system_1 = require("@mui/system");
|
|
5
|
-
var StyledImage = (0, system_1.styled)("img")(function () { return ({
|
|
6
|
-
display: "block",
|
|
7
|
-
}); });
|
|
16
|
+
var StyledImage = (0, system_1.styled)("img")(function (sx) { return (__assign({ display: "block" }, sx)); });
|
|
8
17
|
var Image = function (props) {
|
|
9
18
|
return ((0, jsx_runtime_1.jsx)(StyledImage, { onClick: props.onClick, src: props.src, alt: props.alt, sx: props.sx }));
|
|
10
19
|
};
|
|
@@ -20,7 +20,7 @@ var StatusDisplayType;
|
|
|
20
20
|
StatusDisplayType["Normal"] = "normal";
|
|
21
21
|
})(StatusDisplayType || (exports.StatusDisplayType = StatusDisplayType = {}));
|
|
22
22
|
var StatusDisplay = function (props) {
|
|
23
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.default)("flex items-center gap-1", props.className), children: [(0, jsx_runtime_1.jsx)(Image_1.default, { src: (0, getIcon_1.default)("status_".concat(props.status), "gif"),
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.default)("flex items-center gap-1", props.className), children: [(0, jsx_runtime_1.jsx)(Image_1.default, { src: (0, getIcon_1.default)("status_".concat(props.status), "gif"), sx: { width: "1.5rem", height: "1.5rem" } }), (0, jsx_runtime_1.jsx)(Text_1.default, { className: (0, clsx_1.default)("text-13", {
|
|
24
24
|
"text-ui-text-error": props.status === StatusDisplayType.Error,
|
|
25
25
|
"text-ui-text-warning": props.status === StatusDisplayType.Warning,
|
|
26
26
|
"text-ui-text-success": props.status === StatusDisplayType.Success,
|
|
@@ -107,6 +107,14 @@ var CreateWalletView = function (props) {
|
|
|
107
107
|
gotoStep(CreateWalletViewStep.CONFIRM_PASSCODE);
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
+
var handleCreateWalletError = function () {
|
|
111
|
+
var _a;
|
|
112
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showError();
|
|
113
|
+
setTimeout(function () {
|
|
114
|
+
var _a;
|
|
115
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showNormal();
|
|
116
|
+
}, 1500);
|
|
117
|
+
};
|
|
110
118
|
var handleConfirmOtpChange = function (value) {
|
|
111
119
|
setConfirmOtp(value);
|
|
112
120
|
/**
|
|
@@ -122,10 +130,7 @@ var CreateWalletView = function (props) {
|
|
|
122
130
|
}, function () {
|
|
123
131
|
var _a;
|
|
124
132
|
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showSuccess();
|
|
125
|
-
},
|
|
126
|
-
var _a;
|
|
127
|
-
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showError();
|
|
128
|
-
});
|
|
133
|
+
}, handleCreateWalletError);
|
|
129
134
|
}
|
|
130
135
|
};
|
|
131
136
|
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: {
|
|
@@ -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,14 +56,13 @@ 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");
|
|
52
62
|
var Text_1 = __importDefault(require("../../../components/ui/Text"));
|
|
53
63
|
var Button_1 = __importDefault(require("../../ui/Button"));
|
|
54
|
-
var importWalletIntenalService_1 = __importDefault(require("../../../services/axios/import-wallet-service/importWalletIntenalService"));
|
|
55
64
|
var material_1 = require("@mui/material");
|
|
65
|
+
var useWalletData_1 = __importDefault(require("../../../hooks/useWalletData"));
|
|
56
66
|
var ImportWalletViewStep;
|
|
57
67
|
(function (ImportWalletViewStep) {
|
|
58
68
|
ImportWalletViewStep[ImportWalletViewStep["CREATE_PASSCODE"] = 0] = "CREATE_PASSCODE";
|
|
@@ -62,70 +72,59 @@ var ImportWalletView = function (props) {
|
|
|
62
72
|
var _a = (0, react_2.useState)(""), seedPhrase = _a[0], setSeedPhrase = _a[1];
|
|
63
73
|
var swiperControlledRef = (0, react_2.useRef)(null);
|
|
64
74
|
var childPageLayoutRef = (0, react_2.useRef)(null);
|
|
75
|
+
var importWallet = (0, useWalletData_1.default)().importWallet;
|
|
65
76
|
var handleChangeSeedPhrase = function (event) {
|
|
66
77
|
setSeedPhrase(event.target.value);
|
|
67
78
|
};
|
|
79
|
+
var handleImportWalletError = function () {
|
|
80
|
+
var _a;
|
|
81
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showError();
|
|
82
|
+
setTimeout(function () {
|
|
83
|
+
var _a;
|
|
84
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showNormal();
|
|
85
|
+
}, 1500);
|
|
86
|
+
};
|
|
68
87
|
var handleImportWallet = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
-
var delay, response;
|
|
70
88
|
var _a;
|
|
71
89
|
return __generator(this, function (_b) {
|
|
72
90
|
switch (_b.label) {
|
|
73
91
|
case 0:
|
|
74
92
|
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showLoading();
|
|
75
|
-
|
|
76
|
-
return [4 /*yield*/, (0, importWalletIntenalService_1.default)({
|
|
93
|
+
return [4 /*yield*/, importWallet({
|
|
77
94
|
seed_pharse: seedPhrase,
|
|
78
95
|
app_slugs: [process.env.NEXT_PUBLIC_TEK_WALLET_APP_SLUG || ""],
|
|
79
|
-
})
|
|
96
|
+
}, function () {
|
|
97
|
+
var _a;
|
|
98
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showLoading();
|
|
99
|
+
}, function () {
|
|
100
|
+
var _a;
|
|
101
|
+
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showSuccess();
|
|
102
|
+
}, handleImportWalletError)];
|
|
80
103
|
case 1:
|
|
81
|
-
|
|
82
|
-
Promise.allSettled([delay, response]).then(function (result) { return __awaiter(void 0, void 0, void 0, function () {
|
|
83
|
-
var data;
|
|
84
|
-
var _a;
|
|
85
|
-
return __generator(this, function (_b) {
|
|
86
|
-
if (result[1].status === "fulfilled") {
|
|
87
|
-
data = result[1].value;
|
|
88
|
-
if (!(data === null || data === void 0 ? void 0 : data.success)) {
|
|
89
|
-
(_a = childPageLayoutRef.current) === null || _a === void 0 ? void 0 : _a.showError();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return [2 /*return*/];
|
|
93
|
-
});
|
|
94
|
-
}); });
|
|
104
|
+
_b.sent();
|
|
95
105
|
return [2 /*return*/];
|
|
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
|
-
justifyContent: "center",
|
|
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
|
+
alignItems: "center",
|
|
113
|
+
height: "100%",
|
|
114
|
+
gap: "1rem",
|
|
115
|
+
}, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
116
|
+
color: "text.white",
|
|
117
|
+
fontWeight: "500",
|
|
118
|
+
fontSize: "16px",
|
|
119
|
+
}, children: "Your seed phrase" }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
120
|
+
width: "100%",
|
|
121
|
+
height: "fit-content",
|
|
122
|
+
}, children: (0, jsx_runtime_1.jsx)(material_1.TextareaAutosize, { value: seedPhrase, onChange: handleChangeSeedPhrase, minRows: 8, maxRows: 8, placeholder: "Enter your seed phrase", style: {
|
|
121
123
|
width: "100%",
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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" })] }) }) }) }) }) }));
|
|
124
|
+
backgroundColor: "ui.background.primary",
|
|
125
|
+
borderRadius: "lg",
|
|
126
|
+
padding: "1rem",
|
|
127
|
+
color: "text.white",
|
|
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, { sx: { width: "100%", marginTop: "auto" }, onClick: handleImportWallet, children: "Import" })] }) }) }) }) }));
|
|
130
129
|
};
|
|
131
130
|
exports.default = ImportWalletView;
|
|
@@ -82,6 +82,7 @@ var getBalanceService_1 = __importDefault(require("../../services/axios/get-bala
|
|
|
82
82
|
var loginIntenalService_2 = __importDefault(require("../../services/axios/sign-out-internal/loginIntenalService"));
|
|
83
83
|
var const_1 = require("../../handlers/const");
|
|
84
84
|
var createWalletInternalService_1 = __importDefault(require("../../services/axios/create-wallet-service/createWalletInternalService"));
|
|
85
|
+
var importWalletIntenalService_1 = __importDefault(require("../../services/axios/import-wallet-service/importWalletIntenalService"));
|
|
85
86
|
exports.initialWalletData = {
|
|
86
87
|
isAuthenticated: false,
|
|
87
88
|
session: undefined,
|
|
@@ -94,6 +95,7 @@ exports.initialWalletData = {
|
|
|
94
95
|
updateBalance: function () { },
|
|
95
96
|
disconnect: function () { },
|
|
96
97
|
createWallet: function () { return Promise.resolve({}); },
|
|
98
|
+
importWallet: function () { return Promise.resolve({}); },
|
|
97
99
|
};
|
|
98
100
|
exports.WalletDataContext = react_1.default.createContext(exports.initialWalletData);
|
|
99
101
|
function WalletDataProvider(_a) {
|
|
@@ -175,14 +177,44 @@ function WalletDataProvider(_a) {
|
|
|
175
177
|
if (result[1].status === "fulfilled") {
|
|
176
178
|
data = result[1].value;
|
|
177
179
|
if (data.success) {
|
|
178
|
-
// childPageLayoutRef.current?.showSuccess();
|
|
179
180
|
setTimeout(function () {
|
|
180
181
|
updateLogin();
|
|
181
182
|
}, 1000);
|
|
182
183
|
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
183
184
|
}
|
|
184
185
|
else {
|
|
185
|
-
|
|
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
|
+
}); };
|
|
198
|
+
var importWallet = function (body, onStart, onSuccess, onError) { return __awaiter(_this, void 0, void 0, function () {
|
|
199
|
+
var delay, response;
|
|
200
|
+
var _this = this;
|
|
201
|
+
return __generator(this, function (_a) {
|
|
202
|
+
// childPageLayoutRef.current?.showLoading();
|
|
203
|
+
onStart === null || onStart === void 0 ? void 0 : onStart();
|
|
204
|
+
delay = new Promise(function (resolve) { return setTimeout(resolve, 1000); });
|
|
205
|
+
response = (0, importWalletIntenalService_1.default)(body);
|
|
206
|
+
Promise.allSettled([delay, response]).then(function (result) { return __awaiter(_this, void 0, void 0, function () {
|
|
207
|
+
var data;
|
|
208
|
+
return __generator(this, function (_a) {
|
|
209
|
+
if (result[1].status === "fulfilled") {
|
|
210
|
+
data = result[1].value;
|
|
211
|
+
if (data.success) {
|
|
212
|
+
setTimeout(function () {
|
|
213
|
+
updateLogin();
|
|
214
|
+
}, 1000);
|
|
215
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
186
218
|
onError === null || onError === void 0 ? void 0 : onError(new Error("Create wallet failed"));
|
|
187
219
|
}
|
|
188
220
|
}
|
|
@@ -256,6 +288,7 @@ function WalletDataProvider(_a) {
|
|
|
256
288
|
updateBalance: updateBalance,
|
|
257
289
|
disconnect: disconnect,
|
|
258
290
|
createWallet: createWallet,
|
|
291
|
+
importWallet: importWallet,
|
|
259
292
|
}, children: children }));
|
|
260
293
|
}
|
|
261
294
|
exports.default = WalletDataProvider;
|
|
@@ -59,6 +59,7 @@ export interface WalletProviderDataType {
|
|
|
59
59
|
updateBalance: () => void;
|
|
60
60
|
disconnect: () => void;
|
|
61
61
|
createWallet: (body: CreateWalletServiceBody, onStart?: () => void, onSuccess?: (data?: CreateWalletServiceResponse) => void, onError?: (error?: Error) => void) => Promise<CreateWalletServiceResponse>;
|
|
62
|
+
importWallet: (body: importWalletServiceBody, onStart?: () => void, onSuccess?: (data?: ImportWalletServiceResponse) => void, onError?: (error?: Error) => void) => Promise<ImportWalletServiceResponse>;
|
|
62
63
|
}
|
|
63
64
|
export interface LoginInfo {
|
|
64
65
|
accessToken: string;
|