on master help sign in
Merge pull request #238 from urbit/feat/copy-things

feat: make addresses copiable across the app

commit43a012a1463ff3642a2333e3d6ca4fb546cc3eab authorMatt Condon <mattgcondon@gmail.com> dateMon 26 Aug 2019, 14:20 (7 years ago) parent58b9f2542b3758
11 files changed+69−37
src/components/InlineEthereumTransaction.js+5−3 src/indigo-react/components/Button.js+3−2 src/views/Activate/PassportTransfer.js+3−2 src/views/Admin/AdminEditPermissions.js+19−10 src/views/Admin/Reticket/ReticketExecute.js+3−2 src/views/CreateGalaxy.js+2−1 src/views/Disclaimer.js+1−2 src/views/Invite/InviteEmail.js+8−3 src/views/IssueChild.js+3−2 src/views/Party/PartySetPoolSize.js+12−6 src/views/Points.js+10−4
src/components/InlineEthereumTransaction.js+5−3
@@ -22,6 +22,7 @@ import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
2222import WarningBox from './WarningBox';
2323import CopyButton from './CopyButton';
2424import ProgressButton from './ProgressButton';
25+import CopiableAddress from './CopiableAddress';
2526
2627export default function InlineEthereumTransaction({
2728 // from useEthereumTransaction.bind
@@ -144,15 +145,16 @@ export default function InlineEthereumTransaction({
144145 {renderPrimarySection()}
145146
146147 {error && (
147− <Grid.Item full as={ErrorText} className="mt1">
148+ <Grid.Item full as={ErrorText} className="mv1">
148149 {error.message}
149150 </Grid.Item>
150151 )}
151152
152153 {needFunds && (
153154 <Grid.Item full as={WarningBox} className="mt3">
154− The address {needFunds.address} needs at least{' '}
155− {fromWei(needFunds.minBalance)} ETH and currently has{' '}
155+ The address{' '}
156+ <CopiableAddress>{needFunds.address}</CopiableAddress> needs at
157+ least {fromWei(needFunds.minBalance)} ETH and currently has{' '}
156158 {fromWei(needFunds.balance)} ETH. Waiting until the account has
157159 enough funds.
158160 </Grid.Item>
src/indigo-react/components/Button.js+3−2
@@ -6,13 +6,14 @@ import Flex from './Flex';
66import { HelpText } from './Typography';
77
88export default function Button({
9− as: As = 'a',
9+ as: As = 'span',
1010 solid = false,
1111 success = false,
1212 disabled = false,
1313 disabledDetail,
1414 detail,
1515 className,
16+ detailClassName,
1617 accessory = '→',
1718 onClick,
1819 background,
@@ -56,7 +57,7 @@ export default function Button({
5657 <div className={cn('pl4')}>{accessory}</div>
5758 </Grid.Item>
5859 {detail && (
59− <Grid.Item full as={HelpText} className="z2">
60+ <Grid.Item full as={HelpText} className={cn('z2', detailClassName)}>
6061 {detail}
6162 </Grid.Item>
6263 )}
src/views/Activate/PassportTransfer.js+3−2
@@ -22,6 +22,7 @@ import { RestartButton } from 'components/Buttons';
2222
2323import { useActivateFlow } from './ActivateFlow';
2424import PassportView from './PassportView';
25+import CopiableAddress from 'components/CopiableAddress';
2526
2627const labelForProgress = progress => {
2728 if (progress <= 0) {
@@ -163,8 +164,8 @@ export default function PassportTransfer({ className, resetActivateRouter }) {
163164 return (
164165 <Grid.Item full className="mt8">
165166 <Highlighted warning>
166− The address {needFunds.address} needs at least{' '}
167− {fromWei(needFunds.minBalance)} ETH and currently has{' '}
167+ The address <CopiableAddress>{needFunds.address}</CopiableAddress>{' '}
168+ needs at least {fromWei(needFunds.minBalance)} ETH and currently has{' '}
168169 {fromWei(needFunds.balance)} ETH. Waiting until the account has
169170 enough funds.
170171 </Highlighted>
src/views/Admin/AdminEditPermissions.js+19−10
@@ -1,6 +1,6 @@
11import React, { useCallback } from 'react';
22import { Just, Nothing } from 'folktale/maybe';
3−import { Grid } from 'indigo-react';
3+import { Grid, LinkButton } from 'indigo-react';
44import { azimuth } from 'azimuth-js';
55
66import { useNetwork } from 'store/network';
@@ -18,6 +18,7 @@ import useCurrentPermissions from 'lib/useCurrentPermissions';
1818import ViewHeader from 'components/ViewHeader';
1919import { ForwardButton } from 'components/Buttons';
2020import { matchBlinkyDate } from 'components/Blinky';
21+import CopyButton from 'components/CopyButton';
2122
2223export default function AdminEditPermissions() {
2324 const { push, names } = useLocalRouter();
@@ -55,13 +56,15 @@ export default function AdminEditPermissions() {
5556
5657 return (
5758 <>
58− <Grid.Item full>
59− <ForwardButton
60− disabled={!isOwner}
61− onClick={() => goSetProxy(proxyType)}
62− detail={address}>
63− {capitalize(proxyTypeToHuman(proxyType))} Proxy Address
64− </ForwardButton>
59+ <Grid.Item
60+ full
61+ as={ForwardButton}
62+ disabled={!isOwner}
63+ onClick={() => goSetProxy(proxyType)}
64+ detail={address}
65+ detailClassName="mono"
66+ accessory={<LinkButton>Edit</LinkButton>}>
67+ {capitalize(proxyTypeToHuman(proxyType))} Proxy Address
6568 </Grid.Item>
6669 <Grid.Divider />
6770 </>
@@ -95,7 +98,12 @@ export default function AdminEditPermissions() {
9598 Permissions
9699 </Grid.Item>
97100
98− <Grid.Item full as={ForwardButton} detail={details.owner} disabled>
101+ <Grid.Item
102+ full
103+ as={ForwardButton}
104+ detail={details.owner}
105+ detailClassName="mono"
106+ accessory={<CopyButton text={details.owner} />}>
99107 Ownership Address
100108 </Grid.Item>
101109 <Grid.Divider />
@@ -111,7 +119,8 @@ export default function AdminEditPermissions() {
111119 as={ForwardButton}
112120 disabled={!canManage}
113121 onClick={goNetworkingKeys}
114− detail={renderNetworkKeysDetail()}>
122+ detail={renderNetworkKeysDetail()}
123+ accessory={<LinkButton>View</LinkButton>}>
115124 Networking Keys
116125 </Grid.Item>
117126 <Grid.Divider />
src/views/Admin/Reticket/ReticketExecute.js+3−2
@@ -21,6 +21,7 @@ import WarningBox from 'components/WarningBox';
2121import LoadingBar from 'components/LoadingBar';
2222import Highlighted from 'components/Highlighted';
2323import { WALLET_TYPES } from 'lib/wallet';
24+import CopiableAddress from 'components/CopiableAddress';
2425
2526const labelForProgress = progress => {
2627 if (progress <= 0) {
@@ -129,8 +130,8 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
129130 return (
130131 <Grid.Item full className="mt4">
131132 <Highlighted warning>
132− The address {needFunds.address} needs at least{' '}
133− {fromWei(needFunds.minBalance)} ETH and currently has{' '}
133+ The address <CopiableAddress>{needFunds.address}</CopiableAddress>{' '}
134+ needs at least {fromWei(needFunds.minBalance)} ETH and currently has{' '}
134135 {fromWei(needFunds.balance)} ETH. Waiting until the account has
135136 enough funds.
136137 </Highlighted>
src/views/CreateGalaxy.js+2−1
@@ -25,6 +25,7 @@ import {
2525 hasErrors,
2626} from 'form/validators';
2727import FormError from 'form/FormError';
28+import CopiableAddress from 'components/CopiableAddress';
2829
2930function useCreateGalaxy() {
3031 const { contracts } = useNetwork();
@@ -127,7 +128,7 @@ export default function CreateGalaxy() {
127128 green3: completed,
128129 })}>
129130 {values.galaxyName} has been created and can be claimed by{' '}
130− {values.owner}.
131+ <CopiableAddress>{values.owner}</CopiableAddress>.
131132 </Grid.Item>
132133 )}
133134
src/views/Disclaimer.js+1−2
@@ -62,8 +62,7 @@ export default function ActivateDisclaimer() {
6262 2. JSON files <br />
6363 3. Hardware wallet PINs; <br />
6464 4. Downloading this software from a reliable site, and ensuring it
65− has not been tampered with. [add something about using the checksum
66− here]
65+ has not been tampered with.
6766 </Text>
6867
6968 <B className={TEXT_STYLE}>To be clear</B>
src/views/Invite/InviteEmail.js+8−3
@@ -58,7 +58,9 @@ import FormError from 'form/FormError';
5858import { WARNING, onlyHasWarning } from 'form/helpers';
5959import useGasPrice from 'lib/useGasPrice';
6060import timeout from 'lib/timeout';
61+
6162import { ForwardButton } from 'components/Buttons';
63+import CopiableAddress from 'components/CopiableAddress';
6264
6365const INITIAL_VALUES = { emails: [''] };
6466
@@ -584,9 +586,12 @@ export default function InviteEmail() {
584586 {needFunds && (
585587 <Grid.Item full>
586588 <Highlighted warning>
587− Your ownership address {needFunds.address} needs at
588− least {fromWei(needFunds.minBalance)} ETH and
589− currently has {fromWei(needFunds.balance)} ETH.
589+ Your ownership address{' '}
590+ <CopiableAddress>
591+ {needFunds.address}
592+ </CopiableAddress>{' '}
593+ needs at least {fromWei(needFunds.minBalance)} ETH
594+ and currently has {fromWei(needFunds.balance)} ETH.
590595 Waiting until the account has enough funds.
591596 </Highlighted>
592597 </Grid.Item>
src/views/IssueChild.js+3−2
@@ -28,6 +28,7 @@ import {
2828} from 'form/validators';
2929import BridgeForm from 'form/BridgeForm';
3030import FormError from 'form/FormError';
31+import CopiableAddress from 'components/CopiableAddress';
3132
3233function useIssueChild() {
3334 const { contracts } = useNetwork();
@@ -84,7 +85,7 @@ export default function IssueChild() {
8485
8586 const validateFormAsync = useCallback(
8687 async values => {
87− const point = patp2dec(values.name);
88+ const point = patp2dec(values.point);
8889 const hasPoint = (await availablePointsPromise).has(point);
8990
9091 if (!hasPoint) {
@@ -153,7 +154,7 @@ export default function IssueChild() {
153154 green3: completed,
154155 })}>
155156 {values.point} has been spawned and can be claimed by{' '}
156− {values.owner}.
157+ <CopiableAddress>{values.owner}</CopiableAddress>.
157158 </Grid.Item>
158159 )}
159160
src/views/Party/PartySetPoolSize.js+12−6
@@ -27,6 +27,7 @@ import {
2727 buildPointValidator,
2828} from 'form/validators';
2929import FormError from 'form/FormError';
30+import CopiableAddress from 'components/CopiableAddress';
3031
3132function useSetPoolSize() {
3233 const { contracts } = useNetwork();
@@ -98,11 +99,11 @@ export default function PartySetPoolSize() {
9899 </Grid.Item>
99100
100101 {!spawnIsDelegatedSending && (
101− <Grid.Item full as={WarningBox} className="mb4">
102+ <Grid.Item full as={WarningBox} className="mb4 f6">
102103 The spawn proxy must be set to{' '}
103− <code className="mono f6">
104+ <CopiableAddress>
104105 {_contracts.delegatedSending.address}
105− </code>{' '}
106+ </CopiableAddress>{' '}
106107 for invitations to be available.
107108 </Grid.Item>
108109 )}
@@ -119,9 +120,14 @@ export default function PartySetPoolSize() {
119120 className={cn('f5 wrap', {
120121 green3: completed,
121122 })}>
122− {completed
123− ? `${values.poolSize} invites have been allocated to ${values.poolOwner}`
124− : `Allocate invites to a child point.`}
123+ {completed ? (
124+ <>
125+ {values.poolSize} invites have been allocated to{' '}
126+ <CopiableAddress>{values.poolOwner}</CopiableAddress>
127+ </>
128+ ) : (
129+ `Allocate invites to a child point.`
130+ )}
125131 </Grid.Item>
126132
127133 {!completed && (
src/views/Points.js+10−4
@@ -12,12 +12,13 @@ import * as need from 'lib/need';
1212import { isZeroAddress, abbreviateAddress } from 'lib/wallet';
1313import useIsEclipticOwner from 'lib/useIsEclipticOwner';
1414import { useSyncKnownPoints } from 'lib/useSyncPoints';
15+import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
16+import pluralize from 'lib/pluralize';
17+import useCopiable from 'lib/useCopiable';
1518
1619import View from 'components/View';
1720import Blinky from 'components/Blinky';
1821import Passport from 'components/Passport';
19−import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
20−import pluralize from 'lib/pluralize';
2122import Footer from 'components/Footer';
2223import { ForwardButton } from 'components/Buttons';
2324
@@ -162,6 +163,7 @@ export default function Points() {
162163 ]);
163164
164165 const address = need.addressFromWallet(wallet);
166+ const [doCopy, didCopy] = useCopiable(address);
165167
166168 const loading = Nothing.hasInstance(controlledPoints);
167169
@@ -208,8 +210,12 @@ export default function Points() {
208210 return (
209211 <View pop={pop} inset>
210212 <Grid>
211− <Grid.Item full as={H1} className="f6 mono gray4 mb4">
212− {abbreviateAddress(address)}
213+ <Grid.Item
214+ full
215+ as={H1}
216+ className="f6 mono gray4 mb4 us-none clickable"
217+ onClick={doCopy}>
218+ {`${abbreviateAddress(address)}${didCopy ? ' (copied!)' : ''}`}
213219 </Grid.Item>
214220
215221 {loading && (