@@ -9,9 +9,8 @@ import { Just } from 'folktale/maybe';
9import { Grid, Button } from 'indigo-react';
9import { Grid, Button } from 'indigo-react';
10import * as azimuth from 'azimuth-js';
10import * as azimuth from 'azimuth-js';
11import { randomHex } from 'web3-utils';
11import { randomHex } from 'web3-utils';
12−import { Box, Checkbox, Row } from '@tlon/indigo-react';
12+import { Box, Checkbox, Icon, Row } from '@tlon/indigo-react';
14−import { usePointCursor } from 'store/pointCursor';
15import { usePointCache } from 'store/pointCache';
14import { usePointCache } from 'store/pointCache';
16import { useNetwork } from 'store/network';
15import { useNetwork } from 'store/network';
17import { useWallet } from 'store/wallet';
16import { useWallet } from 'store/wallet';
@@ -26,14 +25,13 @@ import {
26 CRYPTO_SUITE_VERSION,
25 CRYPTO_SUITE_VERSION,
27} from 'lib/keys';
26} from 'lib/keys';
28import useEthereumTransaction from 'lib/useEthereumTransaction';
27import useEthereumTransaction from 'lib/useEthereumTransaction';
29−import { GAS_LIMITS } from 'lib/constants';
28+import { GAS_LIMITS, ONE_SECOND } from 'lib/constants';
30import { addHexPrefix } from 'lib/utils/address';
29import { addHexPrefix } from 'lib/utils/address';
31import useMultikeyFileGenerator from 'lib/useMultikeyFileGenerator';
30import useMultikeyFileGenerator from 'lib/useMultikeyFileGenerator';
33import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
32import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
34import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
33import InlineEthereumTransaction from 'components/InlineEthereumTransaction';
35import NoticeBox from 'components/NoticeBox';
34import NoticeBox from 'components/NoticeBox';
36−import AlertBox from 'components/AlertBox';
38import { HexInput } from 'form/Inputs';
36import { HexInput } from 'form/Inputs';
@@ -43,7 +41,6 @@ import {
43} from 'form/validators';
41} from 'form/validators';
44import BridgeForm from 'form/BridgeForm';
42import BridgeForm from 'form/BridgeForm';
45import FormError from 'form/FormError';
43import FormError from 'form/FormError';
46−import { convertToInt } from 'lib/convertToInt';
47import Window from 'components/L2/Window/Window';
44import Window from 'components/L2/Window/Window';
48import HeaderPane from 'components/L2/Window/HeaderPane';
45import HeaderPane from 'components/L2/Window/HeaderPane';
49import BodyPane from 'components/L2/Window/BodyPane';
46import BodyPane from 'components/L2/Window/BodyPane';
@@ -56,19 +53,16 @@ function useSetKeys(
56 setManualNetworkSeed: (seed: string) => void
53 setManualNetworkSeed: (seed: string) => void
58 const { urbitWallet, wallet, authMnemonic, authToken }: any = useWallet();
55 const { urbitWallet, wallet, authMnemonic, authToken }: any = useWallet();
59− const { pointCursor }: any = usePointCursor();
56+ const { point } = useRollerStore();
60− const { syncDetails, syncRekeyDate, getDetails }: any = usePointCache();
57+ const { syncDetails, syncRekeyDate }: any = usePointCache();
61 const { contracts }: any = useNetwork();
58 const { contracts }: any = useNetwork();
63− const _point = need.point(pointCursor);
64 const _contracts = need.contracts(contracts);
60 const _contracts = need.contracts(contracts);
65− const _details = need.details(getDetails(_point));
67− const networkRevision = convertToInt(_details.keyRevisionNumber, 10);
62+ const networkRevision = Number(point.keyRevisionNumber);
68 const randomSeed = useRef<string | null>();
63 const randomSeed = useRef<string | null>();
71− available: keyfileAvailable,
72 generating: keyfileGenerating,
66 generating: keyfileGenerating,
74 bind: keyfileBind,
68 bind: keyfileBind,
@@ -87,8 +81,8 @@ function useSetKeys(
87 urbitWallet,
81 urbitWallet,
89 authMnemonic,
83 authMnemonic,
90− details: _details,
84+ details: point,
91− point: _point,
85+ point: point.value,
92 authToken,
86 authToken,
93 revision: newNetworkRevision,
87 revision: newNetworkRevision,
@@ -104,13 +98,12 @@ function useSetKeys(
108 authMnemonic,
101 authMnemonic,
109 setManualNetworkSeed,
102 setManualNetworkSeed,
110 networkRevision,
103 networkRevision,
111 urbitWallet,
104 urbitWallet,
114 authToken,
107 authToken,
@@ -123,24 +116,24 @@ function useSetKeys(
124 return azimuth.ecliptic.configureKeys(
117 return azimuth.ecliptic.configureKeys(
125 _contracts,
118 _contracts,
126− _point,
119+ point.value,
127 addHexPrefix(pair.crypt.public),
120 addHexPrefix(pair.crypt.public),
128 addHexPrefix(pair.auth.public),
121 addHexPrefix(pair.auth.public),
129 CRYPTO_SUITE_VERSION,
122 CRYPTO_SUITE_VERSION,
130 isDiscontinuity
123 isDiscontinuity
133− [_contracts, _point, buildNetworkSeed]
126+ [_contracts, point, buildNetworkSeed]
135 useCallback(
128 useCallback(
136− () => Promise.all([syncDetails(_point), syncRekeyDate(_point)]),
129+ () => Promise.all([syncDetails(point.value), syncRekeyDate(point.value)]),
137− [_point, syncDetails, syncRekeyDate]
130+ [point, syncDetails, syncRekeyDate]
139 GAS_LIMITS.CONFIGURE_KEYS
132 GAS_LIMITS.CONFIGURE_KEYS
142 // only treat the transaction as completed once we also have keys to download
135 // only treat the transaction as completed once we also have keys to download
143− const completed = _completed && keyfileAvailable && !keyfileGenerating;
136+ const completed = _completed && !keyfileGenerating;
146 completed,
139 completed,
@@ -166,6 +159,7 @@ export default function UrbitOSNetworkKeys({
166 } = useRoller();
159 } = useRoller();
167 const [breach, setBreach] = useState(false);
160 const [breach, setBreach] = useState(false);
168 const [useCustomSeed, setUseCustomSeed] = useState(false);
161 const [useCustomSeed, setUseCustomSeed] = useState(false);
162+ const [l2Completed, setL2Completed] = useState(false);
170 const hasKeys = point.networkKeysSet;
164 const hasKeys = point.networkKeysSet;
@@ -191,6 +185,7 @@ export default function UrbitOSNetworkKeys({
191 hash: txHashes[0],
185 hash: txHashes[0],
192 time: new Date().getTime(),
186 time: new Date().getTime(),
188+ intervalTime: ONE_SECOND,
196 }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
191 }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
@@ -259,8 +254,9 @@ export default function UrbitOSNetworkKeys({
259 checkForUpdates({
254 checkForUpdates({
260 point: point.value,
255 point: point.value,
261 message: `${point.patp}'s Network Keys have been set!`,
256 message: `${point.patp}'s Network Keys have been set!`,
257+ intervalTime: ONE_SECOND,
263− pop();
259+ setTimeout(() => setL2Completed(true), ONE_SECOND);
264 } catch (error) {
260 } catch (error) {
265 // setError(error);
261 // setError(error);
266 } finally {
262 } finally {
@@ -271,7 +267,6 @@ export default function UrbitOSNetworkKeys({
271 manualNetworkSeed,
267 manualNetworkSeed,
272 getPendingTransactions,
268 getPendingTransactions,
275 configureNetworkKeys,
270 configureNetworkKeys,
276 setLoading,
271 setLoading,
277 checkForUpdates,
272 checkForUpdates,
@@ -279,10 +274,18 @@ export default function UrbitOSNetworkKeys({
280 const initialValues = useMemo(() => ({}), []);
275 const initialValues = useMemo(() => ({}), []);
282− const viewTitle = completed ? 'Network Keys are now set' : 'Set Network Keys';
277+ const viewTitle = completed
278+ ? 'Network Keys have been set'
280+ ? 'Set Network Keys'
281+ : 'Initiate Network Keys';
284 const usageMessage =
283 const usageMessage =
285− 'You need this keyfile to authenticate with your OS. Please Download.';
284+ 'With your new network keys, you also have a new keyfile. Download your new keyfile to boot your OS.';
286+ const buttonText = `${hasKeys ? 'Reset' : 'Set'} Network Keys`;
288+ const isComplete = completed || l2Completed;
288 <Window className="network-keys">
291 <Window className="network-keys">
@@ -290,98 +293,114 @@ export default function UrbitOSNetworkKeys({
290 <h5>{viewTitle}</h5>
293 <h5>{viewTitle}</h5>
291 </HeaderPane>
294 </HeaderPane>
292 <BodyPane>
295 <BodyPane>
293− {completed && (
296+ {isComplete && (
294− <>
297+ <Box className="flex-col col justify-between h-full">
298+ <Box className="flex-col download-message">
299+ <Icon icon="Download" className="download" />
300+ <Box>{usageMessage}</Box>
295− <Grid.Item
303+ <Grid.Item
297− className="mb3"
305+ as={Button}
308+ onClick={keyfileBind.download}>
298− as={DownloadKeyfileButton}
314+ as={DownloadKeyfileButton}
301− {...keyfileBind}
317+ {...keyfileBind}
303− <Grid.Item full as={AlertBox} className="mb8">
319+ )}
304− {usageMessage}
320+ </Box>
308− <BridgeForm
324+ <BridgeForm
309− validate={validate}
325+ validate={validate}
310− onValues={onValues}
326+ onValues={onValues}
311− initialValues={initialValues}>
327+ initialValues={initialValues}>
312− {() => (
328+ {() => (
313− <Box className="contents">
329+ <Box className="contents">
314− {!completed && (
330+ {!isComplete && (
333+ className="check-row"
316− <Row className="check-row" onClick={() => setBreach(!breach)}>
334+ onClick={() => setBreach(!breach)}>
318− className="checkbox"
320− disabled={inputsLocked}
324− <Box className="info-text">
325− Use if your ship is corrupted, you lost your files, or
327− you want to erase your data
330− className="check-row"
331− onClick={() => setUseCustomSeed(!useCustomSeed)}>
332− <Checkbox
335+ <Checkbox
333− className="checkbox"
336+ className="checkbox"
334− selected={useCustomSeed}
337+ selected={breach}
335− disabled={inputsLocked}
339− <Box className="info-text">
340− Enter your own custom network seed to derive from
344− <Grid.Item full as={NoticeBox} className="mb2">
345− When using a custom network seed, you'll need to
346− download your Arvo keyfile immediately after this
347− transaction as Bridge does not store your seed.
353− label="Network Seed (32 bytes)"
354 disabled={inputsLocked}
338 disabled={inputsLocked}
342+ <Box className="info-text">
343+ Use if your ship is corrupted, you lost your files, or
345+ you want to erase your data
348+ className="check-row"
349+ onClick={() => setUseCustomSeed(!useCustomSeed)}>
351+ className="checkbox"
352+ selected={useCustomSeed}
353+ disabled={inputsLocked}
357+ <Box className="info-text">
358+ Enter your own custom network seed to derive from
362+ <Grid.Item full as={NoticeBox} className="mb2">
363+ When using a custom network seed, you'll need to
364+ download your Arvo keyfile immediately after this
365+ transaction as Bridge does not store your seed.
371+ label="Network Seed (32 bytes)"
372+ disabled={inputsLocked}
359− <Grid.Item full as={FormError} />
377+ <Grid.Item full as={FormError} />
363− {point.isL2 ? (
381+ {point.isL2 ? (
364− <Grid.Item
382+ <Grid.Item
365− as={Button}
383+ as={Button}
367− className=""
385+ className=""
370− onClick={setNetworkKeys}>
388+ onClick={setNetworkKeys}>
371− {'Reset Network Keys'}
389+ {buttonText}
372− </Grid.Item>
390+ </Grid.Item>
374− <Grid.Item
392+ <Grid.Item
376− as={InlineEthereumTransaction}
394+ as={InlineEthereumTransaction}
377− {...bind}
395+ {...bind}
378− label={`${hasKeys ? 'Reset' : 'Set'} Network Keys`}
396+ label={buttonText}
379− onReturn={() => pop()}
397+ onReturn={() => pop()}
384− </BridgeForm>
402+ </BridgeForm>
385 </BodyPane>
404 </BodyPane>
386 </Window>
405 </Window>