@@ -0,0 +1,113 @@
1+import React from 'react';
2+import { Grid, Flex, H5, Text } from 'indigo-react';
3+import { Just, Nothing } from 'folktale/maybe';
5+import { formatDotsWithTime } from 'lib/dateFormat';
6+import { segmentNetworkKey, CURVE_ZERO_ADDR } from 'lib/keys';
8+import { usePointCache } from 'store/pointCache';
10+const chainKeyProp = name => d =>
11+ d[name] === CURVE_ZERO_ADDR ? Nothing() : Just(d[name]);
13+const renderNetworkKey = key => {
14+ const segments = segmentNetworkKey(key);
20+ return segments.join('\n');
23+export default function NetworkingKeys({ point }) {
24+ const { getDetails, getRekeyDate } = usePointCache();
26+ const details = getDetails(point);
28+ const hasKeys = details.matchWith({
29+ Nothing: () => false,
30+ Just: ({ value: details }) => parseInt(details.keyRevisionNumber, 10) > 0,
31+ // we actually don't mind the default NaN behavior of parseInt here,
32+ // since NaN > 0 === false and that's a reasonable result
35+ const renderTitle = () => {
39+ const renderNetworkKeySection = (title, key) => (
41+ <Grid.Item full as={H5} className="mt3 gray4">
46+ <Grid.Item full as="code" className="f5 mono gray4">
50+ Just: ({ value: key }) => (
52+ <Grid.Item full as="code" className="f5 mono wrap">
55+ <Grid.Item full as="code" className="f5 mono wrap">
56+ {renderNetworkKey(key)}
64+ const renderDetail = (title, value) => (
65+ <Flex.Item as={Flex} col>
66+ <Flex.Item as={H5} className="gray4">
71+ <Flex.Item as={Text} className="f5 gray4">
75+ Just: ({ value }) => <Flex.Item as={Text}>{value}</Flex.Item>,
82+ {renderNetworkKeySection(
84+ details.chain(chainKeyProp('authenticationKey'))
86+ {renderNetworkKeySection(
88+ details.chain(chainKeyProp('encryptionKey'))
90+ <Grid.Item full as={Flex} row justify="between" className="mt3">
91+ {renderDetail('Revision', details.map(d => d.keyRevisionNumber))}
92+ {renderDetail('Continuity Era', details.map(d => d.continuityNumber))}
95+ details.map(d => d.cryptoSuiteVersion)
99+ <Grid.Item full as={Flex} row justify="between" className="mt3">
102+ getRekeyDate(point).map(date =>
104+ Ok: r => formatDotsWithTime(r.value),
105+ Error: () => Nothing(),