on master help sign in
Fix learn more url, gas price, galaxy placeholder, l2 spawn proxy (#838)
commit2f349538e7efa7eeb2701c14bb8eef77a9534911 authorWill Galebach <willbach@gmail.com> dateFri 10 Dec 2021, 17:15 (5 years ago) parent5fbe909
14 files changed+77−118
src/components/L2/Headers/L2BackHeader.tsx+1−4 src/form/Inputs.tsx+8−1 src/lib/getSuggestedGasPrice.js+1−1 src/lib/proxy.js+2−2 src/views/AcceptTransfer.tsx+1−1 src/views/Invite/Cohort.tsx+2−2 src/views/Point/IssueChild.tsx+1−1 src/views/Point/MigrateL2.tsx+1−1 src/views/Point/UrbitOS.js+1−1 src/views/UrbitID/Home.tsx+18−24 src/views/UrbitID/SetProxy.js+5−3 src/views/UrbitID/SetProxy.scss+2−50 src/views/UrbitID/UrbitID.scss+4 src/views/UrbitOS/ChangeSponsor.js → src/views/UrbitOS/ChangeSponsor.tsx+30−27
src/components/L2/Headers/L2BackHeader.tsx+1−4
@@ -54,8 +54,6 @@ const L2BackHeader = ({
5454 getEthBalance();
5555 }, [currentL2, setEthBalance, wallet, web3]);
5656
57− const hasBalance = Number(ethBalance.toString()) !== 0;
58−
5957 return (
6058 <Row className={`l2-back-header ${className}`}>
6159 <HeaderButton icon="ChevronWest" onClick={goBack} />
@@ -65,8 +63,7 @@ const L2BackHeader = ({
6563 {nextRoll}
6664 </Row>
6765 ) : (
68− !hideBalance &&
69− hasBalance && (
66+ !hideBalance && (
7067 <Row className="eth-balance">
7168 <Wallet className="wallet-icon" />
7269 <Box>{ethBalance.toString()} ETH</Box>
src/form/Inputs.tsx+8−1
@@ -19,6 +19,7 @@ import {
1919 StatelessTextInputProps,
2020} from '@tlon/indigo-react';
2121
22+const PLACEHOLDER_GALAXY = '~pel';
2223const PLACEHOLDER_STAR = '~sampel';
2324const PLACEHOLDER_PLANET = '~sampel-ponnym';
2425const PLACEHOLDER_HD_PATH = DEFAULT_HD_PATH;
@@ -123,7 +124,13 @@ export function PointInput({ name, size = 4, ...rest }) {
123124 type="text"
124125 label="Urbit ID"
125126 name={name}
126− placeholder={size === 4 ? PLACEHOLDER_PLANET : PLACEHOLDER_STAR}
127+ placeholder={
128+ size === 1
129+ ? PLACEHOLDER_GALAXY
130+ : size === 2
131+ ? PLACEHOLDER_STAR
132+ : PLACEHOLDER_PLANET
133+ }
127134 autoCapitalize="none"
128135 autoComplete="off"
129136 autoCorrect="off"
src/lib/getSuggestedGasPrice.js+1−1
@@ -5,7 +5,7 @@ import { formatWait } from 'components/L2/Dropdowns/FeeDropdown';
55// ethgasstation returns values in floating point, one order of magitude
66// more than gwei. see: https://docs.ethgasstation.info
77// we don't want to charge users more than the gas tank funds
8−const minGas = gas => Math.min(Math.ceil(gas / 10), MAX_GAS_PRICE_GWEI);
8+const minGas = gas => Math.min(Math.ceil(gas), MAX_GAS_PRICE_GWEI);
99
1010export const defaultGasValues = value => ({
1111 fast: {
src/lib/proxy.js+2−2
@@ -40,9 +40,9 @@ export const proxyTypeToL1TxnType = proxyType => {
4040export const proxyTypeToHumanDescription = proxyType => {
4141 switch (proxyType) {
4242 case PROXY_TYPE.MANAGEMENT:
43− return 'Your management key can configure networking settings (network keys and sponsorship)';
43+ return 'Your management key can configure networking settings (network keys and sponsorship).';
4444 case PROXY_TYPE.SPAWN:
45− return 'Your spawn key can spawn points.';
45+ return 'Your spawn key can spawn points on your behalf.';
4646 case PROXY_TYPE.TRANSFER:
4747 return 'Your transfer key can transfer this point.';
4848 case PROXY_TYPE.VOTING:
src/views/AcceptTransfer.tsx+1−1
@@ -115,7 +115,7 @@ export default function AcceptTransfer() {
115115 inset
116116 className="cancel-transfer"
117117 hideBack
118− header={<L2BackHeader hideBalance back={goBack} />}>
118+ header={<L2BackHeader hideBalance={point.isL2} back={goBack} />}>
119119 <Window>
120120 <HeaderPane>
121121 <Row className="header-row">
src/views/Invite/Cohort.tsx+2−2
@@ -372,7 +372,7 @@ export default function InviteCohort() {
372372 <Box className="mb6" lineHeight="1.4em">
373373 Note: you will have to sign <strong>4</strong> transactions
374374 per invite, for a total of <strong>{4 * numInvites}</strong>{' '}
375− signatures
375+ signatures.
376376 </Box>
377377 )}
378378 </Box>
@@ -429,7 +429,7 @@ export default function InviteCohort() {
429429 inset
430430 className="cohort"
431431 hideBack
432− header={<L2BackHeader hideBalance />}>
432+ header={<L2BackHeader hideBalance={point.isL2Spawn} />}>
433433 <Window>
434434 <HeaderPane>
435435 {!hasInvites ? (
src/views/Point/IssueChild.tsx+1−1
@@ -227,7 +227,7 @@ export default function IssueChild() {
227227 hideBack
228228 inset
229229 className="issue-child"
230− header={<L2BackHeader hideBalance={false} back={pop} />}>
230+ header={<L2BackHeader hideBalance={point.isL2Spawn} back={pop} />}>
231231 <Window className="id-issue-child">
232232 <HeaderPane>
233233 <Row>
src/views/Point/MigrateL2.tsx+1−1
@@ -281,7 +281,7 @@ export default function MigrateL2() {
281281 className="bold"
282282 target="_blank"
283283 rel="noreferrer"
284− href="https://urbit-org-9l0a6849p-urbit.vercel.app/docs/azimuth/l2/layer2">
284+ href="https://urbit.org/docs/azimuth/l2/layer2">
285285 Learn More
286286 </a>
287287 </Box>
src/views/Point/UrbitOS.js+1−1
@@ -10,7 +10,7 @@ import L2BackHeader from 'components/L2/Headers/L2BackHeader';
1010
1111import UrbitOSHome from '../UrbitOS/Home';
1212import UrbitOSNetworkKeys from '../UrbitOS/NetworkKeys.tsx';
13−import UrbitOSChangeSponsor from '../UrbitOS/ChangeSponsor';
13+import UrbitOSChangeSponsor from '../UrbitOS/ChangeSponsor.tsx';
1414
1515const NAMES = {
1616 HOME: 'HOME',
src/views/UrbitID/Home.tsx+18−24
@@ -6,7 +6,7 @@ import { Box, Button, Icon, Row } from '@tlon/indigo-react';
66import { useLocalRouter } from 'lib/LocalRouter';
77import { PROXY_TYPE } from 'lib/proxy';
88import { convertToInt } from 'lib/convertToInt';
9−import { ETH_ZERO_ADDR, MASTER_TICKET_TOOLTIP } from 'lib/constants';
9+import { DUMMY_L2_ADDRESS, ETH_ZERO_ADDR, MASTER_TICKET_TOOLTIP } from 'lib/constants';
1010import { abbreviateAddress } from 'lib/utils/address';
1111import { downloadWallet } from 'lib/invite';
1212import useKeyfileGenerator from 'lib/useKeyfileGenerator';
@@ -63,7 +63,8 @@ export default function UrbitIDHome() {
6363 const goTransfer = useCallback(() => push(names.TRANSFER), [names, push]);
6464
6565 const noManagement = point.managementProxy === ETH_ZERO_ADDR;
66− const noSpawn = point.spawnProxy === ETH_ZERO_ADDR;
66+ const noSpawn =
67+ point.spawnProxy === ETH_ZERO_ADDR || point.spawnProxy === DUMMY_L2_ADDRESS;
6768
6869 return (
6970 <Window className="id-home">
@@ -131,30 +132,23 @@ export default function UrbitIDHome() {
131132 <Box>
132133 <Box>Spawn Proxy Address</Box>
133134 <div className="mt1 mono black subtitle">
134− {noSpawn
135− ? point.isL2Spawn
136− ? 'Layer 2'
137− : 'Unset'
138− : abbreviateAddress(point.spawnProxy)}
135+ {noSpawn ? 'Unset' : abbreviateAddress(point.spawnProxy)}
139136 </div>
140137 </Box>
141− {point.isL2Spawn ? (
142− <LayerIndicator size="lg" layer={2} />
143− ) : (
144− <Row>
145− <Button
146− className="secondary"
147− onClick={() => goSetProxy(PROXY_TYPE.SPAWN)}>
148− {noSpawn ? 'Set' : 'Change'}
149− </Button>
150− {!noSpawn && (
151− <CopiableWithTooltip
152− text={point.spawnProxy}
153− className="copy-button"
154− />
155− )}
156− </Row>
157− )}
138+ <Row>
139+ {point.isL2Spawn && <LayerIndicator size="lg" layer={2} />}
140+ <Button
141+ className="secondary"
142+ onClick={() => goSetProxy(PROXY_TYPE.SPAWN)}>
143+ {noSpawn ? 'Set' : 'Change'}
144+ </Button>
145+ {!noSpawn && (
146+ <CopiableWithTooltip
147+ text={point.spawnProxy}
148+ className="copy-button"
149+ />
150+ )}
151+ </Row>
158152 </Row>
159153 )}
160154
src/views/UrbitID/SetProxy.js+5−3
@@ -38,6 +38,8 @@ import HeaderPane from 'components/L2/Window/HeaderPane';
3838import BodyPane from 'components/L2/Window/BodyPane';
3939import { Row } from '@tlon/indigo-react';
4040
41+import './SetProxy.scss';
42+
4143const getL2ProxyName = proxy =>
4244 proxy === PROXY_TYPE.MANAGEMENT
4345 ? 'manage'
@@ -248,7 +250,7 @@ export default function SetProxy() {
248250 }, [completed, properProxyType]);
249251
250252 return (
251− <Window>
253+ <Window className="set-proxy">
252254 <HeaderPane>
253255 <Row className="header-row">
254256 <h5>{header}</h5>
@@ -258,13 +260,13 @@ export default function SetProxy() {
258260 <Grid className="w-full">
259261 {!completed && (
260262 <>
261− <Grid.Item full as={Text} className="mb4 f5 gray4">
263+ <Grid.Item full as={Text} className="mb4 f5">
262264 {proxyTypeToHumanDescription(data.proxyType)}
263265 </Grid.Item>
264266 <Grid.Item
265267 full
266268 as={Text}
267− className={cn('f6', {
269+ className={cn('f5', {
268270 green3: completed,
269271 })}>
270272 Current
src/views/UrbitID/SetProxy.scss+2−50
@@ -1,57 +1,9 @@
11@import 'style/shared/variables.scss';
22
3−.cohort {
4− font-size: 14px;
5−
6− .number-emphasis {
7− background-color: $light-gray;
8− border-radius: $small-border-radius;
9− margin: 0 4px;
10− }
11−
3+.set-proxy.window {
124 .body-pane {
13− min-height: 212px;
14− justify-content: space-between;
15− font-size: 14px;
16−
17− &.center {
18− justify-content: center;
19− }
20−
21− .content {
22− width: 100%;
5+ .f5 {
236 font-size: 14px;
24− line-height: 24px;
25−
26− &.center {
27− text-align: center;
28− margin-top: 20px;
29− width: 320px;
30− margin: auto;
31− }
32−
337 }
34−
35−
36− }
37−
38−.set-proxy {
39− border-radius: $medium-border-radius;
40− width: 100%;
41− height: 32px;
42− font-size: 14px;
43− background-color: black;
44− color: white;
45− font-family: 'Inter', -apple-system, BlinkMacSystemFont, Roboto, Helvetica,
46− Arial, sans-serif, 'Apple Color Emoji';
47− border: none;
48− margin-top: 8px;
49− padding: 8px;
50−
51− &.loading {
52− background-color: $dark-gray;
538 }
549}
55−
56−
57−}
src/views/UrbitID/UrbitID.scss+4
@@ -13,5 +13,9 @@
1313 }
1414 }
1515 }
16+
17+ .layer-indicator {
18+ margin-right: 0px;
19+ }
1620 }
1721}
src/views/UrbitOS/ChangeSponsor.js → src/views/UrbitOS/ChangeSponsor.tsxrenamed+30−27
@@ -29,39 +29,39 @@ import HeaderPane from 'components/L2/Window/HeaderPane';
2929import BodyPane from 'components/L2/Window/BodyPane';
3030
3131function useChangeSponsor() {
32− const { contracts } = useNetwork();
33− const { pointCursor } = usePointCursor();
34− const { syncExtras } = usePointCache();
32+ const { contracts }: any = useNetwork();
33+ const { pointCursor }: any = usePointCursor();
34+ const { syncExtras }: any = usePointCache();
3535
3636 const _contracts = need.contracts(contracts);
3737 const point = need.point(pointCursor);
3838
3939 return useEthereumTransaction(
40− useCallback(sponsor => ecliptic.escape(_contracts, point, sponsor), [
41− point,
42− _contracts,
43− ]),
40+ useCallback(
41+ (sponsor: number) => ecliptic.escape(_contracts, point, sponsor),
42+ [point, _contracts]
43+ ),
4444 useCallback(() => {
4545 syncExtras(point);
4646 }, [syncExtras, point])
4747 );
4848}
4949
50−function ChangeSponsor({ onDone }) {
51− const { contracts } = useNetwork();
52− const { pop } = useHistory();
50+function ChangeSponsor({ onDone }: { onDone: Function }) {
51+ const { contracts }: any = useNetwork();
52+ const { pop }: any = useHistory();
5353 const { changeSponsor, checkForUpdates } = useRoller();
5454 const { point, setLoading } = useRollerStore();
5555
5656 const _contracts = need.contracts(contracts);
5757 const { construct, unconstruct, inputsLocked, bind } = useChangeSponsor();
5858
59− const [newSponsor, setNewSponsor] = useState();
59+ const [newSponsor, setNewSponsor] = useState<number | undefined>();
6060
6161 const requestNewSponsor = useCallback(async () => {
6262 if (newSponsor !== undefined) {
6363 setLoading(true);
64− await changeSponsor(newSponsor);
64+ await changeSponsor(newSponsor!);
6565 checkForUpdates({
6666 point: point.value,
6767 message: `${point.patp} has requested ${ob.patp(
@@ -123,6 +123,8 @@ function ChangeSponsor({ onDone }) {
123123
124124 const buttonText = 'Request New Sponsor';
125125
126+ const size = point.isStar ? 1 : 2;
127+
126128 return (
127129 <Window>
128130 <HeaderPane>
@@ -141,7 +143,7 @@ function ChangeSponsor({ onDone }) {
141143 disabled={inputsLocked}
142144 label="New sponsor"
143145 className="mv4"
144− size={2}
146+ size={size}
145147 />
146148 <Grid.Item full as={FormError} />
147149 {point.isL2 ? (
@@ -171,9 +173,9 @@ function ChangeSponsor({ onDone }) {
171173}
172174
173175function useCancelEscape() {
174− const { contracts } = useNetwork();
175− const { pointCursor } = usePointCursor();
176− const { syncExtras } = usePointCache();
176+ const { contracts }: any = useNetwork();
177+ const { pointCursor }: any = usePointCursor();
178+ const { syncExtras }: any = usePointCache();
177179
178180 const _contracts = need.contracts(contracts);
179181 const point = need.point(pointCursor);
@@ -187,11 +189,11 @@ function useCancelEscape() {
187189 );
188190}
189191
190−function CurrentEscape({ onDone }) {
192+function CurrentEscape({ onDone }: { onDone: Function }) {
191193 const { construct, bind } = useCancelEscape();
192194 const { point } = useRollerStore();
193195
194− const { pop } = useHistory();
196+ const { pop }: any = useHistory();
195197 const { cancelEscape, checkForUpdates } = useRoller();
196198 const {
197199 point: { isL2 },
@@ -205,14 +207,15 @@ function CurrentEscape({ onDone }) {
205207 }, [construct]);
206208
207209 const cancelRequest = useCallback(async () => {
208− if (newSponsor !== undefined) {
209− setLoading(true);
210− await cancelEscape(newSponsor);
211− checkForUpdates(point.value, `${point.patp}'s sponsor change cancelled`);
212− setLoading(false);
213− pop();
214− }
215− }, [point, newSponsor, cancelEscape, setLoading, checkForUpdates, pop]);
210+ setLoading(true);
211+ await cancelEscape();
212+ checkForUpdates({
213+ point: point.value,
214+ message: `${point.patp}'s sponsor change cancelled`,
215+ });
216+ setLoading(false);
217+ pop();
218+ }, [point, cancelEscape, setLoading, checkForUpdates, pop]);
216219
217220 const buttonText = 'Cancel Request';
218221
@@ -253,7 +256,7 @@ function CurrentEscape({ onDone }) {
253256}
254257
255258export default function UrbitOSChangeSponsor() {
256− const { pop } = useHistory();
259+ const { pop }: any = useHistory();
257260 const { point } = useRollerStore();
258261
259262 const [requested, setRequested] = useState(point.escapeRequested);