on master help sign in
keys: address PR feedback
225800atomholford
src/lib/useKeyfileGenerator.ts+9−7
@@ -24,7 +24,8 @@ interface useKeyfileGeneratorArgs {
24
24
25/**
25/**
26 * The default Keyfile Generator. Can be used by itself, or composed with
26 * The default Keyfile Generator. Can be used by itself, or composed with
27− * other hooks (see `useActivationKeyfileGenerator` and `useHomeKeyfileGenerator`).
27+ * other hooks (see `useActivationKeyfileGenerator` and
28+ * `useSingleKeyfileGenerator`).
28 *
29 *
29 * @param point Point - (optional) the Point for which to generate keys
30 * @param point Point - (optional) the Point for which to generate keys
30 * @param seeds string[] - (required) one or more seeds consumed by deriveNetworkKeys
31 * @param seeds string[] - (required) one or more seeds consumed by deriveNetworkKeys
@@ -57,7 +58,6 @@ function useKeyfileGenerator({ point, seeds }: useKeyfileGeneratorArgs) {
57 const generate = useCallback(async () => {
58 const generate = useCallback(async () => {
58 // Point still loading ...
59 // Point still loading ...
59 if (resolvedPoint.value === EMPTY_POINT.value) {
60 if (resolvedPoint.value === EMPTY_POINT.value) {
60− console.log('Loading point data ...');
61 return;
61 return;
62 }
62 }
63
63
@@ -101,7 +101,6 @@ function useKeyfileGenerator({ point, seeds }: useKeyfileGeneratorArgs) {
101 })
101 })
102 )
102 )
103 );
103 );
104− console.log(`keyfile generated for revision ${networkRevision}`);
105 setGenerating(false);
104 setGenerating(false);
106 }, [hasNetworkKeys, seeds, resolvedPoint, networkRevision]);
105 }, [hasNetworkKeys, seeds, resolvedPoint, networkRevision]);
107
106
@@ -208,17 +207,20 @@ export const useActivationKeyfileGenerator = ({
208 return useKeyfileGenerator({ point, seeds });
207 return useKeyfileGenerator({ point, seeds });
209};
208};
210
209
211−interface HomeKeyfileGeneratorArgs {
210+interface SingleKeyfileGeneratorArgs {
212 seed?: string;
211 seed?: string;
213}
212}
214
213
215/**
214/**
216− * This Home Keyfile Generator is used to derive a multikey in multiple views
215+ * This Single Keyfile Generator is used to derive network keys in multiple
217− * in the Bridge dashboard (Set Network Keys, Home > ID, Home > OS views).
216+ * views in the Bridge dashboard (Set Network Keys, Home > ID, Home > OS).
217+ * By default, it uses the logged in wallet's seed phrase.
218 *
218 *
219 * * @param seed string - (optional) default: provided by the logged in wallet
219 * * @param seed string - (optional) default: provided by the logged in wallet
220 */
220 */
221−export const useHomeKeyfileGenerator = ({ seed }: HomeKeyfileGeneratorArgs) => {
221+export const useSingleKeyfileGenerator = ({
222+ seed,
223+}: SingleKeyfileGeneratorArgs) => {
222 // use provided seed, or fallback to deriving from logged in wallet
224 // use provided seed, or fallback to deriving from logged in wallet
223 const { point } = useRollerStore();
225 const { point } = useRollerStore();
224 const { authMnemonic, authToken, urbitWallet, wallet }: any = useWallet();
226 const { authMnemonic, authToken, urbitWallet, wallet }: any = useWallet();
src/views/UrbitID/DownloadKeys.js+2−2
@@ -9,7 +9,7 @@ import { DownloadButton, RestartButton } from 'components/Buttons';
9import PaperBuilder from 'components/PaperBuilder';
9import PaperBuilder from 'components/PaperBuilder';
10
10
11import { downloadWallet } from 'lib/invite';
11import { downloadWallet } from 'lib/invite';
12−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
12+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
13
13
14import { useWallet } from 'store/wallet';
14import { useWallet } from 'store/wallet';
15import { Grid, P } from 'indigo-react';
15import { Grid, P } from 'indigo-react';
@@ -26,7 +26,7 @@ export default function AdminRedownload() {
26 const _urbitWallet = need.wallet(urbitWallet);
26 const _urbitWallet = need.wallet(urbitWallet);
27 const point = need.point(pointCursor);
27 const point = need.point(pointCursor);
28
28
29− const { keyfile, filename } = useHomeKeyfileGenerator({});
29+ const { keyfile, filename } = useSingleKeyfileGenerator({});
30
30
31 const [paper, setPaper] = useState(Nothing());
31 const [paper, setPaper] = useState(Nothing());
32 const [downloaded, setDownloaded] = useState(false);
32 const [downloaded, setDownloaded] = useState(false);
src/views/UrbitID/Home.tsx+2−2
@@ -13,7 +13,7 @@ import {
13} from 'lib/constants';
13} from 'lib/constants';
14import { abbreviateAddress } from 'lib/utils/address';
14import { abbreviateAddress } from 'lib/utils/address';
15import { downloadWallet } from 'lib/invite';
15import { downloadWallet } from 'lib/invite';
16−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
16+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
17
17
18import { useWallet } from 'store/wallet';
18import { useWallet } from 'store/wallet';
19import { useRollerStore } from 'store/rollerStore';
19import { useRollerStore } from 'store/rollerStore';
@@ -43,7 +43,7 @@ export default function UrbitIDHome() {
43 return null;
43 return null;
44 }
44 }
45 }, [urbitWallet]);
45 }, [urbitWallet]);
46− const { keyfile, filename } = useHomeKeyfileGenerator({});
46+ const { keyfile, filename } = useSingleKeyfileGenerator({});
47 const [paper, setPaper] = useState(Nothing());
47 const [paper, setPaper] = useState(Nothing());
48
48
49 const downloadKeys = useCallback(() => {
49 const downloadKeys = useCallback(() => {
src/views/UrbitOS/Home.tsx+2−2
@@ -9,7 +9,7 @@ import BodyPane from 'components/L2/Window/BodyPane';
9import { ReactComponent as KeyfileIcon } from 'assets/keyfile.svg';
9import { ReactComponent as KeyfileIcon } from 'assets/keyfile.svg';
10
10
11import { useLocalRouter } from 'lib/LocalRouter';
11import { useLocalRouter } from 'lib/LocalRouter';
12−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
12+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
13import { Box, Button, Row } from '@tlon/indigo-react';
13import { Box, Button, Row } from '@tlon/indigo-react';
14import CopiableWithTooltip from 'components/copiable/CopiableWithTooltip';
14import CopiableWithTooltip from 'components/copiable/CopiableWithTooltip';
15
15
@@ -42,7 +42,7 @@ export default function UrbitOSHome() {
42 names,
42 names,
43 ]);
43 ]);
44
44
45− const { code, download } = useHomeKeyfileGenerator({});
45+ const { code, download } = useSingleKeyfileGenerator({});
46
46
47 return (
47 return (
48 <Window className="os-home">
48 <Window className="os-home">
src/views/UrbitOS/NetworkKeys.tsx+2−2
@@ -27,7 +27,7 @@ import {
27import useEthereumTransaction from 'lib/useEthereumTransaction';
27import useEthereumTransaction from 'lib/useEthereumTransaction';
28import { GAS_LIMITS, ONE_SECOND } from 'lib/constants';
28import { GAS_LIMITS, ONE_SECOND } from 'lib/constants';
29import { addHexPrefix } from 'lib/utils/address';
29import { addHexPrefix } from 'lib/utils/address';
30−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
30+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
31
31
32import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
32import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
33import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
33import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
@@ -66,7 +66,7 @@ function useSetKeys(
66 generating: keyfileGenerating,
66 generating: keyfileGenerating,
67 filename,
67 filename,
68 bind: keyfileBind,
68 bind: keyfileBind,
69− } = useHomeKeyfileGenerator({ seed: manualNetworkSeed });
69+ } = useSingleKeyfileGenerator({ seed: manualNetworkSeed });
70
70
71 const buildNetworkSeed = useCallback(
71 const buildNetworkSeed = useCallback(
72 async manualSeed => {
72 async manualSeed => {