on master help sign in
fix: clean up keyfile button notice
6ecd461Matt Condon (shrugs)
src/components/DownloadKeyfileButton.js+2−8
@@ -9,25 +9,19 @@ export default function DownloadKeyfileButton({
9 available,
9 available,
10 downloaded,
10 downloaded,
11 download,
11 download,
12+ notice,
12
13
13 // from caller
14 // from caller
14 className,
15 className,
15 ...rest
16 ...rest
16}) {
17}) {
17− const showHelp = !generating && !available;
18−
19 return (
18 return (
20 <DownloadButton
19 <DownloadButton
21 as="span"
20 as="span"
22 className={className}
21 className={className}
23 disabled={downloaded || !available}
22 disabled={downloaded || !available}
24 disabledDetail={
23 disabledDetail={
25− showHelp && (
26− <B className="wrap ws-normal">
24+ !available && <B className="wrap ws-normal">· {notice}</B>
27− · Custom or nondeterministic networking keys cannot be
28− re-downloaded.
29− </B>
30− )
31 }
25 }
32 loading={generating}
26 loading={generating}
33 onClick={download}
27 onClick={download}
src/lib/useKeyfileGenerator.js+15−8
@@ -18,10 +18,11 @@ import {
18import useCurrentPermissions from './useCurrentPermissions';
18import useCurrentPermissions from './useCurrentPermissions';
19
19
20export default function useKeyfileGenerator(manualNetworkSeed) {
20export default function useKeyfileGenerator(manualNetworkSeed) {
21− const { getDetails } = usePointCache();
22 const { urbitWallet, wallet, authMnemonic } = useWallet();
21 const { urbitWallet, wallet, authMnemonic } = useWallet();
23 const { pointCursor } = usePointCursor();
22 const { pointCursor } = usePointCursor();
23+ const { getDetails } = usePointCache();
24
24
25+ const [notice, setNotice] = useState('Deriving networking keys...');
25 const [downloaded, setDownloaded] = useState(false);
26 const [downloaded, setDownloaded] = useState(false);
26 const [generating, setGenerating] = useState(true);
27 const [generating, setGenerating] = useState(true);
27 const [keyfile, setKeyfile] = useState(false);
28 const [keyfile, setKeyfile] = useState(false);
@@ -36,12 +37,13 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
36 const available =
37 const available =
37 (isOwner || isManagementProxy) && hasNetworkingKeys && !!keyfile;
38 (isOwner || isManagementProxy) && hasNetworkingKeys && !!keyfile;
38
39
39− console.log(
40− `keyfile available (${available}) for revision ${networkRevision}`
41− );
42−
43 const generate = useCallback(async () => {
40 const generate = useCallback(async () => {
44− console.log('generating for network revision', networkRevision);
41+ console.log('attempting generation for network revision', networkRevision);
42+ if (!hasNetworkingKeys) {
43+ setGenerating(false);
44+ setNotice('Networking keys not yet set.');
45+ return;
46+ }
45
47
46 const networkSeed = manualNetworkSeed
48 const networkSeed = manualNetworkSeed
47 ? Just(manualNetworkSeed)
49 ? Just(manualNetworkSeed)
@@ -55,7 +57,9 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
55
57
56 if (Nothing.hasInstance(networkSeed)) {
58 if (Nothing.hasInstance(networkSeed)) {
57 setGenerating(false);
59 setGenerating(false);
58− console.log('manual network seed not provided and key not derivable');
60+ setNotice(
61+ 'Custom or nondeterministic networking keys cannot be re-downloaded.'
62+ );
59 return;
63 return;
60 }
64 }
61
65
@@ -65,14 +69,16 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
65
69
66 if (!keysMatchChain(pair, _details)) {
70 if (!keysMatchChain(pair, _details)) {
67 setGenerating(false);
71 setGenerating(false);
68− console.log('derived network keys do not match on-chain details');
72+ setNotice('Derived networking keys do not match on-chain details.');
69 return;
73 return;
70 }
74 }
71
75
76+ setNotice();
72 setKeyfile(compileNetworkingKey(pair, _point, networkRevision));
77 setKeyfile(compileNetworkingKey(pair, _point, networkRevision));
73 setGenerating(false);
78 setGenerating(false);
74 }, [
79 }, [
75 networkRevision,
80 networkRevision,
81+ hasNetworkingKeys,
76 manualNetworkSeed,
82 manualNetworkSeed,
77 urbitWallet,
83 urbitWallet,
78 wallet,
84 wallet,
@@ -101,6 +107,7 @@ export default function useKeyfileGenerator(manualNetworkSeed) {
101 available,
107 available,
102 downloaded,
108 downloaded,
103 download,
109 download,
110+ notice,
104 };
111 };
105
112
106 return { ...values, bind: values };
113 return { ...values, bind: values };