From 824c8135da1f3108a71c5248616a2d86549214cb Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Thu, 7 Dec 2023 18:50:30 +0200 Subject: [PATCH 1/4] feature: pool validation --- src/components/tools/ExportPrivateKeyModal.js | 2 +- src/components/tools/ProxyConfigPanel.js | 229 ++++++++++++++++++ .../tools/RevealSecretPhraseModal.js | 7 +- src/components/tools/Tools.js | 229 ++---------------- src/components/tools/common.js | 57 +++++ 5 files changed, 312 insertions(+), 212 deletions(-) create mode 100644 src/components/tools/ProxyConfigPanel.js create mode 100644 src/components/tools/common.js diff --git a/src/components/tools/ExportPrivateKeyModal.js b/src/components/tools/ExportPrivateKeyModal.js index 676fa855..9d77a85e 100644 --- a/src/components/tools/ExportPrivateKeyModal.js +++ b/src/components/tools/ExportPrivateKeyModal.js @@ -10,8 +10,8 @@ import { ConfirmBtn, Row } from './ConfirmModal.styles'; -import { Input } from './Tools'; import { useState } from 'react'; +import { Input } from './common'; const PrivateKey = styled.div` word-break: break-word; diff --git a/src/components/tools/ProxyConfigPanel.js b/src/components/tools/ProxyConfigPanel.js new file mode 100644 index 00000000..e52c9859 --- /dev/null +++ b/src/components/tools/ProxyConfigPanel.js @@ -0,0 +1,229 @@ +//ts-check + +import React, { useState } from 'react'; +import { Sp } from '../common'; +import Spinner from '../common/Spinner'; +import ConfirmProxyConfigModal from './ConfirmProxyConfigModal'; +import { generatePoolUrl } from '../../utils'; +import { validatePoolAddress } from '../../store/validators'; + +import 'react-tabs/style/react-tabs.css'; +import './styles.css'; + +import { + ErrorLabel, + StyledBtn, + Subtitle, + StyledParagraph, + Input +} from './common'; + +function RemoteProxyConfig() { + return ( + + You are running Wallet wihout Proxy-Router. Reset wallet to setup + validator node. + + ); +} + +function TitanLightningProxyPanel(props) { + const { titanLightningDashboard, sellerPoolParts } = props; + return ( + <> + +
+ Titan Lightning Address: {sellerPoolParts?.account}{' '} +
+

{ + window.open(titanLightningDashboard, '_blank'); + }} + > + Dashboard for Lightning users +

+
+ + ); +} + +function ProxyConfigView(props) { + const { isTitanLightning, sellerPoolParts, proxyRouterEditClick } = props; + return ( + <> + {isTitanLightning ? ( + + ) : ( + +
+ Proxy Default Pool: {sellerPoolParts?.pool}{' '} +
+
+ Proxy Default Account: {sellerPoolParts?.account}{' '} +
+
+ )} + Edit + + ); +} + +function ProxyConfigEdit(props) { + const { + isTitanLightning, + sellerPoolParts, + setSellerPoolParts, + errors, + setErrors + } = props; + + const onChangePoolAddess = address => { + const result = validatePoolAddress(address, {}); + + setErrors({ + ...errors, + proxyDefaultPool: result.proxyDefaultPool || null + }); + + setSellerPoolParts({ + ...sellerPoolParts, + pool: address, + isTitanLightning + }); + }; + + return ( + <> + {isTitanLightning ? ( + + Titan Lightning Address: + + setSellerPoolParts({ + ...sellerPoolParts, + account: e.value + }) + } + value={sellerPoolParts?.account} + /> + + ) : ( + <> + + Proxy Default Pool Host & Port:{' '} + onChangePoolAddess(e.value)} + value={sellerPoolParts?.pool} + /> + {errors?.proxyDefaultPool && ( + {errors?.proxyDefaultPool} + )} + + + Proxy Default Account: + + setSellerPoolParts({ + ...sellerPoolParts, + account: e.value + }) + } + value={sellerPoolParts?.account} + /> + + + )} + + ); +} + +export function ProxyConfigPanel(props) { + const [errors, setErrors] = useState({}); + + return !props.isLocalProxyRouter ? ( + + ) : ( + <> + + Proxy-Router Configuration + {props.proxyRouterSettings.isFetching ? ( + + ) : props.proxyRouterSettings.proxyRouterEditMode ? ( + <> +
+ Use Titan Pool for Lightning Payouts + { + props.toggleIsLightning(); + }} + checked={props.isTitanLightning} + type="checkbox" + id="isTitanLightning" + /> +
+ +
+ { + props.setProxyRouterSettings({ + ...props.proxyRouterSettings, + isTitanLightning: props.isTitanLightning, + sellerDefaultPool: generatePoolUrl( + props.sellerPoolParts.account, + !props.isTitanLightning + ? props.sellerPoolParts.pool + : props.titanLightningPool + ) + }); + props.onActiveModalClick('confirm-proxy-restart'); + }} + > + Save + + + ) : ( + + )} + + +
+ + Restart Proxy Router + Restart the connected Proxy Router. + {props.isRestarting ? ( + + ) : ( + + props.onActiveModalClick('confirm-proxy-direct-restart') + } + > + Restart + + )} + + + + ); +} diff --git a/src/components/tools/RevealSecretPhraseModal.js b/src/components/tools/RevealSecretPhraseModal.js index 21301271..198725cf 100644 --- a/src/components/tools/RevealSecretPhraseModal.js +++ b/src/components/tools/RevealSecretPhraseModal.js @@ -1,8 +1,8 @@ import PropTypes from 'prop-types'; import styled from 'styled-components'; -import React, { useEffect } from 'react'; +import React, { useState } from 'react'; -import { Modal, BaseBtn } from '../common'; +import { Modal } from '../common'; import { Container, Message, @@ -10,8 +10,7 @@ import { DismissBtn, ConfirmBtn } from './ConfirmModal.styles'; -import { Input } from './Tools'; -import { useState } from 'react'; +import { Input } from './common'; const Mnemonic = styled.div` padding: 10px 0; diff --git a/src/components/tools/Tools.js b/src/components/tools/Tools.js index 869f3754..0e5efe83 100644 --- a/src/components/tools/Tools.js +++ b/src/components/tools/Tools.js @@ -3,10 +3,8 @@ import withToolsState from '../../store/hocs/withToolsState'; import PropTypes from 'prop-types'; import styled from 'styled-components'; import React, { useState, useContext, useEffect } from 'react'; -import axios from 'axios'; import ConfirmModal from './ConfirmModal'; -import TestModal from './TestModal'; import WalletStatus from './WalletStatus'; import { ConfirmationWizard, TextInput, Flex, BaseBtn, Sp } from '../common'; import Spinner from '../common/Spinner'; @@ -16,9 +14,11 @@ import ConfirmProxyConfigModal from './ConfirmProxyConfigModal'; import RevealSecretPhraseModal from './RevealSecretPhraseModal'; import { Message } from './ConfirmModal.styles'; import ExportPrivateKeyModal from './ExportPrivateKeyModal'; -import { generatePoolUrl } from '../../utils'; +import { ProxyConfigPanel } from './ProxyConfigPanel'; import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'; +import { StyledBtn, Subtitle, StyledParagraph, Input } from './common'; + import 'react-tabs/style/react-tabs.css'; import './styles.css'; @@ -75,48 +75,10 @@ const ValidationMsg = styled.div` opacity: 0.75; `; -const StyledBtn = styled(BaseBtn)` - width: 40%; - height: 40px; - font-size: 1.5rem; - border-radius: 5px; - padding: 0 0.6rem; - background-color: ${p => p.theme.colors.primary}; - color: ${p => p.theme.colors.light}; - - @media (min-width: 1040px) { - width: 35%; - height: 40px; - margin-left: 0; - margin-top: 1.6rem; - } -`; - -const Subtitle = styled.h3` - color: ${p => p.theme.colors.dark}; -`; - -const StyledParagraph = styled.p` - color: ${p => p.theme.colors.dark}; - - span { - font-weight: bold; - } -`; - const WalletInfo = styled.h4` color: ${p => p.theme.colors.dark}; `; -export const Input = styled(TextInput)` - outline: 0; - border: 0px; - background: #eaf7fc; - border-radius: 15px; - padding: 1.2rem 1.2rem; - margin-top: 0.25rem; -`; - const getPoolAndAccount = url => { if (!url) return {}; const addressParts = url.replace('stratum+tcp://', '').split(':'); @@ -171,7 +133,6 @@ const Tools = props => { isFetching: true }); const [sellerPoolParts, setSellerPoolParts] = useState(null); - const [buyerPoolParts, setBuyerPoolParts] = useState(null); const [isTitanLightning, setTitanLightning] = useState(false); const [httpNodeInput, setHttpNodeInput] = useState( @@ -193,7 +154,6 @@ const Tools = props => { getProxyRouterSettings() .then(data => { setSellerPoolParts(getPoolAndAccount(data.sellerDefaultPool)); - setBuyerPoolParts(getPoolAndAccount(data.sellerDefaultPool)); setProxyRouterSettings({ ...data, @@ -496,170 +456,25 @@ const Tools = props => { - {props.isLocalProxyRouter ? ( - - - Proxy-Router Configuration - {proxyRouterSettings.isFetching ? ( - - ) : !proxyRouterSettings.proxyRouterEditMode ? ( - <> - - {!isTitanLightning ? ( -
- Proxy Default Pool:{' '} - {sellerPoolParts?.pool}{' '} -
- ) : ( - <> - )} - {!isTitanLightning ? ( -
- Proxy Default Account:{' '} - {sellerPoolParts?.account}{' '} -
- ) : ( -
- Titan Lightning Address:{' '} - {sellerPoolParts?.account}{' '} -
- )} - {isTitanLightning && ( -

{ - window.open(titanLightningDashboard, '_blank'); - }} - > - Dashboard for Lightning users -

- )} -
- Edit - - ) : ( - <> -
- Use Titan Pool for Lightning Payouts - { - toggleIsLightning(); - }} - checked={isTitanLightning} - type="checkbox" - id="isTitanLightning" - /> -
- {!isTitanLightning ? ( - - Proxy Default Pool Host & Port:{' '} - - setSellerPoolParts({ - ...sellerPoolParts, - pool: e.value, - isTitanLightning - }) - } - value={sellerPoolParts?.pool} - /> - - ) : ( - <> - )} - - {!isTitanLightning - ? 'Proxy Default Account: ' - : 'Titan Lightning Address: '} - - setSellerPoolParts({ - ...sellerPoolParts, - account: e.value - }) - } - value={sellerPoolParts?.account} - /> - -
- { - setProxyRouterSettings({ - ...proxyRouterSettings, - isTitanLightning, - sellerDefaultPool: generatePoolUrl( - sellerPoolParts.account, - !isTitanLightning - ? sellerPoolParts.pool - : props.titanLightningPool - ) - }); - onActiveModalClick('confirm-proxy-restart'); - }} - > - Save - - - )} - - - -
- - Restart Proxy Router - - Restart the connected Proxy Router. - - {isRestarting ? ( - - ) : ( - - onActiveModalClick('confirm-proxy-direct-restart') - } - > - Restart - - )} - - -
- ) : ( - - - You are running Wallet wihout Proxy-Router. Reset wallet to - setup validator node. - - - )} + + + HTTP ETH Node: diff --git a/src/components/tools/common.js b/src/components/tools/common.js new file mode 100644 index 00000000..25b0af54 --- /dev/null +++ b/src/components/tools/common.js @@ -0,0 +1,57 @@ +import styled from 'styled-components'; + +import 'react-tabs/style/react-tabs.css'; +import './styles.css'; +import { BaseBtn, TextInput } from '../common'; + +export const Sublabel = styled.label` + line-height: 1.4rem; + font-size: 1.1rem; + font-weight: 400; + opacity: 0.65; + cursor: default; + padding: 5px 0 0 5px; +`; + +export const ErrorLabel = styled(Sublabel)` + padding: 5px 0 0 5px; + color: red; +`; + +export const StyledBtn = styled(BaseBtn)` + width: 40%; + height: 40px; + font-size: 1.5rem; + border-radius: 5px; + padding: 0 0.6rem; + background-color: ${p => p.theme.colors.primary}; + color: ${p => p.theme.colors.light}; + + @media (min-width: 1040px) { + width: 35%; + height: 40px; + margin-left: 0; + margin-top: 1.6rem; + } +`; + +export const Subtitle = styled.h3` + color: ${p => p.theme.colors.dark}; +`; + +export const StyledParagraph = styled.p` + color: ${p => p.theme.colors.dark}; + + span { + font-weight: bold; + } +`; + +export const Input = styled(TextInput)` + outline: 0; + border: 0px; + background: #eaf7fc; + border-radius: 15px; + padding: 1.2rem 1.2rem; + margin-top: 0.25rem; +`; From b0ff240981ff0b897eb1c837b08a39849df1abab Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Thu, 7 Dec 2023 18:54:08 +0200 Subject: [PATCH 2/4] update wallet-core --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index da0009f7..8bdacee0 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ }, "dependencies": { "@electron/remote": "2.0.9", - "@lumerin/wallet-core": "git+ssh://git@github.com:Lumerin-protocol/WalletCore.git#1.0.83", + "@lumerin/wallet-core": "git+ssh://git@github.com:Lumerin-protocol/WalletCore.git#1.0.84", "@reach/menu-button": "0.17.0", "@tabler/icons": "1.119.0", "axios": "0.27.2", From ca61abaf0a911dc872bdab9f45bbbfe4a4c62f23 Mon Sep 17 00:00:00 2001 From: bohdan-titan <118257905+bohdan-titan@users.noreply.github.com> Date: Thu, 7 Dec 2023 19:01:11 +0200 Subject: [PATCH 3/4] Update Toast.js --- src/components/toasts/Toast.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/toasts/Toast.js b/src/components/toasts/Toast.js index cad7d1b7..29a1c9a3 100644 --- a/src/components/toasts/Toast.js +++ b/src/components/toasts/Toast.js @@ -130,7 +130,6 @@ export default class Toast extends React.Component { key: msg, data: msg, style: { - maxHeight: spring(50, { stiffness: 150, damping: 20 }), opacity: spring(1, { stiffness: 60, damping: 5 }) } }))} From 1f288199dbda6f1eda066f41227fe35e3b6a73ab Mon Sep 17 00:00:00 2001 From: Aleksandr Kukharenko Date: Thu, 7 Dec 2023 19:05:03 +0200 Subject: [PATCH 4/4] 1.2.47 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8bdacee0..386915cb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lumerin-wallet-desktop", - "version": "1.2.46", + "version": "1.2.47", "engines": { "node": ">=14" },