on master help sign in
address review comments
commit93bfa0c09e60dbf46e7ea34cc06017455ea10a06 authorLiam Fitzgerald <liam@urizen.co> dateFri 6 Mar 2020, 13:17 (7 years ago) parent7701299
7 files changed+92−44
src/components/CopyButton.js+28 src/components/InlineEthereumTransaction.js+34−35 src/store/lib/useResidentsStore.js+24−2 src/views/UrbitID.js+1−1 src/views/UrbitID/Home.js+1−1 src/views/UrbitID/ResetKeys/ResetExecute.js+2−2 src/views/UrbitOS/Home.js+2−3
src/components/CopyButton.js+28
@@ -2,6 +2,8 @@ import React from 'react';
22import cn from 'classnames';
33import { LinkButton } from 'indigo-react';
44
5+import { ForwardButton } from 'components/Buttons';
6+
57import useCopiable from 'lib/useCopiable';
68
79const renderDefaultCopyText = didCopy => (didCopy ? 'Copied!' : 'Copy');
@@ -27,3 +29,29 @@ export default function CopyButton({
2729 </As>
2830 );
2931}
32+
33+export function CopyButtonWide({
34+ as: As = ForwardButton,
35+ text,
36+ children,
37+ accessory = renderDefaultCopyText,
38+ ...rest
39+}) {
40+ const [doCopy, didCopy] = useCopiable(text);
41+ return (
42+ <As
43+ onClick={doCopy}
44+ accessory={
45+ <LinkButton
46+ className={{
47+ black: !didCopy,
48+ green3: didCopy,
49+ }}>
50+ {accessory(didCopy)}
51+ </LinkButton>
52+ }
53+ {...rest}>
54+ {children}
55+ </As>
56+ );
57+}
src/components/InlineEthereumTransaction.js+34−35
@@ -103,7 +103,31 @@ export default function InlineEthereumTransaction({
103103 </Grid.Item>
104104 );
105105 } else if (completed) {
106− return undefined;
106+ return (
107+ <>
108+ <Grid.Divider />
109+ <Grid.Item full as={RestartButton} onClick={onReturn}>
110+ Return
111+ </Grid.Item>
112+ <Grid.Divider />
113+ {showReceipt && (
114+ <TransactionReceipt
115+ txHashes={txHashes}
116+ maxCost={maxCost}
117+ onClose={toggleShowReceipt}
118+ />
119+ )}
120+
121+ {!showReceipt && (
122+ <Grid.Item
123+ className="underline mv2 pointer"
124+ full
125+ onClick={toggleShowReceipt}>
126+ View Receipt
127+ </Grid.Item>
128+ )}
129+ </>
130+ );
107131 } else if (showBroadcastButton) {
108132 return (
109133 <Grid.Item
@@ -159,7 +183,8 @@ export default function InlineEthereumTransaction({
159183 .mul(toBN(gasPrice))
160184 .mul(toBN(numTxs)),
161185 'gwei'
162− )
186+ ),
187+ 'eth'
163188 ),
164189 [gasLimit, gasPrice, numTxs]
165190 );
@@ -214,7 +239,7 @@ export default function InlineEthereumTransaction({
214239 row
215240 justify="between"
216241 className="mt2">
217− <Flex.Item as={H5}>Gas Price</Flex.Item>
242+ <Flex.Item as={H5}>Transaction Fee</Flex.Item>
218243
219244 <Flex.Item as={H5}>
220245 {gasInfo}{' '}
@@ -264,38 +289,12 @@ export default function InlineEthereumTransaction({
264289 <Condition when="viewSigned" is={true}>
265290 <SignedTransactionList
266291 serializedTxsHex={serializedTxsHex}
267− gasPrice={gasPrice}
292+ maxCost={maxCost}
268293 nonce={nonce}
269294 />
270295 </Condition>
271296 </>
272297 )}
273−
274− {completed && (
275− <>
276− <Grid.Divider />
277− <Grid.Item full as={RestartButton} onClick={onReturn}>
278− Return
279− </Grid.Item>
280− <Grid.Divider />
281− {showReceipt && (
282− <TransactionReceipt
283− txHashes={txHashes}
284− maxCost={maxCost}
285− onClose={toggleShowReceipt}
286− />
287− )}
288−
289− {!showReceipt && (
290− <Grid.Item
291− className="underline mv2 pointer"
292− full
293− onClick={toggleShowReceipt}>
294− View Receipt
295− </Grid.Item>
296− )}
297− </>
298− )}
299298 </>
300299 )}
301300 </BridgeForm>
@@ -303,9 +302,9 @@ export default function InlineEthereumTransaction({
303302 );
304303}
305304
306−function SignedTransactionList({ serializedTxsHex, nonce, gasPrice }) {
305+function SignedTransactionList({ serializedTxsHex, nonce, maxCost }) {
307306 return serializedTxsHex.map((serializedTxHex, i) => (
308− <React.Fragment key="i">
307+ <React.Fragment key={i}>
309308 <Grid.Divider />
310309 <Grid.Item full as={Flex} justify="between" className="pv4 black f5">
311310 <Flex.Item>Nonce</Flex.Item>
@@ -313,8 +312,8 @@ function SignedTransactionList({ serializedTxsHex, nonce, gasPrice }) {
313312 </Grid.Item>
314313 <Grid.Divider />
315314 <Grid.Item full as={Flex} justify="between" className="pv4 black f5">
316− <Flex.Item>Gas Price</Flex.Item>
317− <Flex.Item>{gasPrice.toFixed()} Gwei</Flex.Item>
315+ <Flex.Item>Transaction Cost</Flex.Item>
316+ <Flex.Item>{maxCost} ETH</Flex.Item>
318317 </Grid.Item>
319318 <Grid.Divider />
320319 <Grid.Item full as={Flex} justify="between" className="mt3 mb2">
@@ -340,7 +339,7 @@ function TransactionReceipt({ txHashes, maxCost, onClose }) {
340339 </Flex.Item>
341340 </Grid.Item>
342341 <Grid.Item full as={Flex} justify="between" className="pv2 black f5">
343− <Flex.Item>Gas Price</Flex.Item>
342+ <Flex.Item>Transaction Cost</Flex.Item>
344343 <Flex.Item className="mono">{maxCost} ETH</Flex.Item>
345344 </Grid.Item>
346345 <Grid.Divider />
src/store/lib/useResidentsStore.js+24−2
@@ -34,16 +34,28 @@ export default function useResidents() {
3434 const syncResidentCount = useCallback(
3535 async point => {
3636 // Do nothing if we've already fetched in full
37+ // or we aren't a sponsor
38+ const pointSize = azimuth.getPointSize(point);
3739 if (Just.hasInstance(getResidents(point).residents)) {
3840 return;
3941 }
42+ if (pointSize === azimuth.PointSize.Planet) {
43+ addToResidentCache(point, {
44+ residentCount: Just(0),
45+ requestsCount: Just(0),
46+ requests: Just([]),
47+ residents: Just([]),
48+ });
49+ return;
50+ }
4051
41− const isGalaxy = azimuth.getPointSize(point) === azimuth.PointSize.Galaxy;
52+ const isGalaxy = pointSize === azimuth.PointSize.Galaxy;
4253 const [residentCount, requestCount] = await Promise.all([
4354 azimuth.getSponsoringCount(_contracts, point),
4455 azimuth.getEscapeRequestsCount(_contracts, point),
4556 ]);
4657
58+ // Galaxies sponsor themselves
4759 const _residentCount = isGalaxy
4860 ? residentCount.toNumber() - 1
4961 : residentCount.toNumber();
@@ -60,12 +72,22 @@ export default function useResidents() {
6072
6173 const syncResidents = useCallback(
6274 async point => {
63− // Galaxies sponsor themselves
75+ if (azimuth.getPointSize(point) === azimuth.PointSize.Planet) {
76+ addToResidentCache(point, {
77+ residentCount: Just(0),
78+ requestsCount: Just(0),
79+ requests: Just([]),
80+ residents: Just([]),
81+ });
82+
83+ return;
84+ }
6485 const [residents, requests] = await Promise.all([
6586 azimuth.getSponsoring(_contracts, point),
6687 azimuth.getEscapeRequests(_contracts, point),
6788 ]);
6889
90+ // Galaxies sponsor themselves
6991 const _residents = residents.filter(r => r !== point);
7092
7193 addToResidentCache(point, {
src/views/UrbitID.js+1−1
@@ -53,7 +53,7 @@ const humanizeName = name => {
5353 }
5454};
5555
56−export default function UrbitOS() {
56+export default function UrbitID() {
5757 const history = useHistory();
5858 const name = useCurrentPointName();
5959
src/views/UrbitID/Home.js+1−1
@@ -85,7 +85,7 @@ export default function UrbitIDHome() {
8585 disabled={!isMasterTicket}
8686 disabledDetail={
8787 <B className="wrap ws-normal">
88− · Master Ticket Authentication required.
88+ · Master Key Authentication required.
8989 </B>
9090 }>
9191 Download Keys
src/views/UrbitID/ResetKeys/ResetExecute.js+2−2
@@ -148,7 +148,7 @@ export default function ResetExecute({ newWallet, setNewWallet }) {
148148
149149 return (
150150 <Grid.Item full as={WarningBox} className="mt4">
151− Never give your Master Ticket to anyone
151+ Never give your Master Key to anyone
152152 </Grid.Item>
153153 );
154154 };
@@ -172,7 +172,7 @@ export default function ResetExecute({ newWallet, setNewWallet }) {
172172 className="mt4"
173173 accessory="↺"
174174 onClick={loginAndGoHome}>
175− Login with New Master Ticket
175+ Login with New Master Key
176176 </Grid.Item>
177177 </>
178178 ) : (
src/views/UrbitOS/Home.js+2−3
@@ -12,7 +12,7 @@ import useKeyfileGenerator from 'lib/useKeyfileGenerator';
1212import * as need from 'lib/need';
1313
1414import { OutButton, ForwardButton } from 'components/Buttons';
15−import CopyButton from 'components/CopyButton';
15+import { CopyButtonWide } from 'components/CopyButton';
1616import NetworkingKeys from 'components/NetworkingKeys';
1717import ProgressButton from 'components/ProgressButton';
1818
@@ -221,8 +221,7 @@ function Hosting({ manualNetworkSeed }) {
221221 <Grid.Item
222222 full
223223 className="mt2"
224− as={ForwardButton}
225− accessory={<CopyButton text={code} />}
224+ as={CopyButtonWide}
226225 detail={code}
227226 detailClassName="mono">
228227 Login Code