mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-24 23:44:56 +03:00
Merge branch 'dist' into hm/grid-system-preferences
This commit is contained in:
commit
2d0eb3178f
11
.vercel/README.txt
Normal file
11
.vercel/README.txt
Normal file
@ -0,0 +1,11 @@
|
||||
> Why do I have a folder named ".vercel" in my project?
|
||||
The ".vercel" folder is created when you link a directory to a Vercel project.
|
||||
|
||||
> What does the "project.json" file contain?
|
||||
The "project.json" file contains:
|
||||
- The ID of the Vercel project that you linked ("projectId")
|
||||
- The ID of the user or team your Vercel project is owned by ("orgId")
|
||||
|
||||
> Should I commit the ".vercel" folder?
|
||||
No, you should not share the ".vercel" folder with anyone.
|
||||
Upon creation, it will be automatically added to your ".gitignore" file.
|
1
.vercel/project.json
Normal file
1
.vercel/project.json
Normal file
@ -0,0 +1 @@
|
||||
{"orgId":"EDiU8DZExvM9N4unZGYQbG3d","projectId":"prj_fbAU5smemBgtr5t8lsk5ZoT9zNtI"}
|
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:42b81ff30114d982a485d851879bd3f4abbfaa6272351eaca717e10370af293e
|
||||
size 13645079
|
||||
oid sha256:b8972fd91602b0d2cca76ade229d11aaaca0bc3c89da53c42f4f12895190b4b2
|
||||
size 13762742
|
||||
|
@ -1356,7 +1356,7 @@
|
||||
++ complete-naked-poke
|
||||
|= app=term
|
||||
=/ pax=path
|
||||
/(scot %p our.hid)/[q.byk.hid]/(scot %da now.hid)/app
|
||||
/(scot %p our.hid)/[q:he-beam]/(scot %da now.hid)/app
|
||||
%+ complete (cat 3 ':' app)
|
||||
%+ murn ~(tap by dir:.^(arch %cy pax))
|
||||
|= [=term ~]
|
||||
@ -1386,7 +1386,7 @@
|
||||
(cat 3 '|' gen)
|
||||
:((cury cat 3) ':' app '|' gen)
|
||||
=/ pfix=path
|
||||
/(scot %p our.hid)/[q.byk.hid]/(scot %da now.hid)/gen/[app]
|
||||
/(scot %p our.hid)/[q:he-beam]/(scot %da now.hid)/gen/[app]
|
||||
::
|
||||
%^ tab-generators:auto pfix `app
|
||||
%+ murn
|
||||
@ -1402,7 +1402,7 @@
|
||||
|= gen=term
|
||||
%+ complete (cat 3 '+' gen)
|
||||
=/ pax=path
|
||||
/(scot %p our.hid)/[q.byk.hid]/(scot %da now.hid)/gen
|
||||
/(scot %p our.hid)/[q:he-beam]/(scot %da now.hid)/gen
|
||||
%^ tab-generators:auto pax ~
|
||||
%+ murn
|
||||
~(tap by dir:.^(arch %cy pax))
|
||||
|
@ -1,10 +1,23 @@
|
||||
/+ default-agent
|
||||
/+ drum=hood-drum, helm=hood-helm, kiln=hood-kiln
|
||||
|%
|
||||
+$ state [%16 any-state-tuple]
|
||||
+$ state
|
||||
$~ [%17 *state:drum *state:helm *state:kiln]
|
||||
$>(%17 any-state)
|
||||
::
|
||||
+$ any-state
|
||||
$% [ver=?(%1 %2 %3 %4 %5 %6) lac=(map @tas fin-any-state)]
|
||||
[ver=?(%7 %8 %9 %10 %11 %12 %13 %14 %15 %16) any-state-tuple]
|
||||
[%7 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%8 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%9 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%10 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%11 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%12 drum=state-2:drum helm=state:helm kiln=state-0:kiln]
|
||||
[%13 drum=state-2:drum helm=state:helm kiln=state-1:kiln]
|
||||
[%14 drum=state-3:drum helm=state:helm kiln=state-1:kiln]
|
||||
[%15 drum=state-3:drum helm=state:helm kiln=state-2:kiln]
|
||||
[%16 drum=state-4:drum helm=state:helm kiln=state-3:kiln]
|
||||
[%17 drum=state-4:drum helm=state:helm kiln=state-4:kiln]
|
||||
==
|
||||
+$ any-state-tuple
|
||||
$: drum=any-state:drum
|
||||
@ -55,9 +68,9 @@
|
||||
=-(?>(?=(%kiln -<) ->) (~(got by lac.old) %kiln))
|
||||
==
|
||||
==
|
||||
=^ d drum.state (on-load:drum-core -.old drum.tup)
|
||||
=^ h helm.state (on-load:helm-core -.old helm.tup)
|
||||
=^ k kiln.state (on-load:kiln-core -.old kiln.tup)
|
||||
=^ d drum.state (on-load:(drum bowl *state:drum) -.old drum.tup)
|
||||
=^ h helm.state (on-load:(helm bowl *state:helm) -.old helm.tup)
|
||||
=^ k kiln.state (on-load:(kiln bowl *state:kiln) -.old kiln.tup)
|
||||
[:(welp d h k) this]
|
||||
::
|
||||
++ on-poke
|
||||
|
@ -285,17 +285,17 @@
|
||||
~/ %handle-http-request
|
||||
|= [eyre-id=@ta =inbound-request:eyre]
|
||||
^- (quip card _state)
|
||||
?> authenticated.inbound-request
|
||||
::?> authenticated.inbound-request
|
||||
=/ url
|
||||
(parse-request-line:server url.request.inbound-request)
|
||||
?> ?=([%spider @t @t @t ~] site.url)
|
||||
=* input-mark i.t.site.url
|
||||
=* thread i.t.t.site.url
|
||||
=* output-mark i.t.t.t.site.url
|
||||
?> ?=([%spider @t @t @t @t ~] site.url)
|
||||
=* desk i.t.site.url
|
||||
=* input-mark i.t.t.site.url
|
||||
=* thread i.t.t.t.site.url
|
||||
=* output-mark i.t.t.t.t.site.url
|
||||
=/ =tid (new-thread-id thread)
|
||||
=. serving.state
|
||||
(~(put by serving.state) tid [eyre-id output-mark])
|
||||
=/ =desk %landscape :: TODO: make this generic
|
||||
:: TODO: speed this up somehow. we spend about 15ms in this arm alone
|
||||
::
|
||||
=+ .^
|
||||
|
@ -1,7 +1,7 @@
|
||||
:- %say
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
~ ~
|
||||
~
|
||||
check=_&
|
||||
except=(set desk)
|
||||
==
|
||||
:- %kiln-bump
|
||||
~
|
||||
|
||||
[%kiln-bump except check]
|
||||
|
16
pkg/arvo/gen/hood/rein.hoon
Normal file
16
pkg/arvo/gen/hood/rein.hoon
Normal file
@ -0,0 +1,16 @@
|
||||
/- hood
|
||||
:- %say
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
$: =desk
|
||||
arg=(list [? dude:gall])
|
||||
==
|
||||
liv=_&
|
||||
==
|
||||
:- %kiln-rein
|
||||
:- desk
|
||||
%+ roll arg
|
||||
=| =rein:hood
|
||||
|: [*[on=? =dude:gall] rein(liv liv)]
|
||||
?: on
|
||||
rein(add (~(put in add.rein) dude))
|
||||
rein(sub (~(put in sub.rein) dude))
|
5
pkg/arvo/gen/hood/revive.hoon
Normal file
5
pkg/arvo/gen/hood/revive.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:- %say
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
[[=desk ~] ~]
|
||||
==
|
||||
[%kiln-revive desk]
|
5
pkg/arvo/gen/hood/suspend.hoon
Normal file
5
pkg/arvo/gen/hood/suspend.hoon
Normal file
@ -0,0 +1,5 @@
|
||||
:- %say
|
||||
|= $: [now=@da eny=@uvJ bec=beak]
|
||||
[[=desk ~] ~]
|
||||
==
|
||||
[%kiln-suspend desk]
|
@ -1,135 +0,0 @@
|
||||
=>
|
||||
|%
|
||||
++ card card:agent:gall
|
||||
--
|
||||
::
|
||||
|_ =bowl:gall
|
||||
++ scry
|
||||
|= [desk=@tas =path]
|
||||
%+ weld
|
||||
/(scot %p our.bowl)/[desk]/(scot %da now.bowl)
|
||||
path
|
||||
::
|
||||
++ pass
|
||||
|_ =wire
|
||||
++ poke
|
||||
|= [=dock =cage]
|
||||
[%pass wire %agent dock %poke cage]
|
||||
::
|
||||
++ poke-our
|
||||
|= [app=term =cage]
|
||||
^- card
|
||||
(poke [our.bowl app] cage)
|
||||
::
|
||||
++ poke-self
|
||||
|= =cage
|
||||
^- card
|
||||
(poke-our dap.bowl cage)
|
||||
::
|
||||
++ arvo
|
||||
|= =note-arvo
|
||||
^- card
|
||||
[%pass wire %arvo note-arvo]
|
||||
::
|
||||
++ watch
|
||||
|= [=dock =path]
|
||||
[%pass (watch-wire path) %agent dock %watch path]
|
||||
::
|
||||
++ watch-our
|
||||
|= [app=term =path]
|
||||
(watch [our.bowl app] path)
|
||||
::
|
||||
++ watch-wire
|
||||
|= =path
|
||||
^+ wire
|
||||
?. ?=(~ wire)
|
||||
wire
|
||||
agentio-watch+path
|
||||
::
|
||||
++ leave
|
||||
|= =dock
|
||||
[%pass wire %agent dock %leave ~]
|
||||
::
|
||||
++ leave-our
|
||||
|= app=term
|
||||
(leave our.bowl app)
|
||||
::
|
||||
++ leave-path
|
||||
|= [=dock =path]
|
||||
=. wire
|
||||
(watch-wire path)
|
||||
(leave dock)
|
||||
::
|
||||
++ wait
|
||||
|= p=@da
|
||||
(arvo %b %wait p)
|
||||
::
|
||||
++ rest
|
||||
|= p=@da
|
||||
(arvo %b %wait p)
|
||||
::
|
||||
++ warp
|
||||
|= [wer=ship =riff:clay]
|
||||
(arvo %c %warp wer riff)
|
||||
::
|
||||
++ warp-our
|
||||
|= =riff:clay
|
||||
(warp our.bowl riff)
|
||||
::
|
||||
:: right here, right now
|
||||
++ warp-slim
|
||||
|= [genre=?(%sing %next) =care:clay =path]
|
||||
=/ =mood:clay
|
||||
[care r.byk.bowl path]
|
||||
=/ =rave:clay
|
||||
?:(?=(%sing genre) [genre mood] [genre mood])
|
||||
(warp-our q.byk.bowl `rave)
|
||||
--
|
||||
::
|
||||
++ fact-curry
|
||||
|* [=mark =mold]
|
||||
|= [paths=(list path) fac=mold]
|
||||
(fact mark^!>(fac) paths)
|
||||
::
|
||||
++ fact-kick
|
||||
|= [=path =cage]
|
||||
^- (list card)
|
||||
:~ (fact cage ~[path])
|
||||
(kick ~[path])
|
||||
==
|
||||
::
|
||||
++ fact-init
|
||||
|= =cage
|
||||
^- card
|
||||
[%give %fact ~ cage]
|
||||
::
|
||||
++ fact-init-kick
|
||||
|= =cage
|
||||
^- (list card)
|
||||
:~ (fact cage ~)
|
||||
(kick ~)
|
||||
==
|
||||
::
|
||||
++ fact
|
||||
|= [=cage paths=(list path)]
|
||||
^- card
|
||||
[%give %fact paths cage]
|
||||
::
|
||||
++ fact-all
|
||||
|= =cage
|
||||
^- (unit card)
|
||||
=/ paths=(list path)
|
||||
%+ turn ~(tap by sup.bowl)
|
||||
|= [duct ship =path]
|
||||
path
|
||||
?~ paths ~
|
||||
`[%give %fact paths cage]
|
||||
::
|
||||
++ kick
|
||||
|= paths=(list path)
|
||||
[%give %kick paths ~]
|
||||
::
|
||||
++ kick-only
|
||||
|= [=ship paths=(list path)]
|
||||
[%give %kick paths `ship]
|
||||
--
|
1
pkg/arvo/lib/agentio.hoon
Symbolic link
1
pkg/arvo/lib/agentio.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/agentio.hoon
|
@ -1,454 +0,0 @@
|
||||
:: azimuth: constants and utilities
|
||||
::
|
||||
/+ ethereum
|
||||
::
|
||||
=> => [azimuth-types ethereum-types .]
|
||||
|%
|
||||
+$ complete-ship
|
||||
$: state=point
|
||||
history=(list diff-point) ::TODO maybe block/event nr? :: newest first
|
||||
keys=(map life pass)
|
||||
==
|
||||
::
|
||||
++ fleet (map @p complete-ship)
|
||||
::
|
||||
++ eth-type
|
||||
|%
|
||||
++ point
|
||||
:~ [%bytes-n 32] :: encryptionKey
|
||||
[%bytes-n 32] :: authenticationKey
|
||||
%bool :: hasSponsor
|
||||
%bool :: active
|
||||
%bool :: escapeRequested
|
||||
%uint :: sponsor
|
||||
%uint :: escapeRequestedTo
|
||||
%uint :: cryptoSuiteVersion
|
||||
%uint :: keyRevisionNumber
|
||||
%uint :: continuityNumber
|
||||
==
|
||||
++ deed
|
||||
:~ %address :: owner
|
||||
%address :: managementProxy
|
||||
%address :: spawnProxy
|
||||
%address :: votingProxy
|
||||
%address :: transferProxy
|
||||
==
|
||||
--
|
||||
::
|
||||
++ eth-noun
|
||||
|%
|
||||
+$ point
|
||||
$: encryption-key=octs
|
||||
authentication-key=octs
|
||||
has-sponsor=?
|
||||
active=?
|
||||
escape-requested=?
|
||||
sponsor=@ud
|
||||
escape-to=@ud
|
||||
crypto-suite=@ud
|
||||
key-revision=@ud
|
||||
continuity-number=@ud
|
||||
==
|
||||
+$ deed
|
||||
$: owner=address
|
||||
management-proxy=address
|
||||
spawn-proxy=address
|
||||
voting-proxy=address
|
||||
transfer-proxy=address
|
||||
==
|
||||
--
|
||||
::
|
||||
++ function
|
||||
|%
|
||||
++ azimuth
|
||||
$% [%points who=@p]
|
||||
[%rights who=@p]
|
||||
[%get-spawned who=@p]
|
||||
[%dns-domains ind=@ud]
|
||||
==
|
||||
--
|
||||
::
|
||||
:: # diffs
|
||||
::
|
||||
++ update
|
||||
$% [%full ships=(map ship point) dns=dnses heard=events]
|
||||
[%difs dis=(list (pair event-id diff-azimuth))]
|
||||
==
|
||||
::
|
||||
:: # constants
|
||||
::
|
||||
:: contract addresses
|
||||
++ contracts mainnet-contracts
|
||||
++ mainnet-contracts
|
||||
|%
|
||||
:: azimuth: data contract
|
||||
::
|
||||
++ azimuth
|
||||
0x223c.067f.8cf2.8ae1.73ee.5caf.ea60.ca44.c335.fecb
|
||||
::
|
||||
++ ecliptic
|
||||
0x6ac0.7b7c.4601.b5ce.11de.8dfe.6335.b871.c7c4.dd4d
|
||||
::
|
||||
++ linear-star-release
|
||||
0x86cd.9cd0.992f.0423.1751.e376.1de4.5cec.ea5d.1801
|
||||
::
|
||||
++ conditional-star-release
|
||||
0x8c24.1098.c3d3.498f.e126.1421.633f.d579.86d7.4aea
|
||||
::
|
||||
++ delegated-sending
|
||||
0xf790.8ab1.f1e3.52f8.3c5e.bc75.051c.0565.aeae.a5fb
|
||||
::
|
||||
:: launch: block number of azimuth deploy
|
||||
::
|
||||
++ launch 6.784.800
|
||||
::
|
||||
:: public: block number of azimuth becoming independent
|
||||
::
|
||||
++ public 7.033.765
|
||||
--
|
||||
::
|
||||
:: Testnet contract addresses
|
||||
::
|
||||
++ ropsten-contracts
|
||||
|%
|
||||
++ azimuth
|
||||
0x308a.b6a6.024c.f198.b57e.008d.0ac9.ad02.1988.6579
|
||||
::
|
||||
++ ecliptic
|
||||
0x8b9f.86a2.8921.d9c7.05b3.113a.755f.b979.e1bd.1bce
|
||||
::
|
||||
++ linear-star-release
|
||||
0x1f8e.dd03.1ee4.1474.0aed.b39b.84fb.8f2f.66ca.422f
|
||||
::
|
||||
++ conditional-star-release
|
||||
0x0
|
||||
::
|
||||
++ delegated-sending
|
||||
0x3e8c.a510.354b.c2fd.bbd6.1502.52d9.3105.c9c2.7bbe
|
||||
::
|
||||
++ launch 4.601.630
|
||||
++ public launch
|
||||
--
|
||||
::
|
||||
:: Local contract addresses
|
||||
::
|
||||
:: These addresses are only reproducible if you use the deploy
|
||||
:: script in bridge
|
||||
::
|
||||
++ local-contracts
|
||||
|%
|
||||
++ ecliptic
|
||||
0x56db.68f2.9203.ff44.a803.faa2.404a.44ec.bb7a.7480
|
||||
++ azimuth
|
||||
0x863d.9c2e.5c4c.1335.96cf.ac29.d552.55f0.d0f8.6381
|
||||
++ delegated-sending
|
||||
0xb71c.0b6c.ee1b.cae5.6dfe.95cd.9d3e.41dd.d7ea.fc43
|
||||
++ linear-star-release
|
||||
0x3c3.dc12.be65.8158.d1d7.f9e6.6e08.ec40.99c5.68e4
|
||||
++ conditional-star-release
|
||||
0x35eb.3b10.2d9c.1b69.ac14.69c1.b1fe.1799.850c.d3eb
|
||||
++ launch 0
|
||||
++ public 0
|
||||
--
|
||||
::
|
||||
:: ++ azimuth 0x863d.9c2e.5c4c.1335.96cf.ac29.d552.55f0.d0f8.6381 :: local bridge
|
||||
:: hashes of ship event signatures
|
||||
++ azimuth-events
|
||||
|%
|
||||
::
|
||||
:: OwnerChanged(uint32,address)
|
||||
++ owner-changed
|
||||
0x16d0.f539.d49c.6cad.822b.767a.9445.bfb1.
|
||||
cf7e.a6f2.a6c2.b120.a7ea.4cc7.660d.8fda
|
||||
::
|
||||
:: Activated(uint32)
|
||||
++ activated
|
||||
0xe74c.0380.9d07.69e1.b1f7.06cc.8414.258c.
|
||||
d1f3.b6fe.020c.d15d.0165.c210.ba50.3a0f
|
||||
::
|
||||
:: Spawned(uint32,uint32)
|
||||
++ spawned
|
||||
0xb2d3.a6e7.a339.f5c8.ff96.265e.2f03.a010.
|
||||
a854.1070.f374.4a24.7090.9644.1508.1546
|
||||
::
|
||||
:: EscapeRequested(uint32,uint32)
|
||||
++ escape-requested
|
||||
0xb4d4.850b.8f21.8218.141c.5665.cba3.79e5.
|
||||
3e9b.b015.b51e.8d93.4be7.0210.aead.874a
|
||||
::
|
||||
:: EscapeCanceled(uint32,uint32)
|
||||
++ escape-canceled
|
||||
0xd653.bb0e.0bb7.ce83.93e6.24d9.8fbf.17cd.
|
||||
a590.2c83.28ed.0cd0.9988.f368.90d9.932a
|
||||
::
|
||||
:: EscapeAccepted(uint32,uint32)
|
||||
++ escape-accepted
|
||||
0x7e44.7c9b.1bda.4b17.4b07.96e1.00bf.7f34.
|
||||
ebf3.6dbb.7fe6.6549.0b1b.fce6.246a.9da5
|
||||
::
|
||||
:: LostSponsor(uint32,uint32)
|
||||
++ lost-sponsor
|
||||
0xd770.4f9a.2519.3dbd.0b0c.b4a8.09fe.ffff.
|
||||
a7f1.9d1a.ae88.17a7.1346.c194.4482.10d5
|
||||
::
|
||||
:: ChangedKeys(uint32,bytes32,bytes32,uint32,uint32)
|
||||
++ changed-keys
|
||||
0xaa10.e7a0.117d.4323.f1d9.9d63.0ec1.69be.
|
||||
bb3a.988e.8957.70e3.5198.7e01.ff54.23d5
|
||||
::
|
||||
:: BrokeContinuity(uint32,uint32)
|
||||
++ broke-continuity
|
||||
0x2929.4799.f1c2.1a37.ef83.8e15.f79d.d91b.
|
||||
cee2.df99.d63c.d1c1.8ac9.68b1.2951.4e6e
|
||||
::
|
||||
:: ChangedSpawnProxy(uint32,address)
|
||||
++ changed-spawn-proxy
|
||||
0x9027.36af.7b3c.efe1.0d9e.840a.ed0d.687e.
|
||||
35c8.4095.122b.2505.1a20.ead8.866f.006d
|
||||
::
|
||||
:: ChangedTransferProxy(uint32,address)
|
||||
++ changed-transfer-proxy
|
||||
0xcfe3.69b7.197e.7f0c.f067.93ae.2472.a9b1.
|
||||
3583.fecb.ed2f.78df.a14d.1f10.796b.847c
|
||||
::
|
||||
:: ChangedManagementProxy(uint32,address)
|
||||
++ changed-management-proxy
|
||||
0xab9c.9327.cffd.2acc.168f.afed.be06.139f.
|
||||
5f55.cb84.c761.df05.e051.1c25.1e2e.e9bf
|
||||
::
|
||||
:: ChangedVotingProxy(uint32,address)
|
||||
++ changed-voting-proxy
|
||||
0xcbd6.269e.c714.57f2.c7b1.a227.74f2.46f6.
|
||||
c5a2.eae3.795e.d730.0db5.1768.0c61.c805
|
||||
::
|
||||
:: ChangedDns(string,string,string)
|
||||
++ changed-dns
|
||||
0xfafd.04ad.e1da.ae2e.1fdb.0fc1.cc6a.899f.
|
||||
d424.063e.d5c9.2120.e67e.0730.53b9.4898
|
||||
--
|
||||
--
|
||||
::
|
||||
:: logic
|
||||
::
|
||||
|%
|
||||
++ pass-from-eth
|
||||
|= [enc=octs aut=octs sut=@ud]
|
||||
^- pass
|
||||
%^ cat 3 'b'
|
||||
?. &(=(1 sut) =(p.enc 32) =(p.aut 32))
|
||||
(cat 8 0 0)
|
||||
(cat 8 q.aut q.enc)
|
||||
::
|
||||
++ point-from-eth
|
||||
|= [who=@p point:eth-noun deed:eth-noun]
|
||||
^- point
|
||||
::
|
||||
:: ownership
|
||||
::
|
||||
:+ :* owner
|
||||
management-proxy
|
||||
voting-proxy
|
||||
transfer-proxy
|
||||
==
|
||||
::
|
||||
:: network state
|
||||
::
|
||||
?. active ~
|
||||
:- ~
|
||||
:* key-revision
|
||||
::
|
||||
(pass-from-eth encryption-key authentication-key crypto-suite)
|
||||
::
|
||||
continuity-number
|
||||
::
|
||||
[has-sponsor `@p`sponsor]
|
||||
::
|
||||
?. escape-requested ~
|
||||
``@p`escape-to
|
||||
==
|
||||
::
|
||||
:: spawn state
|
||||
::
|
||||
?. ?=(?(%czar %king) (clan:title who)) ~
|
||||
:- ~
|
||||
:* spawn-proxy
|
||||
~ ::TODO call getSpawned to fill this
|
||||
==
|
||||
::
|
||||
++ event-log-to-point-diff
|
||||
=, azimuth-events
|
||||
=, abi:ethereum
|
||||
|= log=event-log:rpc:ethereum
|
||||
^- (unit (pair ship diff-point))
|
||||
~? ?=(~ mined.log) %processing-unmined-event
|
||||
::
|
||||
?: =(i.topics.log owner-changed)
|
||||
=/ [who=@ wer=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %owner wer]
|
||||
::
|
||||
?: =(i.topics.log activated)
|
||||
=/ who=@
|
||||
(decode-topics t.topics.log ~[%uint])
|
||||
`[who %activated who]
|
||||
::
|
||||
?: =(i.topics.log spawned)
|
||||
=/ [pre=@ who=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[pre %spawned who]
|
||||
::
|
||||
?: =(i.topics.log escape-requested)
|
||||
=/ [who=@ wer=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[who %escape `wer]
|
||||
::
|
||||
?: =(i.topics.log escape-canceled)
|
||||
=/ who=@ (decode-topics t.topics.log ~[%uint])
|
||||
`[who %escape ~]
|
||||
::
|
||||
?: =(i.topics.log escape-accepted)
|
||||
=/ [who=@ wer=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[who %sponsor & wer]
|
||||
::
|
||||
?: =(i.topics.log lost-sponsor)
|
||||
=/ [who=@ pos=@]
|
||||
(decode-topics t.topics.log ~[%uint %uint])
|
||||
`[who %sponsor | pos]
|
||||
::
|
||||
?: =(i.topics.log changed-keys)
|
||||
=/ who=@ (decode-topics t.topics.log ~[%uint])
|
||||
=/ [enc=octs aut=octs sut=@ud rev=@ud]
|
||||
%+ decode-results data.log
|
||||
~[[%bytes-n 32] [%bytes-n 32] %uint %uint]
|
||||
`[who %keys rev (pass-from-eth enc aut sut)]
|
||||
::
|
||||
?: =(i.topics.log broke-continuity)
|
||||
=/ who=@ (decode-topics t.topics.log ~[%uint])
|
||||
=/ num=@ (decode-results data.log ~[%uint])
|
||||
`[who %continuity num]
|
||||
::
|
||||
?: =(i.topics.log changed-management-proxy)
|
||||
=/ [who=@ sox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %management-proxy sox]
|
||||
::
|
||||
?: =(i.topics.log changed-voting-proxy)
|
||||
=/ [who=@ tox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %voting-proxy tox]
|
||||
::
|
||||
?: =(i.topics.log changed-spawn-proxy)
|
||||
=/ [who=@ sox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %spawn-proxy sox]
|
||||
::
|
||||
?: =(i.topics.log changed-transfer-proxy)
|
||||
=/ [who=@ tox=address]
|
||||
(decode-topics t.topics.log ~[%uint %address])
|
||||
`[who %transfer-proxy tox]
|
||||
::
|
||||
:: warn about unimplemented events, but ignore
|
||||
:: the ones we know are harmless.
|
||||
~? ?! .= i.topics.log
|
||||
:: OwnershipTransferred(address,address)
|
||||
0x8be0.079c.5316.5914.1344.cd1f.d0a4.f284.
|
||||
1949.7f97.22a3.daaf.e3b4.186f.6b64.57e0
|
||||
[%unimplemented-event i.topics.log]
|
||||
~
|
||||
::
|
||||
++ apply-point-diff
|
||||
|= [pot=point dif=diff-point]
|
||||
^- point
|
||||
?- -.dif
|
||||
%full new.dif
|
||||
::
|
||||
%activated
|
||||
%_ pot
|
||||
net `[0 0 0 &^(^sein:title who.dif) ~]
|
||||
kid ?. ?=(?(%czar %king) (clan:title who.dif)) ~
|
||||
`[0x0 ~]
|
||||
==
|
||||
::
|
||||
:: ownership
|
||||
::
|
||||
%owner pot(owner.own new.dif)
|
||||
%transfer-proxy pot(transfer-proxy.own new.dif)
|
||||
%management-proxy pot(management-proxy.own new.dif)
|
||||
%voting-proxy pot(voting-proxy.own new.dif)
|
||||
::
|
||||
:: networking
|
||||
::
|
||||
?(%keys %continuity %sponsor %escape)
|
||||
?> ?=(^ net.pot)
|
||||
?- -.dif
|
||||
%keys
|
||||
pot(life.u.net life.dif, pass.u.net pass.dif)
|
||||
::
|
||||
%sponsor
|
||||
%= pot
|
||||
sponsor.u.net new.dif
|
||||
escape.u.net ?:(has.new.dif ~ escape.u.net.pot)
|
||||
==
|
||||
::
|
||||
%continuity pot(continuity-number.u.net new.dif)
|
||||
%escape pot(escape.u.net new.dif)
|
||||
==
|
||||
::
|
||||
:: spawning
|
||||
::
|
||||
?(%spawned %spawn-proxy)
|
||||
?> ?=(^ kid.pot)
|
||||
?- -.dif
|
||||
%spawned
|
||||
=- pot(spawned.u.kid -)
|
||||
(~(put in spawned.u.kid.pot) who.dif)
|
||||
::
|
||||
%spawn-proxy pot(spawn-proxy.u.kid new.dif)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ parse-id
|
||||
|= id=@t
|
||||
^- azimuth:function
|
||||
|^
|
||||
~| id
|
||||
%+ rash id
|
||||
;~ pose
|
||||
(function %points 'points' shipname)
|
||||
(function %get-spawned 'getSpawned' shipname)
|
||||
(function %dns-domains 'dnsDomains' dem:ag)
|
||||
==
|
||||
::
|
||||
++ function
|
||||
|* [tag=@tas fun=@t rul=rule]
|
||||
;~(plug (cold tag (jest fun)) (ifix [pal par] rul))
|
||||
::
|
||||
++ shipname
|
||||
;~(pfix sig fed:ag)
|
||||
--
|
||||
::
|
||||
++ function-to-call
|
||||
|%
|
||||
++ azimuth
|
||||
|= cal=azimuth:function
|
||||
^- [id=@t dat=call-data:rpc:ethereum]
|
||||
?- -.cal
|
||||
%points
|
||||
:- (crip "points({(scow %p who.cal)})")
|
||||
['points(uint32)' ~[uint+`@`who.cal]]
|
||||
::
|
||||
%rights
|
||||
:- (crip "rights({(scow %p who.cal)})")
|
||||
['rights(uint32)' ~[uint+`@`who.cal]]
|
||||
::
|
||||
%get-spawned
|
||||
:- (crip "getSpawned({(scow %p who.cal)})")
|
||||
['getSpawned(uint32)' ~[uint+`@`who.cal]]
|
||||
::
|
||||
%dns-domains
|
||||
:- (crip "dnsDomains({(scow %ud ind.cal)})")
|
||||
['dnsDomains(uint256)' ~[uint+ind.cal]]
|
||||
==
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/azimuth.hoon
Symbolic link
1
pkg/arvo/lib/azimuth.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/azimuth.hoon
|
@ -1,146 +0,0 @@
|
||||
/- rpc=json-rpc
|
||||
/+ ethereum, azimuth, strandio
|
||||
=, strand=strand:strandio
|
||||
=, jael
|
||||
|%
|
||||
++ tract azimuth:contracts:azimuth
|
||||
++ fetch-point
|
||||
|= [url=@ta who=ship]
|
||||
=/ m (strand ,point:azimuth)
|
||||
^- form:m
|
||||
=/ =request:rpc:ethereum
|
||||
:+ %eth-call
|
||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
||||
(encode-call:rpc:ethereum 'points(uint32)' [%uint `@`who]~)
|
||||
[%label %latest]
|
||||
;< jon=json bind:m (request-rpc url `'point' request)
|
||||
=/ res=cord (so:dejs:format jon)
|
||||
=/ =point:eth-noun:azimuth
|
||||
(decode-results:abi:ethereum res point:eth-type:azimuth)
|
||||
::
|
||||
=/ =request:rpc:ethereum
|
||||
:+ %eth-call
|
||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
||||
(encode-call:rpc:ethereum 'rights(uint32)' [%uint `@`who]~)
|
||||
[%label %latest]
|
||||
;< jon=json bind:m (request-rpc url `'deed' request)
|
||||
=/ res=cord (so:dejs:format jon)
|
||||
=/ =deed:eth-noun:azimuth
|
||||
(decode-results:abi:ethereum res deed:eth-type:azimuth)
|
||||
::
|
||||
(pure:m (point-from-eth:azimuth who point deed))
|
||||
::
|
||||
++ request-rpc
|
||||
|= [url=@ta id=(unit @t) req=request:rpc:ethereum]
|
||||
=/ m (strand ,json)
|
||||
^- form:m
|
||||
%+ (retry json) `10
|
||||
=/ m (strand ,(unit json))
|
||||
^- form:m
|
||||
|^
|
||||
=/ =request:http
|
||||
:* method=%'POST'
|
||||
url=url
|
||||
header-list=['Content-Type'^'application/json' ~]
|
||||
^= body
|
||||
%- some %- as-octt:mimes:html
|
||||
%- en-json:html
|
||||
(request-to-json:rpc:ethereum id req)
|
||||
==
|
||||
;< ~ bind:m (send-request:strandio request)
|
||||
;< rep=(unit client-response:iris) bind:m
|
||||
take-maybe-response:strandio
|
||||
?~ rep
|
||||
(pure:m ~)
|
||||
(parse-response u.rep)
|
||||
::
|
||||
++ parse-response
|
||||
|= =client-response:iris
|
||||
=/ m (strand ,(unit json))
|
||||
^- form:m
|
||||
?> ?=(%finished -.client-response)
|
||||
?~ full-file.client-response
|
||||
(pure:m ~)
|
||||
=/ body=@t q.data.u.full-file.client-response
|
||||
=/ jon=(unit json) (de-json:html body)
|
||||
?~ jon
|
||||
(pure:m ~)
|
||||
=, dejs-soft:format
|
||||
=/ array=(unit (list response:rpc))
|
||||
((ar parse-one-response) u.jon)
|
||||
?~ array
|
||||
=/ res=(unit response:rpc) (parse-one-response u.jon)
|
||||
?~ res
|
||||
(strand-fail:strandio %request-rpc-parse-error >id< ~)
|
||||
?: ?=(%error -.u.res)
|
||||
(strand-fail:strandio %request-rpc-error >id< >+.res< ~)
|
||||
?. ?=(%result -.u.res)
|
||||
(strand-fail:strandio %request-rpc-fail >u.res< ~)
|
||||
(pure:m `res.u.res)
|
||||
(strand-fail:strandio %request-rpc-batch >%not-implemented< ~)
|
||||
:: (pure:m `[%batch u.array])
|
||||
::
|
||||
++ parse-one-response
|
||||
|= =json
|
||||
^- (unit response:rpc)
|
||||
=/ res=(unit [@t ^json])
|
||||
%. json
|
||||
=, dejs-soft:format
|
||||
(ot id+so result+some ~)
|
||||
?^ res `[%result u.res]
|
||||
~| parse-one-response=json
|
||||
:+ ~ %error %- need
|
||||
%. json
|
||||
=, dejs-soft:format
|
||||
(ot id+so error+(ot code+no message+so ~) ~)
|
||||
--
|
||||
::
|
||||
++ retry
|
||||
|* result=mold
|
||||
|= [crash-after=(unit @ud) computation=_*form:(strand (unit result))]
|
||||
=/ m (strand ,result)
|
||||
=| try=@ud
|
||||
|- ^- form:m
|
||||
=* loop $
|
||||
?: =(crash-after `try)
|
||||
(strand-fail:strandio %retry-too-many ~)
|
||||
;< ~ bind:m (backoff:strandio try ~m1)
|
||||
;< res=(unit result) bind:m computation
|
||||
?^ res
|
||||
(pure:m u.res)
|
||||
loop(try +(try))
|
||||
::
|
||||
++ get-latest-block
|
||||
|= url=@ta
|
||||
=/ m (strand ,block)
|
||||
^- form:m
|
||||
;< =json bind:m (request-rpc url `'block number' %eth-block-number ~)
|
||||
(get-block-by-number url (parse-eth-block-number:rpc:ethereum json))
|
||||
::
|
||||
++ get-block-by-number
|
||||
|= [url=@ta =number:block]
|
||||
=/ m (strand ,block)
|
||||
^- form:m
|
||||
|^
|
||||
;< =json bind:m
|
||||
(request-rpc url `'block by number' %eth-get-block-by-number number |)
|
||||
=/ =block (parse-block json)
|
||||
?. =(number number.id.block)
|
||||
(strand-fail:strandio %reorg-detected >number< >block< ~)
|
||||
(pure:m block)
|
||||
::
|
||||
++ parse-block
|
||||
|= =json
|
||||
^- block
|
||||
=< [[&1 &2] |2]
|
||||
^- [@ @ @]
|
||||
~| json
|
||||
%. json
|
||||
=, dejs:format
|
||||
%- ot
|
||||
:~ hash+parse-hex-result:rpc:ethereum
|
||||
number+parse-hex-result:rpc:ethereum
|
||||
'parentHash'^parse-hex-result:rpc:ethereum
|
||||
==
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/azimuthio.hoon
Symbolic link
1
pkg/arvo/lib/azimuthio.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/azimuthio.hoon
|
@ -1,263 +0,0 @@
|
||||
/- bc=bitcoin
|
||||
/+ bcu=bitcoin-utils
|
||||
~% %bip-158-top ..part ~
|
||||
|%
|
||||
++ params
|
||||
|%
|
||||
++ p 19
|
||||
++ m 784.931
|
||||
--
|
||||
::
|
||||
++ siphash
|
||||
~/ %siphash
|
||||
|= [k=byts m=byts]
|
||||
^- byts
|
||||
|^
|
||||
?> =(wid.k 16)
|
||||
?> (lte (met 3 dat.k) wid.k)
|
||||
?> (lte (met 3 dat.m) wid.m)
|
||||
=. k (flim:sha k)
|
||||
=. m (flim:sha m)
|
||||
(flim:sha (fin (comp m (init dat.k))))
|
||||
:: Initialise internal state
|
||||
::
|
||||
++ init
|
||||
|= k=@
|
||||
^- [@ @ @ @]
|
||||
=/ k0=@ (end [6 1] k)
|
||||
=/ k1=@ (cut 6 [1 1] k)
|
||||
:^ (mix k0 0x736f.6d65.7073.6575)
|
||||
(mix k1 0x646f.7261.6e64.6f6d)
|
||||
(mix k0 0x6c79.6765.6e65.7261)
|
||||
(mix k1 0x7465.6462.7974.6573)
|
||||
::
|
||||
:: Compression rounds
|
||||
++ comp
|
||||
|= [m=byts v=[v0=@ v1=@ v2=@ v3=@]]
|
||||
^- [@ @ @ @]
|
||||
=/ len=@ud (div wid.m 8)
|
||||
=/ last=@ (lsh [3 7] (mod wid.m 256))
|
||||
=| i=@ud
|
||||
=| w=@
|
||||
|-
|
||||
=. w (cut 6 [i 1] dat.m)
|
||||
?: =(i len)
|
||||
=. v3.v (mix v3.v (mix last w))
|
||||
=. v (rnd (rnd v))
|
||||
=. v0.v (mix v0.v (mix last w))
|
||||
v
|
||||
%= $
|
||||
v =. v3.v (mix v3.v w)
|
||||
=. v (rnd (rnd v))
|
||||
=. v0.v (mix v0.v w)
|
||||
v
|
||||
i (add i 1)
|
||||
==
|
||||
::
|
||||
:: Finalisation rounds
|
||||
++ fin
|
||||
|= v=[v0=@ v1=@ v2=@ v3=@]
|
||||
^- byts
|
||||
=. v2.v (mix v2.v 0xff)
|
||||
=. v (rnd (rnd (rnd (rnd v))))
|
||||
:- 8
|
||||
:(mix v0.v v1.v v2.v v3.v)
|
||||
::
|
||||
:: Sipround
|
||||
++ rnd
|
||||
|= [v0=@ v1=@ v2=@ v3=@]
|
||||
^- [@ @ @ @]
|
||||
=. v0 (~(sum fe 6) v0 v1)
|
||||
=. v2 (~(sum fe 6) v2 v3)
|
||||
=. v1 (~(rol fe 6) 0 13 v1)
|
||||
=. v3 (~(rol fe 6) 0 16 v3)
|
||||
=. v1 (mix v1 v0)
|
||||
=. v3 (mix v3 v2)
|
||||
=. v0 (~(rol fe 6) 0 32 v0)
|
||||
=. v2 (~(sum fe 6) v2 v1)
|
||||
=. v0 (~(sum fe 6) v0 v3)
|
||||
=. v1 (~(rol fe 6) 0 17 v1)
|
||||
=. v3 (~(rol fe 6) 0 21 v3)
|
||||
=. v1 (mix v1 v2)
|
||||
=. v3 (mix v3 v0)
|
||||
=. v2 (~(rol fe 6) 0 32 v2)
|
||||
[v0 v1 v2 v3]
|
||||
--
|
||||
:: +str: bit streams
|
||||
:: read is from the front
|
||||
:: write appends to the back
|
||||
::
|
||||
++ str
|
||||
~% %str ..params ~
|
||||
|%
|
||||
++ read-bit
|
||||
~/ %read-bit
|
||||
|= s=bits:bc
|
||||
^- [bit=@ub rest=bits:bc]
|
||||
?> (gth wid.s 0)
|
||||
:+ ?:((gth wid.s (met 0 dat.s)) 0b0 0b1)
|
||||
(dec wid.s)
|
||||
(end [0 (dec wid.s)] dat.s)
|
||||
::
|
||||
::
|
||||
++ read-bits
|
||||
~/ %read-bits
|
||||
|= [n=@ s=bits:bc]
|
||||
^- [bits:bc rest=bits:bc]
|
||||
=/ r=@ (sub wid.s n)
|
||||
:- n^(cut 0 [r n] dat.s)
|
||||
r^(cut 0 [0 r] dat.s)
|
||||
::
|
||||
++ write-bits
|
||||
~/ %write-bits
|
||||
|= [s1=bits:bc s2=bits:bc]
|
||||
^- bits:bc
|
||||
[(add wid.s1 wid.s2) (can 0 ~[s2 s1])]
|
||||
--
|
||||
:: +gol: Golomb-Rice encoding/decoding
|
||||
::
|
||||
++ gol
|
||||
~% %gol ..params ~
|
||||
|%
|
||||
:: +en: encode x and append to end of s
|
||||
:: - s: bits stream
|
||||
:: - x: number to add to the stream
|
||||
:: - p: golomb-rice p param
|
||||
::
|
||||
++ en
|
||||
~/ %en
|
||||
|= [s=bits:bc x=@ p=@]
|
||||
^- bits:bc
|
||||
=+ q=(rsh [0 p] x)
|
||||
=+ unary=[+(q) (lsh [0 1] (dec (bex q)))]
|
||||
=+ r=[p (end [0 p] x)]
|
||||
%+ write-bits:str s
|
||||
(write-bits:str unary r)
|
||||
::
|
||||
++ de
|
||||
~/ %de
|
||||
|= [s=bits:bc p=@]
|
||||
^- [delta=@ rest=bits:bc]
|
||||
|^ ?> (gth wid.s 0)
|
||||
=^ q s (get-q s)
|
||||
=^ r s (read-bits:str p s)
|
||||
[(add dat.r (lsh [0 p] q)) s]
|
||||
::
|
||||
++ get-q
|
||||
|= s=bits:bc
|
||||
=| q=@
|
||||
=^ first-bit s (read-bit:str s)
|
||||
|-
|
||||
?: =(0 first-bit) [q s]
|
||||
=^ b s (read-bit:str s)
|
||||
$(first-bit b, q +(q))
|
||||
--
|
||||
--
|
||||
:: +hsh
|
||||
::
|
||||
++ hsh
|
||||
~% %hsh ..params ~
|
||||
|%
|
||||
:: +to-range
|
||||
:: - item: scriptpubkey to hash
|
||||
:: - f: N*M
|
||||
:: - k: key for siphash (end of blockhash, reversed)
|
||||
::
|
||||
++ to-range
|
||||
~/ %to-range
|
||||
|= [item=byts f=@ k=byts]
|
||||
^- @
|
||||
(rsh [0 64] (mul f (rev 3 (siphash k item))))
|
||||
:: +set-construct: return sorted hashes of scriptpubkeys
|
||||
::
|
||||
++ set-construct
|
||||
|= [items=(list byts) k=byts f=@]
|
||||
^- (list @)
|
||||
%+ sort
|
||||
%+ turn items
|
||||
|= item=byts
|
||||
(to-range item f k)
|
||||
lth
|
||||
--
|
||||
::
|
||||
++ parse-filter
|
||||
~/ %parse-filter
|
||||
|= filter=hexb:bc
|
||||
^- [n=@ux gcs-set=bits:bc]
|
||||
=/ n n:(de:csiz:bcu filter)
|
||||
=/ lead=@ ?:(=(1 wid.n) 1 +(wid.n))
|
||||
:- dat.n
|
||||
[(mul 8 (sub wid.filter lead)) `@ub`dat:(drop:byt:bcu lead filter)]
|
||||
:: +to-key: blockhash (little endian) to key for siphash
|
||||
::
|
||||
++ to-key
|
||||
~/ %to-key
|
||||
|= blockhash=tape
|
||||
^- byts
|
||||
%+ take:byt:bcu 16
|
||||
%- flip:byt:bcu
|
||||
(from-cord:hxb:bcu (crip blockhash))
|
||||
:: +match: whether block filter matches *any* target scriptpubkeys
|
||||
:: - filter: full block filter, with leading N
|
||||
:: - k: key for siphash (end of blockhash, reversed)
|
||||
:: - targets: scriptpubkeys to match
|
||||
::
|
||||
++ match
|
||||
~/ %match
|
||||
|= [filter=hexb:bc k=byts targets=(list byts)]
|
||||
^- ?
|
||||
=/ [p=@ m=@] [p:params m:params]
|
||||
=/ [n=@ux gcs-set=bits:bc] (parse-filter filter)
|
||||
=+ target-hs=(set-construct:hsh targets k (mul n m))
|
||||
=+ last-val=0
|
||||
|-
|
||||
?~ target-hs %.n
|
||||
?: =(last-val i.target-hs)
|
||||
%.y
|
||||
?: (gth last-val i.target-hs)
|
||||
$(target-hs t.target-hs)
|
||||
:: last-val is less than target: check next val in GCS, if any
|
||||
::
|
||||
?: (lth wid.gcs-set p) %.n
|
||||
=^ delta gcs-set
|
||||
(de:gol gcs-set p)
|
||||
$(last-val (add delta last-val))
|
||||
:: +all-match: returns all target byts that match
|
||||
:: - filter: full block filter, with leading N
|
||||
:: - targets: scriptpubkeys to match
|
||||
::
|
||||
++ all-match
|
||||
~/ %all-match
|
||||
|= [filter=hexb:bc blockhash=hexb:bc targets=(list [address:bc byts])]
|
||||
^- (set [address:bc hexb:bc])
|
||||
=/ k (to-key (trip (to-cord:hxb:bcu blockhash)))
|
||||
%- ~(gas in *(set [address:bc hexb:bc]))
|
||||
=/ [p=@ m=@] [p:params m:params]
|
||||
=/ [n=@ux gcs-set=bits:bc] (parse-filter filter)
|
||||
=/ target-map=(map @ [address:bc hexb:bc])
|
||||
%- ~(gas by *(map @ [address:bc hexb:bc]))
|
||||
%+ turn targets
|
||||
|= [a=address:bc t=hexb:bc]
|
||||
[(to-range:hsh t (mul n m) k) a t]
|
||||
=+ target-hs=(sort ~(tap in ~(key by target-map)) lth)
|
||||
=+ last-val=0
|
||||
=| matches=(list @)
|
||||
|-
|
||||
?~ target-hs
|
||||
(murn matches ~(get by target-map))
|
||||
?: =(last-val i.target-hs)
|
||||
%= $
|
||||
target-hs t.target-hs
|
||||
matches [last-val matches]
|
||||
==
|
||||
?: (gth last-val i.target-hs)
|
||||
$(target-hs t.target-hs)
|
||||
:: last-val is less than target: get next val in GCS, if any
|
||||
::
|
||||
?: (lth wid.gcs-set p)
|
||||
(murn matches ~(get by target-map))
|
||||
=^ delta gcs-set
|
||||
(de:gol gcs-set p)
|
||||
$(last-val (add delta last-val))
|
||||
::
|
||||
--
|
1
pkg/arvo/lib/bip/b158.hoon
Symbolic link
1
pkg/arvo/lib/bip/b158.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/bip/b158.hoon
|
@ -1,144 +0,0 @@
|
||||
:: BIP173: Bech32 Addresses
|
||||
:: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
|
||||
::
|
||||
:: Heavily copies:
|
||||
:: https://github.com/bitcoinjs/bech32/blob/master/index.js
|
||||
::
|
||||
/- sur=bitcoin
|
||||
/+ bcu=bitcoin-utils
|
||||
=, sur
|
||||
=, bcu
|
||||
|%
|
||||
++ prefixes
|
||||
^- (map network tape)
|
||||
(my [[%main "bc"] [%testnet "tb"] ~])
|
||||
++ charset "qpzry9x8gf2tvdw0s3jn54khce6mua7l"
|
||||
+$ raw-decoded [hrp=tape data=(list @) checksum=(list @)]
|
||||
:: below is a port of: https://github.com/bitcoinjs/bech32/blob/master/index.js
|
||||
::
|
||||
++ polymod
|
||||
|= values=(list @)
|
||||
|^ ^- @
|
||||
=/ gen=(list @ux)
|
||||
~[0x3b6a.57b2 0x2650.8e6d 0x1ea1.19fa 0x3d42.33dd 0x2a14.62b3]
|
||||
=/ chk=@ 1
|
||||
|- ?~ values chk
|
||||
=/ top (rsh [0 25] chk)
|
||||
=. chk
|
||||
(mix i.values (lsh [0 5] (dis chk 0x1ff.ffff)))
|
||||
$(values t.values, chk (update-chk chk top gen))
|
||||
::
|
||||
++ update-chk
|
||||
|= [chk=@ top=@ gen=(list @ux)]
|
||||
=/ is (gulf 0 4)
|
||||
|- ?~ is chk
|
||||
?: =(1 (dis 1 (rsh [0 i.is] top)))
|
||||
$(is t.is, chk (mix chk (snag i.is gen)))
|
||||
$(is t.is)
|
||||
--
|
||||
::
|
||||
++ expand-hrp
|
||||
|= hrp=tape
|
||||
^- (list @)
|
||||
=/ front (turn hrp |=(p=@tD (rsh [0 5] p)))
|
||||
=/ back (turn hrp |=(p=@tD (dis 31 p)))
|
||||
(zing ~[front ~[0] back])
|
||||
::
|
||||
++ verify-checksum
|
||||
|= [hrp=tape data-and-checksum=(list @)]
|
||||
^- ?
|
||||
%- |=(a=@ =(1 a))
|
||||
%- polymod
|
||||
(weld (expand-hrp hrp) data-and-checksum)
|
||||
::
|
||||
++ checksum
|
||||
|= [hrp=tape data=(list @)]
|
||||
^- (list @)
|
||||
:: xor 1 with the polymod
|
||||
::
|
||||
=/ pmod=@
|
||||
%+ mix 1
|
||||
%- polymod
|
||||
(zing ~[(expand-hrp hrp) data (reap 6 0)])
|
||||
%+ turn (gulf 0 5)
|
||||
|=(i=@ (dis 31 (rsh [0 (mul 5 (sub 5 i))] pmod)))
|
||||
::
|
||||
++ charset-to-value
|
||||
|= c=@tD
|
||||
^- (unit @)
|
||||
(find ~[c] charset)
|
||||
++ value-to-charset
|
||||
|= value=@
|
||||
^- (unit @tD)
|
||||
?: (gth value 31) ~
|
||||
`(snag value charset)
|
||||
::
|
||||
++ is-valid
|
||||
|= [bech=tape last-1-pos=@] ^- ?
|
||||
?& ?|(=((cass bech) bech) =((cuss bech) bech)) :: to upper or to lower is same as bech
|
||||
(gte last-1-pos 1)
|
||||
(lte (add last-1-pos 7) (lent bech))
|
||||
(lte (lent bech) 90)
|
||||
(levy bech |=(c=@tD (gte c 33)))
|
||||
(levy bech |=(c=@tD (lte c 126)))
|
||||
==
|
||||
:: data should be 5bit words
|
||||
::
|
||||
++ encode-raw
|
||||
|= [hrp=tape data=(list @)]
|
||||
^- cord
|
||||
=/ combined=(list @)
|
||||
(weld data (checksum hrp data))
|
||||
%- crip
|
||||
(zing ~[hrp "1" (tape (murn combined value-to-charset))])
|
||||
++ decode-raw
|
||||
|= body=cord
|
||||
^- (unit raw-decoded)
|
||||
=/ bech (cass (trip body)) :: to lowercase
|
||||
=/ pos (flop (fand "1" bech))
|
||||
?~ pos ~
|
||||
=/ last-1=@ i.pos
|
||||
?. (is-valid bech last-1) :: check bech32 validity (not segwit validity or checksum)
|
||||
~
|
||||
=/ hrp (scag last-1 bech)
|
||||
=/ encoded-data-and-checksum=(list @)
|
||||
(slag +(last-1) bech)
|
||||
=/ data-and-checksum=(list @)
|
||||
%+ murn encoded-data-and-checksum
|
||||
charset-to-value
|
||||
?. =((lent encoded-data-and-checksum) (lent data-and-checksum)) :: ensure all were in CHARSET
|
||||
~
|
||||
?. (verify-checksum hrp data-and-checksum)
|
||||
~
|
||||
=/ checksum-pos (sub (lent data-and-checksum) 6)
|
||||
`[hrp (scag checksum-pos data-and-checksum) (slag checksum-pos data-and-checksum)]
|
||||
:: +from-address: BIP173 bech32 address encoding to hex
|
||||
:: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
|
||||
:: expects to drop a leading 5-bit 0 (the witness version)
|
||||
::
|
||||
++ from-address
|
||||
|= body=cord
|
||||
^- hexb
|
||||
~| "Invalid bech32 address"
|
||||
=/ d=(unit raw-decoded) (decode-raw body)
|
||||
?> ?=(^ d)
|
||||
=/ bs=bits (from-atoms:bit 5 data.u.d)
|
||||
=/ byt-len=@ (div (sub wid.bs 5) 8)
|
||||
?> =(5^0b0 (take:bit 5 bs))
|
||||
?> ?| =(20 byt-len)
|
||||
=(32 byt-len)
|
||||
==
|
||||
[byt-len `@ux`dat:(take:bit (mul 8 byt-len) (drop:bit 5 bs))]
|
||||
:: pubkey is the 33 byte ECC compressed public key
|
||||
::
|
||||
++ encode-pubkey
|
||||
|= [=network pubkey=byts]
|
||||
^- (unit cord)
|
||||
?. =(33 wid.pubkey)
|
||||
~|('pubkey must be a 33 byte ECC compressed public key' !!)
|
||||
=/ prefix (~(get by prefixes) network)
|
||||
?~ prefix ~
|
||||
:- ~
|
||||
%+ encode-raw u.prefix
|
||||
[0v0 (to-atoms:bit 5 [160 `@ub`dat:(hash-160 pubkey)])]
|
||||
--
|
1
pkg/arvo/lib/bip/b173.hoon
Symbolic link
1
pkg/arvo/lib/bip/b173.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/bip/b173.hoon
|
@ -1,182 +0,0 @@
|
||||
:: BIP174: PSBTs
|
||||
:: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
|
||||
::
|
||||
/- sur=bitcoin
|
||||
/+ bcu=bitcoin-utils
|
||||
=, sur
|
||||
=, bcu
|
||||
|%
|
||||
++ en
|
||||
|%
|
||||
++ globals
|
||||
|= rawtx=hexb
|
||||
^- map:psbt
|
||||
:~ [[1 0x0] rawtx]
|
||||
==
|
||||
::
|
||||
++ input
|
||||
|= [only-witness=? i=in:psbt]
|
||||
^- map:psbt
|
||||
%+ weld
|
||||
?: only-witness ~
|
||||
~[[1^0x0 rawtx.i]]
|
||||
:~ (witness-tx i)
|
||||
(hdkey %input hdkey.i)
|
||||
==
|
||||
::
|
||||
++ output
|
||||
|= =out:psbt
|
||||
^- map:psbt
|
||||
?~ hk.out ~
|
||||
:~ (hdkey %output u.hk.out)
|
||||
==
|
||||
::
|
||||
++ witness-tx
|
||||
|= i=in:psbt
|
||||
^- keyval:psbt
|
||||
:- [1 0x1]
|
||||
%- cat:byt
|
||||
:~ (flip:byt 8^value.utxo.i)
|
||||
1^0x16
|
||||
2^0x14
|
||||
(hash-160 pubkey.hdkey.i)
|
||||
==
|
||||
::
|
||||
++ hdkey
|
||||
|= [=target:psbt h=^hdkey]
|
||||
^- keyval:psbt
|
||||
=/ typ=@ux
|
||||
?- target
|
||||
%input 0x6
|
||||
%output 0x2
|
||||
==
|
||||
=/ coin-type=hexb
|
||||
?- network.h
|
||||
%main
|
||||
1^0x0
|
||||
%testnet
|
||||
1^0x1
|
||||
==
|
||||
:- (cat:byt ~[1^typ pubkey.h])
|
||||
%- cat:byt
|
||||
:~ fprint.h
|
||||
1^`@ux`bipt.h 3^0x80
|
||||
coin-type 3^0x80
|
||||
4^0x80
|
||||
1^`@ux`chyg.h 3^0x0
|
||||
(flip:byt 4^idx.h)
|
||||
==
|
||||
::
|
||||
++ keyval-byts
|
||||
|= kv=keyval:psbt
|
||||
^- hexb
|
||||
%- cat:byt
|
||||
:~ 1^wid.key.kv
|
||||
key.kv
|
||||
1^wid.val.kv
|
||||
val.kv
|
||||
==
|
||||
::
|
||||
++ map-byts
|
||||
|= m=map:psbt
|
||||
^- (unit hexb)
|
||||
?~ m ~
|
||||
:- ~
|
||||
%- cat:byt
|
||||
(turn m keyval-byts)
|
||||
--
|
||||
++ base64
|
||||
|= b=hexb
|
||||
^- base64:psbt
|
||||
%- en:base64:mimes:html
|
||||
(flip:byt b)
|
||||
:: +encode: make base64 cord of PSBT
|
||||
:: - only-witness: don't include non-witness UTXO
|
||||
::
|
||||
++ encode
|
||||
|= $: only-witness=?
|
||||
rawtx=hexb
|
||||
txid=hexb
|
||||
inputs=(list in:psbt)
|
||||
outputs=(list out:psbt)
|
||||
==
|
||||
^- base64:psbt
|
||||
=/ sep=(unit hexb) `1^0x0
|
||||
=/ final=(list (unit hexb))
|
||||
%+ join sep
|
||||
%+ turn
|
||||
%- zing
|
||||
:~ ~[(globals:en rawtx)]
|
||||
(turn inputs (cury input:en only-witness))
|
||||
(turn outputs output:en)
|
||||
==
|
||||
map-byts:en
|
||||
%- base64:en
|
||||
^- byts
|
||||
%- cat:byt
|
||||
%+ weld ~[[5 0x70.7362.74ff]]
|
||||
(murn (snoc final sep) same)
|
||||
::
|
||||
++ parse
|
||||
|= psbt-base64=cord
|
||||
^- (list map:psbt)
|
||||
=/ todo=hexb
|
||||
(drop:byt 5 (to-byts psbt-base64))
|
||||
=| acc=(list map:psbt)
|
||||
=| m=map:psbt
|
||||
|-
|
||||
?: =(wid.todo 0)
|
||||
(snoc acc m)
|
||||
:: 0x0: map separator
|
||||
::
|
||||
?: =(1^0x0 (take:byt 1 todo))
|
||||
$(acc (snoc acc m), m *map:psbt, todo (drop:byt 1 todo))
|
||||
=^ kv todo (next-keyval todo)
|
||||
$(m (snoc m kv))
|
||||
:: +get-txid: extract txid from a valid PSBT
|
||||
::
|
||||
++ get-txid
|
||||
|= psbt-base64=cord
|
||||
^- hexb
|
||||
=/ tx=hexb
|
||||
%- raw-tx
|
||||
%+ drop:byt 5
|
||||
(to-byts psbt-base64)
|
||||
%- flip:byt
|
||||
(dsha256 tx)
|
||||
:: +raw-tx: extract hex transaction
|
||||
:: looks for key 0x0 in global map
|
||||
:: crashes if tx not in hex
|
||||
::
|
||||
++ raw-tx
|
||||
|= b=hexb
|
||||
^- hexb
|
||||
|-
|
||||
?: =(wid.b 0) !!
|
||||
?: =(1^0x0 (take:byt 1 b)) !!
|
||||
=/ nk (next-keyval b)
|
||||
?: =(0x0 dat.key.kv.nk)
|
||||
val.kv.nk
|
||||
$(b rest.nk)
|
||||
:: +next-keyval: returns next key-val in a PSBT map
|
||||
:: input first byte must be a map key length
|
||||
::
|
||||
++ next-keyval
|
||||
|= b=hexb
|
||||
^- [kv=keyval:psbt rest=hexb]
|
||||
=/ klen dat:(take:byt 1 b)
|
||||
=/ k (take:byt klen (drop:byt 1 b))
|
||||
=/ vlen dat:(take:byt 1 (drop:byt (add 1 klen) b))
|
||||
=/ v (take:byt vlen (drop:byt (add 2 klen) b))
|
||||
?> ?&((gth wid.k 0) (gth wid.v 0))
|
||||
:- [k v]
|
||||
(drop:byt ;:(add 2 klen vlen) b)
|
||||
::
|
||||
++ to-byts
|
||||
|= psbt-base64=cord
|
||||
^- hexb
|
||||
~| "Invalid PSBT"
|
||||
=+ p=(de:base64:mimes:html psbt-base64)
|
||||
?~ p !!
|
||||
(flip:byt u.p)
|
||||
--
|
1
pkg/arvo/lib/bip/b174.hoon
Symbolic link
1
pkg/arvo/lib/bip/b174.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/bip/b174.hoon
|
@ -1,243 +0,0 @@
|
||||
:: bip32 implementation in hoon
|
||||
::
|
||||
:: to use, call one of the core initialization arms.
|
||||
:: using the produced core, derive as needed and take out the data you want.
|
||||
::
|
||||
::NOTE tested to be correct against
|
||||
:: https://en.bitcoin.it/wiki/BIP_0032_TestVectors
|
||||
::
|
||||
=, hmac:crypto
|
||||
=, secp:crypto
|
||||
=+ ecc=secp256k1
|
||||
::
|
||||
:: prv: private key
|
||||
:: pub: public key
|
||||
:: cad: chain code
|
||||
:: dep: depth in chain
|
||||
:: ind: index at depth
|
||||
:: pif: parent fingerprint (4 bytes)
|
||||
|_ [prv=@ pub=point.ecc cad=@ dep=@ud ind=@ud pif=@]
|
||||
::
|
||||
+$ keyc [key=@ cai=@] :: prv/pub key + chain code
|
||||
::
|
||||
:: elliptic curve operations and values
|
||||
::
|
||||
++ point priv-to-pub.ecc
|
||||
::
|
||||
++ ser-p compress-point.ecc
|
||||
::
|
||||
++ n n:t.ecc
|
||||
::
|
||||
:: core initialization
|
||||
::
|
||||
++ from-seed
|
||||
|= byts
|
||||
^+ +>
|
||||
=+ der=(hmac-sha512l [12 'dees nioctiB'] [wid dat])
|
||||
=+ pri=(cut 3 [32 32] der)
|
||||
+>.$(prv pri, pub (point pri), cad (cut 3 [0 32] der))
|
||||
::
|
||||
++ from-private
|
||||
|= keyc
|
||||
+>(prv key, pub (point key), cad cai)
|
||||
::
|
||||
++ from-public
|
||||
|= keyc
|
||||
+>(pub (decompress-point.ecc key), cad cai)
|
||||
::
|
||||
++ from-public-point
|
||||
|= [pon=point.ecc cai=@]
|
||||
+>(pub pon, cad cai)
|
||||
::
|
||||
++ from-extended
|
||||
|= t=tape
|
||||
=+ x=(de-base58check 4 t)
|
||||
=> |%
|
||||
++ take
|
||||
|= b=@ud
|
||||
^- [v=@ x=@]
|
||||
:- (end [3 b] x)
|
||||
(rsh [3 b] x)
|
||||
--
|
||||
=^ k x (take 33)
|
||||
=^ c x (take 32)
|
||||
=^ i x (take 4)
|
||||
=^ p x (take 4)
|
||||
=^ d x (take 1)
|
||||
?> =(0 x) :: sanity check
|
||||
%. [d i p]
|
||||
=< set-metadata
|
||||
=+ v=(swag [1 3] t)
|
||||
?: =("prv" v) (from-private k c)
|
||||
?: =("pub" v) (from-public k c)
|
||||
!!
|
||||
::
|
||||
++ set-metadata
|
||||
|= [d=@ud i=@ud p=@]
|
||||
+>(dep d, ind i, pif p)
|
||||
::
|
||||
:: derivation
|
||||
::
|
||||
++ derivation-path
|
||||
;~ pfix
|
||||
;~(pose (jest 'm/') (easy ~))
|
||||
%+ most fas
|
||||
;~ pose
|
||||
%+ cook
|
||||
|=(i=@ (add i (bex 31)))
|
||||
;~(sfix dem soq)
|
||||
::
|
||||
dem
|
||||
== ==
|
||||
::
|
||||
++ derive-path
|
||||
|= t=tape
|
||||
%- derive-sequence
|
||||
(scan t derivation-path)
|
||||
::
|
||||
++ derive-sequence
|
||||
|= j=(list @u)
|
||||
?~ j +>
|
||||
=. +> (derive i.j)
|
||||
$(j t.j)
|
||||
::
|
||||
++ derive
|
||||
?: =(0 prv)
|
||||
derive-public
|
||||
derive-private
|
||||
::
|
||||
++ derive-private
|
||||
|= i=@u
|
||||
^+ +>
|
||||
:: we must have a private key to derive the next one
|
||||
?: =(0 prv)
|
||||
~| %know-no-private-key
|
||||
!!
|
||||
:: derive child at i
|
||||
=/ [left=@ right=@]
|
||||
=- [(cut 3 [32 32] -) (cut 3 [0 32] -)]
|
||||
%+ hmac-sha512l [32 cad]
|
||||
:- 37
|
||||
?: (gte i (bex 31))
|
||||
:: hardened child
|
||||
(can 3 ~[4^i 32^prv 1^0])
|
||||
:: normal child
|
||||
(can 3 ~[4^i 33^(ser-p (point prv))])
|
||||
=+ key=(mod (add left prv) n)
|
||||
:: rare exception, invalid key, go to the next one
|
||||
?: |(=(0 key) (gte left n)) $(i +(i))
|
||||
%_ +>.$
|
||||
prv key
|
||||
pub (point key)
|
||||
cad right
|
||||
dep +(dep)
|
||||
ind i
|
||||
pif fingerprint
|
||||
==
|
||||
::
|
||||
++ derive-public
|
||||
|= i=@u
|
||||
^+ +>
|
||||
:: public keys can't be hardened
|
||||
?: (gte i (bex 31))
|
||||
~| %cant-derive-hardened-public-key
|
||||
!!
|
||||
:: derive child at i
|
||||
=/ [left=@ right=@]
|
||||
=- [(cut 3 [32 32] -) (cut 3 [0 32] -)]
|
||||
%+ hmac-sha512l [32 cad]
|
||||
37^(can 3 ~[4^i 33^(ser-p pub)])
|
||||
:: rare exception, invalid key, go to the next one
|
||||
?: (gte left n) $(i +(i)) ::TODO or child key is "point at infinity"
|
||||
%_ +>.$
|
||||
pub (add-points.ecc (point left) pub)
|
||||
cad right
|
||||
dep +(dep)
|
||||
ind i
|
||||
pif fingerprint
|
||||
==
|
||||
::
|
||||
:: rendering
|
||||
::
|
||||
++ private-key ?.(=(0 prv) prv ~|(%know-no-private-key !!))
|
||||
++ public-key (ser-p pub)
|
||||
++ chain-code cad
|
||||
++ private-chain [private-key cad]
|
||||
++ public-chain [public-key cad]
|
||||
::
|
||||
++ identity (hash160 public-key)
|
||||
++ fingerprint (cut 3 [16 4] identity)
|
||||
::
|
||||
++ address
|
||||
|= network=?(%main %regtest %testnet)
|
||||
^- @uc
|
||||
:: removes checksum
|
||||
::
|
||||
%+ rsh [3 4]
|
||||
%+ en-base58check
|
||||
[4 (version-bytes network %pub %.n)]
|
||||
[20 identity]
|
||||
::
|
||||
++ prv-extended
|
||||
|= network=?(%main %regtest %testnet)
|
||||
%+ en-b58c-bip32 (version-bytes network %prv %.y)
|
||||
(build-extended private-key)
|
||||
::
|
||||
++ pub-extended
|
||||
|= network=?(%main %regtest %testnet)
|
||||
%+ en-b58c-bip32 (version-bytes network %pub %.y)
|
||||
(build-extended public-key)
|
||||
::
|
||||
++ build-extended
|
||||
|= key=@
|
||||
%+ can 3
|
||||
:~ 33^key
|
||||
32^cad
|
||||
4^ind
|
||||
4^pif
|
||||
1^dep
|
||||
==
|
||||
::
|
||||
++ en-b58c-bip32
|
||||
|= [v=@ k=@]
|
||||
%- en-base58:mimes:html
|
||||
(en-base58check [4 v] [74 k])
|
||||
::
|
||||
:: base58check
|
||||
::
|
||||
++ en-base58check
|
||||
:: v: version bytes
|
||||
:: d: data
|
||||
|= [v=byts d=byts]
|
||||
=+ p=[(add wid.v wid.d) (can 3 ~[d v])]
|
||||
=- (can 3 ~[4^- p])
|
||||
%+ rsh [3 28]
|
||||
(sha-256l:sha 32 (sha-256l:sha p))
|
||||
::
|
||||
++ de-base58check
|
||||
:: vw: amount of version bytes
|
||||
|= [vw=@u t=tape]
|
||||
=+ x=(de-base58:mimes:html t)
|
||||
=+ hash=(sha-256l:sha 32 (sha-256:sha (rsh [3 4] x)))
|
||||
?> =((end [3 4] x) (rsh [3 28] hash))
|
||||
(cut 3 [vw (sub (met 3 x) (add 4 vw))] x)
|
||||
::
|
||||
++ hash160
|
||||
|= d=@
|
||||
(ripemd-160:ripemd:crypto 32 (sha-256:sha d))
|
||||
::
|
||||
++ version-bytes
|
||||
|= [network=?(%main %regtest %testnet) type=?(%pub %prv) bip32=?]
|
||||
^- @ux
|
||||
|^
|
||||
?- type
|
||||
%pub ?:(bip32 xpub-key pay-to-pubkey)
|
||||
%prv ?:(bip32 xprv-key private-key)
|
||||
==
|
||||
::
|
||||
++ pay-to-pubkey ?:(=(network %main) 0x0 0x6f)
|
||||
++ private-key ?:(=(network %main) 0x80 0xef)
|
||||
++ xpub-key ?:(=(network %main) 0x488.b21e 0x435.87cf)
|
||||
++ xprv-key ?:(=(network %main) 0x488.ade4 0x435.8394)
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/bip32.hoon
Symbolic link
1
pkg/arvo/lib/bip32.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/bip32.hoon
|
@ -1,46 +0,0 @@
|
||||
:: bip39 implementation in hoon
|
||||
::
|
||||
/+ bip39-english
|
||||
::
|
||||
|%
|
||||
++ from-entropy
|
||||
|= byts
|
||||
^- tape
|
||||
=. wid (mul wid 8)
|
||||
~| [%unsupported-entropy-bit-length wid]
|
||||
?> &((gte wid 128) (lte wid 256))
|
||||
::
|
||||
=+ cs=(div wid 32)
|
||||
=/ check=@
|
||||
%+ rsh [0 (sub 256 cs)]
|
||||
(sha-256l:sha (div wid 8) dat)
|
||||
=/ bits=byts
|
||||
:- (add wid cs)
|
||||
%+ can 0
|
||||
:~ cs^check
|
||||
wid^dat
|
||||
==
|
||||
::
|
||||
=/ pieces
|
||||
|- ^- (list @)
|
||||
:- (end [0 11] dat.bits)
|
||||
?: (lte wid.bits 11) ~
|
||||
$(bits [(sub wid.bits 11) (rsh [0 11] dat.bits)])
|
||||
::
|
||||
=/ words=(list tape)
|
||||
%+ turn pieces
|
||||
|= ind=@ud
|
||||
(snag ind `(list tape)`bip39-english)
|
||||
::
|
||||
%+ roll (flop words)
|
||||
|= [nex=tape all=tape]
|
||||
?~ all nex
|
||||
:(weld all " " nex)
|
||||
::
|
||||
::NOTE always produces a 512-bit result
|
||||
++ to-seed
|
||||
|= [mnem=tape pass=tape]
|
||||
^- @
|
||||
%- hmac-sha512t:pbkdf:crypto
|
||||
[(crip mnem) (crip (weld "mnemonic" pass)) 2.048 64]
|
||||
--
|
1
pkg/arvo/lib/bip39.hoon
Symbolic link
1
pkg/arvo/lib/bip39.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/bip39.hoon
|
File diff suppressed because it is too large
Load Diff
1
pkg/arvo/lib/bip39/english.hoon
Symbolic link
1
pkg/arvo/lib/bip39/english.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/bip39/english.hoon
|
@ -1,155 +0,0 @@
|
||||
:: dbug: agent wrapper for generic debugging tools
|
||||
::
|
||||
:: usage: %-(agent:dbug your-agent)
|
||||
::
|
||||
|%
|
||||
+$ poke
|
||||
$% [%bowl ~]
|
||||
[%state grab=cord]
|
||||
[%incoming =about]
|
||||
[%outgoing =about]
|
||||
==
|
||||
::
|
||||
+$ about
|
||||
$@ ~
|
||||
$% [%ship =ship]
|
||||
[%path =path]
|
||||
[%wire =wire]
|
||||
[%term =term]
|
||||
==
|
||||
::
|
||||
++ agent
|
||||
|= =agent:gall
|
||||
^- agent:gall
|
||||
!.
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
ag ~(. agent bowl)
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
?. ?=(%dbug mark)
|
||||
=^ cards agent (on-poke:ag mark vase)
|
||||
[cards this]
|
||||
=/ dbug
|
||||
!<(poke vase)
|
||||
=; =tang
|
||||
((%*(. slog pri 1) tang) [~ this])
|
||||
?- -.dbug
|
||||
%bowl [(sell !>(bowl))]~
|
||||
::
|
||||
%state
|
||||
=? grab.dbug =('' grab.dbug) '-'
|
||||
=; product=^vase
|
||||
[(sell product)]~
|
||||
=/ state=^vase
|
||||
:: if the underlying app has implemented a /dbug/state scry endpoint,
|
||||
:: use that vase in place of +on-save's.
|
||||
::
|
||||
=/ result=(each ^vase tang)
|
||||
(mule |.(q:(need (need (on-peek:ag /x/dbug/state)))))
|
||||
?:(?=(%& -.result) p.result on-save:ag)
|
||||
%+ slap
|
||||
(slop state !>([bowl=bowl ..zuse]))
|
||||
(ream grab.dbug)
|
||||
::
|
||||
%incoming
|
||||
=; =tang
|
||||
?^ tang tang
|
||||
[%leaf "no matching subscriptions"]~
|
||||
%+ murn
|
||||
%+ sort ~(tap by sup.bowl)
|
||||
|= [[* a=[=ship =path]] [* b=[=ship =path]]]
|
||||
(aor [path ship]:a [path ship]:b)
|
||||
|= [=duct [=ship =path]]
|
||||
^- (unit tank)
|
||||
=; relevant=?
|
||||
?. relevant ~
|
||||
`>[path=path from=ship duct=duct]<
|
||||
?: ?=(~ about.dbug) &
|
||||
?- -.about.dbug
|
||||
%ship =(ship ship.about.dbug)
|
||||
%path ?=(^ (find path.about.dbug path))
|
||||
%wire %+ lien duct
|
||||
|=(=wire ?=(^ (find wire.about.dbug wire)))
|
||||
%term !!
|
||||
==
|
||||
::
|
||||
%outgoing
|
||||
=; =tang
|
||||
?^ tang tang
|
||||
[%leaf "no matching subscriptions"]~
|
||||
%+ murn
|
||||
%+ sort ~(tap by wex.bowl)
|
||||
|= [[[a=wire *] *] [[b=wire *] *]]
|
||||
(aor a b)
|
||||
|= [[=wire =ship =term] [acked=? =path]]
|
||||
^- (unit tank)
|
||||
=; relevant=?
|
||||
?. relevant ~
|
||||
`>[wire=wire agnt=[ship term] path=path ackd=acked]<
|
||||
?: ?=(~ about.dbug) &
|
||||
?- -.about.dbug
|
||||
%ship =(ship ship.about.dbug)
|
||||
%path ?=(^ (find path.about.dbug path))
|
||||
%wire ?=(^ (find wire.about.dbug wire))
|
||||
%term =(term term.about.dbug)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ on-peek
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
?. ?=([@ %dbug *] path)
|
||||
(on-peek:ag path)
|
||||
?+ path [~ ~]
|
||||
[%u %dbug ~] ``noun+!>(&)
|
||||
[%x %dbug %state ~] ``noun+!>(on-save:ag)
|
||||
[%x %dbug %subscriptions ~] ``noun+!>([wex sup]:bowl)
|
||||
==
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards agent on-init:ag
|
||||
[cards this]
|
||||
::
|
||||
++ on-save on-save:ag
|
||||
::
|
||||
++ on-load
|
||||
|= old-state=vase
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards agent (on-load:ag old-state)
|
||||
[cards this]
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards agent (on-watch:ag path)
|
||||
[cards this]
|
||||
::
|
||||
++ on-leave
|
||||
|= =path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards agent (on-leave:ag path)
|
||||
[cards this]
|
||||
::
|
||||
++ on-agent
|
||||
|= [=wire =sign:agent:gall]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards agent (on-agent:ag wire sign)
|
||||
[cards this]
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards agent (on-arvo:ag wire sign-arvo)
|
||||
[cards this]
|
||||
::
|
||||
++ on-fail
|
||||
|= [=term =tang]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards agent (on-fail:ag term tang)
|
||||
[cards this]
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/dbug.hoon
Symbolic link
1
pkg/arvo/lib/dbug.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/dbug.hoon
|
@ -1,69 +0,0 @@
|
||||
/+ skeleton
|
||||
|* [agent=* help=*]
|
||||
?: ?=(%& help)
|
||||
~| %default-agent-helpfully-crashing
|
||||
skeleton
|
||||
|_ =bowl:gall
|
||||
++ on-init
|
||||
`agent
|
||||
::
|
||||
++ on-save
|
||||
!>(~)
|
||||
::
|
||||
++ on-load
|
||||
|= old-state=vase
|
||||
`agent
|
||||
::
|
||||
++ on-poke
|
||||
|= =cage
|
||||
~| "unexpected poke to {<dap.bowl>} with mark {<p.cage>}"
|
||||
!!
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
~| "unexpected subscription to {<dap.bowl>} on path {<path>}"
|
||||
!!
|
||||
::
|
||||
++ on-leave
|
||||
|= path
|
||||
`agent
|
||||
::
|
||||
++ on-peek
|
||||
|= =path
|
||||
~| "unexpected scry into {<dap.bowl>} on path {<path>}"
|
||||
!!
|
||||
::
|
||||
++ on-agent
|
||||
|= [=wire =sign:agent:gall]
|
||||
^- (quip card:agent:gall _agent)
|
||||
?- -.sign
|
||||
%poke-ack
|
||||
?~ p.sign
|
||||
`agent
|
||||
%- (slog leaf+"poke failed from {<dap.bowl>} on wire {<wire>}" u.p.sign)
|
||||
`agent
|
||||
::
|
||||
%watch-ack
|
||||
?~ p.sign
|
||||
`agent
|
||||
=/ =tank leaf+"subscribe failed from {<dap.bowl>} on wire {<wire>}"
|
||||
%- (slog tank u.p.sign)
|
||||
`agent
|
||||
::
|
||||
%kick `agent
|
||||
%fact
|
||||
~| "unexpected subscription update to {<dap.bowl>} on wire {<wire>}"
|
||||
~| "with mark {<p.cage.sign>}"
|
||||
!!
|
||||
==
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
~| "unexpected system response {<-.sign-arvo>} to {<dap.bowl>} on wire {<wire>}"
|
||||
!!
|
||||
::
|
||||
++ on-fail
|
||||
|= [=term =tang]
|
||||
%- (slog leaf+"error in {<dap.bowl>}" >term< tang)
|
||||
`agent
|
||||
--
|
1
pkg/arvo/lib/default-agent.hoon
Symbolic link
1
pkg/arvo/lib/default-agent.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/default-agent.hoon
|
1
pkg/arvo/lib/docket.hoon
Symbolic link
1
pkg/arvo/lib/docket.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/docket.hoon
|
@ -1,257 +0,0 @@
|
||||
:: ethio: Asynchronous Ethereum input/output functions.
|
||||
::
|
||||
/- rpc=json-rpc
|
||||
/+ ethereum, strandio
|
||||
=, ethereum-types
|
||||
=, jael
|
||||
::
|
||||
=> |%
|
||||
+$ topics (list ?(@ux (list @ux)))
|
||||
--
|
||||
|%
|
||||
:: +request-rpc: send rpc request, with retry
|
||||
::
|
||||
++ request-rpc
|
||||
|= [url=@ta id=(unit @t) req=request:rpc:ethereum]
|
||||
=/ m (strand:strandio ,json)
|
||||
^- form:m
|
||||
;< res=(list [id=@t =json]) bind:m
|
||||
(request-batch-rpc-strict url [id req]~)
|
||||
?: ?=([* ~] res)
|
||||
(pure:m json.i.res)
|
||||
%+ strand-fail:strandio
|
||||
%unexpected-multiple-results
|
||||
[>(lent res)< ~]
|
||||
:: +request-batch-rpc-strict: send rpc requests, with retry
|
||||
::
|
||||
:: sends a batch request. produces results for all requests in the batch,
|
||||
:: but only if all of them are successful.
|
||||
::
|
||||
++ request-batch-rpc-strict
|
||||
|= [url=@ta reqs=(list [id=(unit @t) req=request:rpc:ethereum])]
|
||||
|^ %+ (retry:strandio results)
|
||||
`10
|
||||
attempt-request
|
||||
::
|
||||
+$ results (list [id=@t =json])
|
||||
::
|
||||
++ attempt-request
|
||||
=/ m (strand:strandio ,(unit results))
|
||||
^- form:m
|
||||
;< responses=(list response:rpc) bind:m
|
||||
(request-batch-rpc-loose url reqs)
|
||||
=- ?~ err
|
||||
(pure:m `res)
|
||||
(pure:m ~)
|
||||
%+ roll responses
|
||||
|= $: rpc=response:rpc
|
||||
[res=results err=(list [id=@t code=@t message=@t])]
|
||||
==
|
||||
?: ?=(%error -.rpc)
|
||||
[res [+.rpc err]]
|
||||
?. ?=(%result -.rpc)
|
||||
[res [['' 'ethio-rpc-fail' (crip <rpc>)] err]]
|
||||
[[+.rpc res] err]
|
||||
--
|
||||
:: +request-batch-rpc-loose: send rpc requests, with retry
|
||||
::
|
||||
:: sends a batch request. produces results for all requests in the batch,
|
||||
:: including the ones that are unsuccessful.
|
||||
::
|
||||
++ request-batch-rpc-loose
|
||||
|= [url=@ta reqs=(list [id=(unit @t) req=request:rpc:ethereum])]
|
||||
|^ %+ (retry:strandio results)
|
||||
`10
|
||||
attempt-request
|
||||
::
|
||||
+$ result response:rpc
|
||||
+$ results (list response:rpc)
|
||||
::
|
||||
++ attempt-request
|
||||
=/ m (strand:strandio ,(unit results))
|
||||
^- form:m
|
||||
=/ =request:http
|
||||
:* method=%'POST'
|
||||
url=url
|
||||
header-list=['Content-Type'^'application/json' ~]
|
||||
::
|
||||
^= body
|
||||
%- some %- as-octt:mimes:html
|
||||
%- en-json:html
|
||||
a+(turn reqs request-to-json:rpc:ethereum)
|
||||
==
|
||||
;< ~ bind:m
|
||||
(send-request:strandio request)
|
||||
;< rep=(unit client-response:iris) bind:m
|
||||
take-maybe-response:strandio
|
||||
?~ rep
|
||||
(pure:m ~)
|
||||
(parse-responses u.rep)
|
||||
::
|
||||
++ parse-responses
|
||||
|= =client-response:iris
|
||||
=/ m (strand:strandio ,(unit results))
|
||||
^- form:m
|
||||
?> ?=(%finished -.client-response)
|
||||
?~ full-file.client-response
|
||||
(pure:m ~)
|
||||
=/ body=@t q.data.u.full-file.client-response
|
||||
=/ jon=(unit json) (de-json:html body)
|
||||
?~ jon
|
||||
(pure:m ~)
|
||||
=/ array=(unit (list response:rpc))
|
||||
((ar:dejs-soft:format parse-one-response) u.jon)
|
||||
?~ array
|
||||
(strand-fail:strandio %rpc-result-incomplete-batch >u.jon< ~)
|
||||
(pure:m array)
|
||||
::
|
||||
++ parse-one-response
|
||||
|= =json
|
||||
^- (unit response:rpc)
|
||||
=/ res=(unit [@t ^json])
|
||||
%. json
|
||||
=, dejs-soft:format
|
||||
(ot id+so result+some ~)
|
||||
?^ res `[%result u.res]
|
||||
~| parse-one-response=json
|
||||
:+ ~ %error %- need
|
||||
%. json
|
||||
=, dejs-soft:format
|
||||
(ot id+so error+(ot code+no message+so ~) ~)
|
||||
--
|
||||
::
|
||||
:: +read-contract: calls a read function on a contract, produces result hex
|
||||
::
|
||||
++ read-contract
|
||||
|= [url=@t req=proto-read-request:rpc:ethereum]
|
||||
=/ m (strand:strandio ,@t)
|
||||
;< res=(list [id=@t res=@t]) bind:m
|
||||
(batch-read-contract-strict url [req]~)
|
||||
?: ?=([* ~] res)
|
||||
(pure:m res.i.res)
|
||||
%+ strand-fail:strandio
|
||||
%unexpected-multiple-results
|
||||
[>(lent res)< ~]
|
||||
:: +batch-read-contract-strict: calls read functions on contracts
|
||||
::
|
||||
:: sends a batch request. produces results for all requests in the batch,
|
||||
:: but only if all of them are successful.
|
||||
::
|
||||
++ batch-read-contract-strict
|
||||
|= [url=@t reqs=(list proto-read-request:rpc:ethereum)]
|
||||
|^ =/ m (strand:strandio ,results)
|
||||
^- form:m
|
||||
;< res=(list [id=@t =json]) bind:m
|
||||
%+ request-batch-rpc-strict url
|
||||
(turn reqs proto-to-rpc)
|
||||
=+ ^- [=results =failures]
|
||||
(roll res response-to-result)
|
||||
?~ failures (pure:m results)
|
||||
(strand-fail:strandio %batch-read-failed-for >failures< ~)
|
||||
::
|
||||
+$ results (list [id=@t res=@t])
|
||||
+$ failures (list [id=@t =json])
|
||||
::
|
||||
++ proto-to-rpc
|
||||
|= proto-read-request:rpc:ethereum
|
||||
^- [(unit @t) request:rpc:ethereum]
|
||||
:- id
|
||||
:+ %eth-call
|
||||
^- call:rpc:ethereum
|
||||
[~ to ~ ~ ~ `tape`(encode-call:rpc:ethereum function arguments)]
|
||||
[%label %latest]
|
||||
::
|
||||
++ response-to-result
|
||||
|= [[id=@t =json] =results =failures]
|
||||
^+ [results failures]
|
||||
?: ?=(%s -.json)
|
||||
[[id^p.json results] failures]
|
||||
[results [id^json failures]]
|
||||
--
|
||||
::
|
||||
::
|
||||
++ get-latest-block
|
||||
|= url=@ta
|
||||
=/ m (strand:strandio ,block)
|
||||
^- form:m
|
||||
;< =json bind:m
|
||||
(request-rpc url `'block number' %eth-block-number ~)
|
||||
(get-block-by-number url (parse-eth-block-number:rpc:ethereum json))
|
||||
::
|
||||
++ get-block-by-number
|
||||
|= [url=@ta =number:block]
|
||||
=/ m (strand:strandio ,block)
|
||||
^- form:m
|
||||
|^
|
||||
%+ (retry:strandio ,block) `10
|
||||
=/ m (strand:strandio ,(unit block))
|
||||
^- form:m
|
||||
;< =json bind:m
|
||||
%+ request-rpc url
|
||||
:- `'block by number'
|
||||
[%eth-get-block-by-number number |]
|
||||
(pure:m (parse-block json))
|
||||
::
|
||||
++ parse-block
|
||||
|= =json
|
||||
^- (unit block)
|
||||
=< ?~(. ~ `[[&1 &2] |2]:u)
|
||||
^- (unit [@ @ @])
|
||||
~| json
|
||||
%. json
|
||||
=, dejs-soft:format
|
||||
%- ot
|
||||
:~ hash+parse-hex
|
||||
number+parse-hex
|
||||
'parentHash'^parse-hex
|
||||
==
|
||||
::
|
||||
++ parse-hex |=(=json `(unit @)`(some (parse-hex-result:rpc:ethereum json)))
|
||||
--
|
||||
::
|
||||
++ get-logs-by-hash
|
||||
|= [url=@ta =hash:block contracts=(list address) =topics]
|
||||
=/ m (strand:strandio (list event-log:rpc:ethereum))
|
||||
^- form:m
|
||||
;< =json bind:m
|
||||
%+ request-rpc url
|
||||
:* `'logs by hash'
|
||||
%eth-get-logs-by-hash
|
||||
hash
|
||||
contracts
|
||||
topics
|
||||
==
|
||||
%- pure:m
|
||||
(parse-event-logs:rpc:ethereum json)
|
||||
::
|
||||
++ get-logs-by-range
|
||||
|= $: url=@ta
|
||||
contracts=(list address)
|
||||
=topics
|
||||
=from=number:block
|
||||
=to=number:block
|
||||
==
|
||||
=/ m (strand:strandio (list event-log:rpc:ethereum))
|
||||
^- form:m
|
||||
;< =json bind:m
|
||||
%+ request-rpc url
|
||||
:* `'logs by range'
|
||||
%eth-get-logs
|
||||
`number+from-number
|
||||
`number+to-number
|
||||
contracts
|
||||
topics
|
||||
==
|
||||
%- pure:m
|
||||
(parse-event-logs:rpc:ethereum json)
|
||||
::
|
||||
++ get-next-nonce
|
||||
|= [url=@ta =address]
|
||||
=/ m (strand:strandio ,@ud)
|
||||
^- form:m
|
||||
;< =json bind:m
|
||||
%^ request-rpc url `'nonce'
|
||||
[%eth-get-transaction-count address [%label %latest]]
|
||||
%- pure:m
|
||||
(parse-eth-get-transaction-count:rpc:ethereum json)
|
||||
--
|
1
pkg/arvo/lib/ethio.hoon
Symbolic link
1
pkg/arvo/lib/ethio.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/ethio.hoon
|
@ -81,8 +81,7 @@
|
||||
--
|
||||
:: TODO: remove .ost
|
||||
::
|
||||
|= [hid=bowl:gall any-state]
|
||||
?> ?=(%4 +<+<)
|
||||
|= [hid=bowl:gall state]
|
||||
=* sat +<+
|
||||
=/ ost 0
|
||||
=+ (~(gut by bin) ost *source)
|
||||
|
@ -23,8 +23,7 @@
|
||||
^- state
|
||||
[%1 mass-timer:(~(got by hoc.s) 0)]
|
||||
--
|
||||
|= [=bowl:gall sat=any-state]
|
||||
?> ?=(%1 -.sat)
|
||||
|= [=bowl:gall sat=state]
|
||||
=| moz=(list card)
|
||||
|%
|
||||
++ this .
|
||||
|
@ -5,19 +5,21 @@
|
||||
=, format
|
||||
=* dude dude:gall
|
||||
|%
|
||||
+$ state state-3
|
||||
+$ state state-4
|
||||
+$ state-4 [%4 pith-4]
|
||||
+$ state-3 [%3 pith-3]
|
||||
+$ state-2 [%2 pith-2]
|
||||
+$ state-1 [%1 pith-1]
|
||||
+$ state-0 [%0 pith-0]
|
||||
+$ any-state
|
||||
$~ *state
|
||||
$% state-3
|
||||
$% state-4
|
||||
state-3
|
||||
state-2
|
||||
state-1
|
||||
state-0
|
||||
==
|
||||
+$ pith-3 ::
|
||||
+$ pith-4 ::
|
||||
$: rem=(map desk per-desk) ::
|
||||
syn=(map kiln-sync let=@ud) ::
|
||||
ark=(map desk arak) ::
|
||||
@ -31,6 +33,32 @@
|
||||
:: request is made multiple times.
|
||||
hxs=(map desk @ud)
|
||||
== ::
|
||||
+$ pith-3 ::
|
||||
$: rem=(map desk per-desk) ::
|
||||
syn=(map kiln-sync let=@ud) ::
|
||||
ark=(map desk arak-3) ::
|
||||
commit-timer=[way=wire nex=@da tim=@dr mon=term] ::
|
||||
:: map desk to the currently ongoing fuse request
|
||||
:: and the latest version numbers for beaks to
|
||||
fus=(map desk per-fuse)
|
||||
:: used for fuses - every time we get a fuse we
|
||||
:: bump this. used when calculating hashes to
|
||||
:: ensure they're unique even when the same
|
||||
:: request is made multiple times.
|
||||
hxs=(map desk @ud)
|
||||
==
|
||||
+$ arak-3
|
||||
$: =ship
|
||||
=desk
|
||||
=aeon
|
||||
next=(list [=aeon =weft])
|
||||
rein=rein-3
|
||||
==
|
||||
+$ rein-3
|
||||
$: add=(set dude)
|
||||
sub=(set dude)
|
||||
==
|
||||
::
|
||||
+$ pith-2 ::
|
||||
$: rem=(map desk per-desk) ::
|
||||
syn=(map kiln-sync let=@ud) ::
|
||||
@ -116,8 +144,7 @@
|
||||
::
|
||||
+$ kiln-fuse-list (unit desk)
|
||||
--
|
||||
|= [bowl:gall any-state]
|
||||
?> ?=(%3 +<+<)
|
||||
|= [bowl:gall state]
|
||||
?> =(src our)
|
||||
=| moz=(list card:agent:gall)
|
||||
|%
|
||||
@ -142,7 +169,7 @@
|
||||
++ on-init
|
||||
=< abet
|
||||
~> %slog.0^leaf/"kiln: boot"
|
||||
=/ =rein [add=(sy %hood %dojo ~) sub=~] :: TODO questionable
|
||||
=/ =rein [liv=& add=(sy %hood %dojo ~) sub=~] :: TODO questionable
|
||||
=/ daz (get-apps-want base-bill rein)
|
||||
%- emil
|
||||
%- zing ^- (list (list card:agent:gall))
|
||||
@ -190,8 +217,17 @@
|
||||
fus.old
|
||||
hxs.old
|
||||
==
|
||||
=? old ?=(%3 -.old)
|
||||
:* %4
|
||||
rem.old
|
||||
syn.old
|
||||
ark=(~(run by ark.old) |=(a=arak-3 a(rein [liv=& rein.a])))
|
||||
commit-timer.old
|
||||
fus.old
|
||||
hxs.old
|
||||
==
|
||||
::
|
||||
?> ?=(%3 -.old)
|
||||
?> ?=(%4 -.old)
|
||||
=. +<+.$.abet old
|
||||
=< abet
|
||||
?~ old-ota
|
||||
@ -202,9 +238,23 @@
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
?+ path [~ ~]
|
||||
[%x %kiln %vats ~]
|
||||
[%x %kiln %lag ~] ``loob+!>(.^(? //(scot %p our)//(scot %da now)/zen/lag))
|
||||
::
|
||||
[%x %kiln %vat @ ~]
|
||||
=* loc i.t.t.t.path
|
||||
=/ ego (scot %p our)
|
||||
=/ wen (scot %da now)
|
||||
=/ rak=(unit arak) (~(get by ark) loc)
|
||||
?~ rak [~ ~]
|
||||
=/ hog .^(@uv cz+~[ego loc wen])
|
||||
=/ cas .^(cass cw+~[ego loc wen])
|
||||
:^ ~ ~ %noun
|
||||
!> ^- (list [=desk hash=@uv =cass =arak])
|
||||
!> ^- vat
|
||||
[loc hog cas u.rak]
|
||||
::
|
||||
[%x %kiln %vats ~]
|
||||
:^ ~ ~ %kiln-vats
|
||||
!> ^- (list vat)
|
||||
=/ ego (scot %p our)
|
||||
=/ wen (scot %da now)
|
||||
%+ turn ~(tap by ark)
|
||||
@ -241,11 +291,12 @@
|
||||
++ emil |=((list card:agent:gall) vats(kiln (^emil +<)))
|
||||
++ give
|
||||
|%
|
||||
++ snap [%give %fact ~[/vats] %kiln-vats-snap !>(ark)]
|
||||
++ diff |=(d=^diff [%give %fact ~[/vats] %kiln-vats-diff !>(d)])
|
||||
++ snap [%give %fact ~[/kiln/vats] %kiln-vats-snap !>(ark)]
|
||||
++ diff |=(d=^diff [%give %fact ~[/kiln/vats] %kiln-vats-diff !>(d)])
|
||||
--
|
||||
++ pass
|
||||
|%
|
||||
++ pyre |=(=tang [%pass /kiln/vats %pyre tang])
|
||||
++ find (warp %find [%sing %y ud+1 /])
|
||||
++ sync-da (warp %sync [%sing %w da+now /])
|
||||
++ sync-ud (warp %sync [%sing %w ud+aeon.rak /])
|
||||
@ -290,18 +341,14 @@
|
||||
|= lac=desk
|
||||
^+ kiln
|
||||
?: =(%base lac)
|
||||
~> %slog.0^leaf/"kiln: |uninstall: %base cannot be uninstalled"
|
||||
!!
|
||||
=- (^emit (pyre:pass leaf/- ~))
|
||||
"kiln: |uninstall: %base cannot be uninstalled"
|
||||
?. (~(has by ark) lac)
|
||||
~> %slog.0^leaf/"kiln: |uninstall: {<lac>} not installed, ignoring"
|
||||
kiln
|
||||
=. vats (abed lac)
|
||||
~> %slog.0^leaf/"kiln: uninstalling {here}"
|
||||
=/ ded (get-apps-live our lac now)
|
||||
:: hood and dojo must never die
|
||||
::
|
||||
=. ded (skip ded |=(d=dude ?=(?(%hood %dojo) d)))
|
||||
=. vats (stop-dudes ded)
|
||||
=. vats stop-agents
|
||||
kiln(ark (~(del by ark) lac))
|
||||
:: +install: set up desk sync to .lac to install all apps from [her rem]
|
||||
::
|
||||
@ -326,24 +373,103 @@
|
||||
=. vats (emit (diff:give %reset loc rak))
|
||||
=. ark (~(del by ark) loc)
|
||||
(install loc [ship desk]:rak)
|
||||
:: +suspend: shut down all agents, keep syncing
|
||||
::
|
||||
++ suspend
|
||||
|= lac=desk
|
||||
^+ vats
|
||||
=/ got (~(get by ark) lac)
|
||||
?: =(%base lac)
|
||||
=- (emit (pyre:pass leaf/- ~))
|
||||
"kiln: suspend: %base cannot be suspended"
|
||||
?. (~(has by ark) lac)
|
||||
~> %slog.0^leaf/"kiln: suspend: {<lac>} not installed, ignoring"
|
||||
vats
|
||||
=. vats (abed lac)
|
||||
=. liv.rein.rak |
|
||||
=. vats stop-agents
|
||||
(emit (diff:give %suspend loc rak))
|
||||
:: +revive: restart agents on a suspended desk
|
||||
::
|
||||
++ revive
|
||||
|= lac=desk
|
||||
^+ vats
|
||||
=. vats (abed lac)
|
||||
=. liv.rein.rak &
|
||||
=. vats (update-running-apps (get-apps-diff our loc now rein.rak))
|
||||
(emit (diff:give %revive loc rak))
|
||||
:: +set-rein: adjust which agents are forced on or off
|
||||
::
|
||||
++ set-rein
|
||||
|= [lac=desk new=rein]
|
||||
^+ vats
|
||||
=. vats (abed lac)
|
||||
=^ old rein.rak [rein.rak new]
|
||||
?+ [liv.old liv.new] !!
|
||||
[%| %|] vats
|
||||
[%| %&] (revive lac)
|
||||
[%& %|] (suspend lac)
|
||||
[%& %&] (update-running-apps (get-apps-diff our loc now rein.rak))
|
||||
==
|
||||
:: +bump: handle kernel kelvin upgrade
|
||||
::
|
||||
:: Apply merges to revive faded agents on all paused desks.
|
||||
::
|
||||
++ bump
|
||||
|= except=(set desk)
|
||||
|= [except=(set desk) check=?]
|
||||
^+ kiln
|
||||
=/ kel=weft [%zuse zuse]
|
||||
=/ ded (~(dif in (get-blockers kel)) except)
|
||||
?. =(~ ded)
|
||||
~> %slog.0^leaf/"kiln: desks blocked upgrade {<ded>}"
|
||||
!!
|
||||
=/ liv (skip ~(tap by ark) |=([d=desk *] (~(has in except) d)))
|
||||
~> %slog.0^leaf/"kiln: bump {<liv>}"
|
||||
=< kiln
|
||||
|- ^+ vats
|
||||
?~ liv vats
|
||||
$(liv t.liv, vats (emit merge-main:pass(loc p.i.liv, rak q.i.liv)))
|
||||
|^ ^+ kiln
|
||||
?. check
|
||||
bump-all
|
||||
=/ ded find-blocked
|
||||
?: =(~ ded)
|
||||
bump-all
|
||||
=- (^emit (pyre:pass leaf/- ~))
|
||||
"kiln: desks blocked upgrade to {<zuse/zuse>}: {<ded>}"
|
||||
::
|
||||
++ find-blocked
|
||||
^- (set desk)
|
||||
(~(dif in (get-blockers zuse/zuse)) (~(put in except) %base))
|
||||
::
|
||||
++ bump-all
|
||||
=/ liv=(list desk) (skip ~(tap in ~(key by ark)) ~(has in except))
|
||||
~> %slog.0^leaf/"kiln: bump {<liv>}"
|
||||
|- ^+ kiln
|
||||
?~ liv kiln
|
||||
$(liv t.liv, kiln (bump-one i.liv))
|
||||
::
|
||||
++ bump-one
|
||||
|= =desk
|
||||
^+ kiln
|
||||
=< abet ^+ vats
|
||||
=. vats (abed desk)
|
||||
:: skip to first commit at new kelvin
|
||||
::
|
||||
=/ yon
|
||||
=* nex next.rak
|
||||
|- ^- (unit aeon)
|
||||
?~ nex ~
|
||||
?: =(kel weft.i.nex)
|
||||
`aeon.i.nex
|
||||
$(nex t.nex)
|
||||
?~ yon
|
||||
?. check
|
||||
~> %slog.0^leaf/"kiln: bump: ignoring {<desk>}"
|
||||
vats
|
||||
=- (emit (pyre:pass leaf/- ~))
|
||||
"kiln: {here} killed upgrade to {<zuse/zuse>}"
|
||||
=. next.rak (crank-next u.yon)
|
||||
(emit merge-main:pass)
|
||||
--
|
||||
:: +stop-agents: internal helper to suspend agents on .loc
|
||||
::
|
||||
:: Will not shut down %hood or %dojo.
|
||||
::
|
||||
++ stop-agents
|
||||
^+ vats
|
||||
=/ ded (get-apps-live our loc now)
|
||||
=. ded (skip ded |=(d=dude ?=(?(%hood %dojo) d)))
|
||||
(stop-dudes ded)
|
||||
::
|
||||
++ take
|
||||
|= [=wire syn=sign-arvo]
|
||||
@ -409,6 +535,7 @@
|
||||
=/ =diff [%block loc rak new-weft blockers=(sy %base ~)]
|
||||
(emil sync-ud:pass (diff:give diff) ~)
|
||||
~> %slog.0^leaf/"kiln: merging into {here}"
|
||||
=. next.rak (crank-next (dec aeon.rak))
|
||||
(emil ~[merge-main sync-ud]:pass)
|
||||
::
|
||||
=/ blockers
|
||||
@ -418,9 +545,11 @@
|
||||
::
|
||||
?. =(~ blockers)
|
||||
~> %slog.0^leaf/"kiln: OTA blocked on {<blockers>}"
|
||||
=. next.rak (snoc next.rak [(dec aeon.rak) new-weft])
|
||||
=/ =diff [%block loc rak new-weft blockers]
|
||||
(emil sync-ud:pass (diff:give diff) ~)
|
||||
~> %slog.0^leaf/"kiln: applying OTA to {here}, kelvin: {<new-weft>}"
|
||||
=. next.rak (crank-next (dec aeon.rak))
|
||||
(emil ~[merge-main sync-ud]:pass)
|
||||
::
|
||||
++ take-merge-main
|
||||
@ -439,10 +568,11 @@
|
||||
vats
|
||||
~> %slog.0^leaf/"kiln: merge into {here} succeeded"
|
||||
=. vats (emit (diff:give %merge loc rak))
|
||||
=. vats (update-running-apps (get-apps-diff our loc now rein.rak))
|
||||
=? vats liv.rein.rak
|
||||
(update-running-apps (get-apps-diff our loc now rein.rak))
|
||||
?. =(%base loc)
|
||||
vats
|
||||
=. kiln (bump (sy %base %kids ~))
|
||||
=. kiln (bump (sy %base %kids ~) check=|)
|
||||
(emit merge-kids:pass)
|
||||
::
|
||||
++ take-merge-kids
|
||||
@ -484,14 +614,18 @@
|
||||
|= daz=(list dude)
|
||||
~> %slog.0^leaf/"kiln: stopping {<daz>}"
|
||||
(emil `(list card:agent:gall)`(zing (turn daz stop-dude:pass)))
|
||||
:: +crank-next: pop stale aeons from .next.rak
|
||||
::
|
||||
++ crank-next
|
||||
|= new=aeon
|
||||
^+ next.rak
|
||||
=/ rog next.rak
|
||||
|- ^+ next.rak
|
||||
?~ rog next.rak
|
||||
?: =(new aeon.i.rog)
|
||||
t.rog
|
||||
$(rog t.rog)
|
||||
--
|
||||
:: +get-ankh: extract $ankh from clay %v response $rant
|
||||
::
|
||||
++ get-ankh
|
||||
|= =rant
|
||||
^- ankh
|
||||
?> ?=(%dome p.r.rant)
|
||||
!<(ankh q.r.rant)
|
||||
:: +get-blockers: find desks that would block a kernel update
|
||||
::
|
||||
++ get-blockers
|
||||
@ -500,11 +634,9 @@
|
||||
%- ~(gas in *(set desk))
|
||||
%+ murn ~(tap by ark)
|
||||
|= [=desk =arak]
|
||||
:: TODO: make this work -- aeon.arak is wrong
|
||||
:: also, scrying at current doesn't work because middle of event
|
||||
:: maybe replace with %warp
|
||||
::?: =(kel (read-kelvin-local our desk aeon.arak))
|
||||
?: &
|
||||
?: =(%base desk)
|
||||
~
|
||||
?. liv.rein.arak
|
||||
~
|
||||
?: (lien next.arak |=([* k=weft] =(k kel)))
|
||||
~
|
||||
@ -542,7 +674,10 @@
|
||||
%kiln-merge =;(f (f !<(_+<.f vase)) poke-merge)
|
||||
%kiln-mount =;(f (f !<(_+<.f vase)) poke-mount)
|
||||
%kiln-nuke =;(f (f !<(_+<.f vase)) poke-nuke)
|
||||
%kiln-suspend =;(f (f !<(_+<.f vase)) poke-suspend)
|
||||
%kiln-permission =;(f (f !<(_+<.f vase)) poke-permission)
|
||||
%kiln-revive =;(f (f !<(_+<.f vase)) poke-revive)
|
||||
%kiln-rein =;(f (f !<(_+<.f vase)) poke-rein)
|
||||
%kiln-rm =;(f (f !<(_+<.f vase)) poke-rm)
|
||||
%kiln-schedule =;(f (f !<(_+<.f vase)) poke-schedule)
|
||||
%kiln-sync =;(f (f !<(_+<.f vase)) poke-sync)
|
||||
@ -565,7 +700,7 @@
|
||||
(emit %pass way.commit-timer %arvo %b [%wait nex.commit-timer])
|
||||
::
|
||||
++ poke-bump
|
||||
|= except=(set desk)
|
||||
|= [except=(set desk) check=?]
|
||||
abet:(bump:vats +<)
|
||||
::
|
||||
++ poke-cancel
|
||||
@ -699,6 +834,14 @@
|
||||
=/ =rite [%r ~ ?:(pub %black %white) ~]
|
||||
[%pass /kiln/permission %arvo %c [%perm syd pax rite]]
|
||||
::
|
||||
++ poke-rein
|
||||
|= [=desk =rein]
|
||||
abet:abet:(set-rein:vats +<)
|
||||
::
|
||||
++ poke-revive
|
||||
|= =desk
|
||||
abet:abet:(revive:vats desk)
|
||||
::
|
||||
++ poke-rm
|
||||
|= a=path
|
||||
=+ b=.^(arch %cy a)
|
||||
@ -714,6 +857,10 @@
|
||||
=+ old=;;((map @da cord) (fall (file where) ~))
|
||||
`(foal where %sched !>((~(put by old) tym eve)))
|
||||
::
|
||||
++ poke-suspend
|
||||
|= =desk
|
||||
abet:abet:(suspend:vats desk)
|
||||
::
|
||||
++ poke-sync
|
||||
|= hos=kiln-sync
|
||||
?: (~(has by syn) hos)
|
||||
@ -761,6 +908,8 @@
|
||||
|= =path
|
||||
?> (team:title our src)
|
||||
?+ path ~|(kiln-path/path !!)
|
||||
[%vats ~] abet
|
||||
::
|
||||
[%ark ~]
|
||||
abet(moz :_(moz [%give %fact ~ %kiln-vats-snap !>(ark)]))
|
||||
==
|
||||
|
@ -1,61 +0,0 @@
|
||||
/- *language-server
|
||||
::
|
||||
|%
|
||||
++ parse-error
|
||||
|= =tape
|
||||
^- (unit [=path =range])
|
||||
=/ parse-pair
|
||||
%+ cook
|
||||
|=([row=@ud col=@ud] [(dec row) col])
|
||||
(ifix [sel ser] ;~((glue ace) dem dem))
|
||||
=/ parse-path
|
||||
%+ cook
|
||||
|=(p=path (slag 3 p))
|
||||
(ifix [fas (jest '::')] (more fas urs:ab))
|
||||
=/ parse-full
|
||||
;~(plug parse-path ;~(sfix ;~((glue dot) parse-pair parse-pair) gar))
|
||||
(rust tape parse-full)
|
||||
::
|
||||
++ get-errors-from-tang
|
||||
|= [uri=@t =tang]
|
||||
^- (list range)
|
||||
=/ =path
|
||||
(uri-to-path uri)
|
||||
%+ murn tang
|
||||
|= =tank
|
||||
^- (unit range)
|
||||
?. ?=([%leaf *] tank)
|
||||
~
|
||||
=/ error
|
||||
(parse-error p.tank)
|
||||
?~ error
|
||||
~
|
||||
?: =(path path.u.error)
|
||||
`range.u.error
|
||||
~
|
||||
::
|
||||
++ uri-to-path
|
||||
|= uri=@t
|
||||
^- path
|
||||
=/ pier-root=(set cord)
|
||||
%- sy
|
||||
['app' 'gen' 'lib' 'mar' 'ren' 'sur' 'sys' 'test' ~]
|
||||
=/ path=(list cord)
|
||||
(parse-uri uri)
|
||||
|-
|
||||
?< ?=(~ path)
|
||||
?: (~(has in pier-root) i.path)
|
||||
`^path`path
|
||||
$(path t.path)
|
||||
::
|
||||
++ parse-uri
|
||||
|= uri=@t
|
||||
=- (fall - /fail)
|
||||
%+ rush uri
|
||||
%+ more
|
||||
;~(pose (plus fas) dot)
|
||||
%+ cook
|
||||
crip
|
||||
(star ;~(pose col hep alf))
|
||||
::
|
||||
--
|
1
pkg/arvo/lib/language-server/build.hoon
Symbolic link
1
pkg/arvo/lib/language-server/build.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/language-server/build.hoon
|
@ -1,386 +0,0 @@
|
||||
/+ language-server-parser
|
||||
:: Autocomplete for hoon.
|
||||
::
|
||||
=/ debug |
|
||||
|%
|
||||
+* option [item]
|
||||
[term=cord detail=item]
|
||||
::
|
||||
:: Like +rose except also produces line number
|
||||
::
|
||||
++ lily
|
||||
|* [los=tape sab=rule]
|
||||
=+ vex=(sab [[1 1] los])
|
||||
?~ q.vex
|
||||
[%| p=p.vex(q (dec q.p.vex))]
|
||||
?. =(~ q.q.u.q.vex)
|
||||
[%| p=p.vex(q (dec q.p.vex))]
|
||||
[%& p=p.u.q.vex]
|
||||
::
|
||||
:: Get all the identifiers accessible if this type is your subject.
|
||||
::
|
||||
++ get-identifiers
|
||||
|= ty=type
|
||||
%- flop
|
||||
|- ^- (list (option type))
|
||||
?- ty
|
||||
%noun ~
|
||||
%void ~
|
||||
[%atom *] ~
|
||||
[%cell *]
|
||||
%+ weld
|
||||
$(ty p.ty)
|
||||
$(ty q.ty)
|
||||
::
|
||||
[%core *]
|
||||
%- weld
|
||||
:_ ?. ?=(%gold r.p.q.ty)
|
||||
~
|
||||
$(ty p.ty)
|
||||
^- (list (option type))
|
||||
%- zing
|
||||
%+ turn ~(tap by q.r.q.ty)
|
||||
|= [term =tome]
|
||||
%+ turn
|
||||
~(tap by q.tome)
|
||||
|= [name=term =hoon]
|
||||
^- (pair term type)
|
||||
~| term=term
|
||||
[name ~(play ~(et ut ty) ~[name] ~)]
|
||||
::
|
||||
[%face *]
|
||||
?^ p.ty
|
||||
~
|
||||
[p.ty q.ty]~
|
||||
::
|
||||
[%fork *]
|
||||
%= $
|
||||
ty
|
||||
=/ tines ~(tap in p.ty)
|
||||
?~ tines
|
||||
%void
|
||||
|- ^- type
|
||||
?~ t.tines
|
||||
i.tines
|
||||
(~(fuse ut $(tines t.tines)) i.tines)
|
||||
==
|
||||
::
|
||||
[%hint *] $(ty q.ty)
|
||||
[%hold *] $(ty ~(repo ut ty))
|
||||
==
|
||||
::
|
||||
++ search-exact
|
||||
|* [sid=term options=(list (option))]
|
||||
=/ match
|
||||
%+ skim options
|
||||
|= [id=cord *]
|
||||
=(sid id)
|
||||
?~ match
|
||||
~
|
||||
[~ i.match]
|
||||
::
|
||||
:: Get all the identifiers that start with sid.
|
||||
::
|
||||
++ search-prefix
|
||||
|* [sid=cord ids=(list (option))]
|
||||
^+ ids
|
||||
%+ skim ids
|
||||
|= [id=cord *]
|
||||
^- ?(%.y %.n)
|
||||
=(sid (end [3 (met 3 sid)] id))
|
||||
::
|
||||
:: Get the longest prefix of a list of identifiers.
|
||||
::
|
||||
++ longest-match
|
||||
|= matches=(list (option))
|
||||
^- cord
|
||||
?~ matches
|
||||
''
|
||||
=/ n 1
|
||||
=/ last (met 3 term.i.matches)
|
||||
|- ^- term
|
||||
?: (gth n last)
|
||||
term.i.matches
|
||||
=/ prefix (end [3 n] term.i.matches)
|
||||
?: |- ^- ?
|
||||
?| ?=(~ t.matches)
|
||||
?& =(prefix (end [3 n] term.i.t.matches))
|
||||
$(t.matches t.t.matches)
|
||||
== ==
|
||||
$(n +(n))
|
||||
(end [3 (dec n)] term.i.matches)
|
||||
::
|
||||
:: Run +find-type safely, printing the first line of the stack trace on
|
||||
:: error.
|
||||
::
|
||||
++ find-type-mule
|
||||
|= [sut=type gen=hoon]
|
||||
^- (unit [term type])
|
||||
=/ res (mule |.((find-type sut gen)))
|
||||
?- -.res
|
||||
%& p.res
|
||||
%| ((slog (flop (scag 10 p.res))) ~)
|
||||
==
|
||||
::
|
||||
:: Get the subject type of the wing where you've put the "magic-spoon".
|
||||
::
|
||||
++ find-type
|
||||
|= [sut=type gen=hoon]
|
||||
=* loop $
|
||||
|^
|
||||
^- (unit [term type])
|
||||
?- gen
|
||||
[%cnts [%magic-spoon ~] *] `['' sut]
|
||||
[%cnts [%magic-spoon @ ~] *] `[i.t.p.gen sut]
|
||||
[%cnts [%magic-spoon @ *] *]
|
||||
%= $
|
||||
sut (~(play ut sut) wing+t.t.p.gen)
|
||||
t.p.gen t.p.gen(t ~)
|
||||
==
|
||||
::
|
||||
[%cnts [%magic-fork @ ~] *]
|
||||
`['' (~(play ut sut) wing+t.p.gen)]
|
||||
::
|
||||
[^ *] (both p.gen q.gen)
|
||||
[%brcn *] (grow q.gen)
|
||||
[%brpt *] (grow q.gen)
|
||||
[%cnts *]
|
||||
|- ^- (unit [term type])
|
||||
=* inner-loop $
|
||||
?~ q.gen
|
||||
~
|
||||
%+ replace
|
||||
loop(gen q.i.q.gen)
|
||||
|. inner-loop(q.gen t.q.gen)
|
||||
::
|
||||
[%dtkt *] (spec-and-hoon p.gen q.gen)
|
||||
[%dtls *] loop(gen p.gen)
|
||||
[%rock *] ~
|
||||
[%sand *] ~
|
||||
[%tune *] ~
|
||||
[%dttr *] (both p.gen q.gen)
|
||||
[%dtts *] (both p.gen q.gen)
|
||||
[%dtwt *] loop(gen p.gen)
|
||||
[%hand *] ~
|
||||
[%ktbr *] loop(gen p.gen)
|
||||
[%ktls *] (both p.gen q.gen)
|
||||
[%ktpm *] loop(gen p.gen)
|
||||
[%ktsg *] loop(gen p.gen)
|
||||
[%ktwt *] loop(gen p.gen)
|
||||
[%note *] loop(gen q.gen)
|
||||
[%sgzp *] (both p.gen q.gen)
|
||||
[%sggr *] loop(gen q.gen) :: should check for hoon in p.gen
|
||||
[%tsgr *] (change p.gen q.gen)
|
||||
[%tscm *]
|
||||
%+ replace
|
||||
loop(gen p.gen)
|
||||
|.(loop(gen q.gen, sut (~(busk ut sut) p.gen)))
|
||||
::
|
||||
[%wtcl *] (bell p.gen q.gen r.gen)
|
||||
[%fits *] (both p.gen wing+q.gen)
|
||||
[%wthx *] loop(gen wing+q.gen)
|
||||
[%dbug *] loop(gen q.gen)
|
||||
[%zpcm *] (both p.gen q.gen)
|
||||
[%lost *] loop(gen p.gen)
|
||||
[%zpmc *] (both p.gen q.gen)
|
||||
[%zpts *] loop(gen p.gen)
|
||||
[%zppt *] (both q.gen r.gen)
|
||||
[%zpgl *] (spec-and-hoon p.gen q.gen)
|
||||
[%zpzp *] ~
|
||||
*
|
||||
=+ doz=~(open ap gen)
|
||||
?: =(doz gen)
|
||||
~_ (show [%c 'hoon'] [%q gen])
|
||||
~> %mean.'play-open'
|
||||
!!
|
||||
loop(gen doz)
|
||||
==
|
||||
::
|
||||
++ replace
|
||||
|= [a=(unit [term type]) b=(trap (unit [term type]))]
|
||||
^- (unit [term type])
|
||||
?~(a $:b a)
|
||||
::
|
||||
++ both
|
||||
|= [a=hoon b=hoon]
|
||||
(replace loop(gen a) |.(loop(gen b)))
|
||||
::
|
||||
++ bell
|
||||
|= [a=hoon b=hoon c=hoon]
|
||||
%+ replace loop(gen a)
|
||||
|. %+ replace loop(gen b, sut (~(gain ut sut) a))
|
||||
|. loop(gen c, sut (~(lose ut sut) a))
|
||||
::
|
||||
++ spec-and-hoon
|
||||
|= [a=spec b=hoon]
|
||||
(replace (find-type-in-spec sut a) |.(loop(gen b)))
|
||||
::
|
||||
++ change
|
||||
|= [a=hoon b=hoon]
|
||||
(replace loop(gen a) |.(loop(gen b, sut (~(play ut sut) a))))
|
||||
::
|
||||
++ grow
|
||||
|= m=(map term tome)
|
||||
=/ tomes ~(tap by m)
|
||||
|- ^- (unit [term type])
|
||||
=* outer-loop $
|
||||
?~ tomes
|
||||
~
|
||||
=/ arms ~(tap by q.q.i.tomes)
|
||||
|- ^- (unit [term type])
|
||||
=* inner-loop $
|
||||
?~ arms
|
||||
outer-loop(tomes t.tomes)
|
||||
%+ replace
|
||||
loop(gen q.i.arms, sut (~(play ut sut) gen))
|
||||
|. inner-loop(arms t.arms)
|
||||
--
|
||||
::
|
||||
:: Not implemented yet. I wonder whether we should modify types found
|
||||
:: in spec mode such that if it's a mold that produces a type, it
|
||||
:: should just display the type and not that it's technically a
|
||||
:: function.
|
||||
::
|
||||
++ find-type-in-spec
|
||||
|= [sut=type pec=spec]
|
||||
^- (unit [term type])
|
||||
~
|
||||
::
|
||||
++ get-id-sym
|
||||
|= [pos=@ud =tape]
|
||||
%^ get-id pos tape
|
||||
^- $-(nail (like (unit @t)))
|
||||
;~(sfix (punt sym) (star ;~(pose prn (just `@`10))))
|
||||
::
|
||||
++ get-id-cord
|
||||
|= [pos=@ud =tape]
|
||||
%^ get-id pos tape
|
||||
^- $-(nail (like (unit @t)))
|
||||
;~(sfix (punt (cook crip (star prn))) (star ;~(pose prn (just `@`10))))
|
||||
::
|
||||
++ get-id
|
||||
|= [pos=@ud txt=tape seek=$-(nail (like (unit @t)))]
|
||||
^- [forward=(unit @t) backward=(unit @t) id=(unit @t)]
|
||||
=/ forward=(unit @t)
|
||||
(scan (slag pos txt) seek)
|
||||
=/ backward=(unit @t)
|
||||
%- (lift |=(t=@t (swp 3 t)))
|
||||
(scan (flop (scag pos txt)) seek)
|
||||
=/ id=(unit @t)
|
||||
?~ forward
|
||||
?~ backward
|
||||
~
|
||||
`u.backward
|
||||
?~ backward
|
||||
`u.forward
|
||||
`(cat 3 u.backward u.forward)
|
||||
[forward backward id]
|
||||
::
|
||||
:: Insert magic marker in hoon source at the given position.
|
||||
::
|
||||
++ insert-magic
|
||||
|= [pos=@ud txt=tape]
|
||||
^- [back-pos=@ud fore-pos=@ud txt=tape]
|
||||
:: Find beg-pos by searching backward to where the current term
|
||||
:: begins
|
||||
=+ (get-id-sym pos txt)
|
||||
=/ back-pos
|
||||
?~ backward
|
||||
pos
|
||||
(sub pos (met 3 u.backward))
|
||||
=/ fore-pos
|
||||
?~ forward
|
||||
pos
|
||||
(add pos (met 3 u.forward))
|
||||
:+ back-pos fore-pos
|
||||
:: Insert "magic-spoon" marker so +find-type can identify where to
|
||||
:: stop.
|
||||
::
|
||||
;: weld
|
||||
(scag back-pos txt)
|
||||
?: &(?=(~ id) ?=([%'.' *] (slag pos txt)))
|
||||
"magic-fork"
|
||||
"magic-spoon"
|
||||
?~ id
|
||||
""
|
||||
"."
|
||||
(slag back-pos txt)
|
||||
"\0a"
|
||||
==
|
||||
::
|
||||
:: Produce the longest possible advance without choosing between
|
||||
:: matches.
|
||||
::
|
||||
:: Takes a +hoon which has already has a magic-spoon marker. Useful if
|
||||
:: you want to handle your own parsing.
|
||||
::
|
||||
++ advance-hoon
|
||||
|= [sut=type gen=hoon]
|
||||
%+ bind (find-type-mule sut gen)
|
||||
|= [id=term typ=type]
|
||||
=/ matches=(list (option type))
|
||||
(search-prefix id (get-identifiers typ))
|
||||
(longest-match matches)
|
||||
::
|
||||
:: Same as +advance-hoon, but takes a position and text directly.
|
||||
::
|
||||
++ advance-tape
|
||||
|= [sut=type pos=@ud code=tape]
|
||||
(advance-hoon sut (scan txt:(insert-magic pos code) vest))
|
||||
::
|
||||
:: Produce a list of matches.
|
||||
::
|
||||
:: Takes a +hoon which has already has a magic-spoon marker. Useful if
|
||||
:: you want to handle your own parsing.
|
||||
::
|
||||
++ tab-list-hoon
|
||||
|= [sut=type gen=hoon]
|
||||
^- (unit (list (option type)))
|
||||
%+ bind (find-type-mule sut gen)
|
||||
|= [id=term typ=type]
|
||||
(search-prefix id (get-identifiers typ))
|
||||
::
|
||||
:: Same as +advance-hoon, but takes a position and text directly.
|
||||
::
|
||||
++ tab-list-tape
|
||||
|= [sut=type pos=@ud code=tape]
|
||||
^- (each (unit (list (option type))) [row=@ col=@])
|
||||
~? > debug %start-magick
|
||||
=/ magicked txt:(insert-magic pos code)
|
||||
~? > debug %start-parsing
|
||||
=/ res (lily magicked (language-server-parser *path))
|
||||
?: ?=(%| -.res)
|
||||
~? > debug [%parsing-error p.res]
|
||||
[%| p.res]
|
||||
:- %&
|
||||
~? > debug %parsed-good
|
||||
((cury tab-list-hoon sut) hoon:`pile:clay`p.res)
|
||||
::
|
||||
:: Generators
|
||||
++ tab-generators
|
||||
|= [pfix=path app=(unit term) gens=(list term)]
|
||||
^- (list (option tank))
|
||||
%+ turn gens
|
||||
|= gen=term
|
||||
^- (option tank)
|
||||
=/ pax=path
|
||||
(weld pfix ~[gen %hoon])
|
||||
=/ file
|
||||
.^(@t %cx pax)
|
||||
:_ (render-help file)
|
||||
?~ app
|
||||
(cat 3 '+' gen)
|
||||
?: =(%hood u.app)
|
||||
(cat 3 '|' gen)
|
||||
:((cury cat 3) ':' u.app '|' gen)
|
||||
:: Stolen from +help
|
||||
++ render-help
|
||||
|= a=@t
|
||||
^- tank
|
||||
:- %leaf
|
||||
=/ c (to-wain:format a)
|
||||
?~ c "~"
|
||||
?. =(':: ' (end [3 4] i.c))
|
||||
"<undocumented>"
|
||||
(trip i.c)
|
||||
--
|
1
pkg/arvo/lib/language-server/complete.hoon
Symbolic link
1
pkg/arvo/lib/language-server/complete.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/language-server/complete.hoon
|
@ -1,484 +0,0 @@
|
||||
:: Fast type printing that's easy on the eyes or your money back
|
||||
::
|
||||
=> |%
|
||||
+$ cape [p=(map @ud wine) q=wine]
|
||||
+$ wine
|
||||
$@ $? %noun
|
||||
%path
|
||||
%type
|
||||
%void
|
||||
%wall
|
||||
%wool
|
||||
%yarn
|
||||
==
|
||||
$% [%mato p=term]
|
||||
[%gate p=hoon q=type r=wine]
|
||||
[%core p=(list @ta) q=wine]
|
||||
[%face p=term q=wine]
|
||||
[%list p=term q=wine]
|
||||
[%pear p=term q=@]
|
||||
[%bcwt p=(list wine)]
|
||||
[%plot p=(list wine)]
|
||||
[%stop p=@ud]
|
||||
[%tree p=term q=wine]
|
||||
[%unit p=term q=wine]
|
||||
==
|
||||
--
|
||||
|_ sut=type
|
||||
++ dash
|
||||
|= [mil=tape lim=char lam=tape]
|
||||
^- tape
|
||||
=/ esc (~(gas in *(set @tD)) lam)
|
||||
:- lim
|
||||
|- ^- tape
|
||||
?~ mil [lim ~]
|
||||
?: ?| =(lim i.mil)
|
||||
=('\\' i.mil)
|
||||
(~(has in esc) i.mil)
|
||||
==
|
||||
['\\' i.mil $(mil t.mil)]
|
||||
?: (lte ' ' i.mil)
|
||||
[i.mil $(mil t.mil)]
|
||||
['\\' ~(x ne (rsh 2 i.mil)) ~(x ne (end 2 i.mil)) $(mil t.mil)]
|
||||
::
|
||||
++ deal |=(lum=* (dish dole lum))
|
||||
++ dial
|
||||
|= ham=cape
|
||||
=+ gid=*(set @ud)
|
||||
=| top-level=? :: don't need circumfix punctuation
|
||||
=< `tank`-:$
|
||||
|%
|
||||
++ many
|
||||
|= haz=(list wine)
|
||||
^- [(list tank) (set @ud)]
|
||||
?~ haz [~ gid]
|
||||
=^ mor gid $(haz t.haz)
|
||||
=^ dis gid ^$(q.ham i.haz)
|
||||
[[dis mor] gid]
|
||||
::
|
||||
++ $
|
||||
^- [tank (set @ud)]
|
||||
?- q.ham
|
||||
%noun :_(gid [%leaf '*' ~])
|
||||
%path :_(gid [%leaf '/' ~])
|
||||
%type :_(gid [%leaf '#' 't' ~])
|
||||
%void :_(gid [%leaf '#' '!' ~])
|
||||
%wool :_(gid [%leaf '*' '"' '"' ~])
|
||||
%wall :_(gid [%leaf '*' '\'' '\'' ~])
|
||||
%yarn :_(gid [%leaf '"' '"' ~])
|
||||
[%mato *] :_(gid [%leaf '@' (trip p.q.ham)])
|
||||
[%gate *]
|
||||
=^ sam gid
|
||||
?. ?=([%plot * * *] r.q.ham)
|
||||
?: ?=(%plot -.r.q.ham)
|
||||
%- (slog -:$(q.ham r.q.ham) ~)
|
||||
`gid
|
||||
`gid
|
||||
[`u=- +]:$(q.ham i.p.r.q.ham, top-level |)
|
||||
:_ gid
|
||||
:+ %rose
|
||||
:- ?> ?=(%core -.q.q.ham)
|
||||
?: ?=(%dry q.p.q.q.q.ham)
|
||||
" -> "
|
||||
" ~> "
|
||||
?: top-level
|
||||
["" ""]
|
||||
["(" ")"]
|
||||
:+ ?~(sam leaf+"_" u.sam)
|
||||
=/ res (mule |.((~(play ut q.q.ham) p.q.ham)))
|
||||
?- -.res
|
||||
%& duck(sut p.res)
|
||||
%| leaf+"###"
|
||||
==
|
||||
~
|
||||
::
|
||||
[%core *]
|
||||
=^ sam gid
|
||||
?. ?=([%plot * * ~] q.q.ham)
|
||||
`gid
|
||||
[`u=- +]:$(q.ham i.p.q.q.ham)
|
||||
:_ gid
|
||||
?~ sam
|
||||
:+ %rose
|
||||
[[' ' ~] ['<' ~] ['>' ~]]
|
||||
|- ^- (list tank)
|
||||
?~ p.q.ham ~
|
||||
[[%leaf (rip 3 i.p.q.ham)] $(p.q.ham t.p.q.ham)]
|
||||
:+ %rose
|
||||
[" -> " "" ""]
|
||||
:+ u.sam
|
||||
:+ %rose
|
||||
[[' ' ~] ['<' ~] ['>' ~]]
|
||||
|- ^- (list tank)
|
||||
?~ p.q.ham ~
|
||||
[[%leaf (rip 3 i.p.q.ham)] $(p.q.ham t.p.q.ham)]
|
||||
~
|
||||
::
|
||||
[%face *]
|
||||
=^ cox gid $(q.ham q.q.ham)
|
||||
:_(gid [%palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] cox ~])
|
||||
::
|
||||
[%list *]
|
||||
=^ cox gid $(q.ham q.q.ham)
|
||||
:_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~])
|
||||
::
|
||||
[%bcwt *]
|
||||
=^ coz gid (many p.q.ham)
|
||||
:_(gid [%rose [[' ' ~] ['?' '(' ~] [')' ~]] coz])
|
||||
::
|
||||
[%plot *]
|
||||
=^ coz gid (many p.q.ham)
|
||||
:_(gid [%rose [[' ' ~] ['[' ~] [']' ~]] coz])
|
||||
::
|
||||
[%pear *]
|
||||
:_(gid [%leaf '$' ~(rend co [%$ p.q.ham q.q.ham])])
|
||||
::
|
||||
[%stop *]
|
||||
=+ num=~(rend co [%$ %ud p.q.ham])
|
||||
?: (~(has in gid) p.q.ham)
|
||||
:_(gid [%leaf '#' num])
|
||||
=^ cox gid
|
||||
%= $
|
||||
gid (~(put in gid) p.q.ham)
|
||||
q.ham (~(got by p.ham) p.q.ham)
|
||||
==
|
||||
:_(gid [%palm [['.' ~] ~ ~ ~] [%leaf ['^' '#' num]] cox ~])
|
||||
::
|
||||
[%tree *]
|
||||
=^ cox gid $(q.ham q.q.ham)
|
||||
:_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~])
|
||||
::
|
||||
[%unit *]
|
||||
=^ cox gid $(q.ham q.q.ham)
|
||||
:_(gid [%rose [" " (weld (trip p.q.ham) "(") ")"] cox ~])
|
||||
==
|
||||
--
|
||||
::
|
||||
++ dish !:
|
||||
|= [ham=cape lum=*] ^- tank
|
||||
~| [%dish-h ?@(q.ham q.ham -.q.ham)]
|
||||
~| [%lump lum]
|
||||
~| [%ham ham]
|
||||
%- need
|
||||
=| gil=(set [@ud *])
|
||||
|- ^- (unit tank)
|
||||
?- q.ham
|
||||
%noun
|
||||
%= $
|
||||
q.ham
|
||||
?: ?=(@ lum)
|
||||
[%mato %$]
|
||||
:- %plot
|
||||
|- ^- (list wine)
|
||||
[%noun ?:(?=(@ +.lum) [[%mato %$] ~] $(lum +.lum))]
|
||||
==
|
||||
::
|
||||
%path
|
||||
:- ~
|
||||
:+ %rose
|
||||
[['/' ~] ['/' ~] ~]
|
||||
|- ^- (list tank)
|
||||
?~ lum ~
|
||||
?@ lum !!
|
||||
?> ?=(@ -.lum)
|
||||
[[%leaf (rip 3 -.lum)] $(lum +.lum)]
|
||||
::
|
||||
%type
|
||||
=+ tyr=|.((dial dole))
|
||||
=+ vol=tyr(sut lum)
|
||||
=+ cis=;;(tank .*(vol [%9 2 %0 1]))
|
||||
:^ ~ %palm
|
||||
[~ ~ ~ ~]
|
||||
[[%leaf '#' 't' '/' ~] cis ~]
|
||||
::
|
||||
%wall
|
||||
:- ~
|
||||
:+ %rose
|
||||
[[' ' ~] ['<' '|' ~] ['|' '>' ~]]
|
||||
|- ^- (list tank)
|
||||
?~ lum ~
|
||||
?@ lum !!
|
||||
[[%leaf (trip ;;(@ -.lum))] $(lum +.lum)]
|
||||
::
|
||||
%wool
|
||||
:- ~
|
||||
:+ %rose
|
||||
[[' ' ~] ['<' '<' ~] ['>' '>' ~]]
|
||||
|- ^- (list tank)
|
||||
?~ lum ~
|
||||
?@ lum !!
|
||||
[(need ^$(q.ham %yarn, lum -.lum)) $(lum +.lum)]
|
||||
::
|
||||
%yarn
|
||||
[~ %leaf (dash (tape lum) '"' "\{")]
|
||||
::
|
||||
%void
|
||||
~
|
||||
::
|
||||
[%mato *]
|
||||
?. ?=(@ lum)
|
||||
~
|
||||
:+ ~
|
||||
%leaf
|
||||
?+ (rash p.q.ham ;~(sfix (cook crip (star low)) (star hig)))
|
||||
~(rend co [%$ p.q.ham lum])
|
||||
%$ ~(rend co [%$ %ud lum])
|
||||
%t (dash (rip 3 lum) '\'' ~)
|
||||
%tas ['%' ?.(=(0 lum) (rip 3 lum) ['$' ~])]
|
||||
==
|
||||
::
|
||||
[%gate *]
|
||||
!!
|
||||
::
|
||||
[%core *]
|
||||
:: XX needs rethinking for core metal
|
||||
:: ?. ?=(^ lum) ~
|
||||
:: => .(lum `*`lum)
|
||||
:: =- ?~(tok ~ [~ %rose [[' ' ~] ['<' ~] ['>' ~]] u.tok])
|
||||
:: ^= tok
|
||||
:: |- ^- (unit (list tank))
|
||||
:: ?~ p.q.ham
|
||||
:: =+ den=^$(q.ham q.q.ham)
|
||||
:: ?~(den ~ [~ u.den ~])
|
||||
:: =+ mur=$(p.q.ham t.p.q.ham, lum +.lum)
|
||||
:: ?~(mur ~ [~ [[%leaf (rip 3 i.p.q.ham)] u.mur]])
|
||||
[~ (dial ham)]
|
||||
::
|
||||
[%face *]
|
||||
=+ wal=$(q.ham q.q.ham)
|
||||
?~ wal
|
||||
~
|
||||
[~ %palm [['=' ~] ~ ~ ~] [%leaf (trip p.q.ham)] u.wal ~]
|
||||
::
|
||||
[%list *]
|
||||
?: =(~ lum)
|
||||
[~ %leaf '~' ~]
|
||||
=- ?~ tok
|
||||
~
|
||||
[~ %rose [[' ' ~] ['~' '[' ~] [']' ~]] u.tok]
|
||||
^= tok
|
||||
|- ^- (unit (list tank))
|
||||
?: ?=(@ lum)
|
||||
?.(=(~ lum) ~ [~ ~])
|
||||
=+ [for=^$(q.ham q.q.ham, lum -.lum) aft=$(lum +.lum)]
|
||||
?. &(?=(^ for) ?=(^ aft))
|
||||
~
|
||||
[~ u.for u.aft]
|
||||
::
|
||||
[%bcwt *]
|
||||
|- ^- (unit tank)
|
||||
?~ p.q.ham
|
||||
~
|
||||
=+ wal=^$(q.ham i.p.q.ham)
|
||||
?~ wal
|
||||
$(p.q.ham t.p.q.ham)
|
||||
wal
|
||||
::
|
||||
[%plot *]
|
||||
=- ?~ tok
|
||||
~
|
||||
[~ %rose [[' ' ~] ['[' ~] [']' ~]] u.tok]
|
||||
^= tok
|
||||
|- ^- (unit (list tank))
|
||||
?~ p.q.ham
|
||||
~
|
||||
?: ?=([* ~] p.q.ham)
|
||||
=+ wal=^$(q.ham i.p.q.ham)
|
||||
?~(wal ~ [~ [u.wal ~]])
|
||||
?@ lum
|
||||
~
|
||||
=+ gim=^$(q.ham i.p.q.ham, lum -.lum)
|
||||
?~ gim
|
||||
~
|
||||
=+ myd=$(p.q.ham t.p.q.ham, lum +.lum)
|
||||
?~ myd
|
||||
~
|
||||
[~ u.gim u.myd]
|
||||
::
|
||||
[%pear *]
|
||||
?. =(lum q.q.ham)
|
||||
~
|
||||
=. p.q.ham
|
||||
(rash p.q.ham ;~(sfix (cook crip (star low)) (star hig)))
|
||||
=+ fox=$(q.ham [%mato p.q.ham])
|
||||
?> ?=([~ %leaf ^] fox)
|
||||
?: ?=(?(%n %tas) p.q.ham)
|
||||
fox
|
||||
[~ %leaf '%' p.u.fox]
|
||||
::
|
||||
[%stop *]
|
||||
?: (~(has in gil) [p.q.ham lum]) ~
|
||||
=+ kep=(~(get by p.ham) p.q.ham)
|
||||
?~ kep
|
||||
~|([%stop-loss p.q.ham] !!)
|
||||
$(gil (~(put in gil) [p.q.ham lum]), q.ham u.kep)
|
||||
::
|
||||
[%tree *]
|
||||
=- ?~ tok
|
||||
~
|
||||
[~ %rose [[' ' ~] ['{' ~] ['}' ~]] u.tok]
|
||||
^= tok
|
||||
=+ tuk=*(list tank)
|
||||
|- ^- (unit (list tank))
|
||||
?: =(~ lum)
|
||||
[~ tuk]
|
||||
?. ?=([n=* l=* r=*] lum)
|
||||
~
|
||||
=+ rol=$(lum r.lum)
|
||||
?~ rol
|
||||
~
|
||||
=+ tim=^$(q.ham q.q.ham, lum n.lum)
|
||||
?~ tim
|
||||
~
|
||||
$(lum l.lum, tuk [u.tim u.rol])
|
||||
::
|
||||
[%unit *]
|
||||
?@ lum
|
||||
?.(=(~ lum) ~ [~ %leaf '~' ~])
|
||||
?. =(~ -.lum)
|
||||
~
|
||||
=+ wal=$(q.ham q.q.ham, lum +.lum)
|
||||
?~ wal
|
||||
~
|
||||
[~ %rose [[' ' ~] ['[' ~] [']' ~]] [%leaf '~' ~] u.wal ~]
|
||||
==
|
||||
::
|
||||
++ doge
|
||||
|= ham=cape
|
||||
=- ?+ woz woz
|
||||
[%list * [%mato %'ta']] %path
|
||||
[%list * [%mato %'t']] %wall
|
||||
[%list * [%mato %'tD']] %yarn
|
||||
[%list * %yarn] %wool
|
||||
==
|
||||
^= woz
|
||||
^- wine
|
||||
?. ?=([%stop *] q.ham)
|
||||
?: ?& ?= [%bcwt [%pear %n %0] [%plot [%pear %n %0] [%face *] ~] ~]
|
||||
q.ham
|
||||
=(1 (met 3 p.i.t.p.i.t.p.q.ham))
|
||||
==
|
||||
[%unit =<([p q] i.t.p.i.t.p.q.ham)]
|
||||
q.ham
|
||||
=+ may=(~(get by p.ham) p.q.ham)
|
||||
?~ may
|
||||
q.ham
|
||||
=+ nul=[%pear %n 0]
|
||||
?. ?& ?=([%bcwt *] u.may)
|
||||
?=([* * ~] p.u.may)
|
||||
|(=(nul i.p.u.may) =(nul i.t.p.u.may))
|
||||
==
|
||||
q.ham
|
||||
=+ din=?:(=(nul i.p.u.may) i.t.p.u.may i.p.u.may)
|
||||
?: ?& ?=([%plot [%face *] [%face * %stop *] ~] din)
|
||||
=(p.q.ham p.q.i.t.p.din)
|
||||
=(1 (met 3 p.i.p.din))
|
||||
=(1 (met 3 p.i.t.p.din))
|
||||
==
|
||||
:+ %list
|
||||
(cat 3 p.i.p.din p.i.t.p.din)
|
||||
q.i.p.din
|
||||
?: ?& ?= $: %plot
|
||||
[%face *]
|
||||
[%face * %stop *]
|
||||
[[%face * %stop *] ~]
|
||||
==
|
||||
din
|
||||
=(p.q.ham p.q.i.t.p.din)
|
||||
=(p.q.ham p.q.i.t.t.p.din)
|
||||
=(1 (met 3 p.i.p.din))
|
||||
=(1 (met 3 p.i.t.p.din))
|
||||
=(1 (met 3 p.i.t.t.p.din))
|
||||
==
|
||||
:+ %tree
|
||||
%^ cat
|
||||
3
|
||||
p.i.p.din
|
||||
(cat 3 p.i.t.p.din p.i.t.t.p.din)
|
||||
q.i.p.din
|
||||
q.ham
|
||||
::
|
||||
++ dole
|
||||
^- cape
|
||||
=+ gil=*(set type)
|
||||
=+ dex=[p=*(map type @) q=*(map @ wine)]
|
||||
=< [q.p q]
|
||||
|- ^- [p=[p=(map type @) q=(map @ wine)] q=wine]
|
||||
=- [p.tez (doge q.p.tez q.tez)]
|
||||
^= tez
|
||||
^- [p=[p=(map type @) q=(map @ wine)] q=wine]
|
||||
?: (~(meet ut sut) -:!>(*type))
|
||||
[dex %type]
|
||||
?- sut
|
||||
%noun [dex sut]
|
||||
%void [dex sut]
|
||||
[%atom *] [dex ?~(q.sut [%mato p.sut] [%pear p.sut u.q.sut])]
|
||||
[%cell *]
|
||||
=+ hin=$(sut p.sut)
|
||||
=+ yon=$(dex p.hin, sut q.sut)
|
||||
:- p.yon
|
||||
:- %plot
|
||||
?:(?=([%plot *] q.yon) [q.hin p.q.yon] [q.hin q.yon ~])
|
||||
::
|
||||
[%core *]
|
||||
?: ?=([[%$ * [[%$ @ *] ~ ~]] ~ ~] q.r.q.sut)
|
||||
=/ dad $(sut p.sut)
|
||||
:- p.dad
|
||||
~! q.r.q.sut
|
||||
[%gate q.n.q.q.n.q.r.q.sut sut(r.p.q %gold) q.dad]
|
||||
=+ yad=$(sut p.sut)
|
||||
:- p.yad
|
||||
=+ ^= doy ^- [p=(list @ta) q=wine]
|
||||
?: ?=([%core *] q.yad)
|
||||
[p.q.yad q.q.yad]
|
||||
[~ q.yad]
|
||||
:- %core
|
||||
:_ q.doy
|
||||
:_ p.doy
|
||||
%^ cat 3
|
||||
%~ rent co
|
||||
:+ %$ %ud
|
||||
%- ~(rep by (~(run by q.r.q.sut) |=(tome ~(wyt by q.+<))))
|
||||
|=([[@ a=@u] b=@u] (add a b))
|
||||
%^ cat 3
|
||||
?-(r.p.q.sut %gold '.', %iron '|', %lead '?', %zinc '&')
|
||||
=+ gum=(mug q.r.q.sut)
|
||||
%+ can 3
|
||||
:~ [1 (add 'a' (mod gum 26))]
|
||||
[1 (add 'a' (mod (div gum 26) 26))]
|
||||
[1 (add 'a' (mod (div gum 676) 26))]
|
||||
==
|
||||
::
|
||||
[%hint *]
|
||||
$(sut q.sut)
|
||||
::
|
||||
[%face *]
|
||||
=+ yad=$(sut q.sut)
|
||||
?^(p.sut yad [p.yad [%face p.sut q.yad]])
|
||||
::
|
||||
[%fork *]
|
||||
=+ yed=(sort ~(tap in p.sut) aor)
|
||||
=- [p [%bcwt q]]
|
||||
|- ^- [p=[p=(map type @) q=(map @ wine)] q=(list wine)]
|
||||
?~ yed
|
||||
[dex ~]
|
||||
=+ mor=$(yed t.yed)
|
||||
=+ dis=^$(dex p.mor, sut i.yed)
|
||||
[p.dis q.dis q.mor]
|
||||
::
|
||||
[%hold *]
|
||||
=+ hey=(~(get by p.dex) sut)
|
||||
?^ hey
|
||||
[dex [%stop u.hey]]
|
||||
?: (~(has in gil) sut)
|
||||
=+ dyr=+(~(wyt by p.dex))
|
||||
[[(~(put by p.dex) sut dyr) q.dex] [%stop dyr]]
|
||||
=+ rom=$(gil (~(put in gil) sut), sut ~(repo ut sut))
|
||||
=+ rey=(~(get by p.p.rom) sut)
|
||||
?~ rey
|
||||
rom
|
||||
[[p.p.rom (~(put by q.p.rom) u.rey q.rom)] [%stop u.rey]]
|
||||
==
|
||||
::
|
||||
++ duck (dial dole)
|
||||
--
|
1
pkg/arvo/lib/language-server/easy-print.hoon
Symbolic link
1
pkg/arvo/lib/language-server/easy-print.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/language-server/easy-print.hoon
|
@ -1,301 +0,0 @@
|
||||
/- lsp=language-server
|
||||
|%
|
||||
::
|
||||
++ util
|
||||
|%
|
||||
++ get-json-string
|
||||
|= [jon=(map @t json) key=@t]
|
||||
^- (unit cord)
|
||||
=/ cord-jon=(unit json)
|
||||
(~(get by jon) key)
|
||||
?~ cord-jon
|
||||
~
|
||||
?> ?=([%s *] u.cord-jon)
|
||||
`p.u.cord-jon
|
||||
--
|
||||
::
|
||||
::
|
||||
++ dejs
|
||||
=, dejs:format
|
||||
|%
|
||||
++ request
|
||||
|= jon=json
|
||||
?> ?=([%o *] jon)
|
||||
=/ method=cord
|
||||
%- method
|
||||
(trip (need (get-json-string:util p.jon 'method')))
|
||||
=/ id=cord
|
||||
(need (get-json-string:util p.jon 'id'))
|
||||
=/ params=json
|
||||
(~(got by p.jon) 'params')
|
||||
^- all:request:lsp
|
||||
|^
|
||||
?+ method [%unknown jon]
|
||||
%text-document--hover (text-document--hover params id)
|
||||
%text-document--completion (text-document--completion params id)
|
||||
==
|
||||
::
|
||||
++ text-document--hover
|
||||
|= [params=json id=cord]
|
||||
^- text-document--hover:request:lsp
|
||||
:+ %text-document--hover
|
||||
id
|
||||
%. params
|
||||
%: ot
|
||||
position+position
|
||||
'textDocument'^text-document-id
|
||||
~
|
||||
==
|
||||
::
|
||||
++ text-document--completion
|
||||
|= [params=json id=cord]
|
||||
:+ %text-document--completion id
|
||||
%. params
|
||||
%: ot
|
||||
position+position
|
||||
'textDocument'^text-document-id
|
||||
~
|
||||
==
|
||||
--
|
||||
::
|
||||
++ notification
|
||||
|= jon=json
|
||||
?> ?=([%o *] jon)
|
||||
=/ method=cord
|
||||
%- method
|
||||
(trip (need (get-json-string:util p.jon 'method')))
|
||||
=/ params=json
|
||||
(~(got by p.jon) 'params')
|
||||
^- all:notification:lsp
|
||||
|^
|
||||
?+ method [%unknown jon]
|
||||
%text-document--did-change
|
||||
(text-document--did-change params)
|
||||
%text-document--did-open
|
||||
(text-document--did-open params)
|
||||
%text-document--did-save
|
||||
(text-document--did-save params)
|
||||
%text-document--did-close
|
||||
(text-document--did-close params)
|
||||
==
|
||||
::
|
||||
++ text-document--did-save
|
||||
|= jon=json
|
||||
^- text-document--did-save:notification:lsp
|
||||
?> ?=([%o *] jon)
|
||||
=/ doc-id
|
||||
(~(got by p.jon) 'textDocument')
|
||||
:- %text-document--did-save
|
||||
(text-document-id doc-id)
|
||||
::
|
||||
++ text-document--did-close
|
||||
|= jon=json
|
||||
^- text-document--did-close:notification:lsp
|
||||
?> ?=([%o *] jon)
|
||||
=/ doc-id
|
||||
(~(got by p.jon) 'textDocument')
|
||||
:- %text-document--did-close
|
||||
(text-document-id doc-id)
|
||||
::
|
||||
++ text-document--did-change
|
||||
|= jon=json
|
||||
^- text-document--did-change:notification:lsp
|
||||
:- %text-document--did-change
|
||||
%. jon
|
||||
%: ot
|
||||
'textDocument'^text-document-id
|
||||
'contentChanges'^text-document-changes
|
||||
~
|
||||
==
|
||||
::
|
||||
++ text-document--did-open
|
||||
|= jon=json
|
||||
^- text-document--did-open:notification:lsp
|
||||
?> ?=([%o *] jon)
|
||||
:- %text-document--did-open
|
||||
(text-document-item (~(got by p.jon) 'textDocument'))
|
||||
--
|
||||
:: Utilities
|
||||
::
|
||||
++ text-document-item
|
||||
|= jon=json
|
||||
^- text-document-item:lsp
|
||||
%. jon
|
||||
%: ot
|
||||
uri+so
|
||||
version+(mu ni)
|
||||
text+so
|
||||
~
|
||||
==
|
||||
::
|
||||
++ text-document-id
|
||||
%: ou
|
||||
uri+(un so)
|
||||
version+(uf ~ (pe ~ ni))
|
||||
~
|
||||
==
|
||||
::
|
||||
++ text-document-changes
|
||||
%- ar
|
||||
%: ou
|
||||
range+(uf ~ (pe ~ range))
|
||||
'rangeLength'^(uf ~ (pe ~ ni))
|
||||
text+(un so)
|
||||
~
|
||||
==
|
||||
::
|
||||
++ method
|
||||
|= =tape
|
||||
^- cord
|
||||
%- crip %- zing
|
||||
%+ join "--"
|
||||
^- (list ^tape)
|
||||
%+ turn
|
||||
^- (list (list ^tape))
|
||||
%+ scan
|
||||
tape
|
||||
%+ more
|
||||
fas
|
||||
;~ plug
|
||||
(star low)
|
||||
(star ;~(plug (cook |=(a=@ (add a 32)) hig) (star low)))
|
||||
==
|
||||
|= words=(list ^tape)
|
||||
^- ^tape
|
||||
(zing (join "-" words))
|
||||
::
|
||||
++ range
|
||||
%: ot
|
||||
start+position
|
||||
end+position
|
||||
~
|
||||
==
|
||||
::
|
||||
++ position
|
||||
%: ot
|
||||
line+ni
|
||||
character+ni
|
||||
~
|
||||
==
|
||||
--
|
||||
::
|
||||
++ enjs
|
||||
=, enjs:format
|
||||
|%
|
||||
++ text-document--publish-diagnostics
|
||||
|= pub=text-document--publish-diagnostics:notification:lsp
|
||||
^- json
|
||||
%: pairs
|
||||
uri+s+uri.pub
|
||||
diagnostics+a+(turn diagnostics.pub diagnostic)
|
||||
~
|
||||
==
|
||||
++ notification
|
||||
|= notification=all:notification:lsp
|
||||
^- json
|
||||
=/ params=json
|
||||
?+ -.notification !!
|
||||
%text-document--publish-diagnostics
|
||||
(text-document--publish-diagnostics notification)
|
||||
==
|
||||
~! -.notification
|
||||
=/ method=cord (crip (unparse-method -.notification))
|
||||
%: pairs
|
||||
method+s+method
|
||||
params+params
|
||||
~
|
||||
==
|
||||
::
|
||||
++ response
|
||||
|= res=all:response:lsp
|
||||
^- json
|
||||
|^
|
||||
?- -.res
|
||||
%text-document--hover (text-document--hover res)
|
||||
%text-document--completion (text-document--completion res)
|
||||
==
|
||||
::
|
||||
++ wrap-in-id
|
||||
|= [id=cord res=json]
|
||||
%: pairs
|
||||
id+s+id
|
||||
result+res
|
||||
~
|
||||
==
|
||||
++ text-document--hover
|
||||
|= hov=text-document--hover:response:lsp
|
||||
%+ wrap-in-id id.hov
|
||||
%+ frond 'contents'
|
||||
?~ contents.hov
|
||||
~
|
||||
s+u.contents.hov
|
||||
::
|
||||
++ text-document--completion
|
||||
|= com=text-document--completion:response:lsp
|
||||
%+ wrap-in-id id.com
|
||||
[%a (turn completion.com completion-item)]
|
||||
--
|
||||
++ unparse-method
|
||||
|= =cord
|
||||
^- ^tape
|
||||
%+ rash cord
|
||||
%+ cook |=(l=(list ^tape) (zing (join "/" l)))
|
||||
%+ more (jest '--')
|
||||
%+ cook
|
||||
|= tapes=(list ^tape)
|
||||
^- ^tape
|
||||
?~ tapes ~
|
||||
%- zing
|
||||
:- i.tapes
|
||||
%+ turn t.tapes
|
||||
|= t=^tape
|
||||
^- ^tape
|
||||
?~ t ~
|
||||
[`@tD`(sub i.t 32) t.t]
|
||||
%+ more
|
||||
;~(less (jest '--') hep)
|
||||
(star alf)
|
||||
::
|
||||
++ completion-item
|
||||
|= com=completion-item:lsp
|
||||
^- json
|
||||
%: pairs
|
||||
label+s+label.com
|
||||
detail+s+detail.com
|
||||
kind+(numb kind.com)
|
||||
'documentation'^s+doc.com
|
||||
'insertText'^s+insert-text.com
|
||||
'insertTextFormat'^(numb insert-text-format.com)
|
||||
~
|
||||
==
|
||||
::
|
||||
++ position
|
||||
|= =position:lsp
|
||||
^- json
|
||||
%: pairs
|
||||
line+(numb row.position)
|
||||
character+(numb col.position)
|
||||
~
|
||||
==
|
||||
::
|
||||
++ range
|
||||
|= =range:lsp
|
||||
^- json
|
||||
%: pairs
|
||||
start+(position start.range)
|
||||
end+(position end.range)
|
||||
~
|
||||
==
|
||||
::
|
||||
++ diagnostic
|
||||
|= diag=diagnostic:lsp
|
||||
^- json
|
||||
%: pairs
|
||||
range+(range range.diag)
|
||||
severity+(numb severity.diag)
|
||||
message+s+message.diag
|
||||
~
|
||||
==
|
||||
::
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/language-server/json.hoon
Symbolic link
1
pkg/arvo/lib/language-server/json.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/language-server/json.hoon
|
@ -1,72 +0,0 @@
|
||||
:: lifted directly from ford, should probably be in zuse
|
||||
=, clay
|
||||
=< pile-rule
|
||||
|%
|
||||
++ pile-rule
|
||||
|= pax=path
|
||||
%- full
|
||||
%+ ifix
|
||||
:_ gay
|
||||
:: parse optional /? and ignore
|
||||
::
|
||||
;~(plug gay (punt ;~(plug fas wut gap dem gap)))
|
||||
|^
|
||||
;~ plug
|
||||
%+ cook (bake zing (list (list taut)))
|
||||
%+ rune hep
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
::
|
||||
%+ cook (bake zing (list (list taut)))
|
||||
%+ rune lus
|
||||
(most ;~(plug com gaw) taut-rule)
|
||||
::
|
||||
%+ rune tis
|
||||
;~(plug sym ;~(pfix gap stap))
|
||||
::
|
||||
%+ rune sig
|
||||
;~((glue gap) sym wyde:vast stap)
|
||||
::
|
||||
%+ rune cen
|
||||
;~(plug sym ;~(pfix gap ;~(pfix cen sym)))
|
||||
::
|
||||
%+ rune buc
|
||||
;~ (glue gap)
|
||||
sym
|
||||
;~(pfix cen sym)
|
||||
;~(pfix cen sym)
|
||||
==
|
||||
::
|
||||
%+ rune tar
|
||||
;~ (glue gap)
|
||||
sym
|
||||
;~(pfix cen sym)
|
||||
stap
|
||||
==
|
||||
::
|
||||
%+ stag %tssg
|
||||
(most gap tall:(vang & pax))
|
||||
==
|
||||
::
|
||||
++ pant
|
||||
|* fel=^rule
|
||||
;~(pose fel (easy ~))
|
||||
::
|
||||
++ mast
|
||||
|* [bus=^rule fel=^rule]
|
||||
;~(sfix (more bus fel) bus)
|
||||
::
|
||||
++ rune
|
||||
|* [bus=^rule fel=^rule]
|
||||
%- pant
|
||||
%+ mast gap
|
||||
;~(pfix fas bus gap fel)
|
||||
--
|
||||
::
|
||||
++ taut-rule
|
||||
%+ cook |=(taut +<)
|
||||
;~ pose
|
||||
(stag ~ ;~(pfix tar sym))
|
||||
;~(plug (stag ~ sym) ;~(pfix tis sym))
|
||||
(cook |=(a=term [`a a]) sym)
|
||||
==
|
||||
--
|
1
pkg/arvo/lib/language-server/parser.hoon
Symbolic link
1
pkg/arvo/lib/language-server/parser.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/language-server/parser.hoon
|
@ -1,532 +0,0 @@
|
||||
/- lsp-sur=language-server
|
||||
/+ auto=language-server-complete
|
||||
=>
|
||||
|%
|
||||
++ snippet
|
||||
|= [rune=tape text=tape]
|
||||
^- json
|
||||
=, enjs:format
|
||||
%- pairs
|
||||
:~ 'label'^(tape rune)
|
||||
'insertTextFormat'^(numb 2)
|
||||
'insertText'^(tape text)
|
||||
==
|
||||
::
|
||||
++ runes
|
||||
^- (list (option:auto tape))
|
||||
:~ :- '|$'
|
||||
"""
|
||||
$\{1:sample}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '|_'
|
||||
"""
|
||||
$\{1:sample}
|
||||
++ $\{2:arm}
|
||||
$\{3:body}
|
||||
--
|
||||
"""
|
||||
:- '|:'
|
||||
"""
|
||||
$\{1:sample}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '|%'
|
||||
"""
|
||||
|
||||
++ $\{1:arm}
|
||||
$\{2:body}
|
||||
--
|
||||
"""
|
||||
:- '|.'
|
||||
"""
|
||||
$\{1:body}
|
||||
"""
|
||||
:- '|^'
|
||||
"""
|
||||
|
||||
$\{1:body}
|
||||
::
|
||||
++ $\{2:arm}
|
||||
$\{3:body}
|
||||
--
|
||||
"""
|
||||
:- '|-'
|
||||
"""
|
||||
$\{1:body}
|
||||
"""
|
||||
:- '|~'
|
||||
"""
|
||||
$\{1:sample}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '|*'
|
||||
"""
|
||||
$\{1:sample}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '|='
|
||||
"""
|
||||
$\{1:sample}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '|@'
|
||||
"""
|
||||
++ $\{1:arm}
|
||||
$\{2:body}
|
||||
--
|
||||
"""
|
||||
:- '|?'
|
||||
"""
|
||||
$\{1:sample}
|
||||
"""
|
||||
::
|
||||
:- ':_'
|
||||
"""
|
||||
$\{1:tail}
|
||||
$\{2:head}
|
||||
"""
|
||||
:- ':^'
|
||||
"""
|
||||
$\{1:car}
|
||||
$\{2:cadr}
|
||||
$\{3:caddr}
|
||||
$\{4:cddr}
|
||||
"""
|
||||
:- ':-'
|
||||
"""
|
||||
$\{1:tail}
|
||||
$\{2:head}
|
||||
"""
|
||||
:- ':+'
|
||||
"""
|
||||
$\{1:car}
|
||||
$\{2:cadr}
|
||||
$\{3:cddr}
|
||||
"""
|
||||
:- ':~'
|
||||
"""
|
||||
$\{1:item}
|
||||
==
|
||||
"""
|
||||
:- ':*'
|
||||
"""
|
||||
$\{1:item}
|
||||
==
|
||||
"""
|
||||
::
|
||||
:- '%_'
|
||||
"""
|
||||
$\{1:target}
|
||||
$\{2:wing} $\{3:new-value}
|
||||
==
|
||||
"""
|
||||
:- '%.'
|
||||
"""
|
||||
$\{1:arg}
|
||||
$\{2:gate}
|
||||
"""
|
||||
:- '%-'
|
||||
"""
|
||||
$\{1:gate}
|
||||
$\{2:arg}
|
||||
"""
|
||||
:- '%:'
|
||||
"""
|
||||
$\{1:gate}
|
||||
$\{2:args}
|
||||
==
|
||||
"""
|
||||
:- '%*'
|
||||
"""
|
||||
$\{1:target-wing} $\{2:from}
|
||||
$\{3:wing} $\{4:new-value}
|
||||
==
|
||||
"""
|
||||
:- '%^'
|
||||
"""
|
||||
$\{1:gate}
|
||||
$\{2:arg1}
|
||||
$\{3:arg2}
|
||||
$\{4:arg3}
|
||||
"""
|
||||
:- '%+'
|
||||
"""
|
||||
$\{1:gate}
|
||||
$\{2:arg1}
|
||||
$\{3:arg2}
|
||||
"""
|
||||
:- '%~'
|
||||
"""
|
||||
$\{1:arm}
|
||||
$\{2:core}
|
||||
$\{3:arg}
|
||||
"""
|
||||
:- '%='
|
||||
"""
|
||||
$\{1:target}
|
||||
$\{2:wing} $\{3:new-value}
|
||||
==
|
||||
"""
|
||||
::
|
||||
:- '.^'
|
||||
"""
|
||||
$\{1:mold}
|
||||
$\{2:path}
|
||||
"""
|
||||
:- '.+'
|
||||
"""
|
||||
$\{1:atom}
|
||||
"""
|
||||
:- '.*'
|
||||
"""
|
||||
$\{1:subject}
|
||||
$\{2:formula}
|
||||
"""
|
||||
:- '.='
|
||||
"""
|
||||
$\{1:a}
|
||||
$\{2:b}
|
||||
"""
|
||||
:- '.?'
|
||||
"""
|
||||
$\{1:noun}
|
||||
"""
|
||||
::
|
||||
:- '^|'
|
||||
"""
|
||||
$\{1:iron-core}
|
||||
"""
|
||||
:- '^.'
|
||||
"""
|
||||
$\{1:a}
|
||||
$\{2:b}
|
||||
"""
|
||||
:- '^+'
|
||||
"""
|
||||
$\{1:like}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '^-'
|
||||
"""
|
||||
$\{1:type}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '^&'
|
||||
"""
|
||||
$\{1:zinc-core}
|
||||
"""
|
||||
:- '^~'
|
||||
"""
|
||||
$\{1:constant}
|
||||
"""
|
||||
:- '^='
|
||||
"""
|
||||
$\{1:face}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '^?'
|
||||
"""
|
||||
$\{1:lead-core}
|
||||
"""
|
||||
:- '^*'
|
||||
"""
|
||||
$\{1:type}
|
||||
"""
|
||||
:- '^:'
|
||||
"""
|
||||
$\{1:type}
|
||||
"""
|
||||
::
|
||||
:- '~|'
|
||||
"""
|
||||
$\{1:trace}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '~_'
|
||||
"""
|
||||
$\{1:tank}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '~%'
|
||||
"""
|
||||
$\{1:name}
|
||||
$\{2:parent}
|
||||
~
|
||||
$\{3:body}
|
||||
"""
|
||||
:- '~/'
|
||||
"""
|
||||
$\{1:name}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '~<'
|
||||
"""
|
||||
$\{1:hint}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '~>'
|
||||
"""
|
||||
$\{1:hint}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '~$'
|
||||
"""
|
||||
$\{1:name}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '~+'
|
||||
"""
|
||||
|
||||
$\{1:body}
|
||||
"""
|
||||
:- '~&'
|
||||
"""
|
||||
$\{1:printf}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '~='
|
||||
"""
|
||||
$\{1:a}
|
||||
$\{2:b}
|
||||
"""
|
||||
:- '~?'
|
||||
"""
|
||||
$\{1:condition}
|
||||
$\{2:printf}
|
||||
$\{3:body}
|
||||
"""
|
||||
:- '~!'
|
||||
"""
|
||||
$\{1:type}
|
||||
$\{2:body}
|
||||
"""
|
||||
::
|
||||
:- ';='
|
||||
"""
|
||||
$\{1:manx}
|
||||
==
|
||||
"""
|
||||
:- ';:'
|
||||
"""
|
||||
$\{1:gate}
|
||||
$\{2:args}
|
||||
==
|
||||
"""
|
||||
:- ';/'
|
||||
"""
|
||||
$\{1:tape}
|
||||
"""
|
||||
:- ';<'
|
||||
"""
|
||||
$\{1:type} bind:m $\{2:body1}
|
||||
$\{3:body2}
|
||||
"""
|
||||
:- ';~'
|
||||
"""
|
||||
$\{1:gate}
|
||||
$\{2:args}
|
||||
==
|
||||
"""
|
||||
:- ';;'
|
||||
"""
|
||||
$\{1:type}
|
||||
$\{2:body}
|
||||
"""
|
||||
::
|
||||
:- '=|'
|
||||
"""
|
||||
$\{1:type}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '=:'
|
||||
"""
|
||||
$\{1:wing} $\{2:value}
|
||||
==
|
||||
$\{3:body}
|
||||
"""
|
||||
:- '=/'
|
||||
"""
|
||||
$\{1:face}
|
||||
$\{2:value}
|
||||
$\{3:body}
|
||||
"""
|
||||
:- '=;'
|
||||
"""
|
||||
$\{1:face}
|
||||
$\{2:body}
|
||||
$\{3:value}
|
||||
"""
|
||||
:- '=.'
|
||||
"""
|
||||
$\{1:wing}
|
||||
$\{2:value}
|
||||
$\{3:body}
|
||||
"""
|
||||
:- '=?'
|
||||
"""
|
||||
$\{1:wing} $\{2:condition}
|
||||
$\{3:value}
|
||||
$\{4:body}
|
||||
"""
|
||||
:- '=<'
|
||||
"""
|
||||
$\{1:formula}
|
||||
$\{2:subject}
|
||||
"""
|
||||
:- '=-'
|
||||
"""
|
||||
$\{1:body}
|
||||
$\{2:value}
|
||||
"""
|
||||
:- '=>'
|
||||
"""
|
||||
$\{1:subject}
|
||||
$\{2:formula}
|
||||
"""
|
||||
:- '=^'
|
||||
"""
|
||||
$\{1:face} $\{2:wing}
|
||||
$\{3:computation}
|
||||
$\{4:body}
|
||||
"""
|
||||
:- '=+'
|
||||
"""
|
||||
$\{1:value}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '=~'
|
||||
"""
|
||||
|
||||
$\{1:body}
|
||||
"""
|
||||
:- '=*'
|
||||
"""
|
||||
$\{1:alias} $\{2:value}
|
||||
$\{3:body}
|
||||
"""
|
||||
:- '=,'
|
||||
"""
|
||||
$\{1:alias}
|
||||
$\{3:body}
|
||||
"""
|
||||
::
|
||||
:- '?|'
|
||||
"""
|
||||
$\{1:condition}
|
||||
==
|
||||
"""
|
||||
:- '?-'
|
||||
"""
|
||||
$\{1:case}
|
||||
$\{2:type} $\{3:value}
|
||||
==
|
||||
"""
|
||||
:- '?:'
|
||||
"""
|
||||
$\{1:if}
|
||||
$\{2:then}
|
||||
$\{3:else}
|
||||
"""
|
||||
:- '?.'
|
||||
"""
|
||||
$\{1:if}
|
||||
$\{2:else}
|
||||
$\{3:then}
|
||||
"""
|
||||
:- '?^'
|
||||
"""
|
||||
$\{1:value}
|
||||
$\{2:if-cell}
|
||||
$\{3:if-atom}
|
||||
"""
|
||||
:- '?<'
|
||||
"""
|
||||
$\{1:assertion}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '?>'
|
||||
"""
|
||||
$\{1:assertion}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '?+'
|
||||
"""
|
||||
$\{1:case} $\{2:else}
|
||||
$\{3:type} $\{4:value}
|
||||
==
|
||||
"""
|
||||
:- '?&'
|
||||
"""
|
||||
$\{1:condition}
|
||||
==
|
||||
"""
|
||||
:- '?@'
|
||||
"""
|
||||
$\{1:value}
|
||||
$\{2:if-atom}
|
||||
$\{3:if-cell}
|
||||
"""
|
||||
:- '?~'
|
||||
"""
|
||||
$\{1:value}
|
||||
$\{2:if-null}
|
||||
$\{3:if-nonnull}
|
||||
"""
|
||||
:- '?#'
|
||||
"""
|
||||
$\{1:skin}
|
||||
$\{2:wing}
|
||||
"""
|
||||
:- '?='
|
||||
"""
|
||||
$\{1:type}
|
||||
$\{2:wing}
|
||||
"""
|
||||
:- '?!'
|
||||
"""
|
||||
$\{1:loobean}
|
||||
"""
|
||||
::
|
||||
:- '!,'
|
||||
"""
|
||||
*hoon
|
||||
$\{1:ast}
|
||||
"""
|
||||
:- '!>'
|
||||
"""
|
||||
$\{1:value}
|
||||
"""
|
||||
:- '!;'
|
||||
"""
|
||||
$\{1:type}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '!='
|
||||
"""
|
||||
$\{1:body}
|
||||
"""
|
||||
:- '!@'
|
||||
"""
|
||||
$\{1:wing}
|
||||
$\{2:if-exists}
|
||||
$\{3:if-not-exists}
|
||||
"""
|
||||
:- '!?'
|
||||
"""
|
||||
$\{1:version}
|
||||
$\{2:body}
|
||||
"""
|
||||
:- '!!'
|
||||
""
|
||||
==
|
||||
--
|
||||
|= rune=tape
|
||||
^- (list completion-item:lsp-sur)
|
||||
=? rune =(' ' (snag 0 rune))
|
||||
(slag 1 rune)
|
||||
~& rune
|
||||
%+ turn (search-prefix:auto (crip rune) runes)
|
||||
|= [name=cord snippet=tape]
|
||||
^- completion-item:lsp-sur
|
||||
[name 1 '' '' (crip snippet) 2]
|
1
pkg/arvo/lib/language-server/rune-snippet.hoon
Symbolic link
1
pkg/arvo/lib/language-server/rune-snippet.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../base-dev/lib/language-server/rune-snippet.hoon
|
@ -1,159 +0,0 @@
|
||||
=, eyre
|
||||
|%
|
||||
+$ request-line
|
||||
$: [ext=(unit @ta) site=(list @t)]
|
||||
args=(list [key=@t value=@t])
|
||||
==
|
||||
:: +parse-request-line: take a cord and parse out a url
|
||||
::
|
||||
++ parse-request-line
|
||||
|= url=@t
|
||||
^- request-line
|
||||
(fall (rush url ;~(plug apat:de-purl:html yque:de-purl:html)) [[~ ~] ~])
|
||||
::
|
||||
++ manx-to-octs
|
||||
|= man=manx
|
||||
^- octs
|
||||
(as-octt:mimes:html (en-xml:html man))
|
||||
::
|
||||
++ json-to-octs
|
||||
|= jon=json
|
||||
^- octs
|
||||
(as-octt:mimes:html (en-json:html jon))
|
||||
::
|
||||
++ app
|
||||
|%
|
||||
::
|
||||
:: +require-authorization:
|
||||
:: redirect to the login page when unauthenticated
|
||||
:: otherwise call handler on inbound request
|
||||
::
|
||||
++ require-authorization
|
||||
|= $: =inbound-request:eyre
|
||||
handler=$-(inbound-request:eyre simple-payload:http)
|
||||
==
|
||||
^- simple-payload:http
|
||||
::
|
||||
?: authenticated.inbound-request
|
||||
~! this
|
||||
~! +:*handler
|
||||
(handler inbound-request)
|
||||
::
|
||||
=- [[307 ['location' -]~] ~]
|
||||
%^ cat 3
|
||||
'/~/login?redirect='
|
||||
url.request.inbound-request
|
||||
::
|
||||
:: +require-authorization-simple:
|
||||
:: redirect to the login page when unauthenticated
|
||||
:: otherwise pass through simple-paylod
|
||||
::
|
||||
++ require-authorization-simple
|
||||
|= [=inbound-request:eyre =simple-payload:http]
|
||||
^- simple-payload:http
|
||||
::
|
||||
?: authenticated.inbound-request
|
||||
~! this
|
||||
simple-payload
|
||||
::
|
||||
=- [[307 ['location' -]~] ~]
|
||||
%^ cat 3
|
||||
'/~/login?redirect='
|
||||
url.request.inbound-request
|
||||
::
|
||||
++ give-simple-payload
|
||||
|= [eyre-id=@ta =simple-payload:http]
|
||||
^- (list card:agent:gall)
|
||||
=/ header-cage
|
||||
[%http-response-header !>(response-header.simple-payload)]
|
||||
=/ data-cage
|
||||
[%http-response-data !>(data.simple-payload)]
|
||||
:~ [%give %fact ~[/http-response/[eyre-id]] header-cage]
|
||||
[%give %fact ~[/http-response/[eyre-id]] data-cage]
|
||||
[%give %kick ~[/http-response/[eyre-id]] ~]
|
||||
==
|
||||
--
|
||||
++ gen
|
||||
|%
|
||||
::
|
||||
++ max-1-da ['cache-control' 'max-age=86400']
|
||||
++ max-1-wk ['cache-control' 'max-age=604800']
|
||||
::
|
||||
++ html-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
:_ `octs
|
||||
[200 [['content-type' 'text/html'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ css-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
:_ `octs
|
||||
[200 [['content-type' 'text/css'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ js-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
:_ `octs
|
||||
[200 [['content-type' 'text/javascript'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ png-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
:_ `octs
|
||||
[200 [['content-type' 'image/png'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ svg-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
:_ `octs
|
||||
[200 [['content-type' 'image/svg+xml'] ?:(cache [max-1-wk ~] ~)]]
|
||||
::
|
||||
++ ico-response
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'image/x-icon'] max-1-wk ~]] `octs]
|
||||
::
|
||||
++ woff2-response
|
||||
=| cache=?
|
||||
|= =octs
|
||||
^- simple-payload:http
|
||||
[[200 [['content-type' 'font/woff2'] max-1-wk ~]] `octs]
|
||||
::
|
||||
++ json-response
|
||||
=| cache=_|
|
||||
|= =json
|
||||
^- simple-payload:http
|
||||
:_ `(json-to-octs json)
|
||||
[200 [['content-type' 'application/json'] ?:(cache [max-1-da ~] ~)]]
|
||||
::
|
||||
++ manx-response
|
||||
=| cache=_|
|
||||
|= man=manx
|
||||
^- simple-payload:http
|
||||
:_ `(manx-to-octs man)
|
||||
[200 [['content-type' 'text/html'] ?:(cache [max-1-da ~] ~)]]
|
||||
::
|
||||
++ not-found
|
||||
^- simple-payload:http
|
||||
[[404 ~] ~]
|
||||
::
|
||||
++ login-redirect
|
||||
|= =request:http
|
||||
^- simple-payload:http
|
||||
=- [[307 ['location' -]~] ~]
|
||||
%^ cat 3
|
||||
'/~/login?redirect='
|
||||
url.request
|
||||
::
|
||||
++ redirect
|
||||
|= redirect=cord
|
||||
^- simple-payload:http
|
||||
[[307 ['location' redirect]~] ~]
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/server.hoon
Symbolic link
1
pkg/arvo/lib/server.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/server.hoon
|
@ -1,532 +0,0 @@
|
||||
:: shoe: console application library
|
||||
::
|
||||
:: /lib/sole: draw some characters
|
||||
:: /lib/shoe: draw the rest of the fscking app
|
||||
::
|
||||
:: call +agent with a type, then call the resulting function with a core
|
||||
:: of the shape described in +shoe.
|
||||
:: you may produce classic gall cards and "shoe-effects", shorthands for
|
||||
:: sending cli events to connected clients.
|
||||
:: default implementations for the shoe-specific arms are in +default.
|
||||
:: for a simple usage example, see /app/shoe.
|
||||
::
|
||||
/- *sole
|
||||
/+ sole, auto=language-server-complete
|
||||
|%
|
||||
+$ state-0
|
||||
$: %0
|
||||
soles=(map @ta sole-share)
|
||||
==
|
||||
:: $card: standard gall cards plus shoe effects
|
||||
::
|
||||
+$ card
|
||||
$% card:agent:gall
|
||||
[%shoe sole-ids=(list @ta) effect=shoe-effect] :: ~ sends to all soles
|
||||
==
|
||||
:: $shoe-effect: easier sole-effects
|
||||
::
|
||||
+$ shoe-effect
|
||||
$% :: %sole: raw sole-effect
|
||||
::
|
||||
[%sole effect=sole-effect]
|
||||
:: %table: sortable, filterable data, with suggested column char widths
|
||||
::
|
||||
[%table head=(list dime) wide=(list @ud) rows=(list (list dime))]
|
||||
:: %row: line sections with suggested char widths
|
||||
::
|
||||
[%row wide=(list @ud) cols=(list dime)]
|
||||
==
|
||||
:: +shoe: gall agent core with extra arms
|
||||
::
|
||||
++ shoe
|
||||
|* command-type=mold
|
||||
$_ ^|
|
||||
|_ bowl:gall
|
||||
:: +command-parser: input parser for a specific session
|
||||
::
|
||||
:: if the head of the result is true, instantly run the command
|
||||
::
|
||||
++ command-parser
|
||||
|~ sole-id=@ta
|
||||
|~(nail *(like [? command-type]))
|
||||
:: +tab-list: autocomplete options for the session (to match +command-parser)
|
||||
::
|
||||
++ tab-list
|
||||
|~ sole-id=@ta
|
||||
:: (list [@t tank])
|
||||
*(list (option:auto tank))
|
||||
:: +on-command: called when a valid command is run
|
||||
::
|
||||
++ on-command
|
||||
|~ [sole-id=@ta command=command-type]
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ can-connect
|
||||
|~ sole-id=@ta
|
||||
*?
|
||||
::
|
||||
++ on-connect
|
||||
|~ sole-id=@ta
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-disconnect
|
||||
|~ sole-id=@ta
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
::NOTE standard gall agent arms below, though they may produce %shoe cards
|
||||
::
|
||||
++ on-init
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-save
|
||||
*vase
|
||||
::
|
||||
++ on-load
|
||||
|~ vase
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-poke
|
||||
|~ [mark vase]
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-watch
|
||||
|~ path
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-leave
|
||||
|~ path
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-peek
|
||||
|~ path
|
||||
*(unit (unit cage))
|
||||
::
|
||||
++ on-agent
|
||||
|~ [wire sign:agent:gall]
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-arvo
|
||||
|~ [wire sign-arvo]
|
||||
*(quip card _^|(..on-init))
|
||||
::
|
||||
++ on-fail
|
||||
|~ [term tang]
|
||||
*(quip card _^|(..on-init))
|
||||
--
|
||||
:: +default: bare-minimum implementations of shoe arms
|
||||
::
|
||||
++ default
|
||||
|* [shoe=* command-type=mold]
|
||||
|_ =bowl:gall
|
||||
++ command-parser
|
||||
|= sole-id=@ta
|
||||
(easy *[? command-type])
|
||||
::
|
||||
++ tab-list
|
||||
|= sole-id=@ta
|
||||
~
|
||||
::
|
||||
++ on-command
|
||||
|= [sole-id=@ta command=command-type]
|
||||
[~ shoe]
|
||||
::
|
||||
++ can-connect
|
||||
|= sole-id=@ta
|
||||
(team:title [our src]:bowl)
|
||||
::
|
||||
++ on-connect
|
||||
|= sole-id=@ta
|
||||
[~ shoe]
|
||||
::
|
||||
++ on-disconnect
|
||||
|= sole-id=@ta
|
||||
[~ shoe]
|
||||
--
|
||||
:: +agent: creates wrapper core that handles sole events and calls shoe arms
|
||||
::
|
||||
++ agent
|
||||
|* command-type=mold
|
||||
|= =(shoe command-type)
|
||||
=| state-0
|
||||
=* state -
|
||||
^- agent:gall
|
||||
=>
|
||||
|%
|
||||
++ deal
|
||||
|= cards=(list card)
|
||||
%+ turn cards
|
||||
|= =card
|
||||
^- card:agent:gall
|
||||
?. ?=(%shoe -.card) card
|
||||
?- -.effect.card
|
||||
%sole
|
||||
=- [%give %fact - %sole-effect !>(effect.effect.card)]
|
||||
%+ turn
|
||||
?^ sole-ids.card sole-ids.card
|
||||
~(tap in ~(key by soles))
|
||||
|= sole-id=@ta
|
||||
/sole/[sole-id]
|
||||
::
|
||||
%table
|
||||
=; fez=(list sole-effect)
|
||||
$(effect.card [%sole %mor fez])
|
||||
=, +.effect.card
|
||||
:- (row:draw & wide head)
|
||||
%+ turn rows
|
||||
(cury (cury row:draw |) wide)
|
||||
::
|
||||
%row
|
||||
$(effect.card [%sole (row:draw | +.effect.card)])
|
||||
==
|
||||
--
|
||||
::
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
og ~(. shoe bowl)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards shoe on-init:og
|
||||
[(deal cards) this]
|
||||
::
|
||||
++ on-save !>([%shoe-app on-save:og state])
|
||||
::
|
||||
++ on-load
|
||||
|= old-state=vase
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
:: we could be upgrading from a shoe-less app, in which case the vase
|
||||
:: contains inner application state instead of our +on-save.
|
||||
:: to distinguish between the two, we check for the presence of our own
|
||||
:: +on-save tag in the vase.
|
||||
::
|
||||
?. ?=([%shoe-app ^] q.old-state)
|
||||
=^ cards shoe (on-load:og old-state)
|
||||
[(deal cards) this]
|
||||
=^ old-inner state +:!<([%shoe-app vase state-0] old-state)
|
||||
=^ cards shoe (on-load:og old-inner)
|
||||
[(deal cards) this]
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
?. ?=(%sole-action mark)
|
||||
=^ cards shoe (on-poke:og mark vase)
|
||||
[(deal cards) this]
|
||||
::
|
||||
=/ act !<(sole-action vase)
|
||||
=* sole-id id.act
|
||||
=/ cli-state=sole-share
|
||||
(~(gut by soles) sole-id *sole-share)
|
||||
|^ =^ [cards=(list card) =_cli-state] shoe
|
||||
?- -.dat.act
|
||||
%det (apply-edit +.dat.act)
|
||||
%clr [[~ cli-state] shoe]
|
||||
%ret try-command
|
||||
%tab [(tab +.dat.act) shoe]
|
||||
==
|
||||
:- (deal cards)
|
||||
this(soles (~(put by soles) sole-id cli-state))
|
||||
::
|
||||
++ effect
|
||||
|= =sole-effect
|
||||
^- card
|
||||
[%shoe [sole-id]~ %sole sole-effect]
|
||||
::
|
||||
++ apply-edit
|
||||
|= =sole-change
|
||||
^+ [[*(list card) cli-state] shoe]
|
||||
=^ inverse cli-state
|
||||
(~(transceive sole cli-state) sole-change)
|
||||
:: res: & for fully parsed, | for parsing failure at location
|
||||
::
|
||||
=/ res=(each (unit [run=? cmd=command-type]) @ud)
|
||||
%+ rose (tufa buf.cli-state)
|
||||
(command-parser:og sole-id)
|
||||
?: ?=(%& -.res)
|
||||
:: only auto-run eligible commands if they were typed out
|
||||
:: (that is, not retrieved from command history)
|
||||
::
|
||||
?. &(?=(^ p.res) run.u.p.res !?=(%set -.ted.sole-change))
|
||||
[[~ cli-state] shoe]
|
||||
(run-command cmd.u.p.res)
|
||||
:_ shoe
|
||||
:: parsing failed
|
||||
::
|
||||
?. &(?=(%del -.inverse) =(+(p.inverse) (lent buf.cli-state)))
|
||||
:: if edit was somewhere in the middle, let it happen anyway
|
||||
::
|
||||
[~ cli-state]
|
||||
:: if edit was insertion at buffer tail, revert it
|
||||
::
|
||||
=^ undo cli-state
|
||||
(~(transmit sole cli-state) inverse)
|
||||
:_ cli-state
|
||||
:_ ~
|
||||
%+ effect %mor
|
||||
:~ [%det undo] :: undo edit
|
||||
[%err p.res] :: cursor to error location
|
||||
==
|
||||
::
|
||||
++ try-command
|
||||
^+ [[*(list card) cli-state] shoe]
|
||||
=/ res=(unit [? cmd=command-type])
|
||||
%+ rust (tufa buf.cli-state)
|
||||
(command-parser:og sole-id)
|
||||
?^ res (run-command cmd.u.res)
|
||||
[[[(effect %bel ~)]~ cli-state] shoe]
|
||||
::
|
||||
++ run-command
|
||||
|= cmd=command-type
|
||||
^+ [[*(list card) cli-state] shoe]
|
||||
=^ cards shoe (on-command:og sole-id cmd)
|
||||
:: clear buffer
|
||||
::
|
||||
=^ clear cli-state (~(transmit sole cli-state) [%set ~])
|
||||
=- [[[- cards] cli-state] shoe]
|
||||
%+ effect %mor
|
||||
:~ [%nex ~]
|
||||
[%det clear]
|
||||
==
|
||||
::
|
||||
++ tab
|
||||
|= pos=@ud
|
||||
^- (quip card _cli-state)
|
||||
=+ (get-id-cord:auto pos (tufa buf.cli-state))
|
||||
=/ needle=term
|
||||
(fall id %$)
|
||||
:: autocomplete empty command iff user at start of command
|
||||
::
|
||||
=/ options=(list (option:auto tank))
|
||||
(search-prefix:auto needle (tab-list:og sole-id))
|
||||
=/ advance=term
|
||||
(longest-match:auto options)
|
||||
=/ to-send=tape
|
||||
%- trip
|
||||
(rsh [3 (met 3 needle)] advance)
|
||||
=/ send-pos=@ud
|
||||
%+ add pos
|
||||
(met 3 (fall forward ''))
|
||||
=| cards=(list card)
|
||||
:: only render the option list if we couldn't complete anything
|
||||
::
|
||||
=? cards &(?=(~ to-send) ?=(^ options))
|
||||
[(effect %tab options) cards]
|
||||
|- ^- (quip card _cli-state)
|
||||
?~ to-send
|
||||
[(flop cards) cli-state]
|
||||
=^ char cli-state
|
||||
(~(transmit sole cli-state) [%ins send-pos `@c`i.to-send])
|
||||
%_ $
|
||||
cards [(effect %det char) cards]
|
||||
send-pos +(send-pos)
|
||||
to-send t.to-send
|
||||
==
|
||||
--
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
?. ?=([%sole @ ~] path)
|
||||
=^ cards shoe
|
||||
(on-watch:og path)
|
||||
[(deal cards) this]
|
||||
=* sole-id i.t.path
|
||||
?> (can-connect:og sole-id)
|
||||
=. soles (~(put by soles) sole-id *sole-share)
|
||||
=^ cards shoe
|
||||
(on-connect:og sole-id)
|
||||
:_ this
|
||||
%- deal
|
||||
:_ cards
|
||||
[%shoe [sole-id]~ %sole %pro & dap.bowl "> "]
|
||||
::
|
||||
++ on-leave
|
||||
|= =path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards shoe (on-leave:og path)
|
||||
[(deal cards) this]
|
||||
::
|
||||
++ on-peek
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
?. =(/x/dbug/state path) ~
|
||||
``noun+(slop on-save:og !>(shoe=state))
|
||||
::
|
||||
++ on-agent
|
||||
|= [=wire =sign:agent:gall]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards shoe (on-agent:og wire sign)
|
||||
[(deal cards) this]
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards shoe (on-arvo:og wire sign-arvo)
|
||||
[(deal cards) this]
|
||||
::
|
||||
++ on-fail
|
||||
|= [=term =tang]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
=^ cards shoe (on-fail:og term tang)
|
||||
[(deal cards) this]
|
||||
--
|
||||
::
|
||||
++ draw
|
||||
|%
|
||||
++ row
|
||||
|= [bold=? wide=(list @ud) cols=(list dime)]
|
||||
^- sole-effect
|
||||
:- %mor
|
||||
^- (list sole-effect)
|
||||
=/ cows=(list [wid=@ud col=dime])
|
||||
%- head
|
||||
%^ spin cols wide
|
||||
|= [col=dime wiz=(list @ud)]
|
||||
~| [%too-few-wide col]
|
||||
?> ?=(^ wiz)
|
||||
[[i.wiz col] t.wiz]
|
||||
=/ cobs=(list [wid=@ud (list tape)])
|
||||
(turn cows col-as-lines)
|
||||
=+ [lin=0 any=|]
|
||||
=| fez=(list sole-effect)
|
||||
|- ^+ fez
|
||||
=; out=tape
|
||||
:: done when we're past the end of all columns
|
||||
::
|
||||
?: (levy out (cury test ' '))
|
||||
(flop fez)
|
||||
=; fec=sole-effect
|
||||
$(lin +(lin), fez [fec fez])
|
||||
?. bold txt+out
|
||||
klr+[[`%br ~ ~]^[(crip out)]~]~
|
||||
%+ roll cobs
|
||||
|= [[wid=@ud lines=(list tape)] out=tape]
|
||||
%+ weld out
|
||||
%+ weld ?~(out "" " ")
|
||||
=+ l=(swag [lin 1] lines)
|
||||
?^(l i.l (reap wid ' '))
|
||||
::
|
||||
++ col-as-lines
|
||||
|= [wid=@ud col=dime]
|
||||
^- [@ud (list tape)]
|
||||
:- wid
|
||||
%+ turn
|
||||
(break wid (col-as-text col) (break-sets -.col))
|
||||
(cury (cury pad wid) (alignment -.col))
|
||||
::
|
||||
++ col-as-text
|
||||
|= col=dime
|
||||
^- tape
|
||||
?+ p.col (scow col)
|
||||
%t (trip q.col)
|
||||
%tas ['%' (scow col)]
|
||||
==
|
||||
::
|
||||
++ alignment
|
||||
|= wut=@ta
|
||||
^- ?(%left %right)
|
||||
?: ?=(?(%t %ta %tas %da) wut)
|
||||
%left
|
||||
%right
|
||||
::
|
||||
++ break-sets
|
||||
|= wut=@ta
|
||||
:: for: may break directly before these characters
|
||||
:: aft: may break directly after these characters
|
||||
:: new: always break on these characters, consuming them
|
||||
::
|
||||
^- [for=(set @t) aft=(set @t) new=(set @t)]
|
||||
?+ wut [(sy " ") (sy ".:-/") (sy "\0a")]
|
||||
?(%p %q) [(sy "-") (sy "-") ~]
|
||||
%ux [(sy ".") ~ ~]
|
||||
==
|
||||
::
|
||||
++ break
|
||||
|= [wid=@ud cot=tape brs=_*break-sets]
|
||||
^- (list tape)
|
||||
~| [wid cot]
|
||||
?: =("" cot) ~
|
||||
=; [lin=tape rem=tape]
|
||||
[lin $(cot rem)]
|
||||
:: take snip of max width+1, search for breakpoint on that.
|
||||
:: we grab one char extra, to look-ahead for for.brs.
|
||||
:: later on, we always transfer _at least_ the extra char.
|
||||
::
|
||||
=^ lin=tape cot
|
||||
[(scag +(wid) cot) (slag +(wid) cot)]
|
||||
=+ len=(lent lin)
|
||||
:: find the first newline character
|
||||
::
|
||||
=/ new=(unit @ud)
|
||||
=+ new=~(tap in new.brs)
|
||||
=| las=(unit @ud)
|
||||
|-
|
||||
?~ new las
|
||||
$(new t.new, las (hunt lth las (find [i.new]~ lin)))
|
||||
:: if we found a newline, break on it
|
||||
::
|
||||
?^ new
|
||||
:- (scag u.new lin)
|
||||
(weld (slag +(u.new) lin) cot)
|
||||
:: if it fits, we're done
|
||||
::
|
||||
?: (lte len wid)
|
||||
[lin cot]
|
||||
=+ nil=(flop lin)
|
||||
:: search for latest aft match
|
||||
::
|
||||
=/ aft=(unit @ud)
|
||||
:: exclude the look-ahead character from search
|
||||
::
|
||||
=. len (dec len)
|
||||
=. nil (slag 1 nil)
|
||||
=- ?~(- ~ `+(u.-))
|
||||
^- (unit @ud)
|
||||
=+ aft=~(tap in aft.brs)
|
||||
=| las=(unit @ud)
|
||||
|-
|
||||
?~ aft (bind las (cury sub (dec len)))
|
||||
$(aft t.aft, las (hunt lth las (find [i.aft]~ nil)))
|
||||
:: search for latest for match
|
||||
::
|
||||
=/ for=(unit @ud)
|
||||
=+ for=~(tap in for.brs)
|
||||
=| las=(unit @ud)
|
||||
|-
|
||||
?~ for (bind las (cury sub (dec len)))
|
||||
=- $(for t.for, las (hunt lth las -))
|
||||
=+ (find [i.for]~ nil)
|
||||
:: don't break before the first character
|
||||
::
|
||||
?:(=(`(dec len) -) ~ -)
|
||||
:: if any result, break as late as possible
|
||||
::
|
||||
=+ brk=(hunt gth aft for)
|
||||
?~ brk
|
||||
:: lin can't break, produce it in its entirety
|
||||
:: (after moving the look-ahead character back)
|
||||
::
|
||||
:- (scag wid lin)
|
||||
(weld (slag wid lin) cot)
|
||||
:- (scag u.brk lin)
|
||||
=. cot (weld (slag u.brk lin) cot)
|
||||
:: eat any leading whitespace the next line might have, "clean break"
|
||||
::
|
||||
|- ^+ cot
|
||||
?~ cot ~
|
||||
?. ?=(?(%' ' %'\09') i.cot)
|
||||
cot
|
||||
$(cot t.cot)
|
||||
::
|
||||
++ pad
|
||||
|= [wid=@ud lyn=?(%left %right) lin=tape]
|
||||
^+ lin
|
||||
=+ l=(lent lin)
|
||||
?: (gte l wid) lin
|
||||
=+ p=(reap (sub wid l) ' ')
|
||||
?- lyn
|
||||
%left (weld lin p)
|
||||
%right (weld p lin)
|
||||
==
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/shoe.hoon
Symbolic link
1
pkg/arvo/lib/shoe.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/shoe.hoon
|
@ -1,51 +0,0 @@
|
||||
:: Similar to default-agent except crashes everywhere
|
||||
^- agent:gall
|
||||
|_ bowl:gall
|
||||
++ on-init
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
::
|
||||
++ on-save
|
||||
^- vase
|
||||
!!
|
||||
::
|
||||
++ on-load
|
||||
|~ old-state=vase
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
::
|
||||
++ on-poke
|
||||
|~ in-poke-data=cage
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
::
|
||||
++ on-watch
|
||||
|~ path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
::
|
||||
++ on-leave
|
||||
|~ path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
::
|
||||
++ on-peek
|
||||
|~ path
|
||||
^- (unit (unit cage))
|
||||
!!
|
||||
::
|
||||
++ on-agent
|
||||
|~ [wire sign:agent:gall]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
::
|
||||
++ on-arvo
|
||||
|~ [wire =sign-arvo]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
::
|
||||
++ on-fail
|
||||
|~ [term tang]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
!!
|
||||
--
|
1
pkg/arvo/lib/skeleton.hoon
Symbolic link
1
pkg/arvo/lib/skeleton.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/skeleton.hoon
|
@ -1,139 +0,0 @@
|
||||
::
|
||||
:::: /hoon/sole/lib
|
||||
::
|
||||
/? 310
|
||||
/- *sole
|
||||
::::
|
||||
::
|
||||
|_ sole-share :: shared-state engine
|
||||
++ abet +<
|
||||
++ apply
|
||||
|= ted=sole-edit
|
||||
^+ +>
|
||||
?- -.ted
|
||||
%del +>.$(buf (weld (scag p.ted buf) (slag +(p.ted) buf)))
|
||||
%ins +>.$(buf (weld (scag p.ted buf) `_buf`[q.ted (slag p.ted buf)]))
|
||||
%mor |- ^+ +>.^$
|
||||
?~ p.ted
|
||||
+>.^$
|
||||
$(p.ted t.p.ted, +>.^$ ^$(ted i.p.ted))
|
||||
%nop +>.$
|
||||
%set +>.$(buf p.ted)
|
||||
==
|
||||
::
|
||||
::::
|
||||
:: ++transmute: symmetric operational transformation.
|
||||
::
|
||||
:: for any sole state +>, obeys
|
||||
::
|
||||
:: =+ [x=(transmute a b) y=(transmute b a)]
|
||||
:: .= (apply:(apply a) x)
|
||||
:: (apply:(apply b) y)
|
||||
::
|
||||
++ transmute :: dex as after sin
|
||||
|= [sin=sole-edit dex=sole-edit]
|
||||
~| [%transmute sin dex]
|
||||
^- sole-edit
|
||||
?: ?=(%mor -.sin)
|
||||
|- ^- sole-edit
|
||||
?~ p.sin dex
|
||||
$(p.sin t.p.sin, dex ^$(sin i.p.sin))
|
||||
::
|
||||
?: ?=(%mor -.dex)
|
||||
:- %mor
|
||||
|- ^- (list sole-edit)
|
||||
?~ p.dex ~
|
||||
[^$(dex i.p.dex) $(p.dex t.p.dex)]
|
||||
::
|
||||
?: |(?=(%nop -.sin) ?=(%nop -.dex)) dex
|
||||
?: ?=(%set -.sin) [%nop ~]
|
||||
?: ?=(%set -.dex) dex
|
||||
::
|
||||
?- -.sin
|
||||
%del
|
||||
?- -.dex
|
||||
%del ?: =(p.sin p.dex) [%nop ~]
|
||||
?:((lth p.sin p.dex) dex(p (dec p.dex)) dex)
|
||||
%ins ?:((lth p.sin p.dex) dex(p (dec p.dex)) dex)
|
||||
==
|
||||
::
|
||||
%ins
|
||||
?- -.dex
|
||||
%del ?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
|
||||
%ins ?: =(p.sin p.dex)
|
||||
?:((lth q.sin q.dex) dex dex(p +(p.dex)))
|
||||
?:((lte p.sin p.dex) dex(p +(p.dex)) dex)
|
||||
==
|
||||
==
|
||||
::
|
||||
++ commit :: local change
|
||||
|= ted=sole-edit
|
||||
^- sole-share
|
||||
abet:(apply(own.ven +(own.ven), leg [ted leg]) ted)
|
||||
::
|
||||
::::
|
||||
:: ++inverse: inverse of change in context.
|
||||
::
|
||||
:: for any sole state +>, obeys
|
||||
::
|
||||
:: =(+> (apply:(apply a) (inverse a)))
|
||||
::
|
||||
++ inverse :: relative inverse
|
||||
|= ted=sole-edit
|
||||
^- sole-edit
|
||||
=. ted ?.(?=([%mor * ~] ted) ted i.p.ted)
|
||||
?- -.ted
|
||||
%del [%ins p.ted (snag p.ted buf)]
|
||||
%ins [%del p.ted]
|
||||
%mor :- %mor
|
||||
%- flop
|
||||
|- ^- (list sole-edit)
|
||||
?~ p.ted ~
|
||||
:- ^$(ted i.p.ted)
|
||||
$(p.ted t.p.ted, +>.^$ (apply i.p.ted))
|
||||
%nop [%nop ~]
|
||||
%set [%set buf]
|
||||
==
|
||||
::
|
||||
++ receive :: naturalize event
|
||||
|= sole-change
|
||||
^- [sole-edit sole-share]
|
||||
?. &(=(his.ler his.ven) (lte own.ler own.ven))
|
||||
~| [%receive-sync his+[his.ler his.ven] own+[own.ler own.ven]]
|
||||
!!
|
||||
?> &(=(his.ler his.ven) (lte own.ler own.ven))
|
||||
?> |(!=(own.ler own.ven) =(`@`0 haw) =(haw (sham buf)))
|
||||
=. leg (scag (sub own.ven own.ler) leg)
|
||||
:: ~? !=(own.ler own.ven) [%miss-leg leg]
|
||||
=+ dat=(transmute [%mor leg] ted)
|
||||
:: ~? !=(~ leg) [%transmute from+ted to+dat ~]
|
||||
[dat abet:(apply(his.ven +(his.ven)) dat)]
|
||||
::
|
||||
++ remit :: conditional accept
|
||||
|= [cal=sole-change ask=$-((list @c) ?)]
|
||||
^- [(unit sole-change) sole-share]
|
||||
=+ old=buf
|
||||
=^ dat +>+<.$ (receive cal)
|
||||
?: (ask buf)
|
||||
[~ +>+<.$]
|
||||
=^ lic +>+<.$ (transmit (inverse(buf old) dat))
|
||||
[`lic +>+<.$]
|
||||
::
|
||||
++ transmit :: outgoing change
|
||||
|= ted=sole-edit
|
||||
^- [sole-change sole-share]
|
||||
[[[his.ven own.ven] (sham buf) ted] (commit ted)]
|
||||
::
|
||||
++ transceive :: receive and invert
|
||||
|= sole-change
|
||||
^- [sole-edit sole-share]
|
||||
=+ old=buf
|
||||
=^ dat +>+<.$ (receive +<.$)
|
||||
[(inverse(buf old) dat) +>+<.$]
|
||||
::
|
||||
++ transpose :: adjust position
|
||||
|= pos=@ud
|
||||
=+ dat=(transmute [%mor leg] [%ins pos `@c`0])
|
||||
?> ?=(%ins -.dat)
|
||||
p.dat
|
||||
--
|
1
pkg/arvo/lib/sole.hoon
Symbolic link
1
pkg/arvo/lib/sole.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/sole.hoon
|
@ -1,167 +0,0 @@
|
||||
|%
|
||||
+$ card card:agent:gall
|
||||
+$ input
|
||||
$% [%poke =cage]
|
||||
[%sign =wire =sign-arvo]
|
||||
[%agent =wire =sign:agent:gall]
|
||||
[%watch =path]
|
||||
==
|
||||
+$ strand-input [=bowl in=(unit input)]
|
||||
+$ tid @tatid
|
||||
+$ bowl
|
||||
$: our=ship
|
||||
src=ship
|
||||
tid=tid
|
||||
mom=(unit tid)
|
||||
wex=boat:gall
|
||||
sup=bitt:gall
|
||||
eny=@uvJ
|
||||
now=@da
|
||||
byk=beak
|
||||
==
|
||||
::
|
||||
:: cards: cards to send immediately. These will go out even if a
|
||||
:: later stage of the computation fails, so they shouldn't have
|
||||
:: any semantic effect on the rest of the system.
|
||||
:: Alternately, they may record an entry in contracts with
|
||||
:: enough information to undo the effect if the computation
|
||||
:: fails.
|
||||
:: wait: don't move on, stay here. The next sign should come back
|
||||
:: to this same callback.
|
||||
:: skip: didn't expect this input; drop it down to be handled
|
||||
:: elsewhere
|
||||
:: cont: continue computation with new callback.
|
||||
:: fail: abort computation; don't send effects
|
||||
:: done: finish computation; send effects
|
||||
::
|
||||
++ strand-output-raw
|
||||
|* a=mold
|
||||
$~ [~ %done *a]
|
||||
$: cards=(list card)
|
||||
$= next
|
||||
$% [%wait ~]
|
||||
[%skip ~]
|
||||
[%cont self=(strand-form-raw a)]
|
||||
[%fail err=(pair term tang)]
|
||||
[%done value=a]
|
||||
==
|
||||
==
|
||||
::
|
||||
++ strand-form-raw
|
||||
|* a=mold
|
||||
$-(strand-input (strand-output-raw a))
|
||||
::
|
||||
:: Abort strand computation with error message
|
||||
::
|
||||
++ strand-fail
|
||||
|= err=(pair term tang)
|
||||
|= strand-input
|
||||
[~ %fail err]
|
||||
::
|
||||
:: Asynchronous transcaction monad.
|
||||
::
|
||||
:: Combo of four monads:
|
||||
:: - Reader on input
|
||||
:: - Writer on card
|
||||
:: - Continuation
|
||||
:: - Exception
|
||||
::
|
||||
++ strand
|
||||
|* a=mold
|
||||
|%
|
||||
++ output (strand-output-raw a)
|
||||
::
|
||||
:: Type of an strand computation.
|
||||
::
|
||||
++ form (strand-form-raw a)
|
||||
::
|
||||
:: Monadic pure. Identity computation for bind.
|
||||
::
|
||||
++ pure
|
||||
|= arg=a
|
||||
^- form
|
||||
|= strand-input
|
||||
[~ %done arg]
|
||||
::
|
||||
:: Monadic bind. Combines two computations, associatively.
|
||||
::
|
||||
++ bind
|
||||
|* b=mold
|
||||
|= [m-b=(strand-form-raw b) fun=$-(b form)]
|
||||
^- form
|
||||
|= input=strand-input
|
||||
=/ b-res=(strand-output-raw b)
|
||||
(m-b input)
|
||||
^- output
|
||||
:- cards.b-res
|
||||
?- -.next.b-res
|
||||
%wait [%wait ~]
|
||||
%skip [%skip ~]
|
||||
%cont [%cont ..$(m-b self.next.b-res)]
|
||||
%fail [%fail err.next.b-res]
|
||||
%done [%cont (fun value.next.b-res)]
|
||||
==
|
||||
::
|
||||
:: The strand monad must be evaluted in a particular way to maintain
|
||||
:: its monadic character. +take:eval implements this.
|
||||
::
|
||||
++ eval
|
||||
|%
|
||||
:: Indelible state of a strand
|
||||
::
|
||||
+$ eval-form
|
||||
$: =form
|
||||
==
|
||||
::
|
||||
:: Convert initial form to eval-form
|
||||
::
|
||||
++ from-form
|
||||
|= =form
|
||||
^- eval-form
|
||||
form
|
||||
::
|
||||
:: The cases of results of +take
|
||||
::
|
||||
+$ eval-result
|
||||
$% [%next ~]
|
||||
[%fail err=(pair term tang)]
|
||||
[%done value=a]
|
||||
==
|
||||
::
|
||||
:: Take a new sign and run the strand against it
|
||||
::
|
||||
++ take
|
||||
:: cards: accumulate throughout recursion the cards to be
|
||||
:: produced now
|
||||
=| cards=(list card)
|
||||
|= [=eval-form =strand-input]
|
||||
^- [[(list card) =eval-result] _eval-form]
|
||||
=* take-loop $
|
||||
:: run the strand callback
|
||||
::
|
||||
=/ =output (form.eval-form strand-input)
|
||||
:: add cards to cards
|
||||
::
|
||||
=. cards
|
||||
%+ welp
|
||||
cards
|
||||
:: XX add tag to wires?
|
||||
cards.output
|
||||
:: case-wise handle next steps
|
||||
::
|
||||
?- -.next.output
|
||||
%wait [[cards %next ~] eval-form]
|
||||
%skip [[cards %next ~] eval-form]
|
||||
%fail [[cards %fail err.next.output] eval-form]
|
||||
%done [[cards %done value.next.output] eval-form]
|
||||
%cont
|
||||
:: recurse to run continuation with initialization input
|
||||
::
|
||||
%_ take-loop
|
||||
form.eval-form self.next.output
|
||||
strand-input [bowl.strand-input ~]
|
||||
==
|
||||
==
|
||||
--
|
||||
--
|
||||
--
|
1
pkg/arvo/lib/strand.hoon
Symbolic link
1
pkg/arvo/lib/strand.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/strand.hoon
|
@ -1,742 +0,0 @@
|
||||
/- spider
|
||||
/+ libstrand=strand
|
||||
=, strand=strand:libstrand
|
||||
=, strand-fail=strand-fail:libstrand
|
||||
|%
|
||||
++ send-raw-cards
|
||||
|= cards=(list =card:agent:gall)
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
|= strand-input:strand
|
||||
[cards %done ~]
|
||||
::
|
||||
++ send-raw-card
|
||||
|= =card:agent:gall
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(send-raw-cards card ~)
|
||||
::
|
||||
++ ignore
|
||||
|= tin=strand-input:strand
|
||||
`[%fail %ignore ~]
|
||||
::
|
||||
++ get-bowl
|
||||
=/ m (strand ,bowl:strand)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
`[%done bowl.tin]
|
||||
::
|
||||
++ get-beak
|
||||
=/ m (strand ,beak)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
`[%done [our q.byk da+now]:bowl.tin]
|
||||
::
|
||||
++ get-time
|
||||
=/ m (strand ,@da)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
`[%done now.bowl.tin]
|
||||
::
|
||||
++ get-our
|
||||
=/ m (strand ,ship)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
`[%done our.bowl.tin]
|
||||
::
|
||||
++ get-entropy
|
||||
=/ m (strand ,@uvJ)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
`[%done eny.bowl.tin]
|
||||
::
|
||||
:: Convert skips to %ignore failures.
|
||||
::
|
||||
:: This tells the main loop to try the next handler.
|
||||
::
|
||||
++ handle
|
||||
|* a=mold
|
||||
=/ m (strand ,a)
|
||||
|= =form:m
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
=/ res (form tin)
|
||||
=? next.res ?=(%skip -.next.res)
|
||||
[%fail %ignore ~]
|
||||
res
|
||||
::
|
||||
:: Wait for a poke with a particular mark
|
||||
::
|
||||
++ take-poke
|
||||
|= =mark
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %poke @ *]
|
||||
?. =(mark p.cage.u.in.tin)
|
||||
`[%skip ~]
|
||||
`[%done q.cage.u.in.tin]
|
||||
==
|
||||
::
|
||||
::
|
||||
::
|
||||
++ take-sign-arvo
|
||||
=/ m (strand ,[wire sign-arvo])
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %sign *]
|
||||
`[%done [wire sign-arvo]:u.in.tin]
|
||||
==
|
||||
::
|
||||
:: Wait for a subscription update on a wire
|
||||
::
|
||||
++ take-fact-prefix
|
||||
|= =wire
|
||||
=/ m (strand ,[path cage])
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %agent * %fact *]
|
||||
?. =(watch+wire (scag +((lent wire)) wire.u.in.tin))
|
||||
`[%skip ~]
|
||||
`[%done (slag (lent wire) wire.u.in.tin) cage.sign.u.in.tin]
|
||||
==
|
||||
::
|
||||
:: Wait for a subscription update on a wire
|
||||
::
|
||||
++ take-fact
|
||||
|= =wire
|
||||
=/ m (strand ,cage)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %agent * %fact *]
|
||||
?. =(watch+wire wire.u.in.tin)
|
||||
`[%skip ~]
|
||||
`[%done cage.sign.u.in.tin]
|
||||
==
|
||||
::
|
||||
:: Wait for a subscription close
|
||||
::
|
||||
++ take-kick
|
||||
|= =wire
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %agent * %kick *]
|
||||
?. =(watch+wire wire.u.in.tin)
|
||||
`[%skip ~]
|
||||
`[%done ~]
|
||||
==
|
||||
::
|
||||
++ echo
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
%- (main-loop ,~)
|
||||
:~ |= ~
|
||||
^- form:m
|
||||
;< =vase bind:m ((handle ,vase) (take-poke %echo))
|
||||
=/ message=tape !<(tape vase)
|
||||
%- (slog leaf+"{message}..." ~)
|
||||
;< ~ bind:m (sleep ~s2)
|
||||
%- (slog leaf+"{message}.." ~)
|
||||
(pure:m ~)
|
||||
::
|
||||
|= ~
|
||||
^- form:m
|
||||
;< =vase bind:m ((handle ,vase) (take-poke %over))
|
||||
%- (slog leaf+"over..." ~)
|
||||
(pure:m ~)
|
||||
==
|
||||
::
|
||||
++ take-watch
|
||||
=/ m (strand ,path)
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %watch *]
|
||||
`[%done path.u.in.tin]
|
||||
==
|
||||
::
|
||||
++ take-wake
|
||||
|= until=(unit @da)
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %sign [%wait @ ~] %behn %wake *]
|
||||
?. |(?=(~ until) =(`u.until (slaw %da i.t.wire.u.in.tin)))
|
||||
`[%skip ~]
|
||||
?~ error.sign-arvo.u.in.tin
|
||||
`[%done ~]
|
||||
`[%fail %timer-error u.error.sign-arvo.u.in.tin]
|
||||
==
|
||||
::
|
||||
++ take-poke-ack
|
||||
|= =wire
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %agent * %poke-ack *]
|
||||
?. =(wire wire.u.in.tin)
|
||||
`[%skip ~]
|
||||
?~ p.sign.u.in.tin
|
||||
`[%done ~]
|
||||
`[%fail %poke-fail u.p.sign.u.in.tin]
|
||||
==
|
||||
::
|
||||
++ take-watch-ack
|
||||
|= =wire
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %agent * %watch-ack *]
|
||||
?. =(watch+wire wire.u.in.tin)
|
||||
`[%skip ~]
|
||||
?~ p.sign.u.in.tin
|
||||
`[%done ~]
|
||||
`[%fail %watch-ack-fail u.p.sign.u.in.tin]
|
||||
==
|
||||
::
|
||||
++ poke
|
||||
|= [=dock =cage]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
=/ =card:agent:gall [%pass /poke %agent dock %poke cage]
|
||||
;< ~ bind:m (send-raw-card card)
|
||||
(take-poke-ack /poke)
|
||||
::
|
||||
++ raw-poke
|
||||
|= [=dock =cage]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
=/ =card:agent:gall [%pass /poke %agent dock %poke cage]
|
||||
;< ~ bind:m (send-raw-card card)
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~
|
||||
`[%wait ~]
|
||||
::
|
||||
[~ %agent * %poke-ack *]
|
||||
?. =(/poke wire.u.in.tin)
|
||||
`[%skip ~]
|
||||
`[%done ~]
|
||||
==
|
||||
::
|
||||
++ raw-poke-our
|
||||
|= [app=term =cage]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
;< =bowl:spider bind:m get-bowl
|
||||
(raw-poke [our.bowl app] cage)
|
||||
::
|
||||
++ poke-our
|
||||
|= [=term =cage]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
;< our=@p bind:m get-our
|
||||
(poke [our term] cage)
|
||||
::
|
||||
++ watch
|
||||
|= [=wire =dock =path]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
=/ =card:agent:gall [%pass watch+wire %agent dock %watch path]
|
||||
;< ~ bind:m (send-raw-card card)
|
||||
(take-watch-ack wire)
|
||||
::
|
||||
++ watch-our
|
||||
|= [=wire =term =path]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
;< our=@p bind:m get-our
|
||||
(watch wire [our term] path)
|
||||
::
|
||||
++ scry
|
||||
|* [=mold =path]
|
||||
=/ m (strand ,mold)
|
||||
^- form:m
|
||||
?> ?=(^ path)
|
||||
?> ?=(^ t.path)
|
||||
;< =bowl:spider bind:m get-bowl
|
||||
%- pure:m
|
||||
.^(mold i.path (scot %p our.bowl) i.t.path (scot %da now.bowl) t.t.path)
|
||||
::
|
||||
++ leave
|
||||
|= [=wire =dock]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
=/ =card:agent:gall [%pass watch+wire %agent dock %leave ~]
|
||||
(send-raw-card card)
|
||||
::
|
||||
++ leave-our
|
||||
|= [=wire =term]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
;< our=@p bind:m get-our
|
||||
(leave wire [our term])
|
||||
::
|
||||
++ rewatch
|
||||
|= [=wire =dock =path]
|
||||
=/ m (strand ,~)
|
||||
;< ~ bind:m ((handle ,~) (take-kick wire))
|
||||
;< ~ bind:m (flog-text "rewatching {<dock>} {<path>}")
|
||||
;< ~ bind:m (watch wire dock path)
|
||||
(pure:m ~)
|
||||
::
|
||||
++ wait
|
||||
|= until=@da
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
;< ~ bind:m (send-wait until)
|
||||
(take-wake `until)
|
||||
::
|
||||
++ sleep
|
||||
|= for=@dr
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
;< now=@da bind:m get-time
|
||||
(wait (add now for))
|
||||
::
|
||||
++ send-wait
|
||||
|= until=@da
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
=/ =card:agent:gall
|
||||
[%pass /wait/(scot %da until) %arvo %b %wait until]
|
||||
(send-raw-card card)
|
||||
::
|
||||
++ map-err
|
||||
|* computation-result=mold
|
||||
=/ m (strand ,computation-result)
|
||||
|= [f=$-([term tang] [term tang]) computation=form:m]
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
=* loop $
|
||||
=/ c-res (computation tin)
|
||||
?: ?=(%cont -.next.c-res)
|
||||
c-res(self.next ..loop(computation self.next.c-res))
|
||||
?. ?=(%fail -.next.c-res)
|
||||
c-res
|
||||
c-res(err.next (f err.next.c-res))
|
||||
::
|
||||
++ set-timeout
|
||||
|* computation-result=mold
|
||||
=/ m (strand ,computation-result)
|
||||
|= [time=@dr computation=form:m]
|
||||
^- form:m
|
||||
;< now=@da bind:m get-time
|
||||
=/ when (add now time)
|
||||
=/ =card:agent:gall
|
||||
[%pass /timeout/(scot %da when) %arvo %b %wait when]
|
||||
;< ~ bind:m (send-raw-card card)
|
||||
|= tin=strand-input:strand
|
||||
=* loop $
|
||||
?: ?& ?=([~ %sign [%timeout @ ~] %behn %wake *] in.tin)
|
||||
=((scot %da when) i.t.wire.u.in.tin)
|
||||
==
|
||||
`[%fail %timeout ~]
|
||||
=/ c-res (computation tin)
|
||||
?: ?=(%cont -.next.c-res)
|
||||
c-res(self.next ..loop(computation self.next.c-res))
|
||||
?: ?=(%done -.next.c-res)
|
||||
=/ =card:agent:gall
|
||||
[%pass /timeout/(scot %da when) %arvo %b %rest when]
|
||||
c-res(cards [card cards.c-res])
|
||||
c-res
|
||||
::
|
||||
++ send-request
|
||||
|= =request:http
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(send-raw-card %pass /request %arvo %i %request request *outbound-config:iris)
|
||||
::
|
||||
++ send-cancel-request
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(send-raw-card %pass /request %arvo %i %cancel-request ~)
|
||||
::
|
||||
++ take-client-response
|
||||
=/ m (strand ,client-response:iris)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %sign [%request ~] %iris %http-response %finished *]
|
||||
`[%done client-response.sign-arvo.u.in.tin]
|
||||
==
|
||||
::
|
||||
:: Wait until we get an HTTP response or cancelation and unset contract
|
||||
::
|
||||
++ take-maybe-sigh
|
||||
=/ m (strand ,(unit httr:eyre))
|
||||
^- form:m
|
||||
;< rep=(unit client-response:iris) bind:m
|
||||
take-maybe-response
|
||||
?~ rep
|
||||
(pure:m ~)
|
||||
:: XX s/b impossible
|
||||
::
|
||||
?. ?=(%finished -.u.rep)
|
||||
(pure:m ~)
|
||||
(pure:m (some (to-httr:iris +.u.rep)))
|
||||
::
|
||||
++ take-maybe-response
|
||||
=/ m (strand ,(unit client-response:iris))
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %sign [%request ~] %iris %http-response %cancel *]
|
||||
`[%done ~]
|
||||
[~ %sign [%request ~] %iris %http-response %finished *]
|
||||
`[%done `client-response.sign-arvo.u.in.tin]
|
||||
==
|
||||
::
|
||||
++ extract-body
|
||||
|= =client-response:iris
|
||||
=/ m (strand ,cord)
|
||||
^- form:m
|
||||
?> ?=(%finished -.client-response)
|
||||
?> ?=(^ full-file.client-response)
|
||||
(pure:m q.data.u.full-file.client-response)
|
||||
::
|
||||
++ fetch-cord
|
||||
|= url=tape
|
||||
=/ m (strand ,cord)
|
||||
^- form:m
|
||||
=/ =request:http [%'GET' (crip url) ~ ~]
|
||||
;< ~ bind:m (send-request request)
|
||||
;< =client-response:iris bind:m take-client-response
|
||||
(extract-body client-response)
|
||||
::
|
||||
++ fetch-json
|
||||
|= url=tape
|
||||
=/ m (strand ,json)
|
||||
^- form:m
|
||||
;< =cord bind:m (fetch-cord url)
|
||||
=/ json=(unit json) (de-json:html cord)
|
||||
?~ json
|
||||
(strand-fail %json-parse-error ~)
|
||||
(pure:m u.json)
|
||||
::
|
||||
++ hiss-request
|
||||
|= =hiss:eyre
|
||||
=/ m (strand ,(unit httr:eyre))
|
||||
^- form:m
|
||||
;< ~ bind:m (send-request (hiss-to-request:html hiss))
|
||||
take-maybe-sigh
|
||||
::
|
||||
:: +build-file: build the source file at the specified $beam
|
||||
::
|
||||
++ build-file
|
||||
|= [[=ship =desk =case] =spur]
|
||||
=* arg +<
|
||||
=/ m (strand ,(unit vase))
|
||||
^- form:m
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %a case spur)
|
||||
?~ riot
|
||||
(pure:m ~)
|
||||
?> =(%vase p.r.u.riot)
|
||||
(pure:m (some !<(vase q.r.u.riot)))
|
||||
:: +build-mark: build a mark definition to a $dais
|
||||
::
|
||||
++ build-mark
|
||||
|= [[=ship =desk =case] mak=mark]
|
||||
=* arg +<
|
||||
=/ m (strand ,dais:clay)
|
||||
^- form:m
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %b case /[mak])
|
||||
?~ riot
|
||||
(strand-fail %build-mark >arg< ~)
|
||||
?> =(%dais p.r.u.riot)
|
||||
(pure:m !<(dais:clay q.r.u.riot))
|
||||
:: +build-tube: build a mark conversion gate ($tube)
|
||||
::
|
||||
++ build-tube
|
||||
|= [[=ship =desk =case] =mars:clay]
|
||||
=* arg +<
|
||||
=/ m (strand ,tube:clay)
|
||||
^- form:m
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %c case /[a.mars]/[b.mars])
|
||||
?~ riot
|
||||
(strand-fail %build-tube >arg< ~)
|
||||
?> =(%tube p.r.u.riot)
|
||||
(pure:m !<(tube:clay q.r.u.riot))
|
||||
::
|
||||
:: +build-nave: build a mark definition to a $nave
|
||||
::
|
||||
++ build-nave
|
||||
|= [[=ship =desk =case] mak=mark]
|
||||
=* arg +<
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %e case /[mak])
|
||||
?~ riot
|
||||
(strand-fail %build-nave >arg< ~)
|
||||
?> =(%nave p.r.u.riot)
|
||||
(pure:m q.r.u.riot)
|
||||
:: +build-cast: build a mark conversion gate (static)
|
||||
::
|
||||
++ build-cast
|
||||
|= [[=ship =desk =case] =mars:clay]
|
||||
=* arg +<
|
||||
=/ m (strand ,vase)
|
||||
^- form:m
|
||||
;< =riot:clay bind:m
|
||||
(warp ship desk ~ %sing %f case /[a.mars]/[b.mars])
|
||||
?~ riot
|
||||
(strand-fail %build-cast >arg< ~)
|
||||
?> =(%cast p.r.u.riot)
|
||||
(pure:m q.r.u.riot)
|
||||
::
|
||||
:: Read from Clay
|
||||
::
|
||||
++ warp
|
||||
|= [=ship =riff:clay]
|
||||
=/ m (strand ,riot:clay)
|
||||
;< ~ bind:m (send-raw-card %pass /warp %arvo %c %warp ship riff)
|
||||
(take-writ /warp)
|
||||
::
|
||||
++ read-file
|
||||
|= [[=ship =desk =case:clay] =spur]
|
||||
=* arg +<
|
||||
=/ m (strand ,cage)
|
||||
;< =riot:clay bind:m (warp ship desk ~ %sing %x case spur)
|
||||
?~ riot
|
||||
(strand-fail %read-file >arg< ~)
|
||||
(pure:m r.u.riot)
|
||||
::
|
||||
++ check-for-file
|
||||
|= [[=ship =desk =case:clay] =spur]
|
||||
=/ m (strand ,?)
|
||||
;< =riot:clay bind:m (warp ship desk ~ %sing %x case spur)
|
||||
(pure:m ?=(^ riot))
|
||||
::
|
||||
++ list-tree
|
||||
|= [[=ship =desk =case:clay] =spur]
|
||||
=* arg +<
|
||||
=/ m (strand ,(list path))
|
||||
;< =riot:clay bind:m (warp ship desk ~ %sing %t case spur)
|
||||
?~ riot
|
||||
(strand-fail %list-tree >arg< ~)
|
||||
(pure:m !<((list path) q.r.u.riot))
|
||||
::
|
||||
:: Take Clay read result
|
||||
::
|
||||
++ take-writ
|
||||
|= =wire
|
||||
=/ m (strand ,riot:clay)
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
?+ in.tin `[%skip ~]
|
||||
~ `[%wait ~]
|
||||
[~ %sign * ?(%behn %clay) %writ *]
|
||||
?. =(wire wire.u.in.tin)
|
||||
`[%skip ~]
|
||||
`[%done +>.sign-arvo.u.in.tin]
|
||||
==
|
||||
:: +check-online: require that peer respond before timeout
|
||||
::
|
||||
++ check-online
|
||||
|= [who=ship lag=@dr]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
%+ (map-err ,~) |=(* [%offline *tang])
|
||||
%+ (set-timeout ,~) lag
|
||||
;< ~ bind:m
|
||||
(poke [who %hood] %helm-hi !>(~))
|
||||
(pure:m ~)
|
||||
::
|
||||
:: Queue on skip, try next on fail %ignore
|
||||
::
|
||||
++ main-loop
|
||||
|* a=mold
|
||||
=/ m (strand ,~)
|
||||
=/ m-a (strand ,a)
|
||||
=| queue=(qeu (unit input:strand))
|
||||
=| active=(unit [in=(unit input:strand) =form:m-a forms=(list $-(a form:m-a))])
|
||||
=| state=a
|
||||
|= forms=(lest $-(a form:m-a))
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
=* top `form:m`..$
|
||||
=. queue (~(put to queue) in.tin)
|
||||
|^ (continue bowl.tin)
|
||||
::
|
||||
++ continue
|
||||
|= =bowl:strand
|
||||
^- output:m
|
||||
?> =(~ active)
|
||||
?: =(~ queue)
|
||||
`[%cont top]
|
||||
=^ in=(unit input:strand) queue ~(get to queue)
|
||||
^- output:m
|
||||
=. active `[in (i.forms state) t.forms]
|
||||
^- output:m
|
||||
(run bowl in)
|
||||
::
|
||||
++ run
|
||||
^- form:m
|
||||
|= tin=strand-input:strand
|
||||
^- output:m
|
||||
?> ?=(^ active)
|
||||
=/ res (form.u.active tin)
|
||||
=/ =output:m
|
||||
?- -.next.res
|
||||
%wait `[%wait ~]
|
||||
%skip `[%cont ..$(queue (~(put to queue) in.tin))]
|
||||
%cont `[%cont ..$(active `[in.u.active self.next.res forms.u.active])]
|
||||
%done (continue(active ~, state value.next.res) bowl.tin)
|
||||
%fail
|
||||
?: &(?=(^ forms.u.active) ?=(%ignore p.err.next.res))
|
||||
%= $
|
||||
active `[in.u.active (i.forms.u.active state) t.forms.u.active]
|
||||
in.tin in.u.active
|
||||
==
|
||||
`[%fail err.next.res]
|
||||
==
|
||||
[(weld cards.res cards.output) next.output]
|
||||
--
|
||||
::
|
||||
++ retry
|
||||
|* result=mold
|
||||
|= [crash-after=(unit @ud) computation=_*form:(strand (unit result))]
|
||||
=/ m (strand ,result)
|
||||
=| try=@ud
|
||||
|- ^- form:m
|
||||
=* loop $
|
||||
?: =(crash-after `try)
|
||||
(strand-fail %retry-too-many ~)
|
||||
;< ~ bind:m (backoff try ~m1)
|
||||
;< res=(unit result) bind:m computation
|
||||
?^ res
|
||||
(pure:m u.res)
|
||||
loop(try +(try))
|
||||
::
|
||||
++ backoff
|
||||
|= [try=@ud limit=@dr]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
;< eny=@uvJ bind:m get-entropy
|
||||
%- sleep
|
||||
%+ min limit
|
||||
?: =(0 try) ~s0
|
||||
%+ add
|
||||
(mul ~s1 (bex (dec try)))
|
||||
(mul ~s0..0001 (~(rad og eny) 1.000))
|
||||
::
|
||||
:: ----
|
||||
::
|
||||
:: Output
|
||||
::
|
||||
++ flog
|
||||
|= =flog:dill
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(send-raw-card %pass / %arvo %d %flog flog)
|
||||
::
|
||||
++ flog-text
|
||||
|= =tape
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(flog %text tape)
|
||||
::
|
||||
++ flog-tang
|
||||
|= =tang
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
=/ =wall
|
||||
(zing (turn (flop tang) (cury wash [0 80])))
|
||||
|- ^- form:m
|
||||
=* loop $
|
||||
?~ wall
|
||||
(pure:m ~)
|
||||
;< ~ bind:m (flog-text i.wall)
|
||||
loop(wall t.wall)
|
||||
::
|
||||
++ trace
|
||||
|= =tang
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(pure:m ((slog tang) ~))
|
||||
::
|
||||
++ app-message
|
||||
|= [app=term =cord =tang]
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
=/ msg=tape :(weld (trip app) ": " (trip cord))
|
||||
;< ~ bind:m (flog-text msg)
|
||||
(flog-tang tang)
|
||||
::
|
||||
:: ----
|
||||
::
|
||||
:: Handle domains
|
||||
::
|
||||
++ install-domain
|
||||
|= =turf
|
||||
=/ m (strand ,~)
|
||||
^- form:m
|
||||
(send-raw-card %pass / %arvo %e %rule %turf %put turf)
|
||||
::
|
||||
:: ----
|
||||
::
|
||||
:: Threads
|
||||
::
|
||||
++ start-thread
|
||||
|= file=term
|
||||
=/ m (strand ,tid:spider)
|
||||
;< =bowl:spider bind:m get-bowl
|
||||
(start-thread-with-args byk.bowl file *vase)
|
||||
::
|
||||
++ start-thread-with-args
|
||||
|= [=beak file=term args=vase]
|
||||
=/ m (strand ,tid:spider)
|
||||
^- form:m
|
||||
;< =bowl:spider bind:m get-bowl
|
||||
=/ tid
|
||||
(scot %ta (cat 3 (cat 3 'strand_' file) (scot %uv (sham file eny.bowl))))
|
||||
=/ poke-vase !>([`tid.bowl `tid beak file args])
|
||||
;< ~ bind:m (poke-our %spider %spider-start poke-vase)
|
||||
;< ~ bind:m (sleep ~s0) :: wait for thread to start
|
||||
(pure:m tid)
|
||||
::
|
||||
+$ thread-result
|
||||
(each vase [term tang])
|
||||
::
|
||||
++ await-thread
|
||||
|= [file=term args=vase]
|
||||
=/ m (strand ,thread-result)
|
||||
^- form:m
|
||||
;< =bowl:spider bind:m get-bowl
|
||||
=/ tid (scot %ta (cat 3 'strand_' (scot %uv (sham file eny.bowl))))
|
||||
=/ poke-vase !>([`tid.bowl `tid file args])
|
||||
;< ~ bind:m (watch-our /awaiting/[tid] %spider /thread-result/[tid])
|
||||
;< ~ bind:m (poke-our %spider %spider-start poke-vase)
|
||||
;< ~ bind:m (sleep ~s0) :: wait for thread to start
|
||||
;< =cage bind:m (take-fact /awaiting/[tid])
|
||||
;< ~ bind:m (take-kick /awaiting/[tid])
|
||||
?+ p.cage ~|([%strange-thread-result p.cage file tid] !!)
|
||||
%thread-done (pure:m %& q.cage)
|
||||
%thread-fail (pure:m %| !<([term tang] q.cage))
|
||||
==
|
||||
--
|
1
pkg/arvo/lib/strandio.hoon
Symbolic link
1
pkg/arvo/lib/strandio.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/strandio.hoon
|
1
pkg/arvo/lib/treaty.hoon
Symbolic link
1
pkg/arvo/lib/treaty.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/treaty.hoon
|
@ -1,105 +0,0 @@
|
||||
:: Print what your agent is doing.
|
||||
::
|
||||
/- verb
|
||||
::
|
||||
|= [loud=? =agent:gall]
|
||||
=| bowl-print=_|
|
||||
^- agent:gall
|
||||
|^ !.
|
||||
|_ =bowl:gall
|
||||
+* this .
|
||||
ag ~(. agent bowl)
|
||||
::
|
||||
++ on-init
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- (print bowl |.("{<dap.bowl>}: on-init"))
|
||||
=^ cards agent on-init:ag
|
||||
[[(emit-event %on-init ~) cards] this]
|
||||
::
|
||||
++ on-save
|
||||
^- vase
|
||||
%- (print bowl |.("{<dap.bowl>}: on-save"))
|
||||
on-save:ag
|
||||
::
|
||||
++ on-load
|
||||
|= old-state=vase
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- (print bowl |.("{<dap.bowl>}: on-load"))
|
||||
=^ cards agent (on-load:ag old-state)
|
||||
[[(emit-event %on-load ~) cards] this]
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- (print bowl |.("{<dap.bowl>}: on-poke with mark {<mark>}"))
|
||||
?: ?=(%verb mark)
|
||||
?- !<(?(%loud %bowl) vase)
|
||||
%loud `this(loud !loud)
|
||||
%bowl `this(bowl-print !bowl-print)
|
||||
==
|
||||
=^ cards agent (on-poke:ag mark vase)
|
||||
[[(emit-event %on-poke mark) cards] this]
|
||||
::
|
||||
++ on-watch
|
||||
|= =path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- (print bowl |.("{<dap.bowl>}: on-watch on path {<path>}"))
|
||||
=^ cards agent
|
||||
?: ?=([%verb %events ~] path)
|
||||
[~ agent]
|
||||
(on-watch:ag path)
|
||||
[[(emit-event %on-watch path) cards] this]
|
||||
::
|
||||
++ on-leave
|
||||
|= =path
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- (print bowl |.("{<dap.bowl>}: on-leave on path {<path>}"))
|
||||
?: ?=([%verb %event ~] path)
|
||||
[~ this]
|
||||
=^ cards agent (on-leave:ag path)
|
||||
[[(emit-event %on-leave path) cards] this]
|
||||
::
|
||||
++ on-peek
|
||||
|= =path
|
||||
^- (unit (unit cage))
|
||||
%- (print bowl |.("{<dap.bowl>}: on-peek on path {<path>}"))
|
||||
(on-peek:ag path)
|
||||
::
|
||||
++ on-agent
|
||||
|= [=wire =sign:agent:gall]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- (print bowl |.("{<dap.bowl>}: on-agent on wire {<wire>}, {<-.sign>}"))
|
||||
=^ cards agent (on-agent:ag wire sign)
|
||||
[[(emit-event %on-agent wire -.sign) cards] this]
|
||||
::
|
||||
++ on-arvo
|
||||
|= [=wire =sign-arvo]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- %+ print bowl |.
|
||||
"{<dap.bowl>}: on-arvo on wire {<wire>}, {<[- +<]:sign-arvo>}"
|
||||
=^ cards agent (on-arvo:ag wire sign-arvo)
|
||||
[[(emit-event %on-arvo wire [- +<]:sign-arvo) cards] this]
|
||||
::
|
||||
++ on-fail
|
||||
|= [=term =tang]
|
||||
^- (quip card:agent:gall agent:gall)
|
||||
%- (print bowl |.("{<dap.bowl>}: on-fail with term {<term>}"))
|
||||
=^ cards agent (on-fail:ag term tang)
|
||||
[[(emit-event %on-fail term) cards] this]
|
||||
--
|
||||
::
|
||||
++ print
|
||||
|= [=bowl:gall render=(trap tape)]
|
||||
^+ same
|
||||
=? . bowl-print
|
||||
%- (slog >bowl< ~)
|
||||
.
|
||||
?. loud same
|
||||
%- (slog [%leaf $:render] ~)
|
||||
same
|
||||
::
|
||||
++ emit-event
|
||||
|= =event:verb
|
||||
^- card:agent:gall
|
||||
[%give %fact ~[/verb/events] %verb-event !>(event)]
|
||||
--
|
1
pkg/arvo/lib/verb.hoon
Symbolic link
1
pkg/arvo/lib/verb.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/lib/verb.hoon
|
@ -1,29 +0,0 @@
|
||||
:: belt: runtime belt structure
|
||||
::
|
||||
|_ =belt:dill
|
||||
++ grad %noun
|
||||
:: +grab: convert from
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun belt:dill
|
||||
++ json
|
||||
^- $-(^json belt:dill)
|
||||
=, dejs:format
|
||||
%- of
|
||||
:~ aro+(su (perk %d %l %r %u ~))
|
||||
bac+ul
|
||||
ctl+(cu taft so)
|
||||
del+ul
|
||||
met+(cu taft so)
|
||||
ret+ul
|
||||
txt+(ar (cu taft so))
|
||||
==
|
||||
--
|
||||
:: +grow: convert to
|
||||
::
|
||||
++ grow
|
||||
|%
|
||||
++ noun belt
|
||||
--
|
||||
--
|
1
pkg/arvo/mar/belt.hoon
Symbolic link
1
pkg/arvo/mar/belt.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/belt.hoon
|
@ -1,43 +0,0 @@
|
||||
/- *bill
|
||||
|_ bil=bill
|
||||
++ grow
|
||||
|%
|
||||
++ mime `^mime`[/text/x-bill (as-octs:mimes:html hoon)]
|
||||
++ noun bil
|
||||
++ hoon
|
||||
^- @t
|
||||
|^ (crip (of-wall:format (wrap-lines (zing (turn bil spit-chit)))))
|
||||
::
|
||||
++ wrap-lines
|
||||
|= taz=wall
|
||||
^- wall
|
||||
?~ taz ["~"]~
|
||||
:- (weld ":~ " i.taz)
|
||||
%- snoc :_ "=="
|
||||
(turn t.taz |=(t=tape (weld " " t)))
|
||||
::
|
||||
++ spit-chit
|
||||
|= =chit
|
||||
^- wall
|
||||
?- -.chit
|
||||
%apes [":- %apes" (wrap-lines (spit-duz duz.chit))]
|
||||
%fish [":- %fish" (wrap-lines (spit-duz duz.chit))]
|
||||
==
|
||||
::
|
||||
++ spit-duz
|
||||
|= duz=(list dude:gall)
|
||||
^- wall
|
||||
(turn duz |=(=dude:gall "%{<dude>}"))
|
||||
--
|
||||
++ txt (to-wain:format hoon)
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun bill
|
||||
++ mime
|
||||
|= [=mite len=@ud tex=@]
|
||||
~_ tex
|
||||
!<(bill (slap !>(~) (ream tex)))
|
||||
--
|
||||
++ grad %noun
|
||||
--
|
1
pkg/arvo/mar/bill.hoon
Symbolic link
1
pkg/arvo/mar/bill.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/bill.hoon
|
@ -1,61 +0,0 @@
|
||||
:: blit: runtime blit structure
|
||||
::
|
||||
|_ =blit:dill
|
||||
++ grad %noun
|
||||
:: +grab: convert from
|
||||
::
|
||||
++ grab
|
||||
|%
|
||||
++ noun blit:dill
|
||||
--
|
||||
:: +grow: convert to
|
||||
::
|
||||
++ grow
|
||||
|%
|
||||
++ noun blit
|
||||
++ json
|
||||
^- ^json
|
||||
=, enjs:format
|
||||
%+ frond -.blit
|
||||
?- -.blit
|
||||
%bel b+&
|
||||
%clr b+&
|
||||
%hop (numb p.blit)
|
||||
%lin a+(turn p.blit |=(c=@c s+(tuft c)))
|
||||
%mor b+&
|
||||
%url s+p.blit
|
||||
::
|
||||
%sag
|
||||
%- pairs
|
||||
:~ 'path'^(path p.blit)
|
||||
'file'^s+(en:base64:mimes:html (as-octs:mimes:html (jam q.blit)))
|
||||
==
|
||||
::
|
||||
%sav
|
||||
%- pairs
|
||||
:~ 'path'^(path p.blit)
|
||||
'file'^s+(en:base64:mimes:html (as-octs:mimes:html q.blit))
|
||||
==
|
||||
::
|
||||
%klr
|
||||
:- %a
|
||||
%+ turn p.blit
|
||||
|= [=stye text=(list @c)]
|
||||
%- pairs
|
||||
:~ 'text'^a+(turn text |=(c=@c s+(tuft c)))
|
||||
::
|
||||
:- 'stye'
|
||||
%- pairs
|
||||
|^ :~ 'back'^(color p.q.stye)
|
||||
'fore'^(color q.q.stye)
|
||||
'deco'^a+(turn ~(tap in p.stye) |=(d=deco ?~(d ~ s+d)))
|
||||
==
|
||||
++ color
|
||||
|= =tint
|
||||
?@ tint ?~(tint ~ s+tint)
|
||||
s+(crip ((x-co:co 6) (rep 3 ~[b g r]:tint)))
|
||||
--
|
||||
==
|
||||
==
|
||||
--
|
||||
--
|
1
pkg/arvo/mar/blit.hoon
Symbolic link
1
pkg/arvo/mar/blit.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/blit.hoon
|
1
pkg/arvo/mar/docket.hoon
Symbolic link
1
pkg/arvo/mar/docket.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/docket.hoon
|
@ -1,49 +0,0 @@
|
||||
:::: /hoon/hoon/mar
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
=, eyre
|
||||
|_ own=@t
|
||||
::
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ mime `^mime`[/text/x-hoon (as-octs:mimes:html own)] :: convert to %mime
|
||||
++ elem :: convert to %html
|
||||
;div:pre(urb_codemirror "", mode "hoon"):"{(trip own)}"
|
||||
:: =+ gen-id="src-{<`@ui`(mug own)>}"
|
||||
:: ;div
|
||||
:: ;textarea(id "{gen-id}"):"{(trip own)}"
|
||||
:: ;script:"""
|
||||
:: CodeMirror.fromTextArea(
|
||||
:: window[{<gen-id>}],
|
||||
:: \{lineNumbers:true, readOnly:true}
|
||||
:: )
|
||||
:: """
|
||||
:: ==
|
||||
++ hymn
|
||||
:: ;html:(head:title:"Source" "+{elem}")
|
||||
;html
|
||||
;head
|
||||
;title:"Source"
|
||||
;script@"//cdnjs.cloudflare.com/ajax/libs/codemirror/4.3.0/codemirror.js";
|
||||
;script@"/lib/syntax/hoon.js";
|
||||
;link(rel "stylesheet", href "//cdnjs.cloudflare.com/ajax/libs/".
|
||||
"codemirror/4.3.0/codemirror.min.css");
|
||||
;link/"/lib/syntax/codemirror.css"(rel "stylesheet");
|
||||
==
|
||||
;body
|
||||
;textarea#src:"{(trip own)}"
|
||||
;script:'CodeMirror.fromTextArea(src, {lineNumbers:true, readOnly:true})'
|
||||
==
|
||||
==
|
||||
++ txt
|
||||
(to-wain:format own)
|
||||
--
|
||||
++ grab
|
||||
|% :: convert from
|
||||
++ mime |=([p=mite q=octs] q.q)
|
||||
++ noun @t :: clam from %noun
|
||||
++ txt of-wain:format
|
||||
--
|
||||
++ grad %txt
|
||||
--
|
1
pkg/arvo/mar/hoon.hoon
Symbolic link
1
pkg/arvo/mar/hoon.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/hoon.hoon
|
@ -1,15 +0,0 @@
|
||||
::
|
||||
:::: /hoon/htm/mar
|
||||
::
|
||||
/? 310
|
||||
|_ own=manx
|
||||
::
|
||||
++ grad %noun
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ noun own
|
||||
++ hymn own
|
||||
--
|
||||
++ grab |% :: convert from
|
||||
++ noun manx :: clam from %noun
|
||||
-- --
|
1
pkg/arvo/mar/htm.hoon
Symbolic link
1
pkg/arvo/mar/htm.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/htm.hoon
|
@ -1,22 +0,0 @@
|
||||
::
|
||||
:::: /hoon/html/mar
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
:::: compute
|
||||
::
|
||||
=, html
|
||||
|_ htm=@t
|
||||
++ grow :: convert to
|
||||
^?
|
||||
|% ::
|
||||
++ mime [/text/html (met 3 htm) htm] :: to %mime
|
||||
++ hymn (need (de-xml htm)) :: to %hymn
|
||||
-- ::
|
||||
++ grab ^?
|
||||
|% :: convert from
|
||||
++ noun @t :: clam from %noun
|
||||
++ mime |=([p=mite q=octs] q.q) :: retrieve form %mime
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
1
pkg/arvo/mar/html.hoon
Symbolic link
1
pkg/arvo/mar/html.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/html.hoon
|
@ -1,25 +0,0 @@
|
||||
::
|
||||
:::: /hoon/httr/mar
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
=, eyre
|
||||
=, format
|
||||
=, html
|
||||
|_ hit=httr
|
||||
++ grad %noun
|
||||
++ grow |% ++ wall (turn wain trip)
|
||||
++ wain (to-wain cord)
|
||||
++ json (need (de-json cord))
|
||||
++ cord q:octs
|
||||
++ noun hit
|
||||
++ octs
|
||||
~| hit
|
||||
?> =(2 (div p.hit 100))
|
||||
(need r.hit)
|
||||
--
|
||||
++ grab :: convert from
|
||||
|%
|
||||
++ noun httr :: clam from %noun
|
||||
--
|
||||
--
|
1
pkg/arvo/mar/httr.hoon
Symbolic link
1
pkg/arvo/mar/httr.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/httr.hoon
|
@ -1,17 +0,0 @@
|
||||
::
|
||||
:::: /hoon/hymn/mar
|
||||
::
|
||||
/? 310
|
||||
=, mimes:html
|
||||
=, html
|
||||
|_ own=manx
|
||||
::
|
||||
++ grad %noun
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ html (crip (en-xml own)) :: convert to %html
|
||||
++ mime [/text/html (as-octs html)] :: convert to %mime
|
||||
--
|
||||
++ grab |% :: convert from
|
||||
++ noun manx :: clam from %noun
|
||||
-- --
|
1
pkg/arvo/mar/hymn.hoon
Symbolic link
1
pkg/arvo/mar/hymn.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/hymn.hoon
|
@ -1,22 +0,0 @@
|
||||
::
|
||||
:::: /hoon/js/mar
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
=, eyre
|
||||
|_ mud=@
|
||||
++ grow
|
||||
|%
|
||||
++ mime [/application/javascript (as-octs:mimes:html (@t mud))]
|
||||
++ elem ;script
|
||||
;- (trip (@t mud))
|
||||
==
|
||||
++ hymn ;html:(head:"+{elem}" body)
|
||||
--
|
||||
++ grab
|
||||
|% :: convert from
|
||||
++ mime |=([p=mite q=octs] (@t q.q))
|
||||
++ noun cord :: clam from %noun
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
1
pkg/arvo/mar/js.hoon
Symbolic link
1
pkg/arvo/mar/js.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/js.hoon
|
@ -1,26 +0,0 @@
|
||||
::
|
||||
:::: /hoon/json/mar
|
||||
::
|
||||
/? 310
|
||||
::
|
||||
:::: compute
|
||||
::
|
||||
=, eyre
|
||||
=, format
|
||||
=, html
|
||||
|_ jon=json
|
||||
::
|
||||
++ grow :: convert to
|
||||
|%
|
||||
++ mime [/application/json (as-octs:mimes -:txt)] :: convert to %mime
|
||||
++ txt [(crip (en-json jon))]~
|
||||
--
|
||||
++ grab
|
||||
|% :: convert from
|
||||
++ mime |=([p=mite q=octs] (fall (rush (@t q.q) apex:de-json) *json))
|
||||
++ noun json :: clam from %noun
|
||||
++ numb numb:enjs
|
||||
++ time time:enjs
|
||||
--
|
||||
++ grad %mime
|
||||
--
|
1
pkg/arvo/mar/json.hoon
Symbolic link
1
pkg/arvo/mar/json.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/json.hoon
|
@ -1,43 +0,0 @@
|
||||
::
|
||||
/- *json-rpc
|
||||
::
|
||||
|_ res=response
|
||||
::
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun res
|
||||
--
|
||||
++ grab :: convert from
|
||||
|%
|
||||
++ noun response :: from noun
|
||||
++ httr :: from httr
|
||||
|= hit=httr:eyre
|
||||
^- response
|
||||
~| hit
|
||||
?: ?=(%2 (div p.hit 100))
|
||||
=, html
|
||||
%- json
|
||||
?~ r.hit
|
||||
a+~
|
||||
(need (de-json q:u.r.hit))
|
||||
fail+hit
|
||||
++ json :: from json
|
||||
=, dejs-soft:format
|
||||
|= a=json
|
||||
^- response
|
||||
=; dere
|
||||
=+ res=((ar dere) a)
|
||||
?~ res (need (dere a))
|
||||
[%batch u.res]
|
||||
|= a=json
|
||||
^- (unit response)
|
||||
=/ res=(unit [@t json])
|
||||
::TODO breaks when no id present
|
||||
((ot id+so result+some ~) a)
|
||||
?^ res `[%result u.res]
|
||||
~| a
|
||||
:+ ~ %error %- need
|
||||
((ot id+so error+(ot code+no message+so ~) ~) a)
|
||||
--
|
||||
--
|
1
pkg/arvo/mar/json/rpc/response.hoon
Symbolic link
1
pkg/arvo/mar/json/rpc/response.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../base-dev/mar/json/rpc/response.hoon
|
@ -1,18 +0,0 @@
|
||||
=/ weft ,[lal=@tas num=@ud] :: TODO remove after merge
|
||||
|_ kel=weft
|
||||
++ grow
|
||||
|%
|
||||
++ mime `^mime`[/text/x-kelvin (as-octs:mimes:html hoon)]
|
||||
++ noun kel
|
||||
++ hoon (crip "{<[lal num]:kel>}\0a")
|
||||
++ txt (to-wain:format hoon)
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun weft
|
||||
++ mime
|
||||
|= [=mite len=@ud tex=@]
|
||||
!<(weft (slap !>(~) (ream tex)))
|
||||
--
|
||||
++ grad %noun
|
||||
--
|
1
pkg/arvo/mar/kelvin.hoon
Symbolic link
1
pkg/arvo/mar/kelvin.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../base-dev/mar/kelvin.hoon
|
29
pkg/arvo/mar/kiln/install.hoon
Normal file
29
pkg/arvo/mar/kiln/install.hoon
Normal file
@ -0,0 +1,29 @@
|
||||
|%
|
||||
+$ install
|
||||
[local=term =ship =desk]
|
||||
--
|
||||
|_ inst=install
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun inst
|
||||
++ json
|
||||
%- pairs:enjs:format
|
||||
:~ local+s+local.inst
|
||||
desk+s+desk.inst
|
||||
ship+s+(scot %p ship.inst)
|
||||
==
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun install
|
||||
++ json
|
||||
^- $-(^json install)
|
||||
=, dejs:format
|
||||
%- ot
|
||||
:~ local+so
|
||||
ship+(su ;~(pfix sig fed:ag))
|
||||
desk+so
|
||||
==
|
||||
--
|
||||
--
|
13
pkg/arvo/mar/kiln/revive.hoon
Normal file
13
pkg/arvo/mar/kiln/revive.hoon
Normal file
@ -0,0 +1,13 @@
|
||||
|_ =desk
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun desk
|
||||
++ json s+desk
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun ^desk
|
||||
++ json so:dejs:format
|
||||
--
|
||||
--
|
13
pkg/arvo/mar/kiln/suspend.hoon
Normal file
13
pkg/arvo/mar/kiln/suspend.hoon
Normal file
@ -0,0 +1,13 @@
|
||||
|_ =desk
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun desk
|
||||
++ json s+desk
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun ^desk
|
||||
++ json so:dejs:format
|
||||
--
|
||||
--
|
13
pkg/arvo/mar/kiln/uninstall.hoon
Normal file
13
pkg/arvo/mar/kiln/uninstall.hoon
Normal file
@ -0,0 +1,13 @@
|
||||
|_ =desk
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun desk
|
||||
++ json s+desk
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun ^desk
|
||||
++ json so:dejs:format
|
||||
--
|
||||
--
|
54
pkg/arvo/mar/kiln/vats-diff.hoon
Normal file
54
pkg/arvo/mar/kiln/vats-diff.hoon
Normal file
@ -0,0 +1,54 @@
|
||||
/- hood
|
||||
|_ =diff:hood
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun diff
|
||||
++ json
|
||||
=, enjs:format
|
||||
|^
|
||||
%+ frond -.diff
|
||||
?- -.diff
|
||||
%block (block +.diff)
|
||||
?(%merge-sunk %merge-fail) (desk-arak-err +.diff)
|
||||
?(%reset %merge %suspend %revive) (desk-arak +.diff)
|
||||
==
|
||||
::
|
||||
++ block
|
||||
|= [=desk =arak:hood =weft:hood blockers=(set desk)]
|
||||
%+ merge (desk-arak desk arak)
|
||||
%- pairs
|
||||
:~ weft+(weft:enjs:hood weft)
|
||||
blockers+a+(turn ~(tap in blockers) (lead %s))
|
||||
==
|
||||
::
|
||||
++ desk-arak
|
||||
|= [=desk =arak:hood]
|
||||
%- pairs
|
||||
:~ desk+s+desk
|
||||
arak+(arak:enjs:hood arak)
|
||||
==
|
||||
::
|
||||
++ desk-arak-err
|
||||
|= [=desk =arak:hood =tang]
|
||||
%+ merge (desk-arak desk arak)
|
||||
%+ frond %tang
|
||||
a+(turn tang tank)
|
||||
::
|
||||
++ merge
|
||||
|= [a=^json b=^json]
|
||||
^- ^json
|
||||
?> &(?=(%o -.a) ?=(%o -.b))
|
||||
o+(~(uni by p.a) p.b)
|
||||
--
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun diff:hood
|
||||
--
|
||||
--
|
||||
|
||||
|
||||
|
||||
|
||||
|
20
pkg/arvo/mar/kiln/vats.hoon
Normal file
20
pkg/arvo/mar/kiln/vats.hoon
Normal file
@ -0,0 +1,20 @@
|
||||
/- *hood
|
||||
|_ vats=(list vat)
|
||||
++ grow
|
||||
|%
|
||||
++ noun vats
|
||||
++ json (vats:enjs vats)
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun (list vat)
|
||||
--
|
||||
--
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
/- *language-server
|
||||
/+ lsp-json=language-server-json
|
||||
|_ not=all:notification
|
||||
++ grad %noun
|
||||
++ grab
|
||||
|%
|
||||
++ noun all:notification
|
||||
++ json
|
||||
|= jon=^json
|
||||
(notification:dejs:lsp-json jon)
|
||||
--
|
||||
++ grow
|
||||
|%
|
||||
++ noun not
|
||||
++ json
|
||||
(notification:enjs:lsp-json not)
|
||||
--
|
||||
--
|
1
pkg/arvo/mar/language-server/rpc/notification.hoon
Symbolic link
1
pkg/arvo/mar/language-server/rpc/notification.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../base-dev/mar/language-server/rpc/notification.hoon
|
@ -1,16 +0,0 @@
|
||||
/- *language-server
|
||||
/+ lsp-json=language-server-json
|
||||
|_ req=all:request
|
||||
++ grad %noun
|
||||
++ grow
|
||||
|%
|
||||
++ noun req
|
||||
--
|
||||
++ grab
|
||||
|%
|
||||
++ noun all:request
|
||||
++ json
|
||||
|= jon=^json
|
||||
(request:dejs:lsp-json jon)
|
||||
--
|
||||
--
|
1
pkg/arvo/mar/language-server/rpc/request.hoon
Symbolic link
1
pkg/arvo/mar/language-server/rpc/request.hoon
Symbolic link
@ -0,0 +1 @@
|
||||
../../../../base-dev/mar/language-server/rpc/request.hoon
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user