on master help sign in
Some more little updates
a2cc722Will Galebach
src/lib/types/Point.ts+4−1
@@ -3,6 +3,7 @@ import { isGalaxy, isPlanet, isStar } from 'lib/utils/point';
3import { eqAddr, isZeroAddress } from 'lib/utils/address';
3import { eqAddr, isZeroAddress } from 'lib/utils/address';
4import { L1Point } from './L1Point';
4import { L1Point } from './L1Point';
5import { Proxy } from '@urbit/roller-api';
5import { Proxy } from '@urbit/roller-api';
6+import { DUMMY_L2_ADDRESS } from 'lib/constants';
6
7
7export interface Points {
8export interface Points {
8 [key: number]: Point;
9 [key: number]: Point;
@@ -182,7 +183,9 @@ export default class Point {
182 (this.isOwner || this.isSpawnProxy || this.isManagementProxy);
183 (this.isOwner || this.isSpawnProxy || this.isManagementProxy);
183 this.shouldDisplay = this.ownManageSpawn || this.isTransferProxy;
184 this.shouldDisplay = this.ownManageSpawn || this.isTransferProxy;
184 this.isOutgoing =
185 this.isOutgoing =
185− this.isTransferProxySet && this.isTransferProxy && this.canManage;
186+ this.isTransferProxySet &&
187+ this.canManage &&
188+ this.transferProxy !== DUMMY_L2_ADDRESS;
186 }
189 }
187
190
188 equals = (point: Point) => {
191 equals = (point: Point) => {
src/store/lib/useControlledPointsStore.js+1−1
@@ -113,7 +113,7 @@ export default function useControlledPointsStore() {
113 }
113 }
114 } catch (error) {
114 } catch (error) {
115 console.error('failed to fetch controlled points', error);
115 console.error('failed to fetch controlled points', error);
116− _setControlledPoints(Just(Result.Error(error.toString())));
116+ _setControlledPoints(Just(Result.Error(JSON.stringify(error))));
117 }
117 }
118 }, [contracts, wallet, getPoints, getPointsDetails]);
118 }, [contracts, wallet, getPoints, getPointsDetails]);
119
119
src/views/AcceptTransfer.js+8−5
@@ -95,15 +95,18 @@ export default function AcceptTransfer() {
95 [construct]
95 [construct]
96 );
96 );
97 const goBack = useCallback(() => {
97 const goBack = useCallback(() => {
98− setPointCursor(Nothing());
99 pop();
98 pop();
99+ setPointCursor(Nothing());
100 }, [pop, setPointCursor]);
100 }, [pop, setPointCursor]);
101
101
102 const acceptTransfer = useCallback(async () => {
102 const acceptTransfer = useCallback(async () => {
103 await transferPoint(_address, reset);
103 await transferPoint(_address, reset);
104+ await checkForUpdates(
105+ point.value,
104− checkForUpdates(point.value, `${point.patp} has been transferred to you!`);
106+ `${point.patp} has been transferred to you!`
105− pop();
107+ );
108+ goBack();
106− }, [transferPoint, checkForUpdates, point, pop, _address, reset]);
109+ }, [goBack, transferPoint, checkForUpdates, point, _address, reset]);
107
110
108 return (
111 return (
109 <View
112 <View
@@ -161,7 +164,7 @@ export default function AcceptTransfer() {
161 full
164 full
162 as={InlineEthereumTransaction}
165 as={InlineEthereumTransaction}
163 {...bind}
166 {...bind}
164− onReturn={() => pop()}
167+ onReturn={() => goBack()}
165 />
168 />
166 )}
169 )}
167 </Grid>
170 </Grid>
src/views/CancelTransfer.js+10−5
@@ -57,7 +57,7 @@ function AdminCancelTransfer() {
57 const { getDetails } = usePointCache();
57 const { getDetails } = usePointCache();
58 const { point } = useRollerStore();
58 const { point } = useRollerStore();
59 const { setProxyAddress, checkForUpdates } = useRoller();
59 const { setProxyAddress, checkForUpdates } = useRoller();
60− const { pointCursor } = usePointCursor();
60+ const { pointCursor, setPointCursor } = usePointCursor();
61 const _point = need.point(pointCursor);
61 const _point = need.point(pointCursor);
62
62
63 const name = useCurrentPointName();
63 const name = useCurrentPointName();
@@ -71,11 +71,16 @@ function AdminCancelTransfer() {
71 }
71 }
72 }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
72 }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
73
73
74+ const goBack = useCallback(() => {
75+ pop();
76+ setPointCursor(Nothing());
77+ }, [pop, setPointCursor]);
78+
74 const cancelTransfer = useCallback(async () => {
79 const cancelTransfer = useCallback(async () => {
75 await setProxyAddress('transfer', ETH_ZERO_ADDR);
80 await setProxyAddress('transfer', ETH_ZERO_ADDR);
76− checkForUpdates(point.value, `${point.patp} transfer cancelled`);
81+ await checkForUpdates(point.value, `${point.patp} transfer cancelled`);
77− pop();
82+ goBack();
78− }, [setProxyAddress, pop, checkForUpdates, point]);
83+ }, [setProxyAddress, goBack, checkForUpdates, point]);
79
84
80 const formattedName = <span className="mono">{name}</span>;
85 const formattedName = <span className="mono">{name}</span>;
81 const formattedProxy = <span className="mono">{_details.transferProxy}</span>;
86 const formattedProxy = <span className="mono">{_details.transferProxy}</span>;
@@ -119,7 +124,7 @@ function AdminCancelTransfer() {
119 full
124 full
120 as={InlineEthereumTransaction}
125 as={InlineEthereumTransaction}
121 {...bind}
126 {...bind}
122− onReturn={() => pop()}
127+ onReturn={() => goBack()}
123 />
128 />
124 )}
129 )}
125 </BodyPane>
130 </BodyPane>
src/views/Login/Metamask.js+6−4
@@ -19,12 +19,13 @@ import Window from 'components/L2/Window/Window';
19import HeaderPane from 'components/L2/Window/HeaderPane';
19import HeaderPane from 'components/L2/Window/HeaderPane';
20import BodyPane from 'components/L2/Window/BodyPane';
20import BodyPane from 'components/L2/Window/BodyPane';
21import { Row } from '@tlon/indigo-react';
21import { Row } from '@tlon/indigo-react';
22+import Web3 from 'web3';
22
23
23export default function Metamask({ className, goHome }) {
24export default function Metamask({ className, goHome }) {
24 useLoginView(WALLET_TYPES.METAMASK);
25 useLoginView(WALLET_TYPES.METAMASK);
25 const { setWallet, setWalletType, setAuthToken } = useWallet();
26 const { setWallet, setWalletType, setAuthToken } = useWallet();
26
27
27− const { web3, setMetamask } = useNetwork();
28+ const { setMetamask } = useNetwork();
28
29
29 useEffect(() => {
30 useEffect(() => {
30 setMetamask(true);
31 setMetamask(true);
@@ -32,14 +33,15 @@ export default function Metamask({ className, goHome }) {
32
33
33 const onSubmit = useCallback(async () => {
34 const onSubmit = useCallback(async () => {
34 try {
35 try {
35− const _web3 = need.web3(web3);
36+ setMetamask(true);
36 const accounts = await window.ethereum.send('eth_requestAccounts');
37 const accounts = await window.ethereum.send('eth_requestAccounts');
37 const wallet = new MetamaskWallet(accounts.result[0]);
38 const wallet = new MetamaskWallet(accounts.result[0]);
38
39
40+ const web3 = new Web3(window.ethereum);
39 const authToken = await getAuthToken({
41 const authToken = await getAuthToken({
40 address: wallet.address,
42 address: wallet.address,
41 walletType: WALLET_TYPES.METAMASK,
43 walletType: WALLET_TYPES.METAMASK,
42− web3: _web3,
44+ web3,
43 });
45 });
44
46
45 setAuthToken(Just(authToken));
47 setAuthToken(Just(authToken));
@@ -49,7 +51,7 @@ export default function Metamask({ className, goHome }) {
49 console.error(e);
51 console.error(e);
50 return { [FORM_ERROR]: e.message };
52 return { [FORM_ERROR]: e.message };
51 }
53 }
52− }, [web3, setAuthToken, setWallet, setWalletType]);
54+ }, [setAuthToken, setWallet, setWalletType, setMetamask]);
53
55
54 return (
56 return (
55 <Grid className={className}>
57 <Grid className={className}>
src/views/Points.js+1−4
@@ -162,10 +162,7 @@ export default function Points() {
162 );
162 );
163
163
164 const allPoints = pointList
164 const allPoints = pointList
165− .filter(
166− ({ isTransferProxySet, shouldDisplay }) =>
165+ .filter(({ shouldDisplay }) => shouldDisplay)
167− !isTransferProxySet && shouldDisplay
168− )
169 .map(({ value }) => value);
166 .map(({ value }) => value);
170
167
171 // if we can only interact with a single point, jump to the point page.
168 // if we can only interact with a single point, jump to the point page.