on a8b72eb help sign in
bridge/src/views/Point/KeysAndMetadata.js
151 lines 3.7 kB history raw
1import React from 'react';
2import { H2, H4 } from '../../components/old/Base';
4import { isZeroAddress } from '../../lib/wallet';
5import { Grid } from 'indigo-react';
6import { CURVE_ZERO_ADDR } from 'lib/keys';
8const 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 );
25const 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};
51const KeysAndMetadata = props => {
52 const { pointDetails } = props;
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};
94const UrbitNetworking = props => {
95 const { pointDetails } = props;
97 const booted = pointDetails.matchWith({
98 Nothing: _ => false,
99 Just: details => details.value.keyRevisionNumber > 0,
100 });
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 })}
127 <H4>{'Continuity era'}</H4>
128 {pointDetails.matchWith({
129 Nothing: () => '-',
130 Just: deets => deets.value.continuityNumber,
131 })}
133 <H4>{'Crypto suite version'}</H4>
134 {pointDetails.matchWith({
135 Nothing: () => '-',
136 Just: deets => deets.value.cryptoSuiteVersion,
137 })}
138 </Grid.Item>
139 </Grid>
140 );
142 return (
143 <div>
144 <H2>{'Public Keys'}</H2>
146 {body}
147 </div>
148 );
149};
151export default KeysAndMetadata;