Skip to content

Commit

Permalink
create rl admin and user wallets pages. rl walle user page. small mis…
Browse files Browse the repository at this point in the history
…c fixes.
  • Loading branch information
ronanlong authored and hoffmang9 committed Aug 18, 2020
1 parent 098a451 commit e975b01
Show file tree
Hide file tree
Showing 8 changed files with 1,245 additions and 13 deletions.
5 changes: 4 additions & 1 deletion electron-react/src/modules/createWalletReducer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export const CREATE_CC_WALLET_OPTIONS = "CREATE_CC_WALLET_OPTIONS";
export const CREATE_NEW_CC = "CREATE_NEW_CC";
export const CRAETE_EXISTING_CC = "CRAETE_EXISTING_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 => ({
Expand Down
13 changes: 13 additions & 0 deletions electron-react/src/modules/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,19 @@ export const cc_spend = (wallet_id, puzzle_hash, amount, fee) => {
return action;
};

// TODO: needs to include the fee
export const admin_create_coin = (interval, limit, user_pubkey, amount, fee) => {
var action = walletMessage();
action.message.command = "admin_create_coin";
action.message.data = {
interval: interval,
limit: limit,
user_pubkey: user_pubkey,
amount: amount
};
return action;
};

export const logOut = (command, data) => ({ type: "LOG_OUT", command, data });

export const incomingMessage = message => ({
Expand Down
83 changes: 77 additions & 6 deletions electron-react/src/pages/CreateWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,18 @@ import {
changeCreateWallet,
ALL_OPTIONS,
CREATE_CC_WALLET_OPTIONS,
CRAETE_EXISTING_CC,
CREATE_NEW_CC
CREATE_EXISTING_CC,
CREATE_NEW_CC,
CREATE_RL_WALLET_OPTIONS,
CREATE_RL_ADMIN,
CREATE_RL_USER
} from "../modules/createWalletReducer";
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";

export const useStyles = makeStyles(theme => ({
Expand Down Expand Up @@ -73,10 +78,14 @@ export const MainWalletList = () => {
const dispatch = useDispatch();
const classes = useStyles();

function select_option() {
function select_option_cc() {
dispatch(changeCreateWallet(CREATE_CC_WALLET_OPTIONS));
}

function select_option_rl() {
dispatch(changeCreateWallet(CREATE_RL_WALLET_OPTIONS));
}

return (
<div>
<div className={classes.cardTitle}>
Expand All @@ -85,12 +94,18 @@ export const MainWalletList = () => {
</Typography>
</div>
<List>
<ListItem button onClick={select_option}>
<ListItem button onClick={select_option_cc}>
<ListItemIcon>
<InvertColorsIcon />
</ListItemIcon>
<ListItemText primary="Coloured Coin" />
</ListItem>
<ListItem button onClick={select_option_rl}>
<ListItemIcon>
<InvertColorsIcon />
</ListItemIcon>
<ListItemText primary="Rate Limited" />
</ListItem>
</List>
</div>
);
Expand All @@ -109,7 +124,7 @@ export const CCListItems = () => {
}

function select_option_existing() {
dispatch(changeCreateWallet(CRAETE_EXISTING_CC));
dispatch(changeCreateWallet(CREATE_EXISTING_CC));
}

return (
Expand Down Expand Up @@ -146,6 +161,56 @@ export const CCListItems = () => {
);
};

export const RLListItems = () => {
const classes = useStyles();
const dispatch = useDispatch();

function goBack() {
dispatch(changeCreateWallet(ALL_OPTIONS));
}

function select_option_admin() {
dispatch(changeCreateWallet(CREATE_RL_ADMIN));
}

function select_option_user() {
dispatch(changeCreateWallet(CREATE_RL_USER));
}

return (
<div>
<div className={classes.cardTitle}>
<Box display="flex">
<Box>
<Button onClick={goBack}>
<ArrowBackIosIcon> </ArrowBackIosIcon>
</Button>
</Box>
<Box flexGrow={1} className={classes.title}>
<Typography component="h6" variant="h6">
Rate Limited Options
</Typography>
</Box>
</Box>
</div>
<List>
<ListItem button onClick={select_option_admin}>
<ListItemIcon>
<InvertColorsIcon />
</ListItemIcon>
<ListItemText primary="Create admin wallet" />
</ListItem>
<ListItem button onClick={select_option_user}>
<ListItemIcon>
<InvertColorsIcon />
</ListItemIcon>
<ListItemText primary="Create user wallet" />
</ListItem>
</List>
</div>
);
};

const CreateViewSwitch = () => {
const view = useSelector(state => state.create_options.view);

Expand All @@ -155,8 +220,14 @@ const CreateViewSwitch = () => {
return <CCListItems></CCListItems>;
} else if (view === CREATE_NEW_CC) {
return <CreateNewCCWallet></CreateNewCCWallet>;
} else if (view === CRAETE_EXISTING_CC) {
} 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>;
}
};

Expand Down
Loading

0 comments on commit e975b01

Please sign in to comment.