on master help sign in
Updated network seed page
commita388dea560b781c49d6573701d30899fe63c4ef5 authorWill Galebach <willbach@gmail.com> dateMon 6 Dec 2021, 16:31 (5 years ago) parente5348f2
9 files changed+133−81
src/components/Buttons.js+4−6 src/components/InlineEthereumTransaction.js+5 src/views/Party/PartySetPoolSize.js+2−2 src/views/Point/MigrateL2.scss+2−2 src/views/Point/Point.scss+2−2 src/views/Point/UrbitOS.js+1−1 src/views/UrbitOS/Home.tsx+1−3 src/views/UrbitOS/NetworkKeys.scss+37 src/views/UrbitOS/NetworkKeys.js → src/views/UrbitOS/NetworkKeys.tsx+79−65
src/components/Buttons.js+4−6
@@ -6,19 +6,17 @@ import { blinkIf } from './Blinky';
66
77// NOTE: the -> is correct because inter recognizes the pair
88export const ForwardButton = ({ loading, ...props }) => (
9− <Button accessory={blinkIf(loading, '->')} {...props} center />
9+ <Button accessory={blinkIf(loading, '->')} {...props} />
1010);
1111export const DownloadButton = ({ loading, ...props }) => (
12− <Button accessory={blinkIf(loading, '↓')} {...props} center />
13−);
14−export const RestartButton = props => (
15− <Button accessory="↺" {...props} center />
12+ <Button accessory={blinkIf(loading, '↓')} {...props} />
1613);
14+export const RestartButton = props => <Button accessory="↺" {...props} />;
1715export const GenerateButton = ({ loading, ...props }) => (
1816 <Button accessory={blinkIf(loading, '○')} solid {...props} />
1917);
2018export const OutButton = props => (
21− <Button as="a" target="_blank" accessory="↗" {...props} center />
19+ <Button as="a" target="_blank" accessory="↗" {...props} />
2220);
2321
2422export const OfflineButton = props => (
src/components/InlineEthereumTransaction.js+5
@@ -99,6 +99,7 @@ export default function InlineEthereumTransaction({
9999 full
100100 as={RestartButton}
101101 solid
102+ center
102103 onClick={() => reset()}>
103104 Reset Transaction
104105 </Grid.Item>
@@ -111,6 +112,7 @@ export default function InlineEthereumTransaction({
111112 className="eth-tx-button"
112113 full
113114 as={RestartButton}
115+ center
114116 onClick={onReturn}>
115117 Return
116118 </Grid.Item>
@@ -141,6 +143,7 @@ export default function InlineEthereumTransaction({
141143 as={ForwardButton}
142144 solid
143145 success
146+ center
144147 disabled={!canBroadcast}
145148 onClick={() => broadcast()}>
146149 Send Transaction
@@ -152,6 +155,7 @@ export default function InlineEthereumTransaction({
152155 className="ph4 eth-tx-button"
153156 full
154157 as={ProgressButton}
158+ center
155159 success
156160 disabled
157161 progress={confirmationProgress}>
@@ -164,6 +168,7 @@ export default function InlineEthereumTransaction({
164168 className="ph4 eth-tx-button"
165169 full
166170 as={GenerateButton}
171+ center
167172 onClick={generateAndSign}
168173 disabled={!canSign}
169174 loading={!canSign && initializing}>
src/views/Party/PartySetPoolSize.js+2−2
@@ -120,8 +120,8 @@ export default function PartySetPoolSize() {
120120
121121 {!hasKeysSet && (
122122 <Grid.Item full as={WarningBox} className="mb4 f6">
123− Network keys must be configured for invitations to be available
124− for use.
123+ Network keys must be configured for invitations to be available for
124+ use.
125125 </Grid.Item>
126126 )}
127127
src/views/Point/MigrateL2.scss+2−2
@@ -65,8 +65,8 @@
6565 width: 16px;
6666
6767 svg {
68− width: 16px;
69− height: 16px;
68+ width: 18px;
69+ height: 18px;
7070 color: white;
7171 }
7272 }
src/views/Point/Point.scss+2−2
@@ -77,8 +77,8 @@
7777 width: 16px;
7878
7979 svg {
80− width: 16px;
81− height: 16px;
80+ width: 18px;
81+ height: 18px;
8282 color: white;
8383 }
8484 }
src/views/Point/UrbitOS.js+1−1
@@ -9,7 +9,7 @@ import View from 'components/View';
99import L2BackHeader from 'components/L2/Headers/L2BackHeader';
1010
1111import UrbitOSHome from '../UrbitOS/Home';
12−import UrbitOSNetworkKeys from '../UrbitOS/NetworkKeys';
12+import UrbitOSNetworkKeys from '../UrbitOS/NetworkKeys.tsx';
1313import UrbitOSChangeSponsor from '../UrbitOS/ChangeSponsor';
1414
1515const NAMES = {
src/views/UrbitOS/Home.tsx+1−3
@@ -83,9 +83,7 @@ export default function UrbitOSHome() {
8383 <Box>
8484 <Box>Network Keys</Box>
8585 <Box
86− className={`subtitle ${
87− !hasSetNetworkKeys ? 'error-text' : ''
88− }`}>
86+ className={`subtitle ${!hasSetNetworkKeys ? 'error-text' : ''}`}>
8987 {hasSetNetworkKeys
9088 ? `Revision: ${point.keyRevisionNumber}`
9189 : 'No network keys found'}
src/views/UrbitOS/NetworkKeys.scssnew file+37
@@ -0,0 +1,37 @@
1+@import 'style/shared/variables.scss';
2+
3+.network-keys {
4+ font-size: 14px;
5+
6+ .body-pane {
7+ .contents {
8+ height: 448px;
9+ width: 100%;
10+ display: flex;
11+ flex-direction: column;
12+ justify-content: space-between;
13+
14+ .check-row {
15+ margin-top: 8px;
16+ font-weight: 500;
17+
18+ .checkbox {
19+ border-radius: $medium-border-radius;
20+ height: 16px;
21+ width: 16px;
22+ margin-right: 14px;
23+
24+ svg {
25+ height: 18px;
26+ width: 18px;
27+ }
28+ }
29+ }
30+
31+ .info-text {
32+ color: $dark-gray;
33+ margin: 8px 0px 24px 32px;
34+ }
35+ }
36+ }
37+}
src/views/UrbitOS/NetworkKeys.js → src/views/UrbitOS/NetworkKeys.tsxrenamed+79−65
@@ -6,9 +6,10 @@ import React, {
66 useState,
77} from 'react';
88import { Just } from 'folktale/maybe';
9−import { Grid, ToggleInput, CheckboxInput, Button } from 'indigo-react';
9+import { Grid, Button } from 'indigo-react';
1010import * as azimuth from 'azimuth-js';
1111import { randomHex } from 'web3-utils';
12+import { Box, Checkbox, Row } from '@tlon/indigo-react';
1213
1314import { usePointCursor } from 'store/pointCursor';
1415import { usePointCache } from 'store/pointCache';
@@ -41,26 +42,29 @@ import {
4142 buildHexValidator,
4243} from 'form/validators';
4344import BridgeForm from 'form/BridgeForm';
44−import Condition from 'form/Condition';
4545import FormError from 'form/FormError';
4646import { convertToInt } from 'lib/convertToInt';
4747import Window from 'components/L2/Window/Window';
4848import HeaderPane from 'components/L2/Window/HeaderPane';
4949import BodyPane from 'components/L2/Window/BodyPane';
50−import { Box, Row } from '@tlon/indigo-react';
5150
52−function useSetKeys(manualNetworkSeed, setManualNetworkSeed) {
53− const { urbitWallet, wallet, authMnemonic, authToken } = useWallet();
54− const { pointCursor } = usePointCursor();
55− const { syncDetails, syncRekeyDate, getDetails } = usePointCache();
56− const { contracts } = useNetwork();
51+import './NetworkKeys.scss';
52+
53+function useSetKeys(
54+ manualNetworkSeed: string,
55+ setManualNetworkSeed: (seed: string) => void
56+) {
57+ const { urbitWallet, wallet, authMnemonic, authToken }: any = useWallet();
58+ const { pointCursor }: any = usePointCursor();
59+ const { syncDetails, syncRekeyDate, getDetails }: any = usePointCache();
60+ const { contracts }: any = useNetwork();
5761
5862 const _point = need.point(pointCursor);
5963 const _contracts = need.contracts(contracts);
6064 const _details = need.details(getDetails(_point));
6165
6266 const networkRevision = convertToInt(_details.keyRevisionNumber, 10);
63− const randomSeed = useRef();
67+ const randomSeed = useRef<string | null>();
6468
6569 const {
6670 available: keyfileAvailable,
@@ -112,7 +116,7 @@ function useSetKeys(manualNetworkSeed, setManualNetworkSeed) {
112116
113117 const { completed: _completed, ...rest } = useEthereumTransaction(
114118 useCallback(
115− async (manualSeed, isDiscontinuity) => {
119+ async (manualSeed: string, isDiscontinuity: boolean) => {
116120 const seed = await buildNetworkSeed(manualSeed);
117121 const pair = deriveNetworkKeys(seed);
118122
@@ -148,8 +152,11 @@ function useSetKeys(manualNetworkSeed, setManualNetworkSeed) {
148152export default function UrbitOSNetworkKeys({
149153 manualNetworkSeed,
150154 setManualNetworkSeed,
155+}: {
156+ manualNetworkSeed: string;
157+ setManualNetworkSeed: (seed: string) => void;
151158}) {
152− const { pop } = useLocalRouter();
159+ const { pop }: any = useLocalRouter();
153160 const { point, setLoading } = useRollerStore();
154161 const {
155162 configureNetworkKeys,
@@ -157,6 +164,7 @@ export default function UrbitOSNetworkKeys({
157164 checkForUpdates,
158165 } = useRoller();
159166 const [breach, setBreach] = useState(false);
167+ const [useCustomSeed, setUseCustomSeed] = useState(false);
160168
161169 const hasKeys = point.networkKeysSet;
162170
@@ -200,12 +208,9 @@ export default function UrbitOSNetworkKeys({
200208 const onValues = useCallback(
201209 ({ valid, values, form }) => {
202210 if (valid) {
203− construct(
204− values.useNetworkSeed ? values.networkSeed : undefined,
205− values.useDiscontinuity
206− );
207− setBreach(values.useDiscontinuity);
208− setManualNetworkSeed(values.useNetworkSeed);
211+ const networkSeed = useCustomSeed ? values.networkSeed : undefined;
212+ construct(networkSeed, breach);
213+ setManualNetworkSeed(networkSeed);
209214 } else {
210215 unconstruct();
211216 }
@@ -216,7 +221,14 @@ export default function UrbitOSNetworkKeys({
216221 setManualNetworkSeed('');
217222 }
218223 },
219− [construct, unconstruct, setManualNetworkSeed, setBreach]
224+ [
225+ construct,
226+ unconstruct,
227+ breach,
228+ setManualNetworkSeed,
229+ setBreach,
230+ useCustomSeed,
231+ ]
220232 );
221233
222234 const setNetworkKeys = useCallback(async () => {
@@ -224,10 +236,10 @@ export default function UrbitOSNetworkKeys({
224236 try {
225237 await configureNetworkKeys({
226238 breach,
227− manualNetworkSeed,
239+ customNetworkSeed: manualNetworkSeed,
228240 });
229241 // TODO: just use the tx hash instead?
230− getPendingTransactions(point);
242+ getPendingTransactions();
231243 // TODO: this is just so we get visual feedback that the tx has gone through
232244 // but this should be addressed with the new UI flow (-> download keyfile)
233245 //
@@ -264,26 +276,17 @@ export default function UrbitOSNetworkKeys({
264276 []
265277 );
266278
267− const viewTitle = completed
268− ? 'Network Keys are now set'
269− : 'Set Network Keys';
279+ const viewTitle = completed ? 'Network Keys are now set' : 'Set Network Keys';
270280
271281 const usageMessage =
272282 'You need this keyfile to authenticate with your OS. Please Download.';
273283
274284 return (
275− <Window>
285+ <Window className="network-keys">
276286 <HeaderPane>
277− <Row className="header-row">
278− <h5>{viewTitle}</h5>
279− </Row>
287+ <h5>{viewTitle}</h5>
280288 </HeaderPane>
281289 <BodyPane>
282− {!completed && (
283− <Grid.Item className="gray4 f5 mv2 align-self-start" full>
284− Network Keys authenticate Urbit ID with Urbit OS.
285− </Grid.Item>
286− )}
287290 {completed && (
288291 <>
289292 <Grid.Item
@@ -304,43 +307,54 @@ export default function UrbitOSNetworkKeys({
304307 onValues={onValues}
305308 initialValues={initialValues}>
306309 {() => (
307− <Box width="100%">
310+ <Box className="contents">
308311 {!completed && (
309− <>
310− <Grid.Item
311− full
312− as={ToggleInput}
313− name="useNetworkSeed"
314− label="Use Custom Network Seed"
315− inverseLabel="Back to Derived Network Seed"
316− disabled={inputsLocked}
317− />
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.
323− </Grid.Item>
324− <Grid.Item
325− full
326− as={HexInput}
327− name="networkSeed"
328− label="Network Seed (32 bytes)"
312+ <Box>
313+ <Row className="check-row" onClick={() => setBreach(!breach)}>
314+ <Checkbox
315+ className="checkbox"
316+ selected={breach}
329317 disabled={inputsLocked}
330− className="mb6"
331318 />
332− </Condition>
333− <Grid.Item
334− full
335− as={CheckboxInput}
336− name="useDiscontinuity"
337− label="Breach Continuity"
338− disabled={inputsLocked}
339− className="mb6"
340− />
341−
319+ Factory Reset
320+ </Row>
321+ <Box className="info-text">
322+ Use if your ship is corrupted, you lost your files, or
323+ <br />
324+ you want to erase your data
325+ </Box>
326+ <Row
327+ className="check-row"
328+ onClick={() => setUseCustomSeed(!useCustomSeed)}>
329+ <Checkbox
330+ className="checkbox"
331+ selected={useCustomSeed}
332+ disabled={inputsLocked}
333+ />
334+ Custom Network Seed
335+ </Row>
336+ <Box className="info-text">
337+ Enter your own custom network seed to derive from
338+ </Box>
339+ {useCustomSeed && (
340+ <>
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.
345+ </Grid.Item>
346+ <Grid.Item
347+ full
348+ as={HexInput}
349+ name="networkSeed"
350+ label="Network Seed (32 bytes)"
351+ disabled={inputsLocked}
352+ className="mb5"
353+ />
354+ </>
355+ )}
342356 <Grid.Item full as={FormError} />
343− </>
357+ </Box>
344358 )}
345359
346360 {point.isL2 ? (