on main help sign in
fix search, add sponsor chain and probable dominion
commit2904f2ac13c0e77bb35666d4220cfda9c48d993b authorJohn Hyde <johnhydefour@gmail.com> dateTue 7 Jun 2022, 12:41 (4 years ago) parent04e487b
5 files changed+141−62
desk/app/astrolabe.hoon+53−33 desk/lib/astrolabe.hoon+38−2 desk/sur/astrolabe.hoon+2−1 ui/src/components/ShipChain.svelte+11 ui/src/components/ShipView.svelte+37−26
desk/app/astrolabe.hoon+53−33
@@ -12,7 +12,8 @@
1212 ==
1313+$ state-1
1414 $: %1
15− =opoints
15+ fopoints=opoints :: forward ordered points
16+ ropoints=opoints :: reversed ordered points, e.g. .~palnet-sampel
1617 ==
1718::
1819+$ spawned (jug ship ship)
@@ -114,26 +115,28 @@
114115++ get-nas .^(^state:naive %gx (scrio %azimuth /nas/noun))
115116++ put-in-opoints
116117 |= =ship
117− ^- _opoints
118− (put:ors opoints (to-q ship) ~)
118+ ^- _state
119+ =. fopoints
120+ (put:ors fopoints (to-q ship) ~)
121+ =. ropoints
122+ (put:ors ropoints (switch-words (to-q ship)) ~)
123+ state
119124++ on-naive-state
120125 |= nas=^state:naive
121126 ^- (quip card _state)
122127 =+ points=points.nas :: =points, eh?
123− =. opoints
124− |-
125− ^- _opoints
126− ?~ points opoints
127− =/ =ship -.n.points
128− :: traverse tree of points and add @ps to opoints with ^sein, you know
129− =. opoints (put-in-opoints ship)
130− $(points l.points, opoints $(points r.points))
131− `state
128+ :- ~
129+ |-
130+ ^- _state
131+ ?~ points state
132+ =/ =ship -.n.points
133+ =. state (put-in-opoints ship)
134+ $(points l.points, state $(points r.points))
132135::
133136++ on-naive-diff
134137 |= =diff:naive
135138 ^- (quip card _state)
136− =? opoints ?=([%tx [* * * %spawn ship *] *] diff)
139+ =? state ?=([%tx [* * * %spawn ship *] *] diff)
137140 %- put-in-opoints
138141 ship.tx.raw-tx.diff
139142 `state
@@ -143,21 +146,26 @@
143146 ^- ?
144147 ?= [%tx [* * * %spawn ship *] *] diff
145148::
149+++ get-unpoint-term
150+ |= ship-name=term
151+ .^(unpoint %gx (scrio %azimuth /point/[ship-name]/noun))
152+::
153+++ get-unpoint
154+ |= =ship
155+ (get-unpoint-term (scot %p ship))
156+::
146157++ get-point
147158 |= ship-name=term
148159 ^- point
149160 =/ =ship `@p`(slav %p ship-name)
150− =/ unpoint (get-unpoint ship-name)
151− :* unpoint
161+ =/ unpoint (get-unpoint-term ship-name)
162+ :* ship
163+ unpoint
152164 (spa-count ship)
153− (sponsor-chain unpoint)
154− (probable-dominion unpoint)
165+ (sponsor-chain ship unpoint)
166+ (probable-dominion ship unpoint)
155167 ==
156168::
157−++ get-unpoint
158− |= ship-name=term
159− .^(unpoint %gx (scrio %azimuth /point/[ship-name]/noun))
160−::
161169++ run-spawned-points
162170 |* [agg=mold targ=ship]
163171 |= f=$-([agg ship] agg)
@@ -191,21 +199,21 @@
191199 +(agg)
192200::
193201++ run-wildcard-search
194− |* [agg=mold search=search-full =page-info]
202+ |* [agg=mold search=search-full points=opoints =page-info]
195203 |= f=$-([agg @q] agg)
196204 ^- agg
197205 =/ s-syls search-syls.search
198206 ~& s-syls
199207 =/ s-opts search-opts.search
200− =+ =agg
208+ =| =agg
201209 =+ [llb=.~zod rrb=`@q`(sub (bex 32) 1)]
202210 =| agg-count=@
203211 |-
204212 ^- _agg
205− ?~ opoints
213+ ?~ points
206214 :: ~& "nothing here, going up"
207215 agg
208− =* n=@q `@`-.n.opoints
216+ =/ n=@q `@`-.n.points
209217 =/ lrb=@q ?: (gth n 0) (sub-d n 1) .~zod
210218 =/ rlb=@q (add-d n 1)
211219 =/ left-view (range-contains-search llb lrb s-opts)
@@ -213,41 +221,53 @@
213221 :: ~& "left side: {<?:(contains.left-view 'Y' 'N')>} {<llb>} - {<lrb>} contains {<s-opts>}"
214222 =/ right-view (range-contains-search rlb rrb s-opts)
215223 =? agg contains.left-view
216− $(opoints l.opoints, rrb lrb, s-opts opts.left-view)
224+ $(points l.points, rrb lrb, s-opts opts.left-view)
217225 =? agg (matches-search s-syls n)
218226 =/ fits (fits-on-page agg-count page-info)
219227 =. agg-count +(agg-count)
220228 ?: fits (f agg n) agg
221229 :: ~& "right side: {<?:(contains.right-view 'Y' 'N')>} {<rlb>} - {<rrb>} contains {<s-opts>}"
222230 =? agg contains.right-view
223− $(opoints r.opoints, llb rlb, s-opts opts.right-view)
231+ $(points r.points, llb rlb, s-opts opts.right-view)
224232 agg
225233::
226234++ search-opoints
227235 |= =search-text
228236 ^- (list ship)
229237 =/ =search-full (search-text-to-search-full search-text)
238+ =^ spoints search-full
239+ (maybe-reverse-search search-full fopoints ropoints)
230240 =/ results
231− %- (run-wildcard-search (list @q) search-full *page-info)
241+ %-
242+ (run-wildcard-search (list @q) search-full points.spoints *page-info)
232243 |= [agg=(list @q) result=@q]
233244 [result agg]
245+ =? results reversed.spoints
246+ (turn results switch-words)
234247 %- flop
235248 (turn results to-p)
236249::
237250++ sponsor-chain
238− |= =unpoint
239− ^- (list ship)
251+ |= [=ship =unpoint]
252+ ^- (list ^ship)
240253 ?~ unpoint ~
241254 =/ sponsor sponsor.net.u.unpoint
242255 ?. has.sponsor ~
243− [who.sponsor ~] :: todo: lookup parent
256+ =/ spon who.sponsor
257+ ?: =(spon ship) ~
258+ :- spon
259+ =/ spon-point (get-unpoint spon)
260+ $(ship spon, unpoint spon-point)
244261::
245262++ probable-dominion
246− |= =unpoint
263+ |= [=ship =unpoint]
247264 ^- dominion:naive
248265 ?^ unpoint
249266 dominion.u.unpoint
250− %l1 :: todo: lookup parent
267+ =/ parent (^sein:title ship)
268+ ?: =(parent ship) %l1
269+ =/ parent-point (get-unpoint parent)
270+ $(ship parent, unpoint parent-point)
251271::
252272++ read-doc
253273 |= =path
desk/lib/astrolabe.hoon+38−2
@@ -14,6 +14,9 @@
1414++ rev-q
1515 |= a=@
1616 (rev 3 4 a)
17+++ switch-words
18+ |= a=@
19+ (rev 4 2 a)
1720++ add-d
1821 |= [a=@ b=@]
1922 (rev-q (add (rev-q a) b))
@@ -99,6 +102,36 @@
99102 =/ =search-syls (search-text-to-search-syls search-text)
100103 :- search-syls
101104 (search-syls-to-search-opts search-syls)
105+::
106+++ reverse-list :: that is, put first 2 in back "abcd" -> "cdab"
107+ |* lst=(list)
108+ ^- _lst
109+ %+ weld
110+ (slag 2 lst)
111+ (scag 2 lst)
112+++ reverse-search
113+ |= search=search-full
114+ ^- search-full
115+ :- (reverse-list search-syls.search)
116+ (reverse-list search-opts.search)
117+++ estimate-search-pain
118+ |= search=search-full
119+ =/ opts search-opts.search
120+ =| acc=@
121+ |-
122+ ?~ opts acc
123+ =/ new-acc
124+ (add (mul acc 2) (lent i.opts))
125+ $(acc new-acc, opts t.opts)
126+++ maybe-reverse-search
127+ |= [search=search-full fopoints=opoints ropoints=opoints]
128+ ^- [[points=opoints reversed=?] search-full]
129+ =/ search-pain (estimate-search-pain search)
130+ =/ rsearch (reverse-search search)
131+ =/ rsearch-pain (estimate-search-pain rsearch)
132+ ?: (gth search-pain rsearch-pain)
133+ [[ropoints %.y] rsearch]
134+ [[fopoints %.n] search]
102135++ tape-matches
103136 |= [search=tape cand=tape]
104137 ^- ?
@@ -205,12 +238,15 @@
205238 |= =^point
206239 ^- json
207240 =* unpoint unpoint.point
208− ?~ unpoint (pairs ~)
209241 =* npoint u.unpoint
210242 %+ frond %point
211− %- pairs :~
243+ %- pairs :*
244+ ship+(ship ship.point)
212245 spa-count+(numb spa-count.point)
213246 [%probable-dominion s+probable-dominion.point]
247+ [%sponsor-chain a+(turn sponsor-chain.point ship)]
248+ ?~ unpoint ~
249+ :_ ~
214250 :- %npoint
215251 %- pairs :~
216252 [%dominion s+dominion.npoint]
desk/sur/astrolabe.hoon+2−1
@@ -3,7 +3,8 @@
33+$ npoint point:naive
44++ unpoint (unit npoint)
55+$ point
6− $: =unpoint
6+ $: =ship
7+ =unpoint
78 spa-count=@ud
89 sponsor-chain=(list ship)
910 probable-dominion=dominion:naive
ui/src/components/ShipChain.sveltenew file+11
@@ -0,0 +1,11 @@
1+<script lang="ts">
2+ import ShipLink from './ShipLink.svelte';
3+
4+ export let shipChain: string[];
5+</script>
6+
7+{#each shipChain as ship, index}
8+ {#if index > 0}{' > '}{/if}
9+ <ShipLink patp={ship}></ShipLink>
10+{/each}
11+
ui/src/components/ShipView.svelte+37−26
@@ -1,5 +1,4 @@
11<script lang="ts">
2−
32 import UrbitApi from '@urbit/http-api';
43 import { clan, sein, patp2dec } from 'urbit-ob';
54
@@ -11,11 +10,13 @@
1110 import ShipLink from './ShipLink.svelte';
1211 import EthAddressLink from './EthAddressLink.svelte';
1312 import CollapsibleContent from './CollapsibleContent.svelte';
13+ import ShipChain from './ShipChain.svelte';
1414 import ShipListing from './ShipListing.svelte';
1515
1616 export let patp: string;
1717
1818 let parentChain: any[];
19+ let sponsorChain: any[];
1920 let rawPointInfoPromise: any;
2021 let rawPointInfo: any = null;
2122 let pointInfo: any = {};
@@ -124,27 +125,33 @@
124125 'probable-dominion': dominion,
125126 npoint
126127 } = point;
127− spawnedCount = point['spa-count'];
128− life = npoint.net.keys.life;
129− rift = npoint.net.rift;
130− if (life > 0) {
131− keysSet = true;
132− }
133−
134− pointInfo.proxies = npoint.own;
135− // const { dominion } = npoint;
136128 layer = layerOptions[dominion];
137−
138− if (pointInfo.proxies.owner.address === '0x86cd9cd0992f04231751e3761de45cecea5d1801') {
139− spawnStatus = spawnStatusOptions.locked;
140− } else if (keysSet) {
141− spawnStatus = spawnStatusOptions.spawned;
129+ spawnedCount = point['spa-count'];
130+ sponsorChain = point['sponsor-chain'].reverse();
131+ if (npoint) {
132+ life = npoint.net.keys.life;
133+ rift = npoint.net.rift;
134+ if (life > 0) {
135+ keysSet = true;
136+ }
137+
138+ pointInfo.proxies = npoint.own;
139+ if (pointInfo.proxies.owner.address === '0x86cd9cd0992f04231751e3761de45cecea5d1801') {
140+ spawnStatus = spawnStatusOptions.locked;
141+ } else if (keysSet) {
142+ spawnStatus = spawnStatusOptions.spawned;
143+ } else {
144+ spawnStatus = spawnStatusOptions.spawnedNoKeys;
145+ }
146+ // const { sponsor } = npoint.net;
147+ // if (sponsor.has) {
148+ // pointInfo.sponsor = normalizeId(sponsor.who);
149+ // }
142150 } else {
143− spawnStatus = spawnStatusOptions.spawnedNoKeys;
144− }
145− const { sponsor } = npoint.net;
146− if (sponsor.has) {
147− pointInfo.sponsor = normalizeId(sponsor.who);
151+ // no info found
152+ spawnStatus = spawnStatusOptions.unspawned;
153+ life = 0;
154+ rift = 0;
148155 }
149156 } else {
150157 // no info found
@@ -215,10 +222,7 @@
215222 {#if parentChain.length > 0}
216223 <p>
217224 {parentChain.length === 1 ? 'Parent:' : 'Parent Chain:'}
218− {#each parentChain as parent, index}
219− {#if index > 0}{' > '}{/if}
220− <ShipLink patp={parent}></ShipLink>
221− {/each}
225+ <ShipChain shipChain={parentChain}></ShipChain>
222226 </p>
223227 {/if}
224228 {#if azPoint}
@@ -231,8 +235,15 @@
231235 {#if shipClass !== 'galaxy'}
232236 <p>
233237 {#if pointInfo.sponsor && shipClass !== 'galaxy'}
234− Sponsor:
235− <ShipLink patp={pointInfo.sponsor}></ShipLink>
238+ <!-- Sponsor:
239+ <ShipLink patp={pointInfo.sponsor}></ShipLink> -->
240+
241+ {#if sponsorChain.length > 0}
242+ <p>
243+ {sponsorChain.length === 1 ? 'Sponsor:' : 'Sponsor Chain:'}
244+ <ShipChain shipChain={sponsorChain}></ShipChain>
245+ </p>
246+ {/if}
236247 {:else}
237248 Unsponsored
238249 {/if}