on abbbcbc help sign in
bridge/src/views/Point/KeysAndMetadata.js
150 lines 3.7 kB history raw
1import React from 'react';
2import { H2, H4 } from '../../components/old/Base';
4import { CURVE_ZERO_ADDR, isZeroAddress } from '../../lib/wallet';
5import { Grid } from 'indigo-react';
7const renderAddress = addr =>
8 isZeroAddress(addr) ? (
9 <div>{'(not set)'}</div>
10 ) : (
11 <div>
12 <div>
13 <code>{addr.slice(0, 14)}</code>
14 </div>
15 <div>
16 <code>{addr.slice(14, 28)}</code>
17 </div>
18 <div>
19 <code>{addr.slice(28)}</code>
20 </div>
21 </div>
22 );
24const renderNetworkKey = hex => {
25 const sl = i => hex.slice(i, i + 4);
26 const rowFrom = i => `${sl(i)}.${sl(i + 4)}.${sl(i + 8)}.${sl(i + 12)}`;
27 return hex === CURVE_ZERO_ADDR ? (
28 <div>{'(not set)'}</div>
29 ) : (
30 <div>
31 <div>
32 <code>{hex.slice(0, 2)}</code>
33 </div>
34 <div>
35 <code>{rowFrom(2)}</code>
36 </div>
37 <div>
38 <code>{rowFrom(18)}</code>
39 </div>
40 <div>
41 <code>{rowFrom(34)}</code>
42 </div>
43 <div>
44 <code>{rowFrom(50)}</code>
45 </div>
46 </div>
47 );
48};
50const KeysAndMetadata = props => {
51 const { pointDetails } = props;
53 return (
54 <Grid>
55 <Grid.Item full>
56 <H2>{'Ownership and Proxy Addresses'}</H2>
57 </Grid.Item>
58 <Grid.Item fourth={1}>
59 <H4>{'Owner'}</H4>
60 {pointDetails.matchWith({
61 Nothing: () => <div />,
62 Just: deets => renderAddress(deets.value.owner),
63 })}
64 </Grid.Item>
65 <Grid.Item fourth={2}>
66 <H4>{'Transfer Proxy'}</H4>
67 {pointDetails.matchWith({
68 Nothing: () => <div />,
69 Just: deets => renderAddress(deets.value.transferProxy),
70 })}
71 </Grid.Item>
72 <Grid.Item fourth={3}>
73 <H4>{'Spawn Proxy'}</H4>
74 {pointDetails.matchWith({
75 Nothing: () => <div />,
76 Just: deets => renderAddress(deets.value.spawnProxy),
77 })}
78 </Grid.Item>
79 <Grid.Item fourth={4}>
80 <H4>{'Mgmt Proxy'}</H4>
81 {pointDetails.matchWith({
82 Nothing: () => <div />,
83 Just: deets => renderAddress(deets.value.managementProxy),
84 })}
85 </Grid.Item>
86 <Grid.Item full>
87 <UrbitNetworking pointDetails={pointDetails} />
88 </Grid.Item>
89 </Grid>
90 );
91};
93const UrbitNetworking = props => {
94 const { pointDetails } = props;
96 const booted = pointDetails.matchWith({
97 Nothing: _ => false,
98 Just: details => details.value.keyRevisionNumber > 0,
99 });
101 const body = !booted ? (
102 <div>{'(not set)'}</div>
103 ) : (
104 <Grid>
105 <Grid.Item third={1}>
106 <H4>{'Authentication'}</H4>
107 {pointDetails.matchWith({
108 Nothing: () => <div />,
109 Just: deets => renderNetworkKey(deets.value.authenticationKey),
110 })}
111 </Grid.Item>
112 <Grid.Item third={2}>
113 <H4>{'Encryption'}</H4>
114 {pointDetails.matchWith({
115 Nothing: () => <div />,
116 Just: deets => renderNetworkKey(deets.value.encryptionKey),
117 })}
118 </Grid.Item>
119 <Grid.Item third={3}>
120 <H4>{'Revision'}</H4>
121 {pointDetails.matchWith({
122 Nothing: () => '-',
123 Just: deets => deets.value.keyRevisionNumber,
124 })}
126 <H4>{'Continuity era'}</H4>
127 {pointDetails.matchWith({
128 Nothing: () => '-',
129 Just: deets => deets.value.continuityNumber,
130 })}
132 <H4>{'Crypto suite version'}</H4>
133 {pointDetails.matchWith({
134 Nothing: () => '-',
135 Just: deets => deets.value.cryptoSuiteVersion,
136 })}
137 </Grid.Item>
138 </Grid>
139 );
141 return (
142 <div>
143 <H2>{'Public Keys'}</H2>
145 {body}
146 </div>
147 );
148};
150export default KeysAndMetadata;