on master help sign in
address review comments; prep for release
commitd575aa0238564bf19fbd7283396625bbb229203f authorLiam Fitzgerald <liam@urizen.co> dateWed 18 Mar 2020, 10:31 (7 years ago) parente02d105
7 files changed+83−52
package-lock.json+3−3 src/Bridge.js+1−1 src/store/hosting.js+15−1 src/store/lib/useHostingStore.js+16−15 src/views/Adopt.js−1 src/views/Point.js+2−2 src/views/UrbitOS/Home.js+46−29
package-lock.json+3−3
@@ -2653,9 +2653,9 @@
26532653 }
26542654 },
26552655 "azimuth-js": {
2656− "version": "0.18.0",
2657− "resolved": "https://registry.npmjs.org/azimuth-js/-/azimuth-js-0.18.0.tgz",
2658− "integrity": "sha512-i8mkXIfWN9GKQcd8KsjQNbf393HVOadIMN6v40KgRnMIjM6dMgUP5zoEbCsG2Zn0SgLRgw0kiNyXHGVitdumiw==",
2656+ "version": "0.19.0",
2657+ "resolved": "https://registry.npmjs.org/azimuth-js/-/azimuth-js-0.19.0.tgz",
2658+ "integrity": "sha512-8OYrzCMgKCatTNzoNccFkp7fB+4ozol+OUfEo3kJ8TLMZOadT2Zk6ThGVWK1FPZupNcMuZ+s9OI+pqjFIRhwPQ==",
26592659 "requires": {
26602660 "azimuth-solidity": "1.2.1",
26612661 "ethereumjs-util": "^5.2.0",
src/Bridge.js+1−1
@@ -20,7 +20,7 @@ import WithErrorBoundary from 'components/WithErrorBoundary';
2020import GlobalErrorBoundary from 'components/GlobalErrorBoundary';
2121
2222const INITIAL_NETWORK_TYPE = isDevelopment
23− ? NETWORK_TYPES.ROPSTEN
23+ ? NETWORK_TYPES.LOCAL
2424 : NETWORK_TYPES.MAINNET;
2525
2626// 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';
22
33import useHostingStore from './lib/useHostingStore';
44
5+import { NETWORK_TYPES } from '../lib/network';
6+
7+import { useNetwork } from 'store/network';
8+
59export const HostingContext = createContext(null);
610
11+const HOSTING_DETAILS = {
12+ DEV: { url: '', domain: 'liam.tlon.network', disabled: false },
13+ MAINNET: { url: '', domain: '', disabled: true },
14+};
15+
716export function HostingProvider({ children }) {
8− const store = useHostingStore('');
17+ const { networkType } = useNetwork();
18+ const { url, domain, disabled } =
19+ networkType === NETWORK_TYPES.MAINNET
20+ ? HOSTING_DETAILS.MAINNET
21+ : HOSTING_DETAILS.DEV;
22+ const store = useHostingStore(url, domain, disabled);
923 return (
1024 <HostingContext.Provider value={store}>{children}</HostingContext.Provider>
1125 );
src/store/lib/useHostingStore.js+16−15
@@ -14,7 +14,7 @@ const STATE = {
1414 PENDING: 'PENDING',
1515};
1616
17−function useHostingStore(url) {
17+function useHostingStore(url, domain, disabled) {
1818 const client = new SolarisClient(url);
1919
2020 const { pointCursor } = usePointCursor();
@@ -26,7 +26,6 @@ function useHostingStore(url) {
2626 const [status, _setStatus] = useState(STATE.UNKNOWN);
2727 const setStatus = useCallback(
2828 s => {
29− console.log(s);
3029 _setStatus(s);
3130 },
3231 [_setStatus]
@@ -63,7 +62,7 @@ function useHostingStore(url) {
6362
6463 const getEvents = useCallback(() => {
6564 try {
66− if (Nothing.hasInstance(pointCursor)) {
65+ if (Nothing.hasInstance(pointCursor) || disabled) {
6766 return;
6867 }
6968 const patp = ob.patp(pointCursor.value);
@@ -74,21 +73,15 @@ function useHostingStore(url) {
7473 const url = client.getShipsByPatpUrl(patp) + '/events';
7574 const source = new EventSource(url);
7675
77− // source.onerror = () => setStatus(STATE.UNKNOWN);
78− // source.onmessage = console.log;
79−
8076 source.addEventListener('sys', event => {
81− // console.log(event);
8277 const sysEvent = JSON.parse(event.data);
8378 const time = new Date(sysEvent.object.firstTimestamp).getTime();
8479 if (time > startTime) {
85− console.log(sysEvent);
8680 setSysEvents(previous => [...previous, sysEvent]);
8781 }
8882 });
8983
9084 source.addEventListener('new', event => {
91− // console.log(event);
9285 const elapsed = (Date.now() - startTime) / 1000;
9386 if (event.data !== '') {
9487 setNewEvents(previous => [...previous, event.data]);
@@ -96,7 +89,6 @@ function useHostingStore(url) {
9689 if (event.data === '1-b') {
9790 setBootMessage('Compiling Hoon');
9891 setBootProgress(0.2);
99− console.log(`${elapsed}: compiling Hoon`);
10092 } else if (event.data === '1-c') {
10193 setBootProgress(0.25);
10294 } else if (event.data === '%arvo-assembly') {
@@ -127,6 +119,7 @@ function useHostingStore(url) {
127119 }
128120 }, [
129121 setError,
122+ disabled,
130123 resetEvents,
131124 client,
132125 pointCursor,
@@ -137,7 +130,7 @@ function useHostingStore(url) {
137130
138131 syncStatus = useCallback(async () => {
139132 try {
140− if (Nothing.hasInstance(pointCursor)) {
133+ if (Nothing.hasInstance(pointCursor) || disabled) {
141134 return;
142135 }
143136 const patp = ob.patp(pointCursor.value);
@@ -166,7 +159,15 @@ function useHostingStore(url) {
166159 } catch (error) {
167160 setError(error);
168161 }
169− }, [client, getEvents, pointCursor, resetEvents, setError, setStatus]);
162+ }, [
163+ client,
164+ getEvents,
165+ pointCursor,
166+ resetEvents,
167+ setError,
168+ setStatus,
169+ disabled,
170+ ]);
170171
171172 const hostedShipUrl = useMemo(
172173 () =>
@@ -177,14 +178,13 @@ function useHostingStore(url) {
177178 const create = useCallback(
178179 async keyfile => {
179180 try {
180− if (Nothing.hasInstance(pointCursor)) {
181+ if (Nothing.hasInstance(pointCursor) || disabled) {
181182 return;
182183 }
183184 const patp = ob.patp(pointCursor.value).slice(1);
184185 setError(undefined);
185186
186187 const start = Date.now();
187− console.log(start);
188188 setStatus(STATE.PENDING);
189189 setBootProgress(0.1);
190190
@@ -204,7 +204,7 @@ function useHostingStore(url) {
204204 setError(error);
205205 }
206206 },
207− [pointCursor, setError, setStatus, client, getEvents]
207+ [pointCursor, setError, setStatus, client, getEvents, disabled]
208208 );
209209
210210 return {
@@ -226,6 +226,7 @@ function useHostingStore(url) {
226226 bootProgress,
227227 bootMessage,
228228
229+ disabled,
229230 // debugging
230231 status,
231232 };
src/views/Adopt.js−1
@@ -45,7 +45,6 @@ export default function Adopt() {
4545
4646 const patp = useMemo(() => ob.patp(adoptee), [adoptee]);
4747
48− // const header = //useMemo(() => denied ? 'A Request' : 'Accept Request', [denied]);
4948 const { construct, bind, completed } = useAdopt();
5049
5150 const body = useMemo(
src/views/Point.js+2−2
@@ -261,7 +261,7 @@ export default function Point() {
261261 as={ForwardButton}
262262 disabled={!canManage}
263263 onClick={goUrbitID}
264− className="mt2"
264+ className="mt1"
265265 detail="Identity and security settings">
266266 ID
267267 </Grid.Item>
@@ -270,7 +270,7 @@ export default function Point() {
270270 full
271271 as={ForwardButton}
272272 disabled={!canManage}
273− className="mt2"
273+ className="mt1"
274274 detail="Urbit OS Settings"
275275 onClick={goUrbitOS}>
276276 OS
src/views/UrbitOS/Home.js+46−29
@@ -96,7 +96,14 @@ function Hosting({ manualNetworkSeed }) {
9696 const { keyfile, code } = bind;
9797 const ship = useHosting();
9898
99− const { syncStatus, url, unknown, bootProgress, bootMessage } = ship;
99+ const {
100+ syncStatus,
101+ url,
102+ unknown,
103+ bootProgress,
104+ bootMessage,
105+ disabled,
106+ } = ship;
100107
101108 const [synced, setSynced] = useState(false);
102109 useEffect(() => {
@@ -180,34 +187,44 @@ function Hosting({ manualNetworkSeed }) {
180187
181188 return (
182189 <>
183− <Grid gap={4}>
184− <Grid.Item full className="f5" as={Flex}>
185− <Flex.Item>Urbit OS </Flex.Item>
186− <Flex.Item
187− className={cn(
188− { green3: ship.running, gray4: !ship.running },
189− 'ml3'
190− )}>
191− {ship.running ? 'Connected' : 'Disconnected'}
192− </Flex.Item>
193− </Grid.Item>
194− <BridgeForm initialValues={{ provider: 'tlon' }}>
195− {() => (
196− <>
197− {renderDetails()}
198− {renderMain()}
199− <Grid.Item
200− full
201− as={SelectInput}
202− name="provider"
203− label="Host Provider"
204− options={options}
205− disabled
206− />
207− </>
208− )}
209− </BridgeForm>
210− </Grid>
190+ {disabled && (
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}>
200+ <Grid.Item full className="f5" as={Flex}>
201+ <Flex.Item>Urbit OS </Flex.Item>
202+ <Flex.Item
203+ className={cn(
204+ { green3: ship.running, gray4: !ship.running },
205+ 'ml3'
206+ )}>
207+ {ship.running ? 'Connected' : 'Disconnected'}
208+ </Flex.Item>
209+ </Grid.Item>
210+ <BridgeForm initialValues={{ provider: 'tlon' }}>
211+ {() => (
212+ <>
213+ {renderDetails()}
214+ {renderMain()}
215+ <Grid.Item
216+ full
217+ as={SelectInput}
218+ name="provider"
219+ label="Host Provider"
220+ options={options}
221+ disabled
222+ />
223+ </>
224+ )}
225+ </BridgeForm>
226+ </Grid>
227+ )}
211228 <Grid>
212229 <Grid.Item
213230 full