mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2026-09-06 10:04:59 -05:00
fixed basic eslint errors and warnings
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
import React, { useState, useRef } from "react";
|
||||
import { Typography } from "@material-ui/core";
|
||||
import { ChevronRight as ChevronRightIcon } from "@material-ui/icons";
|
||||
import "./Accordion.css";
|
||||
import React, { useState, useRef } from 'react';
|
||||
import { Typography } from '@material-ui/core';
|
||||
import { ChevronRight as ChevronRightIcon } from '@material-ui/icons';
|
||||
import './Accordion.css';
|
||||
|
||||
type Props = {
|
||||
content: string,
|
||||
content: string;
|
||||
};
|
||||
|
||||
export default function Accordion(props: Props) {
|
||||
const [setActive, setActiveState] = useState("");
|
||||
const [setHeight, setHeightState] = useState("0px");
|
||||
const [setRotate, setRotateState] = useState("accordion__icon");
|
||||
const [setTitle, setTitleState] = useState("View pending balances...");
|
||||
const [setActive, setActiveState] = useState('');
|
||||
const [setHeight, setHeightState] = useState('0px');
|
||||
const [setRotate, setRotateState] = useState('accordion__icon');
|
||||
const [setTitle, setTitleState] = useState('View pending balances...');
|
||||
const content = useRef<HTMLDivElement>(null);
|
||||
function toggleAccordion() {
|
||||
setActiveState(setActive === "" ? "active" : "");
|
||||
setActiveState(setActive === '' ? 'active' : '');
|
||||
setHeightState(
|
||||
setActive === "active" ? "0px" : `${content.current?.scrollHeight}px`
|
||||
setActive === 'active' ? '0px' : `${content.current?.scrollHeight}px`,
|
||||
);
|
||||
setRotateState(
|
||||
setActive === "active" ? "accordion__icon" : "accordion__icon rotate"
|
||||
setActive === 'active' ? 'accordion__icon' : 'accordion__icon rotate',
|
||||
);
|
||||
setTitleState(
|
||||
setActive === "active"
|
||||
? "View pending balances..."
|
||||
: "Hide pending balances"
|
||||
setActive === 'active'
|
||||
? 'View pending balances...'
|
||||
: 'Hide pending balances',
|
||||
);
|
||||
}
|
||||
return (
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import React from 'react';
|
||||
import { CssBaseline } from "@material-ui/core";
|
||||
import { Provider } from "react-redux";
|
||||
import { CssBaseline } from '@material-ui/core';
|
||||
import { Provider } from 'react-redux';
|
||||
import { I18nProvider } from '@lingui/react';
|
||||
import useDarkMode from 'use-dark-mode';
|
||||
import { ModalDialog, Spinner } from '../../pages/ModalDialog';
|
||||
import Router from '../router/Router';
|
||||
import darkTheme from '../../theme/dark';
|
||||
import lightTheme from '../../theme/light';
|
||||
import WebSocketConnection from "../../hocs/WebsocketConnection";
|
||||
import { daemon_rpc_ws } from "../../util/config";
|
||||
import store from "../../modules/store";
|
||||
import WebSocketConnection from '../../hocs/WebsocketConnection';
|
||||
import { daemon_rpc_ws } from '../../util/config';
|
||||
import store from '../../modules/store';
|
||||
import ThemeProvider from '../theme/ThemeProvider';
|
||||
import en from '../../locales/en/messages';
|
||||
import sk from '../../locales/sk/messages';
|
||||
|
||||
@@ -8,8 +8,12 @@ const StyledImage = styled('img')`
|
||||
// animation: App-logo-spin infinite 20s linear;
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from { transform: rotate(0deg); }
|
||||
to { transform: rotate(360deg); }
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { darken } from 'polished';
|
||||
import { Button as BaseButton, ButtonProps } from "@material-ui/core";
|
||||
import { Button as BaseButton, ButtonProps } from '@material-ui/core';
|
||||
|
||||
const DangerButton = styled(BaseButton)`
|
||||
color: ${({ theme }) => theme.palette.danger.contrastText};
|
||||
@@ -14,7 +14,7 @@ const DangerButton = styled(BaseButton)`
|
||||
`;
|
||||
|
||||
type Props = Omit<ButtonProps, 'color'> & {
|
||||
color?: 'primary' | 'danger' | 'secondary',
|
||||
color?: 'primary' | 'danger' | 'secondary';
|
||||
};
|
||||
|
||||
export default function Button(props: Props) {
|
||||
@@ -24,16 +24,10 @@ export default function Button(props: Props) {
|
||||
case 'danger':
|
||||
return <DangerButton {...rest} />;
|
||||
case 'primary':
|
||||
return (
|
||||
<BaseButton color="primary" {...rest} />
|
||||
);
|
||||
return <BaseButton color="primary" {...rest} />;
|
||||
case 'secondary':
|
||||
return (
|
||||
<BaseButton color="secondary" {...rest} />
|
||||
);
|
||||
return <BaseButton color="secondary" {...rest} />;
|
||||
default:
|
||||
return (
|
||||
<BaseButton {...rest} />
|
||||
);
|
||||
return <BaseButton {...rest} />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
import { withStyles } from "@material-ui/styles";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import { withStyles } from '@material-ui/styles';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
|
||||
const CssTextField = withStyles({
|
||||
root: {
|
||||
"& .MuiFormLabel-root": {
|
||||
color: "#e3f2fd"
|
||||
'& .MuiFormLabel-root': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& MuiInputLabel-root": {
|
||||
color: "#e3f2fd"
|
||||
'& MuiInputLabel-root': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& label.Mui-focused": {
|
||||
color: "#e3f2fd"
|
||||
'& label.Mui-focused': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& label.Mui-required": {
|
||||
color: "#e3f2fd"
|
||||
'& label.Mui-required': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& label.Mui-disabled": {
|
||||
color: "#e3f2fd"
|
||||
'& label.Mui-disabled': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& label.Mui-root": {
|
||||
color: "#e3f2fd"
|
||||
'& label.Mui-root': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& .MuiInput-underline:after": {
|
||||
borderBottomColor: "#e3f2fd"
|
||||
'& .MuiInput-underline:after': {
|
||||
borderBottomColor: '#e3f2fd',
|
||||
},
|
||||
"& .MuiOutlinedInput-root": {
|
||||
"& fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
'& .MuiOutlinedInput-root': {
|
||||
'& fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
"&:hover fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
'&:hover fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
"&.Mui-focused fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
'&.Mui-focused fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
'&.Mui-disabled fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
"&.Mui-disabled fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
}
|
||||
},
|
||||
color: "#ffffff",
|
||||
"& .MuiOutlinedInput-input": {
|
||||
color: "#ffffff"
|
||||
}
|
||||
}
|
||||
color: '#ffffff',
|
||||
'& .MuiOutlinedInput-input': {
|
||||
color: '#ffffff',
|
||||
},
|
||||
},
|
||||
})(TextField);
|
||||
|
||||
export default CssTextField;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import useDarkMode from 'use-dark-mode';
|
||||
import { IconButton } from "@material-ui/core";
|
||||
import { IconButton } from '@material-ui/core';
|
||||
import { Brightness4, Brightness7 } from '@material-ui/icons';
|
||||
|
||||
export default function DarkModeToggle() {
|
||||
@@ -12,9 +12,7 @@ export default function DarkModeToggle() {
|
||||
|
||||
return (
|
||||
<IconButton color="inherit" onClick={handleClick}>
|
||||
{darkMode
|
||||
? <Brightness7 />
|
||||
: <Brightness4 /> }
|
||||
{darkMode ? <Brightness7 /> : <Brightness4 />}
|
||||
</IconButton>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Route, Switch, useRouteMatch } from 'react-router';
|
||||
import { AppBar, Toolbar, Drawer, Divider } from "@material-ui/core";
|
||||
import Wallets from "../wallet/Wallets";
|
||||
import { AppBar, Toolbar, Drawer, Divider } from '@material-ui/core';
|
||||
import Wallets from '../wallet/Wallets';
|
||||
import FullNode from '../fullNode/FullNode';
|
||||
import Plotter from '../plotter/Plotter';
|
||||
import Farmer from '../farmer/Farmer';
|
||||
@@ -11,7 +11,7 @@ import Flex from '../flex/Flex';
|
||||
import DashboardSideBar from './DashboardSideBar';
|
||||
import { DashboardTitleTarget } from './DashboardTitle';
|
||||
import ToolbarSpacing from '../toolbar/ToolbarSpacing';
|
||||
import TradeManager from "../trading/TradeManager";
|
||||
import TradeManager from '../trading/TradeManager';
|
||||
import DarkModeToggle from '../darkMode/DarkModeToggle';
|
||||
import LocaleToggle from '../locale/LocaleToggle';
|
||||
|
||||
@@ -23,7 +23,8 @@ const StyledRoot = styled(Flex)`
|
||||
`;
|
||||
|
||||
const StyledAppBar = styled(AppBar)`
|
||||
background-color: ${({ theme }) => theme.palette.type === 'dark' ? '#424242' : 'white' } ;
|
||||
background-color: ${({ theme }) =>
|
||||
theme.palette.type === 'dark' ? '#424242' : 'white'};
|
||||
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
|
||||
width: ${({ theme }) => `calc(100% - ${theme.drawer.width})`};
|
||||
margin-left: ${({ theme }) => theme.drawer.width};
|
||||
@@ -58,11 +59,7 @@ export default function Dashboard() {
|
||||
|
||||
return (
|
||||
<StyledRoot>
|
||||
<StyledAppBar
|
||||
position="fixed"
|
||||
color="transparent"
|
||||
elevation={0}
|
||||
>
|
||||
<StyledAppBar position="fixed" color="transparent" elevation={0}>
|
||||
<Toolbar>
|
||||
<DashboardTitleTarget />
|
||||
<Flex flexGrow={1} />
|
||||
@@ -72,7 +69,7 @@ export default function Dashboard() {
|
||||
</StyledAppBar>
|
||||
<StyledDrawer variant="permanent">
|
||||
<StyledBrandWrapper>
|
||||
<Brand width={2/3}/>
|
||||
<Brand width={2 / 3} />
|
||||
</StyledBrandWrapper>
|
||||
<Divider />
|
||||
<DashboardSideBar />
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Trans } from '@lingui/macro';
|
||||
import { useDispatch } from "react-redux";
|
||||
import { List } from "@material-ui/core";
|
||||
import { logOut } from "../../modules/message";
|
||||
import { ReactComponent as WalletsIcon} from "./images/wallet.svg";
|
||||
import { ReactComponent as FarmIcon } from "./images/farm.svg";
|
||||
import { ReactComponent as KeysIcon } from "./images/help.svg";
|
||||
import { ReactComponent as HomeIcon } from "./images/home.svg";
|
||||
import { ReactComponent as PlotIcon } from "./images/plot.svg";
|
||||
import { ReactComponent as TradeIcon } from "./images/pool.svg";
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { List } from '@material-ui/core';
|
||||
import { logOut } from '../../modules/message';
|
||||
import { ReactComponent as WalletsIcon } from './images/wallet.svg';
|
||||
import { ReactComponent as FarmIcon } from './images/farm.svg';
|
||||
import { ReactComponent as KeysIcon } from './images/help.svg';
|
||||
import { ReactComponent as HomeIcon } from './images/home.svg';
|
||||
import { ReactComponent as PlotIcon } from './images/plot.svg';
|
||||
import { ReactComponent as TradeIcon } from './images/pool.svg';
|
||||
import SideBarItem from '../sideBar/SideBarItem';
|
||||
import Flex from '../flex/Flex';
|
||||
|
||||
@@ -26,7 +26,7 @@ export default function DashboardSideBar() {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
function handleLogOut() {
|
||||
dispatch(logOut("log_out", {}));
|
||||
dispatch(logOut('log_out', {}));
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -35,58 +35,34 @@ export default function DashboardSideBar() {
|
||||
<SideBarItem
|
||||
to="/dashboard"
|
||||
icon={<HomeIcon />}
|
||||
title={(
|
||||
<Trans id="DashboardSideBar.home">
|
||||
Full Node
|
||||
</Trans>
|
||||
)}
|
||||
title={<Trans id="DashboardSideBar.home">Full Node</Trans>}
|
||||
exact
|
||||
/>
|
||||
<SideBarItem
|
||||
to="/dashboard/wallets"
|
||||
icon={<WalletsIcon />}
|
||||
title={(
|
||||
<Trans id="DashboardSideBar.wallets">
|
||||
Wallets
|
||||
</Trans>
|
||||
)}
|
||||
title={<Trans id="DashboardSideBar.wallets">Wallets</Trans>}
|
||||
/>
|
||||
<SideBarItem
|
||||
to="/dashboard/plot"
|
||||
icon={<PlotIcon />}
|
||||
title={(
|
||||
<Trans id="DashboardSideBar.plot">
|
||||
Plot
|
||||
</Trans>
|
||||
)}
|
||||
title={<Trans id="DashboardSideBar.plot">Plot</Trans>}
|
||||
/>
|
||||
<SideBarItem
|
||||
to="/dashboard/farm"
|
||||
icon={<FarmIcon />}
|
||||
title={(
|
||||
<Trans id="DashboardSideBar.farm">
|
||||
Farm
|
||||
</Trans>
|
||||
)}
|
||||
title={<Trans id="DashboardSideBar.farm">Farm</Trans>}
|
||||
/>
|
||||
<SideBarItem
|
||||
to="/dashboard/trade"
|
||||
icon={<TradeIcon />}
|
||||
title={(
|
||||
<Trans id="DashboardSideBar.trade">
|
||||
Trade
|
||||
</Trans>
|
||||
)}
|
||||
title={<Trans id="DashboardSideBar.trade">Trade</Trans>}
|
||||
/>
|
||||
<SideBarItem
|
||||
to="/"
|
||||
icon={<KeysIcon />}
|
||||
onSelect={handleLogOut}
|
||||
title={(
|
||||
<Trans id="DashboardSideBar.keys">
|
||||
Keys
|
||||
</Trans>
|
||||
)}
|
||||
title={<Trans id="DashboardSideBar.keys">Keys</Trans>}
|
||||
exact
|
||||
/>
|
||||
</StyledList>
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
import { Typography } from "@material-ui/core";
|
||||
import { Typography } from '@material-ui/core';
|
||||
import { createTeleporter } from 'react-teleporter';
|
||||
|
||||
const DashboardTitleTeleporter = createTeleporter();
|
||||
|
||||
export function DashboardTitleTarget() {
|
||||
return (
|
||||
<Typography
|
||||
component="h1"
|
||||
variant="h6"
|
||||
noWrap
|
||||
>
|
||||
<Typography component="h1" variant="h6" noWrap>
|
||||
<DashboardTitleTeleporter.Target />
|
||||
</Typography>
|
||||
);
|
||||
}
|
||||
|
||||
type Props = {
|
||||
children: ReactNode,
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export default function DashboardTitle(props: Props) {
|
||||
|
||||
@@ -10,35 +10,39 @@ function getGap(gap: GAP_SIZE, theme: any): string {
|
||||
}
|
||||
|
||||
switch (gap) {
|
||||
case 'small':
|
||||
case 'small':
|
||||
return '0.5rem';
|
||||
case 'normal':
|
||||
case 'normal':
|
||||
return '1rem';
|
||||
case 'large':
|
||||
case 'large':
|
||||
return '2rem';
|
||||
default:
|
||||
return String(gap);
|
||||
}
|
||||
}
|
||||
|
||||
const StyledGapBox = styled(({ rowGap, columnGap, ...rest }) => <Box {...rest} />)`
|
||||
margin: ${({ rowGap, columnGap }) => `calc(${rowGap} / -2) calc(${columnGap} / -2)`};
|
||||
const StyledGapBox = styled(({ rowGap, columnGap, ...rest }) => (
|
||||
<Box {...rest} />
|
||||
))`
|
||||
margin: ${({ rowGap, columnGap }) =>
|
||||
`calc(${rowGap} / -2) calc(${columnGap} / -2)`};
|
||||
|
||||
> * {
|
||||
margin: ${({ rowGap, columnGap }) => `calc(${rowGap} / 2) calc(${columnGap} / 2)`};
|
||||
margin: ${({ rowGap, columnGap }) =>
|
||||
`calc(${rowGap} / 2) calc(${columnGap} / 2)`};
|
||||
}
|
||||
`;
|
||||
|
||||
type Props = BoxProps & {
|
||||
gap?: GAP_SIZE,
|
||||
rowGap?: GAP_SIZE,
|
||||
columnGap?: GAP_SIZE,
|
||||
gap?: GAP_SIZE;
|
||||
rowGap?: GAP_SIZE;
|
||||
columnGap?: GAP_SIZE;
|
||||
};
|
||||
|
||||
export default function Flex(props: Props) {
|
||||
const {
|
||||
gap = '0px',
|
||||
flexDirection,
|
||||
const {
|
||||
gap = '0px',
|
||||
flexDirection,
|
||||
rowGap = gap,
|
||||
columnGap = gap,
|
||||
...rest
|
||||
@@ -46,13 +50,11 @@ export default function Flex(props: Props) {
|
||||
|
||||
const theme = useTheme();
|
||||
|
||||
const rowGapValue = flexDirection === 'column'
|
||||
? getGap(rowGap, theme)
|
||||
: '0px';
|
||||
const rowGapValue =
|
||||
flexDirection === 'column' ? getGap(rowGap, theme) : '0px';
|
||||
|
||||
const columnGapValue = flexDirection !== 'column'
|
||||
? getGap(columnGap, theme)
|
||||
: '0px';
|
||||
const columnGapValue =
|
||||
flexDirection !== 'column' ? getGap(columnGap, theme) : '0px';
|
||||
|
||||
return (
|
||||
<StyledGapBox
|
||||
@@ -60,7 +62,7 @@ export default function Flex(props: Props) {
|
||||
display="flex"
|
||||
rowGap={rowGapValue}
|
||||
columnGap={columnGapValue}
|
||||
{...rest}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import styled from "styled-components";
|
||||
import { TextField } from "@material-ui/core";
|
||||
import styled from 'styled-components';
|
||||
import { TextField } from '@material-ui/core';
|
||||
|
||||
export default styled(TextField)`
|
||||
color: #ffffff;
|
||||
@@ -7,19 +7,19 @@ export default styled(TextField)`
|
||||
& .MuiFormLabel-root {
|
||||
color: #e3f2fd;
|
||||
}
|
||||
|
||||
|
||||
& .MuiInputLabel-root {
|
||||
color: #e3f2fd;
|
||||
}
|
||||
|
||||
& label.Mui-focused {
|
||||
color: #e3f2fd;
|
||||
color: #e3f2fd;
|
||||
}
|
||||
|
||||
& label.Mui-required {
|
||||
color: #e3f2fd;
|
||||
}
|
||||
|
||||
|
||||
& label.Mui-disabled {
|
||||
color: #e3f2fd;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ export default styled(TextField)`
|
||||
& .MuiInput-underline:after {
|
||||
border-bottom-color: #e3f2fd;
|
||||
}
|
||||
|
||||
|
||||
& .MuiOutlinedInput-root {
|
||||
& fieldset {
|
||||
border-color: #e3f2fd;
|
||||
@@ -46,7 +46,7 @@ export default styled(TextField)`
|
||||
border-color: #e3f2fd;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
& .MuiOutlinedInput-input {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ const StyledWrapper = styled(Box)`
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
children: ReactNode,
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export default function LayoutHero(props: Props) {
|
||||
|
||||
@@ -9,7 +9,7 @@ const StyledTypography = styled(Typography)`
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
children: ReactNode,
|
||||
children: ReactNode;
|
||||
};
|
||||
|
||||
export default function LoadingScreen(props: Props) {
|
||||
@@ -17,9 +17,7 @@ export default function LoadingScreen(props: Props) {
|
||||
|
||||
return (
|
||||
<LayoutHero>
|
||||
<StyledTypography variant="h6">
|
||||
{children}
|
||||
</StyledTypography>
|
||||
<StyledTypography variant="h6">{children}</StyledTypography>
|
||||
<Loading />
|
||||
</LayoutHero>
|
||||
);
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { useToggle } from 'react-use';
|
||||
import { Button, Menu, MenuItem } from '@material-ui/core';
|
||||
import { Translate, ExpandMore } from '@material-ui/icons';
|
||||
import useLocale from "../../hooks/useLocale";
|
||||
import useLocale from '../../hooks/useLocale';
|
||||
|
||||
const locales: { [char: string]: string } = {
|
||||
en: 'English',
|
||||
@@ -32,9 +32,9 @@ export default function LocaleToggle() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
aria-controls="simple-menu"
|
||||
aria-haspopup="true"
|
||||
<Button
|
||||
aria-controls="simple-menu"
|
||||
aria-haspopup="true"
|
||||
onClick={handleClick}
|
||||
startIcon={<Translate />}
|
||||
endIcon={<ExpandMore />}
|
||||
@@ -50,8 +50,8 @@ export default function LocaleToggle() {
|
||||
>
|
||||
<MenuItem onClick={() => handleSelect('en')}>English</MenuItem>
|
||||
<MenuItem onClick={() => handleSelect('sk')}>Slovak</MenuItem>
|
||||
<MenuItem >Help to translate</MenuItem>
|
||||
<MenuItem>Help to translate</MenuItem>
|
||||
</Menu>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
import React from 'react';
|
||||
import { useSelector } from "react-redux";
|
||||
import { useSelector } from 'react-redux';
|
||||
import { Route, Redirect, RouteProps } from 'react-router-dom';
|
||||
import type { RootState } from "../../modules/rootReducer";
|
||||
import type { RootState } from '../../modules/rootReducer';
|
||||
|
||||
type Props = RouteProps;
|
||||
|
||||
export default function GuestRoute(props: Props) {
|
||||
const loggedIn = useSelector((state: RootState) => state.wallet_state.logged_in);
|
||||
const loggedIn = useSelector(
|
||||
(state: RootState) => state.wallet_state.logged_in,
|
||||
);
|
||||
if (loggedIn) {
|
||||
return (
|
||||
<Redirect to="/dashboard" />
|
||||
);
|
||||
return <Redirect to="/dashboard" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Route {...props} />
|
||||
);
|
||||
return <Route {...props} />;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Link as BaseLink, LinkProps as BaseLinkProps } from "@material-ui/core";
|
||||
import { Link as RouterLink, LinkProps as RouterLinkProps } from 'react-router-dom';
|
||||
import {
|
||||
Link as BaseLink,
|
||||
LinkProps as BaseLinkProps,
|
||||
} from '@material-ui/core';
|
||||
import {
|
||||
Link as RouterLink,
|
||||
LinkProps as RouterLinkProps,
|
||||
} from 'react-router-dom';
|
||||
|
||||
type Props = BaseLinkProps & RouterLinkProps & {
|
||||
to?: string | Object,
|
||||
fullWidth?: boolean,
|
||||
};
|
||||
type Props = BaseLinkProps &
|
||||
RouterLinkProps & {
|
||||
to?: string | Object;
|
||||
fullWidth?: boolean;
|
||||
};
|
||||
|
||||
const StyledBadeLink = styled(({ fullWidth, ...rest}) => <BaseLink {...rest} />)`
|
||||
width: ${({ fullWidth }) => fullWidth ? '100%' : 'inherit'};
|
||||
const StyledBadeLink = styled(({ fullWidth, ...rest }) => (
|
||||
<BaseLink {...rest} />
|
||||
))`
|
||||
width: ${({ fullWidth }) => (fullWidth ? '100%' : 'inherit')};
|
||||
`;
|
||||
|
||||
export default function Link(props: Props) {
|
||||
return (
|
||||
<StyledBadeLink component={RouterLink} {...props} fullWidth />
|
||||
);
|
||||
return <StyledBadeLink component={RouterLink} {...props} fullWidth />;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
import React from 'react';
|
||||
import { useSelector } from "react-redux";
|
||||
import { useSelector } from 'react-redux';
|
||||
import { Route, Redirect, RouteProps } from 'react-router-dom';
|
||||
import type { RootState } from "../../modules/rootReducer";
|
||||
import type { RootState } from '../../modules/rootReducer';
|
||||
|
||||
type Props = RouteProps;
|
||||
|
||||
export default function PrivateRoute(props: Props) {
|
||||
const loggedIn = useSelector((state: RootState) => state.wallet_state.logged_in);
|
||||
const loggedIn = useSelector(
|
||||
(state: RootState) => state.wallet_state.logged_in,
|
||||
);
|
||||
if (!loggedIn) {
|
||||
return (
|
||||
<Redirect to="/" />
|
||||
);
|
||||
return <Redirect to="/" />;
|
||||
}
|
||||
|
||||
return (
|
||||
<Route {...props} />
|
||||
);
|
||||
return <Route {...props} />;
|
||||
}
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
import React from 'react';
|
||||
import { HashRouter, Switch } from 'react-router-dom';
|
||||
import SelectKey from "../selectKey/SelectKey";
|
||||
import WalletAdd from "../wallet/WalletAdd";
|
||||
import WalletImport from "../wallet/WalletImport";
|
||||
import { useSelector } from 'react-redux';
|
||||
import SelectKey from '../selectKey/SelectKey';
|
||||
import WalletAdd from '../wallet/WalletAdd';
|
||||
import WalletImport from '../wallet/WalletImport';
|
||||
import PrivateRoute from './PrivateRoute';
|
||||
import GuestRoute from './GuestRoute';
|
||||
import Dashboard from '../dashboard/Dashboard';
|
||||
import { RestoreBackup } from "../../pages/backup/restoreBackup";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RestoreBackup } from '../../pages/backup/restoreBackup';
|
||||
import type { RootState } from '../../modules/rootReducer';
|
||||
import LoadingScreen from '../loading/LoadingScreen';
|
||||
|
||||
export default function Router() {
|
||||
const loggedInReceived = useSelector(
|
||||
(state: RootState) => state.wallet_state.logged_in_received
|
||||
(state: RootState) => state.wallet_state.logged_in_received,
|
||||
);
|
||||
const walletConnected = useSelector(
|
||||
(state: RootState) => state.daemon_state.wallet_connected
|
||||
(state: RootState) => state.daemon_state.wallet_connected,
|
||||
);
|
||||
const exiting = useSelector((state: RootState) => state.daemon_state.exiting);
|
||||
|
||||
if (exiting) {
|
||||
return <LoadingScreen>Closing down node and server</LoadingScreen>;
|
||||
} else if (!walletConnected) {
|
||||
}
|
||||
if (!walletConnected) {
|
||||
return <LoadingScreen>Connecting to wallet</LoadingScreen>;
|
||||
} else if (!loggedInReceived) {
|
||||
}
|
||||
if (!loggedInReceived) {
|
||||
return <LoadingScreen>Logging in</LoadingScreen>;
|
||||
}
|
||||
|
||||
@@ -47,7 +49,7 @@ export default function Router() {
|
||||
</HashRouter>
|
||||
);
|
||||
|
||||
/*
|
||||
/*
|
||||
if (presentView === presentRestoreBackup) {
|
||||
return <RestoreBackup></RestoreBackup>;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
import React, { useState } from "react";
|
||||
import React, { useState } from 'react';
|
||||
import { Trans } from '@lingui/macro';
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { useHistory } from "react-router";
|
||||
import { Card, Typography, Container, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Tooltip, List, ListItem, ListItemText, IconButton } from "@material-ui/core";
|
||||
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
|
||||
import { Delete as DeleteIcon, Visibility as VisibilityIcon } from "@material-ui/icons";
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { useHistory } from 'react-router';
|
||||
import {
|
||||
Card,
|
||||
Typography,
|
||||
Container,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogContentText,
|
||||
DialogTitle,
|
||||
Tooltip,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemText,
|
||||
IconButton,
|
||||
} from '@material-ui/core';
|
||||
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
||||
import {
|
||||
Delete as DeleteIcon,
|
||||
Visibility as VisibilityIcon,
|
||||
} from '@material-ui/icons';
|
||||
import Button from '../button/Button';
|
||||
import LayoutHero from '../layout/LayoutHero';
|
||||
import Flex from '../flex/Flex';
|
||||
@@ -15,11 +32,11 @@ import {
|
||||
get_private_key,
|
||||
selectFingerprint,
|
||||
delete_all_keys,
|
||||
} from "../../modules/message";
|
||||
} from '../../modules/message';
|
||||
import Link from '../router/Link';
|
||||
import { resetMnemonic } from "../../modules/mnemonic";
|
||||
import type { RootState } from "../../modules/rootReducer";
|
||||
import type Fingerprint from "../../types/Fingerprint";
|
||||
import { resetMnemonic } from '../../modules/mnemonic';
|
||||
import type { RootState } from '../../modules/rootReducer';
|
||||
import type Fingerprint from '../../types/Fingerprint';
|
||||
|
||||
export default function SelectKey() {
|
||||
const history = useHistory();
|
||||
@@ -28,7 +45,8 @@ export default function SelectKey() {
|
||||
const publicKeyFingerprints = useSelector(
|
||||
(state: RootState) => state.wallet_state.public_key_fingerprints,
|
||||
);
|
||||
const hasFingerprints = publicKeyFingerprints && !!publicKeyFingerprints.length;
|
||||
const hasFingerprints =
|
||||
publicKeyFingerprints && !!publicKeyFingerprints.length;
|
||||
|
||||
function handleClick(fingerprint: Fingerprint) {
|
||||
dispatch(resetMnemonic());
|
||||
@@ -36,11 +54,11 @@ export default function SelectKey() {
|
||||
dispatch(login_action(fingerprint));
|
||||
|
||||
history.push('/dashboard');
|
||||
};
|
||||
}
|
||||
|
||||
function handleClickOpen() {
|
||||
setOpen(true);
|
||||
};
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
setOpen(false);
|
||||
@@ -53,7 +71,7 @@ export default function SelectKey() {
|
||||
|
||||
function handleShowKey(fingerprint: Fingerprint) {
|
||||
dispatch(get_private_key(fingerprint));
|
||||
};
|
||||
}
|
||||
|
||||
function handleDelete(fingerprint: Fingerprint) {
|
||||
dispatch(delete_key(fingerprint));
|
||||
@@ -65,27 +83,38 @@ export default function SelectKey() {
|
||||
<Flex flexDirection="column" alignItems="center" gap={3}>
|
||||
<Brand />
|
||||
{hasFingerprints ? (
|
||||
<Typography variant="h5" component="h1" color="primary" gutterBottom>
|
||||
<Trans id="SelectKey.title">
|
||||
Select Key
|
||||
</Trans>
|
||||
<Typography
|
||||
variant="h5"
|
||||
component="h1"
|
||||
color="primary"
|
||||
gutterBottom
|
||||
>
|
||||
<Trans id="SelectKey.title">Select Key</Trans>
|
||||
</Typography>
|
||||
) : (
|
||||
<>
|
||||
<Typography variant="h5" component="h1" color="primary" gutterBottom>
|
||||
<Trans id="SelectKey.signInTitle">
|
||||
Sign In
|
||||
</Trans>
|
||||
<Typography
|
||||
variant="h5"
|
||||
component="h1"
|
||||
color="primary"
|
||||
gutterBottom
|
||||
>
|
||||
<Trans id="SelectKey.signInTitle">Sign In</Trans>
|
||||
</Typography>
|
||||
<Typography variant="subtitle1">
|
||||
<Trans id="SelectKey.signInDescription">
|
||||
Welcome to Chia. Please log in with an existing key, or create a
|
||||
a new key.
|
||||
Welcome to Chia. Please log in with an existing key, or create
|
||||
a a new key.
|
||||
</Trans>
|
||||
</Typography>
|
||||
</>
|
||||
)}
|
||||
<Flex flexDirection="column" gap={3} alignItems="stretch" alignSelf="stretch">
|
||||
<Flex
|
||||
flexDirection="column"
|
||||
gap={3}
|
||||
alignItems="stretch"
|
||||
alignSelf="stretch"
|
||||
>
|
||||
{hasFingerprints && (
|
||||
<Card>
|
||||
<List>
|
||||
@@ -120,7 +149,7 @@ export default function SelectKey() {
|
||||
</Tooltip>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
))}
|
||||
))}
|
||||
</List>
|
||||
</Card>
|
||||
)}
|
||||
@@ -165,9 +194,7 @@ export default function SelectKey() {
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
<DialogTitle id="alert-dialog-title">
|
||||
Delete all keys
|
||||
</DialogTitle>
|
||||
<DialogTitle id="alert-dialog-title">Delete all keys</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
Deleting all keys will permanatly remove the keys from your
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { useHistory, useRouteMatch } from 'react-router-dom';
|
||||
import { ListItem, ListItemIcon, ListItemText } from "@material-ui/core";
|
||||
import { ListItem, ListItemIcon, ListItemText } from '@material-ui/core';
|
||||
|
||||
const StyledListItem = styled(ListItem)`
|
||||
display: flex;
|
||||
@@ -17,11 +17,11 @@ const StyledListItemIcon = styled(ListItemIcon)`
|
||||
`;
|
||||
|
||||
type Props = {
|
||||
to: string,
|
||||
title: ReactNode,
|
||||
icon: ReactNode,
|
||||
exact?: boolean,
|
||||
onSelect?: () => void,
|
||||
to: string;
|
||||
title: ReactNode;
|
||||
icon: ReactNode;
|
||||
exact?: boolean;
|
||||
onSelect?: () => void;
|
||||
};
|
||||
|
||||
export default function SideBarItem(props: Props) {
|
||||
@@ -29,9 +29,7 @@ export default function SideBarItem(props: Props) {
|
||||
const history = useHistory();
|
||||
const match = useRouteMatch(to);
|
||||
|
||||
const isSelected = exact
|
||||
? !!match && match.isExact
|
||||
: !!match;
|
||||
const isSelected = exact ? !!match && match.isExact : !!match;
|
||||
|
||||
async function handleClick() {
|
||||
if (onSelect) {
|
||||
@@ -42,9 +40,7 @@ export default function SideBarItem(props: Props) {
|
||||
|
||||
return (
|
||||
<StyledListItem button selected={isSelected} onClick={() => handleClick()}>
|
||||
<StyledListItemIcon>
|
||||
{icon}
|
||||
</StyledListItemIcon>
|
||||
<StyledListItemIcon>{icon}</StyledListItemIcon>
|
||||
<ListItemText primary={title} />
|
||||
</StyledListItem>
|
||||
);
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
import { ThemeProvider as StyledThemeProvider } from 'styled-components';
|
||||
import { ThemeProvider as MaterialThemeProvider, StylesProvider } from "@material-ui/core";
|
||||
import {
|
||||
ThemeProvider as MaterialThemeProvider,
|
||||
StylesProvider,
|
||||
} from '@material-ui/core';
|
||||
|
||||
type Props = {
|
||||
children: ReactNode,
|
||||
theme: Object,
|
||||
children: ReactNode;
|
||||
theme: Object;
|
||||
};
|
||||
|
||||
export default function ThemeProvider(props: Props) {
|
||||
@@ -13,9 +16,7 @@ export default function ThemeProvider(props: Props) {
|
||||
return (
|
||||
<StylesProvider injectFirst>
|
||||
<StyledThemeProvider theme={theme}>
|
||||
<MaterialThemeProvider theme={theme}>
|
||||
{children}
|
||||
</MaterialThemeProvider>
|
||||
<MaterialThemeProvider theme={theme}>{children}</MaterialThemeProvider>
|
||||
</StyledThemeProvider>
|
||||
</StylesProvider>
|
||||
);
|
||||
|
||||
@@ -10,7 +10,5 @@ const useStyles = makeStyles((theme: Theme) =>
|
||||
export default function ToolbarSpacing() {
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
<div className={classes.toolbar} />
|
||||
);
|
||||
return <div className={classes.toolbar} />;
|
||||
}
|
||||
|
||||
@@ -1,50 +1,58 @@
|
||||
import React from "react";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { Route, Switch, useRouteMatch, useHistory } from 'react-router';
|
||||
import clsx from "clsx";
|
||||
import { Drawer, Grid, Container, List, Divider, ListItem, ListItemText } from "@material-ui/core";
|
||||
import { OfferSwitch } from "./ViewOffer";
|
||||
import { TradingOverview } from "./TradingOverview";
|
||||
import CreateOffer from "./CreateOffer";
|
||||
import clsx from 'clsx';
|
||||
import {
|
||||
Drawer,
|
||||
Grid,
|
||||
Container,
|
||||
List,
|
||||
Divider,
|
||||
ListItem,
|
||||
ListItemText,
|
||||
} from '@material-ui/core';
|
||||
import { OfferSwitch } from './ViewOffer';
|
||||
import { TradingOverview } from './TradingOverview';
|
||||
import CreateOffer from './CreateOffer';
|
||||
import DashboardTitle from '../dashboard/DashboardTitle';
|
||||
import Flex from '../flex/Flex';
|
||||
|
||||
const drawerWidth = 180;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
balancePaper: {
|
||||
height: 200,
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
bottomOptions: {
|
||||
position: "absolute",
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
width: "100%"
|
||||
}
|
||||
width: '100%',
|
||||
},
|
||||
}));
|
||||
|
||||
export default function TradeManager() {
|
||||
@@ -54,30 +62,28 @@ export default function TradeManager() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DashboardTitle>
|
||||
Trading
|
||||
</DashboardTitle>
|
||||
<DashboardTitle>Trading</DashboardTitle>
|
||||
<Drawer
|
||||
variant="permanent"
|
||||
classes={{
|
||||
paper: clsx(classes.drawerPaper)
|
||||
paper: clsx(classes.drawerPaper),
|
||||
}}
|
||||
>
|
||||
<List disablePadding>
|
||||
<Divider />
|
||||
<span key={"trade_overview"}>
|
||||
<span key="trade_overview">
|
||||
<ListItem button onClick={() => history.push(url)}>
|
||||
<ListItemText primary="Trade Overview" secondary={""} />
|
||||
<ListItemText primary="Trade Overview" secondary="" />
|
||||
</ListItem>
|
||||
</span>
|
||||
<Divider />
|
||||
<ListItem button onClick={() => history.push(`${url}/create`)}>
|
||||
<ListItemText primary={"Create Trade"} secondary={""} />
|
||||
<ListItemText primary="Create Trade" secondary="" />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
|
||||
<ListItem button onClick={() => history.push(`${url}/offer`)}>
|
||||
<ListItemText primary={"View Trade"} secondary={""} />
|
||||
<ListItemText primary="View Trade" secondary="" />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
</List>
|
||||
@@ -99,7 +105,7 @@ export default function TradeManager() {
|
||||
</Route>
|
||||
</Switch>
|
||||
</Grid>
|
||||
<Grid item xs={12}></Grid>
|
||||
<Grid item xs={12} />
|
||||
</Grid>
|
||||
</Container>
|
||||
</Flex>
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import React from "react";
|
||||
import { Typography, Button, Grid, Container } from "@material-ui/core";
|
||||
import { ArrowBackIos as ArrowBackIosIcon } from "@material-ui/icons";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import React from 'react';
|
||||
import { Typography, Button, Grid, Container } from '@material-ui/core';
|
||||
import { ArrowBackIos as ArrowBackIosIcon } from '@material-ui/icons';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { useEffectOnce } from 'react-use';
|
||||
import { genereate_mnemonics, add_new_key_action } from "../../modules/message";
|
||||
import TextField from "../form/TextField";
|
||||
import { genereate_mnemonics, add_new_key_action } from '../../modules/message';
|
||||
import TextField from '../form/TextField';
|
||||
import Brand from '../brand/Brand';
|
||||
import Flex from '../flex/Flex';
|
||||
import Loading from '../loading/Loading';
|
||||
import Link from '../router/Link';
|
||||
import LayoutHero from "../layout/LayoutHero";
|
||||
import type { RootState } from "../../modules/rootReducer";
|
||||
import LayoutHero from '../layout/LayoutHero';
|
||||
import type { RootState } from '../../modules/rootReducer';
|
||||
|
||||
const MnemonicField = (props: any) => {
|
||||
return (
|
||||
@@ -64,7 +64,7 @@ export default function WalletAdd() {
|
||||
Write down each word along with the order number next to them.
|
||||
(Order is important)
|
||||
</Typography>
|
||||
{!!words.length ? (
|
||||
{words.length ? (
|
||||
<Grid container spacing={2}>
|
||||
{words.map((word: string, index: number) => (
|
||||
<MnemonicField
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import React, { useState } from "react";
|
||||
import { Typography, Container, Button, Grid } from "@material-ui/core";
|
||||
import { ArrowBackIos as ArrowBackIosIcon } from "@material-ui/icons";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { useHistory } from "react-router";
|
||||
import TextField from "../form/TextField";
|
||||
import React, { useState } from 'react';
|
||||
import { Typography, Container, Button, Grid } from '@material-ui/core';
|
||||
import { ArrowBackIos as ArrowBackIosIcon } from '@material-ui/icons';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { useHistory } from 'react-router';
|
||||
import TextField from '../form/TextField';
|
||||
import Brand from '../brand/Brand';
|
||||
import Flex from '../flex/Flex';
|
||||
import Link from '../router/Link';
|
||||
import LayoutHero from "../layout/LayoutHero";
|
||||
import { mnemonic_word_added, resetMnemonic } from "../../modules/mnemonic";
|
||||
import { unselectFingerprint } from "../../modules/message";
|
||||
import type { RootState } from "../../modules/rootReducer";
|
||||
import LayoutHero from '../layout/LayoutHero';
|
||||
import { mnemonic_word_added, resetMnemonic } from '../../modules/mnemonic';
|
||||
import { unselectFingerprint } from '../../modules/message';
|
||||
import type { RootState } from '../../modules/rootReducer';
|
||||
|
||||
function MnemonicField(props: any) {
|
||||
return (
|
||||
@@ -41,15 +41,17 @@ function Iterator(props: any) {
|
||||
(state: RootState) => state.mnemonic_state.incorrect_word,
|
||||
);
|
||||
|
||||
function handleTextFieldChange(e: InputEvent & { target: { id: number, value: string }}) {
|
||||
function handleTextFieldChange(
|
||||
e: InputEvent & { target: { id: number; value: string } },
|
||||
) {
|
||||
if (!e.target) {
|
||||
return;
|
||||
}
|
||||
|
||||
var id = e.target.id + "";
|
||||
var clean_id = id.replace("id_", "");
|
||||
var int_val = parseInt(clean_id) - 1;
|
||||
var data = {
|
||||
const id = `${e.target.id}`;
|
||||
const clean_id = id.replace('id_', '');
|
||||
const int_val = parseInt(clean_id) - 1;
|
||||
const data = {
|
||||
word: e.target.value,
|
||||
id: int_val,
|
||||
};
|
||||
@@ -63,28 +65,26 @@ function Iterator(props: any) {
|
||||
onChange={handleTextFieldChange}
|
||||
key={i}
|
||||
error={
|
||||
(props.submitted && mnemonic_state.mnemonic_input[i] === "") ||
|
||||
(props.submitted && mnemonic_state.mnemonic_input[i] === '') ||
|
||||
mnemonic_state.mnemonic_input[i] === incorrect_word
|
||||
}
|
||||
value={mnemonic_state.mnemonic_input[i]}
|
||||
autofocus={focus}
|
||||
id={"id_" + (i + 1)}
|
||||
id={`id_${i + 1}`}
|
||||
index={i + 1}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
{indents}
|
||||
</>
|
||||
);
|
||||
return <>{indents}</>;
|
||||
}
|
||||
|
||||
export default function WalletImport() {
|
||||
const dispatch = useDispatch();
|
||||
const history = useHistory()
|
||||
const history = useHistory();
|
||||
const [submitted, setSubmitted] = useState<boolean>(false);
|
||||
const mnemonic = useSelector((state: RootState) => state.mnemonic_state.mnemonic_input);
|
||||
const mnemonic = useSelector(
|
||||
(state: RootState) => state.mnemonic_state.mnemonic_input,
|
||||
);
|
||||
|
||||
function handleBack() {
|
||||
dispatch(resetMnemonic());
|
||||
@@ -94,8 +94,8 @@ export default function WalletImport() {
|
||||
|
||||
function handleSubmit() {
|
||||
setSubmitted(true);
|
||||
for (var i = 0; i < mnemonic.length; i++) {
|
||||
if (mnemonic[i] === "") {
|
||||
for (let i = 0; i < mnemonic.length; i++) {
|
||||
if (mnemonic[i] === '') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,11 @@ export default function WalletImport() {
|
||||
return (
|
||||
<LayoutHero>
|
||||
<Container maxWidth="xl">
|
||||
<ArrowBackIosIcon onClick={handleBack} fontSize="large" color="secondary" />
|
||||
<ArrowBackIosIcon
|
||||
onClick={handleBack}
|
||||
fontSize="large"
|
||||
color="secondary"
|
||||
/>
|
||||
</Container>
|
||||
<Container maxWidth="lg">
|
||||
<Flex flexDirection="column" gap={3} alignItems="center">
|
||||
|
||||
@@ -1,111 +1,131 @@
|
||||
import React, { useState } from "react";
|
||||
import { Box, Grid, Container, Drawer, List, Divider, ListItem, ListItemText, Typography } from "@material-ui/core";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { Redirect, Route, Switch, useRouteMatch, useHistory } from "react-router";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import clsx from "clsx";
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Box,
|
||||
Grid,
|
||||
Container,
|
||||
Drawer,
|
||||
List,
|
||||
Divider,
|
||||
ListItem,
|
||||
ListItemText,
|
||||
Typography,
|
||||
} from '@material-ui/core';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import {
|
||||
Redirect,
|
||||
Route,
|
||||
Switch,
|
||||
useRouteMatch,
|
||||
useHistory,
|
||||
} from 'react-router';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import clsx from 'clsx';
|
||||
import Flex from '../flex/Flex';
|
||||
import DashboardTitle from '../dashboard/DashboardTitle';
|
||||
import StandardWallet from "./standard/WalletStandard";
|
||||
import StandardWallet from './standard/WalletStandard';
|
||||
import {
|
||||
changeWalletMenu,
|
||||
createWallet,
|
||||
standardWallet,
|
||||
CCWallet,
|
||||
RLWallet
|
||||
} from "../../modules/walletMenu";
|
||||
import { CreateWalletView } from "./create/WalletCreate";
|
||||
import ColouredWallet from "./coloured/WalletColoured";
|
||||
import RateLimitedWallet from "./rateLimited/WalletRateLimited";
|
||||
import type { RootState } from "../../modules/rootReducer";
|
||||
RLWallet,
|
||||
} from '../../modules/walletMenu';
|
||||
import { CreateWalletView } from './create/WalletCreate';
|
||||
import ColouredWallet from './coloured/WalletColoured';
|
||||
import RateLimitedWallet from './rateLimited/WalletRateLimited';
|
||||
import type { RootState } from '../../modules/rootReducer';
|
||||
import WalletType from '../../types/WalletType';
|
||||
|
||||
const drawerWidth = 180;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
drawerPaperClose: {
|
||||
overflowX: "hidden",
|
||||
transition: theme.transitions.create("width", {
|
||||
overflowX: 'hidden',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
width: theme.spacing(7),
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: theme.spacing(9)
|
||||
}
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: theme.spacing(9),
|
||||
},
|
||||
},
|
||||
paper: {
|
||||
padding: theme.spacing(0),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
fixedHeight: {
|
||||
height: 240
|
||||
height: 240,
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
balancePaper: {
|
||||
height: 200,
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
bottomOptions: {
|
||||
position: "absolute",
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
width: "100%"
|
||||
}
|
||||
width: '100%',
|
||||
},
|
||||
}));
|
||||
|
||||
const WalletItem = (props: any) => {
|
||||
const dispatch = useDispatch();
|
||||
const id = props.wallet_id;
|
||||
|
||||
const wallet = useSelector((state: RootState) => state.wallet_state.wallets[id]);
|
||||
var name = useSelector((state: RootState) => state.wallet_state.wallets[id].name);
|
||||
const wallet = useSelector(
|
||||
(state: RootState) => state.wallet_state.wallets[id],
|
||||
);
|
||||
let name = useSelector(
|
||||
(state: RootState) => state.wallet_state.wallets[id].name,
|
||||
);
|
||||
if (!name) {
|
||||
name = "";
|
||||
name = '';
|
||||
}
|
||||
var mainLabel = "";
|
||||
let mainLabel = '';
|
||||
if (wallet.type === WalletType.STANDARD_WALLET) {
|
||||
mainLabel = "Chia Wallet";
|
||||
name = "Chia";
|
||||
mainLabel = 'Chia Wallet';
|
||||
name = 'Chia';
|
||||
} else if (wallet.type === WalletType.COLOURED_COIN) {
|
||||
mainLabel = "CC Wallet";
|
||||
mainLabel = 'CC Wallet';
|
||||
if (name.length > 18) {
|
||||
name = name.substring(0, 18);
|
||||
name = name.concat("...");
|
||||
name = name.concat('...');
|
||||
}
|
||||
} else if (wallet.type === WalletType.RATE_LIMITED) {
|
||||
mainLabel = "RL Wallet";
|
||||
mainLabel = 'RL Wallet';
|
||||
if (name.length > 18) {
|
||||
name = name.substring(0, 18);
|
||||
name = name.concat("...");
|
||||
name = name.concat('...');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +151,7 @@ const CreateWallet = () => {
|
||||
const classes = useStyles();
|
||||
|
||||
function presentCreateWallet() {
|
||||
history.push('/dashboard/wallets/create')
|
||||
history.push('/dashboard/wallets/create');
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -146,10 +166,14 @@ const CreateWallet = () => {
|
||||
};
|
||||
|
||||
export const StatusCard = () => {
|
||||
const syncing = useSelector((state: RootState) => state.wallet_state.status.syncing);
|
||||
const height = useSelector((state: RootState) => state.wallet_state.status.height);
|
||||
const syncing = useSelector(
|
||||
(state: RootState) => state.wallet_state.status.syncing,
|
||||
);
|
||||
const height = useSelector(
|
||||
(state: RootState) => state.wallet_state.status.height,
|
||||
);
|
||||
const connection_count = useSelector(
|
||||
(state: RootState) => state.wallet_state.status.connection_count
|
||||
(state: RootState) => state.wallet_state.status.connection_count,
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -160,7 +184,7 @@ export const StatusCard = () => {
|
||||
<div style={{ marginLeft: 8 }}>
|
||||
<Box display="flex">
|
||||
<Box flexGrow={1}>status:</Box>
|
||||
<Box>{syncing ? "syncing" : "synced"}</Box>
|
||||
<Box>{syncing ? 'syncing' : 'synced'}</Box>
|
||||
</Box>
|
||||
<Box display="flex">
|
||||
<Box flexGrow={1}>height:</Box>
|
||||
@@ -184,13 +208,11 @@ export default function Wallets() {
|
||||
|
||||
return (
|
||||
<>
|
||||
<DashboardTitle>
|
||||
Wallets
|
||||
</DashboardTitle>
|
||||
<DashboardTitle>Wallets</DashboardTitle>
|
||||
<Drawer
|
||||
variant="permanent"
|
||||
classes={{
|
||||
paper: clsx(classes.drawerPaper, !open && classes.drawerPaperClose)
|
||||
paper: clsx(classes.drawerPaper, !open && classes.drawerPaperClose),
|
||||
}}
|
||||
open={open}
|
||||
>
|
||||
@@ -200,7 +222,7 @@ export default function Wallets() {
|
||||
<List disablePadding>
|
||||
{wallets.map((wallet) => (
|
||||
<span key={wallet.id}>
|
||||
<WalletItem wallet_id={wallet.id} key={wallet.id}></WalletItem>
|
||||
<WalletItem wallet_id={wallet.id} key={wallet.id} />
|
||||
<Divider />
|
||||
</span>
|
||||
))}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default {
|
||||
local_test: false,
|
||||
backup_host: "https://backup.chia.net"
|
||||
backup_host: 'https://backup.chia.net',
|
||||
};
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { wsConnect, wsConnecting } from "../modules/websocket";
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { wsConnect, wsConnecting } from '../modules/websocket';
|
||||
|
||||
const WebSocketConnection = props => {
|
||||
const WebSocketConnection = (props) => {
|
||||
const dispatch = useDispatch();
|
||||
const connected = useSelector(state => state.websocket.connected);
|
||||
const connecting = useSelector(state => state.websocket.connecting);
|
||||
var timeout = null;
|
||||
const connected = useSelector((state) => state.websocket.connected);
|
||||
const connecting = useSelector((state) => state.websocket.connecting);
|
||||
let timeout = null;
|
||||
|
||||
function connect() {
|
||||
timeout = setTimeout(() => {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { useLocalStorage, writeStorage } from '@rehooks/local-storage';
|
||||
|
||||
export default function useLocale(defaultLocale: string): [string, (locale: string) => void] {
|
||||
export default function useLocale(
|
||||
defaultLocale: string,
|
||||
): [string, (locale: string) => void] {
|
||||
const [locale] = useLocalStorage('locale');
|
||||
|
||||
function handleSetLocale(locale: string) {
|
||||
@@ -8,4 +10,4 @@ export default function useLocale(defaultLocale: string): [string, (locale: stri
|
||||
}
|
||||
|
||||
return [locale ?? defaultLocale, handleSetLocale];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom";
|
||||
import App from "./components/app/App";
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './components/app/App';
|
||||
// import "./assets/css/App.css";
|
||||
|
||||
ReactDOM.render((
|
||||
<App />
|
||||
), document.getElementById('root'));
|
||||
ReactDOM.render(<App />, document.getElementById('root'));
|
||||
|
||||
@@ -1,43 +1,44 @@
|
||||
import * as actions from "../modules/websocket";
|
||||
import * as actions from '../modules/websocket';
|
||||
import {
|
||||
registerService,
|
||||
startService,
|
||||
isServiceRunning,
|
||||
startServiceTest
|
||||
} from "../modules/daemon_messages";
|
||||
import { handle_message } from "./middleware_api";
|
||||
startServiceTest,
|
||||
} from '../modules/daemon_messages';
|
||||
import { handle_message } from './middleware_api';
|
||||
import {
|
||||
service_wallet,
|
||||
service_full_node,
|
||||
service_simulator,
|
||||
service_plotter
|
||||
} from "../util/service_names";
|
||||
const config = require("../config");
|
||||
service_plotter,
|
||||
} from '../util/service_names';
|
||||
|
||||
const crypto = require("crypto");
|
||||
const crypto = require('crypto');
|
||||
const config = require('../config');
|
||||
|
||||
const callback_map = {};
|
||||
|
||||
const outgoing_message = (command, data, destination) => ({
|
||||
command: command,
|
||||
data: data,
|
||||
command,
|
||||
data,
|
||||
ack: false,
|
||||
origin: "wallet_ui",
|
||||
destination: destination,
|
||||
request_id: crypto.randomBytes(32).toString("hex")
|
||||
origin: 'wallet_ui',
|
||||
destination,
|
||||
request_id: crypto.randomBytes(32).toString('hex'),
|
||||
});
|
||||
|
||||
const socketMiddleware = () => {
|
||||
let socket = null;
|
||||
let connected = false;
|
||||
|
||||
const onOpen = store => event => {
|
||||
const onOpen = (store) => (event) => {
|
||||
connected = true;
|
||||
store.dispatch(actions.wsConnected(event.target.url));
|
||||
var register_action = registerService();
|
||||
const register_action = registerService();
|
||||
store.dispatch(register_action);
|
||||
|
||||
let start_wallet, start_node;
|
||||
let start_wallet;
|
||||
let start_node;
|
||||
if (config.local_test) {
|
||||
start_wallet = startServiceTest(service_wallet);
|
||||
start_node = startService(service_simulator);
|
||||
@@ -50,14 +51,14 @@ const socketMiddleware = () => {
|
||||
store.dispatch(start_node);
|
||||
};
|
||||
|
||||
const onClose = store => () => {
|
||||
const onClose = (store) => () => {
|
||||
connected = false;
|
||||
store.dispatch(actions.wsDisconnected());
|
||||
};
|
||||
|
||||
const onMessage = store => event => {
|
||||
const onMessage = (store) => (event) => {
|
||||
const payload = JSON.parse(event.data);
|
||||
const request_id = payload["request_id"];
|
||||
const { request_id } = payload;
|
||||
if (callback_map[request_id] != null) {
|
||||
const callback_action = callback_map[request_id];
|
||||
const callback = callback_action.resolve_callback;
|
||||
@@ -67,9 +68,9 @@ const socketMiddleware = () => {
|
||||
handle_message(store, payload);
|
||||
};
|
||||
|
||||
return store => next => action => {
|
||||
return (store) => (next) => (action) => {
|
||||
switch (action.type) {
|
||||
case "WS_CONNECT":
|
||||
case 'WS_CONNECT':
|
||||
if (socket !== null) {
|
||||
socket.close();
|
||||
}
|
||||
@@ -78,7 +79,7 @@ const socketMiddleware = () => {
|
||||
try {
|
||||
socket = new WebSocket(action.host);
|
||||
} catch {
|
||||
console.log("Failed connection to", action.host);
|
||||
console.log('Failed connection to', action.host);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -87,25 +88,25 @@ const socketMiddleware = () => {
|
||||
socket.onclose = onClose(store);
|
||||
socket.onopen = onOpen(store);
|
||||
break;
|
||||
case "WS_DISCONNECT":
|
||||
case 'WS_DISCONNECT':
|
||||
if (socket !== null) {
|
||||
socket.close();
|
||||
}
|
||||
socket = null;
|
||||
break;
|
||||
case "OUTGOING_MESSAGE":
|
||||
case 'OUTGOING_MESSAGE':
|
||||
if (connected) {
|
||||
const message = outgoing_message(
|
||||
action.message.command,
|
||||
action.message.data,
|
||||
action.message.destination
|
||||
action.message.destination,
|
||||
);
|
||||
if (action.resolve_callback != null) {
|
||||
callback_map[message.request_id] = action;
|
||||
}
|
||||
socket.send(JSON.stringify(message));
|
||||
} else {
|
||||
console.log("Socket not connected");
|
||||
console.log('Socket not connected');
|
||||
}
|
||||
return next(action);
|
||||
default:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import isElectron from 'is-electron';
|
||||
import {
|
||||
get_address,
|
||||
format_message,
|
||||
@@ -9,61 +10,60 @@ import {
|
||||
get_connection_info,
|
||||
get_colour_info,
|
||||
get_colour_name,
|
||||
pingWallet
|
||||
} from "../modules/message";
|
||||
pingWallet,
|
||||
} from '../modules/message';
|
||||
|
||||
import { offerParsed, resetTrades } from "../modules/trade";
|
||||
import { openDialog } from "../modules/dialog";
|
||||
import { offerParsed, resetTrades } from '../modules/trade';
|
||||
import { openDialog } from '../modules/dialog';
|
||||
import {
|
||||
service_wallet,
|
||||
service_full_node,
|
||||
service_simulator,
|
||||
service_farmer,
|
||||
service_harvester,
|
||||
service_plotter
|
||||
} from "../util/service_names";
|
||||
service_plotter,
|
||||
} from '../util/service_names';
|
||||
import {
|
||||
pingFullNode,
|
||||
getBlockChainState,
|
||||
getLatestBlocks,
|
||||
getFullNodeConnections
|
||||
} from "../modules/fullnodeMessages";
|
||||
getFullNodeConnections,
|
||||
} from '../modules/fullnodeMessages';
|
||||
import {
|
||||
getLatestChallenges,
|
||||
getFarmerConnections,
|
||||
pingFarmer
|
||||
} from "../modules/farmerMessages";
|
||||
pingFarmer,
|
||||
} from '../modules/farmerMessages';
|
||||
import {
|
||||
getPlots,
|
||||
getPlotDirectories,
|
||||
pingHarvester,
|
||||
refreshPlots
|
||||
} from "../modules/harvesterMessages";
|
||||
import { changeEntranceMenu, presentSelectKeys } from "../modules/entranceMenu";
|
||||
refreshPlots,
|
||||
} from '../modules/harvesterMessages';
|
||||
import { changeEntranceMenu, presentSelectKeys } from '../modules/entranceMenu';
|
||||
import {
|
||||
addProgress,
|
||||
resetProgress,
|
||||
plottingStopped,
|
||||
plottingStarted
|
||||
} from "../modules/plotter_messages";
|
||||
import isElectron from "is-electron";
|
||||
import { startService, isServiceRunning } from "../modules/daemon_messages";
|
||||
import { get_all_trades } from "../modules/trade_messages";
|
||||
plottingStarted,
|
||||
} from '../modules/plotter_messages';
|
||||
import { startService, isServiceRunning } from '../modules/daemon_messages';
|
||||
import { get_all_trades } from '../modules/trade_messages';
|
||||
import {
|
||||
COLOURED_COIN,
|
||||
STANDARD_WALLET,
|
||||
RATE_LIMITED
|
||||
} from "../util/wallet_types";
|
||||
RATE_LIMITED,
|
||||
} from '../util/wallet_types';
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function ping_wallet(store) {
|
||||
store.dispatch(pingWallet());
|
||||
await sleep(1000);
|
||||
const state = store.getState();
|
||||
const wallet_connected = state.daemon_state.wallet_connected;
|
||||
const { wallet_connected } = state.daemon_state;
|
||||
if (!wallet_connected) {
|
||||
ping_wallet(store);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ async function ping_farmer(store) {
|
||||
store.dispatch(pingFarmer());
|
||||
await sleep(1000);
|
||||
const state = store.getState();
|
||||
const farmer_connected = state.daemon_state.farmer_connected;
|
||||
const { farmer_connected } = state.daemon_state;
|
||||
if (!farmer_connected) {
|
||||
ping_farmer(store);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ async function ping_harvester(store) {
|
||||
store.dispatch(pingHarvester());
|
||||
await sleep(1000);
|
||||
const state = store.getState();
|
||||
const harvester_connected = state.daemon_state.harvester_connected;
|
||||
const { harvester_connected } = state.daemon_state;
|
||||
if (!harvester_connected) {
|
||||
ping_harvester(store);
|
||||
}
|
||||
@@ -105,10 +105,10 @@ async function track_progress(store, location) {
|
||||
if (!isElectron()) {
|
||||
return;
|
||||
}
|
||||
const Tail = window.require("tail").Tail;
|
||||
const { Tail } = window.require('tail');
|
||||
|
||||
const dispatch = store.dispatch;
|
||||
var options = { fromBeginning: true, follow: true, useWatchFile: true };
|
||||
const { dispatch } = store;
|
||||
const options = { fromBeginning: true, follow: true, useWatchFile: true };
|
||||
if (!location) {
|
||||
return;
|
||||
}
|
||||
@@ -119,13 +119,13 @@ async function track_progress(store, location) {
|
||||
global_tail.unwatch();
|
||||
}
|
||||
global_tail = new Tail(location, options);
|
||||
global_tail.on("line", data => {
|
||||
global_tail.on('line', (data) => {
|
||||
dispatch(addProgress(data));
|
||||
if (data.includes("Renamed final file")) {
|
||||
if (data.includes('Renamed final file')) {
|
||||
dispatch(refreshPlots());
|
||||
}
|
||||
});
|
||||
global_tail.on("error", err => {
|
||||
global_tail.on('error', (err) => {
|
||||
dispatch(addProgress(err));
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -133,10 +133,10 @@ async function track_progress(store, location) {
|
||||
}
|
||||
}
|
||||
|
||||
export const refreshAllState = dispatch => {
|
||||
dispatch(format_message("get_wallets", {}));
|
||||
let start_farmer = startService(service_farmer);
|
||||
let start_harvester = startService(service_harvester);
|
||||
export const refreshAllState = (dispatch) => {
|
||||
dispatch(format_message('get_wallets', {}));
|
||||
const start_farmer = startService(service_farmer);
|
||||
const start_harvester = startService(service_harvester);
|
||||
dispatch(start_farmer);
|
||||
dispatch(start_harvester);
|
||||
dispatch(get_height_info());
|
||||
@@ -155,10 +155,10 @@ export const refreshAllState = dispatch => {
|
||||
|
||||
export const handle_message = (store, payload) => {
|
||||
store.dispatch(incomingMessage(payload));
|
||||
if (payload.command === "ping") {
|
||||
if (payload.command === 'ping') {
|
||||
if (payload.origin === service_wallet) {
|
||||
store.dispatch(get_connection_info());
|
||||
store.dispatch(format_message("get_public_keys", {}));
|
||||
store.dispatch(format_message('get_public_keys', {}));
|
||||
} else if (payload.origin === service_full_node) {
|
||||
store.dispatch(getBlockChainState());
|
||||
store.dispatch(getLatestBlocks());
|
||||
@@ -168,47 +168,44 @@ export const handle_message = (store, payload) => {
|
||||
store.dispatch(getFarmerConnections());
|
||||
} else if (payload.origin === service_harvester) {
|
||||
}
|
||||
} else if (payload.command === "delete_key") {
|
||||
} else if (payload.command === 'delete_key') {
|
||||
if (payload.data.success) {
|
||||
store.dispatch(format_message("get_public_keys", {}));
|
||||
store.dispatch(format_message('get_public_keys', {}));
|
||||
}
|
||||
} else if (payload.command === "delete_all_keys") {
|
||||
} else if (payload.command === 'delete_all_keys') {
|
||||
if (payload.data.success) {
|
||||
store.dispatch(format_message("get_public_keys", {}));
|
||||
store.dispatch(format_message('get_public_keys', {}));
|
||||
}
|
||||
} else if (payload.command === "get_public_keys") {
|
||||
} else if (payload.command === 'get_public_keys') {
|
||||
if (payload.data.success) {
|
||||
store.dispatch(changeEntranceMenu(presentSelectKeys));
|
||||
}
|
||||
} else if (payload.command === "get_private_key") {
|
||||
} else if (payload.command === 'get_private_key') {
|
||||
const text =
|
||||
"Private key: " +
|
||||
payload.data.private_key.sk +
|
||||
"\n" +
|
||||
"Public key: " +
|
||||
payload.data.private_key.pk +
|
||||
"\n" +
|
||||
(payload.data.private_key.seed
|
||||
? "seed: " + payload.data.private_key.seed
|
||||
: "No 24 word seed, since this key is imported.");
|
||||
`Private key: ${payload.data.private_key.sk}\n` +
|
||||
`Public key: ${payload.data.private_key.pk}\n${
|
||||
payload.data.private_key.seed
|
||||
? `seed: ${payload.data.private_key.seed}`
|
||||
: 'No 24 word seed, since this key is imported.'
|
||||
}`;
|
||||
store.dispatch(
|
||||
openDialog("Private key " + payload.data.private_key.fingerprint, text)
|
||||
openDialog(`Private key ${payload.data.private_key.fingerprint}`, text),
|
||||
);
|
||||
} else if (payload.command === "delete_plot") {
|
||||
} else if (payload.command === 'delete_plot') {
|
||||
store.dispatch(refreshPlots());
|
||||
} else if (payload.command === "refresh_plots") {
|
||||
} else if (payload.command === 'refresh_plots') {
|
||||
store.dispatch(getPlots());
|
||||
} else if (payload.command === "get_wallets") {
|
||||
} else if (payload.command === 'get_wallets') {
|
||||
if (payload.data.success) {
|
||||
const wallets = payload.data.wallets;
|
||||
for (let wallet of wallets) {
|
||||
const { wallets } = payload.data;
|
||||
for (const wallet of wallets) {
|
||||
if (wallet.type === RATE_LIMITED) {
|
||||
const data = JSON.parse(wallet.data);
|
||||
wallet.data = data;
|
||||
if (data.initialized === true) {
|
||||
store.dispatch(get_balance_for_wallet(wallet.id));
|
||||
} else {
|
||||
console.log("RL wallet has not been initalized yet");
|
||||
console.log('RL wallet has not been initalized yet');
|
||||
}
|
||||
} else {
|
||||
store.dispatch(get_balance_for_wallet(wallet.id));
|
||||
@@ -223,41 +220,41 @@ export const handle_message = (store, payload) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (payload.command === "state_changed") {
|
||||
const state = payload.data.state;
|
||||
if (state === "coin_added" || state === "coin_removed") {
|
||||
var wallet_id = payload.data.wallet_id;
|
||||
} else if (payload.command === 'state_changed') {
|
||||
const { state } = payload.data;
|
||||
if (state === 'coin_added' || state === 'coin_removed') {
|
||||
var { wallet_id } = payload.data;
|
||||
store.dispatch(get_balance_for_wallet(wallet_id));
|
||||
store.dispatch(get_transactions(wallet_id));
|
||||
} else if (state === "sync_changed") {
|
||||
} else if (state === 'sync_changed') {
|
||||
store.dispatch(get_sync_status());
|
||||
} else if (state === "new_block") {
|
||||
} else if (state === 'new_block') {
|
||||
store.dispatch(get_height_info());
|
||||
} else if (state === "pending_transaction") {
|
||||
} else if (state === 'pending_transaction') {
|
||||
wallet_id = payload.data.wallet_id;
|
||||
store.dispatch(get_balance_for_wallet(wallet_id));
|
||||
store.dispatch(get_transactions(wallet_id));
|
||||
}
|
||||
} else if (payload.command === "cc_set_name") {
|
||||
} else if (payload.command === 'cc_set_name') {
|
||||
if (payload.data.success) {
|
||||
const wallet_id = payload.data.wallet_id;
|
||||
const { wallet_id } = payload.data;
|
||||
store.dispatch(get_colour_name(wallet_id));
|
||||
}
|
||||
} else if (payload.command === "respond_to_offer") {
|
||||
} else if (payload.command === 'respond_to_offer') {
|
||||
if (payload.data.success) {
|
||||
store.dispatch(openDialog("Success!", "Offer accepted"));
|
||||
store.dispatch(openDialog('Success!', 'Offer accepted'));
|
||||
}
|
||||
store.dispatch(resetTrades());
|
||||
} else if (payload.command === "get_discrepancies_for_offer") {
|
||||
} else if (payload.command === 'get_discrepancies_for_offer') {
|
||||
if (payload.data.success) {
|
||||
store.dispatch(offerParsed(payload.data.discrepancies));
|
||||
}
|
||||
} else if (payload.command === "start_plotting") {
|
||||
} else if (payload.command === 'start_plotting') {
|
||||
if (payload.data.success) {
|
||||
track_progress(store, payload.data.out_file);
|
||||
}
|
||||
} else if (payload.command === "start_service") {
|
||||
const service = payload.data.service;
|
||||
} else if (payload.command === 'start_service') {
|
||||
const { service } = payload.data;
|
||||
if (payload.data.success) {
|
||||
if (service === service_wallet) {
|
||||
ping_wallet(store);
|
||||
@@ -272,7 +269,7 @@ export const handle_message = (store, payload) => {
|
||||
} else if (service === service_plotter) {
|
||||
track_progress(store, payload.data.out_file);
|
||||
}
|
||||
} else if (payload.data.error.includes("already running")) {
|
||||
} else if (payload.data.error.includes('already running')) {
|
||||
if (service === service_wallet) {
|
||||
ping_wallet(store);
|
||||
} else if (service === service_full_node) {
|
||||
@@ -286,17 +283,17 @@ export const handle_message = (store, payload) => {
|
||||
} else if (service === service_plotter) {
|
||||
}
|
||||
}
|
||||
} else if (payload.command === "is_running") {
|
||||
} else if (payload.command === 'is_running') {
|
||||
if (payload.data.success) {
|
||||
const service = payload.data.service_name;
|
||||
const is_running = payload.data.is_running;
|
||||
const { is_running } = payload.data;
|
||||
if (service === service_plotter) {
|
||||
if (is_running) {
|
||||
track_progress(store, payload.data.out_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (payload.command === "stop_service") {
|
||||
} else if (payload.command === 'stop_service') {
|
||||
if (payload.data.success) {
|
||||
if (payload.data.service_name === service_plotter) {
|
||||
store.dispatch(plottingStopped());
|
||||
@@ -305,14 +302,14 @@ export const handle_message = (store, payload) => {
|
||||
}
|
||||
if (payload.data.success === false) {
|
||||
if (
|
||||
payload.data.error && (
|
||||
payload.data.error.includes("already running") ||
|
||||
payload.data.error === "not_initialized")
|
||||
payload.data.error &&
|
||||
(payload.data.error.includes('already running') ||
|
||||
payload.data.error === 'not_initialized')
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (payload.data.error) {
|
||||
store.dispatch(openDialog("Error: ", payload.data.error));
|
||||
store.dispatch(openDialog('Error: ', payload.data.error));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,48 +1,56 @@
|
||||
export const presentBackupInfo = "BACKUP_INFO";
|
||||
export const presentMain = "MAIN";
|
||||
export const presentBackupInfo = 'BACKUP_INFO';
|
||||
export const presentMain = 'MAIN';
|
||||
|
||||
export const changeBackupView = (view: 'MAIN' | 'BACKUP_INFO') => ({ type: "BACKUP_VIEW", view });
|
||||
export const changeBackupView = (view: 'MAIN' | 'BACKUP_INFO') => ({
|
||||
type: 'BACKUP_VIEW',
|
||||
view,
|
||||
});
|
||||
export const setBackupInfo = (backup_info: Object) => ({
|
||||
type: "BACKUP_INFO",
|
||||
type: 'BACKUP_INFO',
|
||||
backup_info,
|
||||
});
|
||||
|
||||
export const selectFilePath = (file_path: string) => ({
|
||||
type: "SELECT_FILEPATH",
|
||||
type: 'SELECT_FILEPATH',
|
||||
file_path,
|
||||
});
|
||||
|
||||
type BackupState = {
|
||||
view: 'MAIN' | 'BACKUP_INFO',
|
||||
backup_info: {} | {
|
||||
type: 'BACKUP_INFO' | 'SELECT_FILEPATH',
|
||||
backup_info?: string,
|
||||
file_path?: string,
|
||||
},
|
||||
selected_file_path?: string | null,
|
||||
view: 'MAIN' | 'BACKUP_INFO';
|
||||
backup_info:
|
||||
| {}
|
||||
| {
|
||||
type: 'BACKUP_INFO' | 'SELECT_FILEPATH';
|
||||
backup_info?: string;
|
||||
file_path?: string;
|
||||
};
|
||||
selected_file_path?: string | null;
|
||||
};
|
||||
|
||||
const initialState: BackupState = {
|
||||
view: presentMain,
|
||||
backup_info: {},
|
||||
selected_file_path: null
|
||||
selected_file_path: null,
|
||||
};
|
||||
|
||||
export default function backupReducer(state: BackupState = { ...initialState }, action: any): BackupState {
|
||||
export default function backupReducer(
|
||||
state: BackupState = { ...initialState },
|
||||
action: any,
|
||||
): BackupState {
|
||||
switch (action.type) {
|
||||
case "BACKUP_VIEW":
|
||||
return {
|
||||
...state,
|
||||
case 'BACKUP_VIEW':
|
||||
return {
|
||||
...state,
|
||||
view: action.view,
|
||||
};
|
||||
case "BACKUP_INFO":
|
||||
return {
|
||||
...state,
|
||||
case 'BACKUP_INFO':
|
||||
return {
|
||||
...state,
|
||||
backup_info: action.backup_info,
|
||||
};
|
||||
case "SELECT_FILEPATH":
|
||||
return {
|
||||
...state,
|
||||
case 'SELECT_FILEPATH':
|
||||
return {
|
||||
...state,
|
||||
selected_file_path: action.file_path,
|
||||
};
|
||||
default:
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
export const CREATE_CC_WALLET_OPTIONS = "CREATE_CC_WALLET_OPTIONS";
|
||||
export const CREATE_NEW_CC = "CREATE_NEW_CC";
|
||||
export const CREATE_EXISTING_CC = "CREATE_EXISTING_CC";
|
||||
export const CREATE_RL_WALLET_OPTIONS = "CREATE_RL_WALLET_OPTIONS";
|
||||
export const CREATE_RL_ADMIN = "CREATE_RL_ADMIN";
|
||||
export const CREATE_RL_USER = "CREATE_RL_USER";
|
||||
export const ALL_OPTIONS = "ALL_OPTIONS";
|
||||
export const CREATE_CC_WALLET_OPTIONS = 'CREATE_CC_WALLET_OPTIONS';
|
||||
export const CREATE_NEW_CC = 'CREATE_NEW_CC';
|
||||
export const CREATE_EXISTING_CC = 'CREATE_EXISTING_CC';
|
||||
export const CREATE_RL_WALLET_OPTIONS = 'CREATE_RL_WALLET_OPTIONS';
|
||||
export const CREATE_RL_ADMIN = 'CREATE_RL_ADMIN';
|
||||
export const CREATE_RL_USER = 'CREATE_RL_USER';
|
||||
export const ALL_OPTIONS = 'ALL_OPTIONS';
|
||||
|
||||
export const changeCreateWallet = (item: string) => ({
|
||||
type: "CREATE_OPTIONS",
|
||||
type: 'CREATE_OPTIONS',
|
||||
item,
|
||||
});
|
||||
|
||||
export const createState = (created: boolean, pending: boolean) => ({
|
||||
type: "CREATE_STATE",
|
||||
type: 'CREATE_STATE',
|
||||
created,
|
||||
pending,
|
||||
});
|
||||
|
||||
type CreateWalletState = {
|
||||
view: string,
|
||||
created: boolean,
|
||||
pending: boolean,
|
||||
view: string;
|
||||
created: boolean;
|
||||
pending: boolean;
|
||||
};
|
||||
|
||||
const initialState: CreateWalletState = {
|
||||
@@ -29,18 +29,21 @@ const initialState: CreateWalletState = {
|
||||
pending: false,
|
||||
};
|
||||
|
||||
export default function createWalletReducer(state: CreateWalletState = { ...initialState }, action: any): CreateWalletState {
|
||||
export default function createWalletReducer(
|
||||
state: CreateWalletState = { ...initialState },
|
||||
action: any,
|
||||
): CreateWalletState {
|
||||
switch (action.type) {
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return { ...initialState };
|
||||
case "CREATE_OPTIONS":
|
||||
var item = action.item;
|
||||
case 'CREATE_OPTIONS':
|
||||
var { item } = action;
|
||||
return { ...state, view: item };
|
||||
case "CREATE_STATE":
|
||||
return {
|
||||
...state,
|
||||
created: action.created,
|
||||
pending: action.pending,
|
||||
case 'CREATE_STATE':
|
||||
return {
|
||||
...state,
|
||||
created: action.created,
|
||||
pending: action.pending,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -5,22 +5,22 @@ import {
|
||||
service_daemon,
|
||||
service_farmer,
|
||||
service_harvester,
|
||||
service_plotter
|
||||
} from "../util/service_names";
|
||||
service_plotter,
|
||||
} from '../util/service_names';
|
||||
|
||||
type DeamonState = {
|
||||
daemon_running: boolean,
|
||||
daemon_connected: boolean,
|
||||
wallet_running: boolean,
|
||||
wallet_connected: boolean,
|
||||
full_node_running: boolean,
|
||||
full_node_connected: boolean,
|
||||
farmer_running: boolean,
|
||||
farmer_connected: boolean,
|
||||
harvester_running: boolean,
|
||||
harvester_connected: boolean,
|
||||
plotter_running: boolean,
|
||||
exiting: boolean,
|
||||
daemon_running: boolean;
|
||||
daemon_connected: boolean;
|
||||
wallet_running: boolean;
|
||||
wallet_connected: boolean;
|
||||
full_node_running: boolean;
|
||||
full_node_connected: boolean;
|
||||
farmer_running: boolean;
|
||||
farmer_connected: boolean;
|
||||
harvester_running: boolean;
|
||||
harvester_connected: boolean;
|
||||
plotter_running: boolean;
|
||||
exiting: boolean;
|
||||
};
|
||||
|
||||
const initialState: DeamonState = {
|
||||
@@ -35,55 +35,68 @@ const initialState: DeamonState = {
|
||||
harvester_running: false,
|
||||
harvester_connected: false,
|
||||
plotter_running: false,
|
||||
exiting: false
|
||||
exiting: false,
|
||||
};
|
||||
|
||||
export default function daemonReducer(state = { ...initialState }, action: any): DeamonState {
|
||||
export default function daemonReducer(
|
||||
state = { ...initialState },
|
||||
action: any,
|
||||
): DeamonState {
|
||||
switch (action.type) {
|
||||
case "INCOMING_MESSAGE":
|
||||
case 'INCOMING_MESSAGE':
|
||||
if (
|
||||
action.message.origin !== service_daemon &&
|
||||
action.message.command !== "ping"
|
||||
action.message.command !== 'ping'
|
||||
) {
|
||||
return state;
|
||||
}
|
||||
const message = action.message;
|
||||
const data = message.data;
|
||||
const command = message.command;
|
||||
if (command === "register_service") {
|
||||
if (command === 'register_service') {
|
||||
return { ...state, daemon_running: true, daemon_connected: true };
|
||||
} else if (command === "start_service") {
|
||||
}
|
||||
if (command === 'start_service') {
|
||||
const service = data.service;
|
||||
if (service === service_full_node) {
|
||||
return { ...state, full_node_running: true };
|
||||
} else if (service === service_simulator) {
|
||||
}
|
||||
if (service === service_simulator) {
|
||||
return { ...state, full_node_running: true };
|
||||
} else if (service === service_wallet) {
|
||||
}
|
||||
if (service === service_wallet) {
|
||||
return { ...state, wallet_running: true };
|
||||
} else if (service === service_farmer) {
|
||||
}
|
||||
if (service === service_farmer) {
|
||||
return { ...state, farmer_running: true };
|
||||
} else if (service === service_harvester) {
|
||||
}
|
||||
if (service === service_harvester) {
|
||||
return { ...state, harvester_running: true };
|
||||
}
|
||||
} else if (command === "ping") {
|
||||
} else if (command === 'ping') {
|
||||
const origin = message.origin;
|
||||
if (origin === service_full_node) {
|
||||
return { ...state, full_node_connected: true };
|
||||
} else if (origin === service_simulator) {
|
||||
}
|
||||
if (origin === service_simulator) {
|
||||
return { ...state, full_node_connected: true };
|
||||
} else if (origin === service_wallet) {
|
||||
}
|
||||
if (origin === service_wallet) {
|
||||
return { ...state, wallet_connected: true };
|
||||
} else if (origin === service_farmer) {
|
||||
}
|
||||
if (origin === service_farmer) {
|
||||
return { ...state, farmer_connected: true };
|
||||
} else if (origin === service_harvester) {
|
||||
}
|
||||
if (origin === service_harvester) {
|
||||
return { ...state, harvester_connected: true };
|
||||
}
|
||||
} else if (command === "is_running") {
|
||||
} else if (command === 'is_running') {
|
||||
if (data.success) {
|
||||
const service = data.service;
|
||||
if (service === service_plotter) {
|
||||
return { ...state, plotter_running: data.is_running };
|
||||
} else if (service === service_full_node) {
|
||||
}
|
||||
if (service === service_full_node) {
|
||||
return { ...state, full_node_running: data.is_running };
|
||||
} else if (service === service_wallet) {
|
||||
return { ...state, wallet_running: data.is_running };
|
||||
@@ -93,7 +106,7 @@ export default function daemonReducer(state = { ...initialState }, action: any):
|
||||
return { ...state, harvester_running: data.is_running };
|
||||
}
|
||||
}
|
||||
} else if (command === "stop_service") {
|
||||
} else if (command === 'stop_service') {
|
||||
if (data.success) {
|
||||
if (data.service_name === service_plotter) {
|
||||
return { ...state, plotter_running: false };
|
||||
@@ -101,15 +114,15 @@ export default function daemonReducer(state = { ...initialState }, action: any):
|
||||
}
|
||||
}
|
||||
return state;
|
||||
case "OUTGOING_MESSAGE":
|
||||
case 'OUTGOING_MESSAGE':
|
||||
if (
|
||||
action.message.command === "exit" &&
|
||||
action.message.destination === "daemon"
|
||||
action.message.command === 'exit' &&
|
||||
action.message.destination === 'daemon'
|
||||
) {
|
||||
return { ...state, exiting: true };
|
||||
}
|
||||
return state;
|
||||
case "WS_DISCONNECTED":
|
||||
case 'WS_DISCONNECTED':
|
||||
return initialState;
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -1,47 +1,47 @@
|
||||
export const daemonMessage = () => ({
|
||||
type: "OUTGOING_MESSAGE",
|
||||
type: 'OUTGOING_MESSAGE',
|
||||
message: {
|
||||
destination: "daemon"
|
||||
}
|
||||
destination: 'daemon',
|
||||
},
|
||||
});
|
||||
|
||||
export const registerService = () => {
|
||||
var action = daemonMessage();
|
||||
action.message.command = "register_service";
|
||||
action.message.data = { service: "wallet_ui" };
|
||||
const action = daemonMessage();
|
||||
action.message.command = 'register_service';
|
||||
action.message.data = { service: 'wallet_ui' };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const startService = service_name => {
|
||||
var action = daemonMessage();
|
||||
action.message.command = "start_service";
|
||||
export const startService = (service_name) => {
|
||||
const action = daemonMessage();
|
||||
action.message.command = 'start_service';
|
||||
action.message.data = { service: service_name };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const startServiceTest = service_name => {
|
||||
var action = daemonMessage();
|
||||
action.message.command = "start_service";
|
||||
export const startServiceTest = (service_name) => {
|
||||
const action = daemonMessage();
|
||||
action.message.command = 'start_service';
|
||||
action.message.data = { service: service_name, testing: true };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const stopService = service_name => {
|
||||
var action = daemonMessage();
|
||||
action.message.command = "stop_service";
|
||||
export const stopService = (service_name) => {
|
||||
const action = daemonMessage();
|
||||
action.message.command = 'stop_service';
|
||||
action.message.data = { service: service_name };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const isServiceRunning = service_name => {
|
||||
var action = daemonMessage();
|
||||
action.message.command = "is_running";
|
||||
export const isServiceRunning = (service_name) => {
|
||||
const action = daemonMessage();
|
||||
action.message.command = 'is_running';
|
||||
action.message.data = { service: service_name };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const exitDaemon = () => {
|
||||
var action = daemonMessage();
|
||||
action.message.command = "exit";
|
||||
const action = daemonMessage();
|
||||
action.message.command = 'exit';
|
||||
return action;
|
||||
};
|
||||
|
||||
@@ -2,7 +2,7 @@ import createDialog from '../util/createDialog';
|
||||
|
||||
export const openDialog = (title: string, text: string) => {
|
||||
return {
|
||||
type: "DIALOG_CONTROL",
|
||||
type: 'DIALOG_CONTROL',
|
||||
open: true,
|
||||
title,
|
||||
text,
|
||||
@@ -11,7 +11,7 @@ export const openDialog = (title: string, text: string) => {
|
||||
|
||||
export const closeDialog = (id: number) => {
|
||||
return {
|
||||
type: "DIALOG_CONTROL",
|
||||
type: 'DIALOG_CONTROL',
|
||||
open: false,
|
||||
id,
|
||||
};
|
||||
@@ -19,35 +19,35 @@ export const closeDialog = (id: number) => {
|
||||
|
||||
type DialogState = {
|
||||
dialogs: {
|
||||
id: number,
|
||||
title: string,
|
||||
label: string,
|
||||
}[],
|
||||
id: number;
|
||||
title: string;
|
||||
label: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
const initialState: DialogState = {
|
||||
dialogs: []
|
||||
dialogs: [],
|
||||
};
|
||||
|
||||
export default function dialogReducer(state = { ...initialState }, action: any): DialogState {
|
||||
export default function dialogReducer(
|
||||
state = { ...initialState },
|
||||
action: any,
|
||||
): DialogState {
|
||||
switch (action.type) {
|
||||
case "DIALOG_CONTROL":
|
||||
case 'DIALOG_CONTROL':
|
||||
if (action.open) {
|
||||
const { title, text } = action;
|
||||
|
||||
return {
|
||||
...state,
|
||||
dialogs: [
|
||||
...state.dialogs,
|
||||
createDialog(Date.now(), title, text)
|
||||
],
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
return {
|
||||
...state,
|
||||
dialogs: state.dialogs.filter((dialog) => dialog.id !== action.id),
|
||||
dialogs: [...state.dialogs, createDialog(Date.now(), title, text)],
|
||||
};
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
dialogs: state.dialogs.filter((dialog) => dialog.id !== action.id),
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
export const presentNewWallet = "NEW_WALLET";
|
||||
export const presentOldWallet = "OLD_WALLET";
|
||||
export const presentDashboard = "DASHBOARD";
|
||||
export const presentSelectKeys = "SELECT_KEYS";
|
||||
export const presentRestoreBackup = "RESTORE_BACKUP";
|
||||
export const presentNewWallet = 'NEW_WALLET';
|
||||
export const presentOldWallet = 'OLD_WALLET';
|
||||
export const presentDashboard = 'DASHBOARD';
|
||||
export const presentSelectKeys = 'SELECT_KEYS';
|
||||
export const presentRestoreBackup = 'RESTORE_BACKUP';
|
||||
|
||||
export const changeEntranceMenu = item => ({
|
||||
type: "ENTRANCE_MENU",
|
||||
item: item
|
||||
export const changeEntranceMenu = (item) => ({
|
||||
type: 'ENTRANCE_MENU',
|
||||
item,
|
||||
});
|
||||
|
||||
const initial_state = {
|
||||
view: presentSelectKeys
|
||||
view: presentSelectKeys,
|
||||
};
|
||||
|
||||
export const entranceReducer = (state = { ...initial_state }, action) => {
|
||||
switch (action.type) {
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return { ...initial_state };
|
||||
case "ENTRANCE_MENU":
|
||||
var item = action.item;
|
||||
case 'ENTRANCE_MENU':
|
||||
var { item } = action;
|
||||
return { ...state, view: item };
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -1,43 +1,43 @@
|
||||
import { service_farmer } from "../util/service_names";
|
||||
import { service_farmer } from '../util/service_names';
|
||||
|
||||
export const farmerMessage = () => ({
|
||||
type: "OUTGOING_MESSAGE",
|
||||
type: 'OUTGOING_MESSAGE',
|
||||
message: {
|
||||
destination: service_farmer
|
||||
}
|
||||
destination: service_farmer,
|
||||
},
|
||||
});
|
||||
|
||||
export const pingFarmer = () => {
|
||||
var action = farmerMessage();
|
||||
action.message.command = "ping";
|
||||
const action = farmerMessage();
|
||||
action.message.command = 'ping';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getLatestChallenges = () => {
|
||||
var action = farmerMessage();
|
||||
action.message.command = "get_latest_challenges";
|
||||
const action = farmerMessage();
|
||||
action.message.command = 'get_latest_challenges';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getFarmerConnections = () => {
|
||||
var action = farmerMessage();
|
||||
action.message.command = "get_connections";
|
||||
const action = farmerMessage();
|
||||
action.message.command = 'get_connections';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const openConnection = (host, port) => {
|
||||
var action = farmerMessage();
|
||||
action.message.command = "open_connection";
|
||||
const action = farmerMessage();
|
||||
action.message.command = 'open_connection';
|
||||
action.message.data = { host, port };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const closeConnection = node_id => {
|
||||
var action = farmerMessage();
|
||||
action.message.command = "close_connection";
|
||||
export const closeConnection = (node_id) => {
|
||||
const action = farmerMessage();
|
||||
action.message.command = 'close_connection';
|
||||
action.message.data = { node_id };
|
||||
return action;
|
||||
};
|
||||
|
||||
@@ -1,88 +1,93 @@
|
||||
import { service_farmer, service_harvester } from "../util/service_names";
|
||||
import { service_farmer, service_harvester } from '../util/service_names';
|
||||
|
||||
type FarmingState = {
|
||||
farmer: {
|
||||
latest_challenges: string[],
|
||||
connections: string[],
|
||||
open_connection_error?: string,
|
||||
},
|
||||
latest_challenges: string[];
|
||||
connections: string[];
|
||||
open_connection_error?: string;
|
||||
};
|
||||
harvester: {
|
||||
plots: string[],
|
||||
not_found_filenames: string[],
|
||||
failed_to_open_filenames: string[],
|
||||
plot_directories: string[]
|
||||
}
|
||||
plots: string[];
|
||||
not_found_filenames: string[];
|
||||
failed_to_open_filenames: string[];
|
||||
plot_directories: string[];
|
||||
};
|
||||
};
|
||||
|
||||
const initialState: FarmingState = {
|
||||
const initialState: FarmingState = {
|
||||
farmer: {
|
||||
latest_challenges: [],
|
||||
connections: [],
|
||||
open_connection_error: "",
|
||||
open_connection_error: '',
|
||||
},
|
||||
harvester: {
|
||||
plots: [],
|
||||
not_found_filenames: [],
|
||||
failed_to_open_filenames: [],
|
||||
plot_directories: []
|
||||
}
|
||||
plot_directories: [],
|
||||
},
|
||||
};
|
||||
|
||||
export default function farmingReducer(state: FarmingState = { ...initialState }, action: any): FarmingState {
|
||||
export default function farmingReducer(
|
||||
state: FarmingState = { ...initialState },
|
||||
action: any,
|
||||
): FarmingState {
|
||||
switch (action.type) {
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return { ...initialState };
|
||||
case "INCOMING_MESSAGE":
|
||||
case 'INCOMING_MESSAGE':
|
||||
if (
|
||||
action.message.origin !== service_farmer &&
|
||||
action.message.origin !== service_harvester
|
||||
) {
|
||||
return state;
|
||||
}
|
||||
const message = action.message;
|
||||
const data = message.data;
|
||||
const command = message.command;
|
||||
const { message } = action;
|
||||
const { data } = message;
|
||||
const { command } = message;
|
||||
|
||||
// Farmer API
|
||||
if (command === "get_latest_challenges") {
|
||||
if (command === 'get_latest_challenges') {
|
||||
if (data.success === false) {
|
||||
return state;
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
farmer: { ...state.farmer, latest_challenges: data.latest_challenges }
|
||||
farmer: {
|
||||
...state.farmer,
|
||||
latest_challenges: data.latest_challenges,
|
||||
},
|
||||
};
|
||||
}
|
||||
if (
|
||||
command === "get_connections" &&
|
||||
command === 'get_connections' &&
|
||||
action.message.origin === service_farmer
|
||||
) {
|
||||
if (data.success) {
|
||||
return {
|
||||
...state,
|
||||
farmer: { ...state.farmer, connections: data.connections }
|
||||
farmer: { ...state.farmer, connections: data.connections },
|
||||
};
|
||||
}
|
||||
}
|
||||
if (
|
||||
command === "open_connection" &&
|
||||
command === 'open_connection' &&
|
||||
action.message.origin === service_farmer
|
||||
) {
|
||||
if (data.success) {
|
||||
return {
|
||||
...state,
|
||||
farmer: { ...state.farmer, open_connection_error: "" }
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
...state,
|
||||
farmer: { ...state.farmer, open_connection_error: data.error }
|
||||
farmer: { ...state.farmer, open_connection_error: '' },
|
||||
};
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
farmer: { ...state.farmer, open_connection_error: data.error },
|
||||
};
|
||||
}
|
||||
|
||||
// Harvester API
|
||||
if (command === "get_plots") {
|
||||
if (command === 'get_plots') {
|
||||
if (data.success !== true) {
|
||||
return state;
|
||||
}
|
||||
@@ -92,12 +97,12 @@ export default function farmingReducer(state: FarmingState = { ...initialState }
|
||||
...state.harvester,
|
||||
plots: data.plots,
|
||||
failed_to_open_filenames: data.failed_to_open_filenames,
|
||||
not_found_filenames: data.not_found_filenames
|
||||
}
|
||||
not_found_filenames: data.not_found_filenames,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
if (command === "get_plot_directories") {
|
||||
if (command === 'get_plot_directories') {
|
||||
if (data.success !== true) {
|
||||
return state;
|
||||
}
|
||||
@@ -105,8 +110,8 @@ export default function farmingReducer(state: FarmingState = { ...initialState }
|
||||
...state,
|
||||
harvester: {
|
||||
...state.harvester,
|
||||
plot_directories: data.directories
|
||||
}
|
||||
plot_directories: data.directories,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
import { service_full_node } from "../util/service_names";
|
||||
import { service_full_node } from '../util/service_names';
|
||||
import type Connection from '../types/Connection';
|
||||
import type Header from '../types/Header';
|
||||
|
||||
type FullNodeState = {
|
||||
blockchain_state: {
|
||||
difficulty: number,
|
||||
ips: number,
|
||||
lca?: Header | null,
|
||||
min_iters: number,
|
||||
difficulty: number;
|
||||
ips: number;
|
||||
lca?: Header | null;
|
||||
min_iters: number;
|
||||
sync: {
|
||||
sync_mode: boolean,
|
||||
sync_progress_height: number,
|
||||
sync_tip_height: number,
|
||||
},
|
||||
tip_hashes?: string[] | null,
|
||||
tips?: Header[] | null,
|
||||
space: number,
|
||||
},
|
||||
connections: Connection[],
|
||||
open_connection_error?: string,
|
||||
headers: Header[],
|
||||
block?: string | null, // If not null, page is changed to block page
|
||||
header?: string | null
|
||||
sync_mode: boolean;
|
||||
sync_progress_height: number;
|
||||
sync_tip_height: number;
|
||||
};
|
||||
tip_hashes?: string[] | null;
|
||||
tips?: Header[] | null;
|
||||
space: number;
|
||||
};
|
||||
connections: Connection[];
|
||||
open_connection_error?: string;
|
||||
headers: Header[];
|
||||
block?: string | null; // If not null, page is changed to block page
|
||||
header?: string | null;
|
||||
};
|
||||
|
||||
const initialBlockchain = {
|
||||
@@ -32,7 +32,7 @@ const initialBlockchain = {
|
||||
sync: {
|
||||
sync_mode: false,
|
||||
sync_progress_height: 0,
|
||||
sync_tip_height: 0
|
||||
sync_tip_height: 0,
|
||||
},
|
||||
tip_hashes: null,
|
||||
tips: null,
|
||||
@@ -42,50 +42,52 @@ const initialBlockchain = {
|
||||
const initialState: FullNodeState = {
|
||||
blockchain_state: initialBlockchain,
|
||||
connections: [],
|
||||
open_connection_error: "",
|
||||
open_connection_error: '',
|
||||
headers: [],
|
||||
block: null, // If not null, page is changed to block page
|
||||
header: null,
|
||||
};
|
||||
|
||||
export default function fullnodeReducer(state: FullNodeState = { ...initialState }, action: any): FullNodeState {
|
||||
export default function fullnodeReducer(
|
||||
state: FullNodeState = { ...initialState },
|
||||
action: any,
|
||||
): FullNodeState {
|
||||
switch (action.type) {
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return { ...initialState };
|
||||
case "CLEAR_BLOCK":
|
||||
case 'CLEAR_BLOCK':
|
||||
return { ...state, block: null };
|
||||
case "INCOMING_MESSAGE":
|
||||
case 'INCOMING_MESSAGE':
|
||||
if (action.message.origin !== service_full_node) {
|
||||
return state;
|
||||
}
|
||||
const message = action.message;
|
||||
const data = message.data;
|
||||
const command = message.command;
|
||||
const { message } = action;
|
||||
const { data } = message;
|
||||
const { command } = message;
|
||||
|
||||
if (command === "get_blockchain_state") {
|
||||
if (command === 'get_blockchain_state') {
|
||||
if (data.success) {
|
||||
return { ...state, blockchain_state: data.blockchain_state };
|
||||
}
|
||||
} else if (command === "get_latest_block_headers") {
|
||||
} else if (command === 'get_latest_block_headers') {
|
||||
if (data.success) {
|
||||
return { ...state, headers: data.latest_blocks };
|
||||
}
|
||||
} else if (command === "get_block") {
|
||||
} else if (command === 'get_block') {
|
||||
if (data.success) {
|
||||
return { ...state, block: data.block };
|
||||
}
|
||||
} else if (command === "get_header") {
|
||||
} else if (command === 'get_header') {
|
||||
if (data.success) {
|
||||
return { ...state, header: data.header };
|
||||
}
|
||||
} else if (command === "get_connections") {
|
||||
} else if (command === 'get_connections') {
|
||||
return { ...state, connections: data.connections };
|
||||
} else if (command === "open_connection") {
|
||||
} else if (command === 'open_connection') {
|
||||
if (data.success) {
|
||||
return { ...state, open_connection_error: "" };
|
||||
} else {
|
||||
return { ...state, open_connection_error: data.error };
|
||||
return { ...state, open_connection_error: '' };
|
||||
}
|
||||
return { ...state, open_connection_error: data.error };
|
||||
}
|
||||
return state;
|
||||
default:
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
import { service_full_node } from "../util/service_names";
|
||||
import { service_full_node } from '../util/service_names';
|
||||
|
||||
export const fullNodeMessage = () => ({
|
||||
type: "OUTGOING_MESSAGE",
|
||||
type: 'OUTGOING_MESSAGE',
|
||||
message: {
|
||||
destination: service_full_node
|
||||
}
|
||||
destination: service_full_node,
|
||||
},
|
||||
});
|
||||
|
||||
export const pingFullNode = () => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "ping";
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'ping';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getBlockChainState = () => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "get_blockchain_state";
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'get_blockchain_state';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getLatestBlocks = () => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "get_latest_block_headers";
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'get_latest_block_headers';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getFullNodeConnections = () => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "get_connections";
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'get_connections';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const openConnection = (host, port) => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "open_connection";
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'open_connection';
|
||||
action.message.data = { host, port };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const closeConnection = node_id => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "close_connection";
|
||||
export const closeConnection = (node_id) => {
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'close_connection';
|
||||
action.message.data = { node_id };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getBlock = header_hash => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "get_block";
|
||||
export const getBlock = (header_hash) => {
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'get_block';
|
||||
action.message.data = { header_hash };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getHeader = header_hash => {
|
||||
var action = fullNodeMessage();
|
||||
action.message.command = "get_header";
|
||||
export const getHeader = (header_hash) => {
|
||||
const action = fullNodeMessage();
|
||||
action.message.command = 'get_header';
|
||||
action.message.data = { header_hash };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const clearBlock = header_hash => {
|
||||
var action = {
|
||||
type: "CLEAR_BLOCK",
|
||||
command: "clear_block"
|
||||
export const clearBlock = (header_hash) => {
|
||||
const action = {
|
||||
type: 'CLEAR_BLOCK',
|
||||
command: 'clear_block',
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
@@ -1,57 +1,57 @@
|
||||
import { service_harvester } from "../util/service_names";
|
||||
import { service_harvester } from '../util/service_names';
|
||||
|
||||
export const harvesterMessage = () => ({
|
||||
type: "OUTGOING_MESSAGE",
|
||||
type: 'OUTGOING_MESSAGE',
|
||||
message: {
|
||||
destination: service_harvester
|
||||
}
|
||||
destination: service_harvester,
|
||||
},
|
||||
});
|
||||
|
||||
export const pingHarvester = () => {
|
||||
var action = harvesterMessage();
|
||||
action.message.command = "ping";
|
||||
const action = harvesterMessage();
|
||||
action.message.command = 'ping';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getPlots = () => {
|
||||
var action = harvesterMessage();
|
||||
action.message.command = "get_plots";
|
||||
const action = harvesterMessage();
|
||||
action.message.command = 'get_plots';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const getPlotDirectories = () => {
|
||||
var action = harvesterMessage();
|
||||
action.message.command = "get_plot_directories";
|
||||
const action = harvesterMessage();
|
||||
action.message.command = 'get_plot_directories';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const deletePlot = filename => {
|
||||
var action = harvesterMessage();
|
||||
action.message.command = "delete_plot";
|
||||
export const deletePlot = (filename) => {
|
||||
const action = harvesterMessage();
|
||||
action.message.command = 'delete_plot';
|
||||
action.message.data = { filename };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const refreshPlots = () => {
|
||||
var action = harvesterMessage();
|
||||
action.message.command = "refresh_plots";
|
||||
const action = harvesterMessage();
|
||||
action.message.command = 'refresh_plots';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const addPlotDirectory = dirname => {
|
||||
var action = harvesterMessage();
|
||||
action.message.command = "add_plot_directory";
|
||||
export const addPlotDirectory = (dirname) => {
|
||||
const action = harvesterMessage();
|
||||
action.message.command = 'add_plot_directory';
|
||||
action.message.data = { dirname };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const removePlotDirectory = dirname => {
|
||||
var action = harvesterMessage();
|
||||
action.message.command = "remove_plot_directory";
|
||||
export const removePlotDirectory = (dirname) => {
|
||||
const action = harvesterMessage();
|
||||
action.message.command = 'remove_plot_directory';
|
||||
action.message.data = { dirname };
|
||||
return action;
|
||||
};
|
||||
|
||||
@@ -4,21 +4,21 @@ import type Fingerprint from '../types/Fingerprint';
|
||||
import createWallet from '../util/createWallet';
|
||||
|
||||
type IncomingState = {
|
||||
mnemonic: string[],
|
||||
public_key_fingerprints: Fingerprint[],
|
||||
selected_fingerprint: null,
|
||||
logged_in_received: boolean,
|
||||
logged_in: boolean,
|
||||
wallets: Wallet[],
|
||||
mnemonic: string[];
|
||||
public_key_fingerprints: Fingerprint[];
|
||||
selected_fingerprint: null;
|
||||
logged_in_received: boolean;
|
||||
logged_in: boolean;
|
||||
wallets: Wallet[];
|
||||
status: {
|
||||
connections: [],
|
||||
connection_count: number,
|
||||
syncing: boolean,
|
||||
height?: number,
|
||||
},
|
||||
send_transaction_result?: string | null,
|
||||
show_create_backup: boolean,
|
||||
server_started?: boolean,
|
||||
connections: [];
|
||||
connection_count: number;
|
||||
syncing: boolean;
|
||||
height?: number;
|
||||
};
|
||||
send_transaction_result?: string | null;
|
||||
show_create_backup: boolean;
|
||||
server_started?: boolean;
|
||||
};
|
||||
|
||||
const initialState: IncomingState = {
|
||||
@@ -31,132 +31,140 @@ const initialState: IncomingState = {
|
||||
status: {
|
||||
connections: [],
|
||||
connection_count: 0,
|
||||
syncing: false
|
||||
syncing: false,
|
||||
},
|
||||
show_create_backup: false
|
||||
show_create_backup: false,
|
||||
};
|
||||
|
||||
export default function incomingReducer(state: IncomingState = { ...initialState }, action: any): IncomingState {
|
||||
export default function incomingReducer(
|
||||
state: IncomingState = { ...initialState },
|
||||
action: any,
|
||||
): IncomingState {
|
||||
switch (action.type) {
|
||||
case "SHOW_CREATE_BACKUP":
|
||||
case 'SHOW_CREATE_BACKUP':
|
||||
return {
|
||||
...state,
|
||||
show_create_backup: action.show,
|
||||
};
|
||||
case "SELECT_FINGERPRINT":
|
||||
case 'SELECT_FINGERPRINT':
|
||||
return {
|
||||
...state,
|
||||
selected_fingerprint: action.fingerprint,
|
||||
};
|
||||
case "UNSELECT_FINGERPRINT":
|
||||
case 'UNSELECT_FINGERPRINT':
|
||||
return {
|
||||
...state,
|
||||
selected_fingerprint: null
|
||||
selected_fingerprint: null,
|
||||
};
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return {
|
||||
...initialState,
|
||||
logged_in_received: true,
|
||||
public_key_fingerprints: state.public_key_fingerprints,
|
||||
};
|
||||
|
||||
case "CLEAR_SEND":
|
||||
case 'CLEAR_SEND':
|
||||
var id = action.message.data.wallet_id;
|
||||
var wallet = state.wallets[parseInt(id)];
|
||||
wallet.sending_transaction = false;
|
||||
wallet.send_transaction_result = null;
|
||||
return {
|
||||
...state
|
||||
...state,
|
||||
};
|
||||
case "OUTGOING_MESSAGE":
|
||||
case 'OUTGOING_MESSAGE':
|
||||
if (
|
||||
action.message.command === "send_transaction" ||
|
||||
action.message.command === "cc_spend"
|
||||
action.message.command === 'send_transaction' ||
|
||||
action.message.command === 'cc_spend'
|
||||
) {
|
||||
id = action.message.data.wallet_id;
|
||||
wallet = state.wallets[parseInt(id)];
|
||||
wallet.sending_transaction = false;
|
||||
wallet.send_transaction_result = null;
|
||||
return {
|
||||
...state
|
||||
...state,
|
||||
};
|
||||
}
|
||||
return state;
|
||||
case "INCOMING_MESSAGE":
|
||||
case 'INCOMING_MESSAGE':
|
||||
if (action.message.origin !== service_wallet) {
|
||||
return state;
|
||||
}
|
||||
|
||||
const message = action.message;
|
||||
const data = message.data;
|
||||
const command = message.command;
|
||||
let success, wallets;
|
||||
if (command === "generate_mnemonic") {
|
||||
const mnemonic = typeof message.data.mnemonic === 'string'
|
||||
? message.data.mnemonic.split(' ')
|
||||
: message.data.mnemonic;
|
||||
const { message } = action;
|
||||
const { data } = message;
|
||||
const { command } = message;
|
||||
let success;
|
||||
let wallets;
|
||||
if (command === 'generate_mnemonic') {
|
||||
const mnemonic =
|
||||
typeof message.data.mnemonic === 'string'
|
||||
? message.data.mnemonic.split(' ')
|
||||
: message.data.mnemonic;
|
||||
|
||||
return { ...state, mnemonic };
|
||||
} else if (command === "add_key") {
|
||||
}
|
||||
if (command === 'add_key') {
|
||||
success = data.success;
|
||||
return { ...state, logged_in: success };
|
||||
} else if (command === "log_in") {
|
||||
}
|
||||
if (command === 'log_in') {
|
||||
success = data.success;
|
||||
return { ...state, logged_in: success };
|
||||
} else if (command === "delete_all_keys") {
|
||||
}
|
||||
if (command === 'delete_all_keys') {
|
||||
success = data.success;
|
||||
if (success) {
|
||||
return {
|
||||
...state,
|
||||
logged_in: false,
|
||||
public_key_fingerprints: [],
|
||||
logged_in_received: true
|
||||
logged_in_received: true,
|
||||
};
|
||||
}
|
||||
} else if (command === "get_public_keys") {
|
||||
} else if (command === 'get_public_keys') {
|
||||
success = data.success;
|
||||
if (success) {
|
||||
var public_key_fingerprints = data.public_key_fingerprints;
|
||||
const { public_key_fingerprints } = data;
|
||||
return {
|
||||
...state,
|
||||
public_key_fingerprints: public_key_fingerprints,
|
||||
logged_in_received: true
|
||||
public_key_fingerprints,
|
||||
logged_in_received: true,
|
||||
};
|
||||
}
|
||||
} else if (command === "ping") {
|
||||
var started = data.success;
|
||||
} else if (command === 'ping') {
|
||||
const started = data.success;
|
||||
return { ...state, server_started: started };
|
||||
} else if (command === "get_wallets") {
|
||||
} else if (command === 'get_wallets') {
|
||||
if (data.success) {
|
||||
const wallets: Wallet[] = data.wallets;
|
||||
var wallets_state = [];
|
||||
for (let object of wallets) {
|
||||
var walletid = Number(object.id);
|
||||
var wallet_obj = createWallet(
|
||||
const { wallets } = data;
|
||||
const wallets_state = [];
|
||||
for (const object of wallets) {
|
||||
const walletid = Number(object.id);
|
||||
const wallet_obj = createWallet(
|
||||
walletid,
|
||||
object.name,
|
||||
object.type,
|
||||
object.data
|
||||
object.data,
|
||||
);
|
||||
wallets_state[walletid] = wallet_obj;
|
||||
}
|
||||
return { ...state, wallets: wallets_state };
|
||||
}
|
||||
} else if (command === "get_wallet_balance") {
|
||||
} else if (command === 'get_wallet_balance') {
|
||||
if (data.success) {
|
||||
const wallet_balance = data.wallet_balance;
|
||||
const { wallet_balance } = data;
|
||||
id = wallet_balance.wallet_id;
|
||||
wallets = state.wallets;
|
||||
wallet = wallets[parseInt(id)];
|
||||
if (!wallet) {
|
||||
return state;
|
||||
}
|
||||
var balance = wallet_balance.confirmed_wallet_balance;
|
||||
var unconfirmed_balance = wallet_balance.unconfirmed_wallet_balance;
|
||||
var pending_balance = unconfirmed_balance - balance;
|
||||
var frozen_balance = wallet_balance.frozen_balance;
|
||||
var spendable_balance = wallet_balance.spendable_balance;
|
||||
var change_balance = wallet_balance.pending_change;
|
||||
const balance = wallet_balance.confirmed_wallet_balance;
|
||||
const unconfirmed_balance = wallet_balance.unconfirmed_wallet_balance;
|
||||
const pending_balance = unconfirmed_balance - balance;
|
||||
const { frozen_balance } = wallet_balance;
|
||||
const { spendable_balance } = wallet_balance;
|
||||
const change_balance = wallet_balance.pending_change;
|
||||
wallet.balance_total = balance;
|
||||
wallet.balance_pending = pending_balance;
|
||||
wallet.balance_frozen = frozen_balance;
|
||||
@@ -164,10 +172,10 @@ export default function incomingReducer(state: IncomingState = { ...initialState
|
||||
wallet.balance_change = change_balance;
|
||||
return { ...state };
|
||||
}
|
||||
} else if (command === "get_transactions") {
|
||||
} else if (command === 'get_transactions') {
|
||||
if (data.success) {
|
||||
id = data.wallet_id;
|
||||
var transactions = data.transactions;
|
||||
const { transactions } = data;
|
||||
wallets = state.wallets;
|
||||
wallet = wallets[Number(id)];
|
||||
if (!wallet) {
|
||||
@@ -176,9 +184,9 @@ export default function incomingReducer(state: IncomingState = { ...initialState
|
||||
wallet.transactions = transactions.reverse();
|
||||
return { ...state };
|
||||
}
|
||||
} else if (command === "get_next_address") {
|
||||
} else if (command === 'get_next_address') {
|
||||
id = data.wallet_id;
|
||||
var address = data.address;
|
||||
const { address } = data;
|
||||
wallets = state.wallets;
|
||||
wallet = wallets[Number(id)];
|
||||
if (!wallet) {
|
||||
@@ -186,18 +194,18 @@ export default function incomingReducer(state: IncomingState = { ...initialState
|
||||
}
|
||||
wallet.address = address;
|
||||
return { ...state };
|
||||
} else if (command === "get_connections") {
|
||||
} else if (command === 'get_connections') {
|
||||
if (data.success || data.connections) {
|
||||
return {
|
||||
...state,
|
||||
status: {
|
||||
...state.status,
|
||||
connections: data.connections,
|
||||
connection_count: data.connections.length
|
||||
}
|
||||
connection_count: data.connections.length,
|
||||
},
|
||||
};
|
||||
}
|
||||
} else if (command === "get_height_info") {
|
||||
} else if (command === 'get_height_info') {
|
||||
return {
|
||||
...state,
|
||||
status: {
|
||||
@@ -205,16 +213,16 @@ export default function incomingReducer(state: IncomingState = { ...initialState
|
||||
height: data.height,
|
||||
},
|
||||
};
|
||||
} else if (command === "get_sync_status") {
|
||||
} else if (command === 'get_sync_status') {
|
||||
if (data.success) {
|
||||
return {
|
||||
...state,
|
||||
status: { ...state.status, syncing: data.syncing }
|
||||
status: { ...state.status, syncing: data.syncing },
|
||||
};
|
||||
}
|
||||
} else if (command === "cc_get_colour") {
|
||||
} else if (command === 'cc_get_colour') {
|
||||
id = data.wallet_id;
|
||||
const colour = data.colour;
|
||||
const { colour } = data;
|
||||
wallets = state.wallets;
|
||||
wallet = wallets[Number(id)];
|
||||
if (!wallet) {
|
||||
@@ -222,9 +230,9 @@ export default function incomingReducer(state: IncomingState = { ...initialState
|
||||
}
|
||||
wallet.colour = colour;
|
||||
return { ...state };
|
||||
} else if (command === "cc_get_name") {
|
||||
} else if (command === 'cc_get_name') {
|
||||
const id = data.wallet_id;
|
||||
const name = data.name;
|
||||
const { name } = data;
|
||||
wallets = state.wallets;
|
||||
wallet = wallets[Number(id)];
|
||||
if (!wallet) {
|
||||
@@ -233,7 +241,7 @@ export default function incomingReducer(state: IncomingState = { ...initialState
|
||||
wallet.name = name;
|
||||
return { ...state };
|
||||
}
|
||||
if (command === "state_changed" && data.state === "tx_update") {
|
||||
if (command === 'state_changed' && data.state === 'tx_update') {
|
||||
const id = data.wallet_id;
|
||||
wallets = state.wallets;
|
||||
wallet = wallets[Number(id)];
|
||||
|
||||
@@ -1,77 +1,75 @@
|
||||
import { service_wallet } from "../util/service_names";
|
||||
import { openProgress, closeProgress } from "./progress";
|
||||
import { refreshAllState } from "../middleware/middleware_api";
|
||||
import { setIncorrectWord, resetMnemonic } from "./mnemonic";
|
||||
import { service_wallet } from '../util/service_names';
|
||||
import { openProgress, closeProgress } from './progress';
|
||||
import { refreshAllState } from '../middleware/middleware_api';
|
||||
import { setIncorrectWord, resetMnemonic } from './mnemonic';
|
||||
import {
|
||||
changeEntranceMenu,
|
||||
presentRestoreBackup,
|
||||
presentOldWallet
|
||||
} from "./entranceMenu";
|
||||
import { openDialog } from "./dialog";
|
||||
import { createState } from "./createWallet";
|
||||
presentOldWallet,
|
||||
} from './entranceMenu';
|
||||
import { openDialog } from './dialog';
|
||||
import { createState, changeCreateWallet, ALL_OPTIONS } from './createWallet';
|
||||
import {
|
||||
addPlotDirectory,
|
||||
getPlotDirectories,
|
||||
removePlotDirectory,
|
||||
getPlots,
|
||||
refreshPlots
|
||||
} from "./harvesterMessages";
|
||||
refreshPlots,
|
||||
} from './harvesterMessages';
|
||||
import {
|
||||
setBackupInfo,
|
||||
changeBackupView,
|
||||
presentBackupInfo,
|
||||
selectFilePath
|
||||
} from "./backup";
|
||||
import { exitDaemon } from "./daemon_messages";
|
||||
import { wsDisconnect } from "./websocket";
|
||||
import {
|
||||
changeCreateWallet,
|
||||
ALL_OPTIONS
|
||||
} from "../modules/createWallet";
|
||||
const config = require("../config");
|
||||
const backup_host = config.backup_host;
|
||||
selectFilePath,
|
||||
} from './backup';
|
||||
import { exitDaemon } from './daemon_messages';
|
||||
import { wsDisconnect } from './websocket';
|
||||
|
||||
const config = require('../config');
|
||||
|
||||
const { backup_host } = config;
|
||||
|
||||
export const clearSend = () => {
|
||||
var action = {
|
||||
type: "CLEAR_SEND",
|
||||
mesasge: ""
|
||||
const action = {
|
||||
type: 'CLEAR_SEND',
|
||||
mesasge: '',
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const walletMessage = () => ({
|
||||
type: "OUTGOING_MESSAGE",
|
||||
type: 'OUTGOING_MESSAGE',
|
||||
message: {
|
||||
destination: service_wallet
|
||||
}
|
||||
destination: service_wallet,
|
||||
},
|
||||
});
|
||||
|
||||
export const selectFingerprint = fingerprint => ({
|
||||
type: "SELECT_FINGERPRINT",
|
||||
fingerprint: fingerprint
|
||||
export const selectFingerprint = (fingerprint) => ({
|
||||
type: 'SELECT_FINGERPRINT',
|
||||
fingerprint,
|
||||
});
|
||||
|
||||
export const unselectFingerprint = () => ({
|
||||
type: "UNSELECT_FINGERPRINT"
|
||||
type: 'UNSELECT_FINGERPRINT',
|
||||
});
|
||||
|
||||
export const selectMnemonic = mnemonic => ({
|
||||
type: "SELECT_MNEMONIC",
|
||||
mnemonic: mnemonic
|
||||
export const selectMnemonic = (mnemonic) => ({
|
||||
type: 'SELECT_MNEMONIC',
|
||||
mnemonic,
|
||||
});
|
||||
|
||||
export const showCreateBackup = show => ({
|
||||
type: "SHOW_CREATE_BACKUP",
|
||||
show: show
|
||||
export const showCreateBackup = (show) => ({
|
||||
type: 'SHOW_CREATE_BACKUP',
|
||||
show,
|
||||
});
|
||||
|
||||
export const async_api = (dispatch, action, open_spinner) => {
|
||||
if (open_spinner === true) {
|
||||
dispatch(openProgress());
|
||||
}
|
||||
var resolve_callback;
|
||||
var reject_callback;
|
||||
let myFirstPromise = new Promise((resolve, reject) => {
|
||||
let resolve_callback;
|
||||
let reject_callback;
|
||||
const myFirstPromise = new Promise((resolve, reject) => {
|
||||
resolve_callback = resolve;
|
||||
reject_callback = reject;
|
||||
});
|
||||
@@ -82,117 +80,117 @@ export const async_api = (dispatch, action, open_spinner) => {
|
||||
};
|
||||
|
||||
export const format_message = (command, data) => {
|
||||
var action = walletMessage();
|
||||
const action = walletMessage();
|
||||
action.message.command = command;
|
||||
action.message.data = data;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const pingWallet = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "ping";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'ping';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_balance_for_wallet = id => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_wallet_balance";
|
||||
export const get_balance_for_wallet = (id) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_wallet_balance';
|
||||
action.message.data = { wallet_id: id };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const send_transaction = (wallet_id, amount, fee, address) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "send_transaction";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'send_transaction';
|
||||
action.message.data = {
|
||||
wallet_id: wallet_id,
|
||||
amount: amount,
|
||||
fee: fee,
|
||||
address: address
|
||||
wallet_id,
|
||||
amount,
|
||||
fee,
|
||||
address,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const genereate_mnemonics = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "generate_mnemonic";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'generate_mnemonic';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const add_key = (mnemonic, type, file_path) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "add_key";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'add_key';
|
||||
action.message.data = {
|
||||
mnemonic: mnemonic,
|
||||
type: type,
|
||||
file_path: file_path
|
||||
mnemonic,
|
||||
type,
|
||||
file_path,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const add_new_key_action = mnemonic => {
|
||||
return dispatch => {
|
||||
export const add_new_key_action = (mnemonic) => {
|
||||
return (dispatch) => {
|
||||
return async_api(
|
||||
dispatch,
|
||||
add_key(mnemonic, "new_wallet", null),
|
||||
true
|
||||
).then(response => {
|
||||
add_key(mnemonic, 'new_wallet', null),
|
||||
true,
|
||||
).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
dispatch(resetMnemonic());
|
||||
dispatch(format_message("get_public_keys", {}));
|
||||
dispatch(format_message('get_public_keys', {}));
|
||||
refreshAllState(dispatch);
|
||||
} else {
|
||||
if (response.data.word) {
|
||||
dispatch(setIncorrectWord(response.data.word));
|
||||
dispatch(changeEntranceMenu(presentOldWallet));
|
||||
} else if (response.data.error === "Invalid order of mnemonic words") {
|
||||
} else if (response.data.error === 'Invalid order of mnemonic words') {
|
||||
dispatch(changeEntranceMenu(presentOldWallet));
|
||||
}
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const add_and_skip_backup = mnemonic => {
|
||||
return dispatch => {
|
||||
return async_api(dispatch, add_key(mnemonic, "skip", null), true).then(
|
||||
response => {
|
||||
export const add_and_skip_backup = (mnemonic) => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, add_key(mnemonic, 'skip', null), true).then(
|
||||
(response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
dispatch(resetMnemonic());
|
||||
dispatch(format_message("get_public_keys", {}));
|
||||
dispatch(format_message('get_public_keys', {}));
|
||||
refreshAllState(dispatch);
|
||||
} else {
|
||||
if (response.data.word) {
|
||||
dispatch(setIncorrectWord(response.data.word));
|
||||
dispatch(changeEntranceMenu(presentOldWallet));
|
||||
} else if (
|
||||
response.data.error === "Invalid order of mnemonic words"
|
||||
response.data.error === 'Invalid order of mnemonic words'
|
||||
) {
|
||||
dispatch(changeEntranceMenu(presentOldWallet));
|
||||
}
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export const add_and_restore_from_backup = (mnemonic, file_path) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return async_api(
|
||||
dispatch,
|
||||
add_key(mnemonic, "restore_backup", file_path),
|
||||
true
|
||||
).then(response => {
|
||||
add_key(mnemonic, 'restore_backup', file_path),
|
||||
true,
|
||||
).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
@@ -202,125 +200,125 @@ export const add_and_restore_from_backup = (mnemonic, file_path) => {
|
||||
if (response.data.word) {
|
||||
dispatch(setIncorrectWord(response.data.word));
|
||||
dispatch(changeEntranceMenu(presentOldWallet));
|
||||
} else if (response.data.error === "Invalid order of mnemonic words") {
|
||||
} else if (response.data.error === 'Invalid order of mnemonic words') {
|
||||
dispatch(changeEntranceMenu(presentOldWallet));
|
||||
}
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const delete_key = fingerprint => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "delete_key";
|
||||
action.message.data = { fingerprint: fingerprint };
|
||||
export const delete_key = (fingerprint) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'delete_key';
|
||||
action.message.data = { fingerprint };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const delete_all_keys = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "delete_all_keys";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'delete_all_keys';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const log_in = fingerprint => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "log_in";
|
||||
export const log_in = (fingerprint) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'log_in';
|
||||
action.message.data = {
|
||||
fingerprint: fingerprint,
|
||||
fingerprint,
|
||||
host: backup_host,
|
||||
type: "normal"
|
||||
type: 'normal',
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const log_in_and_skip_import = fingerprint => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "log_in";
|
||||
export const log_in_and_skip_import = (fingerprint) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'log_in';
|
||||
action.message.data = {
|
||||
fingerprint: fingerprint,
|
||||
fingerprint,
|
||||
host: backup_host,
|
||||
type: "skip"
|
||||
type: 'skip',
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const log_in_and_import_backup = (fingerprint, file_path) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "log_in";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'log_in';
|
||||
action.message.data = {
|
||||
fingerprint: fingerprint,
|
||||
type: "restore_backup",
|
||||
file_path: file_path,
|
||||
host: backup_host
|
||||
fingerprint,
|
||||
type: 'restore_backup',
|
||||
file_path,
|
||||
host: backup_host,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const log_in_and_import_backup_action = (fingerprint, file_path) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch(selectFingerprint(fingerprint));
|
||||
return async_api(
|
||||
dispatch,
|
||||
log_in_and_import_backup(fingerprint, file_path),
|
||||
true
|
||||
).then(response => {
|
||||
true,
|
||||
).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
refreshAllState(dispatch);
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
if (error === "not_initialized") {
|
||||
const { error } = response.data;
|
||||
if (error === 'not_initialized') {
|
||||
dispatch(changeEntranceMenu(presentRestoreBackup));
|
||||
// Go to restore from backup screen
|
||||
} else {
|
||||
dispatch(openDialog("Error", error));
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const login_and_skip_action = fingerprint => {
|
||||
return dispatch => {
|
||||
export const login_and_skip_action = (fingerprint) => {
|
||||
return (dispatch) => {
|
||||
dispatch(selectFingerprint(fingerprint));
|
||||
return async_api(dispatch, log_in_and_skip_import(fingerprint), true).then(
|
||||
response => {
|
||||
(response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
refreshAllState(dispatch);
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
if (error === "not_initialized") {
|
||||
const { error } = response.data;
|
||||
if (error === 'not_initialized') {
|
||||
dispatch(changeEntranceMenu(presentRestoreBackup));
|
||||
// Go to restore from backup screen
|
||||
} else {
|
||||
dispatch(openDialog("Error", error));
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export const login_action = fingerprint => {
|
||||
return dispatch => {
|
||||
export const login_action = (fingerprint) => {
|
||||
return (dispatch) => {
|
||||
dispatch(selectFingerprint(fingerprint));
|
||||
return async_api(dispatch, log_in(fingerprint), true).then(response => {
|
||||
return async_api(dispatch, log_in(fingerprint), true).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
refreshAllState(dispatch);
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
if (error === "not_initialized") {
|
||||
const backup_info = response.data.backup_info;
|
||||
const backup_path = response.data.backup_path;
|
||||
const { error } = response.data;
|
||||
if (error === 'not_initialized') {
|
||||
const { backup_info } = response.data;
|
||||
const { backup_path } = response.data;
|
||||
dispatch(changeEntranceMenu(presentRestoreBackup));
|
||||
if (backup_info && backup_path) {
|
||||
dispatch(setBackupInfo(backup_info));
|
||||
@@ -329,7 +327,7 @@ export const login_action = fingerprint => {
|
||||
}
|
||||
// Go to restore from backup screen
|
||||
} else {
|
||||
dispatch(openDialog("Error", error));
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -337,323 +335,321 @@ export const login_action = fingerprint => {
|
||||
};
|
||||
|
||||
export const get_backup_info = (file_path, fingerprint, words) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_backup_info";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_backup_info';
|
||||
if (fingerprint === null) {
|
||||
action.message.data = {
|
||||
file_path: file_path,
|
||||
words: words
|
||||
file_path,
|
||||
words,
|
||||
};
|
||||
} else if (words === null) {
|
||||
action.message.data = {
|
||||
file_path: file_path,
|
||||
fingerprint: fingerprint
|
||||
file_path,
|
||||
fingerprint,
|
||||
};
|
||||
}
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_backup_info_action = (file_path, fingerprint, words) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
dispatch(selectFilePath(file_path));
|
||||
return async_api(
|
||||
dispatch,
|
||||
get_backup_info(file_path, fingerprint, words),
|
||||
true
|
||||
).then(response => {
|
||||
true,
|
||||
).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
response.data.backup_info.downloaded = false;
|
||||
dispatch(setBackupInfo(response.data.backup_info));
|
||||
dispatch(changeBackupView(presentBackupInfo));
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const get_private_key = fingerprint => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_private_key";
|
||||
export const get_private_key = (fingerprint) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_private_key';
|
||||
action.message.data = { fingerprint };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_transactions = wallet_id => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_transactions";
|
||||
export const get_transactions = (wallet_id) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_transactions';
|
||||
action.message.data = { wallet_id };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_address = wallet_id => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_next_address";
|
||||
export const get_address = (wallet_id) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_next_address';
|
||||
action.message.data = { wallet_id };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const farm_block = address => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "farm_block";
|
||||
export const farm_block = (address) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'farm_block';
|
||||
action.message.data = { address };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_height_info = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_height_info";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_height_info';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_sync_status = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_sync_status";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_sync_status';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_connection_info = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_connections";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_connections';
|
||||
action.message.data = {};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const create_coloured_coin = (amount, fee) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "create_new_wallet";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'create_new_wallet';
|
||||
action.message.data = {
|
||||
wallet_type: "cc_wallet",
|
||||
mode: "new",
|
||||
amount: amount,
|
||||
fee: fee,
|
||||
host: backup_host
|
||||
wallet_type: 'cc_wallet',
|
||||
mode: 'new',
|
||||
amount,
|
||||
fee,
|
||||
host: backup_host,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const create_cc_for_colour = (colour, fee) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "create_new_wallet";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'create_new_wallet';
|
||||
action.message.data = {
|
||||
wallet_type: "cc_wallet",
|
||||
mode: "existing",
|
||||
colour: colour,
|
||||
fee: fee,
|
||||
host: backup_host
|
||||
wallet_type: 'cc_wallet',
|
||||
mode: 'existing',
|
||||
colour,
|
||||
fee,
|
||||
host: backup_host,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const create_backup = file_path => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "create_backup";
|
||||
export const create_backup = (file_path) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'create_backup';
|
||||
action.message.data = {
|
||||
file_path: file_path
|
||||
file_path,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const create_backup_action = file_path => {
|
||||
return dispatch => {
|
||||
export const create_backup_action = (file_path) => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, create_backup(file_path), true).then(
|
||||
response => {
|
||||
(response) => {
|
||||
dispatch(closeProgress());
|
||||
if (response.data.success) {
|
||||
dispatch(showCreateBackup(false));
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export const create_cc_action = (amount, fee) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, create_coloured_coin(amount, fee), true).then(
|
||||
response => {
|
||||
(response) => {
|
||||
dispatch(closeProgress());
|
||||
dispatch(createState(true, false));
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
dispatch(format_message("get_wallets", {}));
|
||||
dispatch(format_message('get_wallets', {}));
|
||||
dispatch(showCreateBackup(true));
|
||||
dispatch(createState(true, false));
|
||||
dispatch(changeCreateWallet(ALL_OPTIONS));
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export const create_cc_for_colour_action = (colour, fee) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, create_cc_for_colour(colour, fee), true).then(
|
||||
response => {
|
||||
(response) => {
|
||||
dispatch(closeProgress());
|
||||
dispatch(createState(true, false));
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
dispatch(showCreateBackup(true));
|
||||
dispatch(format_message("get_wallets", {}));
|
||||
dispatch(format_message('get_wallets', {}));
|
||||
dispatch(changeCreateWallet(ALL_OPTIONS));
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
export const get_colour_info = wallet_id => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "cc_get_colour";
|
||||
action.message.data = { wallet_id: wallet_id };
|
||||
export const get_colour_info = (wallet_id) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'cc_get_colour';
|
||||
action.message.data = { wallet_id };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_colour_name = wallet_id => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "cc_get_name";
|
||||
action.message.data = { wallet_id: wallet_id };
|
||||
export const get_colour_name = (wallet_id) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'cc_get_name';
|
||||
action.message.data = { wallet_id };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const rename_cc_wallet = (wallet_id, name) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "cc_set_name";
|
||||
action.message.data = { wallet_id: wallet_id, name: name };
|
||||
const action = walletMessage();
|
||||
action.message.command = 'cc_set_name';
|
||||
action.message.data = { wallet_id, name };
|
||||
return action;
|
||||
};
|
||||
|
||||
export const cc_spend = (wallet_id, address, amount, fee) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "cc_spend";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'cc_spend';
|
||||
action.message.data = {
|
||||
wallet_id: wallet_id,
|
||||
wallet_id,
|
||||
inner_address: address,
|
||||
amount: amount,
|
||||
fee: fee
|
||||
amount,
|
||||
fee,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const logOut = (command, data) => ({ type: "LOG_OUT", command, data });
|
||||
export const logOut = (command, data) => ({ type: 'LOG_OUT', command, data });
|
||||
|
||||
export const incomingMessage = message => ({
|
||||
type: "INCOMING_MESSAGE",
|
||||
message: message
|
||||
export const incomingMessage = (message) => ({
|
||||
type: 'INCOMING_MESSAGE',
|
||||
message,
|
||||
});
|
||||
|
||||
export const create_rl_admin = (interval, limit, pubkey, amount) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "create_new_wallet";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'create_new_wallet';
|
||||
action.message.data = {
|
||||
wallet_type: "rl_wallet",
|
||||
rl_type: "admin",
|
||||
interval: interval,
|
||||
limit: limit,
|
||||
pubkey: pubkey,
|
||||
amount: amount,
|
||||
host: backup_host
|
||||
wallet_type: 'rl_wallet',
|
||||
rl_type: 'admin',
|
||||
interval,
|
||||
limit,
|
||||
pubkey,
|
||||
amount,
|
||||
host: backup_host,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const create_rl_admin_action = (interval, limit, pubkey, amount) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return async_api(
|
||||
dispatch,
|
||||
create_rl_admin(interval, limit, pubkey, amount),
|
||||
true
|
||||
).then(response => {
|
||||
true,
|
||||
).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
dispatch(createState(true, false));
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
dispatch(format_message("get_wallets", {}));
|
||||
dispatch(format_message('get_wallets', {}));
|
||||
dispatch(showCreateBackup(true));
|
||||
dispatch(createState(true, false));
|
||||
dispatch(changeCreateWallet(ALL_OPTIONS));
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const create_rl_user = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "create_new_wallet";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'create_new_wallet';
|
||||
action.message.data = {
|
||||
wallet_type: "rl_wallet",
|
||||
rl_type: "user",
|
||||
host: backup_host
|
||||
wallet_type: 'rl_wallet',
|
||||
rl_type: 'user',
|
||||
host: backup_host,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const create_rl_user_action = () => {
|
||||
return dispatch => {
|
||||
return async_api(dispatch, create_rl_user(), true).then(response => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, create_rl_user(), true).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
dispatch(createState(true, false));
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
dispatch(format_message("get_wallets", {}));
|
||||
dispatch(format_message('get_wallets', {}));
|
||||
dispatch(createState(true, false));
|
||||
dispatch(changeCreateWallet(ALL_OPTIONS));
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const add_plot_directory_and_refresh = dir => {
|
||||
return dispatch => {
|
||||
return async_api(dispatch, addPlotDirectory(dir), true).then(response => {
|
||||
export const add_plot_directory_and_refresh = (dir) => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, addPlotDirectory(dir), true).then((response) => {
|
||||
if (response.data.success) {
|
||||
dispatch(getPlotDirectories());
|
||||
return async_api(dispatch, refreshPlots(), false).then(response => {
|
||||
return async_api(dispatch, refreshPlots(), false).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
dispatch(getPlots());
|
||||
});
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
}
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const remove_plot_directory_and_refresh = dir => {
|
||||
return dispatch => {
|
||||
export const remove_plot_directory_and_refresh = (dir) => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, removePlotDirectory(dir), true).then(
|
||||
response => {
|
||||
(response) => {
|
||||
if (response.data.success) {
|
||||
dispatch(getPlotDirectories());
|
||||
return async_api(dispatch, refreshPlots(), false).then(response => {
|
||||
return async_api(dispatch, refreshPlots(), false).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
dispatch(getPlots());
|
||||
});
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
}
|
||||
}
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
},
|
||||
);
|
||||
};
|
||||
};
|
||||
@@ -663,16 +659,16 @@ export const rl_set_user_info = (
|
||||
interval,
|
||||
limit,
|
||||
origin,
|
||||
admin_pubkey
|
||||
admin_pubkey,
|
||||
) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "rl_set_user_info";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'rl_set_user_info';
|
||||
action.message.data = {
|
||||
wallet_id: wallet_id,
|
||||
interval: interval,
|
||||
limit: limit,
|
||||
origin: origin,
|
||||
admin_pubkey: admin_pubkey
|
||||
wallet_id,
|
||||
interval,
|
||||
limit,
|
||||
origin,
|
||||
admin_pubkey,
|
||||
};
|
||||
return action;
|
||||
};
|
||||
@@ -682,39 +678,39 @@ export const rl_set_user_info_action = (
|
||||
interval,
|
||||
limit,
|
||||
origin,
|
||||
admin_pubkey
|
||||
admin_pubkey,
|
||||
) => {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return async_api(
|
||||
dispatch,
|
||||
rl_set_user_info(wallet_id, interval, limit, origin, admin_pubkey),
|
||||
true
|
||||
).then(response => {
|
||||
true,
|
||||
).then((response) => {
|
||||
dispatch(closeProgress());
|
||||
dispatch(createState(true, false));
|
||||
if (response.data.success) {
|
||||
// Go to wallet
|
||||
dispatch(format_message("get_wallets", {}));
|
||||
dispatch(format_message('get_wallets', {}));
|
||||
dispatch(showCreateBackup(true));
|
||||
dispatch(createState(true, false));
|
||||
} else {
|
||||
const error = response.data.error;
|
||||
dispatch(openDialog("Error", error));
|
||||
const { error } = response.data;
|
||||
dispatch(openDialog('Error', error));
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export const clawback_rl_coin = wallet_id => {
|
||||
export const clawback_rl_coin = (wallet_id) => {
|
||||
// THIS IS A PLACEHOLDER FOR RL CLAWBACK FUNCTIONALITY
|
||||
};
|
||||
|
||||
export const exit_and_close = event => {
|
||||
return dispatch => {
|
||||
return async_api(dispatch, exitDaemon(), false).then(response => {
|
||||
console.log("GOT RESPONSE", response);
|
||||
export const exit_and_close = (event) => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, exitDaemon(), false).then((response) => {
|
||||
console.log('GOT RESPONSE', response);
|
||||
dispatch(wsDisconnect());
|
||||
event.sender.send("daemon-exited");
|
||||
event.sender.send('daemon-exited');
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
export const wordChanged = () => ({ type: "MNEMONIC_TYPING" });
|
||||
export const resetMnemonic = () => ({ type: "RESET_MNEMONIC" });
|
||||
export const setIncorrectWord = (word: string) => ({ type: "SET_INCORRECT_WORD", word });
|
||||
export const wordChanged = () => ({ type: 'MNEMONIC_TYPING' });
|
||||
export const resetMnemonic = () => ({ type: 'RESET_MNEMONIC' });
|
||||
export const setIncorrectWord = (word: string) => ({
|
||||
type: 'SET_INCORRECT_WORD',
|
||||
word,
|
||||
});
|
||||
|
||||
type MnemonicState = {
|
||||
mnemonic_input: string[],
|
||||
incorrect_word?: string | null,
|
||||
mnemonic_input: string[];
|
||||
incorrect_word?: string | null;
|
||||
};
|
||||
|
||||
const initialState: MnemonicState = {
|
||||
mnemonic_input: new Array(24).fill(""),
|
||||
mnemonic_input: new Array(24).fill(''),
|
||||
incorrect_word: null,
|
||||
};
|
||||
|
||||
@@ -19,20 +22,23 @@ export const mnemonic_word_added = (data: unknown) => {
|
||||
};
|
||||
};
|
||||
|
||||
export default function mnemonicReducer(state = { ...initialState }, action: any): MnemonicState {
|
||||
export default function mnemonicReducer(
|
||||
state = { ...initialState },
|
||||
action: any,
|
||||
): MnemonicState {
|
||||
switch (action.type) {
|
||||
case "MNEMONIC_TYPING":
|
||||
var word = action.data.word;
|
||||
var id = action.data.id;
|
||||
case 'MNEMONIC_TYPING':
|
||||
var { word } = action.data;
|
||||
var { id } = action.data;
|
||||
var current_input = state.mnemonic_input;
|
||||
current_input[id] = word;
|
||||
return { ...state, mnemonic_input: current_input };
|
||||
case "RESET_MNEMONIC":
|
||||
case 'RESET_MNEMONIC':
|
||||
return {
|
||||
mnemonic_input: new Array(24).fill(""),
|
||||
incorrect_word: null
|
||||
mnemonic_input: new Array(24).fill(''),
|
||||
incorrect_word: null,
|
||||
};
|
||||
case "SET_INCORRECT_WORD":
|
||||
case 'SET_INCORRECT_WORD':
|
||||
return { ...state, incorrect_word: action.word };
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -1,45 +1,54 @@
|
||||
type PlotterControlState = {
|
||||
plotting_in_proggress: boolean,
|
||||
workspace_location: string,
|
||||
t2: string,
|
||||
final_location: string,
|
||||
progress_location: string,
|
||||
progress: string,
|
||||
plotting_stopped: boolean,
|
||||
plotting_in_proggress: boolean;
|
||||
workspace_location: string;
|
||||
t2: string;
|
||||
final_location: string;
|
||||
progress_location: string;
|
||||
progress: string;
|
||||
plotting_stopped: boolean;
|
||||
};
|
||||
|
||||
const initialState: PlotterControlState = {
|
||||
plotting_in_proggress: false,
|
||||
workspace_location: "",
|
||||
t2: "",
|
||||
final_location: "",
|
||||
progress_location: "",
|
||||
progress: "",
|
||||
workspace_location: '',
|
||||
t2: '',
|
||||
final_location: '',
|
||||
progress_location: '',
|
||||
progress: '',
|
||||
plotting_stopped: false,
|
||||
};
|
||||
|
||||
export default function plotControlReducer(state: PlotterControlState = { ...initialState }, action: any): PlotterControlState {
|
||||
export default function plotControlReducer(
|
||||
state: PlotterControlState = { ...initialState },
|
||||
action: any,
|
||||
): PlotterControlState {
|
||||
switch (action.type) {
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return { ...initialState };
|
||||
case "PLOTTER_CONTROL":
|
||||
if (action.command === "workspace_location") {
|
||||
case 'PLOTTER_CONTROL':
|
||||
if (action.command === 'workspace_location') {
|
||||
return { ...state, workspace_location: action.location };
|
||||
} else if (action.command === "final_location") {
|
||||
}
|
||||
if (action.command === 'final_location') {
|
||||
return { ...state, final_location: action.location };
|
||||
} else if (action.command === "reset_progress") {
|
||||
return { ...state, progress: "" };
|
||||
} else if (action.command === "add_progress") {
|
||||
return { ...state, progress: state.progress + "\n" + action.progress };
|
||||
} else if (action.command === "plotting_started") {
|
||||
}
|
||||
if (action.command === 'reset_progress') {
|
||||
return { ...state, progress: '' };
|
||||
}
|
||||
if (action.command === 'add_progress') {
|
||||
return { ...state, progress: `${state.progress}\n${action.progress}` };
|
||||
}
|
||||
if (action.command === 'plotting_started') {
|
||||
return {
|
||||
...state,
|
||||
plotting_in_proggress: true,
|
||||
plotting_stopped: false
|
||||
plotting_stopped: false,
|
||||
};
|
||||
} else if (action.command === "progress_location") {
|
||||
}
|
||||
if (action.command === 'progress_location') {
|
||||
return { ...state, progress_location: action.location };
|
||||
} else if (action.command === "plotting_stopped") {
|
||||
}
|
||||
if (action.command === 'plotting_stopped') {
|
||||
return { ...state, plotting_stopped: true };
|
||||
}
|
||||
return state;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { service_plotter } from "../util/service_names";
|
||||
import { daemonMessage } from "./daemon_messages";
|
||||
import { service_plotter } from '../util/service_names';
|
||||
import { daemonMessage } from './daemon_messages';
|
||||
|
||||
export const plotControl = () => ({
|
||||
type: "PLOTTER_CONTROL"
|
||||
type: 'PLOTTER_CONTROL',
|
||||
});
|
||||
|
||||
export const startPlotting = (k, n, t, t2, d, b, u, r, s) => {
|
||||
var action = daemonMessage();
|
||||
action.message.command = "start_plotting";
|
||||
export const startPlotting = (k, n, t, t2, d, b) => {
|
||||
const action = daemonMessage();
|
||||
action.message.command = 'start_plotting';
|
||||
action.message.data = {
|
||||
service: service_plotter,
|
||||
k,
|
||||
@@ -16,57 +16,54 @@ export const startPlotting = (k, n, t, t2, d, b, u, r, s) => {
|
||||
t2,
|
||||
d,
|
||||
b,
|
||||
u,
|
||||
r,
|
||||
s
|
||||
};
|
||||
return action;
|
||||
};
|
||||
|
||||
export const workspaceSelected = location => {
|
||||
export const workspaceSelected = (location) => {
|
||||
const action = plotControl();
|
||||
action.command = "workspace_location";
|
||||
action.command = 'workspace_location';
|
||||
action.location = location;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const finalSelected = location => {
|
||||
export const finalSelected = (location) => {
|
||||
const action = plotControl();
|
||||
action.command = "final_location";
|
||||
action.command = 'final_location';
|
||||
action.location = location;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const plottingStarted = () => {
|
||||
const action = plotControl();
|
||||
action.command = "plotting_started";
|
||||
action.command = 'plotting_started';
|
||||
action.started = true;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const plottingStopped = () => {
|
||||
const action = plotControl();
|
||||
action.command = "plotting_stopped";
|
||||
action.command = 'plotting_stopped';
|
||||
action.stopped = true;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const proggressLocation = location => {
|
||||
export const proggressLocation = (location) => {
|
||||
const action = plotControl();
|
||||
action.command = "progress_location";
|
||||
action.command = 'progress_location';
|
||||
action.location = location;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const resetProgress = () => {
|
||||
const action = plotControl();
|
||||
action.command = "reset_progress";
|
||||
action.command = 'reset_progress';
|
||||
return action;
|
||||
};
|
||||
|
||||
export const addProgress = progress => {
|
||||
export const addProgress = (progress) => {
|
||||
const action = plotControl();
|
||||
action.command = "add_progress";
|
||||
action.command = 'add_progress';
|
||||
action.progress = progress;
|
||||
return action;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const progressControl = () => ({ type: "PROGRESS_CONTROL" });
|
||||
const progressControl = () => ({ type: 'PROGRESS_CONTROL' });
|
||||
|
||||
export const openProgress = () => {
|
||||
return {
|
||||
@@ -15,16 +15,19 @@ export const closeProgress = (id: string) => {
|
||||
};
|
||||
|
||||
type ProgressState = {
|
||||
progress_indicator: boolean,
|
||||
progress_indicator: boolean;
|
||||
};
|
||||
|
||||
const initialState: ProgressState = {
|
||||
progress_indicator: false
|
||||
progress_indicator: false,
|
||||
};
|
||||
|
||||
export default function progressReducer(state: ProgressState = { ...initialState }, action: any): ProgressState {
|
||||
export default function progressReducer(
|
||||
state: ProgressState = { ...initialState },
|
||||
action: any,
|
||||
): ProgressState {
|
||||
switch (action.type) {
|
||||
case "PROGRESS_CONTROL":
|
||||
case 'PROGRESS_CONTROL':
|
||||
return { ...state, progress_indicator: action.open };
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { combineReducers } from "redux";
|
||||
import websocketReducer from "./websocket";
|
||||
import incomingReducer from "./incoming";
|
||||
import mnemonicReducer from "./mnemonic";
|
||||
import walletMenuReducer from "./walletMenu";
|
||||
import createWallet from "./createWallet";
|
||||
import tradeReducer from "./trade";
|
||||
import dialogReducer from "./dialog";
|
||||
import daemonReducer from "./daemon";
|
||||
import { entranceReducer } from "./entranceMenu";
|
||||
import fullNodeReducer from "./fullNode";
|
||||
import farmingReducer from "./farming";
|
||||
import plotControlReducer from "./plotterControl";
|
||||
import progressReducer from "./progress";
|
||||
import backupReducer from "./backup";
|
||||
import { combineReducers } from 'redux';
|
||||
import websocketReducer from './websocket';
|
||||
import incomingReducer from './incoming';
|
||||
import mnemonicReducer from './mnemonic';
|
||||
import walletMenuReducer from './walletMenu';
|
||||
import createWallet from './createWallet';
|
||||
import tradeReducer from './trade';
|
||||
import dialogReducer from './dialog';
|
||||
import daemonReducer from './daemon';
|
||||
import { entranceReducer } from './entranceMenu';
|
||||
import fullNodeReducer from './fullNode';
|
||||
import farmingReducer from './farming';
|
||||
import plotControlReducer from './plotterControl';
|
||||
import progressReducer from './progress';
|
||||
import backupReducer from './backup';
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
daemon_state: daemonReducer,
|
||||
@@ -28,7 +28,7 @@ const rootReducer = combineReducers({
|
||||
farming_state: farmingReducer,
|
||||
plot_control: plotControlReducer,
|
||||
progress: progressReducer,
|
||||
backup_state: backupReducer
|
||||
backup_state: backupReducer,
|
||||
});
|
||||
|
||||
export type RootState = ReturnType<typeof rootReducer>;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import reduxThunk from "redux-thunk";
|
||||
import { createStore, applyMiddleware, compose } from "redux";
|
||||
import isElectron from "is-electron";
|
||||
import rootReducer from "./rootReducer";
|
||||
import wsMiddleware from "../middleware/middleware";
|
||||
import dev_config from "../dev_config";
|
||||
import { exit_and_close } from "./message";
|
||||
import reduxThunk from 'redux-thunk';
|
||||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import isElectron from 'is-electron';
|
||||
import rootReducer from './rootReducer';
|
||||
import wsMiddleware from '../middleware/middleware';
|
||||
import dev_config from '../dev_config';
|
||||
import { exit_and_close } from './message';
|
||||
|
||||
const middleware = [reduxThunk, wsMiddleware];
|
||||
|
||||
@@ -14,9 +14,10 @@ const store =
|
||||
: createStore(
|
||||
rootReducer,
|
||||
compose(
|
||||
applyMiddleware(...middleware), /* preloadedState, */
|
||||
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__()
|
||||
)
|
||||
applyMiddleware(...middleware),
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__ &&
|
||||
window.__REDUX_DEVTOOLS_EXTENSION__(),
|
||||
),
|
||||
);
|
||||
|
||||
window.onload = () => {
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
import { service_wallet } from "../util/service_names";
|
||||
import { service_wallet } from '../util/service_names';
|
||||
|
||||
export const addTrade = (trade: any) => ({ type: "TRADE_ADDED", trade });
|
||||
export const resetTrades = () => ({ type: "RESET_TRADE" });
|
||||
export const presentTrade = (trade: any) => ({ type: "PRESENT_TRADES", trade });
|
||||
export const presetOverview = () => ({ type: "PRESENT_OVERVIEW" });
|
||||
export const addTrade = (trade: any) => ({ type: 'TRADE_ADDED', trade });
|
||||
export const resetTrades = () => ({ type: 'RESET_TRADE' });
|
||||
export const presentTrade = (trade: any) => ({ type: 'PRESENT_TRADES', trade });
|
||||
export const presetOverview = () => ({ type: 'PRESENT_OVERVIEW' });
|
||||
|
||||
export const newBuy = (amount: number, id: number) => ({
|
||||
amount,
|
||||
wallet_id: id,
|
||||
side: "buy"
|
||||
side: 'buy',
|
||||
});
|
||||
|
||||
export const newSell = (amount: number, id: number) => ({
|
||||
amount,
|
||||
wallet_id: id,
|
||||
side: "sell"
|
||||
side: 'sell',
|
||||
});
|
||||
|
||||
export const offerParsed = (offer: any) => ({
|
||||
type: "OFFER_PARSING",
|
||||
type: 'OFFER_PARSING',
|
||||
status: parsingStateParsed,
|
||||
offer,
|
||||
});
|
||||
export const offerParsingName = (name: string, path: string) => ({
|
||||
type: "OFFER_NAME",
|
||||
type: 'OFFER_NAME',
|
||||
name,
|
||||
path,
|
||||
});
|
||||
export const parsingStarted = () => ({
|
||||
type: "OFFER_PARSING",
|
||||
status: parsingStatePending
|
||||
type: 'OFFER_PARSING',
|
||||
status: parsingStatePending,
|
||||
});
|
||||
|
||||
export const parsingStateNone = "NONE";
|
||||
export const parsingStatePending = "PENDING";
|
||||
export const parsingStateParsed = "PARSED";
|
||||
export const parsingStateReset = "RESET";
|
||||
export const parsingStateNone = 'NONE';
|
||||
export const parsingStatePending = 'PENDING';
|
||||
export const parsingStateParsed = 'PARSED';
|
||||
export const parsingStateReset = 'RESET';
|
||||
|
||||
type TradeState = {
|
||||
trades: any[],
|
||||
show_offer: boolean,
|
||||
parsing_state: 'NONE' | 'PENDING' | 'PARSED' | 'RESET',
|
||||
parsed_offer: any,
|
||||
parsed_offer_name: string,
|
||||
parsed_offer_path: string,
|
||||
pending_trades: Object[],
|
||||
trade_history: Object[],
|
||||
showing_trade: boolean,
|
||||
trade_showed?: boolean | null,
|
||||
trades: any[];
|
||||
show_offer: boolean;
|
||||
parsing_state: 'NONE' | 'PENDING' | 'PARSED' | 'RESET';
|
||||
parsed_offer: any;
|
||||
parsed_offer_name: string;
|
||||
parsed_offer_path: string;
|
||||
pending_trades: Object[];
|
||||
trade_history: Object[];
|
||||
showing_trade: boolean;
|
||||
trade_showed?: boolean | null;
|
||||
};
|
||||
|
||||
const initialState: TradeState = {
|
||||
@@ -55,7 +55,7 @@ const initialState: TradeState = {
|
||||
show_offer: false,
|
||||
parsing_state: parsingStateNone,
|
||||
parsed_offer: null,
|
||||
parsed_offer_name: "",
|
||||
parsed_offer_name: '',
|
||||
parsed_offer_path: '',
|
||||
pending_trades: [],
|
||||
trade_history: [],
|
||||
@@ -63,27 +63,30 @@ const initialState: TradeState = {
|
||||
trade_showed: null,
|
||||
};
|
||||
|
||||
export default function tradeReducer(state = { ...initialState }, action: any): TradeState {
|
||||
export default function tradeReducer(
|
||||
state = { ...initialState },
|
||||
action: any,
|
||||
): TradeState {
|
||||
let trade;
|
||||
switch (action.type) {
|
||||
case "INCOMING_MESSAGE":
|
||||
case 'INCOMING_MESSAGE':
|
||||
if (action.message.origin !== service_wallet) {
|
||||
return state;
|
||||
}
|
||||
|
||||
const message = action.message;
|
||||
const data = message.data;
|
||||
const command = message.command;
|
||||
const success = data.success;
|
||||
const { message } = action;
|
||||
const { data } = message;
|
||||
const { command } = message;
|
||||
const { success } = data;
|
||||
|
||||
if (command === "get_all_trades" && success === true) {
|
||||
if (command === 'get_all_trades' && success === true) {
|
||||
const all_trades = data.trades;
|
||||
var pending_trades = [];
|
||||
var trade_history = [];
|
||||
for (var i = 0; i < all_trades.length; i++) {
|
||||
const pending_trades = [];
|
||||
const trade_history = [];
|
||||
for (let i = 0; i < all_trades.length; i++) {
|
||||
const trade = all_trades[i];
|
||||
const my_trade = trade.my_offer;
|
||||
const confirmed_at_index = trade.confirmed_at_index;
|
||||
const { confirmed_at_index } = trade;
|
||||
if (my_trade === true && confirmed_at_index === 0) {
|
||||
pending_trades.push(trade);
|
||||
} else {
|
||||
@@ -92,57 +95,58 @@ export default function tradeReducer(state = { ...initialState }, action: any):
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
trade_history: trade_history,
|
||||
pending_trades: pending_trades
|
||||
trade_history,
|
||||
pending_trades,
|
||||
};
|
||||
}
|
||||
return state;
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return { ...initialState };
|
||||
case "TRADE_ADDED":
|
||||
case 'TRADE_ADDED':
|
||||
trade = action.trade;
|
||||
const new_trades = [...state.trades];
|
||||
new_trades.push(trade);
|
||||
return { ...state, trades: new_trades };
|
||||
case "RESET_TRADE":
|
||||
case 'RESET_TRADE':
|
||||
return { ...initialState };
|
||||
case "OFFER_PARSING":
|
||||
var status = action.status;
|
||||
case 'OFFER_PARSING':
|
||||
var { status } = action;
|
||||
if (status === parsingStateParsed) {
|
||||
return {
|
||||
...state,
|
||||
parsing_state: status,
|
||||
parsed_offer: action.offer,
|
||||
show_offer: true
|
||||
show_offer: true,
|
||||
};
|
||||
} else if (status === parsingStateReset) {
|
||||
}
|
||||
if (status === parsingStateReset) {
|
||||
return {
|
||||
...state,
|
||||
parsing_state: parsingStatePending,
|
||||
show_offer: false
|
||||
show_offer: false,
|
||||
};
|
||||
}
|
||||
return {
|
||||
...state,
|
||||
parsing_state: status
|
||||
parsing_state: status,
|
||||
};
|
||||
case "OFFER_NAME":
|
||||
case 'OFFER_NAME':
|
||||
return {
|
||||
...state,
|
||||
parsed_offer_name: action.name,
|
||||
parsed_offer_path: action.path,
|
||||
};
|
||||
case "PRESENT_OVERVIEW":
|
||||
case 'PRESENT_OVERVIEW':
|
||||
return {
|
||||
...state,
|
||||
showing_trade: false,
|
||||
trade_showed: null,
|
||||
};
|
||||
case "PRESENT_TRADES":
|
||||
case 'PRESENT_TRADES':
|
||||
return {
|
||||
...state,
|
||||
showing_trade: true,
|
||||
trade_showed: action.trade
|
||||
trade_showed: action.trade,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
import { walletMessage, async_api } from "./message";
|
||||
import { closeProgress } from "./progress";
|
||||
import { walletMessage, async_api } from './message';
|
||||
import { closeProgress } from './progress';
|
||||
|
||||
export const cancel_trade = trade_id => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "cancel_trade";
|
||||
export const cancel_trade = (trade_id) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'cancel_trade';
|
||||
const data = {
|
||||
trade_id: trade_id,
|
||||
secure: false
|
||||
trade_id,
|
||||
secure: false,
|
||||
};
|
||||
action.message.data = data;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const cancel_trade_with_spend = trade_id => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "cancel_trade";
|
||||
export const cancel_trade_with_spend = (trade_id) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'cancel_trade';
|
||||
const data = {
|
||||
trade_id: trade_id,
|
||||
secure: true
|
||||
trade_id,
|
||||
secure: true,
|
||||
};
|
||||
action.message.data = data;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const get_all_trades = () => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_all_trades";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_all_trades';
|
||||
const data = {};
|
||||
action.message.data = data;
|
||||
return action;
|
||||
};
|
||||
|
||||
export function cancel_trade_action(trade_id) {
|
||||
return dispatch => {
|
||||
return async_api(dispatch, cancel_trade(trade_id)).then(response => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, cancel_trade(trade_id)).then((response) => {
|
||||
dispatch(get_all_trades());
|
||||
dispatch(closeProgress());
|
||||
});
|
||||
@@ -41,57 +41,57 @@ export function cancel_trade_action(trade_id) {
|
||||
}
|
||||
|
||||
export function cancel_trade_with_spend_action(trade_id) {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, cancel_trade_with_spend(trade_id)).then(
|
||||
response => {
|
||||
(response) => {
|
||||
dispatch(get_all_trades());
|
||||
dispatch(closeProgress());
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export const create_trade_offer = (trades, filepath) => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "create_offer_for_ids";
|
||||
const action = walletMessage();
|
||||
action.message.command = 'create_offer_for_ids';
|
||||
const data = {
|
||||
ids: trades,
|
||||
filename: filepath
|
||||
filename: filepath,
|
||||
};
|
||||
action.message.data = data;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const parse_trade_offer = filepath => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "get_discrepancies_for_offer";
|
||||
export const parse_trade_offer = (filepath) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'get_discrepancies_for_offer';
|
||||
const data = { filename: filepath };
|
||||
action.message.data = data;
|
||||
return action;
|
||||
};
|
||||
|
||||
export const accept_trade_offer = filepath => {
|
||||
var action = walletMessage();
|
||||
action.message.command = "respond_to_offer";
|
||||
export const accept_trade_offer = (filepath) => {
|
||||
const action = walletMessage();
|
||||
action.message.command = 'respond_to_offer';
|
||||
action.message.data = { filename: filepath };
|
||||
return action;
|
||||
};
|
||||
|
||||
export function create_trade_action(trades, filepath, history) {
|
||||
return dispatch => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, create_trade_offer(trades, filepath)).then(
|
||||
response => {
|
||||
(response) => {
|
||||
dispatch(get_all_trades());
|
||||
history.push('/dashboard/trade');
|
||||
dispatch(closeProgress());
|
||||
}
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
export function parse_trade_action(filepath) {
|
||||
return dispatch => {
|
||||
return async_api(dispatch, parse_trade_offer(filepath)).then(response => {
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, parse_trade_offer(filepath)).then((response) => {
|
||||
dispatch(get_all_trades());
|
||||
dispatch(closeProgress());
|
||||
});
|
||||
@@ -99,10 +99,12 @@ export function parse_trade_action(filepath) {
|
||||
}
|
||||
|
||||
export function accept_trade_action(filepath) {
|
||||
return dispatch => {
|
||||
return async_api(dispatch, accept_trade_offer(filepath)).then(response => {
|
||||
dispatch(get_all_trades());
|
||||
dispatch(closeProgress());
|
||||
});
|
||||
return (dispatch) => {
|
||||
return async_api(dispatch, accept_trade_offer(filepath)).then(
|
||||
(response) => {
|
||||
dispatch(get_all_trades());
|
||||
dispatch(closeProgress());
|
||||
},
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,35 +1,38 @@
|
||||
import WalletType from "../types/WalletType";
|
||||
import WalletType from '../types/WalletType';
|
||||
|
||||
export const standardWallet = "STANDARD_WALLET";
|
||||
export const createWallet = "CREATE_WALLET";
|
||||
export const CCWallet = "CC_WALLET";
|
||||
export const RLWallet = "RL_WALLET";
|
||||
export const standardWallet = 'STANDARD_WALLET';
|
||||
export const createWallet = 'CREATE_WALLET';
|
||||
export const CCWallet = 'CC_WALLET';
|
||||
export const RLWallet = 'RL_WALLET';
|
||||
|
||||
export const changeWalletMenu = (item: unknown, id: number) => ({
|
||||
type: "WALLET_MENU",
|
||||
type: 'WALLET_MENU',
|
||||
item,
|
||||
id,
|
||||
});
|
||||
|
||||
type WalletMenuState = {
|
||||
view: WalletType,
|
||||
id: number,
|
||||
view: WalletType;
|
||||
id: number;
|
||||
};
|
||||
|
||||
const initialState: WalletMenuState = {
|
||||
const initialState: WalletMenuState = {
|
||||
view: WalletType.STANDARD_WALLET,
|
||||
id: 1,
|
||||
};
|
||||
|
||||
export default function walletMenuReducer(state = { ...initialState }, action: any): WalletMenuState {
|
||||
export default function walletMenuReducer(
|
||||
state = { ...initialState },
|
||||
action: any,
|
||||
): WalletMenuState {
|
||||
switch (action.type) {
|
||||
case "LOG_OUT":
|
||||
case 'LOG_OUT':
|
||||
return { ...initialState };
|
||||
case "WALLET_MENU":
|
||||
case 'WALLET_MENU':
|
||||
const { item, id } = action;
|
||||
return {
|
||||
...state,
|
||||
view: item,
|
||||
return {
|
||||
...state,
|
||||
view: item,
|
||||
id,
|
||||
};
|
||||
default:
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
export const wsConnect = (host: string) => ({ type: "WS_CONNECT", host });
|
||||
export const wsConnecting = (host: string) => ({ type: "WS_CONNECTING", host });
|
||||
export const wsConnected = (host: string) => ({ type: "WS_CONNECTED", host });
|
||||
export const wsDisconnect = (host: string) => ({ type: "WS_DISCONNECT", host });
|
||||
export const wsDisconnected = (host: string) => ({ type: "WS_DISCONNECTED", host });
|
||||
export const wsConnect = (host: string) => ({ type: 'WS_CONNECT', host });
|
||||
export const wsConnecting = (host: string) => ({ type: 'WS_CONNECTING', host });
|
||||
export const wsConnected = (host: string) => ({ type: 'WS_CONNECTED', host });
|
||||
export const wsDisconnect = (host: string) => ({ type: 'WS_DISCONNECT', host });
|
||||
export const wsDisconnected = (host: string) => ({
|
||||
type: 'WS_DISCONNECTED',
|
||||
host,
|
||||
});
|
||||
|
||||
type WebsocketState = {
|
||||
connected: boolean,
|
||||
connecting: boolean,
|
||||
host?: string,
|
||||
connected: boolean;
|
||||
connecting: boolean;
|
||||
host?: string;
|
||||
};
|
||||
|
||||
const initialState: WebsocketState = {
|
||||
connected: false,
|
||||
connecting: false
|
||||
connecting: false,
|
||||
};
|
||||
|
||||
export default function websocketReducer(
|
||||
@@ -20,24 +23,24 @@ export default function websocketReducer(
|
||||
action: any,
|
||||
): WebsocketState {
|
||||
switch (action.type) {
|
||||
case "WS_CONNECTED":
|
||||
case 'WS_CONNECTED':
|
||||
return {
|
||||
...state,
|
||||
host: action.host,
|
||||
connected: true,
|
||||
connecting: false
|
||||
connecting: false,
|
||||
};
|
||||
case "WS_DISCONNECTED":
|
||||
case 'WS_DISCONNECTED':
|
||||
return {
|
||||
...state,
|
||||
host: action.host,
|
||||
connected: false,
|
||||
connecting: false
|
||||
connecting: false,
|
||||
};
|
||||
case "WS_CONNECTING":
|
||||
return {
|
||||
...state,
|
||||
host: action.host,
|
||||
case 'WS_CONNECTING':
|
||||
return {
|
||||
...state,
|
||||
host: action.host,
|
||||
connecting: true,
|
||||
};
|
||||
default:
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
import { openDialog } from "../modules/dialog";
|
||||
import DialogTitle from "@material-ui/core/DialogTitle";
|
||||
import DialogContent from "@material-ui/core/DialogContent";
|
||||
import DialogActions from "@material-ui/core/DialogActions";
|
||||
import Dialog from "@material-ui/core/Dialog";
|
||||
import isElectron from "is-electron";
|
||||
import Box from "@material-ui/core/Box";
|
||||
import React from "react";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import List from "@material-ui/core/List";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import ListItemAvatar from "@material-ui/core/ListItemAvatar";
|
||||
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import Avatar from "@material-ui/core/Avatar";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import FolderIcon from "@material-ui/icons/Folder";
|
||||
import DeleteIcon from "@material-ui/icons/Delete";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||
import DialogContent from '@material-ui/core/DialogContent';
|
||||
import DialogActions from '@material-ui/core/DialogActions';
|
||||
import Dialog from '@material-ui/core/Dialog';
|
||||
import isElectron from 'is-electron';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import React from 'react';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
|
||||
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import Avatar from '@material-ui/core/Avatar';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
import FolderIcon from '@material-ui/icons/Folder';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { openDialog } from '../modules/dialog';
|
||||
|
||||
import {
|
||||
add_plot_directory_and_refresh,
|
||||
remove_plot_directory_and_refresh
|
||||
} from "../modules/message";
|
||||
remove_plot_directory_and_refresh,
|
||||
} from '../modules/message';
|
||||
|
||||
const styles = theme => ({
|
||||
const styles = (theme) => ({
|
||||
dialogTitle: {
|
||||
width: 500
|
||||
width: 500,
|
||||
},
|
||||
addPlotButton: {
|
||||
width: 220,
|
||||
marginLeft: theme.spacing(2),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
keyInput: {
|
||||
marginTop: 10
|
||||
marginTop: 10,
|
||||
},
|
||||
dirList: {
|
||||
width: "100%"
|
||||
}
|
||||
width: '100%',
|
||||
},
|
||||
});
|
||||
|
||||
const useStyles = makeStyles(styles);
|
||||
|
||||
const AddPlotDialog = props => {
|
||||
const AddPlotDialog = (props) => {
|
||||
const classes = useStyles();
|
||||
const { onClose, open, ...other } = props;
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const directories = useSelector(
|
||||
state => state.farming_state.harvester.plot_directories
|
||||
(state) => state.farming_state.harvester.plot_directories,
|
||||
);
|
||||
|
||||
const removePlotDir = dir => {
|
||||
const removePlotDir = (dir) => {
|
||||
dispatch(remove_plot_directory_and_refresh(dir));
|
||||
};
|
||||
|
||||
async function select() {
|
||||
if (isElectron()) {
|
||||
const dialogOptions = {
|
||||
properties: ["openDirectory", "showHiddenFiles"],
|
||||
buttonLabel: "Select Plot Directory"
|
||||
properties: ['openDirectory', 'showHiddenFiles'],
|
||||
buttonLabel: 'Select Plot Directory',
|
||||
};
|
||||
const result = await window.remote.dialog.showOpenDialog(dialogOptions);
|
||||
console.log(result);
|
||||
if (!result.canceled) {
|
||||
const filePath = result["filePaths"][0];
|
||||
const filePath = result.filePaths[0];
|
||||
dispatch(add_plot_directory_and_refresh(filePath));
|
||||
}
|
||||
} else {
|
||||
dispatch(
|
||||
openDialog("", "This feature is available only from electron app")
|
||||
openDialog('', 'This feature is available only from electron app'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -96,8 +96,8 @@ const AddPlotDialog = props => {
|
||||
not created any plots, go to the plotting screen.
|
||||
</p>
|
||||
<Box display="flex">
|
||||
<List dense={true} className={classes.dirList}>
|
||||
{directories.map(dir => (
|
||||
<List dense className={classes.dirList}>
|
||||
{directories.map((dir) => (
|
||||
<ListItem key={dir}>
|
||||
<ListItemAvatar>
|
||||
<Avatar>
|
||||
|
||||
@@ -1,84 +1,89 @@
|
||||
import React, { useEffect, useCallback, useState } from "react";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { withStyles } from "@material-ui/core/styles";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import { Paper, TableRow, Tooltip } from "@material-ui/core";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Table from "@material-ui/core/Table";
|
||||
import TableBody from "@material-ui/core/TableBody";
|
||||
import TableCell from "@material-ui/core/TableCell";
|
||||
import TableContainer from "@material-ui/core/TableContainer";
|
||||
import { unix_to_short_date } from "../util/utils";
|
||||
import { clearBlock, getHeader, getBlock } from "../modules/fullnodeMessages";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { chia_formatter } from "../util/chia";
|
||||
import { hex_to_array, arr_to_hex, sha256 } from "../util/utils";
|
||||
import { hash_header } from "../util/header";
|
||||
import HelpIcon from "@material-ui/icons/Help";
|
||||
import { calculate_block_reward } from "../util/block_rewards";
|
||||
import React, { useEffect, useCallback, useState } from 'react';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { withStyles } from '@material-ui/core/styles';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import { Paper, TableRow, Tooltip } from '@material-ui/core';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Table from '@material-ui/core/Table';
|
||||
import TableBody from '@material-ui/core/TableBody';
|
||||
import TableCell from '@material-ui/core/TableCell';
|
||||
import TableContainer from '@material-ui/core/TableContainer';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import HelpIcon from '@material-ui/icons/Help';
|
||||
import {
|
||||
unix_to_short_date,
|
||||
hex_to_array,
|
||||
arr_to_hex,
|
||||
sha256,
|
||||
} from '../util/utils';
|
||||
import { clearBlock, getHeader, getBlock } from '../modules/fullnodeMessages';
|
||||
import { chia_formatter } from '../util/chia';
|
||||
|
||||
import { hash_header } from '../util/header';
|
||||
import { calculate_block_reward } from '../util/block_rewards';
|
||||
|
||||
/* global BigInt */
|
||||
|
||||
const styles = theme => ({
|
||||
const styles = (theme) => ({
|
||||
form: {
|
||||
margin: theme.spacing(1)
|
||||
margin: theme.spacing(1),
|
||||
},
|
||||
clickable: {
|
||||
cursor: "pointer"
|
||||
cursor: 'pointer',
|
||||
},
|
||||
error: {
|
||||
color: "red"
|
||||
color: 'red',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(0),
|
||||
paddingBottom: theme.spacing(0),
|
||||
paddingRight: theme.spacing(0)
|
||||
paddingRight: theme.spacing(0),
|
||||
},
|
||||
balancePaper: {
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(1),
|
||||
paddingTop: theme.spacing(1),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
table: {
|
||||
minWidth: 650
|
||||
minWidth: 650,
|
||||
},
|
||||
connect: {
|
||||
marginLeft: theme.spacing(1)
|
||||
}
|
||||
marginLeft: theme.spacing(1),
|
||||
},
|
||||
});
|
||||
|
||||
const Block = props => {
|
||||
const [headerHash, setHeaderHash] = useState("");
|
||||
const [plotId, setPlotId] = useState("");
|
||||
const Block = (props) => {
|
||||
const [headerHash, setHeaderHash] = useState('');
|
||||
const [plotId, setPlotId] = useState('');
|
||||
const [didMount, setDidMount] = useState(false);
|
||||
|
||||
const prev_header_hash = props.block.header.data.prev_header_hash;
|
||||
const height = props.block.header.data.height;
|
||||
const { prev_header_hash } = props.block.header.data;
|
||||
const { height } = props.block.header.data;
|
||||
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const handleClearBlock = useCallback(() => dispatch(clearBlock()), [
|
||||
dispatch
|
||||
dispatch,
|
||||
]);
|
||||
|
||||
const handleGetHeader = useCallback(
|
||||
headerHash => dispatch(getHeader(headerHash)),
|
||||
[dispatch]
|
||||
(headerHash) => dispatch(getHeader(headerHash)),
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
const handleGetBlock = useCallback(
|
||||
headerHash => dispatch(getBlock(headerHash)),
|
||||
[dispatch]
|
||||
(headerHash) => dispatch(getBlock(headerHash)),
|
||||
[dispatch],
|
||||
);
|
||||
|
||||
const fetchHeaderIfNecessary = useCallback(async () => {
|
||||
if (props.prevHeader) {
|
||||
const phh = await hash_header(props.prevHeader);
|
||||
let phh_expected = props.block.header.data.prev_header_hash;
|
||||
if (phh_expected.startsWith("0x") || phh_expected.startsWith("0X")) {
|
||||
if (phh_expected.startsWith('0x') || phh_expected.startsWith('0X')) {
|
||||
phh_expected = phh_expected.substring(2);
|
||||
}
|
||||
if (phh !== phh_expected) {
|
||||
@@ -87,30 +92,30 @@ const Block = props => {
|
||||
} else {
|
||||
handleGetHeader(props.block.header.data.prev_header_hash);
|
||||
}
|
||||
var newHeaderHash = await hash_header(props.block.header);
|
||||
const newHeaderHash = await hash_header(props.block.header);
|
||||
|
||||
let buf = hex_to_array(props.block.proof_of_space.pool_public_key);
|
||||
buf = buf.concat(hex_to_array(props.block.proof_of_space.plot_public_key));
|
||||
const bufHash = await sha256(buf);
|
||||
var newPlotId = arr_to_hex(bufHash);
|
||||
const newPlotId = arr_to_hex(bufHash);
|
||||
setHeaderHash(newHeaderHash);
|
||||
setPlotId(newPlotId);
|
||||
}, [handleGetHeader, props]);
|
||||
|
||||
useEffect(
|
||||
prevProps => {
|
||||
(prevProps) => {
|
||||
(async () => {
|
||||
if (!didMount || height > 0) {
|
||||
await fetchHeaderIfNecessary();
|
||||
}
|
||||
})();
|
||||
},
|
||||
[prev_header_hash, height, didMount, setDidMount, fetchHeaderIfNecessary]
|
||||
[prev_header_hash, height, didMount, setDidMount, fetchHeaderIfNecessary],
|
||||
);
|
||||
|
||||
const classes = props.classes;
|
||||
const block = props.block;
|
||||
const prevHeader = props.prevHeader;
|
||||
const { classes } = props;
|
||||
const { block } = props;
|
||||
const { prevHeader } = props;
|
||||
|
||||
let diff = 0;
|
||||
if (block.header.data.height === 0) {
|
||||
@@ -118,87 +123,87 @@ const Block = props => {
|
||||
} else if (prevHeader) {
|
||||
diff = block.header.data.weight - prevHeader.data.weight;
|
||||
}
|
||||
var newHeaderHash = "0x" + headerHash;
|
||||
var newPlotId = "0x" + plotId;
|
||||
const newHeaderHash = `0x${headerHash}`;
|
||||
const newPlotId = `0x${plotId}`;
|
||||
|
||||
const chia_cb = chia_formatter(
|
||||
parseFloat(calculate_block_reward(block.header.data.height)),
|
||||
"mojo"
|
||||
'mojo',
|
||||
)
|
||||
.to("chia")
|
||||
.to('chia')
|
||||
.toString();
|
||||
const chia_fees = chia_formatter(
|
||||
parseFloat(BigInt(block.header.data.total_transaction_fees)),
|
||||
"mojo"
|
||||
'mojo',
|
||||
)
|
||||
.to("chia")
|
||||
.to('chia')
|
||||
.toString();
|
||||
|
||||
const rows = [
|
||||
{ name: "Header hash", value: newHeaderHash },
|
||||
{ name: 'Header hash', value: newHeaderHash },
|
||||
{
|
||||
name: "Timestamp",
|
||||
name: 'Timestamp',
|
||||
value: unix_to_short_date(block.header.data.timestamp),
|
||||
tooltip:
|
||||
"This is the time the block was created by the farmer, which is before it is finalized with a proof of time"
|
||||
'This is the time the block was created by the farmer, which is before it is finalized with a proof of time',
|
||||
},
|
||||
{ name: "Height", value: block.header.data.height },
|
||||
{ name: 'Height', value: block.header.data.height },
|
||||
{
|
||||
name: "Weight",
|
||||
name: 'Weight',
|
||||
value: BigInt(block.header.data.weight).toLocaleString(),
|
||||
tooltip:
|
||||
"Weight is the total added difficulty of all blocks up to and including this one"
|
||||
'Weight is the total added difficulty of all blocks up to and including this one',
|
||||
},
|
||||
{ name: "Previous block", value: block.header.data.prev_header_hash },
|
||||
{ name: "Difficulty", value: BigInt(diff).toLocaleString() },
|
||||
{ name: 'Previous block', value: block.header.data.prev_header_hash },
|
||||
{ name: 'Difficulty', value: BigInt(diff).toLocaleString() },
|
||||
{
|
||||
name: "Total VDF Iterations",
|
||||
name: 'Total VDF Iterations',
|
||||
value: BigInt(block.header.data.total_iters).toLocaleString(),
|
||||
tooltip:
|
||||
"The total number of VDF (verifiable delay function) or proof of time iterations on the whole chain up to this block."
|
||||
'The total number of VDF (verifiable delay function) or proof of time iterations on the whole chain up to this block.',
|
||||
},
|
||||
{
|
||||
name: "Block VDF Iterations",
|
||||
name: 'Block VDF Iterations',
|
||||
value: BigInt(block.proof_of_time.number_of_iterations).toLocaleString(),
|
||||
tooltip:
|
||||
"The total number of VDF (verifiable delay function) or proof of time iterations on this block."
|
||||
'The total number of VDF (verifiable delay function) or proof of time iterations on this block.',
|
||||
},
|
||||
{ name: "Proof of Space Size", value: block.proof_of_space.size },
|
||||
{ name: "Plot Public Key", value: block.proof_of_space.plot_public_key },
|
||||
{ name: "Pool Public Key", value: block.proof_of_space.pool_public_key },
|
||||
{ name: 'Proof of Space Size', value: block.proof_of_space.size },
|
||||
{ name: 'Plot Public Key', value: block.proof_of_space.plot_public_key },
|
||||
{ name: 'Pool Public Key', value: block.proof_of_space.pool_public_key },
|
||||
{
|
||||
name: "Plot Id",
|
||||
name: 'Plot Id',
|
||||
value: newPlotId,
|
||||
tooltip:
|
||||
"The seed used to create the plot, this depends on the pool pk and plot pk"
|
||||
'The seed used to create the plot, this depends on the pool pk and plot pk',
|
||||
},
|
||||
{
|
||||
name: "Transactions Filter Hash",
|
||||
value: block.header.data.filter_hash
|
||||
name: 'Transactions Filter Hash',
|
||||
value: block.header.data.filter_hash,
|
||||
},
|
||||
{
|
||||
name: "Transactions Generator Hash",
|
||||
value: block.header.data.generator_hash
|
||||
name: 'Transactions Generator Hash',
|
||||
value: block.header.data.generator_hash,
|
||||
},
|
||||
{
|
||||
name: "Coinbase Amount",
|
||||
value: chia_cb + " TXCH",
|
||||
name: 'Coinbase Amount',
|
||||
value: `${chia_cb} TXCH`,
|
||||
tooltip:
|
||||
"The Chia block reward, goes to the pool (or farmer if not pooling)"
|
||||
'The Chia block reward, goes to the pool (or farmer if not pooling)',
|
||||
},
|
||||
{
|
||||
name: "Coinbase Puzzle Hash",
|
||||
value: block.header.data.pool_target.puzzle_hash
|
||||
name: 'Coinbase Puzzle Hash',
|
||||
value: block.header.data.pool_target.puzzle_hash,
|
||||
},
|
||||
{
|
||||
name: "Fees Amount",
|
||||
value: chia_fees + " TXCH",
|
||||
tooltip: "The total fees in this block, goes to the farmer"
|
||||
name: 'Fees Amount',
|
||||
value: `${chia_fees} TXCH`,
|
||||
tooltip: 'The total fees in this block, goes to the farmer',
|
||||
},
|
||||
{
|
||||
name: "Fees Puzzle Hash",
|
||||
value: block.header.data.farmer_rewards_puzzle_hash
|
||||
}
|
||||
name: 'Fees Puzzle Hash',
|
||||
value: block.header.data.farmer_rewards_puzzle_hash,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
@@ -214,23 +219,23 @@ const Block = props => {
|
||||
<TableContainer component={Paper}>
|
||||
<Table className={classes.table} aria-label="simple table">
|
||||
<TableBody>
|
||||
{rows.map(row => (
|
||||
{rows.map((row) => (
|
||||
<TableRow key={row.name}>
|
||||
<TableCell component="th" scope="row">
|
||||
{row.name}{" "}
|
||||
{row.name}{' '}
|
||||
{row.tooltip ? (
|
||||
<Tooltip title={row.tooltip}>
|
||||
<HelpIcon
|
||||
style={{ color: "#c8c8c8", fontSize: 12 }}
|
||||
></HelpIcon>
|
||||
style={{ color: '#c8c8c8', fontSize: 12 }}
|
||||
/>
|
||||
</Tooltip>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
onClick={
|
||||
row.name === "Previous block"
|
||||
row.name === 'Previous block'
|
||||
? () => handleGetBlock(row.value)
|
||||
: () => {}
|
||||
}
|
||||
|
||||
@@ -1,208 +1,209 @@
|
||||
import React from "react";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import React from 'react';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import Box from "@material-ui/core/Box";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Table from "@material-ui/core/Table";
|
||||
import TableBody from "@material-ui/core/TableBody";
|
||||
import TableCell from "@material-ui/core/TableCell";
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Table from '@material-ui/core/Table';
|
||||
import TableBody from '@material-ui/core/TableBody';
|
||||
import TableCell from '@material-ui/core/TableCell';
|
||||
|
||||
import TableHead from "@material-ui/core/TableHead";
|
||||
import TableRow from "@material-ui/core/TableRow";
|
||||
import TableHead from '@material-ui/core/TableHead';
|
||||
import TableRow from '@material-ui/core/TableRow';
|
||||
import {
|
||||
get_address,
|
||||
cc_spend,
|
||||
farm_block,
|
||||
rename_cc_wallet
|
||||
} from "../modules/message";
|
||||
rename_cc_wallet,
|
||||
} from '../modules/message';
|
||||
import {
|
||||
mojo_to_chia_string,
|
||||
mojo_to_colouredcoin_string,
|
||||
colouredcoin_to_mojo
|
||||
} from "../util/chia";
|
||||
import { unix_to_short_date } from "../util/utils";
|
||||
import Accordion from "../components/Accordion";
|
||||
import { openDialog } from "../modules/dialog";
|
||||
import { get_transaction_result } from "../util/transaction_result";
|
||||
const config = require("../config");
|
||||
colouredcoin_to_mojo,
|
||||
} from '../util/chia';
|
||||
import { unix_to_short_date } from '../util/utils';
|
||||
import Accordion from '../components/Accordion';
|
||||
import { openDialog } from '../modules/dialog';
|
||||
import { get_transaction_result } from '../util/transaction_result';
|
||||
|
||||
const config = require('../config');
|
||||
|
||||
const drawerWidth = 240;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
display: "flex",
|
||||
paddingLeft: "0px"
|
||||
display: 'flex',
|
||||
paddingLeft: '0px',
|
||||
},
|
||||
resultSuccess: {
|
||||
color: "green"
|
||||
color: 'green',
|
||||
},
|
||||
resultFailure: {
|
||||
color: "red"
|
||||
color: 'red',
|
||||
},
|
||||
toolbar: {
|
||||
paddingRight: 24 // keep right padding when drawer closed
|
||||
paddingRight: 24, // keep right padding when drawer closed
|
||||
},
|
||||
toolbarIcon: {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
padding: "0 8px",
|
||||
...theme.mixins.toolbar
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-end',
|
||||
padding: '0 8px',
|
||||
...theme.mixins.toolbar,
|
||||
},
|
||||
appBar: {
|
||||
zIndex: theme.zIndex.drawer + 1,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
transition: theme.transitions.create(['width', 'margin'], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
})
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
},
|
||||
appBarShift: {
|
||||
marginLeft: drawerWidth,
|
||||
width: `calc(100% - ${drawerWidth}px)`,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
transition: theme.transitions.create(['width', 'margin'], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
drawerPaperClose: {
|
||||
overflowX: "hidden",
|
||||
transition: theme.transitions.create("width", {
|
||||
overflowX: 'hidden',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
width: theme.spacing(7),
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: theme.spacing(9)
|
||||
}
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: theme.spacing(9),
|
||||
},
|
||||
},
|
||||
appBarSpacer: theme.mixins.toolbar,
|
||||
content: {
|
||||
flexGrow: 1,
|
||||
height: "100vh",
|
||||
overflow: "auto"
|
||||
height: '100vh',
|
||||
overflow: 'auto',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(0),
|
||||
paddingBottom: theme.spacing(0),
|
||||
paddingRight: theme.spacing(0)
|
||||
paddingRight: theme.spacing(0),
|
||||
},
|
||||
paper: {
|
||||
padding: theme.spacing(1),
|
||||
margin: theme.spacing(1),
|
||||
marginBottom: theme.spacing(2),
|
||||
marginTop: theme.spacing(2),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
balancePaper: {
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
sendButton: {
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(2),
|
||||
width: 150,
|
||||
height: 50
|
||||
height: 50,
|
||||
},
|
||||
copyButton: {
|
||||
marginTop: theme.spacing(0),
|
||||
marginBottom: theme.spacing(0),
|
||||
width: 70,
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(1),
|
||||
paddingTop: theme.spacing(1),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
cardSubSection: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingTop: theme.spacing(1)
|
||||
paddingTop: theme.spacing(1),
|
||||
},
|
||||
walletContainer: {
|
||||
marginBottom: theme.spacing(5)
|
||||
marginBottom: theme.spacing(5),
|
||||
},
|
||||
table_root: {
|
||||
width: "100%",
|
||||
width: '100%',
|
||||
maxHeight: 600,
|
||||
overflowY: "scroll",
|
||||
overflowY: 'scroll',
|
||||
padding: theme.spacing(1),
|
||||
margin: theme.spacing(1),
|
||||
marginBottom: theme.spacing(2),
|
||||
marginTop: theme.spacing(2),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
table: {
|
||||
height: "100%",
|
||||
overflowY: "scroll"
|
||||
height: '100%',
|
||||
overflowY: 'scroll',
|
||||
},
|
||||
tableBody: {
|
||||
height: "100%",
|
||||
overflowY: "scroll"
|
||||
height: '100%',
|
||||
overflowY: 'scroll',
|
||||
},
|
||||
row: {
|
||||
width: 700
|
||||
width: 700,
|
||||
},
|
||||
cell_short: {
|
||||
fontSize: "14px",
|
||||
fontSize: '14px',
|
||||
width: 50,
|
||||
overflowWrap: "break-word" /* Renamed property in CSS3 draft spec */
|
||||
overflowWrap: 'break-word' /* Renamed property in CSS3 draft spec */,
|
||||
},
|
||||
colourCard: {
|
||||
overflowWrap: "break-word",
|
||||
overflowWrap: 'break-word',
|
||||
marginTop: theme.spacing(2),
|
||||
paddingBottom: 20
|
||||
paddingBottom: 20,
|
||||
},
|
||||
amountField: {
|
||||
paddingRight: 20
|
||||
}
|
||||
paddingRight: 20,
|
||||
},
|
||||
}));
|
||||
|
||||
const ColourCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const ColourCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const colour = useSelector(state => state.wallet_state.wallets[id].colour);
|
||||
const name = useSelector(state => state.wallet_state.wallets[id].name);
|
||||
const colour = useSelector((state) => state.wallet_state.wallets[id].colour);
|
||||
const name = useSelector((state) => state.wallet_state.wallets[id].name);
|
||||
|
||||
var name_input = null;
|
||||
let name_input = null;
|
||||
|
||||
function rename() {
|
||||
dispatch(rename_cc_wallet(id, name_input.value));
|
||||
@@ -228,8 +229,8 @@ const ColourCard = props => {
|
||||
<Box
|
||||
style={{
|
||||
paddingLeft: 20,
|
||||
width: "80%",
|
||||
overflowWrap: "break-word"
|
||||
width: '80%',
|
||||
overflowWrap: 'break-word',
|
||||
}}
|
||||
>
|
||||
<Typography variant="subtitle1">{colour}</Typography>
|
||||
@@ -247,7 +248,7 @@ const ColourCard = props => {
|
||||
color="secondary"
|
||||
fullWidth
|
||||
label="Nickname"
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
name_input = input;
|
||||
}}
|
||||
defaultValue={name}
|
||||
@@ -273,11 +274,11 @@ const ColourCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const BalanceCardSubSection = props => {
|
||||
const BalanceCardSubSection = (props) => {
|
||||
const classes = useStyles();
|
||||
var cc_unit = props.name;
|
||||
let cc_unit = props.name;
|
||||
if (cc_unit.length > 10) {
|
||||
cc_unit = cc_unit.substring(0, 10) + "...";
|
||||
cc_unit = `${cc_unit.substring(0, 10)}...`;
|
||||
}
|
||||
return (
|
||||
<Grid item xs={12}>
|
||||
@@ -298,45 +299,45 @@ const BalanceCardSubSection = props => {
|
||||
};
|
||||
|
||||
function get_cc_unit(name) {
|
||||
var cc_unit = name;
|
||||
let cc_unit = name;
|
||||
if (cc_unit.length > 10) {
|
||||
cc_unit = cc_unit.substring(0, 10) + "...";
|
||||
cc_unit = `${cc_unit.substring(0, 10)}...`;
|
||||
}
|
||||
return cc_unit;
|
||||
}
|
||||
|
||||
const BalanceCard = props => {
|
||||
var id = props.wallet_id;
|
||||
let name = useSelector(state => state.wallet_state.wallets[id].name);
|
||||
const BalanceCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
let name = useSelector((state) => state.wallet_state.wallets[id].name);
|
||||
if (!name) {
|
||||
name = "";
|
||||
name = '';
|
||||
}
|
||||
const cc_unit = get_cc_unit(name);
|
||||
|
||||
const balance = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_total
|
||||
(state) => state.wallet_state.wallets[id].balance_total,
|
||||
);
|
||||
var balance_spendable = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_spendable
|
||||
const balance_spendable = useSelector(
|
||||
(state) => state.wallet_state.wallets[id].balance_spendable,
|
||||
);
|
||||
const balance_pending = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_pending
|
||||
(state) => state.wallet_state.wallets[id].balance_pending,
|
||||
);
|
||||
const balance_change = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_change
|
||||
(state) => state.wallet_state.wallets[id].balance_change,
|
||||
);
|
||||
const balance_ptotal = balance + balance_pending;
|
||||
|
||||
const balancebox_1 = "<table width='100%'>";
|
||||
const balancebox_2 = "<tr><td align='left'>";
|
||||
const balancebox_3 = "</td><td align='right'>";
|
||||
const balancebox_4 = "</td></tr>";
|
||||
const balancebox_4 = '</td></tr>';
|
||||
const balancebox_row = "<tr height='8px'></tr>";
|
||||
const balancebox_5 = "</td></tr></table>";
|
||||
const balancebox_ptotal = "Pending Total Balance";
|
||||
const balancebox_pending = "Pending Transactions";
|
||||
const balancebox_change = "Pending Change";
|
||||
const balancebox_unit = " " + cc_unit;
|
||||
const balancebox_5 = '</td></tr></table>';
|
||||
const balancebox_ptotal = 'Pending Total Balance';
|
||||
const balancebox_pending = 'Pending Transactions';
|
||||
const balancebox_change = 'Pending Change';
|
||||
const balancebox_unit = ` ${cc_unit}`;
|
||||
const balancebox_hline =
|
||||
"<tr><td colspan='2' style='text-align:center'><hr width='50%'></td></tr>";
|
||||
const balance_ptotal_chia = mojo_to_colouredcoin_string(balance_ptotal);
|
||||
@@ -404,38 +405,38 @@ const BalanceCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const SendCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const SendCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
const classes = useStyles();
|
||||
var address_input = null;
|
||||
var amount_input = null;
|
||||
var fee_input = null;
|
||||
let address_input = null;
|
||||
let amount_input = null;
|
||||
let fee_input = null;
|
||||
const dispatch = useDispatch();
|
||||
let name = useSelector(state => state.wallet_state.wallets[id].name);
|
||||
let name = useSelector((state) => state.wallet_state.wallets[id].name);
|
||||
if (!name) {
|
||||
name = "";
|
||||
name = '';
|
||||
}
|
||||
const cc_unit = get_cc_unit(name);
|
||||
|
||||
const sending_transaction = useSelector(
|
||||
state => state.wallet_state.wallets[id].sending_transaction
|
||||
(state) => state.wallet_state.wallets[id].sending_transaction,
|
||||
);
|
||||
|
||||
const send_transaction_result = useSelector(
|
||||
state => state.wallet_state.wallets[id].send_transaction_result
|
||||
(state) => state.wallet_state.wallets[id].send_transaction_result,
|
||||
);
|
||||
|
||||
const colour = useSelector(state => state.wallet_state.wallets[id].colour);
|
||||
const syncing = useSelector(state => state.wallet_state.status.syncing);
|
||||
const colour = useSelector((state) => state.wallet_state.wallets[id].colour);
|
||||
const syncing = useSelector((state) => state.wallet_state.status.syncing);
|
||||
const result = get_transaction_result(send_transaction_result);
|
||||
let result_message = result.message;
|
||||
let result_class = result.success
|
||||
const result_message = result.message;
|
||||
const result_class = result.success
|
||||
? classes.resultSuccess
|
||||
: classes.resultFailure;
|
||||
|
||||
function farm() {
|
||||
var address = address_input.value;
|
||||
if (address !== "") {
|
||||
const address = address_input.value;
|
||||
if (address !== '') {
|
||||
dispatch(farm_block(address));
|
||||
}
|
||||
}
|
||||
@@ -445,49 +446,49 @@ const SendCard = props => {
|
||||
return;
|
||||
}
|
||||
if (syncing) {
|
||||
dispatch(openDialog("Please finish syncing before making a transaction"));
|
||||
dispatch(openDialog('Please finish syncing before making a transaction'));
|
||||
return;
|
||||
}
|
||||
let address = address_input.value.trim();
|
||||
if (
|
||||
amount_input.value === "" ||
|
||||
amount_input.value === '' ||
|
||||
Number(amount_input.value) === 0 ||
|
||||
!Number(amount_input.value) ||
|
||||
isNaN(Number(amount_input.value))
|
||||
) {
|
||||
dispatch(openDialog("Please enter a valid numeric amount"));
|
||||
dispatch(openDialog('Please enter a valid numeric amount'));
|
||||
return;
|
||||
}
|
||||
if (fee_input.value === "" || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog("Please enter a valid numeric fee"));
|
||||
if (fee_input.value === '' || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog('Please enter a valid numeric fee'));
|
||||
return;
|
||||
}
|
||||
|
||||
const amount = colouredcoin_to_mojo(amount_input.value);
|
||||
const fee = colouredcoin_to_mojo(fee_input.value);
|
||||
|
||||
if (address.includes("chia_addr") || address.includes("colour_desc")) {
|
||||
if (address.includes('chia_addr') || address.includes('colour_desc')) {
|
||||
dispatch(
|
||||
openDialog(
|
||||
"Error: recipient address is not a coloured wallet address. Please enter a coloured wallet address"
|
||||
)
|
||||
'Error: recipient address is not a coloured wallet address. Please enter a coloured wallet address',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (address.substring(0, 14) === "colour_addr://") {
|
||||
if (address.substring(0, 14) === 'colour_addr://') {
|
||||
const colour_id = address.substring(14, 78);
|
||||
address = address.substring(79);
|
||||
if (colour_id !== colour) {
|
||||
dispatch(
|
||||
openDialog(
|
||||
"Error the entered address appears to be for a different colour."
|
||||
)
|
||||
'Error the entered address appears to be for a different colour.',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (address.startsWith("0x") || address.startsWith("0X")) {
|
||||
if (address.startsWith('0x') || address.startsWith('0X')) {
|
||||
address = address.substring(2);
|
||||
}
|
||||
|
||||
@@ -497,15 +498,15 @@ const SendCard = props => {
|
||||
if (fee_value !== 0) {
|
||||
dispatch(
|
||||
openDialog(
|
||||
"Please enter 0 fee. Positive fees not supported yet for coloured coins."
|
||||
)
|
||||
'Please enter 0 fee. Positive fees not supported yet for coloured coins.',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(cc_spend(id, address, amount_value, fee_value));
|
||||
address_input.value = "";
|
||||
amount_input.value = "";
|
||||
address_input.value = '';
|
||||
amount_input.value = '';
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -533,13 +534,13 @@ const SendCard = props => {
|
||||
color="secondary"
|
||||
fullWidth
|
||||
disabled={sending_transaction}
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
address_input = input;
|
||||
}}
|
||||
label="Address"
|
||||
/>
|
||||
</Box>
|
||||
<Box></Box>
|
||||
<Box />
|
||||
</Box>
|
||||
</div>
|
||||
</Grid>
|
||||
@@ -555,10 +556,10 @@ const SendCard = props => {
|
||||
disabled={sending_transaction}
|
||||
margin="normal"
|
||||
className={classes.amountField}
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
amount_input = input;
|
||||
}}
|
||||
label={"Amount (" + cc_unit + ")"}
|
||||
label={`Amount (${cc_unit})`}
|
||||
/>
|
||||
</Box>
|
||||
<Box flexGrow={6}>
|
||||
@@ -569,7 +570,7 @@ const SendCard = props => {
|
||||
color="secondary"
|
||||
margin="normal"
|
||||
disabled={sending_transaction}
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
fee_input = input;
|
||||
}}
|
||||
label="Fee (TXCH)"
|
||||
@@ -587,7 +588,7 @@ const SendCard = props => {
|
||||
className={classes.sendButton}
|
||||
variant="contained"
|
||||
color="primary"
|
||||
style={config.local_test ? {} : { visibility: "hidden" }}
|
||||
style={config.local_test ? {} : { visibility: 'hidden' }}
|
||||
>
|
||||
Farm
|
||||
</Button>
|
||||
@@ -610,8 +611,8 @@ const SendCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const HistoryCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const HistoryCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper className={classes.paper}>
|
||||
@@ -631,26 +632,25 @@ const HistoryCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const TransactionTable = props => {
|
||||
const TransactionTable = (props) => {
|
||||
const classes = useStyles();
|
||||
var id = props.wallet_id;
|
||||
const id = props.wallet_id;
|
||||
const transactions = useSelector(
|
||||
state => state.wallet_state.wallets[id].transactions
|
||||
(state) => state.wallet_state.wallets[id].transactions,
|
||||
);
|
||||
|
||||
if (transactions.length === 0) {
|
||||
return <div style={{ margin: "30px" }}>No previous transactions</div>;
|
||||
return <div style={{ margin: '30px' }}>No previous transactions</div>;
|
||||
}
|
||||
|
||||
const incoming_string = incoming => {
|
||||
const incoming_string = (incoming) => {
|
||||
if (incoming) {
|
||||
return "Incoming";
|
||||
} else {
|
||||
return "Outgoing";
|
||||
return 'Incoming';
|
||||
}
|
||||
return 'Outgoing';
|
||||
};
|
||||
const confirmed_to_string = confirmed => {
|
||||
return confirmed ? "Confirmed" : "Pending";
|
||||
const confirmed_to_string = (confirmed) => {
|
||||
return confirmed ? 'Confirmed' : 'Pending';
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -667,7 +667,7 @@ const TransactionTable = props => {
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody className={classes.tableBody}>
|
||||
{transactions.map(tx => (
|
||||
{transactions.map((tx) => (
|
||||
<TableRow
|
||||
className={classes.row}
|
||||
key={tx.to_address + tx.created_at_time + tx.amount}
|
||||
@@ -676,7 +676,7 @@ const TransactionTable = props => {
|
||||
{incoming_string(tx.incoming)}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
style={{ maxWidth: "150px" }}
|
||||
style={{ maxWidth: '150px' }}
|
||||
className={classes.cell_short}
|
||||
>
|
||||
{tx.to_address}
|
||||
@@ -701,9 +701,11 @@ const TransactionTable = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const AddressCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const address = useSelector(state => state.wallet_state.wallets[id].address);
|
||||
const AddressCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
const address = useSelector(
|
||||
(state) => state.wallet_state.wallets[id].address,
|
||||
);
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
@@ -754,7 +756,7 @@ const AddressCard = props => {
|
||||
<Grid item xs={12}>
|
||||
<div className={classes.cardSubSection}>
|
||||
<Box display="flex">
|
||||
<Box flexGrow={1}></Box>
|
||||
<Box flexGrow={1} />
|
||||
<Box>
|
||||
<Button
|
||||
onClick={newAddress}
|
||||
@@ -773,22 +775,22 @@ const AddressCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const ColouredWallet = props => {
|
||||
const ColouredWallet = (props) => {
|
||||
const classes = useStyles();
|
||||
const id = useSelector(state => state.wallet_menu.id);
|
||||
const name = useSelector(state => state.wallet_state.wallets[id].name);
|
||||
const wallets = useSelector(state => state.wallet_state.wallets);
|
||||
const id = useSelector((state) => state.wallet_menu.id);
|
||||
const name = useSelector((state) => state.wallet_state.wallets[id].name);
|
||||
const wallets = useSelector((state) => state.wallet_state.wallets);
|
||||
|
||||
return wallets.length > props.wallet_id ? (
|
||||
<Grid className={classes.walletContainer} item xs={12}>
|
||||
<ColourCard wallet_id={id} name={name}></ColourCard>
|
||||
<BalanceCard wallet_id={id}></BalanceCard>
|
||||
<SendCard wallet_id={id}></SendCard>
|
||||
<AddressCard wallet_id={id}></AddressCard>
|
||||
<HistoryCard wallet_id={id}></HistoryCard>
|
||||
<ColourCard wallet_id={id} name={name} />
|
||||
<BalanceCard wallet_id={id} />
|
||||
<SendCard wallet_id={id} />
|
||||
<AddressCard wallet_id={id} />
|
||||
<HistoryCard wallet_id={id} />
|
||||
</Grid>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,78 +1,78 @@
|
||||
import React from "react";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import { Paper, TableRow } from "@material-ui/core";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Table from "@material-ui/core/Table";
|
||||
import TableBody from "@material-ui/core/TableBody";
|
||||
import TableCell from "@material-ui/core/TableCell";
|
||||
import TableContainer from "@material-ui/core/TableContainer";
|
||||
import TableHead from "@material-ui/core/TableHead";
|
||||
import DeleteForeverIcon from "@material-ui/icons/DeleteForever";
|
||||
import { unix_to_short_date } from "../util/utils";
|
||||
import { service_connection_types } from "../util/service_names";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import SettingsInputAntennaIcon from "@material-ui/icons/SettingsInputAntenna";
|
||||
import React from 'react';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import { Paper, TableRow } from '@material-ui/core';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Table from '@material-ui/core/Table';
|
||||
import TableBody from '@material-ui/core/TableBody';
|
||||
import TableCell from '@material-ui/core/TableCell';
|
||||
import TableContainer from '@material-ui/core/TableContainer';
|
||||
import TableHead from '@material-ui/core/TableHead';
|
||||
import DeleteForeverIcon from '@material-ui/icons/DeleteForever';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import SettingsInputAntennaIcon from '@material-ui/icons/SettingsInputAntenna';
|
||||
import { unix_to_short_date } from '../util/utils';
|
||||
import { service_connection_types } from '../util/service_names';
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
form: {
|
||||
margin: theme.spacing(1)
|
||||
margin: theme.spacing(1),
|
||||
},
|
||||
clickable: {
|
||||
cursor: "pointer"
|
||||
cursor: 'pointer',
|
||||
},
|
||||
error: {
|
||||
color: "red"
|
||||
color: 'red',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(0),
|
||||
paddingBottom: theme.spacing(0),
|
||||
paddingRight: theme.spacing(0)
|
||||
paddingRight: theme.spacing(0),
|
||||
},
|
||||
balancePaper: {
|
||||
marginTop: theme.spacing(2),
|
||||
padding: theme.spacing(2)
|
||||
padding: theme.spacing(2),
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(1),
|
||||
paddingTop: theme.spacing(1),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
table: {
|
||||
minWidth: 650
|
||||
minWidth: 650,
|
||||
},
|
||||
connect: {
|
||||
marginLeft: theme.spacing(1)
|
||||
}
|
||||
marginLeft: theme.spacing(1),
|
||||
},
|
||||
}));
|
||||
|
||||
const Connections = props => {
|
||||
const Connections = (props) => {
|
||||
const classes = useStyles();
|
||||
|
||||
const connections = props.connections;
|
||||
const connectionError = props.connectionError;
|
||||
const { connections } = props;
|
||||
const { connectionError } = props;
|
||||
const connectionTime = props.connectionTime ? props.connectionTime : false;
|
||||
|
||||
const [host, setHost] = React.useState("");
|
||||
const handleChangeHost = event => {
|
||||
const [host, setHost] = React.useState('');
|
||||
const handleChangeHost = (event) => {
|
||||
setHost(event.target.value);
|
||||
};
|
||||
|
||||
const [port, setPort] = React.useState("");
|
||||
const handleChangePort = event => {
|
||||
const [port, setPort] = React.useState('');
|
||||
const handleChangePort = (event) => {
|
||||
setPort(event.target.value);
|
||||
};
|
||||
|
||||
const deleteConnection = node_id => {
|
||||
const deleteConnection = (node_id) => {
|
||||
return () => {
|
||||
props.closeConnection(node_id);
|
||||
};
|
||||
};
|
||||
const connectToPeer = () => {
|
||||
props.openConnection(host, port);
|
||||
setHost("");
|
||||
setPort("");
|
||||
setHost('');
|
||||
setPort('');
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -107,7 +107,7 @@ const Connections = props => {
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{connections.map(item => (
|
||||
{connections.map((item) => (
|
||||
<TableRow key={item.node_id}>
|
||||
<TableCell component="th" scope="row">
|
||||
{item.node_id.substring(0, 10)}...
|
||||
@@ -140,7 +140,7 @@ const Connections = props => {
|
||||
onClick={deleteConnection(item.node_id)}
|
||||
align="right"
|
||||
>
|
||||
<DeleteForeverIcon></DeleteForeverIcon>
|
||||
<DeleteForeverIcon />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
@@ -165,8 +165,8 @@ const Connections = props => {
|
||||
Connect
|
||||
</Button>
|
||||
</form>
|
||||
{connectionError === "" ? (
|
||||
""
|
||||
{connectionError === '' ? (
|
||||
''
|
||||
) : (
|
||||
<p className={classes.error}>{connectionError}</p>
|
||||
)}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import React, { Component } from "react";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import { withTheme, withStyles, makeStyles } from "@material-ui/styles";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { genereate_mnemonics } from "../modules/message";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import React, { Component } from 'react';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import { withTheme, withStyles, makeStyles } from '@material-ui/styles';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { genereate_mnemonics } from '../modules/message';
|
||||
|
||||
// function Copyright() {
|
||||
// return (
|
||||
@@ -26,94 +26,94 @@ import { withRouter } from "react-router-dom";
|
||||
|
||||
const CssTextField = withStyles({
|
||||
root: {
|
||||
"& MuiFormLabel-root": {
|
||||
color: "#e3f2fd"
|
||||
'& MuiFormLabel-root': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& label.Mui-focused": {
|
||||
color: "#e3f2fd"
|
||||
'& label.Mui-focused': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& label.Mui-required": {
|
||||
color: "#e3f2fd"
|
||||
'& label.Mui-required': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& label.Mui-disabled": {
|
||||
color: "#e3f2fd"
|
||||
'& label.Mui-disabled': {
|
||||
color: '#e3f2fd',
|
||||
},
|
||||
"& .MuiInput-underline:after": {
|
||||
borderBottomColor: "#e3f2fd"
|
||||
'& .MuiInput-underline:after': {
|
||||
borderBottomColor: '#e3f2fd',
|
||||
},
|
||||
"& .MuiOutlinedInput-root": {
|
||||
"& fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
'& .MuiOutlinedInput-root': {
|
||||
'& fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
"&:hover fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
'&:hover fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
"&.Mui-focused fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
'&.Mui-focused fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
'&.Mui-disabled fieldset': {
|
||||
borderColor: '#e3f2fd',
|
||||
},
|
||||
"&.Mui-disabled fieldset": {
|
||||
borderColor: "#e3f2fd"
|
||||
}
|
||||
},
|
||||
color: "#ffffff",
|
||||
"& .MuiOutlinedInput-input": {
|
||||
color: "#ffffff"
|
||||
}
|
||||
}
|
||||
color: '#ffffff',
|
||||
'& .MuiOutlinedInput-input': {
|
||||
color: '#ffffff',
|
||||
},
|
||||
},
|
||||
})(TextField);
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
background: "linear-gradient(45deg, #142229 30%, #112240 90%)",
|
||||
height: "100%"
|
||||
background: 'linear-gradient(45deg, #142229 30%, #112240 90%)',
|
||||
height: '100%',
|
||||
},
|
||||
paper: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center"
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
},
|
||||
avatar: {
|
||||
marginTop: theme.spacing(8),
|
||||
backgroundColor: theme.palette.secondary.main
|
||||
backgroundColor: theme.palette.secondary.main,
|
||||
},
|
||||
form: {
|
||||
width: "100%", // Fix IE 11 issue.
|
||||
marginTop: theme.spacing(5)
|
||||
width: '100%', // Fix IE 11 issue.
|
||||
marginTop: theme.spacing(5),
|
||||
},
|
||||
textField: {
|
||||
borderColor: "#ffffff"
|
||||
borderColor: '#ffffff',
|
||||
},
|
||||
submit: {
|
||||
marginTop: theme.spacing(8),
|
||||
marginBottom: theme.spacing(3)
|
||||
marginBottom: theme.spacing(3),
|
||||
},
|
||||
grid: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
paddingTop: theme.spacing(5)
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
paddingTop: theme.spacing(5),
|
||||
},
|
||||
grid_item: {
|
||||
paddingTop: 10,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
backgroundColor: "#444444",
|
||||
color: "#ffffff",
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#444444',
|
||||
color: '#ffffff',
|
||||
height: 50,
|
||||
verticalAlign: "middle"
|
||||
verticalAlign: 'middle',
|
||||
},
|
||||
title: {
|
||||
color: "#ffffff",
|
||||
color: '#ffffff',
|
||||
marginTop: theme.spacing(4),
|
||||
marginBottom: theme.spacing(8)
|
||||
marginBottom: theme.spacing(8),
|
||||
},
|
||||
navigator: {
|
||||
color: "#ffffff",
|
||||
color: '#ffffff',
|
||||
marginTop: theme.spacing(4),
|
||||
marginLeft: theme.spacing(4),
|
||||
fontSize: 35
|
||||
}
|
||||
fontSize: 35,
|
||||
},
|
||||
}));
|
||||
|
||||
class MnemonicLabel extends Component {
|
||||
@@ -139,7 +139,7 @@ class MnemonicLabel extends Component {
|
||||
}
|
||||
|
||||
const UIPart = () => {
|
||||
const words = useSelector(state => state.wallet_state.mnemonic);
|
||||
const words = useSelector((state) => state.wallet_state.mnemonic);
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
@@ -174,7 +174,7 @@ const UIPart = () => {
|
||||
};
|
||||
|
||||
const CreateMnemonics = () => {
|
||||
var get_mnemonics = genereate_mnemonics();
|
||||
const get_mnemonics = genereate_mnemonics();
|
||||
const dispatch = useDispatch();
|
||||
dispatch(get_mnemonics);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import {
|
||||
makeStyles,
|
||||
Typography,
|
||||
@@ -6,12 +6,15 @@ import {
|
||||
Grid,
|
||||
List,
|
||||
Button,
|
||||
Box
|
||||
} from "@material-ui/core";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import ListItemIcon from "@material-ui/core/ListItemIcon";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
Box,
|
||||
} from '@material-ui/core';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemIcon from '@material-ui/core/ListItemIcon';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import InvertColorsIcon from '@material-ui/icons/InvertColors';
|
||||
import {
|
||||
changeCreateWallet,
|
||||
ALL_OPTIONS,
|
||||
@@ -20,62 +23,59 @@ import {
|
||||
CREATE_NEW_CC,
|
||||
CREATE_RL_WALLET_OPTIONS,
|
||||
CREATE_RL_ADMIN,
|
||||
CREATE_RL_USER
|
||||
} from "../modules/createWallet";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { CreateNewCCWallet } from "./createNewColouredCoin";
|
||||
import { CreateExistingCCWallet } from "./createExistingColouredCoin";
|
||||
import { CreateRLAdminWallet } from "./createRLAdmin";
|
||||
import { CreateRLUserWallet } from "./createRLUser";
|
||||
import InvertColorsIcon from "@material-ui/icons/InvertColors";
|
||||
CREATE_RL_USER,
|
||||
} from '../modules/createWallet';
|
||||
import { CreateNewCCWallet } from './createNewColouredCoin';
|
||||
import { CreateExistingCCWallet } from './createExistingColouredCoin';
|
||||
import { CreateRLAdminWallet } from './createRLAdmin';
|
||||
import { CreateRLUserWallet } from './createRLUser';
|
||||
|
||||
export const useStyles = makeStyles(theme => ({
|
||||
export const useStyles = makeStyles((theme) => ({
|
||||
walletContainer: {
|
||||
marginBottom: theme.spacing(5)
|
||||
marginBottom: theme.spacing(5),
|
||||
},
|
||||
root: {
|
||||
display: "flex",
|
||||
paddingLeft: "0px",
|
||||
color: "#000000"
|
||||
display: 'flex',
|
||||
paddingLeft: '0px',
|
||||
color: '#000000',
|
||||
},
|
||||
appBarSpacer: theme.mixins.toolbar,
|
||||
content: {
|
||||
flexGrow: 1,
|
||||
height: "100vh",
|
||||
overflow: "auto"
|
||||
height: '100vh',
|
||||
overflow: 'auto',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(0),
|
||||
paddingBottom: theme.spacing(0),
|
||||
paddingRight: theme.spacing(0)
|
||||
paddingRight: theme.spacing(0),
|
||||
},
|
||||
paper: {
|
||||
marginTop: theme.spacing(2),
|
||||
padding: theme.spacing(2),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column",
|
||||
minWidth: "100%"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
minWidth: '100%',
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(1),
|
||||
paddingTop: theme.spacing(1),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
title: {
|
||||
paddingTop: 6
|
||||
paddingTop: 6,
|
||||
},
|
||||
sendButton: {
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(2),
|
||||
width: 150,
|
||||
height: 50
|
||||
height: 50,
|
||||
},
|
||||
backdrop: {
|
||||
zIndex: 3000,
|
||||
color: "#fff"
|
||||
}
|
||||
color: '#fff',
|
||||
},
|
||||
}));
|
||||
|
||||
export const MainWalletList = () => {
|
||||
@@ -226,22 +226,28 @@ export const RLListItems = () => {
|
||||
};
|
||||
|
||||
const CreateViewSwitch = () => {
|
||||
const view = useSelector(state => state.create_options.view);
|
||||
const view = useSelector((state) => state.create_options.view);
|
||||
|
||||
if (view === ALL_OPTIONS) {
|
||||
return <MainWalletList></MainWalletList>;
|
||||
} else if (view === CREATE_CC_WALLET_OPTIONS) {
|
||||
return <CCListItems></CCListItems>;
|
||||
} else if (view === CREATE_NEW_CC) {
|
||||
return <CreateNewCCWallet></CreateNewCCWallet>;
|
||||
} else if (view === CREATE_EXISTING_CC) {
|
||||
return <CreateExistingCCWallet></CreateExistingCCWallet>;
|
||||
} else if (view === CREATE_RL_WALLET_OPTIONS) {
|
||||
return <RLListItems></RLListItems>;
|
||||
} else if (view === CREATE_RL_ADMIN) {
|
||||
return <CreateRLAdminWallet></CreateRLAdminWallet>;
|
||||
} else if (view === CREATE_RL_USER) {
|
||||
return <CreateRLUserWallet></CreateRLUserWallet>;
|
||||
return <MainWalletList />;
|
||||
}
|
||||
if (view === CREATE_CC_WALLET_OPTIONS) {
|
||||
return <CCListItems />;
|
||||
}
|
||||
if (view === CREATE_NEW_CC) {
|
||||
return <CreateNewCCWallet />;
|
||||
}
|
||||
if (view === CREATE_EXISTING_CC) {
|
||||
return <CreateExistingCCWallet />;
|
||||
}
|
||||
if (view === CREATE_RL_WALLET_OPTIONS) {
|
||||
return <RLListItems />;
|
||||
}
|
||||
if (view === CREATE_RL_ADMIN) {
|
||||
return <CreateRLAdminWallet />;
|
||||
}
|
||||
if (view === CREATE_RL_USER) {
|
||||
return <CreateRLUserWallet />;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -251,7 +257,7 @@ export const CreateWalletView = () => {
|
||||
return (
|
||||
<Grid className={classes.walletContainer} item xs={12}>
|
||||
<Paper className={classes.paper}>
|
||||
<CreateViewSwitch></CreateViewSwitch>
|
||||
<CreateViewSwitch />
|
||||
</Paper>
|
||||
</Grid>
|
||||
);
|
||||
|
||||
@@ -1,150 +1,154 @@
|
||||
import React from "react";
|
||||
import clsx from "clsx";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
import Drawer from "@material-ui/core/Drawer";
|
||||
import AppBar from "@material-ui/core/AppBar";
|
||||
import Toolbar from "@material-ui/core/Toolbar";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Divider from "@material-ui/core/Divider";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import logo from "../assets/img/chia_logo.svg"; // Tell webpack this JS file uses this image
|
||||
import Wallets from "./Wallets";
|
||||
import { SideBar } from "./sidebar";
|
||||
import { useSelector } from "react-redux";
|
||||
import Plotter from "./Plotter";
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import Drawer from '@material-ui/core/Drawer';
|
||||
import AppBar from '@material-ui/core/AppBar';
|
||||
import Toolbar from '@material-ui/core/Toolbar';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Divider from '@material-ui/core/Divider';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import { useSelector } from 'react-redux';
|
||||
import logo from '../assets/img/chia_logo.svg'; // Tell webpack this JS file uses this image
|
||||
import Wallets from './Wallets';
|
||||
import { SideBar } from './sidebar';
|
||||
import Plotter from './Plotter';
|
||||
import {
|
||||
presentWallet,
|
||||
presentNode,
|
||||
presentFarmer,
|
||||
presentTrading,
|
||||
presentPlotter
|
||||
} from "../modules/mainMenu";
|
||||
import FullNode from "./FullNode";
|
||||
import Farmer from "./Farmer";
|
||||
import { TradeManger } from "./trading/TradeManager";
|
||||
import { CreateBackup } from "./backup/createBackup";
|
||||
presentPlotter,
|
||||
} from '../modules/mainMenu';
|
||||
import FullNode from './FullNode';
|
||||
import Farmer from './Farmer';
|
||||
import { TradeManger } from './trading/TradeManager';
|
||||
import { CreateBackup } from './backup/createBackup';
|
||||
|
||||
const drawerWidth = 100;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
display: "flex"
|
||||
display: 'flex',
|
||||
},
|
||||
toolbar: {
|
||||
paddingRight: 24 // keep right padding when drawer closed
|
||||
paddingRight: 24, // keep right padding when drawer closed
|
||||
},
|
||||
toolbarIcon: {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
padding: "0 8px",
|
||||
...theme.mixins.toolbar
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-end',
|
||||
padding: '0 8px',
|
||||
...theme.mixins.toolbar,
|
||||
},
|
||||
appBar: {
|
||||
zIndex: theme.zIndex.drawer + 1,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
transition: theme.transitions.create(['width', 'margin'], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
})
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
},
|
||||
appBarShift: {
|
||||
marginLeft: drawerWidth,
|
||||
width: `calc(100% - ${drawerWidth}px)`,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
transition: theme.transitions.create(['width', 'margin'], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
appBarSpacer: theme.mixins.toolbar,
|
||||
content: {
|
||||
flexGrow: 1,
|
||||
height: "100vh",
|
||||
overflowX: "hidden",
|
||||
overflowY: "scroll"
|
||||
height: '100vh',
|
||||
overflowX: 'hidden',
|
||||
overflowY: 'scroll',
|
||||
},
|
||||
container: {
|
||||
padding: "0px",
|
||||
marginLeft: "0px"
|
||||
padding: '0px',
|
||||
marginLeft: '0px',
|
||||
},
|
||||
paper: {
|
||||
padding: theme.spacing(2),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
fixedHeight: {
|
||||
height: 240
|
||||
height: 240,
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
logo: {
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(2),
|
||||
marginLeft: theme.spacing(2),
|
||||
marginRight: theme.spacing(2),
|
||||
width: "62px"
|
||||
}
|
||||
width: '62px',
|
||||
},
|
||||
}));
|
||||
|
||||
const ComopnentSwitch = () => {
|
||||
const toPresent = useSelector(state => state.main_menu.view);
|
||||
const toPresent = useSelector((state) => state.main_menu.view);
|
||||
|
||||
if (toPresent === presentWallet) {
|
||||
return <Wallets></Wallets>;
|
||||
} else if (toPresent === presentNode) {
|
||||
return <FullNode></FullNode>;
|
||||
} else if (toPresent === presentFarmer) {
|
||||
return <Farmer></Farmer>;
|
||||
} else if (toPresent === presentPlotter) {
|
||||
return <Plotter></Plotter>;
|
||||
} else if (toPresent === presentTrading) {
|
||||
return <TradeManger></TradeManger>;
|
||||
return <Wallets />;
|
||||
}
|
||||
return <div></div>;
|
||||
if (toPresent === presentNode) {
|
||||
return <FullNode />;
|
||||
}
|
||||
if (toPresent === presentFarmer) {
|
||||
return <Farmer />;
|
||||
}
|
||||
if (toPresent === presentPlotter) {
|
||||
return <Plotter />;
|
||||
}
|
||||
if (toPresent === presentTrading) {
|
||||
return <TradeManger />;
|
||||
}
|
||||
return <div />;
|
||||
};
|
||||
|
||||
export default function Dashboard() {
|
||||
const classes = useStyles();
|
||||
const [open] = React.useState(true);
|
||||
const toPresent = useSelector(state => state.main_menu.view);
|
||||
const toPresent = useSelector((state) => state.main_menu.view);
|
||||
let title;
|
||||
if (toPresent === presentWallet) {
|
||||
title = "Wallets";
|
||||
title = 'Wallets';
|
||||
} else if (toPresent === presentNode) {
|
||||
title = "Full Node";
|
||||
title = 'Full Node';
|
||||
} else if (toPresent === presentFarmer) {
|
||||
title = "Farming";
|
||||
title = 'Farming';
|
||||
} else if (toPresent === presentPlotter) {
|
||||
title = "Plotting";
|
||||
title = 'Plotting';
|
||||
} else if (toPresent === presentTrading) {
|
||||
title = "Trading";
|
||||
title = 'Trading';
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -169,21 +173,21 @@ export default function Dashboard() {
|
||||
<Drawer
|
||||
variant="permanent"
|
||||
classes={{
|
||||
paper: clsx(classes.drawerPaper)
|
||||
paper: clsx(classes.drawerPaper),
|
||||
}}
|
||||
>
|
||||
<div className={classes.toolbarIcon}>
|
||||
<img className={classes.logo} src={logo} alt="Logo" />
|
||||
</div>
|
||||
<Divider />
|
||||
<SideBar></SideBar>
|
||||
<SideBar />
|
||||
</Drawer>
|
||||
<main className={classes.content}>
|
||||
<div className={classes.appBarSpacer} />
|
||||
<Container maxWidth="lg" className={classes.container}>
|
||||
<ComopnentSwitch></ComopnentSwitch>
|
||||
<ComopnentSwitch />
|
||||
</Container>
|
||||
<CreateBackup></CreateBackup>
|
||||
<CreateBackup />
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
|
||||
+141
-142
@@ -1,112 +1,112 @@
|
||||
import React, { useEffect, useState, useCallback } from "react";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { makeStyles, withStyles } from "@material-ui/core/styles";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Box from "@material-ui/core/Box";
|
||||
import React, { useEffect, useState, useCallback } from 'react';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { makeStyles, withStyles } from '@material-ui/core/styles';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import {
|
||||
Paper,
|
||||
TableRow,
|
||||
List,
|
||||
ListItem,
|
||||
ListItemText,
|
||||
Tooltip
|
||||
} from "@material-ui/core";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Table from "@material-ui/core/Table";
|
||||
import TableBody from "@material-ui/core/TableBody";
|
||||
import TableCell from "@material-ui/core/TableCell";
|
||||
import TableContainer from "@material-ui/core/TableContainer";
|
||||
import TableHead from "@material-ui/core/TableHead";
|
||||
import DeleteForeverIcon from "@material-ui/icons/DeleteForever";
|
||||
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import Dialog from "@material-ui/core/Dialog";
|
||||
import DialogActions from "@material-ui/core/DialogActions";
|
||||
import DialogContent from "@material-ui/core/DialogContent";
|
||||
import DialogContentText from "@material-ui/core/DialogContentText";
|
||||
import DialogTitle from "@material-ui/core/DialogTitle";
|
||||
Tooltip,
|
||||
} from '@material-ui/core';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Table from '@material-ui/core/Table';
|
||||
import TableBody from '@material-ui/core/TableBody';
|
||||
import TableCell from '@material-ui/core/TableCell';
|
||||
import TableContainer from '@material-ui/core/TableContainer';
|
||||
import TableHead from '@material-ui/core/TableHead';
|
||||
import DeleteForeverIcon from '@material-ui/icons/DeleteForever';
|
||||
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
import Dialog from '@material-ui/core/Dialog';
|
||||
import DialogActions from '@material-ui/core/DialogActions';
|
||||
import DialogContent from '@material-ui/core/DialogContent';
|
||||
import DialogContentText from '@material-ui/core/DialogContentText';
|
||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||
|
||||
import { closeConnection, openConnection } from "../modules/farmerMessages";
|
||||
import TablePagination from '@material-ui/core/TablePagination';
|
||||
import RefreshIcon from '@material-ui/icons/Refresh';
|
||||
import HelpIcon from '@material-ui/icons/Help';
|
||||
import { closeConnection, openConnection } from '../modules/farmerMessages';
|
||||
import {
|
||||
refreshPlots,
|
||||
deletePlot,
|
||||
getPlotDirectories
|
||||
} from "../modules/harvesterMessages";
|
||||
getPlotDirectories,
|
||||
} from '../modules/harvesterMessages';
|
||||
|
||||
import TablePagination from "@material-ui/core/TablePagination";
|
||||
import RefreshIcon from "@material-ui/icons/Refresh";
|
||||
import Connections from "./Connections";
|
||||
import Connections from './Connections';
|
||||
|
||||
import { big_int_to_array, arr_to_hex, sha256 } from "../util/utils";
|
||||
import { mojo_to_chia_string } from "../util/chia";
|
||||
import HelpIcon from "@material-ui/icons/Help";
|
||||
import { clearSend } from "../modules/message";
|
||||
import AddPlotDialog from "./AddPlotDialog";
|
||||
import { big_int_to_array, arr_to_hex, sha256 } from '../util/utils';
|
||||
import { mojo_to_chia_string } from '../util/chia';
|
||||
import { clearSend } from '../modules/message';
|
||||
import AddPlotDialog from './AddPlotDialog';
|
||||
|
||||
/* global BigInt */
|
||||
|
||||
const drawerWidth = 180;
|
||||
|
||||
const styles = theme => ({
|
||||
const styles = (theme) => ({
|
||||
root: {
|
||||
display: "flex",
|
||||
paddingLeft: "0px"
|
||||
display: 'flex',
|
||||
paddingLeft: '0px',
|
||||
},
|
||||
tabs: {
|
||||
flexGrow: 1,
|
||||
marginTop: 40
|
||||
marginTop: 40,
|
||||
},
|
||||
clickable: {
|
||||
cursor: "pointer"
|
||||
cursor: 'pointer',
|
||||
},
|
||||
refreshButton: {
|
||||
marginLeft: "20px"
|
||||
marginLeft: '20px',
|
||||
},
|
||||
content: {
|
||||
height: "calc(100vh - 64px)",
|
||||
overflowX: "hidden",
|
||||
padding: "0px"
|
||||
height: 'calc(100vh - 64px)',
|
||||
overflowX: 'hidden',
|
||||
padding: '0px',
|
||||
},
|
||||
noPadding: {
|
||||
padding: "0px"
|
||||
padding: '0px',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(3),
|
||||
paddingRight: theme.spacing(6),
|
||||
paddingLeft: theme.spacing(6),
|
||||
paddingBottom: theme.spacing(3)
|
||||
paddingBottom: theme.spacing(3),
|
||||
},
|
||||
balancePaper: {
|
||||
padding: theme.spacing(2),
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(1),
|
||||
paddingTop: theme.spacing(1),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
cardSubSection: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingTop: theme.spacing(1)
|
||||
paddingTop: theme.spacing(1),
|
||||
},
|
||||
table: {
|
||||
minWidth: 650
|
||||
minWidth: 650,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
addPlotButton: {
|
||||
marginLeft: theme.spacing(2)
|
||||
}
|
||||
marginLeft: theme.spacing(2),
|
||||
},
|
||||
});
|
||||
|
||||
const useStyles = makeStyles(styles);
|
||||
@@ -116,22 +116,22 @@ const getStatusItems = (
|
||||
farmerSpace,
|
||||
totalChia,
|
||||
biggestHeight,
|
||||
totalNetworkSpace
|
||||
totalNetworkSpace,
|
||||
) => {
|
||||
var status_items = [];
|
||||
const status_items = [];
|
||||
|
||||
if (connected) {
|
||||
const item = {
|
||||
label: "Connection Status ",
|
||||
value: "Connected",
|
||||
colour: "green"
|
||||
label: 'Connection Status ',
|
||||
value: 'Connected',
|
||||
colour: 'green',
|
||||
};
|
||||
status_items.push(item);
|
||||
} else {
|
||||
const item = {
|
||||
label: "Connection Status ",
|
||||
value: "Not connected",
|
||||
colour: "red"
|
||||
label: 'Connection Status ',
|
||||
value: 'Not connected',
|
||||
colour: 'red',
|
||||
};
|
||||
status_items.push(item);
|
||||
}
|
||||
@@ -139,42 +139,41 @@ const getStatusItems = (
|
||||
const totalHours = 5.0 / proportion / 60;
|
||||
|
||||
status_items.push({
|
||||
label: "Total size of local plots",
|
||||
value: Math.floor(farmerSpace / Math.pow(1024, 3)).toString() + " GiB",
|
||||
tooltip:
|
||||
"You have " +
|
||||
(proportion * 100).toFixed(6) +
|
||||
"% of the space on the network, so farming a block will take " +
|
||||
totalHours.toFixed(3) +
|
||||
" hours in expectation"
|
||||
label: 'Total size of local plots',
|
||||
value: `${Math.floor(farmerSpace / Math.pow(1024, 3)).toString()} GiB`,
|
||||
tooltip: `You have ${(proportion * 100).toFixed(
|
||||
6,
|
||||
)}% of the space on the network, so farming a block will take ${totalHours.toFixed(
|
||||
3,
|
||||
)} hours in expectation`,
|
||||
});
|
||||
|
||||
status_items.push({
|
||||
label: "Total chia farmed",
|
||||
value: mojo_to_chia_string(totalChia)
|
||||
label: 'Total chia farmed',
|
||||
value: mojo_to_chia_string(totalChia),
|
||||
});
|
||||
if (biggestHeight === 0) {
|
||||
status_items.push({
|
||||
label: "Last height farmed",
|
||||
value: "No blocks farmed yet"
|
||||
label: 'Last height farmed',
|
||||
value: 'No blocks farmed yet',
|
||||
});
|
||||
} else {
|
||||
status_items.push({
|
||||
label: "Last height farmed",
|
||||
value: biggestHeight
|
||||
label: 'Last height farmed',
|
||||
value: biggestHeight,
|
||||
});
|
||||
}
|
||||
|
||||
return status_items;
|
||||
};
|
||||
|
||||
const StatusCell = props => {
|
||||
const StatusCell = (props) => {
|
||||
const classes = useStyles();
|
||||
const item = props.item;
|
||||
const label = item.label;
|
||||
const value = item.value;
|
||||
const colour = item.colour;
|
||||
const tooltip = item.tooltip;
|
||||
const { item } = props;
|
||||
const { label } = item;
|
||||
const { value } = item;
|
||||
const { colour } = item;
|
||||
const { tooltip } = item;
|
||||
return (
|
||||
<Grid item xs={6}>
|
||||
<div className={classes.cardSubSection}>
|
||||
@@ -188,10 +187,10 @@ const StatusCell = props => {
|
||||
</Typography>
|
||||
{tooltip ? (
|
||||
<Tooltip title={tooltip}>
|
||||
<HelpIcon style={{ color: "#c8c8c8", fontSize: 12 }}></HelpIcon>
|
||||
<HelpIcon style={{ color: '#c8c8c8', fontSize: 12 }} />
|
||||
</Tooltip>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
)}
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -200,24 +199,24 @@ const StatusCell = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const FarmerStatus = props => {
|
||||
const plots = useSelector(state => state.farming_state.harvester.plots);
|
||||
const FarmerStatus = (props) => {
|
||||
const plots = useSelector((state) => state.farming_state.harvester.plots);
|
||||
const totalNetworkSpace = useSelector(
|
||||
state => state.full_node_state.blockchain_state.space
|
||||
(state) => state.full_node_state.blockchain_state.space,
|
||||
);
|
||||
|
||||
var farmerSpace = 0;
|
||||
let farmerSpace = 0;
|
||||
if (plots !== undefined) {
|
||||
farmerSpace = plots.map(p => p.file_size).reduce((a, b) => a + b, 0);
|
||||
farmerSpace = plots.map((p) => p.file_size).reduce((a, b) => a + b, 0);
|
||||
}
|
||||
|
||||
const connected = useSelector(state => state.daemon_state.farmer_connected);
|
||||
const connected = useSelector((state) => state.daemon_state.farmer_connected);
|
||||
const statusItems = getStatusItems(
|
||||
connected,
|
||||
farmerSpace,
|
||||
props.totalChiaFarmed,
|
||||
props.biggestHeight,
|
||||
totalNetworkSpace
|
||||
totalNetworkSpace,
|
||||
);
|
||||
|
||||
const classes = useStyles();
|
||||
@@ -231,18 +230,18 @@ const FarmerStatus = props => {
|
||||
</Typography>
|
||||
</div>
|
||||
</Grid>
|
||||
{statusItems.map(item => (
|
||||
<StatusCell item={item} key={item.label}></StatusCell>
|
||||
{statusItems.map((item) => (
|
||||
<StatusCell item={item} key={item.label} />
|
||||
))}
|
||||
</Grid>
|
||||
</Paper>
|
||||
);
|
||||
};
|
||||
|
||||
const Challenges = props => {
|
||||
const Challenges = (props) => {
|
||||
const classes = useStyles();
|
||||
var latest_challenges = useSelector(
|
||||
state => state.farming_state.farmer.latest_challenges
|
||||
let latest_challenges = useSelector(
|
||||
(state) => state.farming_state.farmer.latest_challenges,
|
||||
);
|
||||
|
||||
if (!latest_challenges) {
|
||||
@@ -272,7 +271,7 @@ const Challenges = props => {
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{latest_challenges.map(item => (
|
||||
{latest_challenges.map((item) => (
|
||||
<TableRow key={item.challenge}>
|
||||
<TableCell component="th" scope="row">
|
||||
{item.challenge.substring(0, 10)}...
|
||||
@@ -281,10 +280,10 @@ const Challenges = props => {
|
||||
<TableCell align="right">{item.estimates.length}</TableCell>
|
||||
<TableCell align="right">
|
||||
{item.estimates.length > 0
|
||||
? Math.floor(
|
||||
Math.min.apply(Math, item.estimates) / 60
|
||||
).toString() + " minutes"
|
||||
: ""}
|
||||
? `${Math.floor(
|
||||
Math.min.apply(Math, item.estimates) / 60,
|
||||
).toString()} minutes`
|
||||
: ''}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
@@ -297,28 +296,28 @@ const Challenges = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const Plots = props => {
|
||||
const Plots = (props) => {
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
const plots = useSelector(state => state.farming_state.harvester.plots);
|
||||
const plots = useSelector((state) => state.farming_state.harvester.plots);
|
||||
const not_found_filenames = useSelector(
|
||||
state => state.farming_state.harvester.not_found_filenames
|
||||
(state) => state.farming_state.harvester.not_found_filenames,
|
||||
);
|
||||
const failed_to_open_filenames = useSelector(
|
||||
state => state.farming_state.harvester.failed_to_open_filenames
|
||||
(state) => state.farming_state.harvester.failed_to_open_filenames,
|
||||
);
|
||||
plots.sort((a, b) => b.size - a.size);
|
||||
const [page, setPage] = React.useState(0);
|
||||
const [rowsPerPage, setRowsPerPage] = React.useState(10);
|
||||
const [addDirectoryOpen, addDirectorySetOpen] = React.useState(false);
|
||||
const [deletePlotName, deletePlotSetName] = React.useState("");
|
||||
const [deletePlotName, deletePlotSetName] = React.useState('');
|
||||
const [deletePlotOpen, deletePlotSetOpen] = React.useState(false);
|
||||
|
||||
const handleChangePage = (event, newPage) => {
|
||||
setPage(newPage);
|
||||
};
|
||||
|
||||
const handleChangeRowsPerPage = event => {
|
||||
const handleChangeRowsPerPage = (event) => {
|
||||
setRowsPerPage(+event.target.value);
|
||||
setPage(0);
|
||||
};
|
||||
@@ -368,7 +367,7 @@ const Plots = props => {
|
||||
</Button>
|
||||
<AddPlotDialog
|
||||
classes={{
|
||||
paper: classes.paper
|
||||
paper: classes.paper,
|
||||
}}
|
||||
id="ringtone-menu"
|
||||
keepMounted
|
||||
@@ -397,7 +396,7 @@ const Plots = props => {
|
||||
<TableBody>
|
||||
{plots
|
||||
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
||||
.map(item => (
|
||||
.map((item) => (
|
||||
<TableRow key={item.filename}>
|
||||
<TableCell component="th" scope="row">
|
||||
<Tooltip title={item.filename} interactive>
|
||||
@@ -407,13 +406,13 @@ const Plots = props => {
|
||||
<TableCell align="right">
|
||||
{item.size} (
|
||||
{Math.round(
|
||||
(item.file_size * 1000) / (1024 * 1024 * 1024)
|
||||
(item.file_size * 1000) / (1024 * 1024 * 1024),
|
||||
) / 1000}
|
||||
GiB)
|
||||
</TableCell>
|
||||
<TableCell align="right">
|
||||
<Tooltip title={item["plot-seed"]} interactive>
|
||||
<span>{item["plot-seed"].substring(0, 10)}</span>
|
||||
<Tooltip title={item['plot-seed']} interactive>
|
||||
<span>{item['plot-seed'].substring(0, 10)}</span>
|
||||
</Tooltip>
|
||||
</TableCell>
|
||||
<TableCell align="right">
|
||||
@@ -438,7 +437,7 @@ const Plots = props => {
|
||||
}}
|
||||
align="right"
|
||||
>
|
||||
<DeleteForeverIcon fontSize="small"></DeleteForeverIcon>
|
||||
<DeleteForeverIcon fontSize="small" />
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
@@ -467,7 +466,7 @@ const Plots = props => {
|
||||
that the storage devices are properly connected.
|
||||
</p>
|
||||
<List dense={classes.dense}>
|
||||
{not_found_filenames.map(filename => (
|
||||
{not_found_filenames.map((filename) => (
|
||||
<ListItem key={filename}>
|
||||
<ListItemText primary={filename} />
|
||||
<ListItemSecondaryAction>
|
||||
@@ -484,10 +483,10 @@ const Plots = props => {
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>{" "}
|
||||
</List>{' '}
|
||||
</span>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
)}
|
||||
{failed_to_open_filenames.length > 0 ? (
|
||||
<span>
|
||||
@@ -500,7 +499,7 @@ const Plots = props => {
|
||||
These plots are invalid, you might want to delete them forever.
|
||||
</p>
|
||||
<List dense={classes.dense}>
|
||||
{failed_to_open_filenames.map(filename => (
|
||||
{failed_to_open_filenames.map((filename) => (
|
||||
<ListItem key={filename}>
|
||||
<ListItemText primary={filename} />
|
||||
<ListItemSecondaryAction>
|
||||
@@ -520,7 +519,7 @@ const Plots = props => {
|
||||
</List>
|
||||
</span>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
)}
|
||||
</Grid>
|
||||
</Grid>
|
||||
@@ -530,7 +529,7 @@ const Plots = props => {
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
<DialogTitle id="alert-dialog-title">{"Delete all keys"}</DialogTitle>
|
||||
<DialogTitle id="alert-dialog-title">Delete all keys</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
Are you sure you want to delete the plot? The plot cannot be
|
||||
@@ -554,22 +553,22 @@ const Plots = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const FarmerContent = props => {
|
||||
const FarmerContent = (props) => {
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const connections = useSelector(
|
||||
state => state.farming_state.farmer.connections
|
||||
(state) => state.farming_state.farmer.connections,
|
||||
);
|
||||
|
||||
const connectionError = useSelector(
|
||||
state => state.farming_state.farmer.open_connection_error
|
||||
(state) => state.farming_state.farmer.open_connection_error,
|
||||
);
|
||||
|
||||
const openConnectionCallback = (host, port) => {
|
||||
dispatch(openConnection(host, port));
|
||||
};
|
||||
const closeConnectionCallback = node_id => {
|
||||
const closeConnectionCallback = (node_id) => {
|
||||
dispatch(closeConnection(node_id));
|
||||
};
|
||||
return (
|
||||
@@ -580,13 +579,13 @@ const FarmerContent = props => {
|
||||
<FarmerStatus
|
||||
totalChiaFarmed={props.totalChiaFarmed}
|
||||
biggestHeight={props.biggestHeight}
|
||||
></FarmerStatus>
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Challenges></Challenges>
|
||||
<Challenges />
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Plots></Plots>
|
||||
<Plots />
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Connections
|
||||
@@ -594,47 +593,47 @@ const FarmerContent = props => {
|
||||
connectionError={connectionError}
|
||||
openConnection={openConnectionCallback}
|
||||
closeConnection={closeConnectionCallback}
|
||||
></Connections>
|
||||
/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Container>
|
||||
);
|
||||
};
|
||||
|
||||
const Farmer = props => {
|
||||
const Farmer = (props) => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const [totalChiaFarmed, setTotalChiaFarmed] = useState(BigInt(0));
|
||||
const [biggestHeight, setBiggestHeight] = useState(0);
|
||||
const [didMount, setDidMount] = useState(false);
|
||||
|
||||
const wallets = useSelector(state => state.wallet_state.wallets);
|
||||
const wallets = useSelector((state) => state.wallet_state.wallets);
|
||||
|
||||
const classes = props.classes;
|
||||
const { classes } = props;
|
||||
|
||||
const checkRewards = useCallback(async () => {
|
||||
let totalChia = BigInt(0);
|
||||
let biggestHeight = 0;
|
||||
for (let wallet of wallets) {
|
||||
for (const wallet of wallets) {
|
||||
if (!wallet) {
|
||||
continue;
|
||||
}
|
||||
for (let tx of wallet.transactions) {
|
||||
for (const tx of wallet.transactions) {
|
||||
if (!didMount) return;
|
||||
if (tx.additions.length < 1) {
|
||||
continue;
|
||||
}
|
||||
console.log("Checking tx", tx);
|
||||
console.log('Checking tx', tx);
|
||||
// Height here is filled into the whole 256 bits (32 bytes) of the parent
|
||||
let hexHeight = arr_to_hex(
|
||||
big_int_to_array(BigInt(tx.confirmed_at_index), 32)
|
||||
const hexHeight = arr_to_hex(
|
||||
big_int_to_array(BigInt(tx.confirmed_at_index), 32),
|
||||
);
|
||||
// Height is a 32 bit int so hashing it requires serializing it to 4 bytes
|
||||
let hexHeightHashBytes = await sha256(
|
||||
big_int_to_array(BigInt(tx.confirmed_at_index), 4)
|
||||
const hexHeightHashBytes = await sha256(
|
||||
big_int_to_array(BigInt(tx.confirmed_at_index), 4),
|
||||
);
|
||||
let hexHeightDoubleHashBytes = await sha256(hexHeightHashBytes);
|
||||
let hexHeightDoubleHash = arr_to_hex(hexHeightDoubleHashBytes);
|
||||
const hexHeightDoubleHashBytes = await sha256(hexHeightHashBytes);
|
||||
const hexHeightDoubleHash = arr_to_hex(hexHeightDoubleHashBytes);
|
||||
|
||||
if (
|
||||
hexHeight === tx.additions[0].parent_coin_info ||
|
||||
@@ -673,7 +672,7 @@ const Farmer = props => {
|
||||
<FarmerContent
|
||||
totalChiaFarmed={totalChiaFarmed}
|
||||
biggestHeight={biggestHeight}
|
||||
></FarmerContent>
|
||||
/>
|
||||
</Container>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
@@ -1,210 +1,210 @@
|
||||
import React from "react";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Box from "@material-ui/core/Box";
|
||||
import { Paper, Tooltip } from "@material-ui/core";
|
||||
import { unix_to_short_date } from "../util/utils";
|
||||
import Connections from "./Connections";
|
||||
import Block from "./Block";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import HelpIcon from "@material-ui/icons/Help";
|
||||
import React from 'react';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import { Paper, Tooltip } from '@material-ui/core';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import HelpIcon from '@material-ui/icons/Help';
|
||||
import { unix_to_short_date } from '../util/utils';
|
||||
import Connections from './Connections';
|
||||
import Block from './Block';
|
||||
import {
|
||||
closeConnection,
|
||||
openConnection,
|
||||
getBlock,
|
||||
getHeader
|
||||
} from "../modules/fullnodeMessages";
|
||||
getHeader,
|
||||
} from '../modules/fullnodeMessages';
|
||||
|
||||
/* global BigInt */
|
||||
|
||||
const drawerWidth = 180;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
display: "flex",
|
||||
paddingLeft: "0px",
|
||||
paddingRight: "0px"
|
||||
display: 'flex',
|
||||
paddingLeft: '0px',
|
||||
paddingRight: '0px',
|
||||
},
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
searchHashButton: {
|
||||
marginLeft: "10px",
|
||||
height: "100%"
|
||||
marginLeft: '10px',
|
||||
height: '100%',
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
drawerPaperClose: {
|
||||
overflowX: "hidden",
|
||||
transition: theme.transitions.create("width", {
|
||||
overflowX: 'hidden',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
width: theme.spacing(7),
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: theme.spacing(9)
|
||||
}
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: theme.spacing(9),
|
||||
},
|
||||
},
|
||||
content: {
|
||||
flexGrow: 1,
|
||||
height: "calc(100vh - 64px)",
|
||||
overflowX: "hidden"
|
||||
height: 'calc(100vh - 64px)',
|
||||
overflowX: 'hidden',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(3),
|
||||
paddingLeft: theme.spacing(6),
|
||||
paddingRight: theme.spacing(6),
|
||||
paddingBottom: theme.spacing(3)
|
||||
paddingBottom: theme.spacing(3),
|
||||
},
|
||||
paper: {
|
||||
padding: theme.spacing(0),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
fixedHeight: {
|
||||
height: 240
|
||||
height: 240,
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
balancePaper: {
|
||||
padding: theme.spacing(2),
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
bottomOptions: {
|
||||
position: "absolute",
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
width: "100%"
|
||||
width: '100%',
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(1),
|
||||
paddingTop: theme.spacing(1),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
cardSubSection: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingTop: theme.spacing(1)
|
||||
paddingTop: theme.spacing(1),
|
||||
},
|
||||
left_block_cell: {
|
||||
marginLeft: 10,
|
||||
width: "25%",
|
||||
textAlign: "left",
|
||||
overflowWrap: "break-word"
|
||||
width: '25%',
|
||||
textAlign: 'left',
|
||||
overflowWrap: 'break-word',
|
||||
},
|
||||
center_block_cell: {
|
||||
width: "25%",
|
||||
textAlign: "center",
|
||||
overflowWrap: "break-word"
|
||||
width: '25%',
|
||||
textAlign: 'center',
|
||||
overflowWrap: 'break-word',
|
||||
},
|
||||
center_block_cell_small: {
|
||||
width: "15%",
|
||||
textAlign: "center",
|
||||
overflowWrap: "break-word"
|
||||
width: '15%',
|
||||
textAlign: 'center',
|
||||
overflowWrap: 'break-word',
|
||||
},
|
||||
right_block_cell: {
|
||||
marginLeft: 30,
|
||||
marginRight: 10,
|
||||
width: "25%",
|
||||
textAlign: "right",
|
||||
overflowWrap: "break-word"
|
||||
width: '25%',
|
||||
textAlign: 'right',
|
||||
overflowWrap: 'break-word',
|
||||
},
|
||||
block_row: {
|
||||
height: "30px",
|
||||
cursor: "pointer",
|
||||
borderBottom: "1px solid #eeeeee",
|
||||
height: '30px',
|
||||
cursor: 'pointer',
|
||||
borderBottom: '1px solid #eeeeee',
|
||||
/* mouse over link */
|
||||
"&:hover": {
|
||||
backgroundColor: "#eeeeee"
|
||||
}
|
||||
'&:hover': {
|
||||
backgroundColor: '#eeeeee',
|
||||
},
|
||||
},
|
||||
block_row_unfinished: {
|
||||
height: "30px",
|
||||
borderBottom: "1px solid #eeeeee",
|
||||
color: "orange"
|
||||
height: '30px',
|
||||
borderBottom: '1px solid #eeeeee',
|
||||
color: 'orange',
|
||||
},
|
||||
block_header: {
|
||||
marginBottom: 10
|
||||
}
|
||||
marginBottom: 10,
|
||||
},
|
||||
}));
|
||||
|
||||
const getStatusItems = (state, connected) => {
|
||||
var status_items = [];
|
||||
const status_items = [];
|
||||
if (state.sync && state.sync.sync_mode) {
|
||||
const progress = state.sync.sync_progress_height;
|
||||
const tip = state.sync.sync_tip_height;
|
||||
const item = {
|
||||
label: "Status",
|
||||
value: "Syncing " + progress + "/" + tip,
|
||||
colour: "orange",
|
||||
label: 'Status',
|
||||
value: `Syncing ${progress}/${tip}`,
|
||||
colour: 'orange',
|
||||
tooltip:
|
||||
"The node is syncing, which means it is downloading blocks from other nodes, to reach the latest block in the chain"
|
||||
'The node is syncing, which means it is downloading blocks from other nodes, to reach the latest block in the chain',
|
||||
};
|
||||
status_items.push(item);
|
||||
} else if (connected) {
|
||||
const item = {
|
||||
label: "Status",
|
||||
value: "Synced",
|
||||
colour: "green",
|
||||
tooltip: "This node is fully caught up and validating the network"
|
||||
label: 'Status',
|
||||
value: 'Synced',
|
||||
colour: 'green',
|
||||
tooltip: 'This node is fully caught up and validating the network',
|
||||
};
|
||||
status_items.push(item);
|
||||
} else {
|
||||
const item = {
|
||||
label: "Status",
|
||||
value: "Not connected",
|
||||
colour: "black"
|
||||
label: 'Status',
|
||||
value: 'Not connected',
|
||||
colour: 'black',
|
||||
};
|
||||
status_items.push(item);
|
||||
}
|
||||
|
||||
if (state.lca) {
|
||||
const lca_height = state.lca.data.height;
|
||||
const item = { label: "LCA Block Height", value: "" + lca_height };
|
||||
const item = { label: 'LCA Block Height', value: `${lca_height}` };
|
||||
status_items.push(item);
|
||||
} else {
|
||||
const item = { label: "LCA Block Height", value: "0" };
|
||||
const item = { label: 'LCA Block Height', value: '0' };
|
||||
status_items.push(item);
|
||||
}
|
||||
|
||||
if (state.tips) {
|
||||
var max_height = 0;
|
||||
for (let tip of state.tips) {
|
||||
let max_height = 0;
|
||||
for (const tip of state.tips) {
|
||||
if (parseInt(tip.data.height) > max_height) {
|
||||
max_height = parseInt(tip.data.height);
|
||||
}
|
||||
}
|
||||
const item = { label: "Max Tip Block Height", value: "" + max_height };
|
||||
const item = { label: 'Max Tip Block Height', value: `${max_height}` };
|
||||
status_items.push(item);
|
||||
} else {
|
||||
const item = { label: "Max Tip Block Height", value: "0" };
|
||||
const item = { label: 'Max Tip Block Height', value: '0' };
|
||||
status_items.push(item);
|
||||
}
|
||||
|
||||
@@ -212,69 +212,70 @@ const getStatusItems = (state, connected) => {
|
||||
const lca_time = state.lca.data.timestamp;
|
||||
const date_string = unix_to_short_date(parseInt(lca_time));
|
||||
const item = {
|
||||
label: "LCA Time",
|
||||
label: 'LCA Time',
|
||||
value: date_string,
|
||||
tooltip:
|
||||
"This is the time of the latest common ancestor, which is a block ancestor of all tip blocks. Note that the full node keeps track of up to three tips at each height."
|
||||
'This is the time of the latest common ancestor, which is a block ancestor of all tip blocks. Note that the full node keeps track of up to three tips at each height.',
|
||||
};
|
||||
status_items.push(item);
|
||||
} else {
|
||||
const item = { label: "LCA Time", value: "" };
|
||||
const item = { label: 'LCA Time', value: '' };
|
||||
status_items.push(item);
|
||||
}
|
||||
|
||||
if (connected) {
|
||||
const item = {
|
||||
label: "Connection Status ",
|
||||
value: "Connected",
|
||||
colour: "green"
|
||||
label: 'Connection Status ',
|
||||
value: 'Connected',
|
||||
colour: 'green',
|
||||
};
|
||||
status_items.push(item);
|
||||
} else {
|
||||
const item = {
|
||||
label: "Connection Status ",
|
||||
value: "Not connected",
|
||||
colour: "red"
|
||||
label: 'Connection Status ',
|
||||
value: 'Not connected',
|
||||
colour: 'red',
|
||||
};
|
||||
status_items.push(item);
|
||||
}
|
||||
const difficulty = state.difficulty;
|
||||
const diff_item = { label: "Difficulty", value: difficulty };
|
||||
const { difficulty } = state;
|
||||
const diff_item = { label: 'Difficulty', value: difficulty };
|
||||
status_items.push(diff_item);
|
||||
|
||||
const ips = state.ips;
|
||||
const { ips } = state;
|
||||
const ips_item = {
|
||||
label: "Iterations per Second",
|
||||
label: 'Iterations per Second',
|
||||
value: ips,
|
||||
tooltip:
|
||||
"The estimated proof of time speed of the fastest timelord in the network."
|
||||
'The estimated proof of time speed of the fastest timelord in the network.',
|
||||
};
|
||||
status_items.push(ips_item);
|
||||
|
||||
const iters = state.min_iters;
|
||||
const min_item = { label: "Min Iterations", value: iters };
|
||||
const min_item = { label: 'Min Iterations', value: iters };
|
||||
status_items.push(min_item);
|
||||
|
||||
const space =
|
||||
(BigInt(state.space) / BigInt(Math.pow(1024, 4))).toString() + "TiB";
|
||||
const space = `${(
|
||||
BigInt(state.space) / BigInt(Math.pow(1024, 4))
|
||||
).toString()}TiB`;
|
||||
const space_item = {
|
||||
label: "Estimated network space",
|
||||
label: 'Estimated network space',
|
||||
value: space,
|
||||
tooltip:
|
||||
"Estimated sum of all the plotted disk space of all farmers in the network"
|
||||
'Estimated sum of all the plotted disk space of all farmers in the network',
|
||||
};
|
||||
status_items.push(space_item);
|
||||
|
||||
return status_items;
|
||||
};
|
||||
|
||||
const StatusCell = props => {
|
||||
const StatusCell = (props) => {
|
||||
const classes = useStyles();
|
||||
const item = props.item;
|
||||
const label = item.label;
|
||||
const value = item.value;
|
||||
const tooltip = item.tooltip;
|
||||
const colour = item.colour;
|
||||
const { item } = props;
|
||||
const { label } = item;
|
||||
const { value } = item;
|
||||
const { tooltip } = item;
|
||||
const { colour } = item;
|
||||
return (
|
||||
<Grid item xs={6}>
|
||||
<div className={classes.cardSubSection}>
|
||||
@@ -283,10 +284,10 @@ const StatusCell = props => {
|
||||
<Typography variant="subtitle1">{label}</Typography>
|
||||
{tooltip ? (
|
||||
<Tooltip title={tooltip}>
|
||||
<HelpIcon style={{ color: "#c8c8c8", fontSize: 12 }}></HelpIcon>
|
||||
<HelpIcon style={{ color: '#c8c8c8', fontSize: 12 }} />
|
||||
</Tooltip>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
)}
|
||||
</Box>
|
||||
<Box>
|
||||
@@ -300,12 +301,12 @@ const StatusCell = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const FullNodeStatus = props => {
|
||||
const FullNodeStatus = (props) => {
|
||||
const blockchain_state = useSelector(
|
||||
state => state.full_node_state.blockchain_state
|
||||
(state) => state.full_node_state.blockchain_state,
|
||||
);
|
||||
const connected = useSelector(
|
||||
state => state.daemon_state.full_node_connected
|
||||
(state) => state.daemon_state.full_node_connected,
|
||||
);
|
||||
const statusItems = getStatusItems(blockchain_state, connected);
|
||||
|
||||
@@ -320,8 +321,8 @@ const FullNodeStatus = props => {
|
||||
</Typography>
|
||||
</div>
|
||||
</Grid>
|
||||
{statusItems.map(item => (
|
||||
<StatusCell item={item} key={item.label}></StatusCell>
|
||||
{statusItems.map((item) => (
|
||||
<StatusCell item={item} key={item.label} />
|
||||
))}
|
||||
</Grid>
|
||||
</Paper>
|
||||
@@ -329,7 +330,7 @@ const FullNodeStatus = props => {
|
||||
};
|
||||
|
||||
const BlocksCard = () => {
|
||||
const headers = useSelector(state => state.full_node_state.headers);
|
||||
const headers = useSelector((state) => state.full_node_state.headers);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
function clickedBlock(height, header_hash, prev_header_hash) {
|
||||
@@ -354,8 +355,8 @@ const BlocksCard = () => {
|
||||
<Box
|
||||
className={classes.block_header}
|
||||
display="flex"
|
||||
key={"header"}
|
||||
style={{ minWidth: "100%" }}
|
||||
key="header"
|
||||
style={{ minWidth: '100%' }}
|
||||
>
|
||||
<Box className={classes.left_block_cell}>Header Hash</Box>
|
||||
<Box className={classes.center_block_cell_small}>Height</Box>
|
||||
@@ -364,7 +365,7 @@ const BlocksCard = () => {
|
||||
</Box>
|
||||
<Box className={classes.right_block_cell}>Expected finish time</Box>
|
||||
</Box>
|
||||
{headers.map(header => (
|
||||
{headers.map((header) => (
|
||||
<Box
|
||||
className={
|
||||
header.data.finished
|
||||
@@ -376,17 +377,17 @@ const BlocksCard = () => {
|
||||
? clickedBlock(
|
||||
header.data.height,
|
||||
header.data.header_hash,
|
||||
header.data.prev_header_hash
|
||||
header.data.prev_header_hash,
|
||||
)
|
||||
: () => {}
|
||||
}
|
||||
display="flex"
|
||||
key={header.data.header_hash}
|
||||
style={{ minWidth: "100%" }}
|
||||
style={{ minWidth: '100%' }}
|
||||
>
|
||||
<Box className={classes.left_block_cell}>
|
||||
{header.data.header_hash.substring(0, 12) + "..."}
|
||||
{header.data.finished ? "" : " (unfinished)"}
|
||||
{`${header.data.header_hash.substring(0, 12)}...`}
|
||||
{header.data.finished ? '' : ' (unfinished)'}
|
||||
</Box>
|
||||
<Box className={classes.center_block_cell_small}>
|
||||
{header.data.height}
|
||||
@@ -396,7 +397,7 @@ const BlocksCard = () => {
|
||||
</Box>
|
||||
<Box className={classes.right_block_cell}>
|
||||
{header.data.finished
|
||||
? "finished"
|
||||
? 'finished'
|
||||
: unix_to_short_date(parseInt(header.data.finish_time))}
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -406,15 +407,15 @@ const BlocksCard = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const SearchBlock = props => {
|
||||
const SearchBlock = (props) => {
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
const [searchHash, setSearchHash] = React.useState("");
|
||||
const handleChangeSearchHash = event => {
|
||||
const [searchHash, setSearchHash] = React.useState('');
|
||||
const handleChangeSearchHash = (event) => {
|
||||
setSearchHash(event.target.value);
|
||||
};
|
||||
const clickSearch = () => {
|
||||
setSearchHash("");
|
||||
setSearchHash('');
|
||||
dispatch(getBlock(searchHash));
|
||||
};
|
||||
return (
|
||||
@@ -461,17 +462,17 @@ const FullNode = () => {
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const connections = useSelector(state => state.full_node_state.connections);
|
||||
const connections = useSelector((state) => state.full_node_state.connections);
|
||||
const connectionError = useSelector(
|
||||
state => state.full_node_state.open_connection_error
|
||||
(state) => state.full_node_state.open_connection_error,
|
||||
);
|
||||
const block = useSelector(state => state.full_node_state.block);
|
||||
const header = useSelector(state => state.full_node_state.header);
|
||||
const block = useSelector((state) => state.full_node_state.block);
|
||||
const header = useSelector((state) => state.full_node_state.header);
|
||||
|
||||
const openConnectionCallback = (host, port) => {
|
||||
dispatch(openConnection(host, port));
|
||||
};
|
||||
const closeConnectionCallback = node_id => {
|
||||
const closeConnectionCallback = (node_id) => {
|
||||
dispatch(closeConnection(node_id));
|
||||
};
|
||||
|
||||
@@ -482,14 +483,14 @@ const FullNode = () => {
|
||||
<Container maxWidth="lg" className={classes.container}>
|
||||
<Grid container spacing={3}>
|
||||
{block != null ? (
|
||||
<Block block={block} prevHeader={header}></Block>
|
||||
<Block block={block} prevHeader={header} />
|
||||
) : (
|
||||
<span>
|
||||
<Grid item xs={12}>
|
||||
<FullNodeStatus></FullNodeStatus>
|
||||
<FullNodeStatus />
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<BlocksCard></BlocksCard>
|
||||
<BlocksCard />
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<Connections
|
||||
@@ -497,10 +498,10 @@ const FullNode = () => {
|
||||
connectionError={connectionError}
|
||||
openConnection={openConnectionCallback}
|
||||
closeConnection={closeConnectionCallback}
|
||||
></Connections>
|
||||
/>
|
||||
</Grid>
|
||||
<Grid item xs={12}>
|
||||
<SearchBlock></SearchBlock>
|
||||
<SearchBlock />
|
||||
</Grid>
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import React from "react";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Dialog from "@material-ui/core/Dialog";
|
||||
import DialogActions from "@material-ui/core/DialogActions";
|
||||
import DialogContent from "@material-ui/core/DialogContent";
|
||||
import DialogContentText from "@material-ui/core/DialogContentText";
|
||||
import DialogTitle from "@material-ui/core/DialogTitle";
|
||||
import { closeDialog } from "../modules/dialog";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Backdrop } from "@material-ui/core";
|
||||
import { CircularProgress } from "@material-ui/core";
|
||||
import { useStyles } from "./CreateWallet";
|
||||
import React from 'react';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Dialog from '@material-ui/core/Dialog';
|
||||
import DialogActions from '@material-ui/core/DialogActions';
|
||||
import DialogContent from '@material-ui/core/DialogContent';
|
||||
import DialogContentText from '@material-ui/core/DialogContentText';
|
||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { Backdrop, CircularProgress } from '@material-ui/core';
|
||||
|
||||
export const DialogItem = props => {
|
||||
const dialog = props.dialog;
|
||||
import { closeDialog } from '../modules/dialog';
|
||||
import { useStyles } from './CreateWallet';
|
||||
|
||||
export const DialogItem = (props) => {
|
||||
const { dialog } = props;
|
||||
const text = dialog.label;
|
||||
const title = dialog.title;
|
||||
const id = dialog.id;
|
||||
const { title } = dialog;
|
||||
const { id } = dialog;
|
||||
const dispatch = useDispatch();
|
||||
const open = true;
|
||||
|
||||
@@ -47,19 +47,19 @@ export const DialogItem = props => {
|
||||
};
|
||||
|
||||
export const ModalDialog = () => {
|
||||
const dialogs = useSelector(state => state.dialog_state.dialogs);
|
||||
const dialogs = useSelector((state) => state.dialog_state.dialogs);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{dialogs.map(dialog => (
|
||||
<DialogItem dialog={dialog} key={dialog.id}></DialogItem>
|
||||
{dialogs.map((dialog) => (
|
||||
<DialogItem dialog={dialog} key={dialog.id} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const Spinner = () => {
|
||||
const show = useSelector(state => state.progress.progress_indicator);
|
||||
const show = useSelector((state) => state.progress.progress_indicator);
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Backdrop className={classes.backdrop} open={show}>
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { withTheme } from "@material-ui/styles";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import { genereate_mnemonics, add_new_key_action } from "../modules/message";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import CssTextField from "../components/cssTextField";
|
||||
import { changeEntranceMenu, presentSelectKeys } from "../modules/entranceMenu";
|
||||
import logo from "../assets/img/chia_logo.svg";
|
||||
import myStyle from "./style";
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { withTheme } from '@material-ui/styles';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { genereate_mnemonics, add_new_key_action } from '../modules/message';
|
||||
import CssTextField from '../components/cssTextField';
|
||||
import { changeEntranceMenu, presentSelectKeys } from '../modules/entranceMenu';
|
||||
import logo from '../assets/img/chia_logo.svg';
|
||||
import myStyle from './style';
|
||||
|
||||
const MnemonicField = props => {
|
||||
const MnemonicField = (props) => {
|
||||
return (
|
||||
<Grid item xs={2}>
|
||||
<CssTextField
|
||||
@@ -33,14 +33,14 @@ const MnemonicField = props => {
|
||||
</Grid>
|
||||
);
|
||||
};
|
||||
const Iterator = props => {
|
||||
const Iterator = (props) => {
|
||||
return props.mnemonic.map((word, i) => (
|
||||
<MnemonicField key={i} word={word} id={"id_" + (i + 1)} index={i + 1} />
|
||||
<MnemonicField key={i} word={word} id={`id_${i + 1}`} index={i + 1} />
|
||||
));
|
||||
};
|
||||
|
||||
const UIPart = props => {
|
||||
var words = useSelector(state => state.wallet_state.mnemonic);
|
||||
const UIPart = (props) => {
|
||||
let words = useSelector((state) => state.wallet_state.mnemonic);
|
||||
const dispatch = useDispatch();
|
||||
const classes = myStyle();
|
||||
if (!words) {
|
||||
@@ -58,7 +58,7 @@ const UIPart = props => {
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
<ArrowBackIosIcon onClick={goBack} className={classes.navigator}>
|
||||
{" "}
|
||||
{' '}
|
||||
</ArrowBackIosIcon>
|
||||
<div className={classes.grid_wrap}>
|
||||
<img className={classes.logo} src={logo} alt="Logo" />
|
||||
@@ -71,7 +71,7 @@ const UIPart = props => {
|
||||
(Order is important)
|
||||
</p>
|
||||
<Grid container spacing={2}>
|
||||
<Iterator mnemonic={words}></Iterator>
|
||||
<Iterator mnemonic={words} />
|
||||
</Grid>
|
||||
</Container>
|
||||
</div>
|
||||
@@ -94,7 +94,7 @@ const UIPart = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const NewWallet = props => {
|
||||
const NewWallet = (props) => {
|
||||
const [didMount, setDidMount] = useState(false);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
@@ -107,7 +107,7 @@ const NewWallet = props => {
|
||||
}
|
||||
}, [didMount, setDidMount, dispatch]);
|
||||
|
||||
return <UIPart props={props}></UIPart>;
|
||||
return <UIPart props={props} />;
|
||||
};
|
||||
|
||||
export default withTheme(withRouter(NewWallet));
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import React from "react";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
import Link from "@material-ui/core/Link";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { withTheme } from "@material-ui/styles";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { useSelector } from "react-redux";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import CssTextField from "../components/cssTextField";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { mnemonic_word_added, resetMnemonic } from "../modules/mnemonic";
|
||||
import { unselectFingerprint } from "../modules/message";
|
||||
import React from 'react';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import Link from '@material-ui/core/Link';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { withTheme } from '@material-ui/styles';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import CssTextField from '../components/cssTextField';
|
||||
|
||||
import { mnemonic_word_added, resetMnemonic } from '../modules/mnemonic';
|
||||
import { unselectFingerprint } from '../modules/message';
|
||||
import {
|
||||
changeEntranceMenu,
|
||||
presentSelectKeys,
|
||||
presentRestoreBackup
|
||||
} from "../modules/entranceMenu";
|
||||
import logo from "../assets/img/chia_logo.svg";
|
||||
import myStyle from "./style";
|
||||
presentRestoreBackup,
|
||||
} from '../modules/entranceMenu';
|
||||
import logo from '../assets/img/chia_logo.svg';
|
||||
import myStyle from './style';
|
||||
|
||||
const MnemonicField = props => {
|
||||
const MnemonicField = (props) => {
|
||||
return (
|
||||
<Grid item xs={2}>
|
||||
<CssTextField
|
||||
@@ -40,36 +40,36 @@ const MnemonicField = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const Iterator = props => {
|
||||
const Iterator = (props) => {
|
||||
const dispatch = useDispatch();
|
||||
const mnemonic_state = useSelector(state => state.mnemonic_state);
|
||||
const mnemonic_state = useSelector((state) => state.mnemonic_state);
|
||||
const incorrect_word = useSelector(
|
||||
state => state.mnemonic_state.incorrect_word
|
||||
(state) => state.mnemonic_state.incorrect_word,
|
||||
);
|
||||
|
||||
function handleTextFieldChange(e) {
|
||||
var id = e.target.id + "";
|
||||
var clean_id = id.replace("id_", "");
|
||||
var int_val = parseInt(clean_id) - 1;
|
||||
var data = { word: e.target.value, id: int_val };
|
||||
const id = `${e.target.id}`;
|
||||
const clean_id = id.replace('id_', '');
|
||||
const int_val = parseInt(clean_id) - 1;
|
||||
const data = { word: e.target.value, id: int_val };
|
||||
dispatch(mnemonic_word_added(data));
|
||||
}
|
||||
var indents = [];
|
||||
for (var i = 0; i < 24; i++) {
|
||||
var focus = i === 0;
|
||||
const indents = [];
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const focus = i === 0;
|
||||
indents.push(
|
||||
<MnemonicField
|
||||
onChange={handleTextFieldChange}
|
||||
key={i}
|
||||
error={
|
||||
(props.submitted && mnemonic_state.mnemonic_input[i] === "") ||
|
||||
(props.submitted && mnemonic_state.mnemonic_input[i] === '') ||
|
||||
mnemonic_state.mnemonic_input[i] === incorrect_word
|
||||
}
|
||||
value={mnemonic_state.mnemonic_input[i]}
|
||||
autofocus={focus}
|
||||
id={"id_" + (i + 1)}
|
||||
id={`id_${i + 1}`}
|
||||
index={i + 1}
|
||||
/>
|
||||
/>,
|
||||
);
|
||||
}
|
||||
return indents;
|
||||
@@ -82,13 +82,13 @@ const UIPart = () => {
|
||||
}
|
||||
const dispatch = useDispatch();
|
||||
const [submitted, setSubmitted] = React.useState(false);
|
||||
const mnemonic = useSelector(state => state.mnemonic_state.mnemonic_input);
|
||||
const mnemonic = useSelector((state) => state.mnemonic_state.mnemonic_input);
|
||||
const classes = myStyle();
|
||||
|
||||
function enterMnemonic() {
|
||||
setSubmitted(true);
|
||||
for (var i = 0; i < mnemonic.length; i++) {
|
||||
if (mnemonic[i] === "") {
|
||||
for (let i = 0; i < mnemonic.length; i++) {
|
||||
if (mnemonic[i] === '') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ const UIPart = () => {
|
||||
your Chia wallet.
|
||||
</p>
|
||||
<Grid container spacing={2}>
|
||||
<Iterator submitted={submitted}></Iterator>
|
||||
<Iterator submitted={submitted} />
|
||||
</Grid>
|
||||
</Container>
|
||||
</div>
|
||||
@@ -135,8 +135,8 @@ const UIPart = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const OldWallet = props => {
|
||||
return <UIPart props={props}></UIPart>;
|
||||
const OldWallet = (props) => {
|
||||
return <UIPart props={props} />;
|
||||
};
|
||||
|
||||
export default withTheme(withRouter(OldWallet));
|
||||
|
||||
+119
-181
@@ -1,195 +1,195 @@
|
||||
import React from "react";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Box from "@material-ui/core/Box";
|
||||
import React from 'react';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import {
|
||||
Paper,
|
||||
FormControl,
|
||||
InputLabel,
|
||||
Select,
|
||||
MenuItem
|
||||
} from "@material-ui/core";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import InputAdornment from "@material-ui/core/InputAdornment";
|
||||
import FormHelperText from "@material-ui/core/FormHelperText";
|
||||
import { openDialog } from "../modules/dialog";
|
||||
import isElectron from "is-electron";
|
||||
MenuItem,
|
||||
} from '@material-ui/core';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import InputAdornment from '@material-ui/core/InputAdornment';
|
||||
import FormHelperText from '@material-ui/core/FormHelperText';
|
||||
import isElectron from 'is-electron';
|
||||
import Input from '@material-ui/core/Input';
|
||||
import { openDialog } from '../modules/dialog';
|
||||
import {
|
||||
workspaceSelected,
|
||||
finalSelected,
|
||||
startPlotting,
|
||||
resetProgress
|
||||
} from "../modules/plotter_messages";
|
||||
import { stopService } from "../modules/daemon_messages";
|
||||
import { service_plotter } from "../util/service_names";
|
||||
import Input from "@material-ui/core/Input";
|
||||
resetProgress,
|
||||
} from '../modules/plotter_messages';
|
||||
import { stopService } from '../modules/daemon_messages';
|
||||
import { service_plotter } from '../util/service_names';
|
||||
|
||||
const drawerWidth = 180;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
display: "flex",
|
||||
paddingLeft: "0px"
|
||||
display: 'flex',
|
||||
paddingLeft: '0px',
|
||||
},
|
||||
tabs: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
form: {
|
||||
margin: theme.spacing(1)
|
||||
margin: theme.spacing(1),
|
||||
},
|
||||
clickable: {
|
||||
cursor: "pointer"
|
||||
cursor: 'pointer',
|
||||
},
|
||||
error: {
|
||||
color: "red"
|
||||
color: 'red',
|
||||
},
|
||||
refreshButton: {
|
||||
marginLeft: "20px"
|
||||
marginLeft: '20px',
|
||||
},
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
drawerPaperClose: {
|
||||
overflowX: "hidden",
|
||||
transition: theme.transitions.create("width", {
|
||||
overflowX: 'hidden',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
width: theme.spacing(7),
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: theme.spacing(9)
|
||||
}
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: theme.spacing(9),
|
||||
},
|
||||
},
|
||||
content: {
|
||||
marginTop: theme.spacing(3),
|
||||
paddingBottom: theme.spacing(6),
|
||||
height: "calc(100vh - 64px)",
|
||||
overflowX: "hidden"
|
||||
height: 'calc(100vh - 64px)',
|
||||
overflowX: 'hidden',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(0),
|
||||
paddingBottom: theme.spacing(0),
|
||||
paddingRight: theme.spacing(0)
|
||||
paddingRight: theme.spacing(0),
|
||||
},
|
||||
paper: {
|
||||
padding: theme.spacing(0),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
fixedHeight: {
|
||||
height: 240
|
||||
height: 240,
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
balancePaper: {
|
||||
marginTop: theme.spacing(2),
|
||||
marginLeft: theme.spacing(2),
|
||||
marginRight: theme.spacing(2)
|
||||
marginRight: theme.spacing(2),
|
||||
},
|
||||
bottomOptions: {
|
||||
position: "absolute",
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
width: "100%"
|
||||
width: '100%',
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
cardSubSection: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingTop: theme.spacing(1)
|
||||
paddingTop: theme.spacing(1),
|
||||
},
|
||||
table: {
|
||||
minWidth: 650
|
||||
minWidth: 650,
|
||||
},
|
||||
selectButton: {
|
||||
width: 80,
|
||||
paddingLeft: theme.spacing(2),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
input: {
|
||||
paddingRight: theme.spacing(2),
|
||||
cursor: "pointer"
|
||||
cursor: 'pointer',
|
||||
},
|
||||
createButton: {
|
||||
float: "right",
|
||||
float: 'right',
|
||||
width: 150,
|
||||
paddingLeft: theme.spacing(2),
|
||||
height: 56,
|
||||
marginTop: theme.spacing(4),
|
||||
marginBottom: theme.spacing(2),
|
||||
background: "linear-gradient(45deg, #0a6b19 30%, #6ff196 90%)",
|
||||
boxShadow: "0 3px 5px 2px rgba(255, 105, 135, .3)",
|
||||
color: "white"
|
||||
background: 'linear-gradient(45deg, #0a6b19 30%, #6ff196 90%)',
|
||||
boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
|
||||
color: 'white',
|
||||
},
|
||||
logContainer: {
|
||||
marginLeft: theme.spacing(3),
|
||||
marginRight: theme.spacing(3),
|
||||
minHeight: 400,
|
||||
maxHeight: 400,
|
||||
maxWidth: "100%",
|
||||
backgroundColor: "#f1f1f1",
|
||||
border: "1px solid #888888",
|
||||
whiteSpace: "pre-wrap",
|
||||
maxWidth: '100%',
|
||||
backgroundColor: '#f1f1f1',
|
||||
border: '1px solid #888888',
|
||||
whiteSpace: 'pre-wrap',
|
||||
paddingTop: theme.spacing(1),
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingBottom: theme.spacing(3),
|
||||
overflowY: "auto",
|
||||
overflowWrap: "break-word",
|
||||
lineHeight: 1.8
|
||||
overflowY: 'auto',
|
||||
overflowWrap: 'break-word',
|
||||
lineHeight: 1.8,
|
||||
},
|
||||
logPaper: {
|
||||
maxWidth: "100%",
|
||||
maxWidth: '100%',
|
||||
marginBottom: theme.spacing(3),
|
||||
marginTop: theme.spacing(3)
|
||||
marginTop: theme.spacing(3),
|
||||
},
|
||||
cancelButton: {
|
||||
float: "right",
|
||||
float: 'right',
|
||||
width: 150,
|
||||
paddingLeft: theme.spacing(2),
|
||||
height: 56,
|
||||
marginTop: theme.spacing(4),
|
||||
marginBottom: theme.spacing(2)
|
||||
marginBottom: theme.spacing(2),
|
||||
},
|
||||
clearButton: {
|
||||
float: "right",
|
||||
float: 'right',
|
||||
width: 150,
|
||||
marginRight: theme.spacing(2),
|
||||
height: 56,
|
||||
marginTop: theme.spacing(4),
|
||||
marginBottom: theme.spacing(2)
|
||||
}
|
||||
marginBottom: theme.spacing(2),
|
||||
},
|
||||
}));
|
||||
|
||||
const plot_size_options = [
|
||||
@@ -211,21 +211,21 @@ const WorkLocation = () => {
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
const work_location = useSelector(
|
||||
state => state.plot_control.workspace_location
|
||||
(state) => state.plot_control.workspace_location,
|
||||
);
|
||||
async function select() {
|
||||
if (isElectron()) {
|
||||
const dialogOptions = {
|
||||
properties: ["openDirectory", "showHiddenFiles"]
|
||||
properties: ['openDirectory', 'showHiddenFiles'],
|
||||
};
|
||||
const result = await window.remote.dialog.showOpenDialog(dialogOptions);
|
||||
const filePath = result["filePaths"][0];
|
||||
const filePath = result.filePaths[0];
|
||||
if (filePath) {
|
||||
dispatch(workspaceSelected(filePath));
|
||||
}
|
||||
} else {
|
||||
dispatch(
|
||||
openDialog("", "This feature is available only from electron app")
|
||||
openDialog('', 'This feature is available only from electron app'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -242,8 +242,8 @@ const WorkLocation = () => {
|
||||
fullWidth
|
||||
onClick={select}
|
||||
label={
|
||||
work_location === ""
|
||||
? "Temporary folder location"
|
||||
work_location === ''
|
||||
? 'Temporary folder location'
|
||||
: work_location
|
||||
}
|
||||
/>
|
||||
@@ -268,21 +268,21 @@ const FinalLocation = () => {
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
const final_location = useSelector(
|
||||
state => state.plot_control.final_location
|
||||
(state) => state.plot_control.final_location,
|
||||
);
|
||||
async function select() {
|
||||
if (isElectron()) {
|
||||
const dialogOptions = {
|
||||
properties: ["openDirectory", "showHiddenFiles"]
|
||||
properties: ['openDirectory', 'showHiddenFiles'],
|
||||
};
|
||||
const result = await window.remote.dialog.showOpenDialog(dialogOptions);
|
||||
const filePath = result["filePaths"][0];
|
||||
const filePath = result.filePaths[0];
|
||||
if (filePath) {
|
||||
dispatch(finalSelected(filePath));
|
||||
}
|
||||
} else {
|
||||
dispatch(
|
||||
openDialog("", "This feature is available only from electron app")
|
||||
openDialog('', 'This feature is available only from electron app'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ const FinalLocation = () => {
|
||||
onClick={select}
|
||||
fullWidth
|
||||
label={
|
||||
final_location === "" ? "Final folder location" : final_location
|
||||
final_location === '' ? 'Final folder location' : final_location
|
||||
}
|
||||
variant="outlined"
|
||||
/>
|
||||
@@ -323,20 +323,17 @@ const CreatePlot = () => {
|
||||
const dispatch = useDispatch();
|
||||
const classes = useStyles();
|
||||
const work_location = useSelector(
|
||||
state => state.plot_control.workspace_location
|
||||
(state) => state.plot_control.workspace_location,
|
||||
);
|
||||
let t2 = useSelector(state => state.plot_control.t2);
|
||||
let t2 = useSelector((state) => state.plot_control.t2);
|
||||
const final_location = useSelector(
|
||||
state => state.plot_control.final_location
|
||||
(state) => state.plot_control.final_location,
|
||||
);
|
||||
const [plotSize, setPlotSize] = React.useState(32);
|
||||
const [plotCount, setPlotCount] = React.useState(1);
|
||||
const [maxRam, setMaxRam] = React.useState(3072);
|
||||
const [numThreads, setNumThreads] = React.useState(2);
|
||||
const [numBuckets, setNumBuckets] = React.useState(0);
|
||||
const [stripeSize, setStripeSize] = React.useState(65536);
|
||||
const [maxRam, setMaxRam] = React.useState(2000);
|
||||
|
||||
const changePlotSize = event => {
|
||||
const changePlotSize = (event) => {
|
||||
setPlotSize(event.target.value);
|
||||
for (let pso of plot_size_options) {
|
||||
if (pso.value === event.target.value) {
|
||||
@@ -344,25 +341,16 @@ const CreatePlot = () => {
|
||||
}
|
||||
}
|
||||
};
|
||||
const changePlotCount = event => {
|
||||
const changePlotCount = (event) => {
|
||||
setPlotCount(event.target.value);
|
||||
};
|
||||
const handleSetMaxRam = event => {
|
||||
const handleSetMaxRam = (event) => {
|
||||
setMaxRam(event.target.value);
|
||||
};
|
||||
const handleSetNumBuckets = event => {
|
||||
setNumBuckets(event.target.value);
|
||||
};
|
||||
const handleSetNumThreads = event => {
|
||||
setNumThreads(event.target.value);
|
||||
};
|
||||
const handleSetStripeSize = event => {
|
||||
setStripeSize(event.target.value);
|
||||
};
|
||||
|
||||
function create() {
|
||||
if (!work_location || !final_location) {
|
||||
dispatch(openDialog("Please specify a temporary and final directory"));
|
||||
dispatch(openDialog('Please specify a temporary and final directory'));
|
||||
return;
|
||||
}
|
||||
const N = plotCount;
|
||||
@@ -370,11 +358,11 @@ const CreatePlot = () => {
|
||||
if (!t2 || t2 === "") {
|
||||
t2 = work_location;
|
||||
}
|
||||
dispatch(startPlotting(K, N, work_location, t2, final_location, maxRam, numBuckets, numThreads, stripeSize));
|
||||
dispatch(startPlotting(K, N, work_location, t2, final_location, maxRam));
|
||||
}
|
||||
|
||||
var plot_count_options = [];
|
||||
for (var i = 1; i < 30; i++) {
|
||||
const plot_count_options = [];
|
||||
for (let i = 1; i < 30; i++) {
|
||||
plot_count_options.push(i);
|
||||
}
|
||||
|
||||
@@ -390,7 +378,7 @@ const CreatePlot = () => {
|
||||
</Grid>
|
||||
<Grid className={classes.cardTitle} item xs={12}>
|
||||
<p>
|
||||
{" "}
|
||||
{' '}
|
||||
Using this tool, you can create plots, which are allocated space on
|
||||
your hard drive used to farm and earn Chia. Also, temporary files
|
||||
are created during the plotting process, which exceed the size of
|
||||
@@ -414,12 +402,12 @@ const CreatePlot = () => {
|
||||
onChange={changePlotSize}
|
||||
label="Plot Size"
|
||||
>
|
||||
{plot_size_options.map(option => (
|
||||
{plot_size_options.map((option) => (
|
||||
<MenuItem
|
||||
value={option.value}
|
||||
key={"size" + option.value}
|
||||
key={`size${option.value}`}
|
||||
>
|
||||
{option.label} (k={option.value}, temporary space:{" "}
|
||||
{option.label} (k={option.value}, temporary space:{' '}
|
||||
{option.workspace})
|
||||
</MenuItem>
|
||||
))}
|
||||
@@ -438,8 +426,8 @@ const CreatePlot = () => {
|
||||
onChange={changePlotCount}
|
||||
label="Colour"
|
||||
>
|
||||
{plot_count_options.map(option => (
|
||||
<MenuItem value={option} key={"count" + option}>
|
||||
{plot_count_options.map((option) => (
|
||||
<MenuItem value={option} key={`count${option}`}>
|
||||
{option}
|
||||
</MenuItem>
|
||||
))}
|
||||
@@ -468,60 +456,10 @@ const CreatePlot = () => {
|
||||
</FormControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={4}>
|
||||
<FormControl
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
className={classes.formControl}
|
||||
>
|
||||
<InputLabel>Number of threads</InputLabel>
|
||||
<Input
|
||||
value={numThreads}
|
||||
onChange={handleSetNumThreads}
|
||||
label="Colour"
|
||||
type="number"
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<FormControl
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
className={classes.formControl}
|
||||
>
|
||||
<InputLabel>Number of buckets</InputLabel>
|
||||
<Input
|
||||
value={numBuckets}
|
||||
onChange={handleSetNumBuckets}
|
||||
label="Colour"
|
||||
type="number"
|
||||
/>
|
||||
<FormHelperText id="standard-weight-helper-text">
|
||||
0 automatically chooses bucket count
|
||||
</FormHelperText>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
<Grid item xs={4}>
|
||||
<FormControl
|
||||
fullWidth
|
||||
variant="outlined"
|
||||
className={classes.formControl}
|
||||
>
|
||||
<InputLabel>Stripe Size</InputLabel>
|
||||
<Input
|
||||
value={stripeSize}
|
||||
onChange={handleSetStripeSize}
|
||||
label="Colour"
|
||||
type="number"
|
||||
/>
|
||||
</FormControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</div>
|
||||
</Grid>
|
||||
<WorkLocation></WorkLocation>
|
||||
<FinalLocation></FinalLocation>
|
||||
<WorkLocation />
|
||||
<FinalLocation />
|
||||
<Grid item xs={12}>
|
||||
<div className={classes.cardSubSection}>
|
||||
<Grid container spacing={2}>
|
||||
@@ -544,7 +482,7 @@ const CreatePlot = () => {
|
||||
};
|
||||
|
||||
const Proggress = () => {
|
||||
const progress = useSelector(state => state.plot_control.progress);
|
||||
const progress = useSelector((state) => state.plot_control.progress);
|
||||
const classes = useStyles();
|
||||
const dispatch = useDispatch();
|
||||
function clearLog() {
|
||||
@@ -554,7 +492,7 @@ const Proggress = () => {
|
||||
dispatch(stopService(service_plotter));
|
||||
}
|
||||
const plotting_stopped = useSelector(
|
||||
state => state.plot_control.plotting_stopped
|
||||
(state) => state.plot_control.plotting_stopped,
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
@@ -570,7 +508,7 @@ const Proggress = () => {
|
||||
</Box>
|
||||
</div>
|
||||
<div className={classes.cardSubSection}>
|
||||
{plotting_stopped ? <p>Plotting stopped succesfully.</p> : ""}
|
||||
{plotting_stopped ? <p>Plotting stopped succesfully.</p> : ''}
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12}>
|
||||
{!plotting_stopped ? (
|
||||
@@ -583,7 +521,7 @@ const Proggress = () => {
|
||||
Cancel
|
||||
</Button>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
)}
|
||||
<Button
|
||||
onClick={clearLog}
|
||||
@@ -603,15 +541,15 @@ const Proggress = () => {
|
||||
|
||||
const Plotter = () => {
|
||||
const in_progress = useSelector(
|
||||
state => state.plot_control.plotting_in_proggress
|
||||
(state) => state.plot_control.plotting_in_proggress,
|
||||
);
|
||||
const plotting_stopped = useSelector(
|
||||
state => state.plot_control.plotting_stopped
|
||||
(state) => state.plot_control.plotting_stopped,
|
||||
);
|
||||
return (
|
||||
<div>
|
||||
<CreatePlot></CreatePlot>
|
||||
{in_progress || plotting_stopped ? <Proggress></Proggress> : <div></div>}
|
||||
<CreatePlot />
|
||||
{in_progress || plotting_stopped ? <Proggress /> : <div />}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,264 +1,264 @@
|
||||
import React from "react";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import React from 'react';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Paper from "@material-ui/core/Paper";
|
||||
import Box from "@material-ui/core/Box";
|
||||
import TextField from "@material-ui/core/TextField";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import Table from "@material-ui/core/Table";
|
||||
import TableBody from "@material-ui/core/TableBody";
|
||||
import TableCell from "@material-ui/core/TableCell";
|
||||
import TableHead from "@material-ui/core/TableHead";
|
||||
import TableRow from "@material-ui/core/TableRow";
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Paper from '@material-ui/core/Paper';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import TextField from '@material-ui/core/TextField';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import Table from '@material-ui/core/Table';
|
||||
import TableBody from '@material-ui/core/TableBody';
|
||||
import TableCell from '@material-ui/core/TableCell';
|
||||
import TableHead from '@material-ui/core/TableHead';
|
||||
import TableRow from '@material-ui/core/TableRow';
|
||||
|
||||
import { send_transaction, rl_set_user_info_action } from "../modules/message";
|
||||
import Accordion from "@material-ui/core/Accordion";
|
||||
import AccordionSummary from "@material-ui/core/AccordionSummary";
|
||||
import AccordionDetails from "@material-ui/core/AccordionDetails";
|
||||
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
|
||||
import { Tooltip } from "@material-ui/core";
|
||||
import HelpIcon from "@material-ui/icons/Help";
|
||||
import { mojo_to_chia_string, chia_to_mojo } from "../util/chia";
|
||||
import { get_transaction_result } from "../util/transaction_result";
|
||||
import { unix_to_short_date } from "../util/utils";
|
||||
import Accordion from '@material-ui/core/Accordion';
|
||||
import AccordionSummary from '@material-ui/core/AccordionSummary';
|
||||
import AccordionDetails from '@material-ui/core/AccordionDetails';
|
||||
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
||||
import { Tooltip } from '@material-ui/core';
|
||||
import HelpIcon from '@material-ui/icons/Help';
|
||||
import { send_transaction, rl_set_user_info_action } from '../modules/message';
|
||||
import { mojo_to_chia_string, chia_to_mojo } from '../util/chia';
|
||||
import { get_transaction_result } from '../util/transaction_result';
|
||||
import { unix_to_short_date } from '../util/utils';
|
||||
|
||||
import { openDialog } from "../modules/dialog";
|
||||
import { openDialog } from '../modules/dialog';
|
||||
|
||||
const drawerWidth = 240;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
front: {
|
||||
zIndex: "100"
|
||||
zIndex: '100',
|
||||
},
|
||||
root: {
|
||||
display: "flex",
|
||||
paddingLeft: "0px"
|
||||
display: 'flex',
|
||||
paddingLeft: '0px',
|
||||
},
|
||||
resultSuccess: {
|
||||
color: "green"
|
||||
color: 'green',
|
||||
},
|
||||
resultFailure: {
|
||||
color: "red"
|
||||
color: 'red',
|
||||
},
|
||||
toolbar: {
|
||||
paddingRight: 24 // keep right padding when drawer closed
|
||||
paddingRight: 24, // keep right padding when drawer closed
|
||||
},
|
||||
toolbarIcon: {
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "flex-end",
|
||||
padding: "0 8px",
|
||||
...theme.mixins.toolbar
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'flex-end',
|
||||
padding: '0 8px',
|
||||
...theme.mixins.toolbar,
|
||||
},
|
||||
appBar: {
|
||||
zIndex: theme.zIndex.drawer + 1,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
transition: theme.transitions.create(['width', 'margin'], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
})
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
},
|
||||
appBarShift: {
|
||||
marginLeft: drawerWidth,
|
||||
width: `calc(100% - ${drawerWidth}px)`,
|
||||
transition: theme.transitions.create(["width", "margin"], {
|
||||
transition: theme.transitions.create(['width', 'margin'], {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
drawerPaperClose: {
|
||||
overflowX: "hidden",
|
||||
transition: theme.transitions.create("width", {
|
||||
overflowX: 'hidden',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
width: theme.spacing(7),
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: theme.spacing(9)
|
||||
}
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: theme.spacing(9),
|
||||
},
|
||||
},
|
||||
appBarSpacer: theme.mixins.toolbar,
|
||||
content: {
|
||||
flexGrow: 1,
|
||||
height: "100vh",
|
||||
overflow: "auto"
|
||||
height: '100vh',
|
||||
overflow: 'auto',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(0),
|
||||
paddingBottom: theme.spacing(0),
|
||||
paddingRight: theme.spacing(0)
|
||||
paddingRight: theme.spacing(0),
|
||||
},
|
||||
paper: {
|
||||
marginTop: theme.spacing(2),
|
||||
padding: theme.spacing(2),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
balancePaper: {
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
sendButton: {
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(2),
|
||||
width: 150,
|
||||
height: 50
|
||||
height: 50,
|
||||
},
|
||||
clawbackButton: {
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(2),
|
||||
width: 200,
|
||||
height: 50
|
||||
height: 50,
|
||||
},
|
||||
copyButton: {
|
||||
marginTop: theme.spacing(0),
|
||||
marginBottom: theme.spacing(0),
|
||||
width: 70,
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
cardTitle: {
|
||||
paddingLeft: theme.spacing(1),
|
||||
paddingTop: theme.spacing(1),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
cardSubSection: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingTop: theme.spacing(1)
|
||||
paddingTop: theme.spacing(1),
|
||||
},
|
||||
setupSection: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingTop: theme.spacing(3),
|
||||
paddingBottom: theme.spacing(1)
|
||||
paddingBottom: theme.spacing(1),
|
||||
},
|
||||
setupTitle: {
|
||||
paddingLeft: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
paddingTop: theme.spacing(2),
|
||||
paddingBottom: theme.spacing(0)
|
||||
paddingBottom: theme.spacing(0),
|
||||
},
|
||||
inputLeft: {
|
||||
marginLeft: theme.spacing(3),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
inputRight: {
|
||||
marginRight: theme.spacing(3),
|
||||
marginLeft: theme.spacing(6),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
inputTitleLeft: {
|
||||
marginLeft: theme.spacing(0),
|
||||
marginBottom: theme.spacing(0),
|
||||
width: 400
|
||||
width: 400,
|
||||
},
|
||||
inputTitleRight: {
|
||||
marginLeft: theme.spacing(3),
|
||||
width: 400
|
||||
width: 400,
|
||||
},
|
||||
walletContainer: {
|
||||
marginBottom: theme.spacing(5)
|
||||
marginBottom: theme.spacing(5),
|
||||
},
|
||||
table_root: {
|
||||
width: "100%",
|
||||
width: '100%',
|
||||
maxHeight: 600,
|
||||
overflowY: "scroll",
|
||||
overflowY: 'scroll',
|
||||
padding: theme.spacing(1),
|
||||
margin: theme.spacing(1),
|
||||
marginBottom: theme.spacing(2),
|
||||
marginTop: theme.spacing(2),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
table: {
|
||||
height: "100%",
|
||||
overflowY: "scroll"
|
||||
height: '100%',
|
||||
overflowY: 'scroll',
|
||||
},
|
||||
tableBody: {
|
||||
height: "100%",
|
||||
overflowY: "scroll"
|
||||
height: '100%',
|
||||
overflowY: 'scroll',
|
||||
},
|
||||
row: {
|
||||
width: 700
|
||||
width: 700,
|
||||
},
|
||||
cell_short: {
|
||||
fontSize: "14px",
|
||||
fontSize: '14px',
|
||||
width: 50,
|
||||
overflowWrap: "break-word" /* Renamed property in CSS3 draft spec */
|
||||
overflowWrap: 'break-word' /* Renamed property in CSS3 draft spec */,
|
||||
},
|
||||
leftField: {
|
||||
paddingRight: 20
|
||||
paddingRight: 20,
|
||||
},
|
||||
submitButton: {
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(2),
|
||||
width: 150,
|
||||
height: 50
|
||||
}
|
||||
height: 50,
|
||||
},
|
||||
}));
|
||||
|
||||
const IncompleteCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const IncompleteCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const data = useSelector(state => state.wallet_state.wallets[id].data);
|
||||
const data = useSelector((state) => state.wallet_state.wallets[id].data);
|
||||
const data_parsed = JSON.parse(data);
|
||||
const pubkey = data_parsed["user_pubkey"];
|
||||
const pubkey = data_parsed.user_pubkey;
|
||||
|
||||
function copy() {
|
||||
navigator.clipboard.writeText(pubkey);
|
||||
}
|
||||
|
||||
var ip_input = null;
|
||||
let ip_input = null;
|
||||
|
||||
function submit() {
|
||||
const ip_val = ip_input.value;
|
||||
const hexcheck = /[0-9a-f]+$/gi;
|
||||
|
||||
if (!hexcheck.test(ip_val) || ip_val.value === "") {
|
||||
dispatch(openDialog("Please enter a valid info packet"));
|
||||
if (!hexcheck.test(ip_val) || ip_val.value === '') {
|
||||
dispatch(openDialog('Please enter a valid info packet'));
|
||||
return;
|
||||
}
|
||||
|
||||
const ip_unhex = Buffer.from(ip_val, "hex");
|
||||
const ip_debuf = ip_unhex.toString("utf8");
|
||||
const ip_unhex = Buffer.from(ip_val, 'hex');
|
||||
const ip_debuf = ip_unhex.toString('utf8');
|
||||
const ip_parsed = JSON.parse(ip_debuf);
|
||||
const interval_input = ip_parsed["interval"];
|
||||
const chiaper_input = ip_parsed["limit"];
|
||||
const origin_input = ip_parsed["origin_string"];
|
||||
const admin_pubkey_input = ip_parsed["admin_pubkey"];
|
||||
const interval_input = ip_parsed.interval;
|
||||
const chiaper_input = ip_parsed.limit;
|
||||
const origin_input = ip_parsed.origin_string;
|
||||
const admin_pubkey_input = ip_parsed.admin_pubkey;
|
||||
const interval_value = parseInt(Number(interval_input));
|
||||
const chiaper_value = parseInt(Number(chiaper_input));
|
||||
const origin_parsed = JSON.parse(origin_input);
|
||||
@@ -268,8 +268,8 @@ const IncompleteCard = props => {
|
||||
interval_value,
|
||||
chiaper_value,
|
||||
origin_parsed,
|
||||
admin_pubkey_input
|
||||
)
|
||||
admin_pubkey_input,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ const IncompleteCard = props => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
ip_input = input;
|
||||
}}
|
||||
margin="normal"
|
||||
@@ -366,28 +366,28 @@ const IncompleteCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const RLDetailsCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const RLDetailsCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
|
||||
const data = useSelector(state => state.wallet_state.wallets[id].data);
|
||||
const data = useSelector((state) => state.wallet_state.wallets[id].data);
|
||||
const data_parsed = JSON.parse(data);
|
||||
const type = data_parsed["type"];
|
||||
const user_pubkey = data_parsed["user_pubkey"];
|
||||
const admin_pubkey = data_parsed["admin_pubkey"];
|
||||
const interval = data_parsed["interval"];
|
||||
const limit = data_parsed["limit"];
|
||||
const origin = data_parsed["rl_origin"];
|
||||
const { type } = data_parsed;
|
||||
const { user_pubkey } = data_parsed;
|
||||
const { admin_pubkey } = data_parsed;
|
||||
const { interval } = data_parsed;
|
||||
const { limit } = data_parsed;
|
||||
const origin = data_parsed.rl_origin;
|
||||
const origin_string = JSON.stringify(origin);
|
||||
const infopacket = {
|
||||
interval: interval,
|
||||
limit: limit,
|
||||
origin_string: origin_string,
|
||||
admin_pubkey: admin_pubkey
|
||||
interval,
|
||||
limit,
|
||||
origin_string,
|
||||
admin_pubkey,
|
||||
};
|
||||
|
||||
const ip_string = JSON.stringify(infopacket);
|
||||
const ip_buf = Buffer.from(ip_string, "utf8");
|
||||
const ip_hex = ip_buf.toString("hex");
|
||||
const ip_buf = Buffer.from(ip_string, 'utf8');
|
||||
const ip_hex = ip_buf.toString('hex');
|
||||
|
||||
function user_copy() {
|
||||
navigator.clipboard.writeText(user_pubkey);
|
||||
@@ -398,7 +398,7 @@ const RLDetailsCard = props => {
|
||||
}
|
||||
|
||||
const classes = useStyles();
|
||||
if (type === "user") {
|
||||
if (type === 'user') {
|
||||
return (
|
||||
<Paper className={classes.paper}>
|
||||
<Grid container spacing={0}>
|
||||
@@ -419,7 +419,7 @@ const RLDetailsCard = props => {
|
||||
</Box>
|
||||
<Box flexGrow={1}>
|
||||
<Typography variant="subtitle1">
|
||||
Spending Limit (chia per interval):{" "}
|
||||
Spending Limit (chia per interval):{' '}
|
||||
{mojo_to_chia_string(limit)}
|
||||
</Typography>
|
||||
</Box>
|
||||
@@ -455,7 +455,8 @@ const RLDetailsCard = props => {
|
||||
</Grid>
|
||||
</Paper>
|
||||
);
|
||||
} else if (type === "admin") {
|
||||
}
|
||||
if (type === 'admin') {
|
||||
return (
|
||||
<Paper className={classes.paper}>
|
||||
<Grid container spacing={0}>
|
||||
@@ -476,7 +477,7 @@ const RLDetailsCard = props => {
|
||||
</Box>
|
||||
<Box flexGrow={1}>
|
||||
<Typography variant="subtitle1">
|
||||
Spending Limit (chia per interval):{" "}
|
||||
Spending Limit (chia per interval):{' '}
|
||||
{mojo_to_chia_string(limit)}
|
||||
</Typography>
|
||||
</Box>
|
||||
@@ -523,7 +524,7 @@ const RLDetailsCard = props => {
|
||||
}
|
||||
};
|
||||
|
||||
const BalanceCardSubSection = props => {
|
||||
const BalanceCardSubSection = (props) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Grid item xs={12}>
|
||||
@@ -534,12 +535,10 @@ const BalanceCardSubSection = props => {
|
||||
{props.title}
|
||||
{props.tooltip ? (
|
||||
<Tooltip title={props.tooltip}>
|
||||
<HelpIcon
|
||||
style={{ color: "#c8c8c8", fontSize: 12 }}
|
||||
></HelpIcon>
|
||||
<HelpIcon style={{ color: '#c8c8c8', fontSize: 12 }} />
|
||||
</Tooltip>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
)}
|
||||
</Typography>
|
||||
</Box>
|
||||
@@ -554,19 +553,19 @@ const BalanceCardSubSection = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const BalanceCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const BalanceCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
const balance = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_total
|
||||
(state) => state.wallet_state.wallets[id].balance_total,
|
||||
);
|
||||
var balance_spendable = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_spendable
|
||||
const balance_spendable = useSelector(
|
||||
(state) => state.wallet_state.wallets[id].balance_spendable,
|
||||
);
|
||||
const balance_pending = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_pending
|
||||
(state) => state.wallet_state.wallets[id].balance_pending,
|
||||
);
|
||||
const balance_change = useSelector(
|
||||
state => state.wallet_state.wallets[id].balance_change
|
||||
(state) => state.wallet_state.wallets[id].balance_change,
|
||||
);
|
||||
const balance_ptotal = balance + balance_pending;
|
||||
const classes = useStyles();
|
||||
@@ -589,7 +588,7 @@ const BalanceCard = props => {
|
||||
<BalanceCardSubSection
|
||||
title="Spendable Balance"
|
||||
balance={balance_spendable}
|
||||
tooltip={""}
|
||||
tooltip=""
|
||||
/>
|
||||
<Grid item xs={12}>
|
||||
<div className={classes.cardSubSection}>
|
||||
@@ -610,17 +609,17 @@ const BalanceCard = props => {
|
||||
<BalanceCardSubSection
|
||||
title="Pending Total Balance"
|
||||
balance={balance_ptotal}
|
||||
tooltip={""}
|
||||
tooltip=""
|
||||
/>
|
||||
<BalanceCardSubSection
|
||||
title="Pending Balance"
|
||||
balance={balance_pending}
|
||||
tooltip={""}
|
||||
tooltip=""
|
||||
/>
|
||||
<BalanceCardSubSection
|
||||
title="Pending Change"
|
||||
balance={balance_change}
|
||||
tooltip={""}
|
||||
tooltip=""
|
||||
/>
|
||||
</Grid>
|
||||
</AccordionDetails>
|
||||
@@ -634,26 +633,26 @@ const BalanceCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const SendCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const SendCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
const classes = useStyles();
|
||||
var address_input = null;
|
||||
var amount_input = null;
|
||||
var fee_input = null;
|
||||
let address_input = null;
|
||||
let amount_input = null;
|
||||
let fee_input = null;
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const sending_transaction = useSelector(
|
||||
state => state.wallet_state.wallets[id].sending_transaction
|
||||
(state) => state.wallet_state.wallets[id].sending_transaction,
|
||||
);
|
||||
const syncing = useSelector(state => state.wallet_state.status.syncing);
|
||||
const syncing = useSelector((state) => state.wallet_state.status.syncing);
|
||||
|
||||
const send_transaction_result = useSelector(
|
||||
state => state.wallet_state.wallets[id].send_transaction_result
|
||||
(state) => state.wallet_state.wallets[id].send_transaction_result,
|
||||
);
|
||||
|
||||
const result = get_transaction_result(send_transaction_result);
|
||||
let result_message = result.message;
|
||||
let result_class = result.success
|
||||
const result_message = result.message;
|
||||
const result_class = result.success
|
||||
? classes.resultSuccess
|
||||
: classes.resultFailure;
|
||||
|
||||
@@ -662,27 +661,27 @@ const SendCard = props => {
|
||||
return;
|
||||
}
|
||||
if (syncing) {
|
||||
dispatch(openDialog("Please finish syncing before making a transaction"));
|
||||
dispatch(openDialog('Please finish syncing before making a transaction'));
|
||||
return;
|
||||
}
|
||||
let address = address_input.value.trim();
|
||||
if (
|
||||
amount_input.value === "" ||
|
||||
amount_input.value === '' ||
|
||||
Number(amount_input.value) === 0 ||
|
||||
!Number(amount_input.value) ||
|
||||
isNaN(Number(amount_input.value))
|
||||
) {
|
||||
dispatch(openDialog("Please enter a valid numeric amount"));
|
||||
dispatch(openDialog('Please enter a valid numeric amount'));
|
||||
return;
|
||||
}
|
||||
if (fee_input.value === "" || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog("Please enter a valid numeric fee"));
|
||||
if (fee_input.value === '' || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog('Please enter a valid numeric fee'));
|
||||
return;
|
||||
}
|
||||
const amount = chia_to_mojo(amount_input.value);
|
||||
const fee = chia_to_mojo(fee_input.value);
|
||||
|
||||
if (address.startsWith("0x") || address.startsWith("0X")) {
|
||||
if (address.startsWith('0x') || address.startsWith('0X')) {
|
||||
address = address.substring(2);
|
||||
}
|
||||
|
||||
@@ -691,16 +690,16 @@ const SendCard = props => {
|
||||
if (fee_value !== 0) {
|
||||
dispatch(
|
||||
openDialog(
|
||||
"Please enter 0 fee. Positive fees not supported yet for RL."
|
||||
)
|
||||
'Please enter 0 fee. Positive fees not supported yet for RL.',
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(send_transaction(id, amount_value, fee_value, address));
|
||||
address_input.value = "";
|
||||
amount_input.value = "";
|
||||
fee_input.value = "";
|
||||
address_input.value = '';
|
||||
amount_input.value = '';
|
||||
fee_input.value = '';
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -727,13 +726,13 @@ const SendCard = props => {
|
||||
color="secondary"
|
||||
fullWidth
|
||||
disabled={sending_transaction}
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
address_input = input;
|
||||
}}
|
||||
label="Address / Puzzle hash"
|
||||
/>
|
||||
</Box>
|
||||
<Box></Box>
|
||||
<Box />
|
||||
</Box>
|
||||
</div>
|
||||
</Grid>
|
||||
@@ -748,7 +747,7 @@ const SendCard = props => {
|
||||
disabled={sending_transaction}
|
||||
className={classes.leftField}
|
||||
margin="normal"
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
amount_input = input;
|
||||
}}
|
||||
label="Amount"
|
||||
@@ -761,7 +760,7 @@ const SendCard = props => {
|
||||
color="secondary"
|
||||
margin="normal"
|
||||
disabled={sending_transaction}
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
fee_input = input;
|
||||
}}
|
||||
label="Fee"
|
||||
@@ -841,8 +840,8 @@ const SendCard = props => {
|
||||
// );
|
||||
// };
|
||||
|
||||
const HistoryCard = props => {
|
||||
var id = props.wallet_id;
|
||||
const HistoryCard = (props) => {
|
||||
const id = props.wallet_id;
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<Paper className={classes.paper}>
|
||||
@@ -862,26 +861,25 @@ const HistoryCard = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const TransactionTable = props => {
|
||||
const TransactionTable = (props) => {
|
||||
const classes = useStyles();
|
||||
var id = props.wallet_id;
|
||||
const id = props.wallet_id;
|
||||
const transactions = useSelector(
|
||||
state => state.wallet_state.wallets[id].transactions
|
||||
(state) => state.wallet_state.wallets[id].transactions,
|
||||
);
|
||||
|
||||
if (transactions.length === 0) {
|
||||
return <div style={{ margin: "30px" }}>No previous transactions</div>;
|
||||
return <div style={{ margin: '30px' }}>No previous transactions</div>;
|
||||
}
|
||||
|
||||
const incoming_string = incoming => {
|
||||
const incoming_string = (incoming) => {
|
||||
if (incoming) {
|
||||
return "Incoming";
|
||||
} else {
|
||||
return "Outgoing";
|
||||
return 'Incoming';
|
||||
}
|
||||
return 'Outgoing';
|
||||
};
|
||||
const confirmed_to_string = confirmed => {
|
||||
return confirmed ? "Confirmed" : "Pending";
|
||||
const confirmed_to_string = (confirmed) => {
|
||||
return confirmed ? 'Confirmed' : 'Pending';
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -898,7 +896,7 @@ const TransactionTable = props => {
|
||||
</TableRow>
|
||||
</TableHead>
|
||||
<TableBody className={classes.tableBody}>
|
||||
{transactions.map(tx => (
|
||||
{transactions.map((tx) => (
|
||||
<TableRow
|
||||
className={classes.row}
|
||||
key={tx.to_address + tx.created_at_time + tx.amount}
|
||||
@@ -907,7 +905,7 @@ const TransactionTable = props => {
|
||||
{incoming_string(tx.incoming)}
|
||||
</TableCell>
|
||||
<TableCell
|
||||
style={{ maxWidth: "150px" }}
|
||||
style={{ maxWidth: '150px' }}
|
||||
className={classes.cell_short}
|
||||
>
|
||||
{tx.to_address}
|
||||
@@ -932,44 +930,44 @@ const TransactionTable = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const RateLimitedWallet = props => {
|
||||
const RateLimitedWallet = (props) => {
|
||||
const classes = useStyles();
|
||||
const id = useSelector(state => state.wallet_menu.id);
|
||||
const wallets = useSelector(state => state.wallet_state.wallets);
|
||||
const data = useSelector(state => state.wallet_state.wallets[id].data);
|
||||
const id = useSelector((state) => state.wallet_menu.id);
|
||||
const wallets = useSelector((state) => state.wallet_state.wallets);
|
||||
const data = useSelector((state) => state.wallet_state.wallets[id].data);
|
||||
const data_parsed = JSON.parse(data);
|
||||
const type = data_parsed["type"];
|
||||
var init_status = data_parsed["initialized"];
|
||||
const { type } = data_parsed;
|
||||
const init_status = data_parsed.initialized;
|
||||
|
||||
if (type === "user") {
|
||||
if (type === 'user') {
|
||||
if (init_status) {
|
||||
return wallets.length > props.wallet_id ? (
|
||||
<Grid className={classes.walletContainer} item xs={12}>
|
||||
<RLDetailsCard wallet_id={id}></RLDetailsCard>
|
||||
<BalanceCard wallet_id={id}></BalanceCard>
|
||||
<SendCard wallet_id={id}></SendCard>
|
||||
<HistoryCard wallet_id={id}></HistoryCard>
|
||||
<RLDetailsCard wallet_id={id} />
|
||||
<BalanceCard wallet_id={id} />
|
||||
<SendCard wallet_id={id} />
|
||||
<HistoryCard wallet_id={id} />
|
||||
</Grid>
|
||||
) : (
|
||||
""
|
||||
);
|
||||
} else {
|
||||
return wallets.length > props.wallet_id ? (
|
||||
<Grid className={classes.walletContainer} item xs={12}>
|
||||
<IncompleteCard wallet_id={id}></IncompleteCard>
|
||||
</Grid>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
);
|
||||
}
|
||||
} else if (type === "admin") {
|
||||
return wallets.length > props.wallet_id ? (
|
||||
<Grid className={classes.walletContainer} item xs={12}>
|
||||
<RLDetailsCard wallet_id={id}></RLDetailsCard>
|
||||
<BalanceCard wallet_id={id}></BalanceCard>
|
||||
<IncompleteCard wallet_id={id} />
|
||||
</Grid>
|
||||
) : (
|
||||
""
|
||||
''
|
||||
);
|
||||
}
|
||||
if (type === 'admin') {
|
||||
return wallets.length > props.wallet_id ? (
|
||||
<Grid className={classes.walletContainer} item xs={12}>
|
||||
<RLDetailsCard wallet_id={id} />
|
||||
<BalanceCard wallet_id={id} />
|
||||
</Grid>
|
||||
) : (
|
||||
''
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,109 +1,110 @@
|
||||
import React from "react";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
import List from "@material-ui/core/List";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import { Tooltip } from "@material-ui/core";
|
||||
import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction";
|
||||
import DeleteIcon from "@material-ui/icons/Delete";
|
||||
import IconButton from "@material-ui/core/IconButton";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import logo from "../assets/img/chia_logo.svg"; // Tell webpack this JS file uses this image
|
||||
import { withRouter } from "react-router-dom";
|
||||
import { useSelector, useDispatch } from "react-redux";
|
||||
import React from 'react';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import List from '@material-ui/core/List';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import { Tooltip } from '@material-ui/core';
|
||||
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
|
||||
import DeleteIcon from '@material-ui/icons/Delete';
|
||||
import IconButton from '@material-ui/core/IconButton';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import Link from '@material-ui/core/Link';
|
||||
import Button from '@material-ui/core/Button';
|
||||
import VisibilityIcon from '@material-ui/icons/Visibility';
|
||||
import Dialog from '@material-ui/core/Dialog';
|
||||
import DialogActions from '@material-ui/core/DialogActions';
|
||||
import DialogContent from '@material-ui/core/DialogContent';
|
||||
import DialogContentText from '@material-ui/core/DialogContentText';
|
||||
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||
import {
|
||||
delete_all_keys,
|
||||
login_action,
|
||||
delete_key,
|
||||
get_private_key,
|
||||
selectFingerprint
|
||||
} from "../modules/message";
|
||||
import Link from "@material-ui/core/Link";
|
||||
import Button from "@material-ui/core/Button";
|
||||
import VisibilityIcon from "@material-ui/icons/Visibility";
|
||||
import { delete_all_keys } from "../modules/message";
|
||||
import Dialog from "@material-ui/core/Dialog";
|
||||
import DialogActions from "@material-ui/core/DialogActions";
|
||||
import DialogContent from "@material-ui/core/DialogContent";
|
||||
import DialogContentText from "@material-ui/core/DialogContentText";
|
||||
import DialogTitle from "@material-ui/core/DialogTitle";
|
||||
selectFingerprint,
|
||||
} from '../modules/message';
|
||||
|
||||
import logo from '../assets/img/chia_logo.svg'; // Tell webpack this JS file uses this image
|
||||
import {
|
||||
changeEntranceMenu,
|
||||
presentOldWallet,
|
||||
presentNewWallet
|
||||
} from "../modules/entranceMenu";
|
||||
import { resetMnemonic } from "../modules/mnemonic_input";
|
||||
presentNewWallet,
|
||||
} from '../modules/entranceMenu';
|
||||
import { resetMnemonic } from '../modules/mnemonic_input';
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
background: "linear-gradient(45deg, #181818 30%, #333333 90%)",
|
||||
height: "100%"
|
||||
background: 'linear-gradient(45deg, #181818 30%, #333333 90%)',
|
||||
height: '100%',
|
||||
},
|
||||
paper: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
height: "100%"
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
height: '100%',
|
||||
},
|
||||
centeredSpan: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center"
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
},
|
||||
textField: {
|
||||
borderColor: "#ffffff"
|
||||
borderColor: '#ffffff',
|
||||
},
|
||||
topButton: {
|
||||
width: 400,
|
||||
height: 45,
|
||||
marginTop: theme.spacing(4),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
bottomButton: {
|
||||
width: 400,
|
||||
height: 45,
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
bottomButtonRed: {
|
||||
width: 400,
|
||||
height: 45,
|
||||
marginTop: theme.spacing(2),
|
||||
marginBottom: theme.spacing(1),
|
||||
color: "red"
|
||||
color: 'red',
|
||||
},
|
||||
logo: {
|
||||
marginTop: theme.spacing(8),
|
||||
marginBottom: theme.spacing(3)
|
||||
marginBottom: theme.spacing(3),
|
||||
},
|
||||
main: {
|
||||
height: "100%"
|
||||
height: '100%',
|
||||
},
|
||||
whiteText: {
|
||||
color: "white"
|
||||
color: 'white',
|
||||
},
|
||||
whiteP: {
|
||||
color: "white",
|
||||
fontSize: "18px"
|
||||
color: 'white',
|
||||
fontSize: '18px',
|
||||
},
|
||||
demo: {
|
||||
backgroundColor: theme.palette.background.paper
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
},
|
||||
rightPadding: {
|
||||
paddingRight: theme.spacing(3)
|
||||
}
|
||||
paddingRight: theme.spacing(3),
|
||||
},
|
||||
}));
|
||||
|
||||
const SelectKey = () => {
|
||||
const dispatch = useDispatch();
|
||||
const classes = useStyles();
|
||||
const public_key_fingerprints = useSelector(
|
||||
state => state.wallet_state.public_key_fingerprints
|
||||
(state) => state.wallet_state.public_key_fingerprints,
|
||||
);
|
||||
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
const handleClick = fingerprint => {
|
||||
const handleClick = (fingerprint) => {
|
||||
return () => {
|
||||
dispatch(resetMnemonic());
|
||||
dispatch(selectFingerprint(fingerprint));
|
||||
@@ -124,11 +125,11 @@ const SelectKey = () => {
|
||||
dispatch(delete_all_keys());
|
||||
};
|
||||
|
||||
const showKey = fingerprint => {
|
||||
const showKey = (fingerprint) => {
|
||||
return () => dispatch(get_private_key(fingerprint));
|
||||
};
|
||||
|
||||
const handleDelete = fingerprint => {
|
||||
const handleDelete = (fingerprint) => {
|
||||
return () => dispatch(delete_key(fingerprint));
|
||||
};
|
||||
|
||||
@@ -140,7 +141,7 @@ const SelectKey = () => {
|
||||
dispatch(changeEntranceMenu(presentNewWallet));
|
||||
};
|
||||
|
||||
const list_items = public_key_fingerprints.map(fingerprint => {
|
||||
const list_items = public_key_fingerprints.map((fingerprint) => {
|
||||
return (
|
||||
<ListItem
|
||||
button
|
||||
@@ -149,10 +150,8 @@ const SelectKey = () => {
|
||||
>
|
||||
<ListItemText
|
||||
className={classes.rightPadding}
|
||||
primary={
|
||||
"Private key with public fingerprint " + fingerprint.toString()
|
||||
}
|
||||
secondary={"Can be backed up to mnemonic seed"}
|
||||
primary={`Private key with public fingerprint ${fingerprint.toString()}`}
|
||||
secondary="Can be backed up to mnemonic seed"
|
||||
/>
|
||||
<ListItemSecondaryAction>
|
||||
<Tooltip title="See private key">
|
||||
@@ -239,7 +238,7 @@ const SelectKey = () => {
|
||||
aria-labelledby="alert-dialog-title"
|
||||
aria-describedby="alert-dialog-description"
|
||||
>
|
||||
<DialogTitle id="alert-dialog-title">{"Delete all keys"}</DialogTitle>
|
||||
<DialogTitle id="alert-dialog-title">Delete all keys</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText id="alert-dialog-description">
|
||||
Deleting all keys will permanatly remove the keys from your
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from "react";
|
||||
import PropTypes from "prop-types";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
|
||||
export default function Title(props) {
|
||||
return (
|
||||
@@ -11,5 +11,5 @@ export default function Title(props) {
|
||||
}
|
||||
|
||||
Title.propTypes = {
|
||||
children: PropTypes.node
|
||||
children: PropTypes.node,
|
||||
};
|
||||
|
||||
@@ -1,135 +1,135 @@
|
||||
import React from "react";
|
||||
import CssBaseline from "@material-ui/core/CssBaseline";
|
||||
import Grid from "@material-ui/core/Grid";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import Container from "@material-ui/core/Container";
|
||||
import { withRouter, Redirect } from "react-router-dom";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import clsx from "clsx";
|
||||
import Drawer from "@material-ui/core/Drawer";
|
||||
import List from "@material-ui/core/List";
|
||||
import Typography from "@material-ui/core/Typography";
|
||||
import Divider from "@material-ui/core/Divider";
|
||||
import ListItem from "@material-ui/core/ListItem";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
import StandardWallet from "./StandardWallet";
|
||||
import Box from "@material-ui/core/Box";
|
||||
import React from 'react';
|
||||
import CssBaseline from '@material-ui/core/CssBaseline';
|
||||
import Grid from '@material-ui/core/Grid';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import Container from '@material-ui/core/Container';
|
||||
import { withRouter, Redirect } from 'react-router-dom';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import clsx from 'clsx';
|
||||
import Drawer from '@material-ui/core/Drawer';
|
||||
import List from '@material-ui/core/List';
|
||||
import Typography from '@material-ui/core/Typography';
|
||||
import Divider from '@material-ui/core/Divider';
|
||||
import ListItem from '@material-ui/core/ListItem';
|
||||
import ListItemText from '@material-ui/core/ListItemText';
|
||||
import Box from '@material-ui/core/Box';
|
||||
import StandardWallet from './StandardWallet';
|
||||
import {
|
||||
changeWalletMenu,
|
||||
createWallet,
|
||||
standardWallet,
|
||||
CCWallet,
|
||||
RLWallet
|
||||
} from "../modules/walletMenu";
|
||||
import { CreateWalletView } from "./CreateWallet";
|
||||
import ColouredWallet from "./ColouredWallet";
|
||||
import RateLimitedWallet from "./RateLimitedWallet";
|
||||
RLWallet,
|
||||
} from '../modules/walletMenu';
|
||||
import { CreateWalletView } from './CreateWallet';
|
||||
import ColouredWallet from './ColouredWallet';
|
||||
import RateLimitedWallet from './RateLimitedWallet';
|
||||
import {
|
||||
STANDARD_WALLET,
|
||||
COLOURED_COIN,
|
||||
RATE_LIMITED
|
||||
} from "../util/wallet_types";
|
||||
RATE_LIMITED,
|
||||
} from '../util/wallet_types';
|
||||
|
||||
const drawerWidth = 180;
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
display: "flex",
|
||||
paddingLeft: "0px"
|
||||
display: 'flex',
|
||||
paddingLeft: '0px',
|
||||
},
|
||||
menuButton: {
|
||||
marginRight: 36
|
||||
marginRight: 36,
|
||||
},
|
||||
menuButtonHidden: {
|
||||
display: "none"
|
||||
display: 'none',
|
||||
},
|
||||
title: {
|
||||
flexGrow: 1
|
||||
flexGrow: 1,
|
||||
},
|
||||
drawerPaper: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
transition: theme.transitions.create("width", {
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
drawerPaperClose: {
|
||||
overflowX: "hidden",
|
||||
transition: theme.transitions.create("width", {
|
||||
overflowX: 'hidden',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.leavingScreen
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
width: theme.spacing(7),
|
||||
[theme.breakpoints.up("sm")]: {
|
||||
width: theme.spacing(9)
|
||||
}
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: theme.spacing(9),
|
||||
},
|
||||
},
|
||||
content: {
|
||||
flexGrow: 1,
|
||||
height: "calc(100vh - 64px)",
|
||||
overflowX: "hidden"
|
||||
height: 'calc(100vh - 64px)',
|
||||
overflowX: 'hidden',
|
||||
},
|
||||
container: {
|
||||
paddingTop: theme.spacing(0),
|
||||
paddingBottom: theme.spacing(0),
|
||||
paddingRight: theme.spacing(0)
|
||||
paddingRight: theme.spacing(0),
|
||||
},
|
||||
paper: {
|
||||
padding: theme.spacing(0),
|
||||
display: "flex",
|
||||
overflow: "auto",
|
||||
flexDirection: "column"
|
||||
display: 'flex',
|
||||
overflow: 'auto',
|
||||
flexDirection: 'column',
|
||||
},
|
||||
fixedHeight: {
|
||||
height: 240
|
||||
height: 240,
|
||||
},
|
||||
drawerWallet: {
|
||||
position: "relative",
|
||||
whiteSpace: "nowrap",
|
||||
position: 'relative',
|
||||
whiteSpace: 'nowrap',
|
||||
width: drawerWidth,
|
||||
height: "100%",
|
||||
transition: theme.transitions.create("width", {
|
||||
height: '100%',
|
||||
transition: theme.transitions.create('width', {
|
||||
easing: theme.transitions.easing.sharp,
|
||||
duration: theme.transitions.duration.enteringScreen
|
||||
})
|
||||
duration: theme.transitions.duration.enteringScreen,
|
||||
}),
|
||||
},
|
||||
balancePaper: {
|
||||
height: 200,
|
||||
marginTop: theme.spacing(2)
|
||||
marginTop: theme.spacing(2),
|
||||
},
|
||||
bottomOptions: {
|
||||
position: "absolute",
|
||||
position: 'absolute',
|
||||
bottom: 0,
|
||||
width: "100%"
|
||||
}
|
||||
width: '100%',
|
||||
},
|
||||
}));
|
||||
|
||||
const WalletItem = props => {
|
||||
const WalletItem = (props) => {
|
||||
const dispatch = useDispatch();
|
||||
const id = props.wallet_id;
|
||||
|
||||
const wallet = useSelector(state => state.wallet_state.wallets[id]);
|
||||
var name = useSelector(state => state.wallet_state.wallets[id].name);
|
||||
const wallet = useSelector((state) => state.wallet_state.wallets[id]);
|
||||
let name = useSelector((state) => state.wallet_state.wallets[id].name);
|
||||
if (!name) {
|
||||
name = "";
|
||||
name = '';
|
||||
}
|
||||
var mainLabel = "";
|
||||
let mainLabel = '';
|
||||
if (wallet.type === STANDARD_WALLET) {
|
||||
mainLabel = "Chia Wallet";
|
||||
name = "Chia";
|
||||
mainLabel = 'Chia Wallet';
|
||||
name = 'Chia';
|
||||
} else if (wallet.type === COLOURED_COIN) {
|
||||
mainLabel = "CC Wallet";
|
||||
mainLabel = 'CC Wallet';
|
||||
if (name.length > 18) {
|
||||
name = name.substring(0, 18);
|
||||
name = name.concat("...");
|
||||
name = name.concat('...');
|
||||
}
|
||||
} else if (wallet.type === RATE_LIMITED) {
|
||||
mainLabel = "RL Wallet";
|
||||
mainLabel = 'RL Wallet';
|
||||
if (name.length > 18) {
|
||||
name = name.substring(0, 18);
|
||||
name = name.concat("...");
|
||||
name = name.concat('...');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,30 +151,33 @@ const WalletItem = props => {
|
||||
};
|
||||
|
||||
const WalletList = () => {
|
||||
const wallets = useSelector(state => state.wallet_state.wallets);
|
||||
const wallets = useSelector((state) => state.wallet_state.wallets);
|
||||
|
||||
return wallets.map(wallet => (
|
||||
return wallets.map((wallet) => (
|
||||
<span key={wallet.id}>
|
||||
<WalletItem wallet_id={wallet.id} key={wallet.id}></WalletItem>
|
||||
<WalletItem wallet_id={wallet.id} key={wallet.id} />
|
||||
<Divider />
|
||||
</span>
|
||||
));
|
||||
};
|
||||
|
||||
const WalletViewSwitch = () => {
|
||||
const toPresent = useSelector(state => state.wallet_menu.view);
|
||||
const id = useSelector(state => state.wallet_menu.id);
|
||||
const toPresent = useSelector((state) => state.wallet_menu.view);
|
||||
const id = useSelector((state) => state.wallet_menu.id);
|
||||
|
||||
if (toPresent === standardWallet) {
|
||||
return <StandardWallet wallet_id={id}></StandardWallet>;
|
||||
} else if (toPresent === createWallet) {
|
||||
return <CreateWalletView></CreateWalletView>;
|
||||
} else if (toPresent === CCWallet) {
|
||||
return <StandardWallet wallet_id={id} />;
|
||||
}
|
||||
if (toPresent === createWallet) {
|
||||
return <CreateWalletView />;
|
||||
}
|
||||
if (toPresent === CCWallet) {
|
||||
return <ColouredWallet wallet_id={id}> </ColouredWallet>;
|
||||
} else if (toPresent === RLWallet) {
|
||||
}
|
||||
if (toPresent === RLWallet) {
|
||||
return <RateLimitedWallet wallet_id={id}> </RateLimitedWallet>;
|
||||
}
|
||||
return <div></div>;
|
||||
return <div />;
|
||||
};
|
||||
|
||||
const CreateWallet = () => {
|
||||
@@ -187,20 +190,20 @@ const CreateWallet = () => {
|
||||
|
||||
return (
|
||||
<div className={classes.bottomOptions}>
|
||||
<Divider></Divider>
|
||||
<Divider />
|
||||
<ListItem button onClick={presentCreateWallet}>
|
||||
<ListItemText primary="Add Wallet" />
|
||||
</ListItem>
|
||||
<Divider></Divider>
|
||||
<Divider />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const StatusCard = () => {
|
||||
const syncing = useSelector(state => state.wallet_state.status.syncing);
|
||||
const height = useSelector(state => state.wallet_state.status.height);
|
||||
const syncing = useSelector((state) => state.wallet_state.status.syncing);
|
||||
const height = useSelector((state) => state.wallet_state.status.height);
|
||||
const connection_count = useSelector(
|
||||
state => state.wallet_state.status.connection_count
|
||||
(state) => state.wallet_state.status.connection_count,
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -211,7 +214,7 @@ export const StatusCard = () => {
|
||||
<div style={{ marginLeft: 8 }}>
|
||||
<Box display="flex">
|
||||
<Box flexGrow={1}>status:</Box>
|
||||
<Box>{syncing ? "syncing" : "synced"}</Box>
|
||||
<Box>{syncing ? 'syncing' : 'synced'}</Box>
|
||||
</Box>
|
||||
<Box display="flex">
|
||||
<Box flexGrow={1}>height:</Box>
|
||||
@@ -228,7 +231,7 @@ export const StatusCard = () => {
|
||||
|
||||
const Wallets = () => {
|
||||
const classes = useStyles();
|
||||
const logged_in = useSelector(state => state.wallet_state.logged_in);
|
||||
const logged_in = useSelector((state) => state.wallet_state.logged_in);
|
||||
|
||||
const [open] = React.useState(true);
|
||||
if (!logged_in) {
|
||||
@@ -240,26 +243,26 @@ const Wallets = () => {
|
||||
<Drawer
|
||||
variant="permanent"
|
||||
classes={{
|
||||
paper: clsx(classes.drawerPaper, !open && classes.drawerPaperClose)
|
||||
paper: clsx(classes.drawerPaper, !open && classes.drawerPaperClose),
|
||||
}}
|
||||
open={open}
|
||||
>
|
||||
<Divider />
|
||||
<StatusCard></StatusCard>
|
||||
<StatusCard />
|
||||
<Divider />
|
||||
<List>
|
||||
<WalletList></WalletList>
|
||||
<WalletList />
|
||||
</List>
|
||||
<CreateWallet></CreateWallet>
|
||||
<CreateWallet />
|
||||
</Drawer>
|
||||
<main className={classes.content}>
|
||||
<Container maxWidth="lg" className={classes.container}>
|
||||
<Grid container spacing={3}>
|
||||
{/* Chart */}
|
||||
<Grid item xs={12}>
|
||||
<WalletViewSwitch></WalletViewSwitch>
|
||||
<WalletViewSwitch />
|
||||
</Grid>
|
||||
<Grid item xs={12}></Grid>
|
||||
<Grid item xs={12} />
|
||||
</Grid>
|
||||
</Container>
|
||||
</main>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import {
|
||||
makeStyles,
|
||||
Typography,
|
||||
@@ -6,68 +6,68 @@ import {
|
||||
Box,
|
||||
TextField,
|
||||
Backdrop,
|
||||
CircularProgress
|
||||
} from "@material-ui/core";
|
||||
CircularProgress,
|
||||
} from '@material-ui/core';
|
||||
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import {
|
||||
createState,
|
||||
changeCreateWallet,
|
||||
CREATE_CC_WALLET_OPTIONS
|
||||
} from "../modules/createWallet";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { useStyles } from "./CreateWallet";
|
||||
import { chia_to_mojo } from "../util/chia";
|
||||
import { create_cc_for_colour_action } from "../modules/message";
|
||||
import { openDialog } from "../modules/dialog";
|
||||
CREATE_CC_WALLET_OPTIONS,
|
||||
} from '../modules/createWallet';
|
||||
import { useStyles } from './CreateWallet';
|
||||
import { chia_to_mojo } from '../util/chia';
|
||||
import { create_cc_for_colour_action } from '../modules/message';
|
||||
import { openDialog } from '../modules/dialog';
|
||||
|
||||
export const customStyles = makeStyles(theme => ({
|
||||
export const customStyles = makeStyles((theme) => ({
|
||||
input: {
|
||||
marginLeft: theme.spacing(3),
|
||||
marginRight: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
send: {
|
||||
paddingLeft: "0px",
|
||||
paddingLeft: '0px',
|
||||
marginLeft: theme.spacing(6),
|
||||
marginRight: theme.spacing(2),
|
||||
|
||||
height: 56,
|
||||
width: 150
|
||||
width: 150,
|
||||
},
|
||||
card: {
|
||||
paddingTop: theme.spacing(10),
|
||||
height: 200
|
||||
height: 200,
|
||||
},
|
||||
backdrop: {
|
||||
zIndex: theme.zIndex.drawer + 1,
|
||||
color: "#fff"
|
||||
}
|
||||
color: '#fff',
|
||||
},
|
||||
}));
|
||||
|
||||
export const CreateExistingCCWallet = () => {
|
||||
const classes = useStyles();
|
||||
const custom = customStyles();
|
||||
const dispatch = useDispatch();
|
||||
var colour_string = null;
|
||||
var fee_input = null;
|
||||
var open = false;
|
||||
var pending = useSelector(state => state.create_options.pending);
|
||||
var created = useSelector(state => state.create_options.created);
|
||||
let colour_string = null;
|
||||
let fee_input = null;
|
||||
const open = false;
|
||||
const pending = useSelector((state) => state.create_options.pending);
|
||||
const created = useSelector((state) => state.create_options.created);
|
||||
|
||||
function goBack() {
|
||||
dispatch(changeCreateWallet(CREATE_CC_WALLET_OPTIONS));
|
||||
}
|
||||
|
||||
function create() {
|
||||
if (fee_input.value === "" || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog("Please enter a valid numeric fee"));
|
||||
if (fee_input.value === '' || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog('Please enter a valid numeric fee'));
|
||||
return;
|
||||
}
|
||||
dispatch(createState(true, true));
|
||||
const colour = colour_string.value;
|
||||
var fee = chia_to_mojo(fee_input.value);
|
||||
const fee = chia_to_mojo(fee_input.value);
|
||||
dispatch(create_cc_for_colour_action(colour, fee));
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ export const CreateExistingCCWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
colour_string = input;
|
||||
}}
|
||||
label="Colour String"
|
||||
@@ -109,7 +109,7 @@ export const CreateExistingCCWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
fee_input = input;
|
||||
}}
|
||||
label="Fee"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import {
|
||||
makeStyles,
|
||||
Typography,
|
||||
@@ -6,49 +6,49 @@ import {
|
||||
Box,
|
||||
TextField,
|
||||
Backdrop,
|
||||
CircularProgress
|
||||
} from "@material-ui/core";
|
||||
CircularProgress,
|
||||
} from '@material-ui/core';
|
||||
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import {
|
||||
createState,
|
||||
changeCreateWallet,
|
||||
CREATE_CC_WALLET_OPTIONS
|
||||
} from "../modules/createWallet";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { useStyles } from "./CreateWallet";
|
||||
import { create_cc_action } from "../modules/message";
|
||||
import { chia_to_mojo } from "../util/chia";
|
||||
import { openDialog } from "../modules/dialog";
|
||||
CREATE_CC_WALLET_OPTIONS,
|
||||
} from '../modules/createWallet';
|
||||
import { useStyles } from './CreateWallet';
|
||||
import { create_cc_action } from '../modules/message';
|
||||
import { chia_to_mojo } from '../util/chia';
|
||||
import { openDialog } from '../modules/dialog';
|
||||
|
||||
export const customStyles = makeStyles(theme => ({
|
||||
export const customStyles = makeStyles((theme) => ({
|
||||
input: {
|
||||
marginLeft: theme.spacing(3),
|
||||
marginRight: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
send: {
|
||||
paddingLeft: "0px",
|
||||
paddingLeft: '0px',
|
||||
marginLeft: theme.spacing(6),
|
||||
marginRight: theme.spacing(2),
|
||||
height: 56,
|
||||
width: 150
|
||||
width: 150,
|
||||
},
|
||||
card: {
|
||||
paddingTop: theme.spacing(10),
|
||||
height: 200
|
||||
}
|
||||
height: 200,
|
||||
},
|
||||
}));
|
||||
|
||||
export const CreateNewCCWallet = () => {
|
||||
const classes = useStyles();
|
||||
const custom = customStyles();
|
||||
const dispatch = useDispatch();
|
||||
var amount_input = null;
|
||||
var fee_input = null;
|
||||
var pending = useSelector(state => state.create_options.pending);
|
||||
var created = useSelector(state => state.create_options.created);
|
||||
let amount_input = null;
|
||||
let fee_input = null;
|
||||
const pending = useSelector((state) => state.create_options.pending);
|
||||
const created = useSelector((state) => state.create_options.created);
|
||||
|
||||
function goBack() {
|
||||
dispatch(changeCreateWallet(CREATE_CC_WALLET_OPTIONS));
|
||||
@@ -56,21 +56,21 @@ export const CreateNewCCWallet = () => {
|
||||
|
||||
function create() {
|
||||
if (
|
||||
amount_input.value === "" ||
|
||||
amount_input.value === '' ||
|
||||
Number(amount_input.value) === 0 ||
|
||||
!Number(amount_input.value) ||
|
||||
isNaN(Number(amount_input.value))
|
||||
) {
|
||||
dispatch(openDialog("Please enter a valid numeric amount"));
|
||||
dispatch(openDialog('Please enter a valid numeric amount'));
|
||||
return;
|
||||
}
|
||||
if (fee_input.value === "" || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog("Please enter a valid numeric fee"));
|
||||
if (fee_input.value === '' || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog('Please enter a valid numeric fee'));
|
||||
return;
|
||||
}
|
||||
dispatch(createState(true, true));
|
||||
var amount = chia_to_mojo(amount_input.value);
|
||||
var fee = chia_to_mojo(fee_input.value);
|
||||
const amount = chia_to_mojo(amount_input.value);
|
||||
const fee = chia_to_mojo(fee_input.value);
|
||||
dispatch(create_cc_action(amount, fee));
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ export const CreateNewCCWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
amount_input = input;
|
||||
}}
|
||||
label="Amount"
|
||||
@@ -112,7 +112,7 @@ export const CreateNewCCWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
fee_input = input;
|
||||
}}
|
||||
label="Fee"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import {
|
||||
makeStyles,
|
||||
Typography,
|
||||
@@ -6,80 +6,80 @@ import {
|
||||
Box,
|
||||
TextField,
|
||||
Backdrop,
|
||||
CircularProgress
|
||||
} from "@material-ui/core";
|
||||
CircularProgress,
|
||||
} from '@material-ui/core';
|
||||
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import {
|
||||
createState,
|
||||
changeCreateWallet,
|
||||
CREATE_RL_WALLET_OPTIONS
|
||||
} from "../modules/createWallet";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { useStyles } from "./CreateWallet";
|
||||
import { create_rl_admin_action } from "../modules/message";
|
||||
import { chia_to_mojo } from "../util/chia";
|
||||
import { openDialog } from "../modules/dialog";
|
||||
CREATE_RL_WALLET_OPTIONS,
|
||||
} from '../modules/createWallet';
|
||||
import { useStyles } from './CreateWallet';
|
||||
import { create_rl_admin_action } from '../modules/message';
|
||||
import { chia_to_mojo } from '../util/chia';
|
||||
import { openDialog } from '../modules/dialog';
|
||||
|
||||
export const customStyles = makeStyles(theme => ({
|
||||
export const customStyles = makeStyles((theme) => ({
|
||||
input: {
|
||||
marginLeft: theme.spacing(3),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
inputLeft: {
|
||||
marginLeft: theme.spacing(3),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
inputRight: {
|
||||
marginRight: theme.spacing(3),
|
||||
marginLeft: theme.spacing(6),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
send: {
|
||||
paddingLeft: "0px",
|
||||
paddingLeft: '0px',
|
||||
marginLeft: theme.spacing(6),
|
||||
marginRight: theme.spacing(2),
|
||||
height: 56,
|
||||
width: 150
|
||||
width: 150,
|
||||
},
|
||||
card: {
|
||||
paddingTop: theme.spacing(10),
|
||||
height: 200
|
||||
height: 200,
|
||||
},
|
||||
topCard: {
|
||||
height: 100
|
||||
height: 100,
|
||||
},
|
||||
subCard: {
|
||||
height: 100
|
||||
height: 100,
|
||||
},
|
||||
topTitleCard: {
|
||||
paddingTop: theme.spacing(6),
|
||||
paddingBottom: theme.spacing(1)
|
||||
paddingBottom: theme.spacing(1),
|
||||
},
|
||||
titleCard: {
|
||||
paddingBottom: theme.spacing(1)
|
||||
paddingBottom: theme.spacing(1),
|
||||
},
|
||||
inputTitleLeft: {
|
||||
marginLeft: theme.spacing(3),
|
||||
width: "50%"
|
||||
width: '50%',
|
||||
},
|
||||
inputTitleRight: {
|
||||
marginLeft: theme.spacing(3),
|
||||
width: "50%"
|
||||
}
|
||||
width: '50%',
|
||||
},
|
||||
}));
|
||||
|
||||
export const CreateRLAdminWallet = () => {
|
||||
const classes = useStyles();
|
||||
const custom = customStyles();
|
||||
const dispatch = useDispatch();
|
||||
var interval_input = null;
|
||||
var chiaper_input = null;
|
||||
var userpubkey_input = null;
|
||||
var amount_input = null;
|
||||
var fee_input = null;
|
||||
var pending = useSelector(state => state.create_options.pending);
|
||||
var created = useSelector(state => state.create_options.created);
|
||||
let interval_input = null;
|
||||
let chiaper_input = null;
|
||||
let userpubkey_input = null;
|
||||
let amount_input = null;
|
||||
let fee_input = null;
|
||||
const pending = useSelector((state) => state.create_options.pending);
|
||||
const created = useSelector((state) => state.create_options.created);
|
||||
|
||||
function goBack() {
|
||||
dispatch(changeCreateWallet(CREATE_RL_WALLET_OPTIONS));
|
||||
@@ -87,38 +87,38 @@ export const CreateRLAdminWallet = () => {
|
||||
|
||||
function create() {
|
||||
if (
|
||||
interval_input.value === "" ||
|
||||
interval_input.value === '' ||
|
||||
Number(interval_input.value) === 0 ||
|
||||
!Number(interval_input.value) ||
|
||||
isNaN(Number(interval_input.value))
|
||||
) {
|
||||
dispatch(openDialog("Please enter a valid numeric interval length"));
|
||||
dispatch(openDialog('Please enter a valid numeric interval length'));
|
||||
return;
|
||||
}
|
||||
if (
|
||||
chiaper_input.value === "" ||
|
||||
chiaper_input.value === '' ||
|
||||
Number(chiaper_input.value) === 0 ||
|
||||
!Number(chiaper_input.value) ||
|
||||
isNaN(Number(chiaper_input.value))
|
||||
) {
|
||||
dispatch(openDialog("Please enter a valid numeric spendable amount"));
|
||||
dispatch(openDialog('Please enter a valid numeric spendable amount'));
|
||||
return;
|
||||
}
|
||||
if (userpubkey_input.value === "") {
|
||||
dispatch(openDialog("Please enter a valid pubkey"));
|
||||
if (userpubkey_input.value === '') {
|
||||
dispatch(openDialog('Please enter a valid pubkey'));
|
||||
return;
|
||||
}
|
||||
if (
|
||||
amount_input.value === "" ||
|
||||
amount_input.value === '' ||
|
||||
Number(amount_input.value) === 0 ||
|
||||
!Number(amount_input.value) ||
|
||||
isNaN(Number(amount_input.value))
|
||||
) {
|
||||
dispatch(openDialog("Please enter a valid initial coin amount"));
|
||||
dispatch(openDialog('Please enter a valid initial coin amount'));
|
||||
return;
|
||||
}
|
||||
if (fee_input.value === "" || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog("Please enter a valid numeric fee"));
|
||||
if (fee_input.value === '' || isNaN(Number(fee_input.value))) {
|
||||
dispatch(openDialog('Please enter a valid numeric fee'));
|
||||
return;
|
||||
}
|
||||
dispatch(createState(true, true));
|
||||
@@ -137,8 +137,8 @@ export const CreateRLAdminWallet = () => {
|
||||
interval_value,
|
||||
chiaper_value,
|
||||
userpubkey,
|
||||
amount_value
|
||||
)
|
||||
amount_value,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ export const CreateRLAdminWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
interval_input = input;
|
||||
}}
|
||||
label="Interval"
|
||||
@@ -192,7 +192,7 @@ export const CreateRLAdminWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
chiaper_input = input;
|
||||
}}
|
||||
label="Spendable Amount"
|
||||
@@ -218,7 +218,7 @@ export const CreateRLAdminWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
amount_input = input;
|
||||
}}
|
||||
label="Initial Amount"
|
||||
@@ -230,7 +230,7 @@ export const CreateRLAdminWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
fee_input = input;
|
||||
}}
|
||||
label="Fee"
|
||||
@@ -253,7 +253,7 @@ export const CreateRLAdminWallet = () => {
|
||||
variant="filled"
|
||||
color="secondary"
|
||||
fullWidth
|
||||
inputRef={input => {
|
||||
inputRef={(input) => {
|
||||
userpubkey_input = input;
|
||||
}}
|
||||
label="Pubkey"
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import {
|
||||
makeStyles,
|
||||
Typography,
|
||||
Button,
|
||||
Box,
|
||||
Backdrop,
|
||||
CircularProgress
|
||||
} from "@material-ui/core";
|
||||
CircularProgress,
|
||||
} from '@material-ui/core';
|
||||
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import ArrowBackIosIcon from '@material-ui/icons/ArrowBackIos';
|
||||
import {
|
||||
createState,
|
||||
changeCreateWallet,
|
||||
CREATE_RL_WALLET_OPTIONS
|
||||
} from "../modules/createWallet";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import ArrowBackIosIcon from "@material-ui/icons/ArrowBackIos";
|
||||
import { useStyles } from "./CreateWallet";
|
||||
import { create_rl_user_action } from "../modules/message";
|
||||
CREATE_RL_WALLET_OPTIONS,
|
||||
} from '../modules/createWallet';
|
||||
import { useStyles } from './CreateWallet';
|
||||
import { create_rl_user_action } from '../modules/message';
|
||||
|
||||
export const customStyles = makeStyles(theme => ({
|
||||
export const customStyles = makeStyles((theme) => ({
|
||||
walletContainer: {
|
||||
marginBottom: theme.spacing(5)
|
||||
marginBottom: theme.spacing(5),
|
||||
},
|
||||
topTitleCard: {
|
||||
paddingTop: theme.spacing(6),
|
||||
paddingBottom: theme.spacing(1)
|
||||
paddingBottom: theme.spacing(1),
|
||||
},
|
||||
input: {
|
||||
marginLeft: theme.spacing(3),
|
||||
marginRight: theme.spacing(3),
|
||||
paddingRight: theme.spacing(3),
|
||||
height: 56
|
||||
height: 56,
|
||||
},
|
||||
inputTitleLeft: {
|
||||
marginLeft: theme.spacing(3),
|
||||
paddingBottom: theme.spacing(3),
|
||||
width: 400
|
||||
width: 400,
|
||||
},
|
||||
createButton: {
|
||||
marginBottom: theme.spacing(2),
|
||||
width: 150,
|
||||
height: 50
|
||||
height: 50,
|
||||
},
|
||||
card: {
|
||||
height: 100
|
||||
}
|
||||
height: 100,
|
||||
},
|
||||
}));
|
||||
|
||||
export const CreateRLUserWallet = () => {
|
||||
const classes = useStyles();
|
||||
const custom = customStyles();
|
||||
const dispatch = useDispatch();
|
||||
var pending = useSelector(state => state.create_options.pending);
|
||||
var created = useSelector(state => state.create_options.created);
|
||||
const pending = useSelector((state) => state.create_options.pending);
|
||||
const created = useSelector((state) => state.create_options.created);
|
||||
|
||||
function goBack() {
|
||||
dispatch(changeCreateWallet(CREATE_RL_WALLET_OPTIONS));
|
||||
|
||||
@@ -1,79 +1,78 @@
|
||||
import React from "react";
|
||||
import React from 'react';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import List from '@material-ui/core/List';
|
||||
import Divider from '@material-ui/core/Divider';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import {
|
||||
presentWallet,
|
||||
presentNode,
|
||||
presentFarmer,
|
||||
changeMainMenu,
|
||||
presentTrading,
|
||||
presentPlotter
|
||||
} from "../modules/mainMenu";
|
||||
import { useSelector } from "react-redux";
|
||||
import { logOut } from "../modules/message";
|
||||
import { useDispatch } from "react-redux";
|
||||
import List from "@material-ui/core/List";
|
||||
import Divider from "@material-ui/core/Divider";
|
||||
presentPlotter,
|
||||
} from '../modules/mainMenu';
|
||||
import { logOut } from '../modules/message';
|
||||
|
||||
import { changeEntranceMenu, presentSelectKeys } from "../modules/entranceMenu";
|
||||
import walletSidebarLogo from "../assets/img/wallet_sidebar.svg"; // Tell webpack this JS file uses this image
|
||||
import farmSidebarLogo from "../assets/img/farm_sidebar.svg";
|
||||
import helpSidebarLogo from "../assets/img/help_sidebar.svg";
|
||||
import homeSidebarLogo from "../assets/img/home_sidebar.svg";
|
||||
import plotSidebarLogo from "../assets/img/plot_sidebar.svg";
|
||||
import poolSidebarLogo from "../assets/img/pool_sidebar.svg";
|
||||
import { makeStyles } from "@material-ui/core/styles";
|
||||
import { changeEntranceMenu, presentSelectKeys } from '../modules/entranceMenu';
|
||||
import walletSidebarLogo from '../assets/img/wallet_sidebar.svg'; // Tell webpack this JS file uses this image
|
||||
import farmSidebarLogo from '../assets/img/farm_sidebar.svg';
|
||||
import helpSidebarLogo from '../assets/img/help_sidebar.svg';
|
||||
import homeSidebarLogo from '../assets/img/home_sidebar.svg';
|
||||
import plotSidebarLogo from '../assets/img/plot_sidebar.svg';
|
||||
import poolSidebarLogo from '../assets/img/pool_sidebar.svg';
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
div: {
|
||||
textAlign: "center",
|
||||
cursor: "pointer"
|
||||
textAlign: 'center',
|
||||
cursor: 'pointer',
|
||||
},
|
||||
label: {
|
||||
fontFamily: "Roboto",
|
||||
fontWeight: "300",
|
||||
fontSize: "16px",
|
||||
fontStyle: "normal",
|
||||
marginTop: "5px"
|
||||
fontFamily: 'Roboto',
|
||||
fontWeight: '300',
|
||||
fontSize: '16px',
|
||||
fontStyle: 'normal',
|
||||
marginTop: '5px',
|
||||
},
|
||||
labelChosen: {
|
||||
fontFamily: "Roboto",
|
||||
fontWeight: "500",
|
||||
fontSize: "16px",
|
||||
fontStyle: "normal",
|
||||
marginTop: "5px"
|
||||
}
|
||||
fontFamily: 'Roboto',
|
||||
fontWeight: '500',
|
||||
fontSize: '16px',
|
||||
fontStyle: 'normal',
|
||||
marginTop: '5px',
|
||||
},
|
||||
}));
|
||||
|
||||
const menuItems = [
|
||||
{
|
||||
label: "Full Node",
|
||||
label: 'Full Node',
|
||||
present: presentNode,
|
||||
icon: <img src={homeSidebarLogo} alt="Logo" />
|
||||
icon: <img src={homeSidebarLogo} alt="Logo" />,
|
||||
},
|
||||
{
|
||||
label: "Wallets",
|
||||
label: 'Wallets',
|
||||
present: presentWallet,
|
||||
icon: <img src={walletSidebarLogo} alt="Logo" />
|
||||
icon: <img src={walletSidebarLogo} alt="Logo" />,
|
||||
},
|
||||
{
|
||||
label: "Plot",
|
||||
label: 'Plot',
|
||||
present: presentPlotter,
|
||||
icon: <img src={plotSidebarLogo} alt="Logo" />
|
||||
icon: <img src={plotSidebarLogo} alt="Logo" />,
|
||||
},
|
||||
{
|
||||
label: "Farm",
|
||||
label: 'Farm',
|
||||
present: presentFarmer,
|
||||
icon: <img src={farmSidebarLogo} alt="Logo" />
|
||||
icon: <img src={farmSidebarLogo} alt="Logo" />,
|
||||
},
|
||||
{
|
||||
label: "Trade",
|
||||
label: 'Trade',
|
||||
present: presentTrading,
|
||||
icon: <img src={poolSidebarLogo} alt="Logo" />
|
||||
icon: <img src={poolSidebarLogo} alt="Logo" />,
|
||||
},
|
||||
{
|
||||
label: "Keys",
|
||||
label: 'Keys',
|
||||
changeKeys: true,
|
||||
icon: <img src={helpSidebarLogo} alt="Logo" />
|
||||
}
|
||||
icon: <img src={helpSidebarLogo} alt="Logo" />,
|
||||
},
|
||||
];
|
||||
|
||||
const MenuItem = (menuItem, currentView) => {
|
||||
@@ -83,7 +82,7 @@ const MenuItem = (menuItem, currentView) => {
|
||||
|
||||
function presentMe() {
|
||||
if (item.changeKeys) {
|
||||
dispatch(logOut("log_out", {}));
|
||||
dispatch(logOut('log_out', {}));
|
||||
dispatch(changeEntranceMenu(presentSelectKeys));
|
||||
} else {
|
||||
dispatch(changeMainMenu(item.present));
|
||||
@@ -101,10 +100,10 @@ const MenuItem = (menuItem, currentView) => {
|
||||
};
|
||||
|
||||
export const SideBar = () => {
|
||||
const currentView = useSelector(state => state.main_menu.view);
|
||||
const currentView = useSelector((state) => state.main_menu.view);
|
||||
return (
|
||||
<div>
|
||||
<List>{menuItems.map(item => MenuItem(item, currentView))}</List>
|
||||
<List>{menuItems.map((item) => MenuItem(item, currentView))}</List>
|
||||
<Divider />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,117 +1,117 @@
|
||||
import { makeStyles } from "@material-ui/styles";
|
||||
import { makeStyles } from '@material-ui/styles';
|
||||
|
||||
const myStyle = makeStyles(theme => ({
|
||||
const myStyle = makeStyles((theme) => ({
|
||||
root: {
|
||||
background: "linear-gradient(45deg, #181818 30%, #333333 90%)",
|
||||
height: "100%"
|
||||
background: 'linear-gradient(45deg, #181818 30%, #333333 90%)',
|
||||
height: '100%',
|
||||
},
|
||||
paper: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
padding: theme.spacing(0)
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
padding: theme.spacing(0),
|
||||
},
|
||||
avatar: {
|
||||
marginTop: theme.spacing(8),
|
||||
backgroundColor: theme.palette.secondary.main
|
||||
backgroundColor: theme.palette.secondary.main,
|
||||
},
|
||||
form: {
|
||||
width: "100%", // Fix IE 11 issue.
|
||||
marginTop: theme.spacing(5)
|
||||
width: '100%', // Fix IE 11 issue.
|
||||
marginTop: theme.spacing(5),
|
||||
},
|
||||
textField: {
|
||||
borderColor: "#ffffff"
|
||||
borderColor: '#ffffff',
|
||||
},
|
||||
submit: {
|
||||
marginTop: theme.spacing(8),
|
||||
marginBottom: theme.spacing(3)
|
||||
marginBottom: theme.spacing(3),
|
||||
},
|
||||
grid_wrap: {
|
||||
paddingLeft: theme.spacing(10),
|
||||
paddingRight: theme.spacing(10),
|
||||
textAlign: "center"
|
||||
textAlign: 'center',
|
||||
},
|
||||
grid: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center"
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
},
|
||||
grid_item: {
|
||||
padding: theme.spacing(1),
|
||||
paddingTop: 0,
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
alignItems: "center",
|
||||
backgroundColor: "#444444",
|
||||
color: "#ffffff",
|
||||
height: 60
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#444444',
|
||||
color: '#ffffff',
|
||||
height: 60,
|
||||
},
|
||||
title: {
|
||||
color: "#ffffff",
|
||||
color: '#ffffff',
|
||||
marginTop: theme.spacing(4),
|
||||
marginBottom: theme.spacing(8)
|
||||
marginBottom: theme.spacing(8),
|
||||
},
|
||||
titleSmallMargin: {
|
||||
color: "#ffffff",
|
||||
color: '#ffffff',
|
||||
marginTop: theme.spacing(4),
|
||||
marginBottom: theme.spacing(2)
|
||||
marginBottom: theme.spacing(2),
|
||||
},
|
||||
navigator: {
|
||||
color: "#ffffff",
|
||||
color: '#ffffff',
|
||||
marginTop: theme.spacing(4),
|
||||
marginLeft: theme.spacing(4),
|
||||
fontSize: 35,
|
||||
flex: 1,
|
||||
align: "right",
|
||||
cursor: "pointer"
|
||||
align: 'right',
|
||||
cursor: 'pointer',
|
||||
},
|
||||
instructions: {
|
||||
color: "#ffffff",
|
||||
fontSize: 18
|
||||
color: '#ffffff',
|
||||
fontSize: 18,
|
||||
},
|
||||
dragContainer: {
|
||||
paddingLeft: 20,
|
||||
paddingRight: 20,
|
||||
paddingBottom: 20
|
||||
paddingBottom: 20,
|
||||
},
|
||||
drag: {
|
||||
backgroundColor: "#aaaaaa",
|
||||
backgroundColor: '#aaaaaa',
|
||||
height: 300,
|
||||
width: "100%"
|
||||
width: '100%',
|
||||
},
|
||||
dragText: {
|
||||
margin: 0,
|
||||
position: "absolute",
|
||||
top: "50%",
|
||||
left: "50%",
|
||||
transform: "translate(-50%, -50%)"
|
||||
position: 'absolute',
|
||||
top: '50%',
|
||||
left: '50%',
|
||||
transform: 'translate(-50%, -50%)',
|
||||
},
|
||||
circle: {
|
||||
height: "100%",
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center"
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
},
|
||||
logo: {
|
||||
marginTop: theme.spacing(0),
|
||||
marginBottom: theme.spacing(1)
|
||||
marginBottom: theme.spacing(1),
|
||||
},
|
||||
whiteP: {
|
||||
color: "white",
|
||||
fontSize: "18px"
|
||||
color: 'white',
|
||||
fontSize: '18px',
|
||||
},
|
||||
column_three: {
|
||||
width: "33%"
|
||||
width: '33%',
|
||||
},
|
||||
align_right: {
|
||||
textAlign: "right"
|
||||
textAlign: 'right',
|
||||
},
|
||||
align_left: {
|
||||
textAlign: "left"
|
||||
textAlign: 'left',
|
||||
},
|
||||
align_center: {
|
||||
textAlign: "center"
|
||||
}
|
||||
textAlign: 'center',
|
||||
},
|
||||
}));
|
||||
|
||||
export default myStyle;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createMuiTheme } from "@material-ui/core/styles";
|
||||
import { createMuiTheme } from '@material-ui/core/styles';
|
||||
import theme from './default';
|
||||
|
||||
export default createMuiTheme({
|
||||
@@ -7,4 +7,4 @@ export default createMuiTheme({
|
||||
...theme.palette,
|
||||
type: 'dark',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
import { createMuiTheme } from "@material-ui/core/styles";
|
||||
import { createMuiTheme } from '@material-ui/core/styles';
|
||||
|
||||
const defaultTheme = createMuiTheme();
|
||||
|
||||
export default {
|
||||
palette: {
|
||||
primary: {
|
||||
main: "#5DA962",
|
||||
contrastText: "#ffffff",
|
||||
primary: {
|
||||
main: '#5DA962',
|
||||
contrastText: '#ffffff',
|
||||
},
|
||||
secondary: {
|
||||
main: "#000000",
|
||||
contrastText: "#ffffff",
|
||||
secondary: {
|
||||
main: '#000000',
|
||||
contrastText: '#ffffff',
|
||||
},
|
||||
danger: {
|
||||
main: '#dc3545',
|
||||
contrastText: "#ffffff",
|
||||
contrastText: '#ffffff',
|
||||
},
|
||||
},
|
||||
drawer: {
|
||||
@@ -75,4 +75,4 @@ export default {
|
||||
},
|
||||
|
||||
*/
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createMuiTheme } from "@material-ui/core/styles";
|
||||
import { createMuiTheme } from '@material-ui/core/styles';
|
||||
import theme from './default';
|
||||
|
||||
export default createMuiTheme({
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type WalletType from './WalletType';
|
||||
|
||||
type Coin = {
|
||||
confirmed_block_index: number,
|
||||
spent_block_index: number,
|
||||
spent: boolean,
|
||||
coinbase: boolean,
|
||||
wallet_type: WalletType,
|
||||
wallet_id: number,
|
||||
confirmed_block_index: number;
|
||||
spent_block_index: number;
|
||||
spent: boolean;
|
||||
coinbase: boolean;
|
||||
wallet_type: WalletType;
|
||||
wallet_id: number;
|
||||
};
|
||||
|
||||
export default Coin;
|
||||
|
||||
@@ -2,8 +2,8 @@ import type Coin from './Coin';
|
||||
import type Program from './Program';
|
||||
|
||||
type CoinSolution = {
|
||||
coin: Coin,
|
||||
solution: Program,
|
||||
coin: Coin;
|
||||
solution: Program;
|
||||
};
|
||||
|
||||
export default CoinSolution;
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
type Connection = {
|
||||
bytes_read: number,
|
||||
bytes_written: number,
|
||||
creation_time: number,
|
||||
last_message_time: number,
|
||||
local_host: string,
|
||||
local_port: number,
|
||||
node_id: string,
|
||||
peer_host: string,
|
||||
peer_port: number,
|
||||
peer_server_port: number,
|
||||
type: number,
|
||||
bytes_read: number;
|
||||
bytes_written: number;
|
||||
creation_time: number;
|
||||
last_message_time: number;
|
||||
local_host: string;
|
||||
local_port: number;
|
||||
node_id: string;
|
||||
peer_host: string;
|
||||
peer_port: number;
|
||||
peer_server_port: number;
|
||||
type: number;
|
||||
};
|
||||
|
||||
export default Connection;
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
type Header = {
|
||||
data: {
|
||||
additions_root: string,
|
||||
aggregated_signature: string,
|
||||
cost: string,
|
||||
extension_data: string,
|
||||
farmer_rewards_puzzle_hash: string,
|
||||
filter_hash: string,
|
||||
finish_time: number,
|
||||
finished: boolean,
|
||||
generator_hash: string,
|
||||
header_hash: string,
|
||||
height: number
|
||||
additions_root: string;
|
||||
aggregated_signature: string;
|
||||
cost: string;
|
||||
extension_data: string;
|
||||
farmer_rewards_puzzle_hash: string;
|
||||
filter_hash: string;
|
||||
finish_time: number;
|
||||
finished: boolean;
|
||||
generator_hash: string;
|
||||
header_hash: string;
|
||||
height: number;
|
||||
pool_target: {
|
||||
max_height: 0,
|
||||
puzzle_hash: string,
|
||||
},
|
||||
prev_header_hash: string,
|
||||
proof_of_space_hash: string,
|
||||
removals_root: string,
|
||||
timestamp: string,
|
||||
total_iters: string,
|
||||
total_transaction_fees: string,
|
||||
weight: string,
|
||||
},
|
||||
plot_signature: string,
|
||||
max_height: 0;
|
||||
puzzle_hash: string;
|
||||
};
|
||||
prev_header_hash: string;
|
||||
proof_of_space_hash: string;
|
||||
removals_root: string;
|
||||
timestamp: string;
|
||||
total_iters: string;
|
||||
total_transaction_fees: string;
|
||||
weight: string;
|
||||
};
|
||||
plot_signature: string;
|
||||
};
|
||||
|
||||
export default Header;
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
type Program = {
|
||||
};
|
||||
type Program = {};
|
||||
|
||||
export default Program;
|
||||
|
||||
@@ -2,9 +2,8 @@ import type CoinSolution from './CoinSolution';
|
||||
import type G2Element from './G2Element';
|
||||
|
||||
type SpendBundle = {
|
||||
coin_solutions: CoinSolution[]
|
||||
aggregated_signature: G2Element,
|
||||
}
|
||||
coin_solutions: CoinSolution[];
|
||||
aggregated_signature: G2Element;
|
||||
};
|
||||
|
||||
export default SpendBundle;
|
||||
|
||||
|
||||
@@ -2,18 +2,18 @@ import type Coin from './Coin';
|
||||
import type SpendBundle from './SpendBundle';
|
||||
|
||||
type Transaction = {
|
||||
confirmed_at_index: number,
|
||||
created_at_time: number,
|
||||
to_address: string,
|
||||
amount: number,
|
||||
fee_amount: number,
|
||||
incoming: boolean,
|
||||
confirmed: boolean,
|
||||
sent: number,
|
||||
spend_bundle?: SpendBundle,
|
||||
additions: Coin[],
|
||||
removals: Coin[],
|
||||
wallet_id: number,
|
||||
confirmed_at_index: number;
|
||||
created_at_time: number;
|
||||
to_address: string;
|
||||
amount: number;
|
||||
fee_amount: number;
|
||||
incoming: boolean;
|
||||
confirmed: boolean;
|
||||
sent: number;
|
||||
spend_bundle?: SpendBundle;
|
||||
additions: Coin[];
|
||||
removals: Coin[];
|
||||
wallet_id: number;
|
||||
};
|
||||
|
||||
export default Transaction;
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import type Transaction from "./Transaction";
|
||||
import type WalletType from "./WalletType";
|
||||
import type Transaction from './Transaction';
|
||||
import type WalletType from './WalletType';
|
||||
|
||||
interface Wallet {
|
||||
id: number,
|
||||
name: string,
|
||||
type: WalletType,
|
||||
data: Object,
|
||||
balance_total: number,
|
||||
balance_pending: number,
|
||||
balance_spendable: number,
|
||||
balance_frozen: number,
|
||||
balance_change: number,
|
||||
transactions: Transaction[],
|
||||
address: string,
|
||||
colour: string,
|
||||
sending_transaction: boolean,
|
||||
send_transaction_result?: string | null,
|
||||
};
|
||||
id: number;
|
||||
name: string;
|
||||
type: WalletType;
|
||||
data: Object;
|
||||
balance_total: number;
|
||||
balance_pending: number;
|
||||
balance_spendable: number;
|
||||
balance_frozen: number;
|
||||
balance_change: number;
|
||||
transactions: Transaction[];
|
||||
address: string;
|
||||
colour: string;
|
||||
sending_transaction: boolean;
|
||||
send_transaction_result?: string | null;
|
||||
}
|
||||
|
||||
export default Wallet;
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
export function calculate_block_reward(height) {
|
||||
if (height === 0) {
|
||||
return BigInt(500000000000000000);
|
||||
} else {
|
||||
return BigInt(14000000000000);
|
||||
}
|
||||
return BigInt(14000000000000);
|
||||
}
|
||||
|
||||
export function calculate_base_fee(height) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
var Big = require("big.js");
|
||||
var units = require("./units");
|
||||
const Big = require('big.js');
|
||||
const units = require('./units');
|
||||
|
||||
// TODO: use bigint instead of float
|
||||
const convert = (amount, from, to) => {
|
||||
@@ -46,20 +46,20 @@ class Chia {
|
||||
const fractionPower = Big(10).pow(fractionDigits);
|
||||
value = parseFloat(
|
||||
Big(Math.floor(Big(this._value).times(fractionPower))).div(
|
||||
fractionPower
|
||||
)
|
||||
fractionPower,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
value = this._value;
|
||||
}
|
||||
|
||||
let formatted = format.replace(
|
||||
"{amount}",
|
||||
parseFloat(value).toLocaleString(undefined, options)
|
||||
'{amount}',
|
||||
parseFloat(value).toLocaleString(undefined, options),
|
||||
);
|
||||
|
||||
if (displayUnit.pluralize && this._value !== 1) {
|
||||
formatted += "s";
|
||||
formatted += 's';
|
||||
}
|
||||
|
||||
return formatted;
|
||||
@@ -68,7 +68,7 @@ class Chia {
|
||||
toString() {
|
||||
const displayUnit = units.getDisplay(this._unit);
|
||||
const { fractionDigits } = displayUnit;
|
||||
let options = { maximumFractionDigits: fractionDigits };
|
||||
const options = { maximumFractionDigits: fractionDigits };
|
||||
return parseFloat(this._value).toLocaleString(undefined, options);
|
||||
}
|
||||
}
|
||||
@@ -83,38 +83,30 @@ chia_formatter.setFiat = (currency, rate, display = null) => {
|
||||
units.setUnit(currency, 1 / rate, display);
|
||||
};
|
||||
|
||||
export const mojo_to_chia = mojo => {
|
||||
return chia_formatter(parseInt(mojo), "mojo")
|
||||
.to("chia")
|
||||
export const mojo_to_chia = (mojo) => {
|
||||
return chia_formatter(parseInt(mojo), 'mojo').to('chia').value();
|
||||
};
|
||||
|
||||
export const chia_to_mojo = (chia) => {
|
||||
return chia_formatter(parseFloat(Number(chia)), 'chia')
|
||||
.to('mojo')
|
||||
.value();
|
||||
};
|
||||
|
||||
export const chia_to_mojo = chia => {
|
||||
return chia_formatter(parseFloat(Number(chia)), "chia")
|
||||
.to("mojo")
|
||||
export const mojo_to_chia_string = (mojo) => {
|
||||
return chia_formatter(Number(mojo), 'mojo').to('chia').toString();
|
||||
};
|
||||
|
||||
export const mojo_to_colouredcoin = (mojo) => {
|
||||
return chia_formatter(parseInt(mojo), 'mojo').to('colouredcoin').value();
|
||||
};
|
||||
|
||||
export const colouredcoin_to_mojo = (colouredcoin) => {
|
||||
return chia_formatter(parseFloat(Number(colouredcoin)), 'colouredcoin')
|
||||
.to('mojo')
|
||||
.value();
|
||||
};
|
||||
|
||||
export const mojo_to_chia_string = mojo => {
|
||||
return chia_formatter(Number(mojo), "mojo")
|
||||
.to("chia")
|
||||
.toString();
|
||||
};
|
||||
|
||||
export const mojo_to_colouredcoin = mojo => {
|
||||
return chia_formatter(parseInt(mojo), "mojo")
|
||||
.to("colouredcoin")
|
||||
.value();
|
||||
};
|
||||
|
||||
export const colouredcoin_to_mojo = colouredcoin => {
|
||||
return chia_formatter(parseFloat(Number(colouredcoin)), "colouredcoin")
|
||||
.to("mojo")
|
||||
.value();
|
||||
};
|
||||
|
||||
export const mojo_to_colouredcoin_string = mojo => {
|
||||
return chia_formatter(Number(mojo), "mojo")
|
||||
.to("colouredcoin")
|
||||
.toString();
|
||||
export const mojo_to_colouredcoin_string = (mojo) => {
|
||||
return chia_formatter(Number(mojo), 'mojo').to('colouredcoin').toString();
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const self_hostname = "localhost";
|
||||
const daemon_rpc_ws = "ws://" + self_hostname + ":55400";
|
||||
const wallet_rpc_host_and_port = "ws://" + self_hostname + ":9256";
|
||||
const self_hostname = 'localhost';
|
||||
const daemon_rpc_ws = `ws://${self_hostname}:55400`;
|
||||
const wallet_rpc_host_and_port = `ws://${self_hostname}:9256`;
|
||||
const full_node_rpc_host = self_hostname;
|
||||
const full_node_rpc_port = 8555;
|
||||
|
||||
@@ -9,5 +9,5 @@ module.exports = {
|
||||
daemon_rpc_ws,
|
||||
wallet_rpc_host_and_port,
|
||||
full_node_rpc_host,
|
||||
full_node_rpc_port
|
||||
full_node_rpc_port,
|
||||
};
|
||||
|
||||
@@ -28,6 +28,6 @@ export default function createTransaction(
|
||||
spend_bundle,
|
||||
additions,
|
||||
removals,
|
||||
wallet_id
|
||||
wallet_id,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import type Wallet from '../types/Wallet';
|
||||
// export const initial_wallet = createWallet(0, "Chia Wallet", "STANDARD_WALLET", "");
|
||||
|
||||
export default function createWallet(
|
||||
id: number,
|
||||
name: string,
|
||||
type: WalletType,
|
||||
data: Object
|
||||
id: number,
|
||||
name: string,
|
||||
type: WalletType,
|
||||
data: Object,
|
||||
): Wallet {
|
||||
return {
|
||||
id,
|
||||
@@ -20,9 +20,9 @@ export default function createWallet(
|
||||
balance_frozen: 0,
|
||||
balance_change: 0,
|
||||
transactions: [],
|
||||
address: "",
|
||||
colour: "",
|
||||
address: '',
|
||||
colour: '',
|
||||
sending_transaction: false,
|
||||
send_transaction_result: "",
|
||||
send_transaction_result: '',
|
||||
};
|
||||
}
|
||||
|
||||
+2048
-2048
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,8 @@
|
||||
import { big_int_to_array, hex_to_array, arr_to_hex, sha256 } from "./utils";
|
||||
import { big_int_to_array, hex_to_array, arr_to_hex, sha256 } from './utils';
|
||||
/* global BigInt */
|
||||
|
||||
export async function hash_header(header) {
|
||||
var buf = big_int_to_array(BigInt(header.data.height), 4);
|
||||
let buf = big_int_to_array(BigInt(header.data.height), 4);
|
||||
buf = buf.concat(hex_to_array(header.data.prev_header_hash));
|
||||
buf = buf.concat(big_int_to_array(BigInt(header.data.timestamp), 8));
|
||||
buf = buf.concat(hex_to_array(header.data.filter_hash));
|
||||
@@ -13,11 +13,11 @@ export async function hash_header(header) {
|
||||
buf = buf.concat(hex_to_array(header.data.removals_root));
|
||||
buf = buf.concat(hex_to_array(header.data.farmer_rewards_puzzle_hash));
|
||||
buf = buf.concat(
|
||||
big_int_to_array(BigInt(header.data.total_transaction_fees), 8)
|
||||
big_int_to_array(BigInt(header.data.total_transaction_fees), 8),
|
||||
);
|
||||
buf = buf.concat(hex_to_array(header.data.pool_target.puzzle_hash));
|
||||
buf = buf.concat(
|
||||
big_int_to_array(BigInt(header.data.pool_target.max_height), 4)
|
||||
big_int_to_array(BigInt(header.data.pool_target.max_height), 4),
|
||||
);
|
||||
buf = buf.concat(hex_to_array(header.data.aggregated_signature));
|
||||
buf = buf.concat(big_int_to_array(BigInt(header.data.cost), 8));
|
||||
@@ -25,6 +25,6 @@ export async function hash_header(header) {
|
||||
buf = buf.concat(hex_to_array(header.data.generator_hash));
|
||||
buf = buf.concat(hex_to_array(header.plot_signature));
|
||||
|
||||
let hash = await sha256(buf);
|
||||
const hash = await sha256(buf);
|
||||
return arr_to_hex(hash);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
export const service_wallet = "chia_wallet";
|
||||
export const service_full_node = "chia_full_node";
|
||||
export const service_farmer = "chia_farmer";
|
||||
export const service_harvester = "chia_harvester";
|
||||
export const service_simulator = "chia_full_node_simulator";
|
||||
export const service_daemon = "daemon";
|
||||
export const service_plotter = "chia plots create";
|
||||
export const service_wallet = 'chia_wallet';
|
||||
export const service_full_node = 'chia_full_node';
|
||||
export const service_farmer = 'chia_farmer';
|
||||
export const service_harvester = 'chia_harvester';
|
||||
export const service_simulator = 'chia_full_node_simulator';
|
||||
export const service_daemon = 'daemon';
|
||||
export const service_plotter = 'chia plots create';
|
||||
|
||||
// Corresponds with outbound_message.py NodeTypes
|
||||
export const service_connection_types = {
|
||||
1: "Full Node",
|
||||
2: "Harvester",
|
||||
3: "Farmer",
|
||||
4: "Timelord",
|
||||
5: "Introducer",
|
||||
6: "Wallet",
|
||||
7: "Plotter"
|
||||
1: 'Full Node',
|
||||
2: 'Harvester',
|
||||
3: 'Farmer',
|
||||
4: 'Timelord',
|
||||
5: 'Introducer',
|
||||
6: 'Wallet',
|
||||
7: 'Plotter',
|
||||
};
|
||||
|
||||
@@ -1,37 +1,35 @@
|
||||
export const mempool_inclusion_status = {
|
||||
SUCCESS: 1, // Transaction added to mempool
|
||||
PENDING: 2, // Transaction not yet added to mempool
|
||||
FAILED: 3 // Transaction was invalid and dropped
|
||||
FAILED: 3, // Transaction was invalid and dropped
|
||||
};
|
||||
|
||||
export const get_transaction_result = transaction => {
|
||||
let success = true;
|
||||
let message = "";
|
||||
export const get_transaction_result = (transaction) => {
|
||||
const success = true;
|
||||
const message = '';
|
||||
if (!transaction || transaction.transaction.sent_to.length === 0) {
|
||||
return {
|
||||
message,
|
||||
success
|
||||
success,
|
||||
};
|
||||
}
|
||||
|
||||
// At least one node has accepted our transaction
|
||||
for (let full_node_response of transaction.transaction.sent_to) {
|
||||
if (full_node_response[1] === mempool_inclusion_status["SUCCESS"]) {
|
||||
for (const full_node_response of transaction.transaction.sent_to) {
|
||||
if (full_node_response[1] === mempool_inclusion_status.SUCCESS) {
|
||||
return {
|
||||
message:
|
||||
"Transaction has successfully been sent to a full node and included in the mempool.",
|
||||
success: true
|
||||
'Transaction has successfully been sent to a full node and included in the mempool.',
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
// At least one node has accepted our transaction as pending
|
||||
for (let full_node_response of transaction.transaction.sent_to) {
|
||||
if (full_node_response[1] === mempool_inclusion_status["PENDING"]) {
|
||||
for (const full_node_response of transaction.transaction.sent_to) {
|
||||
if (full_node_response[1] === mempool_inclusion_status.PENDING) {
|
||||
return {
|
||||
message:
|
||||
"Transaction has sent to a full node and is pending inclusion into the mempool. " +
|
||||
full_node_response[2],
|
||||
success: true
|
||||
message: `Transaction has sent to a full node and is pending inclusion into the mempool. ${full_node_response[2]}`,
|
||||
success: true,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -39,6 +37,6 @@ export const get_transaction_result = transaction => {
|
||||
// No nodes have accepted our transaction, so display the error message of the first
|
||||
return {
|
||||
message: transaction.transaction.sent_to[0][2],
|
||||
success: false
|
||||
success: false,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,34 +1,34 @@
|
||||
const units = {
|
||||
chia: 1,
|
||||
mojo: 1 / 1e12,
|
||||
colouredcoin: 1 / 1e9
|
||||
colouredcoin: 1 / 1e9,
|
||||
};
|
||||
|
||||
const aliases = {
|
||||
chia: ["ch", "chia", "Chia"],
|
||||
mojo: ["mj", "mojo"],
|
||||
colouredcoin: ["cc", "colouredcoin"]
|
||||
chia: ['ch', 'chia', 'Chia'],
|
||||
mojo: ['mj', 'mojo'],
|
||||
colouredcoin: ['cc', 'colouredcoin'],
|
||||
};
|
||||
|
||||
const display = {
|
||||
chia: {
|
||||
format: "{amount} CH",
|
||||
fractionDigits: 12
|
||||
format: '{amount} CH',
|
||||
fractionDigits: 12,
|
||||
},
|
||||
mojo: {
|
||||
format: "{amount} MJ",
|
||||
fractionDigits: 0
|
||||
format: '{amount} MJ',
|
||||
fractionDigits: 0,
|
||||
},
|
||||
colouredcoin: {
|
||||
format: "{amount} CC",
|
||||
fractionDigits: 3
|
||||
}
|
||||
format: '{amount} CC',
|
||||
fractionDigits: 3,
|
||||
},
|
||||
};
|
||||
|
||||
const getUnitNameByAlias = unitName => {
|
||||
const getUnitNameByAlias = (unitName) => {
|
||||
const name = unitName.toLowerCase();
|
||||
|
||||
const alias = Object.keys(aliases).find(key => aliases[key].includes(name));
|
||||
const alias = Object.keys(aliases).find((key) => aliases[key].includes(name));
|
||||
|
||||
if (alias === undefined) {
|
||||
throw new Error(`Unit '${unitName}' is not supported`);
|
||||
@@ -37,7 +37,7 @@ const getUnitNameByAlias = unitName => {
|
||||
return alias;
|
||||
};
|
||||
|
||||
const getUnitName = unitName => {
|
||||
const getUnitName = (unitName) => {
|
||||
const name = unitName.toLowerCase();
|
||||
|
||||
const unit = units[name];
|
||||
@@ -47,13 +47,13 @@ const getUnitName = unitName => {
|
||||
return getUnitNameByAlias(unitName);
|
||||
};
|
||||
|
||||
const getUnit = unit => units[getUnitName(unit)];
|
||||
const getUnit = (unit) => units[getUnitName(unit)];
|
||||
|
||||
const setDisplay = (unit, options) => {
|
||||
display[unit.toLowerCase()] = options;
|
||||
};
|
||||
|
||||
const getDisplay = unit => display[getUnitName(unit)];
|
||||
const getDisplay = (unit) => display[getUnitName(unit)];
|
||||
|
||||
const setUnit = (unit, value, displayOptions = null) => {
|
||||
units[unit.toLowerCase()] = value;
|
||||
@@ -62,8 +62,8 @@ const setUnit = (unit, value, displayOptions = null) => {
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getUnit: getUnit,
|
||||
setUnit: setUnit,
|
||||
getDisplay: getDisplay,
|
||||
setDisplay: setDisplay
|
||||
getUnit,
|
||||
setUnit,
|
||||
getDisplay,
|
||||
setDisplay,
|
||||
};
|
||||
|
||||
@@ -1,23 +1,19 @@
|
||||
/* global BigInt */
|
||||
|
||||
export function unix_to_short_date(unix_timestamp) {
|
||||
let d = new Date(unix_timestamp * 1000);
|
||||
return (
|
||||
d.toLocaleDateString("en-US", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric"
|
||||
}) +
|
||||
" " +
|
||||
d.toLocaleTimeString()
|
||||
);
|
||||
const d = new Date(unix_timestamp * 1000);
|
||||
return `${d.toLocaleDateString('en-US', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
})} ${d.toLocaleTimeString()}`;
|
||||
}
|
||||
|
||||
export function get_query_variable(variable) {
|
||||
var query = global.location.search.substring(1);
|
||||
var vars = query.split("&");
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
var pair = vars[i].split("=");
|
||||
const query = global.location.search.substring(1);
|
||||
const vars = query.split('&');
|
||||
for (let i = 0; i < vars.length; i++) {
|
||||
const pair = vars[i].split('=');
|
||||
if (decodeURIComponent(pair[0]) === variable) {
|
||||
return decodeURIComponent(pair[1]);
|
||||
}
|
||||
@@ -25,8 +21,8 @@ export function get_query_variable(variable) {
|
||||
}
|
||||
|
||||
export function big_int_to_array(x, num_bytes) {
|
||||
var truncated = BigInt.asUintN(num_bytes * 8, x);
|
||||
var arr = [];
|
||||
let truncated = BigInt.asUintN(num_bytes * 8, x);
|
||||
const arr = [];
|
||||
for (let i = 0; i < num_bytes; i++) {
|
||||
arr.splice(0, 0, Number(truncated & BigInt(255)));
|
||||
truncated >>= BigInt(8);
|
||||
@@ -35,11 +31,11 @@ export function big_int_to_array(x, num_bytes) {
|
||||
}
|
||||
|
||||
export function hex_to_array(hexString) {
|
||||
if (hexString.substr(0, 2) === "0x" || hexString.substr(0, 2) === "0X") {
|
||||
if (hexString.substr(0, 2) === '0x' || hexString.substr(0, 2) === '0X') {
|
||||
hexString = hexString.slice(2);
|
||||
}
|
||||
var arr = [];
|
||||
for (var i = 0; i < hexString.length; i += 2) {
|
||||
const arr = [];
|
||||
for (let i = 0; i < hexString.length; i += 2) {
|
||||
arr.push(parseInt(hexString.substr(i, 2), 16));
|
||||
}
|
||||
return arr;
|
||||
@@ -48,10 +44,10 @@ export function hex_to_array(hexString) {
|
||||
export function arr_to_hex(buffer) {
|
||||
// buffer is an ArrayBuffer
|
||||
return Array.prototype.map
|
||||
.call(new Uint8Array(buffer), x => ("00" + x.toString(16)).slice(-2))
|
||||
.join("");
|
||||
.call(new Uint8Array(buffer), (x) => `00${x.toString(16)}`.slice(-2))
|
||||
.join('');
|
||||
}
|
||||
|
||||
export async function sha256(buf) {
|
||||
return await window.crypto.subtle.digest("SHA-256", new Uint8Array(buf));
|
||||
return await window.crypto.subtle.digest('SHA-256', new Uint8Array(buf));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user