on master help sign in
feat: extract network seed/revision into wallet store
656c219Matt Condon (shrugs)
src/bridge/Bridge.js+1−24
@@ -93,26 +93,7 @@ const AllProviders = nest([
93]);
93]);
94
94
95class Bridge extends React.Component {
95class Bridge extends React.Component {
96− constructor(props) {
97− super(props);
98−
99− this.state = {
100− networkSeedCache: null,
101− };
102−
103− this.setNetworkSeedCache = this.setNetworkSeedCache.bind(this);
104− }
105−
106− setNetworkSeedCache(networkSeed, revision) {
107− this.setState({
108− networkSeedCache: networkSeed,
109− networkRevisionCache: revision,
110− });
111− }
112−
113 render() {
96 render() {
114− const { networkSeedCache, networkRevisionCache } = this.state;
115−
116 return (
97 return (
117 <AllProviders
98 <AllProviders
118 initialRoutes={kInitialRoutes}
99 initialRoutes={kInitialRoutes}
@@ -126,11 +107,7 @@ class Bridge extends React.Component {
126 <Header />
107 <Header />
127
108
128 <Row className={'row wrapper'}>
109 <Row className={'row wrapper'}>
129− <Router
110+ <Router />
130− networkSeedCache={networkSeedCache}
131− networkRevisionCache={networkRevisionCache}
132− setNetworkSeedCache={this.setNetworkSeedCache}
133− />
134
111
135 <div className={'push'} />
112 <div className={'push'} />
136 </Row>
113 </Row>
src/bridge/components/StatelessTransaction.js+6−2
@@ -242,11 +242,15 @@ class StatelessTransaction extends React.Component {
242 props.setTxnCursor(Just(Ok(txHash)));
242 props.setTxnCursor(Just(Ok(txHash)));
243
243
244 let routeData = {};
244 let routeData = {};
245− if (props.networkSeed) {
245+ if (props.newNetworkSeed) {
246− props.setNetworkSeedCache(props.networkSeed);
246+ props.setNetworkSeedCache(props.newNetworkSeed);
247 routeData.promptKeyfile = true;
247 routeData.promptKeyfile = true;
248 }
248 }
249
249
250+ if (props.newRevision) {
251+ props.setNetworkRevision(props.newRevision);
252+ }
253+
250 props.history.popAndPush(ROUTE_NAMES.SENT_TRANSACTION, routeData);
254 props.history.popAndPush(ROUTE_NAMES.SENT_TRANSACTION, routeData);
251 })
255 })
252 .catch(err => {
256 .catch(err => {
src/bridge/store/wallet.js+7
@@ -33,6 +33,8 @@ function _useWallet(
33 const [wallet, _setWallet] = useState(initialWallet);
33 const [wallet, _setWallet] = useState(initialWallet);
34 const [urbitWallet, _setUrbitWallet] = useState(Maybe.Nothing());
34 const [urbitWallet, _setUrbitWallet] = useState(Maybe.Nothing());
35 const [authMnemonic, setAuthMnemonic] = useState(initialMnemonic);
35 const [authMnemonic, setAuthMnemonic] = useState(initialMnemonic);
36+ const [networkSeed, setNetworkSeed] = useState(Maybe.Nothing());
37+ const [networkRevision, setNetowrkRevision] = useState(Maybe.Nothing());
36
38
37 const setWalletType = walletType => {
39 const setWalletType = walletType => {
38 if (!includes(WALLET_TYPES, walletType)) {
40 if (!includes(WALLET_TYPES, walletType)) {
@@ -89,6 +91,11 @@ function _useWallet(
89 setUrbitWallet,
91 setUrbitWallet,
90 authMnemonic,
92 authMnemonic,
91 setAuthMnemonic,
93 setAuthMnemonic,
94+ //
95+ networkSeed,
96+ setNetworkSeed,
97+ networkRevision,
98+ setNetowrkRevision,
92 };
99 };
93}
100}
94
101
src/bridge/views/GenKeyfile.js+3−4
@@ -34,8 +34,7 @@ class GenKeyfile extends React.Component {
34 // in case we did SetKeys earlier this session, make sure to generate the
34 // in case we did SetKeys earlier this session, make sure to generate the
35 // newer keyfile, rather than the one that will expire soon
35 // newer keyfile, rather than the one that will expire soon
36 const revision =
36 const revision =
37− this.props.networkRevisionCache ||
38− parseInt(pointDetails.keyRevisionNumber);
37+ this.props.networkRevision || parseInt(pointDetails.keyRevisionNumber);
39
38
40 return {
39 return {
41 point,
40 point,
@@ -81,8 +80,8 @@ class GenKeyfile extends React.Component {
81 const next = false;
80 const next = false;
82 let seed = await attemptSeedDerivation(next, this.props);
81 let seed = await attemptSeedDerivation(next, this.props);
83
82
84− if (seed.getOrElse('') === '' && this.props.networkSeedCache) {
83+ if (seed.getOrElse('') === '' && this.props.networkSeed) {
85− seed = Maybe.Just(this.props.networkSeedCache);
84+ seed = Maybe.Just(this.props.networkSeed);
86 }
85 }
87
86
88 return seed.getOrElse('');
87 return seed.getOrElse('');
src/bridge/views/SetKeys.js+1−2
@@ -191,9 +191,8 @@ class SetKeys extends React.Component {
191 // Tx
191 // Tx
192 canGenerate={canGenerate}
192 canGenerate={canGenerate}
193 createUnsignedTxn={this.createUnsignedTxn}
193 createUnsignedTxn={this.createUnsignedTxn}
194− networkSeed={state.networkSeed}
194+ newNetworkSeed={state.networkSeed}
195 newRevision={parseInt(pointDetails.keyRevisionNumber) + 1}
195 newRevision={parseInt(pointDetails.keyRevisionNumber) + 1}
196− setNetworkSeedCache={props.setNetworkSeedCache}
197 />
196 />
198 </Col>
197 </Col>
199 </Row>
198 </Row>