on master help sign in
Some more little updates
commita2cc722c8e69bb14a673d1f669f7ba0160249b0e authorWill Galebach <willbach@gmail.com> dateTue 7 Dec 2021, 16:20 (5 years ago) parent5e84d23
6 files changed+30−20
src/lib/types/Point.ts+4−1 src/store/lib/useControlledPointsStore.js+1−1 src/views/AcceptTransfer.js+8−5 src/views/CancelTransfer.js+10−5 src/views/Login/Metamask.js+6−4 src/views/Points.js+1−4
src/lib/types/Point.ts+4−1
@@ -3,6 +3,7 @@ import { isGalaxy, isPlanet, isStar } from 'lib/utils/point';
33import { eqAddr, isZeroAddress } from 'lib/utils/address';
44import { L1Point } from './L1Point';
55import { Proxy } from '@urbit/roller-api';
6+import { DUMMY_L2_ADDRESS } from 'lib/constants';
67
78export interface Points {
89 [key: number]: Point;
@@ -182,7 +183,9 @@ export default class Point {
182183 (this.isOwner || this.isSpawnProxy || this.isManagementProxy);
183184 this.shouldDisplay = this.ownManageSpawn || this.isTransferProxy;
184185 this.isOutgoing =
185− this.isTransferProxySet && this.isTransferProxy && this.canManage;
186+ this.isTransferProxySet &&
187+ this.canManage &&
188+ this.transferProxy !== DUMMY_L2_ADDRESS;
186189 }
187190
188191 equals = (point: Point) => {
src/store/lib/useControlledPointsStore.js+1−1
@@ -113,7 +113,7 @@ export default function useControlledPointsStore() {
113113 }
114114 } catch (error) {
115115 console.error('failed to fetch controlled points', error);
116− _setControlledPoints(Just(Result.Error(error.toString())));
116+ _setControlledPoints(Just(Result.Error(JSON.stringify(error))));
117117 }
118118 }, [contracts, wallet, getPoints, getPointsDetails]);
119119
src/views/AcceptTransfer.js+8−5
@@ -95,15 +95,18 @@ export default function AcceptTransfer() {
9595 [construct]
9696 );
9797 const goBack = useCallback(() => {
98− setPointCursor(Nothing());
9998 pop();
99+ setPointCursor(Nothing());
100100 }, [pop, setPointCursor]);
101101
102102 const acceptTransfer = useCallback(async () => {
103103 await transferPoint(_address, reset);
104− checkForUpdates(point.value, `${point.patp} has been transferred to you!`);
105− pop();
106− }, [transferPoint, checkForUpdates, point, pop, _address, reset]);
104+ await checkForUpdates(
105+ point.value,
106+ `${point.patp} has been transferred to you!`
107+ );
108+ goBack();
109+ }, [goBack, transferPoint, checkForUpdates, point, _address, reset]);
107110
108111 return (
109112 <View
@@ -161,7 +164,7 @@ export default function AcceptTransfer() {
161164 full
162165 as={InlineEthereumTransaction}
163166 {...bind}
164− onReturn={() => pop()}
167+ onReturn={() => goBack()}
165168 />
166169 )}
167170 </Grid>
src/views/CancelTransfer.js+10−5
@@ -57,7 +57,7 @@ function AdminCancelTransfer() {
5757 const { getDetails } = usePointCache();
5858 const { point } = useRollerStore();
5959 const { setProxyAddress, checkForUpdates } = useRoller();
60− const { pointCursor } = usePointCursor();
60+ const { pointCursor, setPointCursor } = usePointCursor();
6161 const _point = need.point(pointCursor);
6262
6363 const name = useCurrentPointName();
@@ -71,11 +71,16 @@ function AdminCancelTransfer() {
7171 }
7272 }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
7373
74+ const goBack = useCallback(() => {
75+ pop();
76+ setPointCursor(Nothing());
77+ }, [pop, setPointCursor]);
78+
7479 const cancelTransfer = useCallback(async () => {
7580 await setProxyAddress('transfer', ETH_ZERO_ADDR);
76− checkForUpdates(point.value, `${point.patp} transfer cancelled`);
77− pop();
78− }, [setProxyAddress, pop, checkForUpdates, point]);
81+ await checkForUpdates(point.value, `${point.patp} transfer cancelled`);
82+ goBack();
83+ }, [setProxyAddress, goBack, checkForUpdates, point]);
7984
8085 const formattedName = <span className="mono">{name}</span>;
8186 const formattedProxy = <span className="mono">{_details.transferProxy}</span>;
@@ -119,7 +124,7 @@ function AdminCancelTransfer() {
119124 full
120125 as={InlineEthereumTransaction}
121126 {...bind}
122− onReturn={() => pop()}
127+ onReturn={() => goBack()}
123128 />
124129 )}
125130 </BodyPane>
src/views/Login/Metamask.js+6−4
@@ -19,12 +19,13 @@ import Window from 'components/L2/Window/Window';
1919import HeaderPane from 'components/L2/Window/HeaderPane';
2020import BodyPane from 'components/L2/Window/BodyPane';
2121import { Row } from '@tlon/indigo-react';
22+import Web3 from 'web3';
2223
2324export default function Metamask({ className, goHome }) {
2425 useLoginView(WALLET_TYPES.METAMASK);
2526 const { setWallet, setWalletType, setAuthToken } = useWallet();
2627
27− const { web3, setMetamask } = useNetwork();
28+ const { setMetamask } = useNetwork();
2829
2930 useEffect(() => {
3031 setMetamask(true);
@@ -32,14 +33,15 @@ export default function Metamask({ className, goHome }) {
3233
3334 const onSubmit = useCallback(async () => {
3435 try {
35− const _web3 = need.web3(web3);
36+ setMetamask(true);
3637 const accounts = await window.ethereum.send('eth_requestAccounts');
3738 const wallet = new MetamaskWallet(accounts.result[0]);
3839
40+ const web3 = new Web3(window.ethereum);
3941 const authToken = await getAuthToken({
4042 address: wallet.address,
4143 walletType: WALLET_TYPES.METAMASK,
42− web3: _web3,
44+ web3,
4345 });
4446
4547 setAuthToken(Just(authToken));
@@ -49,7 +51,7 @@ export default function Metamask({ className, goHome }) {
4951 console.error(e);
5052 return { [FORM_ERROR]: e.message };
5153 }
52− }, [web3, setAuthToken, setWallet, setWalletType]);
54+ }, [setAuthToken, setWallet, setWalletType, setMetamask]);
5355
5456 return (
5557 <Grid className={className}>
src/views/Points.js+1−4
@@ -162,10 +162,7 @@ export default function Points() {
162162 );
163163
164164 const allPoints = pointList
165− .filter(
166− ({ isTransferProxySet, shouldDisplay }) =>
167− !isTransferProxySet && shouldDisplay
168− )
165+ .filter(({ shouldDisplay }) => shouldDisplay)
169166 .map(({ value }) => value);
170167
171168 // if we can only interact with a single point, jump to the point page.