diff --git a/rpc-desk/app/rpc-provider.hoon b/rpc-desk/app/rpc-provider.hoon new file mode 100644 index 000000000..0462b8f63 --- /dev/null +++ b/rpc-desk/app/rpc-provider.hoon @@ -0,0 +1,98 @@ +/- near-rpc +/+ dbug, default-agent +:: +|% ++$ versioned-state + $% state-0 + == ++$ state-0 [%0 ~] ++$ card $+(card card:agent:gall) +-- +:: +%- agent:dbug +=| state-0 +=* state - +:: +^- agent:gall +:: +=< +|_ =bowl:gall ++* this . + def ~(. (default-agent this %|) bowl) + hc ~(. +> [bowl ~]) +++ on-init + ^- (quip card _this) + =^ cards state abet:init:hc + [cards this] +:: +++ on-save + ^- vase + !>(state) +:: +++ on-load + |= =vase + ^- (quip card _this) + =^ cards state abet:(load:hc vase) + [cards this] +:: +++ on-poke + |= [=mark =vase] + ^- (quip card _this) + =^ cards state abet:(poke:hc mark vase) + [cards this] +:: +++ on-peek + |= =path + ^- (unit (unit cage)) + [~ ~] +:: +++ on-watch + |= =path + ^- (quip card _this) + `this +:: +++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card _this) + `this +:: +++ on-arvo on-arvo:def +++ on-fail on-fail:def +++ on-leave on-leave:def +-- +|_ [=bowl:gall deck=(list card)] ++* that . +++ emit |=(=card that(deck [card deck])) +++ emil |=(lac=(list card) that(deck (welp lac deck))) +++ abet ^-((quip card _state) [(flop deck) state]) +:: +++ from-self =(our src):bowl +:: +++ init + ^+ that + that +:: +++ load + |= vaz=vase + ^+ that + ?> ?=([%0 *] q.vaz) + that(state !<(state-0 vaz)) +:: +++ poke + |= [=mark =vase] + ^+ that + ?+ mark that + %near-rpc-ask + =+ !<(act=ask:near-rpc vase) + ?- -.act + %request + ~& >> "Got request" + %- emit + :* %pass /response + %agent [src.bowl %rpc-requester] + %poke %near-rpc-response + !>(`response:near-rpc`[%response ~]) + == + == + == +-- \ No newline at end of file diff --git a/rpc-desk/app/rpc-requester.hoon b/rpc-desk/app/rpc-requester.hoon new file mode 100644 index 000000000..f64600541 --- /dev/null +++ b/rpc-desk/app/rpc-requester.hoon @@ -0,0 +1,110 @@ +/- near-rpc +/+ dbug, default-agent +:: +|% ++$ versioned-state + $% state-0 + == ++$ state-0 [%0 =provider:near-rpc queue=(set request:near-rpc)] ++$ card $+(card card:agent:gall) +-- +:: +%- agent:dbug +=| state-0 +=* state - +:: +^- agent:gall +:: +=< +|_ =bowl:gall ++* this . + def ~(. (default-agent this %|) bowl) + hc ~(. +> [bowl ~]) +++ on-init + ^- (quip card _this) + =^ cards state abet:init:hc + [cards this] +:: +++ on-save + ^- vase + !>(state) +:: +++ on-load + |= =vase + ^- (quip card _this) + =^ cards state abet:(load:hc vase) + [cards this] +:: +++ on-poke + |= [=mark =vase] + ^- (quip card _this) + =^ cards state abet:(poke:hc mark vase) + [cards this] +:: +++ on-peek + |= =path + ^- (unit (unit cage)) + [~ ~] +:: +++ on-watch + |= =path + ^- (quip card _this) + `this +:: +++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card _this) + `this +:: +++ on-arvo on-arvo:def +++ on-fail on-fail:def +++ on-leave on-leave:def +-- +|_ [=bowl:gall deck=(list card)] ++* that . +++ emit |=(=card that(deck [card deck])) +++ emil |=(lac=(list card) that(deck (welp lac deck))) +++ abet ^-((quip card _state) [(flop deck) state]) +:: +++ from-self =(our src):bowl +:: +++ init + ^+ that + =. provider our.bowl ::we're our own provider to start (for testing) + that +:: +++ load + |= vaz=vase + ^+ that + ?> ?=([%0 *] q.vaz) + that(state !<(state-0 vaz)) +:: +++ poke + |= [=mark =vase] + ^+ that + ?+ mark that + %near-rpc-response + ?> =(src.bowl provider) + ~& > 'Got response' + that + :: + %near-rpc-action + ?> from-self + =+ !<(act=action:near-rpc vase) + ?- -.act + %change-provider + =. provider provider.act + that + :: + %send-request + =/ req [now.bowl content.act] + =. queue (~(put in queue) req) + %- emit + :* %pass /request + %agent [provider %rpc-provider] + %poke %near-rpc-ask + !>(`ask:near-rpc`[%request req]) + == + == + == +-- \ No newline at end of file diff --git a/rpc-desk/desk.bill b/rpc-desk/desk.bill new file mode 100644 index 000000000..031aaeee8 --- /dev/null +++ b/rpc-desk/desk.bill @@ -0,0 +1,3 @@ +:~ %rpc-provider + %rpc-requester +== diff --git a/rpc-desk/lib/dbug.hoon b/rpc-desk/lib/dbug.hoon new file mode 100644 index 000000000..ce98619e8 --- /dev/null +++ b/rpc-desk/lib/dbug.hoon @@ -0,0 +1,155 @@ +:: 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] + -- +-- diff --git a/rpc-desk/lib/default-agent.hoon b/rpc-desk/lib/default-agent.hoon new file mode 100644 index 000000000..319bf9524 --- /dev/null +++ b/rpc-desk/lib/default-agent.hoon @@ -0,0 +1,69 @@ +/+ 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 {} with mark {}" + !! +:: +++ on-watch + |= =path + ~| "unexpected subscription to {} on path {}" + !! +:: +++ on-leave + |= path + `agent +:: +++ on-peek + |= =path + ~| "unexpected scry into {} on path {}" + !! +:: +++ on-agent + |= [=wire =sign:agent:gall] + ^- (quip card:agent:gall _agent) + ?- -.sign + %poke-ack + ?~ p.sign + `agent + %- (slog leaf+"poke failed from {} on wire {}" u.p.sign) + `agent + :: + %watch-ack + ?~ p.sign + `agent + =/ =tank leaf+"subscribe failed from {} on wire {}" + %- (slog tank u.p.sign) + `agent + :: + %kick `agent + %fact + ~| "unexpected subscription update to {} on wire {}" + ~| "with mark {}" + !! + == +:: +++ on-arvo + |= [=wire =sign-arvo] + ~| "unexpected system response {<-.sign-arvo>} to {} on wire {}" + !! +:: +++ on-fail + |= [=term =tang] + %- (slog leaf+"error in {}" >term< tang) + `agent +-- diff --git a/rpc-desk/lib/etch.hoon b/rpc-desk/lib/etch.hoon new file mode 100644 index 000000000..e4991709a --- /dev/null +++ b/rpc-desk/lib/etch.hoon @@ -0,0 +1,182 @@ + :: /lib/etch.hoon +:::: ~littel-wolfur, simplified by ~litlep-nibbyt +:: Version ~2023.6.18 +:: +/+ *mip +|% +:: +++ show-json + |= =vase + (en:json:html (en-vase vase)) +:: +++ en-vase + |= [typ=type arg=*] + ^- json + ?- typ + %void !! + %noun (en-noun arg) + :: + [%atom *] + (en-dime p.typ ;;(@ arg)) + :: + [%cell *] + =/ hed=json $(typ p.typ, arg -.arg) + =/ tal=json $(typ q.typ, arg +.arg) + :: + ?: ?& !!?=([%o ^] hed) + !!?=([%o ^] tal) + == + [%o (~(uni by ?>(?=(%o -.hed) p.hed)) ?>(?=(%o -.tal) p.tal))] + :: + ?~ hed tal + ?: &(?=([%s @t] hed) ?=([%s @t] tal)) + [%a hed tal ~] + ?: &(?=([%s @t] hed) !?=([%s @t] tal) !?=([%a *] tal) !=(~ tal)) + [%a hed tal ~] + ?: &(?=([%a *] hed) ?=([%a *] tal)) + [%a (weld p.hed p.tal)] + ?: ?=([%a *] tal) + [%a hed p.tal] + :: + ?~ tal [%a hed ~] + [%a hed tal ~] + :: + [%core *] !! + :: + [%face *] [%o (malt `(list [@t json])`[;;(@t p.typ) $(typ q.typ)]~)] + :: + [%fork *] + =/ tyz=(list type) (turn ~(tap in p.typ) peel) + =. tyz + %- zing + %+ turn tyz + |= tep=type + ^- (list type) + ?:(?=(%fork -.tep) ~(tap in p.tep) ~[tep]) + :: + ?: =(1 (lent tyz)) + $(typ (head tyz)) + :: $? + :: + ?: (levy tyz |=([t=type] ?=(%atom -.t))) + =/ aura + :: + =/ hid (head tyz) + ?>(?=([%atom @ *] hid) p.hid) + ?> (levy tyz |=([t=type] ?>(?=([%atom * *] t) =(aura p.t)))) + (en-dime aura ;;(@ arg)) + :: $% + :: + ?: (levy tyz |=([t=type] ?=([%cell [%atom * ^] *] t))) + =/ aura + =/ hid (head tyz) + ?>(?=([%cell [%atom @ ^] *] hid) p.p.hid) + :: + =/ hid (head tyz) + =/ val ;;(@ -.arg) + ?> ((sane aura) val) + :: + =/ tag ?:(?=(?(%t %ta %tas) aura) val (scot aura val)) + =/ tin=type + |- + ^- type + ?~ tyz !! + =/ ty=type i.tyz + ?> ?=([%cell [%atom @ ^] *] ty) + ?: =(val u.q.p.ty) q.ty + $(tyz t.tyz) + %+ frond:enjs:format tag $(typ tin, arg +.arg) + :: non-$% fork of cells + :: + ?: (levy tyz |=([t=type] ?=([%cell *] t))) + ~| cell-fork/tyz + ~! tyz !! + :: $@ + :: + =/ [atoms=(list type) cells=(list type)] + (skid tyz |=([t=type] ?=(%atom -.t))) + ?@ arg + $(p.typ (sy atoms)) + $(p.typ (sy cells)) + :: + [%hint *] $(typ q.typ) + [%hold *] $(typ (~(play ut p.typ) q.typ)) + == +:: +peel: recursively unwrap type +:: +++ peel + |= [typ=type] + =| [cos=(unit term)] + ^- type + |- =* loop $ + ?+ typ typ + [%atom *] ?~ cos typ ;;(type [%face u.cos typ]) + :: + %void !! + :: + [%cell *] + ?^ cos + =/ coll [%cell loop(typ p.typ) loop(typ q.typ)] + ;;(type [%face u.cos coll]) + [%cell loop(typ p.typ) loop(typ q.typ)] + :: + [%face *] + ?~ cos q.typ + ?: =(-.q.typ %hold) loop(typ q.typ) + loop(typ q.typ, cos ~) + :: + [%hint *] + =/ =note q.p.typ + ?+ -.note loop(typ q.typ) + %made + ?^ q.note loop(typ q.typ) + :: disable for now, too slow + loop(typ q.typ, cos ~) + == + :: + [%hold *] loop(typ (~(play ut p.typ) q.typ)) + == +:: +++ en-noun + |= arg=* + ^- json + ?@ arg + %+ frond:enjs:format ;;(@t arg) ~ + [%a ~[$(arg -.arg) $(arg +.arg)]] +:: +++ en-dime + |= [aura=@tas dat=@] + ^- json + ?+ aura $(aura %ud) + %c !! + :: + %$ $(aura %ui) + :: + %da [%s (scot %da dat)] + :: [%n (time:enjs:format dat)] + :: + %dr [%s (scot %dr dat)] + :: + %f [%b ;;(? dat)] + :: + %n ~ + :: + %p [%s (scot %p dat)] + :: + %q [%s (scot %q dat)] + :: + ?(%rh %rq %rd %rs) [%s (scot %rs dat)] + :: + %s [%s dat] + :: + ?(%t %ta %tas) [%s dat] + :: + ?(%ub %uc) (numb:enjs:format dat) + :: + %ux [%s (scot %ux dat)] + %uv [%s (scot %uv dat)] + :: + %ui [%n `@t`(rsh [3 2] (scot %ui dat))] + %ud [%n (scot %ud dat)] + == + -- diff --git a/rpc-desk/lib/mip.hoon b/rpc-desk/lib/mip.hoon new file mode 100644 index 000000000..322a4c85f --- /dev/null +++ b/rpc-desk/lib/mip.hoon @@ -0,0 +1,55 @@ +|% +++ mip :: map of maps + |$ [kex key value] + (map kex (map key value)) +:: +++ bi :: mip engine + =| a=(map * (map)) + |@ + ++ del + |* [b=* c=*] + =+ d=(~(gut by a) b ~) + =+ e=(~(del by d) c) + ?~ e + (~(del by a) b) + (~(put by a) b e) + :: + ++ get + |* [b=* c=*] + => .(b `_?>(?=(^ a) p.n.a)`b, c `_?>(?=(^ a) ?>(?=(^ q.n.a) p.n.q.n.a))`c) + ^- (unit _?>(?=(^ a) ?>(?=(^ q.n.a) q.n.q.n.a))) + (~(get by (~(gut by a) b ~)) c) + :: + ++ got + |* [b=* c=*] + (need (get b c)) + :: + ++ gut + |* [b=* c=* d=*] + (~(gut by (~(gut by a) b ~)) c d) + :: + ++ has + |* [b=* c=*] + !=(~ (get b c)) + :: + ++ key + |* b=* + ~(key by (~(gut by a) b ~)) + :: + ++ put + |* [b=* c=* d=*] + %+ ~(put by a) b + %. [c d] + %~ put by + (~(gut by a) b ~) + :: + ++ tap + ::NOTE naive turn-based implementation find-errors ): + =< $ + =+ b=`_?>(?=(^ a) *(list [x=_p.n.a _?>(?=(^ q.n.a) [y=p v=q]:n.q.n.a)]))`~ + |. ^+ b + ?~ a + b + $(a r.a, b (welp (turn ~(tap by q.n.a) (lead p.n.a)) $(a l.a))) + -- +-- diff --git a/rpc-desk/lib/skeleton.hoon b/rpc-desk/lib/skeleton.hoon new file mode 100644 index 000000000..982c371b8 --- /dev/null +++ b/rpc-desk/lib/skeleton.hoon @@ -0,0 +1,51 @@ +:: 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) + !! +-- diff --git a/rpc-desk/mar/bill.hoon b/rpc-desk/mar/bill.hoon new file mode 100644 index 000000000..76cef343a --- /dev/null +++ b/rpc-desk/mar/bill.hoon @@ -0,0 +1,34 @@ +|_ bil=(list dude:gall) +++ grow + |% + ++ mime `^mime`[/text/x-bill (as-octs:mimes:html hoon)] + ++ noun bil + ++ hoon + ^- @t + |^ (crip (of-wall:format (wrap-lines (spit-duz bil)))) + :: + ++ wrap-lines + |= taz=wall + ^- wall + ?~ taz ["~"]~ + :- (weld ":~ " i.taz) + %- snoc :_ "==" + (turn t.taz |=(t=tape (weld " " t))) + :: + ++ spit-duz + |= duz=(list dude:gall) + ^- wall + (turn duz |=(=dude:gall ['%' (trip dude)])) + -- + ++ txt (to-wain:format hoon) + -- +++ grab + |% + ++ noun (list dude:gall) + ++ mime + |= [=mite len=@ud tex=@] + ~_ tex + !<((list dude:gall) (slap !>(~) (ream tex))) + -- +++ grad %noun +-- diff --git a/rpc-desk/mar/hoon.hoon b/rpc-desk/mar/hoon.hoon new file mode 100644 index 000000000..428e1056d --- /dev/null +++ b/rpc-desk/mar/hoon.hoon @@ -0,0 +1,36 @@ +:::: /hoon/hoon/mar + :: +/? 310 +:: +=, eyre +|_ own=@t +:: +++ grow :: convert to + |% + ++ mime `^mime`[/text/x-hoon (as-octs:mimes:html own)] :: convert to %mime + ++ hymn + ;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 +-- diff --git a/rpc-desk/mar/json.hoon b/rpc-desk/mar/json.hoon new file mode 100644 index 000000000..7d6fcbf89 --- /dev/null +++ b/rpc-desk/mar/json.hoon @@ -0,0 +1,26 @@ +:: +:::: /hoon/json/mar + :: +/? 310 + :: +:::: compute + :: +=, eyre +=, format +=, html +|_ jon=^json +:: +++ grow :: convert to + |% + ++ mime [/application/json (as-octs:mimes -:txt)] :: convert to %mime + ++ txt [(en:json jon)]~ + -- +++ grab + |% :: convert from + ++ mime |=([p=mite q=octs] (fall (de:json (@t q.q)) *^json)) + ++ noun ^json :: clam from %noun + ++ numb numb:enjs + ++ time time:enjs + -- +++ grad %mime +-- diff --git a/rpc-desk/mar/kelvin.hoon b/rpc-desk/mar/kelvin.hoon new file mode 100644 index 000000000..7f1b409cb --- /dev/null +++ b/rpc-desk/mar/kelvin.hoon @@ -0,0 +1,28 @@ +|_ kal=waft:clay +++ grow + |% + ++ mime `^mime`[/text/x-kelvin (as-octs:mimes:html hoon)] + ++ noun kal + ++ hoon + %+ rap 3 + %+ turn + %+ sort + ~(tap in (waft-to-wefts:clay kal)) + |= [a=weft b=weft] + ?: =(lal.a lal.b) + (gte num.a num.b) + (gte lal.a lal.b) + |= =weft + (rap 3 '[%' (scot %tas lal.weft) ' ' (scot %ud num.weft) ']\0a' ~) + :: + ++ txt (to-wain:format hoon) + -- +++ grab + |% + ++ noun waft:clay + ++ mime + |= [=mite len=@ud tex=@] + (cord-to-waft:clay tex) + -- +++ grad %noun +-- diff --git a/rpc-desk/mar/mime.hoon b/rpc-desk/mar/mime.hoon new file mode 100644 index 000000000..83b4daeb5 --- /dev/null +++ b/rpc-desk/mar/mime.hoon @@ -0,0 +1,32 @@ +:: +:::: /hoon/mime/mar + :: +/? 310 +:: +|_ own=mime +++ grow + ^? + |% + ++ jam `@`q.q.own + -- +:: +++ grab :: convert from + ^? + |% + ++ noun mime :: clam from %noun + ++ tape + |=(a=_"" [/application/x-urb-unknown (as-octt:mimes:html a)]) + -- +++ grad + ^? + |% + ++ form %mime + ++ diff |=(mime +<) + ++ pact |=(mime +<) + ++ join |=([mime mime] `(unit mime)`~) + ++ mash + |= [[ship desk mime] [ship desk mime]] + ^- mime + ~|(%mime-mash !!) + -- +-- diff --git a/rpc-desk/mar/near-rpc/action.hoon b/rpc-desk/mar/near-rpc/action.hoon new file mode 100644 index 000000000..47613737f --- /dev/null +++ b/rpc-desk/mar/near-rpc/action.hoon @@ -0,0 +1,12 @@ +/- near-rpc +|_ act=action:near-rpc +++ grad %noun +++ grow + |% + ++ noun act + -- +++ grab + |% + ++ noun action:near-rpc + -- +-- \ No newline at end of file diff --git a/rpc-desk/mar/near-rpc/ask.hoon b/rpc-desk/mar/near-rpc/ask.hoon new file mode 100644 index 000000000..fe5a84a8d --- /dev/null +++ b/rpc-desk/mar/near-rpc/ask.hoon @@ -0,0 +1,12 @@ +/- near-rpc +|_ req=request:near-rpc +++ grad %noun +++ grow + |% + ++ noun req + -- +++ grab + |% + ++ noun request:near-rpc + -- +-- \ No newline at end of file diff --git a/rpc-desk/mar/near-rpc/response.hoon b/rpc-desk/mar/near-rpc/response.hoon new file mode 100644 index 000000000..919b25f52 --- /dev/null +++ b/rpc-desk/mar/near-rpc/response.hoon @@ -0,0 +1,12 @@ +/- near-rpc +|_ res=response:near-rpc +++ grad %noun +++ grow + |% + ++ noun res + -- +++ grab + |% + ++ noun response:near-rpc + -- +-- \ No newline at end of file diff --git a/rpc-desk/mar/noun.hoon b/rpc-desk/mar/noun.hoon new file mode 100644 index 000000000..ff5443ec4 --- /dev/null +++ b/rpc-desk/mar/noun.hoon @@ -0,0 +1,22 @@ +:: +:::: /hoon/noun/mar + :: +/? 310 +!: +:::: A minimal noun mark +|_ non=* +++ grab |% + ++ noun * + -- +++ grow |% + ++ mime [/application/x-urb-jam (as-octs:mimes:html (jam non))] + -- +++ grad + |% + ++ form %noun + ++ diff |=(* +<) + ++ pact |=(* +<) + ++ join |=([* *] *(unit *)) + ++ mash |=([[ship desk *] [ship desk *]] `*`~|(%noun-mash !!)) + -- +-- diff --git a/rpc-desk/mar/txt.hoon b/rpc-desk/mar/txt.hoon new file mode 100644 index 000000000..982dce973 --- /dev/null +++ b/rpc-desk/mar/txt.hoon @@ -0,0 +1,274 @@ +:: +:::: /hoon/txt/mar + :: +/? 310 +:: +=, clay +=, differ +=, format +=, mimes:html +|_ txt=wain +:: +++ grab :: convert from + |% + ++ mime |=((pair mite octs) (to-wain q.q)) + ++ noun wain :: clam from %noun + -- +++ grow + => v=. + |% + ++ mime => v [/text/plain (as-octs (of-wain txt))] + -- +++ grad + |% + ++ form %txt-diff + ++ diff + |= tyt=wain + ^- (urge cord) + (lusk txt tyt (loss txt tyt)) + :: + ++ pact + |= dif=(urge cord) + ~| [%pacting dif] + ^- wain + (lurk txt dif) + :: + ++ join + |= [ali=(urge cord) bob=(urge cord)] + ^- (unit (urge cord)) + |^ + =. ali (clean ali) + =. bob (clean bob) + |- ^- (unit (urge cord)) + ?~ ali `bob + ?~ bob `ali + ?- -.i.ali + %& + ?- -.i.bob + %& + ?: =(p.i.ali p.i.bob) + %+ bind $(ali t.ali, bob t.bob) + |=(cud=(urge cord) [i.ali cud]) + ?: (gth p.i.ali p.i.bob) + %+ bind $(p.i.ali (sub p.i.ali p.i.bob), bob t.bob) + |=(cud=(urge cord) [i.bob cud]) + %+ bind $(ali t.ali, p.i.bob (sub p.i.bob p.i.ali)) + |=(cud=(urge cord) [i.ali cud]) + :: + %| + ?: =(p.i.ali (lent p.i.bob)) + %+ bind $(ali t.ali, bob t.bob) + |=(cud=(urge cord) [i.bob cud]) + ?: (gth p.i.ali (lent p.i.bob)) + %+ bind $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob) + |=(cud=(urge cord) [i.bob cud]) + ~ + == + :: + %| + ?- -.i.bob + %| + ?. =(i.ali i.bob) + ~ + %+ bind $(ali t.ali, bob t.bob) + |=(cud=(urge cord) [i.ali cud]) + :: + %& + ?: =(p.i.bob (lent p.i.ali)) + %+ bind $(ali t.ali, bob t.bob) + |=(cud=(urge cord) [i.ali cud]) + ?: (gth p.i.bob (lent p.i.ali)) + %+ bind $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali))) + |=(cud=(urge cord) [i.ali cud]) + ~ + == + == + ++ clean :: clean + |= wig=(urge cord) + ^- (urge cord) + ?~ wig ~ + ?~ t.wig wig + ?: ?=(%& -.i.wig) + ?: ?=(%& -.i.t.wig) + $(wig [[%& (add p.i.wig p.i.t.wig)] t.t.wig]) + [i.wig $(wig t.wig)] + ?: ?=(%| -.i.t.wig) + $(wig [[%| (welp p.i.wig p.i.t.wig) (welp q.i.wig q.i.t.wig)] t.t.wig]) + [i.wig $(wig t.wig)] + -- + :: + ++ mash + |= $: [als=ship ald=desk ali=(urge cord)] + [bos=ship bod=desk bob=(urge cord)] + == + ^- (urge cord) + |^ + =. ali (clean ali) + =. bob (clean bob) + |- ^- (urge cord) + ?~ ali bob + ?~ bob ali + ?- -.i.ali + %& + ?- -.i.bob + %& + ?: =(p.i.ali p.i.bob) + [i.ali $(ali t.ali, bob t.bob)] + ?: (gth p.i.ali p.i.bob) + [i.bob $(p.i.ali (sub p.i.ali p.i.bob), bob t.bob)] + [i.ali $(ali t.ali, p.i.bob (sub p.i.bob p.i.ali))] + :: + %| + ?: =(p.i.ali (lent p.i.bob)) + [i.bob $(ali t.ali, bob t.bob)] + ?: (gth p.i.ali (lent p.i.bob)) + [i.bob $(p.i.ali (sub p.i.ali (lent p.i.bob)), bob t.bob)] + =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)] + (resolve ali bob) + [fic $(ali ali, bob bob)] + :: ~ :: here, alice is good for a while, but not for the whole + == :: length of bob's changes + :: + %| + ?- -.i.bob + %| + =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)] + (resolve ali bob) + [fic $(ali ali, bob bob)] + :: + %& + ?: =(p.i.bob (lent p.i.ali)) + [i.ali $(ali t.ali, bob t.bob)] + ?: (gth p.i.bob (lent p.i.ali)) + [i.ali $(ali t.ali, p.i.bob (sub p.i.bob (lent p.i.ali)))] + =/ [fic=(unce cord) ali=(urge cord) bob=(urge cord)] + (resolve ali bob) + [fic $(ali ali, bob bob)] + == + == + :: + ++ annotate :: annotate conflict + |= $: ali=(list @t) + bob=(list @t) + bas=(list @t) + == + ^- (list @t) + %- zing + ^- (list (list @t)) + %- flop + ^- (list (list @t)) + :- :_ ~ + %^ cat 3 '<<<<<<<<<<<<' + %^ cat 3 ' ' + %^ cat 3 `@t`(scot %p bos) + %^ cat 3 '/' + bod + + :- bob + :- ~['------------'] + :- bas + :- ~['++++++++++++'] + :- ali + :- :_ ~ + %^ cat 3 '>>>>>>>>>>>>' + %^ cat 3 ' ' + %^ cat 3 `@t`(scot %p als) + %^ cat 3 '/' + ald + ~ + :: + ++ clean :: clean + |= wig=(urge cord) + ^- (urge cord) + ?~ wig ~ + ?~ t.wig wig + ?: ?=(%& -.i.wig) + ?: ?=(%& -.i.t.wig) + $(wig [[%& (add p.i.wig p.i.t.wig)] t.t.wig]) + [i.wig $(wig t.wig)] + ?: ?=(%| -.i.t.wig) + $(wig [[%| (welp p.i.wig p.i.t.wig) (welp q.i.wig q.i.t.wig)] t.t.wig]) + [i.wig $(wig t.wig)] + :: + ++ resolve + |= [ali=(urge cord) bob=(urge cord)] + ^- [fic=[%| p=(list cord) q=(list cord)] ali=(urge cord) bob=(urge cord)] + =- [[%| bac (annotate alc boc bac)] ali bob] + |- ^- $: $: bac=(list cord) + alc=(list cord) + boc=(list cord) + == + ali=(urge cord) + bob=(urge cord) + == + ?~ ali [[~ ~ ~] ali bob] + ?~ bob [[~ ~ ~] ali bob] + ?- -.i.ali + %& + ?- -.i.bob + %& [[~ ~ ~] ali bob] :: no conflict + %| + =+ lob=(lent p.i.bob) + ?: =(lob p.i.ali) + [[p.i.bob p.i.bob q.i.bob] t.ali t.bob] + ?: (lth lob p.i.ali) + [[p.i.bob p.i.bob q.i.bob] [[%& (sub p.i.ali lob)] t.ali] t.bob] + =+ wat=(scag (sub lob p.i.ali) p.i.bob) + =+ ^= res + %= $ + ali t.ali + bob [[%| (scag (sub lob p.i.ali) p.i.bob) ~] t.bob] + == + :* :* (welp bac.res wat) + (welp alc.res wat) + (welp boc.res q.i.bob) + == + ali.res + bob.res + == + == + :: + %| + ?- -.i.bob + %& + =+ loa=(lent p.i.ali) + ?: =(loa p.i.bob) + [[p.i.ali q.i.ali p.i.ali] t.ali t.bob] + ?: (lth loa p.i.bob) + [[p.i.ali q.i.ali p.i.ali] t.ali [[%& (sub p.i.bob loa)] t.bob]] + =+ wat=(slag (sub loa p.i.bob) p.i.ali) + =+ ^= res + %= $ + ali [[%| (scag (sub loa p.i.bob) p.i.ali) ~] t.ali] + bob t.bob + == + :* :* (welp bac.res wat) + (welp alc.res q.i.ali) + (welp boc.res wat) + == + ali.res + bob.res + == + :: + %| + =+ loa=(lent p.i.ali) + =+ lob=(lent p.i.bob) + ?: =(loa lob) + [[p.i.ali q.i.ali q.i.bob] t.ali t.bob] + =+ ^= res + ?: (gth loa lob) + $(ali [[%| (scag (sub loa lob) p.i.ali) ~] t.ali], bob t.bob) + ~& [%scagging loa=loa pibob=p.i.bob slag=(scag loa p.i.bob)] + $(ali t.ali, bob [[%| (scag (sub lob loa) p.i.bob) ~] t.bob]) + :* :* (welp bac.res ?:((gth loa lob) p.i.bob p.i.ali)) + (welp alc.res q.i.ali) + (welp boc.res q.i.bob) + == + ali.res + bob.res + == + == + == + -- + -- +-- diff --git a/rpc-desk/sur/near-rpc.hoon b/rpc-desk/sur/near-rpc.hoon new file mode 100644 index 000000000..7c083354e --- /dev/null +++ b/rpc-desk/sur/near-rpc.hoon @@ -0,0 +1,14 @@ +|% ++$ provider @p ++$ id @da ++$ content @t ::will probably be JSON ++$ request [=id =content] ++$ action + $% [%change-provider =provider] + [%send-request =content] + == ++$ ask + $% [%request =request] + == ++$ response [%response ~] +-- \ No newline at end of file diff --git a/rpc-desk/sys.kelvin b/rpc-desk/sys.kelvin new file mode 100644 index 000000000..5d8a35da3 --- /dev/null +++ b/rpc-desk/sys.kelvin @@ -0,0 +1 @@ +[%zuse 412]