on e366ef3 help sign in
bridge/src/views/Point/KeysAndMetadata.js
159 lines 4.0 kB history raw
1import React from 'react';
2import { Row, Col, H2, H4 } from '../../components/old/Base';
4import { ETH_ZERO_ADDR, eqAddr } from '../../lib/wallet';
6const NULL_KEY =
7 '0x0000000000000000000000000000000000000000000000000000000000000000';
9const renderAddress = addr =>
10 eqAddr(addr, ETH_ZERO_ADDR) ? (
11 <div>{'(not set)'}</div>
12 ) : (
13 <div>
14 <div>
15 <code>{addr.slice(0, 14)}</code>
16 </div>
17 <div>
18 <code>{addr.slice(14, 28)}</code>
19 </div>
20 <div>
21 <code>{addr.slice(28)}</code>
22 </div>
23 </div>
24 );
26const renderNetworkKey = hex => {
27 const sl = i => hex.slice(i, i + 4);
28 const rowFrom = i => `${sl(i)}.${sl(i + 4)}.${sl(i + 8)}.${sl(i + 12)}`;
29 return hex === NULL_KEY ? (
30 <div>{'(not set)'}</div>
31 ) : (
32 <div>
33 <div>
34 <code>{hex.slice(0, 2)}</code>
35 </div>
36 <div>
37 <code>{rowFrom(2)}</code>
38 </div>
39 <div>
40 <code>{rowFrom(18)}</code>
41 </div>
42 <div>
43 <code>{rowFrom(34)}</code>
44 </div>
45 <div>
46 <code>{rowFrom(50)}</code>
47 </div>
48 </div>
49 );
50};
52const KeysAndMetadata = props => {
53 const { pointDetails } = props;
55 return (
56 <Row>
57 <Col>
58 <H2>{'Ownership and Proxy Addresses'}</H2>
60 <Row>
61 <Col className={'flex flex-column items-start col-md-3'}>
62 <H4>{'Owner'}</H4>
63 {pointDetails.matchWith({
64 Nothing: () => <div />,
65 Just: deets => renderAddress(deets.value.owner),
66 })}
67 </Col>
69 <Col className={'flex flex-column items-start col-md-3'}>
70 <H4>{'Transfer Proxy'}</H4>
71 {pointDetails.matchWith({
72 Nothing: () => <div />,
73 Just: deets => renderAddress(deets.value.transferProxy),
74 })}
75 </Col>
77 <Col className={'flex flex-column items-start col-md-3'}>
78 <H4>{'Spawn Proxy'}</H4>
79 {pointDetails.matchWith({
80 Nothing: () => <div />,
81 Just: deets => renderAddress(deets.value.spawnProxy),
82 })}
83 </Col>
85 <Col className={'flex flex-column items-start col-md-3'}>
86 <H4>{'Mgmt Proxy'}</H4>
87 {pointDetails.matchWith({
88 Nothing: () => <div />,
89 Just: deets => renderAddress(deets.value.managementProxy),
90 })}
91 </Col>
92 </Row>
94 <UrbitNetworking pointDetails={pointDetails} />
95 </Col>
96 </Row>
97 );
98};
100const UrbitNetworking = props => {
101 const { pointDetails } = props;
103 const booted = pointDetails.matchWith({
104 Nothing: _ => false,
105 Just: details => details.value.keyRevisionNumber > 0,
106 });
108 const body = !booted ? (
109 <div>{'(not set)'}</div>
110 ) : (
111 <Row>
112 <Col className={'flex flex-column items-start col-md-4'}>
113 <H4>{'Authentication'}</H4>
114 {pointDetails.matchWith({
115 Nothing: () => <div />,
116 Just: deets => renderNetworkKey(deets.value.authenticationKey),
117 })}
118 </Col>
120 <Col className={'flex flex-column items-start col-md-4'}>
121 <H4>{'Encryption'}</H4>
122 {pointDetails.matchWith({
123 Nothing: () => <div />,
124 Just: deets => renderNetworkKey(deets.value.encryptionKey),
125 })}
126 </Col>
128 <Col className={'flex flex-column items-start col-md-4'}>
129 <H4>{'Revision'}</H4>
130 {pointDetails.matchWith({
131 Nothing: () => '-',
132 Just: deets => deets.value.keyRevisionNumber,
133 })}
135 <H4>{'Continuity era'}</H4>
136 {pointDetails.matchWith({
137 Nothing: () => '-',
138 Just: deets => deets.value.continuityNumber,
139 })}
141 <H4>{'Crypto suite version'}</H4>
142 {pointDetails.matchWith({
143 Nothing: () => '-',
144 Just: deets => deets.value.cryptoSuiteVersion,
145 })}
146 </Col>
147 </Row>
148 );
150 return (
151 <div>
152 <H2>{'Public Keys'}</H2>
154 {body}
155 </div>
156 );
157};
159export default KeysAndMetadata;