diff --git a/.github/workflows/build-check.yml b/.github/workflows/build-check.yml
deleted file mode 100644
index 22d71d004..000000000
--- a/.github/workflows/build-check.yml
+++ /dev/null
@@ -1,41 +0,0 @@
-name: Run build check
-
-on:
- pull_request:
- branches: [dev, master]
-
-jobs:
- build:
- timeout-minutes: 5
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
-
- - uses: actions/setup-node@v3
- with:
- node-version: "16.x"
-
- - name: Create target directory and copy file
- run: |
- mkdir -p near/target
- cp near/dist/index.js near/target/index.js
-
- - name: Install dependencies
- run: yarn
- working-directory: ./near
-
- - name: Build
- run: yarn build
- working-directory: ./near
-
- - name: Check dist/index.js
- run: cmp dist/index.js target/index.js
- working-directory: ./near
-
- - name: Failure message
- if: failure()
- uses: actions/github-script@v3
- with:
- script: |
- core.setFailed('The dist/index.js seems to be stale. Please run *yarn build* and commit the dist/index.js file.')
- working-directory: ./near
diff --git a/desk/app/near-gateways.hoon b/desk/app/near-gateways.hoon
index 5e555edcf..c4a4d16a2 100644
--- a/desk/app/near-gateways.hoon
+++ b/desk/app/near-gateways.hoon
@@ -1,5 +1,5 @@
-/- *near-handler, docket
-/+ dbug, default-agent, *near-handler, gossip, server, schooner
+/- *near-gateways
+/+ dbug, default-agent, *near-gateways, gossip, server, schooner, verb
/$ grab-metadata %noun %near-metadata
::
|%
@@ -11,9 +11,10 @@
+$ state-0
$: %0
:: (map identifier=[ship id] metadata=[name url])
+ ui-glob=[identifier glob]
heard=(map identifier metadata)
published=(map identifier metadata)
- installed=(map identifier glob:docket)
+ installed=(map identifier glob)
==
::
+$ card $+(card card:agent:gall)
@@ -22,6 +23,9 @@
=| state-0
=* state -
::
+::
+%+ verb |
+%- agent:dbug
%- %+ agent:gossip
[2 %anybody %anybody |]
%+ ~(put by *(map mark $-(* vase)))
@@ -75,7 +79,7 @@
=^ cards state abet:(arvo:hc wire sign-arvo)
[cards this]
::
- ++ on-peek on-peek:def
+ ++ on-peek peek:hc
++ on-fail on-fail:def
++ on-leave on-leave:def
--
@@ -89,8 +93,12 @@
::
++ init
^+ that
- %- emit
+ ::for now
+ %- emil
+ :~
[%pass /eyre/connect %arvo %e %connect [~ /apps/near] %near-gateways]
+ [%pass /publish-ui %agent [our.bowl %near-gateways] %poke %near-action !>([%publish 'ui-main' url ''])]
+ ==
::
++ load
|= vaz=vase
@@ -114,6 +122,12 @@
%publish
?~ (find ~[metadata.act] ~(val by published))
=/ id=identifier [our.bowl (sham eny.bowl)]
+ ~& ['publish id' id]
+ ?: =(metadata.act ['ui-main' url ''])
+ =. ui-glob [id *glob]
+ %+ get-gateway-glob
+ metadata.act
+ id
=. published (~(put by published) id metadata.act)
%+ get-gateway-glob
metadata.act
@@ -121,17 +135,30 @@
~& 'Alredy globbed and installed'
that
::
- %install ::[%install =identifier =metadata]
+ %install
%+ get-gateway-glob
metadata.act
identifier.act
+ ::
+ %delete
+ ?~ (~(get by published) identifier.act)
+ ?~ (~(get by installed) identifier.act)
+ ~& >>> 'couldnt find in published or installed gateways'
+ that
+ ~& > 'Deleted gateway'
+ =. installed (~(del by installed) identifier.act)
+ that
+ ~& > 'Deleted gateway'
+ =. published (~(del by published) identifier.act)
+ =. installed (~(del by installed) identifier.act)
+ that
==
==
++ dump [404 ~ [%plain "404 - Not Found"]]
++ handle-http-request
|= [id=@ta inbound-request:eyre]
^+ that
- =/ request-line (parse-request-line:server url.request)
+ =/ req=request-line:server (parse-request-line:server url.request)
=+ send=(cury response:schooner id)
?. authenticated
%- emil
@@ -141,30 +168,47 @@
%- emil
%- send [405 ~ [%stock ~]]
%'GET'
- ?+ [site ext]:request-line
+ ?+ [site ext]:req
%- emil
- %- send [302 ~ [%redirect './apps/near']]
+ %- send [302 ~ [%redirect '../']]
+ [[%apps %near ~] *]
+ %- emil
+ %+ give-simple-payload:app:server
+ id
+ %+ from-glob
+ *identifier
+ req(site /index/html)
::
- [[%apps %near ~] *]
- %- emil
- %- send [200 ~ [%plain "welcome to %near-gateway"]] ::for now
+ [[%apps %near %assets *] *]
+ =/ new-site (weld (slag 2 site.req) (drop ext.req))
+ %- emil
+ %+ give-simple-payload:app:server
+ id
+ %+ from-glob
+ *identifier
+ req(site new-site)
::
- [[%apps %near @ @ *] *]
+ [[%apps %near @ @ %gateway *] *] :: /apps/near/ship/id/name/index/html
+ ?. (gte (lent site.req) 6)::5)
+ %- emil
+ %- send dump
+ =/ identifier :- (slav %p (snag 2 site.req))
+ (slav %uv (snag 3 site.req))
+ ?. (~(has by installed) identifier)
+ %- emil
+ %- send [404 ~ [%plain "Downoloading glob"]]
=/ new-site
- %+ weld
- %+ slag 4
- ;; (list @ta) site.request-line
- %- drop
- ext.request-line
- ~& > request-line
- ~& >> ['site' (weld (slag 4 `(list @ta)`site.request-line) (drop ext.request-line))]
+ %+ weld
+ %+ slag 5
+ ;; (list @ta) site.req
+ %- drop
+ ext.req
%- emil
%+ give-simple-payload:app:server
id
%+ from-glob
- :- (slav %p (snag 2 site.request-line)) ::ship
- (slav %uv (snag 3 site.request-line)) ::id
- request-line(site new-site)
+ identifier
+ req(site new-site)
==
::
%'POST'
@@ -175,28 +219,35 @@
++ from-glob
|= [identifier=[=ship id=@uvH] request=request-line:server]
^- simple-payload:http
- ~& (~(has by installed) identifier)
- ?. (~(has by installed) identifier) not-found:gen:server
- =/ =glob:docket (~(got by installed) identifier)
- ::?: =(suffix /desk/js)
+ =/ =glob
+ ?: =(identifier [ship=~zod id=0v0])
+ +.ui-glob
+ ?. (~(has by installed) identifier)
+ ~
+ (~(got by installed) identifier)
+ ?: =(glob ~)
+ :::_ `(as-octt:mimes:html "Downoloading %gateway glob")
+ :::- 404 ~
+ not-found:gen:server
=/ requested ?: (~(has by glob) site.request)
site.request
/index/html
=/ =mime (~(got by glob) requested)
=/ mime-type=@t (rsh 3 (crip
))
- =; headers
+ =; headers
[[200 headers] `q.mime]
- :- content-type+mime-type
- ?: =(/index/html requested) ~
- ~[max-1-wk:gen:server]
+ :- content-type+mime-type
+ ?: =(/index/html requested) ~
+ ~[max-1-wk:gen:server]
::
++ get-gateway-glob
- |= [data=metadata =identifier] ::[name=@t url=@t]
+ |= [data=metadata =identifier]
^+ that
=/ tid `@ta`(cat 3 'near-' (scot %uv (sham eny.bowl)))
=/ ta-now `@ta`(scot %da now.bowl)
=/ ted-cage=cage :- %glob
- !>(`url.data)
+ ::!>(`url.data)
+ !>(`[url.data about.data])
=/ cage :- %spider-start
!>([~ `tid byk.bowl(r da+now.bowl) ted-cage])
=/ id-path
@@ -213,7 +264,7 @@
==
::
++ watch
- |= =path
+ |= =path
^+ that
?+ path ~|(bad-watch-path+path !!)
[%http-response *]
@@ -227,18 +278,26 @@
^- card
[%give %fact ~ %metadata !>([identifier metadata])]
==
+::
++ agent
|= [=wire =sign:agent:gall]
^+ that
?+ wire ~|(bad-agent-wire+wire !!)
+ [%publish-ui ~]
+ ?+ -.sign ~|([%unexpected-self-poke-sign -.sign] !!)
+ %poke-ack
+ ?~ p.sign
+ that
+ ~& >>> 'Poke ui failed'
+ that
+ ==
+ ::
[%~.~ %gossip %gossip ~]
?+ -.sign ~|([%unexpected-gossip-sign -.sign] !!)
%fact
=* mark p.cage.sign
=* vase q.cage.sign
?. =(%metadata mark) that
- ~& >> 'got fact'
- ~& >> !<([id=identifier =metadata] vase)
=+ !<([id=identifier =metadata] vase)
=. heard (~(put by heard) id metadata)
that
@@ -248,37 +307,46 @@
%kick that
?(%poke-ack %watch-ack)
?~ p.sign
- ~& 'Thread started succesfully'
that
- ~& 'Thread fail to start'
+ ~& >>> 'Thread failed to start'
that
::
%fact
?+ p.cage.sign that
%thread-fail
- ~& >>> ['thread-failed to glob' (slag 2 `(list @ta)`wire)]
+ ~& >>> ['Thread-failed to glob' (slag 2 `(list @ta)`wire)]
=/ id (id-from-wire wire)
=. published (~(del by published) id)
+ :: case for mirror gateway glob that's been deleted from s3-bucket
+ =. heard (~(del by heard) id)
+ ~& >> ['Deleted from heard or published, glob not exist at address' id]
that
::
%thread-done
- =/ glob !<(glob:docket q.cage.sign)
+ =/ result !<([glob @t] q.cage.sign)
+ =/ glob -.result
=/ id (id-from-wire wire)
- =/ had=metadata (~(got by published) id)
+ :: =/ had=metadata (~(got by published) id)
=/ path ;; (list @ta) wire
=/ got=metadata
- :- (snag 2 path)
+ :* (snag 2 path)
(snag 3 path)
- ?. =(url.had url.got)
- ~& >>> 'glob url mismatch'
+ +.result
+ ==
+ :: ?. =(url.had url.got)
+ :: ~& >>> 'Glob url mismatch'
+ :: that
+ ?: =(got ['ui-main' url ''])
+ =. ui-glob [-.ui-glob glob]
that
+ ~& > 'Gateway globbed successfully'
=. installed (~(put by installed) id glob)
%- emit
%+ invent:gossip
%metadata
!> ^- [identifier metadata]
[id got]
- ==
+ ==
==
==
::
@@ -294,8 +362,43 @@
?+ wire that
[%eyre %connect ~]
?. ?=([%eyre %bound *] sign-arvo) that
- ?: accepted.sign-arvo that
+ ?: accepted.sign-arvo
+ that
~& ['Failed to bind' path.binding.sign-arvo]
that
==
+++ peek
+ |= =path
+ ^- (unit (unit cage))
+ ?+ path [~ ~]
+ ::
+ [%x %heard ~] ``near-scry+!>([%heard heard])
+ [%x %published ~] ``near-scry+!>([%published published])
+ [%x %installed ~] ``near-scry+!>([%installed ~(tap in ~(key by installed))])
+ [%x %installed @ ~] ``near-scry+!>([%find-id (find-id -.+.+.path)])
+ [%x %dbug %state ~]
+ =- ``noun+!>(-)
+ %_ state
+ installed
+ %- ~(run by installed)
+ |= =glob
+ %- ~(run by glob)
+ |=(=mime mime(q.q 1.337))
+ +.ui-glob
+ %- ~(run by +.ui-glob)
+ |=(=mime mime(q.q 1.337))
+ ==
+==
+++ find-id
+|= name=@t
+^- identifier
+=/ gateway=(list [identifier metadata])
+ %+ skim ~(tap by published)
+ |= [p=identifier q=metadata]
+ =(name name.q)
+?~ gateway [~zod 0v0]
+-:(rear gateway)
+ ::
+ ::http{s}://{host}/~/scry/{app}{path}.{mark}
+++ url 'glob of %near UI'
--
\ No newline at end of file
diff --git a/desk/app/near-handler.hoon b/desk/app/near-handler.hoon
deleted file mode 100644
index 04125d0f1..000000000
--- a/desk/app/near-handler.hoon
+++ /dev/null
@@ -1,139 +0,0 @@
-/- *near-handler
-/+ dbug, default-agent, *near-handler
-::
-|%
-::
-+$ versioned-state
- $% state-0
- ==
-::
-+$ state-0
- $: %0
- accs=(set acc)
- ==
-::
-+$ 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 peek:hc
- ::
- ++ on-watch
- |= =path
- ^- (quip card _this)
- =^ cards state abet:(watch:hc path)
- [cards this]
- ::
- ++ 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
- --
-|_ [=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-handler-action
- ?> from-self
- =+ !<(act=action vase)
- ?- -.act
- %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))]]
- ==
-==
-::
-++ peek
- |= =path
- ^- (unit (unit cage))
- ?+ path [~ ~]
- [%x %accs ~]
- ``near-handler-update+!>([%accs accs])
- ==
-::
-++ watch
- |= =path
- ^+ that
- ?+ path ~|(bad-watch-path+path !!)
- [%accs ~]
- ?> from-self
- 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])]
-::
---
\ No newline at end of file
diff --git a/desk/desk.bill b/desk/desk.bill
index e86ee5efc..d6cf47232 100644
--- a/desk/desk.bill
+++ b/desk/desk.bill
@@ -1,3 +1,2 @@
-:~ %near-handler
- %near-gateways
+:~ %near-gateways
==
diff --git a/desk/desk.docket-0 b/desk/desk.docket-0
new file mode 100644
index 000000000..33527109c
--- /dev/null
+++ b/desk/desk.docket-0
@@ -0,0 +1,9 @@
+:~
+ title+'Near'
+ info+'near gateway browser'
+ color+0x1f.ec98
+ version+[0 0 1]
+ website+'https://github.com/Urbit'
+ license+'MIT'
+ site+/apps/near
+==
\ No newline at end of file
diff --git a/desk/gen/acc.hoon b/desk/gen/acc.hoon
deleted file mode 100644
index 1fa23adb5..000000000
--- a/desk/gen/acc.hoon
+++ /dev/null
@@ -1,15 +0,0 @@
-!:
-:- %say
-:: :near-handler +near-handler!acc %add 0x0
-|= $: [now=@da eny=@uvJ bec=beak]
- $: act=?(%add %del %poke)
- acc=@uxH
- ~
- ==
- ~
- ==
-?- act
-%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}'))]]]
-==
\ No newline at end of file
diff --git a/desk/lib/docket.hoon b/desk/lib/docket.hoon
new file mode 100644
index 000000000..ef39b7fbb
--- /dev/null
+++ b/desk/lib/docket.hoon
@@ -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
+ ==
+ --
+--
diff --git a/desk/lib/gossip.hoon b/desk/lib/gossip.hoon
index cd3356a16..f3df577a3 100644
--- a/desk/lib/gossip.hoon
+++ b/desk/lib/gossip.hoon
@@ -445,8 +445,8 @@
|= inner=agent:gall
=| state-1
=* state -
- %+ verb |
- %- agent:dbug
+ :: %+ verb |
+ :: %- agent:dbug
^- agent:gall
|_ =bowl:gall
+* this .
@@ -689,8 +689,8 @@
=/ dat (on-peek:og path)
?: ?=(?(~ [~ ~]) dat) ~
(fall ((soft (list mass)) q.q.u.u.dat) ~)
- ?: =(/x/dbug/state path)
- ``noun+(slop on-save:og !>(gossip=state))
+ :: ?: =(/x/dbug/state path)
+ :: ``noun+(slop on-save:og !>(gossip=state))
?. ?=([@ %~.~ %gossip *] path)
(on-peek:og path)
?. ?=(%x i.path) [~ ~]
diff --git a/desk/lib/near-gateways.hoon b/desk/lib/near-gateways.hoon
new file mode 100644
index 000000000..410afe371
--- /dev/null
+++ b/desk/lib/near-gateways.hoon
@@ -0,0 +1,86 @@
+/- *near-gateways
+/+ etch
+|%
+++ enjs
+=, enjs:format
+ |%
+ ::
+ ++ scry-json
+ |= =scry
+ ^- json
+ ?- -.scry
+ %heard
+ (id-data +.scry)
+ %published
+ (id-data +.scry)
+ %installed
+ (id-glob +.scry)
+ %find-id
+ (id +.scry)
+ ==
+ ::
+ ++ id-data
+ |= data=(map identifier metadata)
+ ^- json
+ %- en-vase:etch
+ !> ^- (list [identifier=[ship=@p id=@t] metadata=[name=@t url=@t about=@t]])
+ %+ turn ~(tap by data)
+ |= arg=[=identifier =metadata]
+ :- :- ship=ship.identifier.arg
+ id=(scot %uv id.identifier.arg)
+ [metadata.arg]
+ ::
+ ++ id-glob
+ |= data=(list identifier)
+ ^- json
+ %- en-vase:etch
+ !> ^- (list identifier=[ship=@p id=@t])
+ %+ turn data
+ |= =identifier
+ :- ship.identifier
+ (scot %uv id.identifier)
+ ::
+ ++ id
+ |= =identifier
+ ^- json
+ %- en-vase:etch
+ !> ^- [ship=@p id=@t]
+ :- ship.identifier
+ (scot %uv id.identifier)
+--
+::
+++ dejs
+!:
+=, dejs:format
+ |%
+ ::
+ ++ gateway-act
+ |= =json
+ ^- gateway-action
+ %. json
+ %- of
+ :~
+ [%publish to-metadata]
+ [%install id-data]
+ [%delete to-identifier]
+ ==
+ ++ id-data
+ %- ot
+ :~ [%identifier to-identifier]
+ [%metadata to-metadata]
+ ==
+ ::
+ ++ to-identifier
+ %- ot
+ :~ [%ship (se %p)]
+ [%id (se %uv)]
+ ==
+ ::
+ ++ to-metadata
+ %- ot
+ :~ [%name so]
+ [%url so]
+ [%about so]
+ ==
+ --
+--
\ No newline at end of file
diff --git a/desk/lib/near-handler.hoon b/desk/lib/near-handler.hoon
deleted file mode 100644
index 09f0ebd3f..000000000
--- a/desk/lib/near-handler.hoon
+++ /dev/null
@@ -1,46 +0,0 @@
-/- *near-handler
-/+ etch
-|%
-++ enjs
-=, enjs:format
- |%
- ++ update-json
- |= =update
- ^- json
- ?- -.update
- %accs
- (accs +.update)
- ==
- ::
- ++ accs
- |= accs=(set acc)
- ^- json
- %: en-vase:etch
- !> ^- (list @t)
- %+ turn ~(tap in accs)
- |=(=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]
- ==
- --
---
\ No newline at end of file
diff --git a/desk/mar/docket-0.hoon b/desk/mar/docket-0.hoon
new file mode 100644
index 000000000..c3b253b31
--- /dev/null
+++ b/desk/mar/docket-0.hoon
@@ -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
+--
diff --git a/desk/mar/near-handler/action.hoon b/desk/mar/near-handler/action.hoon
deleted file mode 100644
index db6ca988a..000000000
--- a/desk/mar/near-handler/action.hoon
+++ /dev/null
@@ -1,14 +0,0 @@
-/- *near-handler
-/+ *near-handler
-|_ =action
-++ grab
- |%
- ++ noun action
- ++ json act:dejs
- --
-++ grow
- |%
- ++ noun action
- --
-++ grad %noun
---
\ No newline at end of file
diff --git a/desk/mar/near-handler/update.hoon b/desk/mar/near-handler/update.hoon
deleted file mode 100644
index 85cc43662..000000000
--- a/desk/mar/near-handler/update.hoon
+++ /dev/null
@@ -1,14 +0,0 @@
-/- *near-handler
-/+ *near-handler
-|_ =update
-++ grab
- |%
- ++ noun update
- --
-++ grow
- |%
- ++ noun update
- ++ json (update-json:enjs update)
- --
-++ grad %noun
---
\ No newline at end of file
diff --git a/desk/mar/near/action.hoon b/desk/mar/near/action.hoon
index 4eeab70fc..deab0d85e 100644
--- a/desk/mar/near/action.hoon
+++ b/desk/mar/near/action.hoon
@@ -1,14 +1,15 @@
-/- *near-handler
-/+ *near-handler
-|_ =gateway-action
+/- *near-gateways
+/+ *near-gateways
+|_ act=gateway-action
++ grab
|%
++ noun gateway-action
- ::++ json act:dejs
+ ++ json
+ gateway-act:dejs
--
++ grow
|%
- ++ noun gateway-action
+ ++ noun act
--
++ grad %noun
--
\ No newline at end of file
diff --git a/desk/mar/near/metadata.hoon b/desk/mar/near/metadata.hoon
index b74c59952..e165541d4 100644
--- a/desk/mar/near/metadata.hoon
+++ b/desk/mar/near/metadata.hoon
@@ -1,4 +1,4 @@
-/- *near-handler
+/- *near-gateways
|_ gateway=[identifier metadata]
++ grad %noun
++ grow
diff --git a/desk/mar/near/scry.hoon b/desk/mar/near/scry.hoon
new file mode 100644
index 000000000..b7d135b20
--- /dev/null
+++ b/desk/mar/near/scry.hoon
@@ -0,0 +1,14 @@
+/- *near-gateways
+/+ *near-gateways
+|_ =scry
+++ grab
+ |%
+ ++ noun scry
+ --
+++ grow
+ |%
+ ++ noun scry
+ ++ json (scry-json:enjs scry)
+ --
+++ grad %noun
+--
\ No newline at end of file
diff --git a/desk/sur/near-gateways.hoon b/desk/sur/near-gateways.hoon
new file mode 100644
index 000000000..020a27933
--- /dev/null
+++ b/desk/sur/near-gateways.hoon
@@ -0,0 +1,16 @@
+|%
++$ glob (map path mime)
++$ metadata [name=@t url=@t about=@t]
++$ identifier [=ship id=@uvH]
++$ gateway-action
+ $% [%publish =metadata]
+ [%install =identifier =metadata]
+ [%delete =identifier]
+ ==
++$ scry
+ $% [%heard =(map identifier metadata)]
+ [%published =(map identifier metadata)]
+ [%installed =(list identifier)]
+ [%find-id =identifier]
+ ==
+--
\ No newline at end of file
diff --git a/desk/sur/near-handler.hoon b/desk/sur/near-handler.hoon
deleted file mode 100644
index f8d057753..000000000
--- a/desk/sur/near-handler.hoon
+++ /dev/null
@@ -1,18 +0,0 @@
-|%
-+$ acc @uxH
-:: +$ glob (map path mime)
-+$ metadata [name=@t url=@t]
-+$ identifier [=ship id=@uvH]
-+$ action
- $% [%add =acc]
- [%del =acc]
- [%poke [=dude:gall =mark json=(unit json)]]
- ==
-+$ update
- $% [%accs accs=(set acc)]
- ==
-+$ gateway-action
- $% [%publish =metadata]
- [%install =identifier =metadata]
- ==
---
\ No newline at end of file
diff --git a/desk/ted/glob.hoon b/desk/ted/glob.hoon
index c14635878..975a3232e 100644
--- a/desk/ted/glob.hoon
+++ b/desk/ted/glob.hoon
@@ -1,19 +1,17 @@
-/- spider, *near-handler, docket
+/- spider, *near-gateways
/+ strandio
=, strand=strand:spider
^- thread:spider
|= arg=vase
=/ m (strand ,vase)
^- form:m
-=+ !<([~ url=@t] arg)
-;< =glob:docket bind:m
- %+ (retry:strandio ,glob:docket) `5
- =/ n (strand ,(unit glob:docket))
+=+ !<([~ url=@t about=@t] arg)
+;< =glob bind:m
+ %+ (retry:strandio ,glob) `5
+ =/ n (strand ,(unit glob))
;< =cord bind:n (fetch-cord:strandio (trip url))
- ~& > cord
%- pure:n
%- mole
|.
- ;;(=glob:docket (cue cord))
-~& >> glob
-(pure:m !>(glob))
+ ;;(=glob (cue cord))
+(pure:m !>([glob about]))
diff --git a/near/.babelrc b/near/.babelrc
deleted file mode 100644
index 2b7bafa5f..000000000
--- a/near/.babelrc
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "presets": ["@babel/preset-env", "@babel/preset-react"]
-}
diff --git a/near/CHANGELOG.md b/near/CHANGELOG.md
deleted file mode 100644
index db4d4e4c5..000000000
--- a/near/CHANGELOG.md
+++ /dev/null
@@ -1,546 +0,0 @@
-# Changelog
-
-## 2.5.3
-
-- FIX: Remove `cachedPropery` from `elliptic.utils`. Reported by BrunoModificato from OtterSec.
-- FIX: Replace url-sanitize library with dompurify. Reported by BrunoModificato from OtterSec.
-- FIX: Replace internal usage of `in` operator with `hasOwnProperty` on dictionaries to avoid exposing certain built-in methods and properties. Reported by BrunoModificato from OtterSec.
-- FIX: `atob` and `btoa` are working correctly now.
-
-## 2.5.2
-
-- Use `styled-components` in combination with `customElements` like `Link`:
-
-```jsx
-const MyLink = styled("Link")`
- color: red;
-`;
-
-return (
-
- Click Me!
-
-);
-```
-
-## 2.5.1
-
-- FIX: Add back `Ethers.send`, that was incorrectly removed as part of the https://github.com/NearSocial/VM/pull/128
-- FIX: Disable `is` attribute to avoid conflicts with React. Reported by BrunoModificato from OtterSec.
-
-## 2.5.0
-
-- Fix `default` case for the switch statement in `VM`.
-- Add a VM feature, `enableComponentSrcDataKey`, which adds the `data-component` attribute specifying the path of the comonent responsible for rendering the DOM element.
-- Add support for VM.require when using redirectMap.
-- Fixes an issue with VM.require not retaining context in migration to initGlobalFunctions.
-- Add `onLink` and `onImage` to Markdown component. It allows to display links and images differently.
-- Expose all VM functions into the state directly, it simplifies VM readability and implementation.
-- Expose certain native objects directly into the state. It should improve access to the functions.
-- Update the way events and errors are passed to the functions.
- - For events, expose `preventDefault()` and `stopPropagation()` functions.
- NOTE: Previously, all React's `SyntheticEvent`s were getting `preventDefault()` called by default.
- - For errors, expose `message`, `name` and `type`.
-- Fix `vm.depth` not being initialized.
-- Introduce `useMemo` hook. Similar to the React hook, it calculates a value and memoizes it, only recalculating when one of its dependencies changes.
-
-```jsx
-const data = [
- //...some large array
-];
-
-const filteredData = useMemo(() => {
- console.log("Filtering data");
- return data.filter(/* some filtering criteria */);
-}, [data]);
-
-return (
-
- {filteredData.map(item => (
-
{item.name}
- ))}
-
-);
-```
-
-- Introduce `useCallback` hook. Similarly to the React hook, it memoizes a callback function and returns that memoized version unless one of its dependencies changes.
- ```jsx
- const incrementCounter = useCallback(() => {
- setCounter(counter + 1);
-}, [counter]);
-
-return (
-
- Counter = {counter}
-
- Increment
-
-
-);
-```
-
-## 2.4.2
-
-- Add missing code changes (`cacheOptions` and `lodash`) from 2.4.0.
-> This happened due to revert from master that later cleaned changes from dev at merge conflict.
-
-## 2.4.1
-
-- FIX: Resolve bug with `VM.require` affected by the introduction of `useState` and `useEffect` hooks.
-
-## 2.4.0
-
-- Introduce `useState` and `useEffect`. They should work similarly to the React hooks. Example:
-```jsx
-const [a, setA] = useState(() => {
- console.log("Init 'a'");
- return "Y";
-});
-
-const [b, setB] = useState("B");
-const [sum, setSum] = useState(0);
-
-useEffect(() => {
- setSum(a.length + b.length);
- return () => {
- console.log("cleanup");
- };
-}, [a, b]);
-
-return (
-
- A = {a}
-
B = {b}
-
- Length sum = {sum}
-
- setA((s) => s + "O")}>A
- setB(b + "O")}>B
-
-
-);
-```
-
-- Add `cacheOptions` optional argument to the following methods:
- - `Social.get(keys, blockId|finality, options, cacheOptions)`
- - `Social.getr(keys, blockId|finality, options, cacheOptions)`
- - `Social.keys(keys, blockId|finality, options, cacheOptions)`
- - `Social.index(action, key, options, cacheOptions)`
- - `Near.view(contractName, methodName, args, blockId|finality, subscribe, cacheOptions)`
- - `Near.block(blockId|finality, subscribe, cacheOptions)`
- The `cacheOptions` object is optional and may contain the following property:
- - `ignoreCache` - boolean, if true, the method will ignore the cached value in the local DB and fetch the data from the API server. This will only happen once per session. Default is false.
-
-This is useful to avoid loading stale objects that are likely to change often. For example, the index of posts for the main feed, or notifications.
-```jsx
-const index = Social.index(
- "post",
- "main",
- {
- limit: 10,
- order: "desc",
- },
- {
- ignoreCache: true,
- }
-);
-```
-
-- Replace `lodash` dependency with `lodash.clonedeep` to reduce bundle size.
-
-## 2.3.2
-
-- Nothing. Missed the package.json bump in the previous release.
-
-## 2.3.1
-
-- Rollback the following change: "`Ethers.send` to ignore cache and return a promise instead of the cached value". REASON: Too many widgets forked the logic to retrieve accounts using `Ethers.send`. We'll address it later with cache invalidation strategy. Examples:
-Correct usage:
-```jsx
-// Use `Ethers.provider().send()` to get a promise without caching.
-if (state.sender === undefined) {
- Ethers.provider().send("eth_requestAccounts", []).then((accounts) => {
- if (accounts.length) {
- State.update({ sender: accounts[0] });
- console.log("set sender", accounts[0]);
- }
- });
-}
-```
-Legacy example:
-```jsx
-// Use `Ethers.send()` to get a cached version, but might run into stale cached data.
-if (state.sender === undefined) {
- const accounts = Ethers.send("eth_requestAccounts", []);
- if (accounts.length) {
- State.update({ sender: accounts[0] });
- console.log("set sender", accounts[0]);
- }
-}
-```
-
-## 2.3.0
-
-- Expose `encodeURIComponent`, `decodeURIComponent`, `btoa`, `atob`, `isFinite`, `decodeURI` and `encodeURI` in the global scope.
-- Refactor native functions into an object, making it easier to add new functions.
-- Add a `networkId` prop to the `Widget` component config to allow using a `near` object outside the singleton state to allow testing Mainnet components on a Testnet initialized VM or vice versa. Example usage of `networkId` prop in `Widget` config:
-
-```jsx
-// Import widget from testnet initialized VM
-
-
-
-// Also works with the `code` prop where `Social.get` and other [BOS API](https://docs.near.org/bos/api/near#) features and `Widget`s will reference mainnet in this case.
-```
-- Expose `Ethers.setChain({chainId})` to be able to switch between EVM networks. Note, the gateway should inject it as part of the `EthersProviderContext`.
-- Add `config.defaultFinality` to be able to specify `final` instead of `optimistic` (default). It would route the majority of the view calls through the API server.
-- Expose `ethers.providers`. You will be able to construct a custom JSON provider for read only data. Example usage:
-
-```jsx
-const opGoerliProvider = new ethers.providers.JsonRpcProvider(
- "https://optimism-goerli.blockpi.network/v1/rpc/public"
-);
-
-console.log(opGoerliProvider);
-```
-- BREAKING: Update `Ethers.send` to ignore cache and return a promise instead of the cached value.
-- Add `loading` prop to a Widget. It would display the passed value instead of the default loading spinner. It can be used to display a custom loading indicator or a placeholder. Example:
-```jsx
-Loading...}
- src="mob.near/widget/ProfilePage"
-/>
-```
-
-## 2.2.4
-
-- Fix VM.require bug which was accessing a this.vmInstances map via bracket notion rather than correct .get()
-
-## 2.2.3
-
-- Filter out rest of the args in `Markdown`.
-
-## 2.2.2
-
-- Gracefully handle compilation errors in `VM`. Previously, the VM would throw an error when the compilation failed, which resulted in a blank screen. Now, the VM will render the error message instead.
-
-## 2.2.1
-
-- Fix href sanitization for non-lowercase attribute names.
-- Add testnet URL to the config.
-- Fix SecureIframe bug which did not allow posting a message to iframe window if iframeResizer was used
- An example of a valid `srcDoc` for a SecureIframe using iframeResizer:
-
-```jsx
-const code = `
-
-
-loading...
-`;
-
-return (
-
-
-
-);
-```
-
-## 2.2.0
-
-- _BETA_: Introduce `VM.require`. This is a new API that allows to retrieve a module source from the Social DB, execute it and return the results.
-
-Note, this should be considered a beta feature and the API and the functionality might change.
-
-`VM.require(src)` takes a `src` the path for the source code of the module.
-The `src` argument may contain the source version by including the `blockHeight`. E.g. `VM.require("mob.near/widget/Module.Abc@91698491")` to get the source code at block height `91698491`.
-
-Module example:
-
-```jsx
-function Magic(props) {
- return Magic: {props.children}
;
-}
-
-return { Magic };
-```
-
-Widget example:
-
-```jsx
-const { Magic } = VM.require("mob.near/widget/Module.Magic");
-
-return Hello World ;
-```
-
-- Add `WebSocket` object and support native events for function arguments (needed to get `data`). Websockets are automatically closed when a VM instance is stopped.
-
-## 2.1.0
-
-- Revert functionCall action creator back to use JSON, since wallet selector automatically converts actions from JSON.
-- Introducing custom gateway elements. To define a custom element, a gateway can populate `customElements` argument in `initNear`. It's an optional object that can be used to register custom elements. The key is the name of the element, and the value is a function that returns a React component. For example:
-
-```js
-initNear({
- customElements: {
- Link: (props) => {
- if (!props.to && props.href) {
- props.to = props.href;
- delete props.href;
- }
- if (props.to) {
- props.to = sanitizeUrl(props.to);
- }
- return ;
- },
- },
-});
-```
-
-- Remove `deepCopy` from `state` and `props`. The VM now only copies the top object, but doesn't do a deep copy. It allows to store and pass complex objects into the state.
-
-## 2.0.0
-
-- Uses NAJ action creators rather than POJOs, so they serialize correctly when passed directly to borsh
-- Updates near-api-js to be a peer dependency to avoid multiple copies of NAJ loading at once
-- Removed all global CSS imports. Please update your viewer by installing `react-bootstrap-typeahead` and importing these CSS files:
-
-```
-import "react-bootstrap-typeahead/css/Typeahead.css";
-import "react-bootstrap-typeahead/css/Typeahead.bs5.css";
-```
-
-## 1.3.2
-
-- Added support for `onLoad` event for `