tek-wallet 0.0.190 → 0.0.191
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/DepositFunction/index.js +37 -13
- package/dist/components/ui/NetworkSelection/index.d.ts +1 -4
- package/dist/components/ui/QRCode/index.d.ts +10 -1
- package/dist/components/ui/QRCode/index.js +4 -4
- package/dist/components/ui/TokenSelection/index.d.ts +0 -11
- package/dist/components/ui/TokenSelection/index.js +10 -1
- package/dist/providers/WalletDataProvider/index.js +15 -4
- package/dist/services/axios/get-lock-tokens-list/type.d.ts +2 -2
- package/dist/services/axios/type.d.ts +2 -1
- package/dist/types/expose-type.d.ts +17 -8
- package/package.json +1 -1
|
@@ -36,6 +36,7 @@ var NetworkSelection_1 = __importDefault(require("../NetworkSelection"));
|
|
|
36
36
|
var TokenSelection_1 = __importDefault(require("../TokenSelection"));
|
|
37
37
|
var CloseModal_1 = __importDefault(require("../CloseModal"));
|
|
38
38
|
var useDepositData_1 = __importDefault(require("../../../hooks/useDepositData"));
|
|
39
|
+
var RequireConnect_1 = __importDefault(require("../RequireConnect"));
|
|
39
40
|
var DepositStep;
|
|
40
41
|
(function (DepositStep) {
|
|
41
42
|
DepositStep[DepositStep["SELECT_TOKEN"] = 1] = "SELECT_TOKEN";
|
|
@@ -54,8 +55,32 @@ var DepositFunction = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
54
55
|
var _a = (0, react_1.useState)(DepositStep.SELECT_TOKEN), currentStep = _a[0], setCurrentStep = _a[1];
|
|
55
56
|
var _b = (0, react_1.useState)(), selectedToken = _b[0], setSelectedToken = _b[1];
|
|
56
57
|
var _c = (0, react_1.useState)(), selectedNetwork = _c[0], setSelectedNetwork = _c[1];
|
|
57
|
-
var _d = (0, useWalletData_1.default)(),
|
|
58
|
+
var _d = (0, useWalletData_1.default)(), isAuthenticated = _d.isAuthenticated, blockchainWallets = _d.blockchainWallets;
|
|
58
59
|
var _e = (0, useDepositData_1.default)(), depositTokens = _e.depositTokens, updateDepositToken = _e.updateDepositToken;
|
|
60
|
+
var networks = (0, react_1.useMemo)(function () {
|
|
61
|
+
if (!selectedToken) {
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
var newNetWorks = [selectedToken.network_data];
|
|
65
|
+
var sameNetwork = newNetWorks.find(function (item) { return (item === null || item === void 0 ? void 0 : item.id) === (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.id); });
|
|
66
|
+
if (!sameNetwork) {
|
|
67
|
+
setSelectedNetwork(undefined);
|
|
68
|
+
}
|
|
69
|
+
return newNetWorks;
|
|
70
|
+
}, [selectedToken]);
|
|
71
|
+
var addressByNetwork = (0, react_1.useMemo)(function () {
|
|
72
|
+
var _a;
|
|
73
|
+
if (!blockchainWallets || !selectedNetwork) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return (_a = blockchainWallets.find(function (item) { return item.networkSlug === (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.slug); })) === null || _a === void 0 ? void 0 : _a.blockchainAddress;
|
|
77
|
+
}, [blockchainWallets, selectedNetwork]);
|
|
78
|
+
var qrCodeValue = (0, react_1.useMemo)(function () {
|
|
79
|
+
if (!addressByNetwork || !selectedToken) {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
return "ton://transfer/".concat(addressByNetwork, "?&jetton=").concat(selectedToken.address);
|
|
83
|
+
}, [addressByNetwork, selectedToken]);
|
|
59
84
|
var open = function () {
|
|
60
85
|
var _a;
|
|
61
86
|
(_a = drawerRef.current) === null || _a === void 0 ? void 0 : _a.open();
|
|
@@ -94,30 +119,29 @@ var DepositFunction = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
94
119
|
updateDepositToken();
|
|
95
120
|
}
|
|
96
121
|
}, [isAuthenticated, depositTokens]);
|
|
97
|
-
return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: drawerRef, trigger: props.children, onOpen: props.onOpen, onClose: props.onClose, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { overrideHeader: (0, jsx_runtime_1.jsx)(BackHeader_1.default, { sx: {
|
|
122
|
+
return ((0, jsx_runtime_1.jsx)(DrawerComponent_1.default, { ref: drawerRef, trigger: (0, jsx_runtime_1.jsx)(RequireConnect_1.default, { children: props.children }), onOpen: props.onOpen, onClose: props.onClose, children: (0, jsx_runtime_1.jsx)(ModalLayout_1.default, { overrideHeader: (0, jsx_runtime_1.jsx)(BackHeader_1.default, { sx: {
|
|
98
123
|
width: "100%",
|
|
99
124
|
paddingBottom: theme.mixins.customPadding.p16,
|
|
100
125
|
display: "flex",
|
|
101
126
|
alignItems: "center",
|
|
102
|
-
}, overrideBack: handleBack, hideBack: currentStep === DepositStep.SELECT_TOKEN, center: DEPOSIT_STEP_NAME[currentStep], children: (0, jsx_runtime_1.jsx)(CloseModal_1.default, { sx: { marginLeft: "auto" }, onClick: props.onClose }) }), onClose: close, children: (0, jsx_runtime_1.jsxs)(SwiperControlled_1.default, { ref: swiperRef, swiperProps: { autoHeight: true, spaceBetween: 32 }, children: [(0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, height: "fit-content" }), children:
|
|
103
|
-
var stringifiedTokenData = JSON.stringify(
|
|
104
|
-
return ((0, jsx_runtime_1.jsx)(TokenSelection_1.default, { onClick: handleSelectToken, tokenData: stringifiedTokenData, active: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.id)
|
|
105
|
-
}) }) }, DepositStep.SELECT_TOKEN), (0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children:
|
|
106
|
-
return ((0, jsx_runtime_1.jsx)(NetworkSelection_1.default, { onClick: handleSelectNetwork, networkData: JSON.stringify(
|
|
107
|
-
name: "network ".concat(item.id),
|
|
108
|
-
icon: "https://via.placeholder.com/150",
|
|
109
|
-
}) }, item.id));
|
|
127
|
+
}, overrideBack: handleBack, hideBack: currentStep === DepositStep.SELECT_TOKEN, center: DEPOSIT_STEP_NAME[currentStep], children: (0, jsx_runtime_1.jsx)(CloseModal_1.default, { sx: { marginLeft: "auto" }, onClick: props.onClose }) }), onClose: close, children: (0, jsx_runtime_1.jsxs)(SwiperControlled_1.default, { ref: swiperRef, swiperProps: { autoHeight: true, spaceBetween: 32 }, children: [(0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12, height: "fit-content" }), children: depositTokens === null || depositTokens === void 0 ? void 0 : depositTokens.map(function (item) {
|
|
128
|
+
var stringifiedTokenData = JSON.stringify(item);
|
|
129
|
+
return ((0, jsx_runtime_1.jsx)(TokenSelection_1.default, { onClick: handleSelectToken, tokenData: stringifiedTokenData, active: (selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.id) === item.id }, item.id));
|
|
130
|
+
}) }) }, DepositStep.SELECT_TOKEN), (0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g12 }), children: networks === null || networks === void 0 ? void 0 : networks.map(function (item) {
|
|
131
|
+
return ((0, jsx_runtime_1.jsx)(NetworkSelection_1.default, { onClick: handleSelectNetwork, networkData: JSON.stringify(item), active: (selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.id) === item.id }, item.id));
|
|
110
132
|
}) }) }, DepositStep.SELECT_NETWORK), (0, jsx_runtime_1.jsx)(react_2.SwiperSlide, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: {
|
|
111
133
|
display: "flex",
|
|
112
134
|
flexDirection: "column",
|
|
113
135
|
gap: theme.mixins.gaps.g16,
|
|
114
|
-
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({ width: "100%" }, theme.mixins.column), { gap: theme.mixins.gaps.g12, backgroundColor: theme.palette.background.black24, borderRadius: theme.mixins.theBorderRadius.r16, padding: theme.mixins.customPadding.p16, alignItems: "flex-start", backdropFilter: "blur(10px)" }), id: "share-deposit-info", children: [(0, jsx_runtime_1.
|
|
136
|
+
}, children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({ width: "100%" }, theme.mixins.column), { gap: theme.mixins.gaps.g12, backgroundColor: theme.palette.background.black24, borderRadius: theme.mixins.theBorderRadius.r16, padding: theme.mixins.customPadding.p16, alignItems: "flex-start", backdropFilter: "blur(10px)" }), id: "share-deposit-info", children: [(0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
|
|
115
137
|
width: "fit-content",
|
|
116
138
|
height: "fit-content",
|
|
117
139
|
alignSelf: "center",
|
|
118
140
|
borderRadius: theme.mixins.theBorderRadius.r12,
|
|
119
141
|
overflow: "hidden",
|
|
120
|
-
}, children: (0, jsx_runtime_1.jsx)(QRCode_1.default, {
|
|
142
|
+
}, children: (0, jsx_runtime_1.jsx)(QRCode_1.default, { value: qrCodeValue, title: "Deposit ".concat(selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name), logo: (0, getIcon_1.default)("ton") }) }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g4, color: "text.white" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: "Network" }), (0, jsx_runtime_1.jsxs)(material_1.Box, { component: "button", sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g2, cursor: "pointer", transition: "transform 0.3s ease-in-out", "&:active": {
|
|
143
|
+
transform: "translateX(0.5rem)",
|
|
144
|
+
} }), onClick: handleBack, children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.value), children: selectedNetwork === null || selectedNetwork === void 0 ? void 0 : selectedNetwork.name }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("right_arrow"), width: 10 })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g4, color: "text.white" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: "Address" }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: __assign(__assign({}, theme.mixins.value), { wordBreak: "break-all" }), children: addressByNetwork })] }), (0, jsx_runtime_1.jsx)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { gap: theme.mixins.gaps.g4, backgroundColor: theme.palette.background.white16, borderRadius: theme.mixins.theBorderRadius.r12, padding: theme.mixins.customPadding.p8 }), children: (0, jsx_runtime_1.jsxs)(Text_1.default, { sx: __assign({}, theme.mixins.valueDescription), children: ["Deposit", " ", (0, jsx_runtime_1.jsxs)("strong", { children: ["min ", selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.min_value, " ", selectedToken === null || selectedToken === void 0 ? void 0 : selectedToken.name] }), " ", "and ", (0, jsx_runtime_1.jsx)("strong", { children: "select the correct network" }), ", or you will lose your assets."] }) })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g12, justifyContent: "center" }), children: [(0, jsx_runtime_1.jsx)(CopyTextComponent_1.default, { value: qrCodeValue, children: (0, jsx_runtime_1.jsxs)(Button_1.default.Secondary, { className: "gap-1.5 flex items-center", children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: {
|
|
121
145
|
fontSize: theme.typography.fontSize12,
|
|
122
146
|
fontWeight: theme.typography.fontWeight400,
|
|
123
147
|
leading: "typography.leading150",
|
|
@@ -127,7 +151,7 @@ var DepositFunction = (0, react_1.forwardRef)(function (props, ref) {
|
|
|
127
151
|
fontWeight: theme.typography.fontWeight400,
|
|
128
152
|
leading: "typography.leading150",
|
|
129
153
|
textTransform: "capitalize",
|
|
130
|
-
}, children: "Share" }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("share"), width: 20 })] }) })] })] }) }, DepositStep.SHOW_QR_CODE)] },
|
|
154
|
+
}, children: "Share" }), (0, jsx_runtime_1.jsx)(Icon_1.default, { src: (0, getIcon_1.default)("share"), width: 20 })] }) })] })] }) }, DepositStep.SHOW_QR_CODE)] }, depositTokens === null || depositTokens === void 0 ? void 0 : depositTokens.length) }) }));
|
|
131
155
|
});
|
|
132
156
|
DepositFunction.displayName = "DepositFunction";
|
|
133
157
|
exports.default = DepositFunction;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { GeneralProps } from "../../../types/ui";
|
|
2
|
+
import { NetworkData } from "../../../services/axios/type";
|
|
2
3
|
interface NetworkSelectionProps extends GeneralProps {
|
|
3
4
|
active?: boolean;
|
|
4
5
|
networkData?: string;
|
|
5
6
|
onClick?: (networkData?: NetworkData) => void;
|
|
6
7
|
}
|
|
7
|
-
export interface NetworkData {
|
|
8
|
-
name: string;
|
|
9
|
-
icon: string;
|
|
10
|
-
}
|
|
11
8
|
declare const NetworkSelection: (props: NetworkSelectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
9
|
export default NetworkSelection;
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { GeneralProps } from "../../../types/ui";
|
|
2
|
+
interface QRCodeProps extends GeneralProps {
|
|
3
|
+
value: string;
|
|
4
|
+
size?: number;
|
|
5
|
+
bgColor?: string;
|
|
6
|
+
fgColor?: string;
|
|
7
|
+
logo?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
}
|
|
10
|
+
declare function QRCode(props: QRCodeProps): import("react/jsx-runtime").JSX.Element;
|
|
2
11
|
export default QRCode;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
4
|
var qrcode_react_1 = require("qrcode.react");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeCanvas, { value:
|
|
8
|
-
src: "
|
|
5
|
+
function QRCode(props) {
|
|
6
|
+
var value = props.value, _a = props.size, size = _a === void 0 ? 156 : _a, logo = props.logo, title = props.title;
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(qrcode_react_1.QRCodeCanvas, { value: value, title: title, size: size, bgColor: "#ffffff", fgColor: "#000000", level: "H", minVersion: 8, marginSize: 6, imageSettings: {
|
|
8
|
+
src: logo || "",
|
|
9
9
|
x: undefined,
|
|
10
10
|
y: undefined,
|
|
11
11
|
height: 24,
|
|
@@ -1,18 +1,7 @@
|
|
|
1
1
|
import { GeneralProps } from "../../../types/ui";
|
|
2
|
-
import { Balance } from "../../../types/expose-type";
|
|
3
2
|
interface TokenSelectionProps extends GeneralProps {
|
|
4
3
|
tokenData?: string;
|
|
5
4
|
active?: boolean;
|
|
6
5
|
}
|
|
7
|
-
export interface TokenState {
|
|
8
|
-
tokens?: Balance[];
|
|
9
|
-
}
|
|
10
|
-
export interface TokenData {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
symbol: string;
|
|
14
|
-
decimals: number;
|
|
15
|
-
balance: string;
|
|
16
|
-
}
|
|
17
6
|
declare const TokenSelection: (props: TokenSelectionProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
7
|
export default TokenSelection;
|
|
@@ -36,8 +36,17 @@ var TokenSelection = function (props) {
|
|
|
36
36
|
var tokenDataString = props.tokenData, sx = props.sx, rest = __rest(props, ["tokenData", "sx"]);
|
|
37
37
|
var theme = (0, material_1.useTheme)();
|
|
38
38
|
var tokenData = (0, react_1.useMemo)(function () { return (0, parsePropsData_1.default)(tokenDataString); }, [tokenDataString]);
|
|
39
|
+
var balance = (0, react_1.useMemo)(function () {
|
|
40
|
+
var _a;
|
|
41
|
+
console.warn("calculate balance", tokenData === null || tokenData === void 0 ? void 0 : tokenData.balance);
|
|
42
|
+
return +((_a = tokenData === null || tokenData === void 0 ? void 0 : tokenData.balance) !== null && _a !== void 0 ? _a : 0);
|
|
43
|
+
}, [tokenData]);
|
|
44
|
+
var balanceInUSD = (0, react_1.useMemo)(function () {
|
|
45
|
+
var _a;
|
|
46
|
+
return balance * +((_a = tokenData === null || tokenData === void 0 ? void 0 : tokenData.usd_rate) !== null && _a !== void 0 ? _a : 0);
|
|
47
|
+
}, [balance, tokenData]);
|
|
39
48
|
return ((0, jsx_runtime_1.jsxs)(material_1.Box, __assign({ onClick: function () { var _a; return (_a = props === null || props === void 0 ? void 0 : props.onClick) === null || _a === void 0 ? void 0 : _a.call(props, tokenData); }, sx: __assign({ backgroundColor: props.active
|
|
40
49
|
? "background.secondary16"
|
|
41
|
-
: "background.white16", border: "1px solid", borderColor: props.active ? "border.secondary" : "transparent", borderRadius: theme.mixins.theBorderRadius.r16, padding: theme.mixins.customPadding.p12, display: "flex", alignItems: "center", cursor: "pointer" }, sx) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { width: 20 }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.column), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.value, children: tokenData === null || tokenData === void 0 ? void 0 : tokenData.name }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.valueDescription, children:
|
|
50
|
+
: "background.white16", border: "1px solid", borderColor: props.active ? "border.secondary" : "transparent", borderRadius: theme.mixins.theBorderRadius.r16, padding: theme.mixins.customPadding.p12, display: "flex", alignItems: "center", cursor: "pointer" }, sx) }, rest, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.row), { gap: theme.mixins.gaps.g12 }), children: [(0, jsx_runtime_1.jsx)(Icon_1.default, { width: 20, src: tokenData === null || tokenData === void 0 ? void 0 : tokenData.icon }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign({}, theme.mixins.column), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.value, children: tokenData === null || tokenData === void 0 ? void 0 : tokenData.name }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.valueDescription, children: tokenData === null || tokenData === void 0 ? void 0 : tokenData.full_name })] })] }), (0, jsx_runtime_1.jsxs)(material_1.Box, { sx: __assign(__assign({}, theme.mixins.column), { marginLeft: "auto", alignItems: "end" }), children: [(0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.value, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: balance }) }), (0, jsx_runtime_1.jsx)(Text_1.default, { sx: theme.mixins.valueDescription, children: (0, jsx_runtime_1.jsx)(Formatter_1.default, { value: balanceInUSD, start: "~ $" }) })] })] })));
|
|
42
51
|
};
|
|
43
52
|
exports.default = TokenSelection;
|
|
@@ -90,8 +90,10 @@ exports.initialWalletData = {
|
|
|
90
90
|
isAuthLoading: true,
|
|
91
91
|
tokens: undefined,
|
|
92
92
|
isTokensLoading: true,
|
|
93
|
+
masterWallet: undefined,
|
|
94
|
+
blockchainWallets: undefined,
|
|
93
95
|
updateLogin: function () { },
|
|
94
|
-
|
|
96
|
+
updateWalletDetail: function () { },
|
|
95
97
|
disconnect: function () { },
|
|
96
98
|
createWallet: function () { return Promise.resolve({}); },
|
|
97
99
|
importWallet: function () { return Promise.resolve({}); },
|
|
@@ -106,6 +108,8 @@ function WalletDataProvider(_a) {
|
|
|
106
108
|
var _d = react_1.default.useState(false), isAuthLoading = _d[0], setIsAuthLoading = _d[1];
|
|
107
109
|
var _e = react_1.default.useState(false), isTokensLoading = _e[0], setIsTokensLoading = _e[1];
|
|
108
110
|
var _f = react_1.default.useState(undefined), tokens = _f[0], setTokens = _f[1];
|
|
111
|
+
var _g = react_1.default.useState(undefined), masterWallet = _g[0], setMasterWallet = _g[1];
|
|
112
|
+
var _h = react_1.default.useState(undefined), blockchainWallets = _h[0], setBlockchainWallets = _h[1];
|
|
109
113
|
var timeout = react_1.default.useRef(undefined);
|
|
110
114
|
var updateLogin = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
111
115
|
var response, error_1;
|
|
@@ -140,7 +144,7 @@ function WalletDataProvider(_a) {
|
|
|
140
144
|
}
|
|
141
145
|
});
|
|
142
146
|
}); }, []);
|
|
143
|
-
var
|
|
147
|
+
var updateWalletDetail = (0, react_1.useCallback)(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
144
148
|
var response, error_2;
|
|
145
149
|
return __generator(this, function (_a) {
|
|
146
150
|
switch (_a.label) {
|
|
@@ -152,6 +156,11 @@ function WalletDataProvider(_a) {
|
|
|
152
156
|
response = _a.sent();
|
|
153
157
|
console.warn("🚀 ~ getBalance ~ response:", response);
|
|
154
158
|
setTokens(response === null || response === void 0 ? void 0 : response.balances);
|
|
159
|
+
setMasterWallet(response === null || response === void 0 ? void 0 : response.address);
|
|
160
|
+
setBlockchainWallets(response === null || response === void 0 ? void 0 : response.blockchain_wallets.map(function (item) { return ({
|
|
161
|
+
blockchainAddress: item.blockchain_address,
|
|
162
|
+
networkSlug: item.network_slug,
|
|
163
|
+
}); }));
|
|
155
164
|
setIsTokensLoading(false);
|
|
156
165
|
return [3 /*break*/, 3];
|
|
157
166
|
case 2:
|
|
@@ -280,7 +289,7 @@ function WalletDataProvider(_a) {
|
|
|
280
289
|
}); }, []);
|
|
281
290
|
react_1.default.useEffect(function () {
|
|
282
291
|
if (isAuthenticated) {
|
|
283
|
-
|
|
292
|
+
updateWalletDetail();
|
|
284
293
|
}
|
|
285
294
|
else {
|
|
286
295
|
setTokens(undefined);
|
|
@@ -308,8 +317,10 @@ function WalletDataProvider(_a) {
|
|
|
308
317
|
isAuthLoading: isAuthLoading,
|
|
309
318
|
tokens: tokens,
|
|
310
319
|
isTokensLoading: isTokensLoading,
|
|
320
|
+
masterWallet: masterWallet,
|
|
321
|
+
blockchainWallets: blockchainWallets,
|
|
311
322
|
updateLogin: updateLogin,
|
|
312
|
-
|
|
323
|
+
updateWalletDetail: updateWalletDetail,
|
|
313
324
|
disconnect: disconnect,
|
|
314
325
|
createWallet: createWallet,
|
|
315
326
|
importWallet: importWallet,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Paginated,
|
|
1
|
+
import { Paginated, NetworkData } from "../type";
|
|
2
2
|
export interface LockCurrency {
|
|
3
3
|
id: number;
|
|
4
4
|
status: string;
|
|
@@ -14,7 +14,7 @@ export interface LockCurrency {
|
|
|
14
14
|
icon: string;
|
|
15
15
|
usd_rate: string;
|
|
16
16
|
icon_svg: string;
|
|
17
|
-
network_data:
|
|
17
|
+
network_data: NetworkData;
|
|
18
18
|
balance: string;
|
|
19
19
|
min_value: number;
|
|
20
20
|
max_value: number;
|
|
@@ -11,10 +11,11 @@ export interface Paginated {
|
|
|
11
11
|
has_prev: boolean;
|
|
12
12
|
has_next: boolean;
|
|
13
13
|
}
|
|
14
|
-
export interface
|
|
14
|
+
export interface NetworkData {
|
|
15
15
|
id: number;
|
|
16
16
|
status: string;
|
|
17
17
|
name: string;
|
|
18
18
|
slug: string;
|
|
19
19
|
network_type: string;
|
|
20
|
+
icon: string;
|
|
20
21
|
}
|
|
@@ -55,8 +55,10 @@ export interface WalletProviderDataType {
|
|
|
55
55
|
isAuthLoading: boolean | undefined;
|
|
56
56
|
tokens: Balance[] | undefined;
|
|
57
57
|
isTokensLoading: boolean | undefined;
|
|
58
|
+
masterWallet: string | undefined;
|
|
59
|
+
blockchainWallets: BlockchainWalletType[] | undefined;
|
|
58
60
|
updateLogin: () => void;
|
|
59
|
-
|
|
61
|
+
updateWalletDetail: () => void;
|
|
60
62
|
disconnect: () => void;
|
|
61
63
|
createWallet: (body: CreateWalletServiceBody, onStart?: () => void, onSuccess?: (data?: CreateWalletServiceResponse) => void, onError?: (error?: Error) => void) => Promise<CreateWalletServiceResponse>;
|
|
62
64
|
importWallet: (body: ImportWalletServiceBody, onStart?: () => void, onSuccess?: (data?: ImportWalletServiceResponse) => void, onError?: (error?: Error) => void) => Promise<ImportWalletServiceResponse>;
|
|
@@ -102,6 +104,10 @@ export interface BlockchainWallet {
|
|
|
102
104
|
blockchain_address: string;
|
|
103
105
|
network_slug: string;
|
|
104
106
|
}
|
|
107
|
+
export interface BlockchainWalletType {
|
|
108
|
+
blockchainAddress: string;
|
|
109
|
+
networkSlug: string;
|
|
110
|
+
}
|
|
105
111
|
export interface Balance {
|
|
106
112
|
id: string;
|
|
107
113
|
master_wallet_id: string;
|
|
@@ -190,6 +196,15 @@ export interface DepositCurrency {
|
|
|
190
196
|
icon_svg: string;
|
|
191
197
|
network_data: Networkdata;
|
|
192
198
|
balance: string;
|
|
199
|
+
min_value: number;
|
|
200
|
+
max_value: number;
|
|
201
|
+
}
|
|
202
|
+
interface Networkdata {
|
|
203
|
+
id: number;
|
|
204
|
+
status: string;
|
|
205
|
+
name: string;
|
|
206
|
+
slug: string;
|
|
207
|
+
network_type: string;
|
|
193
208
|
}
|
|
194
209
|
export interface Paginated {
|
|
195
210
|
keyword: string;
|
|
@@ -204,10 +219,4 @@ export interface Paginated {
|
|
|
204
219
|
has_prev: boolean;
|
|
205
220
|
has_next: boolean;
|
|
206
221
|
}
|
|
207
|
-
export
|
|
208
|
-
id: number;
|
|
209
|
-
status: string;
|
|
210
|
-
name: string;
|
|
211
|
-
slug: string;
|
|
212
|
-
network_type: string;
|
|
213
|
-
}
|
|
222
|
+
export {};
|