@@ -6,9 +6,10 @@ import React, {
7} from 'react';
7} from 'react';
8import { Just } from 'folktale/maybe';
8import { Just } from 'folktale/maybe';
9−import { Grid, ToggleInput, CheckboxInput, Button } from 'indigo-react';
9+import { 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';
13import { usePointCursor } from 'store/pointCursor';
14import { usePointCursor } from 'store/pointCursor';
14import { usePointCache } from 'store/pointCache';
15import { usePointCache } from 'store/pointCache';
@@ -41,26 +42,29 @@ import {
41 buildHexValidator,
42 buildHexValidator,
42} from 'form/validators';
43} from 'form/validators';
43import BridgeForm from 'form/BridgeForm';
44import BridgeForm from 'form/BridgeForm';
44−import Condition from 'form/Condition';
45import FormError from 'form/FormError';
45import FormError from 'form/FormError';
46import { convertToInt } from 'lib/convertToInt';
46import { convertToInt } from 'lib/convertToInt';
47import Window from 'components/L2/Window/Window';
47import Window from 'components/L2/Window/Window';
48import HeaderPane from 'components/L2/Window/HeaderPane';
48import HeaderPane from 'components/L2/Window/HeaderPane';
49import BodyPane from 'components/L2/Window/BodyPane';
49import BodyPane from 'components/L2/Window/BodyPane';
50−import { Box, Row } from '@tlon/indigo-react';
51+import './NetworkKeys.scss';
52−function useSetKeys(manualNetworkSeed, setManualNetworkSeed) {
53+function useSetKeys(
54+ manualNetworkSeed: string,
55+ setManualNetworkSeed: (seed: string) => void
53− const { urbitWallet, wallet, authMnemonic, authToken } = useWallet();
57+ const { urbitWallet, wallet, authMnemonic, authToken }: any = useWallet();
54− const { pointCursor } = usePointCursor();
58+ const { pointCursor }: any = usePointCursor();
55− const { syncDetails, syncRekeyDate, getDetails } = usePointCache();
59+ const { syncDetails, syncRekeyDate, getDetails }: any = usePointCache();
56− const { contracts } = useNetwork();
60+ const { contracts }: any = useNetwork();
58 const _point = need.point(pointCursor);
62 const _point = need.point(pointCursor);
59 const _contracts = need.contracts(contracts);
63 const _contracts = need.contracts(contracts);
60 const _details = need.details(getDetails(_point));
64 const _details = need.details(getDetails(_point));
62 const networkRevision = convertToInt(_details.keyRevisionNumber, 10);
66 const networkRevision = convertToInt(_details.keyRevisionNumber, 10);
63− const randomSeed = useRef();
67+ const randomSeed = useRef<string | null>();
66 available: keyfileAvailable,
70 available: keyfileAvailable,
@@ -112,7 +116,7 @@ function useSetKeys(manualNetworkSeed, setManualNetworkSeed) {
113 const { completed: _completed, ...rest } = useEthereumTransaction(
117 const { completed: _completed, ...rest } = useEthereumTransaction(
114 useCallback(
118 useCallback(
115− async (manualSeed, isDiscontinuity) => {
119+ async (manualSeed: string, isDiscontinuity: boolean) => {
116 const seed = await buildNetworkSeed(manualSeed);
120 const seed = await buildNetworkSeed(manualSeed);
117 const pair = deriveNetworkKeys(seed);
121 const pair = deriveNetworkKeys(seed);
@@ -148,8 +152,11 @@ function useSetKeys(manualNetworkSeed, setManualNetworkSeed) {
148export default function UrbitOSNetworkKeys({
152export default function UrbitOSNetworkKeys({
149 manualNetworkSeed,
153 manualNetworkSeed,
150 setManualNetworkSeed,
154 setManualNetworkSeed,
156+ manualNetworkSeed: string;
157+ setManualNetworkSeed: (seed: string) => void;
152− const { pop } = useLocalRouter();
159+ const { pop }: any = useLocalRouter();
153 const { point, setLoading } = useRollerStore();
160 const { point, setLoading } = useRollerStore();
155 configureNetworkKeys,
162 configureNetworkKeys,
@@ -157,6 +164,7 @@ export default function UrbitOSNetworkKeys({
157 checkForUpdates,
164 checkForUpdates,
158 } = useRoller();
165 } = useRoller();
159 const [breach, setBreach] = useState(false);
166 const [breach, setBreach] = useState(false);
167+ const [useCustomSeed, setUseCustomSeed] = useState(false);
161 const hasKeys = point.networkKeysSet;
169 const hasKeys = point.networkKeysSet;
@@ -200,12 +208,9 @@ export default function UrbitOSNetworkKeys({
200 const onValues = useCallback(
208 const onValues = useCallback(
201 ({ valid, values, form }) => {
209 ({ valid, values, form }) => {
202 if (valid) {
210 if (valid) {
204− values.useNetworkSeed ? values.networkSeed : undefined,
211+ const networkSeed = useCustomSeed ? values.networkSeed : undefined;
205− values.useDiscontinuity
212+ construct(networkSeed, breach);
207− setBreach(values.useDiscontinuity);
208− setManualNetworkSeed(values.useNetworkSeed);
213+ setManualNetworkSeed(networkSeed);
210 unconstruct();
215 unconstruct();
@@ -216,7 +221,14 @@ export default function UrbitOSNetworkKeys({
216 setManualNetworkSeed('');
221 setManualNetworkSeed('');
219− [construct, unconstruct, setManualNetworkSeed, setBreach]
228+ setManualNetworkSeed,
222 const setNetworkKeys = useCallback(async () => {
234 const setNetworkKeys = useCallback(async () => {
@@ -224,10 +236,10 @@ export default function UrbitOSNetworkKeys({
225 await configureNetworkKeys({
237 await configureNetworkKeys({
227− manualNetworkSeed,
239+ customNetworkSeed: manualNetworkSeed,
229 // TODO: just use the tx hash instead?
241 // TODO: just use the tx hash instead?
230− getPendingTransactions(point);
242+ getPendingTransactions();
231 // TODO: this is just so we get visual feedback that the tx has gone through
243 // TODO: this is just so we get visual feedback that the tx has gone through
232 // but this should be addressed with the new UI flow (-> download keyfile)
244 // but this should be addressed with the new UI flow (-> download keyfile)
@@ -264,26 +276,17 @@ export default function UrbitOSNetworkKeys({
267− const viewTitle = completed
279+ const viewTitle = completed ? 'Network Keys are now set' : 'Set Network Keys';
268− ? 'Network Keys are now set'
269− : 'Set Network Keys';
271 const usageMessage =
281 const usageMessage =
272 'You need this keyfile to authenticate with your OS. Please Download.';
282 'You need this keyfile to authenticate with your OS. Please Download.';
275− <Window>
285+ <Window className="network-keys">
276 <HeaderPane>
286 <HeaderPane>
277− <Row className="header-row">
278− <h5>{viewTitle}</h5>
287+ <h5>{viewTitle}</h5>
280 </HeaderPane>
288 </HeaderPane>
281 <BodyPane>
289 <BodyPane>
283− <Grid.Item className="gray4 f5 mv2 align-self-start" full>
284− Network Keys authenticate Urbit ID with Urbit OS.
287 {completed && (
290 {completed && (
289 <Grid.Item
292 <Grid.Item
@@ -304,43 +307,54 @@ export default function UrbitOSNetworkKeys({
304 onValues={onValues}
307 onValues={onValues}
305 initialValues={initialValues}>
308 initialValues={initialValues}>
307− <Box width="100%">
310+ <Box className="contents">
308 {!completed && (
311 {!completed && (
310− <Grid.Item
313+ <Row className="check-row" onClick={() => setBreach(!breach)}>
312− as={ToggleInput}
315+ className="checkbox"
313− name="useNetworkSeed"
316+ selected={breach}
314− label="Use Custom Network Seed"
315− inverseLabel="Back to Derived Network Seed"
316− disabled={inputsLocked}
318− <Condition when="useNetworkSeed" is={true}>
319− <Grid.Item full as={NoticeBox} className="mb2">
320− When using a custom network seed, you'll need to download
321− your Arvo keyfile immediately after this transaction as
322− Bridge does not store your seed.
328− label="Network Seed (32 bytes)"
329 disabled={inputsLocked}
317 disabled={inputsLocked}
332− </Condition>
319+ Factory Reset
333− <Grid.Item
320+ </Row>
321+ <Box className="info-text">
322+ Use if your ship is corrupted, you lost your files, or
324+ you want to erase your data
327+ className="check-row"
328+ onClick={() => setUseCustomSeed(!useCustomSeed)}>
330+ className="checkbox"
331+ selected={useCustomSeed}
332+ disabled={inputsLocked}
336+ <Box className="info-text">
337+ Enter your own custom network seed to derive from
341+ <Grid.Item full as={NoticeBox} className="mb2">
342+ When using a custom network seed, you'll need to
343+ download your Arvo keyfile immediately after this
344+ transaction as Bridge does not store your seed.
335− as={CheckboxInput}
348+ as={HexInput}
336− name="useDiscontinuity"
349+ name="networkSeed"
337− label="Breach Continuity"
350+ label="Network Seed (32 bytes)"
338− disabled={inputsLocked}
351+ disabled={inputsLocked}
339− className="mb6"
352+ className="mb5"
342 <Grid.Item full as={FormError} />
356 <Grid.Item full as={FormError} />
346 {point.isL2 ? (
360 {point.isL2 ? (