on master help sign in
address review comments; prep for release
d575aa0Liam Fitzgerald
package-lock.json+3−3
@@ -2653,9 +2653,9 @@
2653 }
2653 }
2654 },
2654 },
2655 "azimuth-js": {
2655 "azimuth-js": {
2656− "version": "0.18.0",
2656+ "version": "0.19.0",
2657− "resolved": "https://registry.npmjs.org/azimuth-js/-/azimuth-js-0.18.0.tgz",
2657+ "resolved": "https://registry.npmjs.org/azimuth-js/-/azimuth-js-0.19.0.tgz",
2658− "integrity": "sha512-i8mkXIfWN9GKQcd8KsjQNbf393HVOadIMN6v40KgRnMIjM6dMgUP5zoEbCsG2Zn0SgLRgw0kiNyXHGVitdumiw==",
2658+ "integrity": "sha512-8OYrzCMgKCatTNzoNccFkp7fB+4ozol+OUfEo3kJ8TLMZOadT2Zk6ThGVWK1FPZupNcMuZ+s9OI+pqjFIRhwPQ==",
2659 "requires": {
2659 "requires": {
2660 "azimuth-solidity": "1.2.1",
2660 "azimuth-solidity": "1.2.1",
2661 "ethereumjs-util": "^5.2.0",
2661 "ethereumjs-util": "^5.2.0",
src/Bridge.js+1−1
@@ -20,7 +20,7 @@ import WithErrorBoundary from 'components/WithErrorBoundary';
20import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
20import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
21
21
22const INITIAL_NETWORK_TYPE = isDevelopment
22const INITIAL_NETWORK_TYPE = isDevelopment
23− ? NETWORK_TYPES.ROPSTEN
23+ ? NETWORK_TYPES.LOCAL
24 : NETWORK_TYPES.MAINNET;
24 : NETWORK_TYPES.MAINNET;
25
25
26// NB(shrugs): modify these variables to change the default local state.
26// NB(shrugs): modify these variables to change the default local state.
src/store/hosting.js+15−1
@@ -2,10 +2,24 @@ import React, { createContext, useContext, forwardRef } from 'react';
2
2
3import useHostingStore from './lib/useHostingStore';
3import useHostingStore from './lib/useHostingStore';
4
4
5+import { NETWORK_TYPES } from '../lib/network';
6+
7+import { useNetwork } from 'store/network';
8+
5export const HostingContext = createContext(null);
9export const HostingContext = createContext(null);
6
10
11+const HOSTING_DETAILS = {
12+ DEV: { url: '', domain: 'liam.tlon.network', disabled: false },
13+ MAINNET: { url: '', domain: '', disabled: true },
14+};
15+
7export function HostingProvider({ children }) {
16export function HostingProvider({ children }) {
17+ const { networkType } = useNetwork();
18+ const { url, domain, disabled } =
19+ networkType === NETWORK_TYPES.MAINNET
20+ ? HOSTING_DETAILS.MAINNET
21+ : HOSTING_DETAILS.DEV;
8− const store = useHostingStore('');
22+ const store = useHostingStore(url, domain, disabled);
9 return (
23 return (
10 <HostingContext.Provider value={store}>{children}</HostingContext.Provider>
24 <HostingContext.Provider value={store}>{children}</HostingContext.Provider>
11 );
25 );
src/store/lib/useHostingStore.js+16−15
@@ -14,7 +14,7 @@ const STATE = {
14 PENDING: 'PENDING',
14 PENDING: 'PENDING',
15};
15};
16
16
17−function useHostingStore(url) {
17+function useHostingStore(url, domain, disabled) {
18 const client = new SolarisClient(url);
18 const client = new SolarisClient(url);
19
19
20 const { pointCursor } = usePointCursor();
20 const { pointCursor } = usePointCursor();
@@ -26,7 +26,6 @@ function useHostingStore(url) {
26 const [status, _setStatus] = useState(STATE.UNKNOWN);
26 const [status, _setStatus] = useState(STATE.UNKNOWN);
27 const setStatus = useCallback(
27 const setStatus = useCallback(
28 s => {
28 s => {
29− console.log(s);
30 _setStatus(s);
29 _setStatus(s);
31 },
30 },
32 [_setStatus]
31 [_setStatus]
@@ -63,7 +62,7 @@ function useHostingStore(url) {
63
62
64 const getEvents = useCallback(() => {
63 const getEvents = useCallback(() => {
65 try {
64 try {
66− if (Nothing.hasInstance(pointCursor)) {
65+ if (Nothing.hasInstance(pointCursor) || disabled) {
67 return;
66 return;
68 }
67 }
69 const patp = ob.patp(pointCursor.value);
68 const patp = ob.patp(pointCursor.value);
@@ -74,21 +73,15 @@ function useHostingStore(url) {
74 const url = client.getShipsByPatpUrl(patp) + '/events';
73 const url = client.getShipsByPatpUrl(patp) + '/events';
75 const source = new EventSource(url);
74 const source = new EventSource(url);
76
75
77− // source.onerror = () => setStatus(STATE.UNKNOWN);
78− // source.onmessage = console.log;
79−
80 source.addEventListener('sys', event => {
76 source.addEventListener('sys', event => {
81− // console.log(event);
82 const sysEvent = JSON.parse(event.data);
77 const sysEvent = JSON.parse(event.data);
83 const time = new Date(sysEvent.object.firstTimestamp).getTime();
78 const time = new Date(sysEvent.object.firstTimestamp).getTime();
84 if (time > startTime) {
79 if (time > startTime) {
85− console.log(sysEvent);
86 setSysEvents(previous => [...previous, sysEvent]);
80 setSysEvents(previous => [...previous, sysEvent]);
87 }
81 }
88 });
82 });
89
83
90 source.addEventListener('new', event => {
84 source.addEventListener('new', event => {
91− // console.log(event);
92 const elapsed = (Date.now() - startTime) / 1000;
85 const elapsed = (Date.now() - startTime) / 1000;
93 if (event.data !== '') {
86 if (event.data !== '') {
94 setNewEvents(previous => [...previous, event.data]);
87 setNewEvents(previous => [...previous, event.data]);
@@ -96,7 +89,6 @@ function useHostingStore(url) {
96 if (event.data === '1-b') {
89 if (event.data === '1-b') {
97 setBootMessage('Compiling Hoon');
90 setBootMessage('Compiling Hoon');
98 setBootProgress(0.2);
91 setBootProgress(0.2);
99− console.log(`${elapsed}: compiling Hoon`);
100 } else if (event.data === '1-c') {
92 } else if (event.data === '1-c') {
101 setBootProgress(0.25);
93 setBootProgress(0.25);
102 } else if (event.data === '%arvo-assembly') {
94 } else if (event.data === '%arvo-assembly') {
@@ -127,6 +119,7 @@ function useHostingStore(url) {
127 }
119 }
128 }, [
120 }, [
129 setError,
121 setError,
122+ disabled,
130 resetEvents,
123 resetEvents,
131 client,
124 client,
132 pointCursor,
125 pointCursor,
@@ -137,7 +130,7 @@ function useHostingStore(url) {
137
130
138 syncStatus = useCallback(async () => {
131 syncStatus = useCallback(async () => {
139 try {
132 try {
140− if (Nothing.hasInstance(pointCursor)) {
133+ if (Nothing.hasInstance(pointCursor) || disabled) {
141 return;
134 return;
142 }
135 }
143 const patp = ob.patp(pointCursor.value);
136 const patp = ob.patp(pointCursor.value);
@@ -166,7 +159,15 @@ function useHostingStore(url) {
166 } catch (error) {
159 } catch (error) {
167 setError(error);
160 setError(error);
168 }
161 }
169− }, [client, getEvents, pointCursor, resetEvents, setError, setStatus]);
162+ }, [
163+ client,
164+ getEvents,
165+ pointCursor,
166+ resetEvents,
167+ setError,
168+ setStatus,
169+ disabled,
170+ ]);
170
171
171 const hostedShipUrl = useMemo(
172 const hostedShipUrl = useMemo(
172 () =>
173 () =>
@@ -177,14 +178,13 @@ function useHostingStore(url) {
177 const create = useCallback(
178 const create = useCallback(
178 async keyfile => {
179 async keyfile => {
179 try {
180 try {
180− if (Nothing.hasInstance(pointCursor)) {
181+ if (Nothing.hasInstance(pointCursor) || disabled) {
181 return;
182 return;
182 }
183 }
183 const patp = ob.patp(pointCursor.value).slice(1);
184 const patp = ob.patp(pointCursor.value).slice(1);
184 setError(undefined);
185 setError(undefined);
185
186
186 const start = Date.now();
187 const start = Date.now();
187− console.log(start);
188 setStatus(STATE.PENDING);
188 setStatus(STATE.PENDING);
189 setBootProgress(0.1);
189 setBootProgress(0.1);
190
190
@@ -204,7 +204,7 @@ function useHostingStore(url) {
204 setError(error);
204 setError(error);
205 }
205 }
206 },
206 },
207− [pointCursor, setError, setStatus, client, getEvents]
207+ [pointCursor, setError, setStatus, client, getEvents, disabled]
208 );
208 );
209
209
210 return {
210 return {
@@ -226,6 +226,7 @@ function useHostingStore(url) {
226 bootProgress,
226 bootProgress,
227 bootMessage,
227 bootMessage,
228
228
229+ disabled,
229 // debugging
230 // debugging
230 status,
231 status,
231 };
232 };
src/views/Adopt.js−1
@@ -45,7 +45,6 @@ export default function Adopt() {
45
45
46 const patp = useMemo(() => ob.patp(adoptee), [adoptee]);
46 const patp = useMemo(() => ob.patp(adoptee), [adoptee]);
47
47
48− // const header = //useMemo(() => denied ? 'A Request' : 'Accept Request', [denied]);
49 const { construct, bind, completed } = useAdopt();
48 const { construct, bind, completed } = useAdopt();
50
49
51 const body = useMemo(
50 const body = useMemo(
src/views/Point.js+2−2
@@ -261,7 +261,7 @@ export default function Point() {
261 as={ForwardButton}
261 as={ForwardButton}
262 disabled={!canManage}
262 disabled={!canManage}
263 onClick={goUrbitID}
263 onClick={goUrbitID}
264− className="mt2"
264+ className="mt1"
265 detail="Identity and security settings">
265 detail="Identity and security settings">
266 ID
266 ID
267 </Grid.Item>
267 </Grid.Item>
@@ -270,7 +270,7 @@ export default function Point() {
270 full
270 full
271 as={ForwardButton}
271 as={ForwardButton}
272 disabled={!canManage}
272 disabled={!canManage}
273− className="mt2"
273+ className="mt1"
274 detail="Urbit OS Settings"
274 detail="Urbit OS Settings"
275 onClick={goUrbitOS}>
275 onClick={goUrbitOS}>
276 OS
276 OS
src/views/UrbitOS/Home.js+46−29
@@ -96,7 +96,14 @@ function Hosting({ manualNetworkSeed }) {
96 const { keyfile, code } = bind;
96 const { keyfile, code } = bind;
97 const ship = useHosting();
97 const ship = useHosting();
98
98
99− const { syncStatus, url, unknown, bootProgress, bootMessage } = ship;
99+ const {
100+ syncStatus,
101+ url,
102+ unknown,
103+ bootProgress,
104+ bootMessage,
105+ disabled,
106+ } = ship;
100
107
101 const [synced, setSynced] = useState(false);
108 const [synced, setSynced] = useState(false);
102 useEffect(() => {
109 useEffect(() => {
@@ -180,34 +187,44 @@ function Hosting({ manualNetworkSeed }) {
180
187
181 return (
188 return (
182 <>
189 <>
190+ {disabled && (
183− <Grid gap={4}>
191+ <Grid gap={4}>
192+ <Grid.Item full className="f5">
193+ Urbit OS
194+ </Grid.Item>
195+ <Grid.Divider />
196+ </Grid>
197+ )}
198+ {!disabled && (
199+ <Grid gap={4}>
184− <Grid.Item full className="f5" as={Flex}>
200+ <Grid.Item full className="f5" as={Flex}>
185− <Flex.Item>Urbit OS </Flex.Item>
201+ <Flex.Item>Urbit OS </Flex.Item>
186− <Flex.Item
202+ <Flex.Item
187− className={cn(
203+ className={cn(
188− { green3: ship.running, gray4: !ship.running },
204+ { green3: ship.running, gray4: !ship.running },
189− 'ml3'
205+ 'ml3'
190− )}>
206+ )}>
191− {ship.running ? 'Connected' : 'Disconnected'}
207+ {ship.running ? 'Connected' : 'Disconnected'}
192− </Flex.Item>
208+ </Flex.Item>
193− </Grid.Item>
209+ </Grid.Item>
194− <BridgeForm initialValues={{ provider: 'tlon' }}>
210+ <BridgeForm initialValues={{ provider: 'tlon' }}>
195− {() => (
211+ {() => (
196− <>
212+ <>
197− {renderDetails()}
213+ {renderDetails()}
198− {renderMain()}
214+ {renderMain()}
199− <Grid.Item
215+ <Grid.Item
200− full
216+ full
201− as={SelectInput}
217+ as={SelectInput}
202− name="provider"
218+ name="provider"
203− label="Host Provider"
219+ label="Host Provider"
204− options={options}
220+ options={options}
205− disabled
221+ disabled
206− />
222+ />
207− </>
223+ </>
208− )}
224+ )}
209− </BridgeForm>
225+ </BridgeForm>
210− </Grid>
226+ </Grid>
227+ )}
211 <Grid>
228 <Grid>
212 <Grid.Item
229 <Grid.Item
213 full
230 full