on master help sign in
- Disabled ‘network seed’ field in setkeys.js if it’s already pre-filled
8fc9df1Chris Johnson
src/views/SetKeys.js+22−3
@@ -44,6 +44,7 @@ class SetKeys extends React.Component {
44 continuity: false,
44 continuity: false,
45 txn: Maybe.Nothing(),
45 txn: Maybe.Nothing(),
46 txError: Maybe.Nothing(),
46 txError: Maybe.Nothing(),
47+ isManagementSeed: false,
47 userApproval: false,
48 userApproval: false,
48 nonce: '',
49 nonce: '',
49 gasPrice: '5',
50 gasPrice: '5',
@@ -65,7 +66,6 @@ class SetKeys extends React.Component {
65 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
66 this.handleSetGasLimit = this.handleSetGasLimit.bind(this)
66 }
67 }
67
68
68−
69 componentDidMount() {
69 componentDidMount() {
70 const { props } = this
70 const { props } = this
71
71
@@ -78,6 +78,8 @@ class SetKeys extends React.Component {
78 }
78 }
79 })
79 })
80
80
81+ this.determineManagementSeed(props.contracts.value, addr)
82+
81 props.web3.matchWith({
83 props.web3.matchWith({
82 Nothing: () => {},
84 Nothing: () => {},
83 Just: (w3) => {
85 Just: (w3) => {
@@ -101,9 +103,16 @@ class SetKeys extends React.Component {
101 })
103 })
102 }
104 }
103 });
105 });
104−
105 }
106 }
106
107
108+ async determineManagementSeed(ctrcs, addr) {
109+ const managing =
110+ await azimuth.azimuth.getManagerFor(ctrcs, addr)
111+
112+ this.setState({
113+ isManagementSeed: managing.length !== 0
114+ })
115+ }
107
116
108 async deriveSeed() {
117 async deriveSeed() {
109 const next = true
118 const next = true
@@ -282,6 +291,16 @@ class SetKeys extends React.Component {
282 ? props.pointCache[state.point]
291 ? props.pointCache[state.point]
283 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
292 : (() => { throw BRIDGE_ERROR.MISSING_POINT })()
284
293
294+ const isManagementMnemonic =
295+ this.state.isManagementSeed &&
296+ props.walletType === WALLET_NAMES.MNEMONIC
297+
298+ const isMasterTicket =
299+ props.walletType === WALLET_NAMES.TICKET ||
300+ props.walletType === WALLET_NAMES.SHARD
301+
302+ const networkSeedDisabled = isManagementMnemonic || isMasterTicket;
303+
285 return (
304 return (
286 <Row>
305 <Row>
287 <Col>
306 <Col>
@@ -318,7 +337,7 @@ class SetKeys extends React.Component {
318 prop-size='lg'
337 prop-size='lg'
319 prop-format='innerLabel'
338 prop-format='innerLabel'
320 autoFocus
339 autoFocus
321− disabled= { props.walletType === WALLET_NAMES.TICKET || props.walletType === WALLET_NAMES.SHARD}
340+ disabled= { networkSeedDisabled }
322 value={ state.networkSeed }
341 value={ state.networkSeed }
323 onChange={ this.handleNetworkSeedInput }>
342 onChange={ this.handleNetworkSeedInput }>
324 <InnerLabel>{ 'Network seed' }</InnerLabel>
343 <InnerLabel>{ 'Network seed' }</InnerLabel>