on 05c1914 help sign in
bridge/src/views/Point/KeysAndMetadata.js
181 lines 4.4 kB history raw
1import React from 'react'
2import { Row, Col, H2, H4 } from '../../components/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>
12 { '(not set)' }
13 </div>
14 : <div>
15 <div><code>{ addr.slice(0, 14) }</code></div>
16 <div><code>{ addr.slice(14, 28) }</code></div>
17 <div><code>{ addr.slice(28) }</code></div>
18 </div>
20const renderNetworkKey = (hex) => {
21 const sl = i => hex.slice(i, i + 4)
22 const rowFrom = i => `${sl(i)}.${sl(i + 4)}.${sl(i + 8)}.${sl(i + 12)}`
23 return (
24 hex === NULL_KEY
25 ? <div>
26 { '(not set)' }
27 </div>
28 : <div>
29 <div><code>{ hex.slice(0, 2) }</code></div>
30 <div>
31 <code>{ rowFrom(2) }</code>
32 </div>
33 <div>
34 <code>{ rowFrom(18) }</code>
35 </div>
36 <div>
37 <code>{ rowFrom(34) }</code>
38 </div>
39 <div>
40 <code>{ rowFrom(50) }</code>
41 </div>
42 </div>
43 )
46const KeysAndMetadata = (props) => {
47 const { pointDetails } = props
49 return (
50 <Row>
51 <Col>
52 <H2>{ 'Ownership and Proxy Addresses' }</H2>
54 <Row>
55 <Col className={'flex flex-column items-start col-md-3'}>
56 <H4>{ 'Owner' }</H4>
57 {
58 pointDetails.matchWith({
59 Nothing: () => <div />,
60 Just: (deets) => renderAddress(deets.value.owner)
61 })
62 }
63 </Col>
66 <Col className={'flex flex-column items-start col-md-3'}>
67 <H4>{ 'Transfer Proxy' }</H4>
68 {
69 pointDetails.matchWith({
70 Nothing: () => <div />,
71 Just: (deets) => renderAddress(deets.value.transferProxy)
72 })
73 }
74 </Col>
77 <Col className={'flex flex-column items-start col-md-3'}>
78 <H4>{ 'Spawn Proxy' }</H4>
79 {
80 pointDetails.matchWith({
81 Nothing: () => <div />,
82 Just: (deets) => renderAddress(deets.value.spawnProxy)
83 })
84 }
85 </Col>
88 <Col className={'flex flex-column items-start col-md-3'}>
89 <H4>{ 'Mgmt Proxy' }</H4>
90 {
91 pointDetails.matchWith({
92 Nothing: () => <div />,
93 Just: (deets) => renderAddress(deets.value.managementProxy)
94 })
95 }
96 </Col>
97 </Row>
100 <UrbitNetworking pointDetails={ pointDetails } />
103 </Col>
104 </Row>
105 )
108const UrbitNetworking = props => {
109 const { pointDetails } = props
111 const booted = pointDetails.matchWith({
112 Nothing: _ => false,
113 Just: (details) => details.value.keyRevisionNumber > 0
114 })
116 const body =
117 !booted
118 ? <div>
119 { '(not set)' }
120 </div>
121 : <Row>
122 <Col className={'flex flex-column items-start col-md-4'}>
123 <H4>{ 'Authentication' }</H4>
124 {
125 pointDetails.matchWith({
126 Nothing: () => <div />,
127 Just: (deets) =>
128 renderNetworkKey(deets.value.authenticationKey)
129 })
130 }
131 </Col>
133 <Col className={'flex flex-column items-start col-md-4'}>
134 <H4>{ 'Encryption' }</H4>
135 {
136 pointDetails.matchWith({
137 Nothing: () => <div />,
138 Just: (deets) =>
139 renderNetworkKey(deets.value.encryptionKey)
140 })
141 }
142 </Col>
144 <Col className={'flex flex-column items-start col-md-4'}>
145 <H4>{ 'Revision' }</H4>
146 {
147 pointDetails.matchWith({
148 Nothing: () => '-',
149 Just: (deets) => deets.value.keyRevisionNumber
150 })
151 }
154 <H4>{ 'Continuity era' }</H4>
155 {
156 pointDetails.matchWith({
157 Nothing: () => '-',
158 Just: (deets) => deets.value.continuityNumber
159 })
160 }
162 <H4>{ 'Crypto suite version' }</H4>
163 {
164 pointDetails.matchWith({
165 Nothing: () => '-',
166 Just: (deets) => deets.value.cryptoSuiteVersion
167 })
168 }
169 </Col>
170 </Row>
172 return (
173 <div>
174 <H2>{ 'Public Keys' }</H2>
176 { body }
177 </div>
178 )
181export default KeysAndMetadata