on master help sign in
Remove unused views
commit6da429ea35a4a5194aa810026ee1fe501da2f852 authorFang <git@fang.io> dateFri 19 Jul 2019, 16:17 (7 years ago) parenta8b72eb
3 files changed−481
src/views/GenKeyfile.js−142 src/views/Point/Actions.js−188 src/views/Point/KeysAndMetadata.js−151
src/views/GenKeyfile.jsdeleted−142
@@ -1,142 +0,0 @@
1−import React from 'react';
2−import * as need from '../lib/need';
3−
4−import { Button } from '../components/old/Base';
5−import { H1, P } from '../components/old/Base';
6−
7−import * as ob from 'urbit-ob';
8−import * as kg from 'urbit-key-generation/dist';
9−import saveAs from 'file-saver';
10−
11−import { attemptNetworkSeedDerivation, genKey } from '../lib/keys';
12−import { addHexPrefix } from '../lib/wallet';
13−import { compose } from '../lib/lib';
14−import { withWallet } from '../store/wallet';
15−import { withPointCursor } from '../store/pointCursor';
16−import { withPointCache } from '../store/pointCache';
17−import View from 'components/View';
18−
19−class GenKeyfile extends React.Component {
20− constructor(props) {
21− super(props);
22−
23− this.state = {
24− keyfile: '',
25− loaded: false,
26− };
27− }
28−
29− getPointDetails() {
30− const point = need.point(this.props.pointCursor);
31− const pointDetails = need.fromPointCache(this.props.pointCache, point);
32−
33− // in case we did SetKeys earlier this session, make sure to generate the
34− // newer keyfile, rather than the one that will expire soon
35− const revision = this.props.networkRevision.matchWith({
36− Nothing: () => parseInt(pointDetails.keyRevisionNumber, 10),
37− Just: p => p.value,
38− });
39−
40− return {
41− point,
42− pointDetails,
43− revision,
44− };
45− }
46−
47− async componentDidMount() {
48− const { point, pointDetails, revision } = this.getPointDetails();
49− let keyfile = '';
50−
51− const hexRegExp = /[0-9A-Fa-f]{64}/g;
52− const networkSeed = await this.deriveSeed();
53−
54− const keysmatch = this.checkKeysMatch(networkSeed, pointDetails);
55− const seedValid = hexRegExp.test(networkSeed);
56−
57− if (keysmatch && seedValid) {
58− keyfile = genKey(networkSeed, point, revision);
59− }
60−
61− this.setState({
62− keyfile: keyfile,
63− loaded: true,
64− });
65− }
66−
67− checkKeysMatch(networkSeed, pointDetails) {
68− const crypub = pointDetails.encryptionKey;
69− const sgnpub = pointDetails.authenticationKey;
70−
71− const { crypt, auth } = kg.deriveNetworkKeys(networkSeed);
72−
73− const keysmatch =
74− crypub === addHexPrefix(crypt.public) &&
75− sgnpub === addHexPrefix(auth.public);
76−
77− return keysmatch;
78− }
79−
80− async deriveSeed() {
81− const next = false;
82−
83− const seed = await attemptNetworkSeedDerivation(next, this.props);
84−
85− // either return the derived seed, the cached seed, or empty string
86− return seed.matchWith({
87− Nothing: () => this.props.networkSeed.getOrElse(''),
88− Just: p => p.value,
89− });
90− }
91−
92− render() {
93− const { point, revision } = this.getPointDetails();
94− const { keyfile, loaded } = this.state;
95−
96− return (
97− <View>
98− <H1>{'Generate keyfile'}</H1>
99−
100− <P>{'Download a private key file for booting this point in Arvo.'}</P>
101−
102− {keyfile === '' && !loaded && <P>{'Generating keyfile...'}</P>}
103−
104− {keyfile === '' && loaded && (
105− <React.Fragment>
106− <P>
107− <b>Warning: </b>
108− {`No valid network seed detected. To generate a keyfile, you
109− must reset your networking keys, or try logging in with your
110− master ticket or management mnemonic.`}
111− </P>
112−
113− <P>
114− {`If you've just reset your networking keys, you may need to wait for the transaction to go through. Check back shortly.`}
115− </P>
116− </React.Fragment>
117− )}
118−
119− {keyfile !== '' && (
120− <React.Fragment>
121− <div className="pb-5 text-code keyfile">{keyfile}</div>
122− <Button
123− onClick={() => {
124− let blob = new Blob([keyfile], {
125− type: 'text/plain;charset=utf-8',
126− });
127− saveAs(blob, `${ob.patp(point).slice(1)}-${revision}.key`);
128− }}>
129− Download →
130− </Button>
131− </React.Fragment>
132− )}
133− </View>
134− );
135− }
136−}
137−
138−export default compose(
139− withWallet,
140− withPointCursor,
141− withPointCache
142−)(GenKeyfile);
src/views/Point/Actions.jsdeleted−188
@@ -1,188 +0,0 @@
1−import React from 'react';
2−import { azimuth } from 'azimuth-js';
3−import * as need from '../../lib/need';
4−
5−import { isZeroAddress, eqAddr } from '../../lib/wallet';
6−import { H2, P } from '../../components/old/Base';
7−import { Button } from '../../components/old/Base';
8−import { ROUTE_NAMES } from '../../lib/routeNames';
9−import { useHistory } from '../../store/history';
10−import { useWallet } from '../../store/wallet';
11−import { Grid } from 'indigo-react';
12−import { usePointCursor } from 'store/pointCursor';
13−import { usePointCache } from 'store/pointCache';
14−import { CURVE_ZERO_ADDR } from 'lib/keys';
15−
16−const isPlanet = point =>
17− azimuth.getPointSize(point) === azimuth.PointSize.Planet;
18−
19−function Actions() {
20− const history = useHistory();
21− const { wallet } = useWallet();
22− const { pointCursor } = usePointCursor();
23− const point = need.point(pointCursor);
24− const { getDetails } = usePointCache();
25− const pointDetails = getDetails(point);
26−
27− const addr = need.addressFromWallet(wallet);
28−
29− const planet = isPlanet(point);
30−
31− const isOwner = pointDetails.matchWith({
32− Nothing: _ => false,
33− Just: details => eqAddr(details.value.owner, addr),
34− });
35− const isActive = pointDetails.matchWith({
36− Nothing: _ => false,
37− Just: details => details.value.active,
38− });
39− const isActiveOwner = isOwner && isActive;
40− const canSetSpawnProxy = isActiveOwner && !planet;
41− const canSetManagementProxy = isActiveOwner;
42−
43− const canManage =
44− isOwner ||
45− pointDetails.matchWith({
46− Nothing: _ => false,
47− Just: details => eqAddr(details.value.managementProxy, addr),
48− });
49− const canConfigureKeys = canManage && isActive;
50−
51− const canIssueChild = pointDetails.matchWith({
52− Nothing: () => false,
53− Just: details => {
54− const hasPermission = isOwner || eqAddr(details.value.spawnProxy, addr);
55−
56− const isBooted = details.value.keyRevisionNumber > 0;
57−
58− const isNotPlanet = !isPlanet(point);
59−
60− return hasPermission && isBooted && isNotPlanet;
61− },
62− });
63−
64− const canTransfer = pointDetails.matchWith({
65− Nothing: () => false,
66− Just: deets =>
67− eqAddr(deets.value.transferProxy, addr) ||
68− eqAddr(deets.value.owner, addr),
69− });
70−
71− const canAcceptTransfer = pointDetails.matchWith({
72− Nothing: () => false,
73− Just: deets => eqAddr(deets.value.transferProxy, addr),
74− });
75−
76− const canCancelTransfer = pointDetails.matchWith({
77− Nothing: () => false,
78− Just: deets =>
79− eqAddr(deets.value.owner, addr) &&
80− !isZeroAddress(deets.value.transferProxy),
81− });
82−
83− const displayReminder = pointDetails.matchWith({
84− Nothing: () => false,
85− Just: deets => {
86− return (
87− deets.value.encryptionKey === CURVE_ZERO_ADDR &&
88− deets.value.authenticationKey === CURVE_ZERO_ADDR
89− );
90− },
91− });
92−
93− return (
94− <div>
95− <H2>{'Actions'}</H2>
96− {displayReminder ? (
97− <P>{`Before you can issue child points or generate your Arvo
98− keyfile, you need to set your public keys.`}</P>
99− ) : (
100− ''
101− )}
102− <Grid>
103− <Grid.Item third={1}>
104− <Button
105− prop-size={'sm'}
106− prop-type={'link'}
107− disabled={planet && !canIssueChild}
108− onClick={() => {
109− history.push(ROUTE_NAMES.ISSUE_CHILD);
110− }}>
111− {'Issue child'}
112− </Button>
113−
114− <Button
115− prop-size={'sm'}
116− prop-type={'link'}
117− disabled={!canAcceptTransfer}
118− onClick={() => {
119− history.push(ROUTE_NAMES.ACCEPT_TRANSFER);
120− }}>
121− {'Accept incoming transfer'}
122− </Button>
123−
124− <Button
125− prop-size={'sm'}
126− prop-type={'link'}
127− disabled={!canCancelTransfer}
128− onClick={() => {
129− history.push(ROUTE_NAMES.CANCEL_TRANSFER);
130− }}>
131− {'Cancel outgoing transfer'}
132− </Button>
133− </Grid.Item>
134− <Grid.Item third={2}>
135− <Button
136− disabled={!canSetSpawnProxy}
137− prop-size={'sm'}
138− prop-type={'link'}
139− onClick={() => {
140− history.push(ROUTE_NAMES.SET_SPAWN_PROXY);
141− }}>
142− {'Change spawn proxy'}
143− </Button>
144−
145− <Button
146− disabled={!canSetManagementProxy}
147− prop-size={'sm'}
148− prop-type={'link'}
149− onClick={() => {
150− history.push(ROUTE_NAMES.SET_MANAGEMENT_PROXY);
151− }}>
152− {'Change management proxy'}
153− </Button>
154−
155− <Button
156− disabled={!canConfigureKeys}
157− prop-size={'sm'}
158− prop-type={'link'}
159− onClick={() => {
160− history.push(ROUTE_NAMES.SET_KEYS);
161− }}>
162− {'Set network keys'}
163− </Button>
164−
165− <Button
166− disabled={!canTransfer}
167− prop-size={'sm'}
168− prop-type={'link'}
169− onClick={() => {
170− history.push(ROUTE_NAMES.TRANSFER);
171− }}>
172− {'Transfer'}
173− </Button>
174− <Button
175− prop-size={'sm'}
176− prop-type={'link'}
177− onClick={() => {
178− history.push(ROUTE_NAMES.INVITES_MANAGE);
179− }}>
180− {'Invite'}
181− </Button>
182− </Grid.Item>
183− </Grid>
184− </div>
185− );
186−}
187−
188−export default Actions;
src/views/Point/KeysAndMetadata.jsdeleted−151
@@ -1,151 +0,0 @@
1−import React from 'react';
2−import { H2, H4 } from '../../components/old/Base';
3−
4−import { isZeroAddress } from '../../lib/wallet';
5−import { Grid } from 'indigo-react';
6−import { CURVE_ZERO_ADDR } from 'lib/keys';
7−
8−const renderAddress = addr =>
9− isZeroAddress(addr) ? (
10− <div>{'(not set)'}</div>
11− ) : (
12− <div>
13− <div>
14− <code>{addr.slice(0, 14)}</code>
15− </div>
16− <div>
17− <code>{addr.slice(14, 28)}</code>
18− </div>
19− <div>
20− <code>{addr.slice(28)}</code>
21− </div>
22− </div>
23− );
24−
25−const renderNetworkKey = hex => {
26− const sl = i => hex.slice(i, i + 4);
27− const rowFrom = i => `${sl(i)}.${sl(i + 4)}.${sl(i + 8)}.${sl(i + 12)}`;
28− return hex === CURVE_ZERO_ADDR ? (
29− <div>{'(not set)'}</div>
30− ) : (
31− <div>
32− <div>
33− <code>{hex.slice(0, 2)}</code>
34− </div>
35− <div>
36− <code>{rowFrom(2)}</code>
37− </div>
38− <div>
39− <code>{rowFrom(18)}</code>
40− </div>
41− <div>
42− <code>{rowFrom(34)}</code>
43− </div>
44− <div>
45− <code>{rowFrom(50)}</code>
46− </div>
47− </div>
48− );
49−};
50−
51−const KeysAndMetadata = props => {
52− const { pointDetails } = props;
53−
54− return (
55− <Grid>
56− <Grid.Item full>
57− <H2>{'Ownership and Proxy Addresses'}</H2>
58− </Grid.Item>
59− <Grid.Item fourth={1}>
60− <H4>{'Owner'}</H4>
61− {pointDetails.matchWith({
62− Nothing: () => <div />,
63− Just: deets => renderAddress(deets.value.owner),
64− })}
65− </Grid.Item>
66− <Grid.Item fourth={2}>
67− <H4>{'Transfer Proxy'}</H4>
68− {pointDetails.matchWith({
69− Nothing: () => <div />,
70− Just: deets => renderAddress(deets.value.transferProxy),
71− })}
72− </Grid.Item>
73− <Grid.Item fourth={3}>
74− <H4>{'Spawn Proxy'}</H4>
75− {pointDetails.matchWith({
76− Nothing: () => <div />,
77− Just: deets => renderAddress(deets.value.spawnProxy),
78− })}
79− </Grid.Item>
80− <Grid.Item fourth={4}>
81− <H4>{'Mgmt Proxy'}</H4>
82− {pointDetails.matchWith({
83− Nothing: () => <div />,
84− Just: deets => renderAddress(deets.value.managementProxy),
85− })}
86− </Grid.Item>
87− <Grid.Item full>
88− <UrbitNetworking pointDetails={pointDetails} />
89− </Grid.Item>
90− </Grid>
91− );
92−};
93−
94−const UrbitNetworking = props => {
95− const { pointDetails } = props;
96−
97− const booted = pointDetails.matchWith({
98− Nothing: _ => false,
99− Just: details => details.value.keyRevisionNumber > 0,
100− });
101−
102− const body = !booted ? (
103− <div>{'(not set)'}</div>
104− ) : (
105− <Grid>
106− <Grid.Item third={1}>
107− <H4>{'Authentication'}</H4>
108− {pointDetails.matchWith({
109− Nothing: () => <div />,
110− Just: deets => renderNetworkKey(deets.value.authenticationKey),
111− })}
112− </Grid.Item>
113− <Grid.Item third={2}>
114− <H4>{'Encryption'}</H4>
115− {pointDetails.matchWith({
116− Nothing: () => <div />,
117− Just: deets => renderNetworkKey(deets.value.encryptionKey),
118− })}
119− </Grid.Item>
120− <Grid.Item third={3}>
121− <H4>{'Revision'}</H4>
122− {pointDetails.matchWith({
123− Nothing: () => '-',
124− Just: deets => deets.value.keyRevisionNumber,
125− })}
126−
127− <H4>{'Continuity era'}</H4>
128− {pointDetails.matchWith({
129− Nothing: () => '-',
130− Just: deets => deets.value.continuityNumber,
131− })}
132−
133− <H4>{'Crypto suite version'}</H4>
134− {pointDetails.matchWith({
135− Nothing: () => '-',
136− Just: deets => deets.value.cryptoSuiteVersion,
137− })}
138− </Grid.Item>
139− </Grid>
140− );
141−
142− return (
143− <div>
144− <H2>{'Public Keys'}</H2>
145−
146− {body}
147− </div>
148− );
149−};
150−
151−export default KeysAndMetadata;