on master help sign in
Signing transactions with Metamask
31860d3Will Galebach
src/components/L2/Dropdowns/AccountsDropdown.tsx+3−2
@@ -54,11 +54,12 @@ const AccountsDropdown = ({ showMigrate = false }: AccountsDropdownProps) => {
54
54
55 const selectPoint = useCallback(
55 const selectPoint = useCallback(
56 (point: number) => () => {
56 (point: number) => () => {
57+ popTo(names.POINTS);
57 setPointCursor(Just(point));
58 setPointCursor(Just(point));
58 push(names.POINT);
59 push(names.POINT);
59 setOpen(false);
60 setOpen(false);
60 },
61 },
61− [push, names.POINT, setOpen, setPointCursor]
62+ [push, popTo, names, setOpen, setPointCursor]
62 );
63 );
63
64
64 const goHome = useCallback(() => popTo(names.POINTS), [names, popTo]);
65 const goHome = useCallback(() => popTo(names.POINTS), [names, popTo]);
@@ -137,7 +138,7 @@ const AccountsDropdown = ({ showMigrate = false }: AccountsDropdownProps) => {
137 )}
138 )}
138 {isParent && canSpawn && (
139 {isParent && canSpawn && (
139 <Row className="entry" onClick={goIssuePoint}>
140 <Row className="entry" onClick={goIssuePoint}>
140− <Box>Spawn{isStar ? ' Planets' : ' Stars'}</Box>
141+ <Box>{isStar ? 'Generate Invites' : 'Spawn Stars'}</Box>
141 <Icon icon="Plus" />
142 <Icon icon="Plus" />
142 </Row>
143 </Row>
143 )}
144 )}
src/components/L2/Dropdowns/Dropdown.scss+8
@@ -4,6 +4,14 @@
4 font-size: 14px;
4 font-size: 14px;
5 position: relative;
5 position: relative;
6
6
7+ .close-background {
8+ position: fixed;
9+ top: 0;
10+ bottom: 0;
11+ right: 0;
12+ left: 0;
13+ }
14+
7 .selector {
15 .selector {
8 background-color: $washed-gray;
16 background-color: $washed-gray;
9 padding: 8px;
17 padding: 8px;
src/components/L2/Dropdowns/Dropdown.tsx+1
@@ -20,6 +20,7 @@ const Dropdown = ({
20}: DropdownProps) => {
20}: DropdownProps) => {
21 return (
21 return (
22 <Box className={`dropdown ${className}`}>
22 <Box className={`dropdown ${className}`}>
23+ {open && <Box className="close-background" onClick={toggleOpen} />}
23 <Box className={`selector ${open ? 'open' : ''}`} onClick={toggleOpen}>
24 <Box className={`selector ${open ? 'open' : ''}`} onClick={toggleOpen}>
24 {value}
25 {value}
25 <Icon icon="ChevronSouth" />
26 <Icon icon="ChevronSouth" />
src/lib/useRoller.ts+11−13
@@ -336,10 +336,6 @@ export default function useRoller() {
336 outgoingPoints.filter((p: number) => !spawnedPoints.includes(p))
336 outgoingPoints.filter((p: number) => !spawnedPoints.includes(p))
337 );
337 );
338
338
339− if (isDevelopment) {
340− console.log('INVITED PLANETS', invitePlanets);
341− }
342−
343 const newInvites: Invite[] = [];
339 const newInvites: Invite[] = [];
344 // Iterate over all of the stored invites, generating wallet info as necessary
340 // Iterate over all of the stored invites, generating wallet info as necessary
345 const storedInvites = getStoredInvites(ls);
341 const storedInvites = getStoredInvites(ls);
@@ -409,7 +405,7 @@ export default function useRoller() {
409 const _contracts = contracts.getOrElse(null);
405 const _contracts = contracts.getOrElse(null);
410
406
411 if (_authToken && _contracts) {
407 if (_authToken && _contracts) {
412− let invitePoints = isL2 ? await api.getSpawned(curPoint) : [];
408+ let spawnedPoints = isL2 ? await api.getSpawned(curPoint) : [];
413
409
414 const availablePoints = await azimuth.azimuth.getUnspawnedChildren(
410 const availablePoints = await azimuth.azimuth.getUnspawnedChildren(
415 _contracts,
411 _contracts,
@@ -424,14 +420,16 @@ export default function useRoller() {
424 getDetails
420 getDetails
425 ).filter((p: number) => isPlanet(p) && availablePoints.includes(p));
421 ).filter((p: number) => isPlanet(p) && availablePoints.includes(p));
426
422
423+ const invitePoints = spawnedPoints
424+ .concat(
425+ outgoingPoints.filter((p: number) => !spawnedPoints.includes(p))
426+ )
427+ .filter((p: number) => !pendingSpawns.has(p));
428+
427 setPendingTransactions(newPending);
429 setPendingTransactions(newPending);
428− setInvitePoints(
430+ setInvitePoints(invitePoints);
429− invitePoints
431+
430− .concat(
432+ return invitePoints;
431− outgoingPoints.filter((p: number) => !invitePoints.includes(p))
432− )
433− .filter((p: number) => !pendingSpawns.has(p))
434− );
435 }
433 }
436 } catch (e) {
434 } catch (e) {
437 if (isDevelopment) {
435 if (isDevelopment) {
@@ -695,7 +693,7 @@ export default function useRoller() {
695 getNumInvites(currentL2);
693 getNumInvites(currentL2);
696 });
694 });
697 }
695 }
698− }, 1000);
696+ }, 10000000);
699
697
700 return () => clearInterval(interval);
698 return () => clearInterval(interval);
701 }, [nextBatchTime, getPendingTransactions, currentL2]); // eslint-disable-line react-hooks/exhaustive-deps
699 }, [nextBatchTime, getPendingTransactions, currentL2]); // eslint-disable-line react-hooks/exhaustive-deps
src/lib/utils/roller.ts+4−3
@@ -63,12 +63,13 @@ export const generateHashAndSign = async (
63 web3: any
63 web3: any
64) => {
64) => {
65 if (walletType === WALLET_TYPES.METAMASK) {
65 if (walletType === WALLET_TYPES.METAMASK) {
66− const hash = await api.getUnsignedTx(nonce, from, type, data);
66+ const hash = await api.prepareForSigning(nonce, from, type, data);
67 const sig = await web3.eth.personal.sign(hash, wallet.address, '');
67 const sig = await web3.eth.personal.sign(hash, wallet.address, '');
68 return sig;
68 return sig;
69 } else {
69 } else {
70− const hash = await api.hashTransaction(nonce, from, type, data);
70+ const hash = await api.getUnsignedTx(nonce, from, type, data);
71− return signTransactionHash(hash, wallet.privateKey);
71+ const sig = await signTransactionHash(hash, wallet.privateKey);
72+ return sig;
72 }
73 }
73};
74};
74
75
src/views/Point/Point.tsx+25−5
@@ -1,4 +1,4 @@
1−import { useCallback, useEffect, useState } from 'react';
1+import { useCallback, useEffect, useState, useRef } from 'react';
2import { Just } from 'folktale/maybe';
2import { Just } from 'folktale/maybe';
3import { Grid, Flex } from 'indigo-react';
3import { Grid, Flex } from 'indigo-react';
4import { Box, Icon, Row, Button, Checkbox } from '@tlon/indigo-react';
4import { Box, Icon, Row, Button, Checkbox } from '@tlon/indigo-react';
@@ -30,13 +30,16 @@ import Modal from 'components/L2/Modal';
30import { isPlanet, isStar } from 'lib/utils/point';
30import { isPlanet, isStar } from 'lib/utils/point';
31import { useHasNetworkKeysSet } from 'lib/useHasNetworkKeysSet';
31import { useHasNetworkKeysSet } from 'lib/useHasNetworkKeysSet';
32import { InviteForm } from './InviteForm';
32import { InviteForm } from './InviteForm';
33+import LoadingOverlay from 'components/L2/LoadingOverlay';
33
34
34export default function Point() {
35export default function Point() {
35 const { pop, push, names }: any = useLocalRouter();
36 const { pop, push, names }: any = useLocalRouter();
36 const { wallet }: any = useWallet();
37 const { wallet }: any = useWallet();
37 const { pointCursor }: any = usePointCursor();
38 const { pointCursor }: any = usePointCursor();
38 const point = need.point(pointCursor);
39 const point = need.point(pointCursor);
40+ const networkKeysSet = useHasNetworkKeysSet();
39 const { syncExtras }: any = usePointCache();
41 const { syncExtras }: any = usePointCache();
42+
40 const { api, getNumInvites, getPendingTransactions } = useRoller();
43 const { api, getNumInvites, getPendingTransactions } = useRoller();
41 const {
44 const {
42 pendingTransactions,
45 pendingTransactions,
@@ -45,10 +48,13 @@ export default function Point() {
45 setCurrentPoint,
48 setCurrentPoint,
46 setInvites,
49 setInvites,
47 } = useRollerStore();
50 } = useRollerStore();
48− const networkKeysSet = useHasNetworkKeysSet();
51+
49 const [seenMissingKeys, setSeenMissingKeys] = useSeenMissingKeys();
52 const [seenMissingKeys, setSeenMissingKeys] = useSeenMissingKeys();
50 const [showModal, setShowModal] = useState(false);
53 const [showModal, setShowModal] = useState(false);
51 const [hideMessage, setHideMessage] = useState(false);
54 const [hideMessage, setHideMessage] = useState(false);
55+ const [loading, setLoading] = useState(false);
56+
57+ const pointRef = useRef<number | null>(null);
52
58
53 const hideModal = useCallback(() => {
59 const hideModal = useCallback(() => {
54 if (hideMessage) {
60 if (hideMessage) {
@@ -59,8 +65,11 @@ export default function Point() {
59 }, [hideMessage, setShowModal, setSeenMissingKeys]);
65 }, [hideMessage, setShowModal, setSeenMissingKeys]);
60
66
61 useEffect(() => {
67 useEffect(() => {
68+ if (pointRef.current !== point) {
69+ pointRef.current = point;
62− setShowModal(!networkKeysSet && !seenMissingKeys);
70+ setShowModal(!networkKeysSet && !seenMissingKeys);
71+ }
63− }, [networkKeysSet, seenMissingKeys]);
72+ }, [networkKeysSet, seenMissingKeys, point]);
64
73
65 const loadL1Info = useCallback(async () => {
74 const loadL1Info = useCallback(async () => {
66 await syncExtras(point);
75 await syncExtras(point);
@@ -68,6 +77,7 @@ export default function Point() {
68
77
69 const loadL2Info = useCallback(async () => {
78 const loadL2Info = useCallback(async () => {
70 const getTransactions = async () => {
79 const getTransactions = async () => {
80+ setLoading(true);
71 const pointInfo = await api.getPoint(Number(point));
81 const pointInfo = await api.getPoint(Number(point));
72
82
73 if (isDevelopment) {
83 if (isDevelopment) {
@@ -76,10 +86,19 @@ export default function Point() {
76 getPendingTransactions();
86 getPendingTransactions();
77 setCurrentPoint(pointInfo);
87 setCurrentPoint(pointInfo);
78 getNumInvites(isL2(pointInfo.dominion));
88 getNumInvites(isL2(pointInfo.dominion));
89+
90+ setTimeout(() => setLoading(false), 100);
79 };
91 };
80
92
81 await getTransactions();
93 await getTransactions();
94+ }, [
95+ api,
96+ point,
97+ getNumInvites,
98+ setCurrentPoint,
82− }, [api, point, getNumInvites, setCurrentPoint, getPendingTransactions]);
99+ getPendingTransactions,
100+ setLoading,
101+ ]);
83
102
84 useEffect(() => {
103 useEffect(() => {
85 loadL1Info();
104 loadL1Info();
@@ -277,6 +296,7 @@ export default function Point() {
277 </Row>
296 </Row>
278 </Box>
297 </Box>
279 </Modal>
298 </Modal>
299+ <LoadingOverlay loading={loading} />
280 </View>
300 </View>
281 );
301 );
282}
302}
src/views/Points.js+3−7
@@ -8,6 +8,7 @@ import { useWallet } from 'store/wallet';
8import { usePointCache } from 'store/pointCache';
8import { usePointCache } from 'store/pointCache';
9import { usePointCursor } from 'store/pointCursor';
9import { usePointCursor } from 'store/pointCursor';
10import { useStarReleaseCache } from 'store/starRelease';
10import { useStarReleaseCache } from 'store/starRelease';
11+import { useNetwork } from 'store/network';
11
12
12import * as need from 'lib/need';
13import * as need from 'lib/need';
13import { isZeroAddress, abbreviateAddress } from 'lib/utils/address';
14import { isZeroAddress, abbreviateAddress } from 'lib/utils/address';
@@ -18,7 +19,6 @@ import { pluralize } from 'lib/pluralize';
18import newGithubIssueUrl from 'new-github-issue-url';
19import newGithubIssueUrl from 'new-github-issue-url';
19
20
20import View from 'components/View';
21import View from 'components/View';
21−import Blinky from 'components/Blinky';
22import Passport from 'components/Passport';
22import Passport from 'components/Passport';
23import Footer from 'components/Footer';
23import Footer from 'components/Footer';
24import { ForwardButton } from 'components/Buttons';
24import { ForwardButton } from 'components/Buttons';
@@ -26,7 +26,7 @@ import CopiableAddress from 'components/copiable/CopiableAddress';
26import NavHeader from 'components/NavHeader';
26import NavHeader from 'components/NavHeader';
27import L2PointHeader from 'components/L2/Headers/L2PointHeader';
27import L2PointHeader from 'components/L2/Headers/L2PointHeader';
28import IncomingPoint from 'components/L2/Points/IncomingPoint';
28import IncomingPoint from 'components/L2/Points/IncomingPoint';
29−import { useNetwork } from 'store/network';
29+import LoadingOverlay from 'components/L2/LoadingOverlay';
30
30
31export const maybeGetResult = (obj, key, defaultValue) =>
31export const maybeGetResult = (obj, key, defaultValue) =>
32 obj.matchWith({
32 obj.matchWith({
@@ -307,11 +307,7 @@ export default function Points() {
307 ) {
307 ) {
308 return (
308 return (
309 <View inset>
309 <View inset>
310− <Grid>
310+ <LoadingOverlay loading />
311− <Grid.Item full as={HelpText} className="mt8 t-center">
312− <Blinky /> Loading...
313− </Grid.Item>
314− </Grid>
315 </View>
311 </View>
316 );
312 );
317 }
313 }
src/views/UrbitOS/NetworkingKeys.js−1
@@ -212,7 +212,6 @@ export default function UrbitOSNetworkingKeys({
212
212
213 const setNetworkingKeys = useCallback(async () => {
213 const setNetworkingKeys = useCallback(async () => {
214 // setLoading(true);
214 // setLoading(true);
215− console.log(breach, manualNetworkSeed);
216 try {
215 try {
217 const txHash = await configureNetworkingKeys({
216 const txHash = await configureNetworkingKeys({
218 breach,
217 breach,