1import React from 'react';
2import { Grid, Flex, H5, Text } from 'indigo-react';
3import { Just, Nothing } from 'folktale/maybe';
5import { formatDotsWithTime } from 'lib/dateFormat';
6import { segmentNetworkKey, CURVE_ZERO_ADDR } from 'lib/keys';
8import { usePointCache } from 'store/pointCache';
10const chainKeyProp = name => d =>
11 d[name] === CURVE_ZERO_ADDR ? Nothing() : Just(d[name]);
13const renderNetworkKey = key => {
14 const segments = segmentNetworkKey(key);
20 return segments.join('\n');
23export default function NetworkingKeys({ point }) {
24 const { getDetails, getRekeyDate } = usePointCache();
26 const details = getDetails(point);
28 const hasKeys = details.matchWith({
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 renderNetworkKeySection = (title, key) => (
37 <Grid.Item full as={H5} className="mt3 gray4">
42 <Grid.Item full as="code" className="f5 mono gray4">
46 Just: ({ value: key }) => (
48 <Grid.Item full as="code" className="f5 mono wrap">
51 <Grid.Item full as="code" className="f5 mono wrap">
52 {renderNetworkKey(key)}
60 const renderDetail = (title, value) => (
61 <Flex.Item as={Flex} col>
62 <Flex.Item as={H5} className="gray4">
67 <Flex.Item as={Text} className="f5 gray4">
71 Just: ({ value }) => <Flex.Item as={Text}>{value}</Flex.Item>,
78 {renderNetworkKeySection(
80 details.chain(chainKeyProp('authenticationKey'))
82 {renderNetworkKeySection(
84 details.chain(chainKeyProp('encryptionKey'))
86 <Grid.Item full as={Flex} row justify="between" className="mt3">
89 details.map(d => d.keyRevisionNumber)
93 details.map(d => d.continuityNumber)
97 details.map(d => d.cryptoSuiteVersion)
100 {/* TODO: retrieve last rekeydate, if possible? */}
102 <Grid.Item full as={Flex} row justify="between" className="mt3">
105 getRekeyDate(point).map(date =>
107 Ok: r => formatDotsWithTime(r.value),
108 Error: () => 'No date available',
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list