on master help sign in
Merge pull request #78 from urbit/set-keys-disabled
7ae8f22Christopher Johnson
src/components/ProtoInput.js+1
@@ -18,6 +18,7 @@ const ProtoInput = props => {
18 onFocus={e => props.onFocus(e)}
18 onFocus={e => props.onFocus(e)}
19 onBlur={e => props.onBlur(e)}
19 onBlur={e => props.onBlur(e)}
20 placeholder={props.placeholder}
20 placeholder={props.placeholder}
21+ disabled={props.disabled}
21 type={props.type}
22 type={props.type}
22 name={props.name}
23 name={props.name}
23 style={props.style}
24 style={props.style}
src/components/advancedInput.js+1−2
@@ -118,6 +118,7 @@ const advancedInput = ({
118 didPass={ report.pass }
118 didPass={ report.pass }
119 value={props.value}
119 value={props.value}
120 className={ props.className }
120 className={ props.className }
121+ disabled={ props.disabled }
121 valClassname={valClassname}
122 valClassname={valClassname}
122 advanced={true} />
123 advanced={true} />
123 )
124 )
@@ -148,6 +149,4 @@ const styleSelector = (pass, fail) => {
148 return 'br-gray-50 f-br-blue outline-blue'
149 return 'br-gray-50 f-br-blue outline-blue'
149}
150}
150
151
151−
152−
153export default advancedInput;
152export default advancedInput;
src/style/input.css+4
@@ -49,3 +49,7 @@ input[prop-format*='innerLabel'][prop-size='md'] {
49 padding-left: 4rem;
49 padding-left: 4rem;
50 padding-right: 4rem;
50 padding-right: 4rem;
51}
51}
52+
53+input[disabled] {
54+ background-color: #d3d3d3;
55+}
src/views/SetKeys.js+23−1
@@ -10,6 +10,8 @@ import { BRIDGE_ERROR } from '../lib/error'
10import { ROUTE_NAMES } from '../lib/router'
10import { ROUTE_NAMES } from '../lib/router'
11import { attemptSeedDerivation } from '../lib/keys'
11import { attemptSeedDerivation } from '../lib/keys'
12
12
13+import { WALLET_NAMES } from '../lib/wallet'
14+
13import * as kg from '../../node_modules/urbit-key-generation/dist/index'
15import * as kg from '../../node_modules/urbit-key-generation/dist/index'
14
16
15import {
17import {
@@ -42,6 +44,7 @@ class SetKeys extends React.Component {
42 continuity: false,
44 continuity: false,
43 txn: Maybe.Nothing(),
45 txn: Maybe.Nothing(),
44 txError: Maybe.Nothing(),
46 txError: Maybe.Nothing(),
47+ isManagementSeed: false,
45 userApproval: false,
48 userApproval: false,
46 nonce: '',
49 nonce: '',
47 gasPrice: '5',
50 gasPrice: '5',
@@ -83,6 +86,8 @@ class SetKeys extends React.Component {
83 }
86 }
84 })
87 })
85
88
89+ this.determineManagementSeed(props.contracts.value, addr)
90+
86 props.web3.matchWith({
91 props.web3.matchWith({
87 Nothing: () => {},
92 Nothing: () => {},
88 Just: (w3) => {
93 Just: (w3) => {
@@ -106,9 +111,16 @@ class SetKeys extends React.Component {
106 })
111 })
107 }
112 }
108 });
113 });
109−
110 }
114 }
111
115
116+ async determineManagementSeed(ctrcs, addr) {
117+ const managing =
118+ await azimuth.azimuth.getManagerFor(ctrcs, addr)
119+
120+ this.setState({
121+ isManagementSeed: managing.length !== 0
122+ })
123+ }
112
124
113 async deriveSeed() {
125 async deriveSeed() {
114 const next = true
126 const next = true
@@ -287,6 +299,15 @@ class SetKeys extends React.Component {
287 ? props.pointCache[state.point]
299 ? props.pointCache[state.point]
288 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
300 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
289
301
302+ const isManagementMnemonic =
303+ this.state.isManagementSeed &&
304+ props.walletType === WALLET_NAMES.MNEMONIC
305+
306+ const isMasterTicket =
307+ props.walletType === WALLET_NAMES.TICKET ||
308+ props.walletType === WALLET_NAMES.SHARD
309+
310+ const networkSeedDisabled = isManagementMnemonic || isMasterTicket;
290
311
291 return (
312 return (
292 <Row>
313 <Row>
@@ -324,6 +345,7 @@ class SetKeys extends React.Component {
324 prop-size='lg'
345 prop-size='lg'
325 prop-format='innerLabel'
346 prop-format='innerLabel'
326 autoFocus
347 autoFocus
348+ disabled= { networkSeedDisabled }
327 value={ state.networkSeed }
349 value={ state.networkSeed }
328 onChange={ this.handleNetworkSeedInput }>
350 onChange={ this.handleNetworkSeedInput }>
329 <InnerLabel>{ 'Network seed' }</InnerLabel>
351 <InnerLabel>{ 'Network seed' }</InnerLabel>