Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions desk/app/near-handler.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
accs=(set acc)
==
::
+$ card card:agent:gall
+$ card $+(card card:agent:gall)
--
::
%- agent:dbug
Expand Down Expand Up @@ -55,7 +55,11 @@
=^ cards state abet:(watch:hc path)
[cards this]
::
++ on-agent on-agent:def
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
=^ cards state abet:(agent:hc wire sign)
[cards this]
++ on-arvo on-arvo:def
++ on-fail on-fail:def
++ on-leave on-leave:def
Expand Down Expand Up @@ -89,9 +93,14 @@
%add
=. accs (~(put in accs) +.act)
give-accs
::
%del
=. accs (~(del in accs) +.act)
give-accs
::
%poke
%- emit
[%pass /poke-to/[dude.act] %agent [our.bowl dude.act] %poke-as mark.act [%json !>((need json.act))]]
==
==
::
Expand All @@ -112,6 +121,17 @@
give-accs
==
::
++ agent
|= [=wire =sign:agent:gall]
^+ that
?+ wire ~|(bad-agent-wire+wire !!)
[%poke-to * ~]
?. ?=(%poke-ack -.sign) that
?~ p.sign that
%- (slog 'Failed to poke' `@t`(scot %tas -.+.wire) ~)
that
==
::
++ give-accs
%- emit
[%give %fact ~[/accs] %near-handler-update !>([%accs accs])]
Expand Down
9 changes: 9 additions & 0 deletions desk/desk.docket-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
:~ title+'Near'
info+''
color+0x9e.9191
base+'near'
version+[0 0 1]
glob-ames+[~zod 0v0]
website+'https://github.com/urbit/NEAR'
license+'MIT'
==
7 changes: 4 additions & 3 deletions desk/gen/acc.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
:- %say
:: :near-handler +near-handler!acc %add 0x0
|= $: [now=@da eny=@uvJ bec=beak]
$: act=?(%add %del)
$: act=?(%add %del %poke)
acc=@uxH
~
==
~
==
?- act
%del [%action [%del acc]]
%add [%action [%add acc]]
%del [%near-handler-action [%del acc]]
%add [%near-handler-action [%add acc]]
%poke [%near-handler-action [%poke-to [%test %test-action (need (de:json:html '{"poke":1}'))]]]
==
223 changes: 223 additions & 0 deletions desk/lib/docket.hoon
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
/- *docket
|%
::
++ mime
|%
+$ draft
$: title=(unit @t)
info=(unit @t)
color=(unit @ux)
glob-http=(unit [=url hash=@uvH])
glob-ames=(unit [=ship hash=@uvH])
base=(unit term)
site=(unit path)
image=(unit url)
version=(unit version)
website=(unit url)
license=(unit cord)
==
::
++ finalize
|= =draft
^- (unit docket)
?~ title.draft ~
?~ info.draft ~
?~ color.draft ~
?~ version.draft ~
?~ website.draft ~
?~ license.draft ~
=/ href=(unit href)
?^ site.draft `[%site u.site.draft]
?~ base.draft ~
?^ glob-http.draft
`[%glob u.base hash.u.glob-http %http url.u.glob-http]:draft
?~ glob-ames.draft
~
`[%glob u.base hash.u.glob-ames %ames ship.u.glob-ames]:draft
?~ href ~
=, draft
:- ~
:* %1
u.title
u.info
u.color
u.href
image
u.version
u.website
u.license
==
::
++ from-clauses
=| =draft
|= cls=(list clause)
^- (unit docket)
=* loop $
?~ cls (finalize draft)
=* clause i.cls
=. draft
?- -.clause
%title draft(title `title.clause)
%info draft(info `info.clause)
%color draft(color `color.clause)
%glob-http draft(glob-http `[url hash]:clause)
%glob-ames draft(glob-ames `[ship hash]:clause)
%base draft(base `base.clause)
%site draft(site `path.clause)
%image draft(image `url.clause)
%version draft(version `version.clause)
%website draft(website `website.clause)
%license draft(license `license.clause)
==
loop(cls t.cls)
::
++ to-clauses
|= d=docket
^- (list clause)
%- zing
:~ :~ title+title.d
info+info.d
color+color.d
version+version.d
website+website.d
license+license.d
==
?~ image.d ~ ~[image+u.image.d]
?: ?=(%site -.href.d) ~[site+path.href.d]
=/ ref=glob-reference glob-reference.href.d
:~ base+base.href.d
?- -.location.ref
%http [%glob-http url.location.ref hash.ref]
%ames [%glob-ames ship.location.ref hash.ref]
== == ==
::
++ spit-clause
|= =clause
^- tape
%+ weld " {(trip -.clause)}+"
?+ -.clause "'{(trip +.clause)}'"
%color (scow %ux color.clause)
%site (spud path.clause)
::
%glob-http
"['{(trip url.clause)}' {(scow %uv hash.clause)}]"
::
%glob-ames
"[{(scow %p ship.clause)} {(scow %uv hash.clause)}]"
::
%version
=, version.clause
"[{(scow %ud major)} {(scow %ud minor)} {(scow %ud patch)}]"
==
::
++ spit-docket
|= dock=docket
^- tape
;: welp
":~\0a"
`tape`(zing (join "\0a" (turn (to-clauses dock) spit-clause)))
"\0a=="
==
--
::
++ enjs
=, enjs:format
|%
::
++ charge-update
|= u=^charge-update
^- json
%+ frond -.u
^- json
?- -.u
%del-charge s+desk.u
::
%initial
%- pairs
%+ turn ~(tap by initial.u)
|=([=desk c=^charge] [desk (charge c)])
::
%add-charge
%- pairs
:~ desk+s+desk.u
charge+(charge charge.u)
==
==
::
++ num
|= a=@u
^- ^tape
=/ p=json (numb a)
?> ?=(%n -.p)
(trip p.p)
::
++ version
|= v=^version
^- json
:- %s
%- crip
"{(num major.v)}.{(num minor.v)}.{(num patch.v)}"
::
++ merge
|= [a=json b=json]
^- json
?> &(?=(%o -.a) ?=(%o -.b))
[%o (~(uni by p.a) p.b)]
::
++ href
|= h=^href
%+ frond -.h
?- -.h
%site s+(spat path.h)
%glob
%- pairs
:~ base+s+base.h
glob-reference+(glob-reference glob-reference.h)
==
==
::
++ glob-reference
|= ref=^glob-reference
%- pairs
:~ hash+s+(scot %uv hash.ref)
location+(glob-location location.ref)
==
::
++ glob-location
|= loc=^glob-location
^- json
%+ frond -.loc
?- -.loc
%http s+url.loc
%ames s+(scot %p ship.loc)
==
::
++ charge
|= c=^charge
%+ merge (docket docket.c)
%- pairs
:~ chad+(chad chad.c)
==
::
++ docket
|= d=^docket
^- json
%- pairs
:~ title+s+title.d
info+s+info.d
color+s+(scot %ux color.d)
href+(href href.d)
image+?~(image.d ~ s+u.image.d)
version+(version version.d)
license+s+license.d
website+s+website.d
==
::
++ chad
|= c=^chad
%+ frond -.c
?+ -.c ~
%hung s+err.c
==
--
--
22 changes: 22 additions & 0 deletions desk/lib/near-handler.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,26 @@
|=(=acc `@t`(scot %ux acc))
==
--
::
++ dejs
=, dejs:format
|%
++ act
|= =json
^- action
%. json
%- of
:~ [%add (se %ux)]
[%del (se %ux)]
[%poke poke]
==
::
:: ::{'poke':{'agent':'test', 'mark':'test-action', 'data':{'poke':1}}}
++ poke
%- ot
:~ [%agent (se %tas)]
[%mark (se %tas)]
[%data some]
==
--
--
25 changes: 25 additions & 0 deletions desk/mar/docket-0.hoon
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/+ dock=docket
|_ =docket:dock
++ grow
|%
++ mime
^- ^mime
[/text/x-docket (as-octt:mimes:html (spit-docket:mime:dock docket))]
++ noun docket
++ json (docket:enjs:dock docket)
--
++ grab
|%
::
++ mime
|= [=mite len=@ud tex=@]
^- docket:dock
%- need
%- from-clauses:mime:dock
!<((list clause:dock) (slap !>(~) (ream tex)))

::
++ noun docket:dock
--
++ grad %noun
--
2 changes: 1 addition & 1 deletion desk/mar/near-handler/action.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
++ grab
|%
++ noun action
::++ json dejs
++ json act:dejs
--
++ grow
|%
Expand Down
Loading