on master help sign in
keys: address PR feedback

- rename to `useSingleKeyfileGenerator` - remove extraneous log statements

commit225800a15ea252f057e03c6f87f93e27ac264949 authortomholford <tomholford@users.noreply.github.com> dateMon 7 Feb 2022, 14:48 (5 years ago) parent63bd524
5 files changed+17−15
src/lib/useKeyfileGenerator.ts+9−7 src/views/UrbitID/DownloadKeys.js+2−2 src/views/UrbitID/Home.tsx+2−2 src/views/UrbitOS/Home.tsx+2−2 src/views/UrbitOS/NetworkKeys.tsx+2−2
src/lib/useKeyfileGenerator.ts+9−7
@@ -24,7 +24,8 @@ interface useKeyfileGeneratorArgs {
2424
2525/**
2626 * 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`).
2829 *
2930 * @param point Point - (optional) the Point for which to generate keys
3031 * @param seeds string[] - (required) one or more seeds consumed by deriveNetworkKeys
@@ -57,7 +58,6 @@ function useKeyfileGenerator({ point, seeds }: useKeyfileGeneratorArgs) {
5758 const generate = useCallback(async () => {
5859 // Point still loading ...
5960 if (resolvedPoint.value === EMPTY_POINT.value) {
60− console.log('Loading point data ...');
6161 return;
6262 }
6363
@@ -101,7 +101,6 @@ function useKeyfileGenerator({ point, seeds }: useKeyfileGeneratorArgs) {
101101 })
102102 )
103103 );
104− console.log(`keyfile generated for revision ${networkRevision}`);
105104 setGenerating(false);
106105 }, [hasNetworkKeys, seeds, resolvedPoint, networkRevision]);
107106
@@ -208,17 +207,20 @@ export const useActivationKeyfileGenerator = ({
208207 return useKeyfileGenerator({ point, seeds });
209208};
210209
211−interface HomeKeyfileGeneratorArgs {
210+interface SingleKeyfileGeneratorArgs {
212211 seed?: string;
213212}
214213
215214/**
216− * This Home Keyfile Generator is used to derive a multikey in multiple views
217− * in the Bridge dashboard (Set Network Keys, Home > ID, Home > OS views).
215+ * This Single Keyfile Generator is used to derive network keys in multiple
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.
218218 *
219219 * * @param seed string - (optional) default: provided by the logged in wallet
220220 */
221−export const useHomeKeyfileGenerator = ({ seed }: HomeKeyfileGeneratorArgs) => {
221+export const useSingleKeyfileGenerator = ({
222+ seed,
223+}: SingleKeyfileGeneratorArgs) => {
222224 // use provided seed, or fallback to deriving from logged in wallet
223225 const { point } = useRollerStore();
224226 const { authMnemonic, authToken, urbitWallet, wallet }: any = useWallet();
src/views/UrbitID/DownloadKeys.js+2−2
@@ -9,7 +9,7 @@ import { DownloadButton, RestartButton } from 'components/Buttons';
99import PaperBuilder from 'components/PaperBuilder';
1010
1111import { downloadWallet } from 'lib/invite';
12−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
12+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
1313
1414import { useWallet } from 'store/wallet';
1515import { Grid, P } from 'indigo-react';
@@ -26,7 +26,7 @@ export default function AdminRedownload() {
2626 const _urbitWallet = need.wallet(urbitWallet);
2727 const point = need.point(pointCursor);
2828
29− const { keyfile, filename } = useHomeKeyfileGenerator({});
29+ const { keyfile, filename } = useSingleKeyfileGenerator({});
3030
3131 const [paper, setPaper] = useState(Nothing());
3232 const [downloaded, setDownloaded] = useState(false);
src/views/UrbitID/Home.tsx+2−2
@@ -13,7 +13,7 @@ import {
1313} from 'lib/constants';
1414import { abbreviateAddress } from 'lib/utils/address';
1515import { downloadWallet } from 'lib/invite';
16−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
16+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
1717
1818import { useWallet } from 'store/wallet';
1919import { useRollerStore } from 'store/rollerStore';
@@ -43,7 +43,7 @@ export default function UrbitIDHome() {
4343 return null;
4444 }
4545 }, [urbitWallet]);
46− const { keyfile, filename } = useHomeKeyfileGenerator({});
46+ const { keyfile, filename } = useSingleKeyfileGenerator({});
4747 const [paper, setPaper] = useState(Nothing());
4848
4949 const downloadKeys = useCallback(() => {
src/views/UrbitOS/Home.tsx+2−2
@@ -9,7 +9,7 @@ import BodyPane from 'components/L2/Window/BodyPane';
99import { ReactComponent as KeyfileIcon } from 'assets/keyfile.svg';
1010
1111import { useLocalRouter } from 'lib/LocalRouter';
12−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
12+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
1313import { Box, Button, Row } from '@tlon/indigo-react';
1414import CopiableWithTooltip from 'components/copiable/CopiableWithTooltip';
1515
@@ -42,7 +42,7 @@ export default function UrbitOSHome() {
4242 names,
4343 ]);
4444
45− const { code, download } = useHomeKeyfileGenerator({});
45+ const { code, download } = useSingleKeyfileGenerator({});
4646
4747 return (
4848 <Window className="os-home">
src/views/UrbitOS/NetworkKeys.tsx+2−2
@@ -27,7 +27,7 @@ import {
2727import useEthereumTransaction from 'lib/useEthereumTransaction';
2828import { GAS_LIMITS, ONE_SECOND } from 'lib/constants';
2929import { addHexPrefix } from 'lib/utils/address';
30−import { useHomeKeyfileGenerator } from 'lib/useKeyfileGenerator';
30+import { useSingleKeyfileGenerator } from 'lib/useKeyfileGenerator';
3131
3232import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
3333import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
@@ -66,7 +66,7 @@ function useSetKeys(
6666 generating: keyfileGenerating,
6767 filename,
6868 bind: keyfileBind,
69− } = useHomeKeyfileGenerator({ seed: manualNetworkSeed });
69+ } = useSingleKeyfileGenerator({ seed: manualNetworkSeed });
7070
7171 const buildNetworkSeed = useCallback(
7272 async manualSeed => {