on master help sign in
Merge pull request #78 from urbit/set-keys-disabled

Network seed disabled

commit7ae8f2241a3703c26e675e89127ceeff565c616a authorChristopher Johnson <chris@cjohnson.io> dateMon 18 Mar 2019, 15:37 (8 years ago) parentda9327a2a02c7e
4 files changed+29−3
src/components/ProtoInput.js+1 src/components/advancedInput.js+1−2 src/style/input.css+4 src/views/SetKeys.js+23−1
src/components/ProtoInput.js+1
@@ -18,6 +18,7 @@ const ProtoInput = props => {
1818 onFocus={e => props.onFocus(e)}
1919 onBlur={e => props.onBlur(e)}
2020 placeholder={props.placeholder}
21+ disabled={props.disabled}
2122 type={props.type}
2223 name={props.name}
2324 style={props.style}
src/components/advancedInput.js+1−2
@@ -118,6 +118,7 @@ const advancedInput = ({
118118 didPass={ report.pass }
119119 value={props.value}
120120 className={ props.className }
121+ disabled={ props.disabled }
121122 valClassname={valClassname}
122123 advanced={true} />
123124 )
@@ -148,6 +149,4 @@ const styleSelector = (pass, fail) => {
148149 return 'br-gray-50 f-br-blue outline-blue'
149150}
150151
151−
152−
153152export default advancedInput;
src/style/input.css+4
@@ -49,3 +49,7 @@ input[prop-format*='innerLabel'][prop-size='md'] {
4949 padding-left: 4rem;
5050 padding-right: 4rem;
5151}
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'
1010import { ROUTE_NAMES } from '../lib/router'
1111import { attemptSeedDerivation } from '../lib/keys'
1212
13+import { WALLET_NAMES } from '../lib/wallet'
14+
1315import * as kg from '../../node_modules/urbit-key-generation/dist/index'
1416
1517import {
@@ -42,6 +44,7 @@ class SetKeys extends React.Component {
4244 continuity: false,
4345 txn: Maybe.Nothing(),
4446 txError: Maybe.Nothing(),
47+ isManagementSeed: false,
4548 userApproval: false,
4649 nonce: '',
4750 gasPrice: '5',
@@ -83,6 +86,8 @@ class SetKeys extends React.Component {
8386 }
8487 })
8588
89+ this.determineManagementSeed(props.contracts.value, addr)
90+
8691 props.web3.matchWith({
8792 Nothing: () => {},
8893 Just: (w3) => {
@@ -106,9 +111,16 @@ class SetKeys extends React.Component {
106111 })
107112 }
108113 });
109−
110114 }
111115
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+ }
112124
113125 async deriveSeed() {
114126 const next = true
@@ -287,6 +299,15 @@ class SetKeys extends React.Component {
287299 ? props.pointCache[state.point]
288300 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
289301
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;
290311
291312 return (
292313 <Row>
@@ -324,6 +345,7 @@ class SetKeys extends React.Component {
324345 prop-size='lg'
325346 prop-format='innerLabel'
326347 autoFocus
348+ disabled= { networkSeedDisabled }
327349 value={ state.networkSeed }
328350 onChange={ this.handleNetworkSeedInput }>
329351 <InnerLabel>{ 'Network seed' }</InnerLabel>