on main help sign in
add azimuth data to ship view
fa02716John Hyde
.gitignore+1
@@ -1,2 +1,3 @@
1# OS X
1# OS X
2.DS_Store
2.DS_Store
3+extras
.vscode/settings.jsonnew file+52
@@ -0,0 +1,52 @@
1+{
2+ "saveEditorLayout.list": [
3+ {
4+ "name": "gall agent",
5+ "orientation": 0,
6+ "documents": [
7+ {
8+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/desk/sur/astrolabe.hoon",
9+ "column": 1
10+ },
11+ {
12+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/desk/app/astrolabe.hoon",
13+ "column": 1
14+ },
15+ {
16+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/extras/scraps/json-lib.hoon",
17+ "column": 2
18+ },
19+ {
20+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/base-desk/lib/naive.hoon",
21+ "column": 3
22+ },
23+ {
24+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/extras/scraps/scry thoughts.txt",
25+ "column": 3
26+ },
27+ {
28+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/desk/mar/astrolabe/point.hoon",
29+ "column": 4
30+ },
31+ {
32+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/install.sh",
33+ "column": 5
34+ },
35+ {
36+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/desk/lib/astrolabe.hoon",
37+ "column": 5
38+ }
39+ ]
40+ },
41+ {
42+ "name": "ui",
43+ "orientation": 0,
44+ "documents": [
45+ {
46+ "fsPath": "/Users/john/ws/urbit-apps/astrolabe/ui/src/components/ShipView.svelte",
47+ "column": 1
48+ }
49+ ]
50+ }
51+ ]
52+}
base-desk/lib/naive.hoonnew file+926
@@ -0,0 +1,926 @@
1+/+ tiny
2+!.
3+=> => tiny
4+:: Laconic bit
5+::
6+=| lac=?
7+:: Constants
8+::
9+|%
10+:: Transfers on L1 to this address count as depositing to L2
11+::
12+++ deposit-address 0x1111.1111.1111.1111.1111.1111.1111.1111.1111.1111
13+++ log-names
14+ |%
15+ :: Generated with (keccak-256:keccak:crypto (as-octs:mimes:html name))
16+ ::
17+ :: OwnerChanged(uint32,address)
18+ ++ owner-changed
19+ 0x16d0.f539.d49c.6cad.822b.767a.9445.bfb1.
20+ cf7e.a6f2.a6c2.b120.a7ea.4cc7.660d.8fda
21+ ::
22+ :: Activated(uint32)
23+ ++ activated
24+ 0xe74c.0380.9d07.69e1.b1f7.06cc.8414.258c.
25+ d1f3.b6fe.020c.d15d.0165.c210.ba50.3a0f
26+ ::
27+ :: Spawned(uint32,uint32)
28+ ++ spawned
29+ 0xb2d3.a6e7.a339.f5c8.ff96.265e.2f03.a010.
30+ a854.1070.f374.4a24.7090.9644.1508.1546
31+ ::
32+ :: OwnershipTransferred(address,address)
33+ ++ ownership-transferred
34+ 0x8be0.079c.5316.5914.1344.cd1f.d0a4.f284.
35+ 1949.7f97.22a3.daaf.e3b4.186f.6b64.57e0
36+ ::
37+ :: EscapeRequested(uint32,uint32)
38+ ++ escape-requested
39+ 0xb4d4.850b.8f21.8218.141c.5665.cba3.79e5.
40+ 3e9b.b015.b51e.8d93.4be7.0210.aead.874a
41+ ::
42+ :: EscapeCanceled(uint32,uint32)
43+ ++ escape-canceled
44+ 0xd653.bb0e.0bb7.ce83.93e6.24d9.8fbf.17cd.
45+ a590.2c83.28ed.0cd0.9988.f368.90d9.932a
46+ ::
47+ :: EscapeAccepted(uint32,uint32)
48+ ++ escape-accepted
49+ 0x7e44.7c9b.1bda.4b17.4b07.96e1.00bf.7f34.
50+ ebf3.6dbb.7fe6.6549.0b1b.fce6.246a.9da5
51+ ::
52+ :: LostSponsor(uint32,uint32)
53+ ++ lost-sponsor
54+ 0xd770.4f9a.2519.3dbd.0b0c.b4a8.09fe.ffff.
55+ a7f1.9d1a.ae88.17a7.1346.c194.4482.10d5
56+ ::
57+ :: ChangedKeys(uint32,bytes32,bytes32,uint32,uint32)
58+ ++ changed-keys
59+ 0xaa10.e7a0.117d.4323.f1d9.9d63.0ec1.69be.
60+ bb3a.988e.8957.70e3.5198.7e01.ff54.23d5
61+ ::
62+ :: BrokeContinuity(uint32,uint32)
63+ ++ broke-continuity
64+ 0x2929.4799.f1c2.1a37.ef83.8e15.f79d.d91b.
65+ cee2.df99.d63c.d1c1.8ac9.68b1.2951.4e6e
66+ ::
67+ :: ChangedSpawnProxy(uint32,address)
68+ ++ changed-spawn-proxy
69+ 0x9027.36af.7b3c.efe1.0d9e.840a.ed0d.687e.
70+ 35c8.4095.122b.2505.1a20.ead8.866f.006d
71+ ::
72+ :: ChangedTransferProxy(uint32,address)
73+ ++ changed-transfer-proxy
74+ 0xcfe3.69b7.197e.7f0c.f067.93ae.2472.a9b1.
75+ 3583.fecb.ed2f.78df.a14d.1f10.796b.847c
76+ ::
77+ :: ChangedManagementProxy(uint32,address)
78+ ++ changed-management-proxy
79+ 0xab9c.9327.cffd.2acc.168f.afed.be06.139f.
80+ 5f55.cb84.c761.df05.e051.1c25.1e2e.e9bf
81+ ::
82+ :: ChangedVotingProxy(uint32,address)
83+ ++ changed-voting-proxy
84+ 0xcbd6.269e.c714.57f2.c7b1.a227.74f2.46f6.
85+ c5a2.eae3.795e.d730.0db5.1768.0c61.c805
86+ ::
87+ :: ChangedDns(string,string,string)
88+ ++ changed-dns
89+ 0xfafd.04ad.e1da.ae2e.1fdb.0fc1.cc6a.899f.
90+ d424.063e.d5c9.2120.e67e.0730.53b9.4898
91+ ::
92+ :: ApprovalForAll(address,address,bool)
93+ ++ approval-for-all
94+ 0x1730.7eab.39ab.6107.e889.9845.ad3d.59bd.
95+ 9653.f200.f220.9204.89ca.2b59.3769.6c31
96+ --
97+-- =>
98+:: Types
99+|%
100+:: ethereum address, 20 bytes.
101+::
102++$ address @ux
103++$ nonce @ud
104++$ dominion ?(%l1 %l2 %spawn)
105++$ keys [=life suite=@ud auth=@ crypt=@]
106+++ orm ((on ship point) por)
107+++ point
108+ $: :: domain
109+ ::
110+ =dominion
111+ ::
112+ :: ownership
113+ ::
114+ $= own
115+ $: owner=[=address =nonce]
116+ spawn-proxy=[=address =nonce]
117+ management-proxy=[=address =nonce]
118+ voting-proxy=[=address =nonce]
119+ transfer-proxy=[=address =nonce]
120+ ==
121+ ::
122+ :: networking
123+ ::
124+ $= net
125+ $: rift=@ud
126+ =keys
127+ sponsor=[has=? who=@p]
128+ escape=(unit @p)
129+ ==
130+ ==
131+::
132+++ diff
133+ $% [%nonce =ship =proxy =nonce]
134+ [%tx =raw-tx err=(unit @tas)]
135+ [%operator owner=address operator=address approved=?]
136+ [%dns domains=(list @t)]
137+ $: %point =ship
138+ $% [%rift =rift]
139+ [%keys =keys]
140+ [%sponsor sponsor=(unit @p)]
141+ [%escape to=(unit @p)]
142+ [%owner =address]
143+ [%spawn-proxy =address]
144+ [%management-proxy =address]
145+ [%voting-proxy =address]
146+ [%transfer-proxy =address]
147+ [%dominion =dominion]
148+ == == ==
149+::
150++$ state
151+ $: %0
152+ =points
153+ =operators
154+ dns=(list @t)
155+ ==
156++$ points (tree [ship point])
157++$ operators (jug address address)
158++$ effects (list diff)
159++$ proxy ?(%own %spawn %manage %vote %transfer)
160++$ roll (list raw-tx)
161++$ raw-tx [sig=@ raw=octs =tx]
162++$ tx [from=[=ship =proxy] skim-tx]
163++$ skim-tx
164+ $% [%transfer-point =address reset=?]
165+ [%spawn =ship =address]
166+ [%configure-keys encrypt=@ auth=@ crypto-suite=@ breach=?]
167+ [%escape parent=ship]
168+ [%cancel-escape parent=ship]
169+ [%adopt =ship]
170+ [%reject =ship]
171+ [%detach =ship]
172+ [%set-management-proxy =address]
173+ [%set-spawn-proxy =address]
174+ [%set-transfer-proxy =address]
175+ ==
176+::
177++$ event-log
178+ $: address=@ux
179+ data=@ux
180+ topics=(lest @ux)
181+ ==
182++$ input
183+ $: block=@ud
184+ $% [%bat batch=@]
185+ [%log =event-log]
186+ == ==
187+:: ECDSA verifier.
188+::
189+:: Must keccak `dat` and recover the ethereum address which signed.
190+:: Must not crash. `v` will normally be between 0 and 3; if it is not,
191+:: should produce null.
192+::
193++$ verifier $-([dat=octs v=@ r=@ s=@] (unit address))
194+-- =>
195+::
196+|%
197+++ debug
198+ |* [meg=@t *]
199+ ?: lac
200+ +<+
201+ ~> %slog.[0 meg]
202+ +<+
203+::
204+++ parse-roll
205+ |= batch=@
206+ =| =roll
207+ =| pos=@ud
208+ =/ las (met 0 batch)
209+ |- ^+ roll
210+ ?: (gte pos las)
211+ (flop roll)
212+ =/ parse-result (parse-raw-tx pos batch)
213+ :: Parsing failed, abort batch
214+ ::
215+ ?~ parse-result
216+ (debug %parse-failed ~)
217+ =^ =raw-tx pos u.parse-result
218+ $(roll [raw-tx roll])
219+::
220+++ parse-raw-tx
221+ |= [pos=@ud batch=@]
222+ ^- (unit [raw-tx pos=@ud])
223+ |^
224+ =^ sig pos (take 3 65)
225+ =/ res=(unit [=tx pos=@ud]) parse-tx
226+ ?~ res ~
227+ =/ dif (sub pos.u.res pos)
228+ =/ len =>((dvr dif 8) ?>(=(0 q) p))
229+ :- ~ :_ pos.u.res
230+ [sig [len (cut 0 [pos dif] batch)] tx.u.res]
231+ ::
232+ ++ parse-tx
233+ ^- (unit [tx pos=@ud])
234+ =^ from-proxy=@ pos (take 0 3)
235+ ?. ?=(?(%0 %1 %2 %3 %4) from-proxy) (debug %bad-proxy ~)
236+ =/ =proxy
237+ ?- from-proxy
238+ %0 %own
239+ %1 %spawn
240+ %2 %manage
241+ %3 %vote
242+ %4 %transfer
243+ ==
244+ =^ pad pos (take 0 5)
245+ =^ from-ship=ship pos (take 3 4)
246+ =- ?~ res
247+ ~
248+ `[[[from-ship proxy] skim-tx.u.res] pos.u.res]
249+ ^- res=(unit [=skim-tx pos=@ud])
250+ =^ op pos (take 0 7)
251+ ?+ op (debug %strange-opcode ~)
252+ %0
253+ =^ reset=@ pos (take 0)
254+ =^ =address pos (take 3 20)
255+ `[[%transfer-point address =(0 reset)] pos]
256+ ::
257+ %1
258+ =^ pad=@ pos (take 0)
259+ =^ =ship pos (take 3 4)
260+ =^ =address pos (take 3 20)
261+ `[[%spawn ship address] pos]
262+ ::
263+ %2
264+ =^ breach=@ pos (take 0)
265+ =^ encrypt=@ pos (take 3 32)
266+ =^ auth=@ pos (take 3 32)
267+ =^ crypto-suite=@ pos (take 3 4)
268+ `[[%configure-keys encrypt auth crypto-suite =(0 breach)] pos]
269+ ::
270+ %3 =^(res pos take-ship `[[%escape res] pos])
271+ %4 =^(res pos take-ship `[[%cancel-escape res] pos])
272+ %5 =^(res pos take-ship `[[%adopt res] pos])
273+ %6 =^(res pos take-ship `[[%reject res] pos])
274+ %7 =^(res pos take-ship `[[%detach res] pos])
275+ %8 =^(res pos take-address `[[%set-management-proxy res] pos])
276+ %9 =^(res pos take-address `[[%set-spawn-proxy res] pos])
277+ %10 =^(res pos take-address `[[%set-transfer-proxy res] pos])
278+ ==
279+ ::
280+ :: Take a bite
281+ ::
282+ ++ take
283+ |= =bite
284+ ^- [@ @ud]
285+ =/ =step
286+ ?@ bite (bex bite)
287+ (mul step.bite (bex bloq.bite))
288+ [(cut 0 [pos step] batch) (add pos step)]
289+ :: Encode ship and address
290+ ::
291+ ++ take-address
292+ ^- [address @ud]
293+ =^ pad=@ pos (take 0)
294+ =^ =address pos (take 3 20)
295+ [address pos]
296+ :: Encode escape-related txs
297+ ::
298+ ++ take-ship
299+ ^- [ship @ud]
300+ =^ pad=@ pos (take 0)
301+ =^ other=ship pos (take 3 4)
302+ [other pos]
303+ --
304+::
305+++ proxy-from-point
306+ |= [=proxy point]
307+ ^- [=address =nonce]
308+ ?- proxy
309+ %own owner.own
310+ %spawn spawn-proxy.own
311+ %manage management-proxy.own
312+ %vote voting-proxy.own
313+ %transfer transfer-proxy.own
314+ ==
315+::
316+++ verify-sig-and-nonce
317+ |= [=verifier chain-t=@t =state =raw-tx]
318+ ^- ?
319+ |^
320+ =/ point (get-point state ship.from.tx.raw-tx)
321+ ?> ?=(^ point) :: we never parse more than four bytes for a ship
322+ =/ need=[=address =nonce]
323+ (proxy-from-point proxy.from.tx.raw-tx u.point)
324+ :: We include a domain separator to avoid letting signatures be
325+ :: accidentally reused with other applications. We include the name
326+ :: UrbitID, a signature format version number, and the EIP-155 chain
327+ :: ID.
328+ ::
329+ :: We also include a nonce so that a transaction cannot be
330+ :: rebroadcast.
331+ ::
332+ =/ prepared-data=octs
333+ %: cad 3
334+ 14^'UrbitIDV1Chain'
335+ (met 3 chain-t)^chain-t
336+ 1^':'
337+ 4^nonce.need
338+ raw.raw-tx
339+ ~
340+ ==
341+ :: Wallets which support personal_sign include this preamble to avoid
342+ :: letting personal_sign be used to sign ethereum transactions
343+ ::
344+ =/ signed-data=octs
345+ =/ len (ud-to-ascii p.prepared-data)
346+ %: cad 3
347+ 26^'\19Ethereum Signed Message:\0a'
348+ (met 3 len)^len
349+ prepared-data
350+ ~
351+ ==
352+ =/ dress (verify-sig sig.raw-tx signed-data)
353+ ?~ dress
354+ |
355+ =(address.need u.dress)
356+ :: Verify signature and produce signer address
357+ ::
358+ ++ verify-sig
359+ |= [sig=@ txdata=octs]
360+ ^- (unit address)
361+ |^
362+ :: Reversed of the usual r-s-v order because Ethereum integers are
363+ :: big-endian
364+ ::
365+ =^ v sig (take 3)
366+ =^ s sig (take 3 32)
367+ =^ r sig (take 3 32)
368+ :: In Ethereum, v is generally 27 + recid, and verifier expects a
369+ :: recid. Old versions of geth used 0 + recid, so most software
370+ :: now supports either format. See:
371+ ::
372+ :: https://github.com/ethereum/go-ethereum/issues/2053
373+ ::
374+ =? v (gte v 27) (sub v 27)
375+ (verifier txdata v r s)
376+ ::
377+ ++ take
378+ |= =bite
379+ [(end bite sig) (rsh bite sig)]
380+ --
381+ --
382+:: ASCII-decimal encode
383+::
384+++ ud-to-ascii
385+ |= n=@ud
386+ ?~ n '0'
387+ =| l=(list @)
388+ |- ^- @t
389+ ?~ n (rep 3 l)
390+ =+ (dvr n 10)
391+ $(n p, l [(add '0' q) l])
392+::
393+++ ship-rank
394+ |= =ship
395+ ^- ?(%0 %1 %2 %3 %4)
396+ ?: (lth ship 0x100) %0
397+ ?: (lth ship 0x1.0000) %1
398+ ?: (lth ship 0x1.0000.0000) %2
399+ ?: (lth ship 0x1.0000.0000.0000.0000) %3
400+ %4
401+::
402+++ sein :: autoboss
403+ |= who=ship
404+ ^- ship
405+ =/ mir (ship-rank who)
406+ ?- mir
407+ %0 who
408+ %1 (end 3 who)
409+ %2 (end 4 who)
410+ %3 (end 5 who)
411+ %4 (end 4 who)
412+ ==
413+::
414+:: Produces null only if ship is not a galaxy, star, or planet
415+::
416+++ get-point
417+ |= [=state =ship]
418+ ^- (unit point)
419+ =/ existing (get:orm points.state ship)
420+ ?^ existing
421+ `u.existing
422+ =| =point
423+ =. who.sponsor.net.point (sein ship)
424+ ?+ (ship-rank ship) (debug %strange-point ~)
425+ %0 `point(dominion %l1)
426+ ?(%1 %2)
427+ =/ existing-parent $(ship (sein ship))
428+ ?~ existing-parent ~
429+ :- ~
430+ %= point
431+ dominion
432+ ?- dominion.u.existing-parent
433+ %l1 %l1
434+ %l2 %l2
435+ %spawn %l2
436+ ==
437+ ==
438+ ==
439+-- =>
440+|%
441+:: Receive log from L1 transaction
442+::
443+++ receive-log
444+ |= [=state log=event-log]
445+ ^- [effects ^state]
446+ =* log-name i.topics.log
447+ ?: =(log-name activated:log-names) `state
448+ ?: =(log-name spawned:log-names) `state
449+ ?: =(log-name ownership-transferred:log-names) `state
450+ ?: =(log-name changed-dns:log-names)
451+ ?> ?=(~ t.topics.log)
452+ =/ words (rip 8 data.log)
453+ :: This is only true if each domain is <= 32 bytes
454+ ::
455+ ?. ?=([c=@ @ b=@ @ a=@ @ @ @ @ ~] words) `state
456+ =* one &5.words
457+ =* two &3.words
458+ =* tri &1.words
459+ =/ domains ~[(swp 3 one) (swp 3 two) (swp 3 tri)]
460+ :- [%dns domains]~
461+ state(dns domains)
462+ ::
463+ ?: =(log-name approval-for-all:log-names)
464+ ?> ?=([@ @ ~] t.topics.log)
465+ =* owner i.t.topics.log
466+ =* operator i.t.t.topics.log
467+ =/ approved !=(0 data.log)
468+ :- [%operator owner operator approved]~
469+ =- state(operators -)
470+ ?: approved
471+ (~(put ju operators.state) owner operator)
472+ (~(del ju operators.state) owner operator)
473+ ::
474+ :: The rest of the logs modify a particular ship, specified in the
475+ :: second topic. We fetch it, and insert the modification back into
476+ :: our state.
477+ ::
478+ ?> ?=([@ *] t.topics.log)
479+ =* ship=@ i.t.topics.log
480+ =/ the-point (get-point state ship)
481+ ?> ?=(^ the-point)
482+ =* point u.the-point
483+ ::
484+ :: Important to fully no-op on failure so we don't insert an entry
485+ :: into points.state
486+ ::
487+ =- ?~ res
488+ `state
489+ [effects.u.res state(points (put:orm points.state ship new-point.u.res))]
490+ ^- res=(unit [=effects new-point=^point])
491+ ::
492+ ?: =(log-name changed-spawn-proxy:log-names)
493+ ?. ?=(%l1 -.point) ~
494+ ?> ?=([@ ~] t.t.topics.log)
495+ =* to i.t.t.topics.log
496+ :: Depositing to L2 is represented by a spawn proxy change on L1,
497+ :: but it doesn't change the actual spawn proxy.
498+ ::
499+ ?: =(deposit-address to)
500+ :+ ~ [%point ship %dominion %spawn]~
501+ point(dominion %spawn)
502+ :+ ~ [%point ship %spawn-proxy to]~
503+ point(address.spawn-proxy.own to)
504+ ::
505+ ?: =(log-name escape-accepted:log-names)
506+ ?> ?=([@ ~] t.t.topics.log)
507+ =* parent=@ i.t.t.topics.log
508+ =/ parent-point (get-point state parent)
509+ ?> ?=(^ parent-point)
510+ ?: ?=(%l2 -.u.parent-point) ~
511+ :+ ~ [%point ship %sponsor `parent]~
512+ point(escape.net ~, sponsor.net [%& parent])
513+ ::
514+ ?: =(log-name lost-sponsor:log-names)
515+ ?> ?=([@ ~] t.t.topics.log)
516+ =* parent=@ i.t.t.topics.log
517+ :: If the sponsor we lost was not our actual sponsor, we didn't
518+ :: actually lose anything.
519+ ::
520+ ?. =(parent who.sponsor.net.point) ~
521+ ::
522+ =/ parent-point (get-point state parent)
523+ ?> ?=(^ parent-point)
524+ ::
525+ :: We can detach even if the child is on L2, as long as the parent
526+ :: is on L1.
527+ ::
528+ ?: ?=(%l2 -.u.parent-point) ~
529+ :+ ~ [%point ship %sponsor ~]~
530+ point(has.sponsor.net %|)
531+ ::
532+ :: The rest can be done by any ship on L1, even if their spawn proxy
533+ :: is set to L2
534+ ::
535+ ?: ?=(%l2 -.point) ~
536+ ::
537+ ?: =(log-name escape-requested:log-names)
538+ ?> ?=([@ ~] t.t.topics.log)
539+ =* parent=@ i.t.t.topics.log
540+ =/ parent-point (get-point state parent)
541+ ?> ?=(^ parent-point)
542+ :+ ~ [%point ship %escape `parent]~
543+ point(escape.net `parent)
544+ ::
545+ ?: =(log-name escape-canceled:log-names)
546+ ?> ?=([@ ~] t.t.topics.log)
547+ =* parent=@ i.t.t.topics.log
548+ =/ parent-point (get-point state parent)
549+ ?> ?=(^ parent-point)
550+ :+ ~ [%point ship %escape ~]~
551+ point(escape.net ~)
552+ ::
553+ ?: =(log-name broke-continuity:log-names)
554+ ?> ?=(~ t.t.topics.log)
555+ =* rift=@ data.log
556+ :+ ~ [%point ship %rift rift]~
557+ point(rift.net rift)
558+ ::
559+ ?: =(log-name changed-keys:log-names)
560+ ?> ?=(~ t.t.topics.log)
561+ =/ =keys
562+ :* life=(cut 8 [0 1] data.log)
563+ suite=(cut 8 [1 1] data.log)
564+ auth=(cut 8 [2 1] data.log)
565+ crypt=(cut 8 [3 1] data.log)
566+ ==
567+ :+ ~ [%point ship %keys keys]~
568+ point(keys.net keys)
569+ ::
570+ ?: =(log-name owner-changed:log-names)
571+ ?> ?=([@ ~] t.t.topics.log)
572+ =* to i.t.t.topics.log
573+ :: Depositing to L2 is represented by an ownership change on L1,
574+ :: but it doesn't change who actually owns the ship.
575+ ::
576+ ?: =(deposit-address to)
577+ :+ ~ [%point ship %dominion %l2]~
578+ point(dominion %l2)
579+ :+ ~ [%point ship %owner to]~
580+ point(address.owner.own to)
581+ ::
582+ ?: =(log-name changed-transfer-proxy:log-names)
583+ ?> ?=([@ ~] t.t.topics.log)
584+ =* to i.t.t.topics.log
585+ :+ ~ [%point ship %transfer-proxy to]~
586+ point(address.transfer-proxy.own to)
587+ ::
588+ ?: =(log-name changed-management-proxy:log-names)
589+ ?> ?=([@ ~] t.t.topics.log)
590+ =* to i.t.t.topics.log
591+ :+ ~ [%point ship %management-proxy to]~
592+ point(address.management-proxy.own to)
593+ ::
594+ ?: =(log-name changed-voting-proxy:log-names)
595+ ?> ?=([@ ~] t.t.topics.log)
596+ =* to i.t.t.topics.log
597+ :+ ~ [%point ship %voting-proxy to]~
598+ point(address.voting-proxy.own to)
599+ ::
600+ (debug %unknown-log ~)
601+::
602+:: Receive batch of L2 transactions
603+::
604+++ receive-batch
605+ |= [=verifier chain-id=@ud =state batch=@]
606+ =/ chain-t (ud-to-ascii chain-id)
607+ =/ =roll (parse-roll batch)
608+ |- ^- [effects ^state]
609+ ?~ roll
610+ [~ state]
611+ :: Verify signature, else skip tx
612+ ::
613+ ?. (verify-sig-and-nonce verifier chain-t state i.roll)
614+ %+ debug %l2-sig-failed
615+ =^ effects state $(roll t.roll)
616+ :_ state
617+ [[%tx i.roll `%sig-or-nonce-failed] effects]
618+ :: Increment nonce, even if it later fails
619+ ::
620+ =^ effects-1 points.state (increment-nonce state from.tx.i.roll)
621+ :: Process tx
622+ ::
623+ =^ effects-2 state
624+ =/ tx-result=(unit [=effects =^state]) (receive-tx state tx.i.roll)
625+ ?~ tx-result
626+ %+ debug %l2-tx-failed
627+ [[%tx i.roll `%tx-failed]~ state]
628+ [[[%tx i.roll ~] effects.u.tx-result] state.u.tx-result]
629+ =^ effects-3 state $(roll t.roll)
630+ [:(welp effects-1 effects-2 effects-3) state]
631+::
632+++ increment-nonce
633+ |= [=state =ship =proxy]
634+ =/ point (get-point state ship)
635+ ?> ?=(^ point) :: we only parsed 4 bytes
636+ =* own own.u.point
637+ =^ nonce u.point
638+ ?- proxy
639+ %own
640+ :- nonce.owner.own
641+ u.point(nonce.owner.own +(nonce.owner.own))
642+ ::
643+ %spawn
644+ :- nonce.spawn-proxy.own
645+ u.point(nonce.spawn-proxy.own +(nonce.spawn-proxy.own))
646+ ::
647+ %manage
648+ :- nonce.management-proxy.own
649+ u.point(nonce.management-proxy.own +(nonce.management-proxy.own))
650+ ::
651+ %vote
652+ :- nonce.voting-proxy.own
653+ u.point(nonce.voting-proxy.own +(nonce.voting-proxy.own))
654+ ::
655+ %transfer
656+ :- nonce.transfer-proxy.own
657+ u.point(nonce.transfer-proxy.own +(nonce.transfer-proxy.own))
658+ ==
659+ ::
660+ :- [%nonce ship proxy nonce]~
661+ (put:orm points.state ship u.point)
662+::
663+:: Receive an individual L2 transaction
664+::
665+++ receive-tx
666+ |= [=state =tx]
667+ |^
668+ ^- (unit [effects ^state])
669+ ?- +<.tx
670+ %spawn (process-spawn +>.tx)
671+ %transfer-point (w-point process-transfer-point ship.from.tx +>.tx)
672+ %configure-keys (w-point process-configure-keys ship.from.tx +>.tx)
673+ %escape (w-point-esc process-escape ship.from.tx +>.tx)
674+ %cancel-escape (w-point-esc process-cancel-escape ship.from.tx +>.tx)
675+ %adopt (w-point-esc process-adopt ship.tx +>.tx)
676+ %reject (w-point-esc process-reject ship.tx +>.tx)
677+ %detach (w-point-esc process-detach ship.tx +>.tx)
678+ %set-spawn-proxy
679+ (w-point-spawn process-set-spawn-proxy ship.from.tx +>.tx)
680+ ::
681+ %set-transfer-proxy
682+ (w-point process-set-transfer-proxy ship.from.tx +>.tx)
683+ ::
684+ %set-management-proxy
685+ (w-point process-set-management-proxy ship.from.tx +>.tx)
686+ ==
687+ ::
688+ ++ w-point
689+ |* [fun=$-([ship point *] (unit [effects point])) =ship rest=*]
690+ ^- (unit [effects ^state])
691+ =/ point (get-point state ship)
692+ ?~ point (debug %strange-ship ~)
693+ ?. ?=(%l2 -.u.point) (debug %ship-not-on-l2 ~)
694+ :: Important to fully no-op on failure so we don't insert an entry
695+ :: into points.state
696+ ::
697+ =/ res=(unit [=effects new-point=^point]) (fun u.point rest)
698+ ?~ res
699+ ~
700+ `[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
701+ ::
702+ ++ w-point-esc
703+ |* [fun=$-([ship point *] (unit [effects point])) =ship rest=*]
704+ ^- (unit [effects ^state])
705+ =/ point (get-point state ship)
706+ ?~ point (debug %strange-ship ~)
707+ =/ res=(unit [=effects new-point=^point]) (fun u.point rest)
708+ ?~ res
709+ ~
710+ `[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
711+ ::
712+ ++ w-point-spawn
713+ |* [fun=$-([ship point *] (unit [effects point])) =ship rest=*]
714+ ^- (unit [effects ^state])
715+ =/ point (get-point state ship)
716+ ?~ point (debug %strange-ship ~)
717+ ?: ?=(%l1 -.u.point) (debug %ship-on-l2 ~)
718+ =/ res=(unit [=effects new-point=^point]) (fun u.point rest)
719+ ?~ res
720+ ~
721+ `[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
722+ ::
723+ ++ process-transfer-point
724+ |= [=point to=address reset=?]
725+ =* ship ship.from.tx
726+ :: Assert from owner or transfer prxoy
727+ ::
728+ ?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
729+ (debug %bad-permission ~)
730+ :: Execute transfer
731+ ::
732+ =/ effects-1
733+ ~[[%point ship %owner to] [%point ship %transfer-proxy *address]]
734+ =: address.owner.own.point to
735+ address.transfer-proxy.own.point *address
736+ ==
737+ :: Execute reset if requested
738+ ::
739+ ?. reset
740+ `[effects-1 point]
741+ ::
742+ =^ effects-2 net.point
743+ ?: =([0 0 0] +.keys.net.point)
744+ `net.point
745+ =/ =keys [+(life.keys.net.point) 0 0 0]
746+ :- [%point ship %keys keys]~
747+ [rift.net.point keys sponsor.net.point escape.net.point]
748+ =^ effects-3 rift.net.point
749+ ?: =(0 life.keys.net.point)
750+ `rift.net.point
751+ :- [%point ship %rift +(rift.net.point)]~
752+ +(rift.net.point)
753+ =/ effects-4
754+ :~ [%point ship %spawn-proxy *address]
755+ [%point ship %management-proxy *address]
756+ [%point ship %voting-proxy *address]
757+ [%point ship %transfer-proxy *address]
758+ ==
759+ =: address.spawn-proxy.own.point *address
760+ address.management-proxy.own.point *address
761+ address.voting-proxy.own.point *address
762+ address.transfer-proxy.own.point *address
763+ ==
764+ `[:(welp effects-1 effects-2 effects-3 effects-4) point]
765+ ::
766+ ++ process-spawn
767+ |= [=ship to=address]
768+ ^- (unit [effects ^state])
769+ =/ parent=^ship (sein ship)
770+ :: Assert parent is on L2
771+ ::
772+ =/ parent-point (get-point state parent)
773+ ?~ parent-point ~
774+ ?. ?=(?(%l2 %spawn) -.u.parent-point) ~
775+ :: Assert from owner or spawn proxy
776+ ::
777+ ?. ?& =(parent ship.from.tx)
778+ |(=(%own proxy.from.tx) =(%spawn proxy.from.tx))
779+ ==
780+ (debug %bad-permission ~)
781+ :: Assert child not already spawned
782+ ::
783+ ?^ (get:orm points.state ship) (debug %spawn-exists ~)
784+ :: Assert one-level-down
785+ ::
786+ ?. =(+((ship-rank parent)) (ship-rank ship)) (debug %bad-rank ~)
787+ ::
788+ =/ [=effects new-point=point]
789+ =/ point=(unit point) (get-point state ship)
790+ ?> ?=(^ point) :: only parsed 4 bytes
791+ :: If spawning to self, just do it
792+ ::
793+ ?: ?| ?& =(%own proxy.from.tx)
794+ =(to address.owner.own.u.parent-point)
795+ ==
796+ ?& =(%spawn proxy.from.tx)
797+ =(to address.spawn-proxy.own.u.parent-point)
798+ ==
799+ ==
800+ :- ~[[%point ship %dominion %l2] [%point ship %owner to]]
801+ u.point(address.owner.own to)
802+ :: Else spawn to parent and set transfer proxy
803+ ::
804+ :- :~ [%point ship %dominion %l2]
805+ [%point ship %owner address.owner.own.u.parent-point]
806+ [%point ship %transfer-proxy to]
807+ ==
808+ %= u.point
809+ address.owner.own address.owner.own.u.parent-point
810+ address.transfer-proxy.own to
811+ ==
812+ `[effects state(points (put:orm points.state ship new-point))]
813+ ::
814+ ++ process-configure-keys
815+ |= [=point crypt=@ auth=@ suite=@ breach=?]
816+ =* ship ship.from.tx
817+ ::
818+ ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
819+ (debug %bad-permission ~)
820+ ::
821+ =^ rift-effects rift.net.point
822+ ?. breach
823+ `rift.net.point
824+ [[%point ship %rift +(rift.net.point)]~ +(rift.net.point)]
825+ ::
826+ =^ keys-effects keys.net.point
827+ ?: =(+.keys.net.point [suite auth crypt])
828+ `keys.net.point
829+ =/ =keys
830+ [+(life.keys.net.point) suite auth crypt]
831+ [[%point ship %keys keys]~ keys]
832+ ::
833+ `[(welp rift-effects keys-effects) point]
834+ ::
835+ ++ process-escape
836+ |= [=point parent=ship]
837+ =* ship ship.from.tx
838+ ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
839+ (debug %bad-permission ~)
840+ ::
841+ ?. =(+((ship-rank parent)) (ship-rank ship))
842+ (debug %bad-rank ~)
843+ ::
844+ :+ ~ [%point ship %escape `parent]~
845+ point(escape.net `parent)
846+ ::
847+ ++ process-cancel-escape
848+ |= [=point parent=ship]
849+ =* ship ship.from.tx
850+ ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
851+ (debug %bad-permission ~)
852+ ::
853+ :+ ~ [%point ship %escape ~]~
854+ point(escape.net ~)
855+ ::
856+ ++ process-adopt
857+ |= [=point =ship]
858+ =* parent ship.from.tx
859+ ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
860+ (debug %bad-permission ~)
861+ ::
862+ ?. =(escape.net.point `parent) (debug %no-adopt ~)
863+ :+ ~ [%point ship %sponsor `parent]~
864+ point(escape.net ~, sponsor.net [%& parent])
865+ ::
866+ ++ process-reject
867+ |= [=point =ship]
868+ =* parent ship.from.tx
869+ ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
870+ (debug %bad-permission ~)
871+ ::
872+ ?. =(escape.net.point `parent) (debug %no-reject ~)
873+ :+ ~ [%point ship %escape ~]~
874+ point(escape.net ~)
875+ ::
876+ ++ process-detach
877+ |= [=point =ship]
878+ =* parent ship.from.tx
879+ ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
880+ (debug %bad-permission ~)
881+ ::
882+ ?. =(who.sponsor.net.point parent) (debug %no-detach ~)
883+ :+ ~ [%point ship %sponsor ~]~
884+ point(has.sponsor.net %|)
885+ ::
886+ ++ process-set-management-proxy
887+ |= [=point =address]
888+ ?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
889+ (debug %bad-permission ~)
890+ ::
891+ :+ ~ [%point ship.from.tx %management-proxy address]~
892+ point(address.management-proxy.own address)
893+ ::
894+ ++ process-set-spawn-proxy
895+ |= [=point =address]
896+ ?. |(=(%own proxy.from.tx) =(%spawn proxy.from.tx))
897+ (debug %bad-permission ~)
898+ ::
899+ ?: (gte (ship-rank ship.from.tx) 2)
900+ (debug %spawn-proxy-planet ~)
901+ ::
902+ :+ ~ [%point ship.from.tx %spawn-proxy address]~
903+ point(address.spawn-proxy.own address)
904+ ::
905+ ++ process-set-transfer-proxy
906+ |= [=point =address]
907+ ?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
908+ (debug %bad-permission ~)
909+ ::
910+ :+ ~ [%point ship.from.tx %transfer-proxy address]~
911+ point(address.transfer-proxy.own address)
912+ --
913+--
914+::
915+:: State transition function
916+::
917+|= [=verifier chain-id=@ud =state =input]
918+^- [effects ^state]
919+?: ?=(%log +<.input)
920+ :: Received log from L1 transaction
921+ ::
922+ (receive-log state event-log.input)
923+:: Received L2 batch
924+::
925+:: %+ debug %batch
926+(receive-batch verifier chain-id state batch.input)
base-desk/lib/tiny.hoonnew file+670
@@ -0,0 +1,670 @@
1+!.
2+=> %a50
3+~% %a.50 ~ ~
4+|%
5+:: Types
6+::
7++$ ship @p
8++$ life @ud
9++$ rift @ud
10++$ pass @
11++$ bloq @
12++$ step _`@u`1
13++$ bite $@(bloq [=bloq =step])
14++$ octs [p=@ud q=@]
15++$ mold $~(* $-(* *))
16+++ unit |$ [item] $@(~ [~ u=item])
17+++ list |$ [item] $@(~ [i=item t=(list item)])
18+++ lest |$ [item] [i=item t=(list item)]
19+++ tree |$ [node] $@(~ [n=node l=(tree node) r=(tree node)])
20+++ pair |$ [head tail] [p=head q=tail]
21+++ map
22+ |$ [key value]
23+ $| (tree (pair key value))
24+ |=(a=(tree (pair)) ?:(=(~ a) & ~(apt by a)))
25+::
26+++ set
27+ |$ [item]
28+ $| (tree item)
29+ |=(a=(tree) ?:(=(~ a) & ~(apt in a)))
30+::
31+++ jug |$ [key value] (map key (set value))
32+::
33+:: Bits
34+::
35+++ dec :: decrement
36+ ~/ %dec
37+ |= a=@
38+ ~_ leaf+"decrement-underflow"
39+ ?< =(0 a)
40+ =+ b=0
41+ |- ^- @
42+ ?: =(a +(b)) b
43+ $(b +(b))
44+::
45+++ add :: plus
46+ ~/ %add
47+ |= [a=@ b=@]
48+ ^- @
49+ ?: =(0 a) b
50+ $(a (dec a), b +(b))
51+::
52+++ sub :: subtract
53+ ~/ %sub
54+ |= [a=@ b=@]
55+ ~_ leaf+"subtract-underflow"
56+ :: difference
57+ ^- @
58+ ?: =(0 b) a
59+ $(a (dec a), b (dec b))
60+::
61+++ mul :: multiply
62+ ~/ %mul
63+ |: [a=`@`1 b=`@`1]
64+ ^- @
65+ =+ c=0
66+ |-
67+ ?: =(0 a) c
68+ $(a (dec a), c (add b c))
69+::
70+++ div :: divide
71+ ~/ %div
72+ |: [a=`@`1 b=`@`1]
73+ ^- @
74+ ~_ leaf+"divide-by-zero"
75+ ?< =(0 b)
76+ =+ c=0
77+ |-
78+ ?: (lth a b) c
79+ $(a (sub a b), c +(c))
80+::
81+++ dvr :: divide w/remainder
82+ ~/ %dvr
83+ |: [a=`@`1 b=`@`1]
84+ ^- [p=@ q=@]
85+ [(div a b) (mod a b)]
86+::
87+++ mod :: modulus
88+ ~/ %mod
89+ |: [a=`@`1 b=`@`1]
90+ ^- @
91+ ?< =(0 b)
92+ (sub a (mul b (div a b)))
93+::
94+++ bex :: binary exponent
95+ ~/ %bex
96+ |= a=bloq
97+ ^- @
98+ ?: =(0 a) 1
99+ (mul 2 $(a (dec a)))
100+::
101+++ lsh :: left-shift
102+ ~/ %lsh
103+ |= [a=bite b=@]
104+ =/ [=bloq =step] ?^(a a [a *step])
105+ (mul b (bex (mul (bex bloq) step)))
106+::
107+++ rsh :: right-shift
108+ ~/ %rsh
109+ |= [a=bite b=@]
110+ =/ [=bloq =step] ?^(a a [a *step])
111+ (div b (bex (mul (bex bloq) step)))
112+::
113+++ con :: binary or
114+ ~/ %con
115+ |= [a=@ b=@]
116+ =+ [c=0 d=0]
117+ |- ^- @
118+ ?: ?&(=(0 a) =(0 b)) d
119+ %= $
120+ a (rsh 0 a)
121+ b (rsh 0 b)
122+ c +(c)
123+ d %+ add d
124+ %+ lsh [0 c]
125+ ?& =(0 (end 0 a))
126+ =(0 (end 0 b))
127+ ==
128+ ==
129+::
130+++ dis :: binary and
131+ ~/ %dis
132+ |= [a=@ b=@]
133+ =| [c=@ d=@]
134+ |- ^- @
135+ ?: ?|(=(0 a) =(0 b)) d
136+ %= $
137+ a (rsh 0 a)
138+ b (rsh 0 b)
139+ c +(c)
140+ d %+ add d
141+ %+ lsh [0 c]
142+ ?| =(0 (end 0 a))
143+ =(0 (end 0 b))
144+ ==
145+ ==
146+::
147+++ mix :: binary xor
148+ ~/ %mix
149+ |= [a=@ b=@]
150+ ^- @
151+ =+ [c=0 d=0]
152+ |-
153+ ?: ?&(=(0 a) =(0 b)) d
154+ %= $
155+ a (rsh 0 a)
156+ b (rsh 0 b)
157+ c +(c)
158+ d (add d (lsh [0 c] =((end 0 a) (end 0 b))))
159+ ==
160+::
161+++ lth :: less
162+ ~/ %lth
163+ |= [a=@ b=@]
164+ ^- ?
165+ ?& !=(a b)
166+ |-
167+ ?| =(0 a)
168+ ?& !=(0 b)
169+ $(a (dec a), b (dec b))
170+ == == ==
171+::
172+++ lte :: less or equal
173+ ~/ %lte
174+ |= [a=@ b=@]
175+ |(=(a b) (lth a b))
176+::
177+++ gte :: greater or equal
178+ ~/ %gte
179+ |= [a=@ b=@]
180+ ^- ?
181+ !(lth a b)
182+::
183+++ gth :: greater
184+ ~/ %gth
185+ |= [a=@ b=@]
186+ ^- ?
187+ !(lte a b)
188+::
189+++ swp :: naive rev bloq order
190+ ~/ %swp
191+ |= [a=bloq b=@]
192+ (rep a (flop (rip a b)))
193+::
194+++ met :: measure
195+ ~/ %met
196+ |= [a=bloq b=@]
197+ ^- @
198+ =+ c=0
199+ |-
200+ ?: =(0 b) c
201+ $(b (rsh a b), c +(c))
202+::
203+++ end :: tail
204+ ~/ %end
205+ |= [a=bite b=@]
206+ =/ [=bloq =step] ?^(a a [a *step])
207+ (mod b (bex (mul (bex bloq) step)))
208+::
209+++ cat :: concatenate
210+ ~/ %cat
211+ |= [a=bloq b=@ c=@]
212+ (add (lsh [a (met a b)] c) b)
213+::
214+++ cut :: slice
215+ ~/ %cut
216+ |= [a=bloq [b=step c=step] d=@]
217+ (end [a c] (rsh [a b] d))
218+::
219+++ can :: assemble
220+ ~/ %can
221+ |= [a=bloq b=(list [p=step q=@])]
222+ ^- @
223+ ?~ b 0
224+ (add (end [a p.i.b] q.i.b) (lsh [a p.i.b] $(b t.b)))
225+::
226+++ cad :: assemble specific
227+ ~/ %cad
228+ |= [a=bloq b=(list [p=step q=@])]
229+ ^- [=step @]
230+ :_ (can a b)
231+ |-
232+ ?~ b
233+ 0
234+ (add p.i.b $(b t.b))
235+::
236+++ rep :: assemble fixed
237+ ~/ %rep
238+ |= [a=bite b=(list @)]
239+ =/ [=bloq =step] ?^(a a [a *step])
240+ =| i=@ud
241+ |- ^- @
242+ ?~ b 0
243+ %+ add $(i +(i), b t.b)
244+ (lsh [bloq (mul step i)] (end [bloq step] i.b))
245+::
246+++ rip :: disassemble
247+ ~/ %rip
248+ |= [a=bite b=@]
249+ ^- (list @)
250+ ?: =(0 b) ~
251+ [(end a b) $(b (rsh a b))]
252+::
253+::
254+:: Lists
255+::
256+++ lent :: length
257+ ~/ %lent
258+ |= a=(list)
259+ ^- @
260+ =+ b=0
261+ |-
262+ ?~ a b
263+ $(a t.a, b +(b))
264+::
265+++ slag :: suffix
266+ ~/ %slag
267+ |* [a=@ b=(list)]
268+ |- ^+ b
269+ ?: =(0 a) b
270+ ?~ b ~
271+ $(b t.b, a (dec a))
272+::
273+++ snag :: index
274+ ~/ %snag
275+ |* [a=@ b=(list)]
276+ |- ^+ ?>(?=(^ b) i.b)
277+ ?~ b
278+ ~_ leaf+"snag-fail"
279+ !!
280+ ?: =(0 a) i.b
281+ $(b t.b, a (dec a))
282+::
283+++ homo :: homogenize
284+ |* a=(list)
285+ ^+ =< $
286+ |@ ++ $ ?:(*? ~ [i=(snag 0 a) t=$])
287+ --
288+ a
289+::
290+++ flop :: reverse
291+ ~/ %flop
292+ |* a=(list)
293+ => .(a (homo a))
294+ ^+ a
295+ =+ b=`_a`~
296+ |-
297+ ?~ a b
298+ $(a t.a, b [i.a b])
299+::
300+++ welp :: concatenate
301+ ~/ %welp
302+ =| [* *]
303+ |@
304+ ++ $
305+ ?~ +<-
306+ +<-(. +<+)
307+ +<-(+ $(+<- +<->))
308+ --
309+::
310+++ reap :: replicate
311+ ~/ %reap
312+ |* [a=@ b=*]
313+ |- ^- (list _b)
314+ ?~ a ~
315+ [b $(a (dec a))]
316+::
317+:: Modular arithmetic
318+::
319+++ fe :: modulo bloq
320+ |_ a=bloq
321+ ++ rol |= [b=bloq c=@ d=@] ^- @ :: roll left
322+ =+ e=(sit d)
323+ =+ f=(bex (sub a b))
324+ =+ g=(mod c f)
325+ (sit (con (lsh [b g] e) (rsh [b (sub f g)] e)))
326+ ++ sum |=([b=@ c=@] (sit (add b c))) :: wrapping add
327+ ++ sit |=(b=@ (end a b)) :: enforce modulo
328+ --
329+::
330+:: Hashes
331+::
332+++ muk :: standard murmur3
333+ ~% %muk ..muk ~
334+ =+ ~(. fe 5)
335+ |= [syd=@ len=@ key=@]
336+ =. syd (end 5 syd)
337+ =/ pad (sub len (met 3 key))
338+ =/ data (welp (rip 3 key) (reap pad 0))
339+ =/ nblocks (div len 4) :: intentionally off-by-one
340+ =/ h1 syd
341+ =+ [c1=0xcc9e.2d51 c2=0x1b87.3593]
342+ =/ blocks (rip 5 key)
343+ =/ i nblocks
344+ =. h1 =/ hi h1 |-
345+ ?: =(0 i) hi
346+ =/ k1 (snag (sub nblocks i) blocks) :: negative array index
347+ =. k1 (sit (mul k1 c1))
348+ =. k1 (rol 0 15 k1)
349+ =. k1 (sit (mul k1 c2))
350+ =. hi (mix hi k1)
351+ =. hi (rol 0 13 hi)
352+ =. hi (sum (sit (mul hi 5)) 0xe654.6b64)
353+ $(i (dec i))
354+ =/ tail (slag (mul 4 nblocks) data)
355+ =/ k1 0
356+ =/ tlen (dis len 3)
357+ =. h1
358+ ?+ tlen h1 :: fallthrough switch
359+ %3 =. k1 (mix k1 (lsh [0 16] (snag 2 tail)))
360+ =. k1 (mix k1 (lsh [0 8] (snag 1 tail)))
361+ =. k1 (mix k1 (snag 0 tail))
362+ =. k1 (sit (mul k1 c1))
363+ =. k1 (rol 0 15 k1)
364+ =. k1 (sit (mul k1 c2))
365+ (mix h1 k1)
366+ %2 =. k1 (mix k1 (lsh [0 8] (snag 1 tail)))
367+ =. k1 (mix k1 (snag 0 tail))
368+ =. k1 (sit (mul k1 c1))
369+ =. k1 (rol 0 15 k1)
370+ =. k1 (sit (mul k1 c2))
371+ (mix h1 k1)
372+ %1 =. k1 (mix k1 (snag 0 tail))
373+ =. k1 (sit (mul k1 c1))
374+ =. k1 (rol 0 15 k1)
375+ =. k1 (sit (mul k1 c2))
376+ (mix h1 k1)
377+ ==
378+ =. h1 (mix h1 len)
379+ |^ (fmix32 h1)
380+ ++ fmix32
381+ |= h=@
382+ =. h (mix h (rsh [0 16] h))
383+ =. h (sit (mul h 0x85eb.ca6b))
384+ =. h (mix h (rsh [0 13] h))
385+ =. h (sit (mul h 0xc2b2.ae35))
386+ =. h (mix h (rsh [0 16] h))
387+ h
388+ --
389+::
390+++ mug :: mug with murmur3
391+ ~/ %mug
392+ |= a=*
393+ |^ ?@ a (mum 0xcafe.babe 0x7fff a)
394+ =/ b (cat 5 $(a -.a) $(a +.a))
395+ (mum 0xdead.beef 0xfffe b)
396+ ::
397+ ++ mum
398+ |= [syd=@uxF fal=@F key=@]
399+ =/ wyd (met 3 key)
400+ =| i=@ud
401+ |- ^- @F
402+ ?: =(8 i) fal
403+ =/ haz=@F (muk syd wyd key)
404+ =/ ham=@F (mix (rsh [0 31] haz) (end [0 31] haz))
405+ ?.(=(0 ham) ham $(i +(i), syd +(syd)))
406+ --
407+::
408+++ gor :: mug order
409+ ~/ %gor
410+ |= [a=* b=*]
411+ ^- ?
412+ =+ [c=(mug a) d=(mug b)]
413+ ?: =(c d)
414+ (dor a b)
415+ (lth c d)
416+::
417+++ mor :: more mug order
418+ ~/ %mor
419+ |= [a=* b=*]
420+ ^- ?
421+ =+ [c=(mug (mug a)) d=(mug (mug b))]
422+ ?: =(c d)
423+ (dor a b)
424+ (lth c d)
425+::
426+++ dor :: tree order
427+ ~/ %dor
428+ |= [a=* b=*]
429+ ^- ?
430+ ?: =(a b) &
431+ ?. ?=(@ a)
432+ ?: ?=(@ b) |
433+ ?: =(-.a -.b)
434+ $(a +.a, b +.b)
435+ $(a -.a, b -.b)
436+ ?. ?=(@ b) &
437+ (lth a b)
438+::
439+++ por :: parent order
440+ ~/ %por
441+ |= [a=@p b=@p]
442+ ^- ?
443+ ?: =(a b) &
444+ =| i=@
445+ |-
446+ ?: =(i 2)
447+ :: second two bytes
448+ (lte a b)
449+ :: first two bytes
450+ =+ [c=(end 3 a) d=(end 3 b)]
451+ ?: =(c d)
452+ $(a (rsh 3 a), b (rsh 3 b), i +(i))
453+ (lth c d)
454+::
455+:: Maps
456+::
457+++ by
458+ ~/ %by
459+ =| a=(tree (pair)) :: (map)
460+ =* node ?>(?=(^ a) n.a)
461+ |@
462+ ++ get
463+ ~/ %get
464+ |* b=*
465+ => .(b `_?>(?=(^ a) p.n.a)`b)
466+ |- ^- (unit _?>(?=(^ a) q.n.a))
467+ ?~ a
468+ ~
469+ ?: =(b p.n.a)
470+ `q.n.a
471+ ?: (gor b p.n.a)
472+ $(a l.a)
473+ $(a r.a)
474+ ::
475+ ++ put
476+ ~/ %put
477+ |* [b=* c=*]
478+ |- ^+ a
479+ ?~ a
480+ [[b c] ~ ~]
481+ ?: =(b p.n.a)
482+ ?: =(c q.n.a)
483+ a
484+ a(n [b c])
485+ ?: (gor b p.n.a)
486+ =+ d=$(a l.a)
487+ ?> ?=(^ d)
488+ ?: (mor p.n.a p.n.d)
489+ a(l d)
490+ d(r a(l r.d))
491+ =+ d=$(a r.a)
492+ ?> ?=(^ d)
493+ ?: (mor p.n.a p.n.d)
494+ a(r d)
495+ d(l a(r l.d))
496+ ::
497+ ++ del
498+ ~/ %del
499+ |* b=*
500+ |- ^+ a
501+ ?~ a
502+ ~
503+ ?. =(b p.n.a)
504+ ?: (gor b p.n.a)
505+ a(l $(a l.a))
506+ a(r $(a r.a))
507+ |- ^- [$?(~ _a)]
508+ ?~ l.a r.a
509+ ?~ r.a l.a
510+ ?: (mor p.n.l.a p.n.r.a)
511+ l.a(r $(l.a r.l.a))
512+ r.a(l $(r.a l.r.a))
513+ ::
514+ ++ apt
515+ =< $
516+ ~/ %apt
517+ =| [l=(unit) r=(unit)]
518+ |. ^- ?
519+ ?~ a &
520+ ?& ?~(l & &((gor p.n.a u.l) !=(p.n.a u.l)))
521+ ?~(r & &((gor u.r p.n.a) !=(u.r p.n.a)))
522+ ?~ l.a &
523+ &((mor p.n.a p.n.l.a) !=(p.n.a p.n.l.a) $(a l.a, l `p.n.a))
524+ ?~ r.a &
525+ &((mor p.n.a p.n.r.a) !=(p.n.a p.n.r.a) $(a r.a, r `p.n.a))
526+ ==
527+ --
528+::
529+++ on :: ordered map
530+ ~/ %on
531+ |* [key=mold val=mold]
532+ => |%
533+ +$ item [key=key val=val]
534+ --
535+ ::
536+ ~% %comp +>+ ~
537+ |= compare=$-([key key] ?)
538+ ~% %core + ~
539+ |%
540+ ::
541+ ++ apt
542+ ~/ %apt
543+ |= a=(tree item)
544+ =| [l=(unit key) r=(unit key)]
545+ |- ^- ?
546+ ?~ a %.y
547+ ?& ?~(l %.y (compare key.n.a u.l))
548+ ?~(r %.y (compare u.r key.n.a))
549+ ?~(l.a %.y &((mor key.n.a key.n.l.a) $(a l.a, l `key.n.a)))
550+ ?~(r.a %.y &((mor key.n.a key.n.r.a) $(a r.a, r `key.n.a)))
551+ ==
552+ ::
553+ ++ get
554+ ~/ %get
555+ |= [a=(tree item) b=key]
556+ ^- (unit val)
557+ ?~ a ~
558+ ?: =(b key.n.a)
559+ `val.n.a
560+ ?: (compare b key.n.a)
561+ $(a l.a)
562+ $(a r.a)
563+ ::
564+ ++ has
565+ ~/ %has
566+ |= [a=(tree item) b=key]
567+ ^- ?
568+ !=(~ (get a b))
569+ ::
570+ ++ put
571+ ~/ %put
572+ |= [a=(tree item) =key =val]
573+ ^- (tree item)
574+ ?~ a [n=[key val] l=~ r=~]
575+ ?: =(key.n.a key) a(val.n val)
576+ ?: (compare key key.n.a)
577+ =/ l $(a l.a)
578+ ?> ?=(^ l)
579+ ?: (mor key.n.a key.n.l)
580+ a(l l)
581+ l(r a(l r.l))
582+ =/ r $(a r.a)
583+ ?> ?=(^ r)
584+ ?: (mor key.n.a key.n.r)
585+ a(r r)
586+ r(l a(r l.r))
587+ --
588+::
589+:: Sets
590+::
591+++ in
592+ ~/ %in
593+ =| a=(tree) :: (set)
594+ |@
595+ ++ put
596+ ~/ %put
597+ |* b=*
598+ |- ^+ a
599+ ?~ a
600+ [b ~ ~]
601+ ?: =(b n.a)
602+ a
603+ ?: (gor b n.a)
604+ =+ c=$(a l.a)
605+ ?> ?=(^ c)
606+ ?: (mor n.a n.c)
607+ a(l c)
608+ c(r a(l r.c))
609+ =+ c=$(a r.a)
610+ ?> ?=(^ c)
611+ ?: (mor n.a n.c)
612+ a(r c)
613+ c(l a(r l.c))
614+ ::
615+ ++ del
616+ ~/ %del
617+ |* b=*
618+ |- ^+ a
619+ ?~ a
620+ ~
621+ ?. =(b n.a)
622+ ?: (gor b n.a)
623+ a(l $(a l.a))
624+ a(r $(a r.a))
625+ |- ^- [$?(~ _a)]
626+ ?~ l.a r.a
627+ ?~ r.a l.a
628+ ?: (mor n.l.a n.r.a)
629+ l.a(r $(l.a r.l.a))
630+ r.a(l $(r.a l.r.a))
631+ ::
632+ ++ apt
633+ =< $
634+ ~/ %apt
635+ =| [l=(unit) r=(unit)]
636+ |. ^- ?
637+ ?~ a &
638+ ?& ?~(l & (gor n.a u.l))
639+ ?~(r & (gor u.r n.a))
640+ ?~(l.a & ?&((mor n.a n.l.a) $(a l.a, l `n.a)))
641+ ?~(r.a & ?&((mor n.a n.r.a) $(a r.a, r `n.a)))
642+ ==
643+ --
644+::
645+:: Jugs
646+::
647+++ ju
648+ =| a=(tree (pair * (tree))) :: (jug)
649+ |@
650+ ++ get
651+ |* b=*
652+ =+ c=(~(get by a) b)
653+ ?~(c ~ u.c)
654+ ::
655+ ++ del
656+ |* [b=* c=*]
657+ ^+ a
658+ =+ d=(get b)
659+ =+ e=(~(del in d) c)
660+ ?~ e
661+ (~(del by a) b)
662+ (~(put by a) b e)
663+ ::
664+ ++ put
665+ |* [b=* c=*]
666+ ^+ a
667+ =+ d=(get b)
668+ (~(put by a) b (~(put in d) c))
669+ --
670+--
base-desk/sources.txtnew file+4
@@ -0,0 +1,4 @@
1+urbit-src/pkg/base-dev
2+urbit-src/pkg/garden-dev
3+urbit-src/pkg/arvo/lib/naive
4+urbit-src/pkg/arvo/lib/tiny
config/ignore_files_on_install.txtnew file+4
@@ -0,0 +1,4 @@
1+.*
2+*.sh
3+*.md
4+*.txt
desk/app/astrolabe.hoonnew file+41
@@ -0,0 +1,41 @@
1+/- astrolabe
2+/+ naive, default-agent, dbug
3+|%
4++$ versioned-state
5+ $% state-0
6+ ==
7++$ state-0 [%0 data=(map @p @t)]
8++$ card card:agent:gall
9+--
10+%- agent:dbug
11+=| state-0
12+=* state -
13+^- agent:gall
14+|_ =bowl:gall
15++* this .
16+ def ~(. (default-agent this %.n) bowl)
17+::
18+++ on-init
19+ ^- (quip card _this)
20+ `this
21+::
22+++ on-save on-save:def
23+++ on-load on-load:def
24+++ on-poke on-poke:def
25+++ on-watch on-watch:def
26+++ on-leave on-leave:def
27+::
28+++ on-peek
29+ |= =path
30+ ^- (unit (unit cage))
31+ ?+ path (on-peek:def path)
32+ [%x %point @ ~]
33+ =, bowl
34+ =/ point .^(noun %gx /(scot %p our)/azimuth/(scot %da now)/point/[&3.path]/noun)
35+ ``astrolabe-point+!>((upoint:astrolabe point))
36+ ==
37+::
38+++ on-agent on-agent:def
39+++ on-arvo on-arvo:def
40+++ on-fail on-fail:def
41+--
desk/desk.bill+2−1
@@ -1 +1,2 @@
1−~
1+:~ %astrolabe
2+==
desk/desk.docket-0+1−1
@@ -4,6 +4,6 @@
4 glob-http+['https://bootstrap.urbit.org/glob-0v5.hurm4.ejod5.ngg9h.iub9i.n1j7o.glob' 0v5.hurm4.ejod5.ngg9h.iub9i.n1j7o]
4 glob-http+['https://bootstrap.urbit.org/glob-0v5.hurm4.ejod5.ngg9h.iub9i.n1j7o.glob' 0v5.hurm4.ejod5.ngg9h.iub9i.n1j7o]
5 base+'astrolabe'
5 base+'astrolabe'
6 version+[0 0 1]
6 version+[0 0 1]
7− website+'https://github.com'
7+ website+'https://github.com/johnhyde/astrolabe'
8 license+'MIT'
8 license+'MIT'
9==
9==
desk/lib/astrolabe.hoonnew file+89
@@ -0,0 +1,89 @@
1+/- sur=astrolabe
2+=< [sur .]
3+=, sur
4+|%
5+++ nu :: parse number as hex
6+ |= jon=json
7+ ?> ?=([%s *] jon)
8+ (rash p.jon hex)
9+::
10+++ enjs
11+ =, enjs:format
12+ |%
13+ ++ point
14+ |= =upoint
15+ ^- json
16+ ?~ upoint (pairs ~)
17+ =* point u.upoint
18+ %+ frond %point
19+ %- pairs :~
20+ [%dominion s+dominion.point]
21+ :- %own
22+ =* own own.point
23+ %- pairs :~
24+ owner+(address owner.own)
25+ spawn-proxy+(address spawn-proxy.own)
26+ management-proxy+(address management-proxy.own)
27+ voting-proxy+(address voting-proxy.own)
28+ transfer-proxy+(address transfer-proxy.own)
29+ ==
30+ :- %net
31+ =* net net.point
32+ %- pairs
33+ :~ rift+(numb rift.net)
34+ :- %keys
35+ %- pairs :~
36+ life+(numb life.keys.net)
37+ suite+(numb suite.keys.net)
38+ auth+(numb auth.keys.net)
39+ crypt+(numb crypt.keys.net)
40+ ==
41+ :- %sponsor
42+ %- pairs :~
43+ has+b+has.sponsor.net
44+ who+(ship who.sponsor.net)
45+ ==
46+ :- %escape
47+ (biff escape.net ship)
48+ ==
49+ ==
50+ ++ address
51+ |= [address=@ux nonce=@ud]
52+ ^- json
53+ %- pairs
54+ :~ address+(numb-ux address)
55+ nonce+(numb nonce)
56+ ==
57+ ++ numb-ux
58+ |= a=@
59+ ^- json
60+ ?~ a ~
61+ s+(remove-dots (scot %ux a))
62+ ++ remove-dots
63+ |= a=@ta
64+ ^- @ta
65+ =+ b=(rip 3 a)
66+ %+ rap 3
67+ |- ^- ^tape
68+ ?~ b
69+ ~
70+ ?: =('.' i.b) $(b t.b)
71+ [i.b $(b t.b)]
72+ --
73+::
74+++ dejs
75+ =, dejs:format
76+ |%
77+ ++ point
78+ |= jon=json
79+ ^- upoint ~
80+ --
81+::
82+++ share-dejs
83+ =, dejs:format
84+ |%
85+ ++ share
86+ ^- $-(json [%share ship])
87+ (of share+(su ;~(pfix sig fed:ag)) ~)
88+ --
89+--
desk/mar/astrolabe/point.hoonnew file+14
@@ -0,0 +1,14 @@
1+/+ *astrolabe
2+|_ pnt=upoint
3+++ grab
4+ |%
5+ ++ noun upoint
6+ ++ json point:dejs
7+ --
8+++ grow
9+ |%
10+ ++ noun pnt
11+ ++ json (point:enjs pnt)
12+ --
13+++ grad %noun
14+--
desk/sur/astrolabe.hoonnew file+5
@@ -0,0 +1,5 @@
1+/+ naive
2+|%
3++$ point point:naive
4+++ upoint (unit point)
5+--
install.shmode 100644 → 100755+10−9
@@ -3,19 +3,19 @@
3# Taken from: https://github.com/timlucmiptev/btc-agents/blob/master/install.sh
3# Taken from: https://github.com/timlucmiptev/btc-agents/blob/master/install.sh
4# by ~timluc-miptev
4# by ~timluc-miptev
5#
5#
6−usage() { printf "Usage: $0 [-w] URBIT_PIER_DIRECTORY \n(-w: flag to watch and live copy code)\n" 1>&2; exit 1; }
6+usage() { printf "Usage: $0 [-w] URBIT_DESK_DIRECTORY \n(-w: flag to watch and live copy code)\n" 1>&2; exit 1; }
7
7
8if [ $# -eq 0 ]; then
8if [ $# -eq 0 ]; then
9 usage
9 usage
10 exit 2
10 exit 2
11fi
11fi
12−PIER=$1
12+DESK=$1
13−EXCLUDE_FILE=ignore_files.txt
13+EXCLUDE_FILE=config/ignore_files_on_install.txt
14
14
15while getopts "w" opt; do
15while getopts "w" opt; do
16 case ${opt} in
16 case ${opt} in
17 w) WATCH_MODE="true"
17 w) WATCH_MODE="true"
18− PIER=$2
18+ DESK=$2
19 ;;
19 ;;
20 *) usage
20 *) usage
21 ;;
21 ;;
@@ -24,16 +24,17 @@ done
24
24
25if [ -z "$WATCH_MODE" ]; then
25if [ -z "$WATCH_MODE" ]; then
26 echo "Installed %astrolabe"
26 echo "Installed %astrolabe"
27− # rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./desk/* $PIER/
27+ rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./base-desk/* $DESK/
28− rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./desk/* $PIER/
28+ rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./desk/* $DESK/
29
29
30else
30else
31− echo "Watching for changes to copy to ${PIER}..."
31+ echo "Watching for changes to copy to ${DESK}..."
32 while [ 0 ]
32 while [ 0 ]
33 do
33 do
34 sleep 0.8
34 sleep 0.8
35− # rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./desk/* $PIER/
35+ rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./base-desk/* $DESK/
36− rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./desk/* $PIER/
36+ rsync -r --copy-links --exclude-from=$EXCLUDE_FILE ./desk/* $DESK/
37
37
38 done
38 done
39fi
39fi
40+ls
ui/package.json+2−1
@@ -10,7 +10,8 @@
10 "dev": "concurrently \"npm run dev:only\" \"npm run tailwind:watch\"",
10 "dev": "concurrently \"npm run dev:only\" \"npm run tailwind:watch\"",
11 "build": "npm run tailwind:build && npm run build:only",
11 "build": "npm run tailwind:build && npm run build:only",
12 "preview": "vite preview",
12 "preview": "vite preview",
13− "check": "svelte-check --tsconfig ./tsconfig.json"
13+ "check": "svelte-check --tsconfig ./tsconfig.json",
14+ "install": "npm run build && ../install.sh "
14 },
15 },
15 "devDependencies": {
16 "devDependencies": {
16 "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
17 "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30",
ui/src/components/SearchBar.svelte+3−3
@@ -5,7 +5,7 @@
5
5
6 export let patp: string = undefined;
6 export let patp: string = undefined;
7 export let searchQuery: RegExp = /~der/;
7 export let searchQuery: RegExp = /~der/;
8− let searchText = 'der';
8+ let searchText = '';
9 let analysis: SearchAnalysis;
9 let analysis: SearchAnalysis;
10
10
11 $: {
11 $: {
@@ -33,14 +33,14 @@
33 <button class="absolute right-0 w-10 h-10 rounded-full bg-black transition-opacity opacity-10 hover:opacity-40"></button>
33 <button class="absolute right-0 w-10 h-10 rounded-full bg-black transition-opacity opacity-10 hover:opacity-40"></button>
34 </div>
34 </div>
35</div>
35</div>
36−<div class="bg-gray-300 p-2 rounded-lg">
36+<!-- <div class="bg-gray-300 p-2 rounded-lg">
37 <p>
37 <p>
38 text: {searchText}
38 text: {searchText}
39 </p>
39 </p>
40 <p>
40 <p>
41 query: {searchQuery}
41 query: {searchQuery}
42 </p>
42 </p>
43−</div>
43+</div> -->
44{#if searchText !== '' && analysis && analysis.queryProblems.length > 0}
44{#if searchText !== '' && analysis && analysis.queryProblems.length > 0}
45 <div class="flex justify-center">
45 <div class="flex justify-center">
46 <ValidationProblems type="Query Problems" problems={analysis.queryProblems}></ValidationProblems>
46 <ValidationProblems type="Query Problems" problems={analysis.queryProblems}></ValidationProblems>
ui/src/components/ShipView.svelte+82
@@ -1,10 +1,19 @@
1<script lang="ts">
1<script lang="ts">
2+ import type { Scry } from '@urbit/http-api';
3+ import UrbitApi from '@urbit/http-api';
4+ import { settings } from '@urbit/api';
2 import { clan, sein, patp2dec } from 'urbit-ob';
5 import { clan, sein, patp2dec } from 'urbit-ob';
6+
3 import { link } from 'svelte-spa-router'
7 import { link } from 'svelte-spa-router'
8+ import { normalizeId } from '../lib/id';
4 import { linkToShip } from '../lib/link';
9 import { linkToShip } from '../lib/link';
5 import Sigil from "./Sigil.svelte";
10 import Sigil from "./Sigil.svelte";
6 export let patp: string;
11 export let patp: string;
7 let parentChain: any[];
12 let parentChain: any[];
13+ let rawPointInfoPromise: any;
14+ let rawPointInfo: any = {};
15+ let pointInfo: any = {};
16+ const api: UrbitApi = new UrbitApi('');
8
17
9 $: shipClass = clan(patp);
18 $: shipClass = clan(patp);
10 $: azPoint = ['galaxy', 'star', 'planet'].includes(shipClass);
19 $: azPoint = ['galaxy', 'star', 'planet'].includes(shipClass);
@@ -29,6 +38,45 @@
29 return { patp: parent, link: linkToShip(parent) };
38 return { patp: parent, link: linkToShip(parent) };
30 });
39 });
31 }
40 }
41+ $: {
42+ rawPointInfo = {};
43+ if (azPoint) {
44+ rawPointInfoPromise = api.scry<any>({ app: 'astrolabe', path: `/point/${patp}` });
45+ rawPointInfoPromise.then((info) => {
46+ rawPointInfo = info;
47+ });
48+ }
49+ }
50+ $: {
51+ pointInfo = {};
52+ let status, life, rift;
53+ if (!azPoint) {
54+ } else if (rawPointInfo.point) {
55+ const { point } = rawPointInfo;
56+ status = point.dominion.toUpperCase();
57+ if (status.length == 2) {
58+ status = `Activated on ${status}?`;
59+ } else {
60+ status = 'Spawned?'
61+ }
62+ life = point.net.keys.life;
63+ rift = point.net.rift;
64+ const { sponsor } = point.net;
65+ if (sponsor.has) {
66+ pointInfo.sponsor = normalizeId(sponsor.who);
67+ }
68+ } else {
69+ status = 'Unspawned';
70+ life = 0;
71+ rift = 0;
72+ }
73+ pointInfo = {
74+ ...pointInfo,
75+ status,
76+ life,
77+ rift,
78+ };
79+ }
32</script>
80</script>
33
81
34<div class="flex justify-center">
82<div class="flex justify-center">
@@ -54,5 +102,39 @@
54 {/each}
102 {/each}
55 </p>
103 </p>
56 {/if}
104 {/if}
105+ {#if shipClass !== 'galaxy'}
106+ <p>
107+ {#if pointInfo.sponsor && shipClass !== 'galaxy'}
108+ Sponsor:
109+ <a use:link={linkToShip(pointInfo.sponsor)}>{pointInfo.sponsor}</a>
110+ {:else}
111+ Unsponsored
112+ {/if}
113+ </p>
114+ {/if}
115+ {#if pointInfo.status}
116+ <p>
117+ Status:
118+ {pointInfo.status}
119+ </p>
120+ <p>
121+ Life:
122+ {pointInfo.life}
123+ </p>
124+ <p>
125+ Rift:
126+ {pointInfo.rift}
127+ </p>
128+ {/if}
129+ {#await rawPointInfoPromise}
130+ Loading Azimuth info...
131+ {:then value}
132+ {#if value.point}
133+ <p>
134+ Raw Info:
135+ {@html JSON.stringify(rawPointInfo, null, 2)}
136+ </p>
137+ {/if}
138+ {/await}
57 </div>
139 </div>
58</div>
140</div>
ui/src/lib/utils.ts+1−1
@@ -12,4 +12,4 @@ function filterObject(obj, predicate) {
12export {
12export {
13 listStrings,
13 listStrings,
14 filterObject,
14 filterObject,
15−}
15+};
ui/src/routes/ShipViewPage.svelte+1
@@ -2,6 +2,7 @@
2 import { link, replace } from 'svelte-spa-router'
2 import { link, replace } from 'svelte-spa-router'
3 import { analyzeSearch, normalizeId } from '../lib/id';
3 import { analyzeSearch, normalizeId } from '../lib/id';
4 import { linkToShip } from '../lib/link';
4 import { linkToShip } from '../lib/link';
5+ import SearchBar from "../components/SearchBar.svelte";
5 import ShipView from '../components/ShipView.svelte';
6 import ShipView from '../components/ShipView.svelte';
6 import ValidationProblems from '../components/ValidationProblems.svelte';
7 import ValidationProblems from '../components/ValidationProblems.svelte';
7 export let params: any = {};
8 export let params: any = {};
ui/src/styles/tailwind-output.css+7−17
@@ -524,9 +524,6 @@ Ensure the default browser behavior of the `hidden` attribute.
524.rounded-lg {
524.rounded-lg {
525 border-radius: 0.5rem;
525 border-radius: 0.5rem;
526}
526}
527−.rounded-sm {
528− border-radius: 0.125rem;
529−}
530.border-b {
527.border-b {
531 border-bottom-width: 1px;
528 border-bottom-width: 1px;
532}
529}
@@ -534,33 +531,26 @@ Ensure the default browser behavior of the `hidden` attribute.
534 --tw-bg-opacity: 1;
531 --tw-bg-opacity: 1;
535 background-color: rgb(0 0 0 / var(--tw-bg-opacity));
532 background-color: rgb(0 0 0 / var(--tw-bg-opacity));
536}
533}
537−.bg-white {
538− --tw-bg-opacity: 1;
539− background-color: rgb(255 255 255 / var(--tw-bg-opacity));
540−}
541−.bg-gray-200 {
542− --tw-bg-opacity: 1;
543− background-color: rgb(229 231 235 / var(--tw-bg-opacity));
544−}
545.bg-gray-300 {
534.bg-gray-300 {
546 --tw-bg-opacity: 1;
535 --tw-bg-opacity: 1;
547 background-color: rgb(209 213 219 / var(--tw-bg-opacity));
536 background-color: rgb(209 213 219 / var(--tw-bg-opacity));
548}
537}
538+.bg-white {
539+ --tw-bg-opacity: 1;
540+ background-color: rgb(255 255 255 / var(--tw-bg-opacity));
541+}
549.p-4 {
542.p-4 {
550 padding: 1rem;
543 padding: 1rem;
551}
544}
545+.p-2 {
546+ padding: 0.5rem;
547+}
552.p-6 {
548.p-6 {
553 padding: 1.5rem;
549 padding: 1.5rem;
554}
550}
555.p-8 {
551.p-8 {
556 padding: 2rem;
552 padding: 2rem;
557}
553}
558−.p-1 {
559− padding: 0.25rem;
560−}
561−.p-2 {
562− padding: 0.5rem;
563−}
564.py-2 {
554.py-2 {
565 padding-top: 0.5rem;
555 padding-top: 0.5rem;
566 padding-bottom: 0.5rem;
556 padding-bottom: 0.5rem;