on master help sign in
Switch to ticket-patp for expired planets, add desig to lib
75770daPatrick O'Sullivan
src/lib/expiredPlanetsByStar.jsondeleted−27
@@ -1,27 +0,0 @@
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/expiredPlanetsWithInviteCodes.jsonnew file+13
@@ -0,0 +1,13 @@
1+{
2+ "rostug-dilsed-passyt-wandys-tambur-raptep": true,
3+ "davmun-watdus-bonwep-pasryc-hadres-rapsub": true,
4+ "sogtec-nomnyt-bactem-sarpes-tapbec-sapnut": true,
5+ "lacsyl-lonwer-paclep-binpen-sabtyr-datdel": true,
6+ "lomhep-roptux-pagtus-fogsed-pittyv-rivmeb": true,
7+ "racdys-botmyl-digmer-molryc-nopdyr-noslec": true,
8+ "lachus-bartep-navsum-rinten-podtug-davtyl": true,
9+ "rapdur-ponteg-nopweg-pardyt-hocdec-hosdev": true,
10+ "ponryc-firfur-livdyn-boslyt-taswyn-montex": true,
11+ "hilpet-tabryc-novnet-nilmur-rosrus-tollyr": true,
12+ "bidfyr-satlyn-pictec-walsug-picrys-tardet": true
13+}
src/lib/lib.js+4
@@ -70,6 +70,9 @@ const randomPatq = len => {
70const patpStringLength = byteLength =>
70const patpStringLength = byteLength =>
71 byteLength * 3 + Math.ceil(byteLength / 2);
71 byteLength * 3 + Math.ceil(byteLength / 2);
72
72
73+const deSiggedString = siggedString =>
74+ siggedString.startsWith('~') ? siggedString.slice(1) : siggedString;
75+
73export {
76export {
74 safeFromWei,
77 safeFromWei,
75 safeToWei,
78 safeToWei,
@@ -84,4 +87,5 @@ export {
84 isValidGalaxy,
87 isValidGalaxy,
85 randomPatq,
88 randomPatq,
86 patpStringLength,
89 patpStringLength,
90+ deSiggedString,
87};
91};
src/lib/useCheckExpired.ts+15−13
@@ -1,21 +1,23 @@
1−import expiredPlanetsByStar from './expiredPlanetsByStar.json';
1+import expiredPlanetsWithInviteCodes from './expiredPlanetsWithInviteCodes.json';
2+import { deSiggedString } from './lib';
2
3
3−export default function useIsExpired(patp: string | null) {
4+export default function useIsExpired(
5+ patp: string | null,
6+ ticket: string | null
7+) {
4 let isExpired = false;
8 let isExpired = false;
5− let expiredPatps: string[] = [];
6
9
7− for (const [_, value] of Object.entries(expiredPlanetsByStar)) {
10+ if (patp !== null && ticket !== null) {
8− const { planets } = value;
11+ const ticketPatp = deSiggedString(ticket)?.concat(
12+ '-',
13+ deSiggedString(patp)
14+ );
9
15
10− planets.forEach(planet => expiredPatps.push(planet.patp));
16+ const expired = Object.keys(expiredPlanetsWithInviteCodes).includes(
11− }
17+ ticketPatp
12−
18+ );
13− function patpInExpiredList(patp: string): boolean {
14− return expiredPatps.includes(patp);
15− }
16
19
17− if (patp !== null) {
20+ isExpired = expired;
18− isExpired = patpInExpiredList(patp);
19 }
21 }
20
22
21 return {
23 return {