on master help sign in
bridge: handle activation links for expired planets
154ca10Patrick O'Sullivan
src/lib/expiredPlanetsByStar.jsonnew file+27
@@ -0,0 +1,27 @@
1+{
2+ "~tomwet": {
3+ "ownership": "0x7915e2909455658cc868af49a4cd77f926320e68",
4+ "planets": [
5+ {
6+ "patp": "~podtug-davtyl",
7+ "oldTicket": "~lachus-bartep-navsum-rinten"
8+ },
9+ {
10+ "patp": "~hocdec-hosdev",
11+ "oldTicket": "~rapdur-ponteg-nopweg-pardyt"
12+ },
13+ {
14+ "patp": "~taswyn-montex",
15+ "oldTicket": "~ponryc-firfur-livdyn-boslyt"
16+ },
17+ {
18+ "patp": "~rosrus-tollyr",
19+ "oldTicket": "~hilpet-tabryc-novnet-nilmur"
20+ },
21+ {
22+ "patp": "~picrys-tardet",
23+ "oldTicket": "~bidfyr-satlyn-pictec-walsug"
24+ }
25+ ]
26+ }
27+}
src/lib/useCheckExpired.tsnew file+24
@@ -0,0 +1,24 @@
1+import expiredPlanetsByStar from './expiredPlanetsByStar.json';
2+
3+export default function useIsExpired(patp: string | null) {
4+ let isExpired = false;
5+ let expiredPatps: string[] = [];
6+
7+ for (const [_, value] of Object.entries(expiredPlanetsByStar)) {
8+ const { planets } = value;
9+
10+ planets.forEach(planet => expiredPatps.push(planet.patp));
11+ }
12+
13+ function patpInExpiredList(patp: string): boolean {
14+ return expiredPatps.includes(patp);
15+ }
16+
17+ if (patp !== null) {
18+ isExpired = patpInExpiredList(patp);
19+ }
20+
21+ return {
22+ isExpired,
23+ };
24+}
src/views/Activate/ActivateCode.tsx+58−50
@@ -2,10 +2,12 @@ import { useCallback, useMemo } from 'react';
2
2
3import View from 'components/View';
3import View from 'components/View';
4import ActivateView from './ActivateView';
4import ActivateView from './ActivateView';
5+import CodeExpired from './CodeExpired';
5
6
6import { useLocalRouter } from 'lib/LocalRouter';
7import { useLocalRouter } from 'lib/LocalRouter';
7import useImpliedTicket from 'lib/useImpliedTicket';
8import useImpliedTicket from 'lib/useImpliedTicket';
8import useHasDisclaimed from 'lib/useHasDisclaimed';
9import useHasDisclaimed from 'lib/useHasDisclaimed';
10+import useIsExpired from 'lib/useCheckExpired';
9
11
10import { ReactComponent as PlaceholderSigil } from 'assets/blank-planet-sigil.svg';
12import { ReactComponent as PlaceholderSigil } from 'assets/blank-planet-sigil.svg';
11import { FadeablePointPresenter as PointPresenter } from './PointPresenter';
13import { FadeablePointPresenter as PointPresenter } from './PointPresenter';
@@ -35,58 +37,64 @@ export default function ActivateCode() {
35 [impliedTicket, impliedPatp]
37 [impliedTicket, impliedPatp]
36 );
38 );
37
39
40+ const { isExpired } = useIsExpired(impliedPatp);
41+
38 return (
42 return (
39 <View inset hideBack>
43 <View inset hideBack>
40− <ActivateView
44+ {isExpired ? (
45+ <CodeExpired />
46+ ) : (
47+ <ActivateView
41− hideBack={hasInitialValues}
48+ hideBack={hasInitialValues}
42− header={
49+ header={
43− <ActivateHeader
50+ <ActivateHeader
44− content={
51+ content={
45− hasInitialValues
52+ hasInitialValues
46− ? 'Welcome. This is your Urbit ID.'
53+ ? 'Welcome. This is your Urbit ID.'
47− : 'Activate a Planet'
54+ : 'Activate a Planet'
48− }
55+ }
49− />
56+ />
50− }
57+ }
51− footer={<ActivateCodeForm afterSubmit={goToMasterKey} />}>
58+ footer={<ActivateCodeForm afterSubmit={goToMasterKey} />}>
52− <Box className="flex-col align-center justify-center w-full h-full">
59+ <Box className="flex-col align-center justify-center w-full h-full">
53− {hasInitialValues ? (
60+ {hasInitialValues ? (
54− <Box>
61+ <Box>
55− <p
62+ <p
56− className="mb2 sans gray5"
63+ className="mb2 sans gray5"
57− style={{
64+ style={{
58− fontSize: 14,
65+ fontSize: 14,
59− textAlign: 'center',
66+ textAlign: 'center',
60− maxWidth: '38ch',
67+ maxWidth: '38ch',
61− marginLeft: 'auto',
68+ marginLeft: 'auto',
62− }}>
69+ }}>
63− An Urbit ID is your unique identity that you use to communicate
70+ An Urbit ID is your unique identity that you use to
64− on Urbit. You own it forever.
71+ communicate on Urbit. You own it forever.
65− </p>
72+ </p>
66− <p
73+ <p
67− className="mb2 sans gray5"
74+ className="mb2 sans gray5"
68− style={{
75+ style={{
69− fontSize: 14,
76+ fontSize: 14,
70− textAlign: 'center',
77+ textAlign: 'center',
71− maxWidth: '38ch',
78+ maxWidth: '38ch',
72− marginLeft: 'auto',
79+ marginLeft: 'auto',
73− }}>
80+ }}>
74− To activate your Urbit ID, begin by claiming it via the link
81+ To activate your Urbit ID, begin by claiming it via the link
75− below.
82+ below.
76− </p>
83+ </p>
77− </Box>
84+ </Box>
78− ) : (
85+ ) : (
79− <Box className="mb2 sans gray5" fontSize={14}>
86+ <Box className="mb2 sans gray5" fontSize={14}>
80− Enter your planet activation code below.
87+ Enter your planet activation code below.
81− </Box>
88+ </Box>
82− )}
89+ )}
83− {impliedPatp ? (
90+ {impliedPatp ? (
84− <PointPresenter patp={impliedPatp} className="mb6 mt7" />
91+ <PointPresenter patp={impliedPatp} className="mb6 mt7" />
85− ) : (
92+ ) : (
86− <PlaceholderSigil className="mv9" style={{ marginTop: 78 }} />
93+ <PlaceholderSigil className="mv9" style={{ marginTop: 78 }} />
87− )}
94+ )}
88− </Box>
95+ </Box>
89− </ActivateView>
96+ </ActivateView>
97+ )}
90 </View>
98 </View>
91 );
99 );
92}
100}
src/views/Activate/CodeExpired.scssnew file+3
@@ -0,0 +1,3 @@
1+.expired-view {
2+ min-height: 200px;
3+}
src/views/Activate/CodeExpired.tsxnew file+49
@@ -0,0 +1,49 @@
1+import View from 'components/View';
2+
3+import { Box, Button } from '@tlon/indigo-react';
4+import { FadeableActivateHeader as ActivateHeader } from './ActivateHeader';
5+import useFadeIn from './useFadeIn';
6+import Window from 'components/L2/Window/Window';
7+
8+import './CodeExpired.scss';
9+
10+export default function CodeExpired() {
11+ // Fade in on load
12+ useFadeIn();
13+
14+ return (
15+ <Window className="expired-view mt10">
16+ <Box className="w-full">
17+ <ActivateHeader content="This invite link has expired." />
18+ </Box>
19+ <Box className="flex-col align-center justify-center w-full h-full">
20+ <Box>
21+ <p
22+ className="mb2 sans gray5"
23+ style={{
24+ fontSize: 14,
25+ textAlign: 'center',
26+ maxWidth: '38ch',
27+ marginLeft: 'auto',
28+ }}>
29+ Please contact the entity you received it from.
30+ </p>
31+ </Box>
32+ <a className="flex-col m4 w-full" href="https://urbit.org/">
33+ <Button
34+ className="m2"
35+ backgroundColor={'black'}
36+ color={'white'}
37+ padding={'16px'}
38+ fontFamily="Inter"
39+ height={'40px'}
40+ fontWeight={'400'}
41+ fontSize={'14px'}
42+ borderRadius={'4px'}>
43+ Learn more
44+ </Button>
45+ </a>
46+ </Box>
47+ </Window>
48+ );
49+}
tool-versionsnew file+1
@@ -0,0 +1 @@
1+nodejs 14.17.0