import React, { useCallback } from 'react'; import { Grid, B } from 'indigo-react'; import { azimuth } from 'azimuth-js'; import { Just } from 'folktale/maybe'; import { ForwardButton } from 'components/Buttons'; import CopyButton from 'components/CopyButton'; import { useLocalRouter } from 'lib/LocalRouter'; import { PROXY_TYPE, proxyTypeToHuman } from 'lib/proxy'; import * as need from 'lib/need'; import capitalize from 'lib/capitalize'; import useCurrentPermissions from 'lib/useCurrentPermissions'; import convertToInt from 'lib/convertToInt'; import { usePointCursor } from 'store/pointCursor'; import { usePointCache } from 'store/pointCache'; import { useWallet } from 'store/wallet'; export default function UrbitIDHome() { const { push, names } = useLocalRouter(); const { pointCursor } = usePointCursor(); const { getDetails } = usePointCache(); const { urbitWallet } = useWallet(); const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]); const goDownloadKeys = useCallback(() => push(names.DOWNLOAD_KEYS), [ push, names, ]); const goResetKeys = useCallback(() => push(names.RESET_KEYS), [push, names]); const isMasterTicket = Just.hasInstance(urbitWallet); const point = need.point(pointCursor); const details = need.details(getDetails(point)); const { isOwner } = useCurrentPermissions(); const networkRevision = convertToInt(details.keyRevisionNumber, 10); const pointSize = azimuth.getPointSize(point); const isParent = pointSize !== azimuth.PointSize.Planet; const isSenate = pointSize === azimuth.PointSize.Galaxy; const goSetProxy = useCallback( proxyType => push(names.SET_PROXY, { proxyType }), [push, names] ); const goTransfer = useCallback(() => push(names.TRANSFER), [names, push]); const renderProxyAction = useCallback( (proxyType, address) => { const disabled = !isOwner || (proxyType === PROXY_TYPE.SPAWN ? networkRevision === 0 : false); return ( <> goSetProxy(proxyType)}> Edit {capitalize(proxyTypeToHuman(proxyType))} Key ); }, [goSetProxy, isOwner, networkRevision] ); return ( Urbit ID Sigil · Master Key Authentication required. }> Download Keys · Ownership key required } detail={ isMasterTicket ? 'Reset Master Key and all other keys' : 'Transfer to Master Ticket, resetting all keys' }> {isMasterTicket ? 'Reset Keys' : 'Transfer to Master Ticket'} Advanced } detail={
{details.owner}
} disabled={!details.owner}> Ownership Address
{renderProxyAction(PROXY_TYPE.MANAGEMENT, details.managementProxy)} {isParent && renderProxyAction(PROXY_TYPE.SPAWN, details.spawnProxy)} {isParent && networkRevision !== 0 && } {isParent && networkRevision === 0 && ( <> Set Keys}> Network Keys Required )} {isSenate && ( <> {renderProxyAction(PROXY_TYPE.VOTING, details.votingProxy)}{' '} )} · Ownership key required }> Transfer this point
); }