on main help sign in
fix search, add sponsor chain and probable dominion
2904f2aJohn Hyde
desk/app/astrolabe.hoon+53−33
@@ -12,7 +12,8 @@
12 ==
12 ==
13+$ state-1
13+$ state-1
14 $: %1
14 $: %1
15− =opoints
15+ fopoints=opoints :: forward ordered points
16+ ropoints=opoints :: reversed ordered points, e.g. .~palnet-sampel
16 ==
17 ==
17::
18::
18+$ spawned (jug ship ship)
19+$ spawned (jug ship ship)
@@ -114,26 +115,28 @@
114++ get-nas .^(^state:naive %gx (scrio %azimuth /nas/noun))
115++ get-nas .^(^state:naive %gx (scrio %azimuth /nas/noun))
115++ put-in-opoints
116++ put-in-opoints
116 |= =ship
117 |= =ship
117− ^- _opoints
118+ ^- _state
119+ =. fopoints
120+ (put:ors fopoints (to-q ship) ~)
121+ =. ropoints
118− (put:ors opoints (to-q ship) ~)
122+ (put:ors ropoints (switch-words (to-q ship)) ~)
123+ state
119++ on-naive-state
124++ on-naive-state
120 |= nas=^state:naive
125 |= nas=^state:naive
121 ^- (quip card _state)
126 ^- (quip card _state)
122 =+ points=points.nas :: =points, eh?
127 =+ points=points.nas :: =points, eh?
123− =. opoints
128+ :- ~
124− |-
129+ |-
125− ^- _opoints
130+ ^- _state
126− ?~ points opoints
131+ ?~ points state
127− =/ =ship -.n.points
132+ =/ =ship -.n.points
128− :: traverse tree of points and add @ps to opoints with ^sein, you know
129− =. opoints (put-in-opoints ship)
133+ =. state (put-in-opoints ship)
130− $(points l.points, opoints $(points r.points))
134+ $(points l.points, state $(points r.points))
131− `state
132::
135::
133++ on-naive-diff
136++ on-naive-diff
134 |= =diff:naive
137 |= =diff:naive
135 ^- (quip card _state)
138 ^- (quip card _state)
136− =? opoints ?=([%tx [* * * %spawn ship *] *] diff)
139+ =? state ?=([%tx [* * * %spawn ship *] *] diff)
137 %- put-in-opoints
140 %- put-in-opoints
138 ship.tx.raw-tx.diff
141 ship.tx.raw-tx.diff
139 `state
142 `state
@@ -143,21 +146,26 @@
143 ^- ?
146 ^- ?
144 ?= [%tx [* * * %spawn ship *] *] diff
147 ?= [%tx [* * * %spawn ship *] *] diff
145::
148::
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+::
146++ get-point
157++ get-point
147 |= ship-name=term
158 |= ship-name=term
148 ^- point
159 ^- point
149 =/ =ship `@p`(slav %p ship-name)
160 =/ =ship `@p`(slav %p ship-name)
150− =/ unpoint (get-unpoint ship-name)
161+ =/ unpoint (get-unpoint-term ship-name)
162+ :* ship
151− :* unpoint
163+ unpoint
152 (spa-count ship)
164 (spa-count ship)
153− (sponsor-chain unpoint)
165+ (sponsor-chain ship unpoint)
154− (probable-dominion unpoint)
166+ (probable-dominion ship unpoint)
155 ==
167 ==
156::
168::
157−++ get-unpoint
158− |= ship-name=term
159− .^(unpoint %gx (scrio %azimuth /point/[ship-name]/noun))
160−::
161++ run-spawned-points
169++ run-spawned-points
162 |* [agg=mold targ=ship]
170 |* [agg=mold targ=ship]
163 |= f=$-([agg ship] agg)
171 |= f=$-([agg ship] agg)
@@ -191,21 +199,21 @@
191 +(agg)
199 +(agg)
192::
200::
193++ run-wildcard-search
201++ run-wildcard-search
194− |* [agg=mold search=search-full =page-info]
202+ |* [agg=mold search=search-full points=opoints =page-info]
195 |= f=$-([agg @q] agg)
203 |= f=$-([agg @q] agg)
196 ^- agg
204 ^- agg
197 =/ s-syls search-syls.search
205 =/ s-syls search-syls.search
198 ~& s-syls
206 ~& s-syls
199 =/ s-opts search-opts.search
207 =/ s-opts search-opts.search
200− =+ =agg
208+ =| =agg
201 =+ [llb=.~zod rrb=`@q`(sub (bex 32) 1)]
209 =+ [llb=.~zod rrb=`@q`(sub (bex 32) 1)]
202 =| agg-count=@
210 =| agg-count=@
203 |-
211 |-
204 ^- _agg
212 ^- _agg
205− ?~ opoints
213+ ?~ points
206 :: ~& "nothing here, going up"
214 :: ~& "nothing here, going up"
207 agg
215 agg
208− =* n=@q `@`-.n.opoints
216+ =/ n=@q `@`-.n.points
209 =/ lrb=@q ?: (gth n 0) (sub-d n 1) .~zod
217 =/ lrb=@q ?: (gth n 0) (sub-d n 1) .~zod
210 =/ rlb=@q (add-d n 1)
218 =/ rlb=@q (add-d n 1)
211 =/ left-view (range-contains-search llb lrb s-opts)
219 =/ left-view (range-contains-search llb lrb s-opts)
@@ -213,41 +221,53 @@
213 :: ~& "left side: {<?:(contains.left-view 'Y' 'N')>} {<llb>} - {<lrb>} contains {<s-opts>}"
221 :: ~& "left side: {<?:(contains.left-view 'Y' 'N')>} {<llb>} - {<lrb>} contains {<s-opts>}"
214 =/ right-view (range-contains-search rlb rrb s-opts)
222 =/ right-view (range-contains-search rlb rrb s-opts)
215 =? agg contains.left-view
223 =? 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)
217 =? agg (matches-search s-syls n)
225 =? agg (matches-search s-syls n)
218 =/ fits (fits-on-page agg-count page-info)
226 =/ fits (fits-on-page agg-count page-info)
219 =. agg-count +(agg-count)
227 =. agg-count +(agg-count)
220 ?: fits (f agg n) agg
228 ?: fits (f agg n) agg
221 :: ~& "right side: {<?:(contains.right-view 'Y' 'N')>} {<rlb>} - {<rrb>} contains {<s-opts>}"
229 :: ~& "right side: {<?:(contains.right-view 'Y' 'N')>} {<rlb>} - {<rrb>} contains {<s-opts>}"
222 =? agg contains.right-view
230 =? 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)
224 agg
232 agg
225::
233::
226++ search-opoints
234++ search-opoints
227 |= =search-text
235 |= =search-text
228 ^- (list ship)
236 ^- (list ship)
229 =/ =search-full (search-text-to-search-full search-text)
237 =/ =search-full (search-text-to-search-full search-text)
238+ =^ spoints search-full
239+ (maybe-reverse-search search-full fopoints ropoints)
230 =/ results
240 =/ results
241+ %-
231− %- (run-wildcard-search (list @q) search-full *page-info)
242+ (run-wildcard-search (list @q) search-full points.spoints *page-info)
232 |= [agg=(list @q) result=@q]
243 |= [agg=(list @q) result=@q]
233 [result agg]
244 [result agg]
245+ =? results reversed.spoints
246+ (turn results switch-words)
234 %- flop
247 %- flop
235 (turn results to-p)
248 (turn results to-p)
236::
249::
237++ sponsor-chain
250++ sponsor-chain
238− |= =unpoint
251+ |= [=ship =unpoint]
239− ^- (list ship)
252+ ^- (list ^ship)
240 ?~ unpoint ~
253 ?~ unpoint ~
241 =/ sponsor sponsor.net.u.unpoint
254 =/ sponsor sponsor.net.u.unpoint
242 ?. has.sponsor ~
255 ?. 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)
244::
261::
245++ probable-dominion
262++ probable-dominion
246− |= =unpoint
263+ |= [=ship =unpoint]
247 ^- dominion:naive
264 ^- dominion:naive
248 ?^ unpoint
265 ?^ unpoint
249 dominion.u.unpoint
266 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)
251::
271::
252++ read-doc
272++ read-doc
253 |= =path
273 |= =path
desk/lib/astrolabe.hoon+38−2
@@ -14,6 +14,9 @@
14++ rev-q
14++ rev-q
15 |= a=@
15 |= a=@
16 (rev 3 4 a)
16 (rev 3 4 a)
17+++ switch-words
18+ |= a=@
19+ (rev 4 2 a)
17++ add-d
20++ add-d
18 |= [a=@ b=@]
21 |= [a=@ b=@]
19 (rev-q (add (rev-q a) b))
22 (rev-q (add (rev-q a) b))
@@ -99,6 +102,36 @@
99 =/ =search-syls (search-text-to-search-syls search-text)
102 =/ =search-syls (search-text-to-search-syls search-text)
100 :- search-syls
103 :- search-syls
101 (search-syls-to-search-opts search-syls)
104 (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]
102++ tape-matches
135++ tape-matches
103 |= [search=tape cand=tape]
136 |= [search=tape cand=tape]
104 ^- ?
137 ^- ?
@@ -205,12 +238,15 @@
205 |= =^point
238 |= =^point
206 ^- json
239 ^- json
207 =* unpoint unpoint.point
240 =* unpoint unpoint.point
208− ?~ unpoint (pairs ~)
209 =* npoint u.unpoint
241 =* npoint u.unpoint
210 %+ frond %point
242 %+ frond %point
211− %- pairs :~
243+ %- pairs :*
244+ ship+(ship ship.point)
212 spa-count+(numb spa-count.point)
245 spa-count+(numb spa-count.point)
213 [%probable-dominion s+probable-dominion.point]
246 [%probable-dominion s+probable-dominion.point]
247+ [%sponsor-chain a+(turn sponsor-chain.point ship)]
248+ ?~ unpoint ~
249+ :_ ~
214 :- %npoint
250 :- %npoint
215 %- pairs :~
251 %- pairs :~
216 [%dominion s+dominion.npoint]
252 [%dominion s+dominion.npoint]
desk/sur/astrolabe.hoon+2−1
@@ -3,7 +3,8 @@
3+$ npoint point:naive
3+$ npoint point:naive
4++ unpoint (unit npoint)
4++ unpoint (unit npoint)
5+$ point
5+$ point
6+ $: =ship
6− $: =unpoint
7+ =unpoint
7 spa-count=@ud
8 spa-count=@ud
8 sponsor-chain=(list ship)
9 sponsor-chain=(list ship)
9 probable-dominion=dominion:naive
10 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 @@
1<script lang="ts">
1<script lang="ts">
2−
3 import UrbitApi from '@urbit/http-api';
2 import UrbitApi from '@urbit/http-api';
4 import { clan, sein, patp2dec } from 'urbit-ob';
3 import { clan, sein, patp2dec } from 'urbit-ob';
5
4
@@ -11,11 +10,13 @@
11 import ShipLink from './ShipLink.svelte';
10 import ShipLink from './ShipLink.svelte';
12 import EthAddressLink from './EthAddressLink.svelte';
11 import EthAddressLink from './EthAddressLink.svelte';
13 import CollapsibleContent from './CollapsibleContent.svelte';
12 import CollapsibleContent from './CollapsibleContent.svelte';
13+ import ShipChain from './ShipChain.svelte';
14 import ShipListing from './ShipListing.svelte';
14 import ShipListing from './ShipListing.svelte';
15
15
16 export let patp: string;
16 export let patp: string;
17
17
18 let parentChain: any[];
18 let parentChain: any[];
19+ let sponsorChain: any[];
19 let rawPointInfoPromise: any;
20 let rawPointInfoPromise: any;
20 let rawPointInfo: any = null;
21 let rawPointInfo: any = null;
21 let pointInfo: any = {};
22 let pointInfo: any = {};
@@ -124,27 +125,33 @@
124 'probable-dominion': dominion,
125 'probable-dominion': dominion,
125 npoint
126 npoint
126 } = point;
127 } = 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;
136 layer = layerOptions[dominion];
128 layer = layerOptions[dominion];
137−
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;
138− if (pointInfo.proxies.owner.address === '0x86cd9cd0992f04231751e3761de45cecea5d1801') {
139+ if (pointInfo.proxies.owner.address === '0x86cd9cd0992f04231751e3761de45cecea5d1801') {
139− spawnStatus = spawnStatusOptions.locked;
140+ spawnStatus = spawnStatusOptions.locked;
140− } else if (keysSet) {
141+ } else if (keysSet) {
141− spawnStatus = spawnStatusOptions.spawned;
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+ // }
142 } else {
150 } else {
151+ // no info found
143− spawnStatus = spawnStatusOptions.spawnedNoKeys;
152+ spawnStatus = spawnStatusOptions.unspawned;
144− }
153+ life = 0;
145− const { sponsor } = npoint.net;
154+ rift = 0;
146− if (sponsor.has) {
147− pointInfo.sponsor = normalizeId(sponsor.who);
148 }
155 }
149 } else {
156 } else {
150 // no info found
157 // no info found
@@ -215,10 +222,7 @@
215 {#if parentChain.length > 0}
222 {#if parentChain.length > 0}
216 <p>
223 <p>
217 {parentChain.length === 1 ? 'Parent:' : 'Parent Chain:'}
224 {parentChain.length === 1 ? 'Parent:' : 'Parent Chain:'}
218− {#each parentChain as parent, index}
225+ <ShipChain shipChain={parentChain}></ShipChain>
219− {#if index > 0}{' > '}{/if}
220− <ShipLink patp={parent}></ShipLink>
221− {/each}
222 </p>
226 </p>
223 {/if}
227 {/if}
224 {#if azPoint}
228 {#if azPoint}
@@ -231,8 +235,15 @@
231 {#if shipClass !== 'galaxy'}
235 {#if shipClass !== 'galaxy'}
232 <p>
236 <p>
233 {#if pointInfo.sponsor && shipClass !== 'galaxy'}
237 {#if pointInfo.sponsor && shipClass !== 'galaxy'}
234− Sponsor:
238+ <!-- Sponsor:
235− <ShipLink patp={pointInfo.sponsor}></ShipLink>
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}
236 {:else}
247 {:else}
237 Unsponsored
248 Unsponsored
238 {/if}
249 {/if}