1import React, { useCallback } from 'react';
2import { Grid, B } from 'indigo-react';
3import { azimuth } from 'azimuth-js';
4import { Just } from 'folktale/maybe';
6import { ForwardButton } from 'components/Buttons';
7import CopyButton from 'components/CopyButton';
9import { useLocalRouter } from 'lib/LocalRouter';
10import { PROXY_TYPE, proxyTypeToHuman } from 'lib/proxy';
11import * as need from 'lib/need';
12import capitalize from 'lib/capitalize';
13import useCurrentPermissions from 'lib/useCurrentPermissions';
14import convertToInt from 'lib/convertToInt';
16import { usePointCursor } from 'store/pointCursor';
17import { usePointCache } from 'store/pointCache';
18import { useWallet } from 'store/wallet';
20export default function UrbitIDHome() {
21 const { push, names } = useLocalRouter();
22 const { pointCursor } = usePointCursor();
23 const { getDetails } = usePointCache();
24 const { urbitWallet } = useWallet();
26 const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]);
28 const goDownloadKeys = useCallback(() => push(names.DOWNLOAD_KEYS), [
33 const goResetKeys = useCallback(() => push(names.RESET_KEYS), [push, names]);
35 const isMasterTicket = Just.hasInstance(urbitWallet);
36 const point = need.point(pointCursor);
37 const details = need.details(getDetails(point));
38 const { isOwner } = useCurrentPermissions();
39 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
41 const pointSize = azimuth.getPointSize(point);
42 const isParent = pointSize !== azimuth.PointSize.Planet;
43 const isSenate = pointSize === azimuth.PointSize.Galaxy;
45 const goSetProxy = useCallback(
46 proxyType => push(names.SET_PROXY, { proxyType }),
50 const goTransfer = useCallback(() => push(names.TRANSFER), [names, push]);
52 const renderProxyAction = useCallback(
53 (proxyType, address) => {
56 (proxyType === PROXY_TYPE.SPAWN ? networkRevision === 0 : false);
63 onClick={() => goSetProxy(proxyType)}>
64 Edit {capitalize(proxyTypeToHuman(proxyType))} Key
69 [goSetProxy, isOwner, networkRevision]
73 <Grid.Item full className="mb7 f5">
77 <Grid.Item full as={ForwardButton} onClick={goSigil}>
84 onClick={goDownloadKeys}
85 disabled={!isMasterTicket}
87 <B className="wrap ws-normal">
88 · Master Key Authentication required.
100 <B className="wrap ws-normal"> · Ownership key required</B>
104 ? 'Reset Master Key and all other keys'
105 : 'Transfer to Master Ticket, resetting all keys'
107 {isMasterTicket ? 'Reset Keys' : 'Transfer to Master Ticket'}
112 <Grid.Item full className="mv7 f5 gray4">
119 accessory={<CopyButton text={details.owner} />}
120 detail={<div className="mt1 mono black">{details.owner}</div>}
121 disabled={!details.owner}>
126 {renderProxyAction(PROXY_TYPE.MANAGEMENT, details.managementProxy)}
129 {isParent && renderProxyAction(PROXY_TYPE.SPAWN, details.spawnProxy)}
131 {isParent && networkRevision !== 0 && <Grid.Divider />}
133 {isParent && networkRevision === 0 && (
139 accessory={<span className="underline pointer">Set Keys</span>}>
140 Network Keys Required
148 {renderProxyAction(PROXY_TYPE.VOTING, details.votingProxy)}{' '}
158 <B className="wrap ws-normal"> · Ownership key required</B>
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