on master help sign in
Use global wallet instead of local state during Login flows
8939f17Fang
src/bridge/views/Login.js+3−3
@@ -30,7 +30,6 @@ class Login extends React.Component {
30
30
31 this.state = {
31 this.state = {
32 currentTab: TABS.TICKET,
32 currentTab: TABS.TICKET,
33− wallet: Nothing(),
34 };
33 };
35
34
36 this.handleTabChange = this.handleTabChange.bind(this);
35 this.handleTabChange = this.handleTabChange.bind(this);
@@ -38,8 +37,9 @@ class Login extends React.Component {
38 }
37 }
39
38
40 componentDidMount() {
39 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());
43 this.props.setPointCursor(Nothing());
43 this.props.setPointCursor(Nothing());
44 }
44 }
45
45
src/bridge/views/Login/Ticket.js+11−10
@@ -38,7 +38,6 @@ class Ticket extends React.Component {
38 ticket: '',
38 ticket: '',
39 ticketStatus: Nothing(),
39 ticketStatus: Nothing(),
40 passphrase: '',
40 passphrase: '',
41− wallet: Nothing(),
42 };
41 };
43
42
44 this.handlePointNameInput = this.handlePointNameInput.bind(this);
43 this.handlePointNameInput = this.handlePointNameInput.bind(this);
@@ -72,7 +71,8 @@ class Ticket extends React.Component {
72 //TODO maybe want to do this only on-go, because wallet derivation is slow...
71 //TODO maybe want to do this only on-go, because wallet derivation is slow...
73 async verifyTicket(pointName, ticket, passphrase) {
72 async verifyTicket(pointName, ticket, passphrase) {
74 if (!ob.isValidPatq(ticket) || !ob.isValidPatp(pointName)) {
73 if (!ob.isValidPatq(ticket) || !ob.isValidPatp(pointName)) {
74+ this.props.setUrbitWallet(Nothing());
75− this.setState({ ticketStatus: Nothing(), wallet: Nothing() });
75+ this.setState({ ticketStatus: Nothing() });
76 return;
76 return;
77 }
77 }
78 this.setState({ ticketStatus: Just(INPUT_STATUS.SPIN) });
78 this.setState({ ticketStatus: Just(INPUT_STATUS.SPIN) });
@@ -89,23 +89,24 @@ class Ticket extends React.Component {
89 pointNumber,
89 pointNumber,
90 uhdw.ownership.keys.address
90 uhdw.ownership.keys.address
91 );
91 );
92− let newState = { wallet: Just(uhdw) };
92+ this.props.setUrbitWallet(Just(uhdw));
93− newState.ticketStatus =
93+ this.setState({
94+ ticketStatus:
94− (await isOwner) || (await isTransferProxy)
95+ (await isOwner) || (await isTransferProxy)
95− ? Just(INPUT_STATUS.GOOD)
96+ ? Just(INPUT_STATUS.GOOD)
96− : Just(INPUT_STATUS.FAIL);
97+ : Just(INPUT_STATUS.FAIL),
97− this.setState(newState);
98+ });
98 }
99 }
99
100
100 canContinue() {
101 canContinue() {
101 // this is our only requirement, since we still want people with
102 // this is our only requirement, since we still want people with
102 // non-standard wallet setups to be able to log in
103 // non-standard wallet setups to be able to log in
103− return Just.hasInstance(this.state.wallet);
104+ return Just.hasInstance(this.props.wallet);
104 }
105 }
105
106
106 continue() {
107 continue() {
108+ //TODO maybe do on-mount?
107 this.props.setWalletType(WALLET_TYPES.TICKET);
109 this.props.setWalletType(WALLET_TYPES.TICKET);
108− this.props.setUrbitWallet(this.state.wallet.value); //TODO wrap
109 this.props.setPointCursor(Just(ob.patp2dec(this.state.pointName)));
110 this.props.setPointCursor(Just(ob.patp2dec(this.state.pointName)));
110 this.props.loginCompleted();
111 this.props.loginCompleted();
111 }
112 }