on master help sign in
Use global wallet instead of local state during Login flows
commit8939f17b6d9cec698e00dc67ab2986957305ab23 authorFang <git@fang.io> dateThu 20 Jun 2019, 22:40 (7 years ago) parentcbe393f
2 files changed+14−13
src/bridge/views/Login.js+3−3 src/bridge/views/Login/Ticket.js+11−10
src/bridge/views/Login.js+3−3
@@ -30,7 +30,6 @@ class Login extends React.Component {
3030
3131 this.state = {
3232 currentTab: TABS.TICKET,
33− wallet: Nothing(),
3433 };
3534
3635 this.handleTabChange = this.handleTabChange.bind(this);
@@ -38,8 +37,9 @@ class Login extends React.Component {
3837 }
3938
4039 componentDidMount() {
41− this.props.setNetworkType(this.props.networkType);
42− // we expect pointCursor to not be set yet
40+ // we expect wallet and pointCursor to not be set yet
41+ this.props.setUrbitWallet(Nothing());
42+ this.props.setWallet(Nothing());
4343 this.props.setPointCursor(Nothing());
4444 }
4545
src/bridge/views/Login/Ticket.js+11−10
@@ -38,7 +38,6 @@ class Ticket extends React.Component {
3838 ticket: '',
3939 ticketStatus: Nothing(),
4040 passphrase: '',
41− wallet: Nothing(),
4241 };
4342
4443 this.handlePointNameInput = this.handlePointNameInput.bind(this);
@@ -72,7 +71,8 @@ class Ticket extends React.Component {
7271 //TODO maybe want to do this only on-go, because wallet derivation is slow...
7372 async verifyTicket(pointName, ticket, passphrase) {
7473 if (!ob.isValidPatq(ticket) || !ob.isValidPatp(pointName)) {
75− this.setState({ ticketStatus: Nothing(), wallet: Nothing() });
74+ this.props.setUrbitWallet(Nothing());
75+ this.setState({ ticketStatus: Nothing() });
7676 return;
7777 }
7878 this.setState({ ticketStatus: Just(INPUT_STATUS.SPIN) });
@@ -89,23 +89,24 @@ class Ticket extends React.Component {
8989 pointNumber,
9090 uhdw.ownership.keys.address
9191 );
92− let newState = { wallet: Just(uhdw) };
93− newState.ticketStatus =
94− (await isOwner) || (await isTransferProxy)
95− ? Just(INPUT_STATUS.GOOD)
96− : Just(INPUT_STATUS.FAIL);
97− this.setState(newState);
92+ this.props.setUrbitWallet(Just(uhdw));
93+ this.setState({
94+ ticketStatus:
95+ (await isOwner) || (await isTransferProxy)
96+ ? Just(INPUT_STATUS.GOOD)
97+ : Just(INPUT_STATUS.FAIL),
98+ });
9899 }
99100
100101 canContinue() {
101102 // this is our only requirement, since we still want people with
102103 // non-standard wallet setups to be able to log in
103− return Just.hasInstance(this.state.wallet);
104+ return Just.hasInstance(this.props.wallet);
104105 }
105106
106107 continue() {
108+ //TODO maybe do on-mount?
107109 this.props.setWalletType(WALLET_TYPES.TICKET);
108− this.props.setUrbitWallet(this.state.wallet.value); //TODO wrap
109110 this.props.setPointCursor(Just(ob.patp2dec(this.state.pointName)));
110111 this.props.loginCompleted();
111112 }