diff --git a/stack_orchestrator/data/compose/docker-compose-fixturenet-urbit.yml b/stack_orchestrator/data/compose/docker-compose-fixturenet-urbit.yml index bc64cd90..5aa4c12a 100644 --- a/stack_orchestrator/data/compose/docker-compose-fixturenet-urbit.yml +++ b/stack_orchestrator/data/compose/docker-compose-fixturenet-urbit.yml @@ -26,9 +26,9 @@ services: - "80" healthcheck: test: ["CMD", "nc", "-v", "localhost", "80"] - interval: 20s + interval: 10s timeout: 5s - retries: 15 + retries: 30 start_period: 10s volumes: diff --git a/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml b/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml index 334ab0cd..2c640870 100644 --- a/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml +++ b/stack_orchestrator/data/compose/docker-compose-uniswap-interface.yml @@ -7,12 +7,12 @@ services: environment: - REACT_APP_INFURA_KEY=${CERC_INFURA_KEY} - REACT_APP_AWS_API_ENDPOINT=${CERC_UNISWAP_GQL} + - REACT_APP_UNISWAP_API_URL=${CERC_UNISWAP_API} command: ["./build-app.sh"] volumes: - ../config/uniswap-interface/build-app.sh:/app/build-app.sh - urbit_app_builds:/app-builds - - ../config/uniswap-interface/urbit-files/mar:/app/mar - - ../config/uniswap-interface/urbit-files/desk.docket-0:/app/desk.docket-0 + - ../config/uniswap-interface/urbit-files:/app/urbit-files volumes: urbit_app_builds: diff --git a/stack_orchestrator/data/compose/docker-compose-vega-interface.yml b/stack_orchestrator/data/compose/docker-compose-vega-interface.yml new file mode 100644 index 00000000..5a33ada0 --- /dev/null +++ b/stack_orchestrator/data/compose/docker-compose-vega-interface.yml @@ -0,0 +1,19 @@ +version: "3.2" + +# This is a short-lived container. It runs the Vega build and then copies the output to the +# `urbit_app_builds` volume. +services: + vega-interface: + image: cerc/vega-interface:local + restart: on-failure + # environment: + # - REACT_APP_INFURA_KEY=${CERC_INFURA_KEY} + # - REACT_APP_AWS_API_ENDPOINT=${CERC_UNISWAP_GQL} + entrypoint: ["./build-app.sh"] + volumes: + - ../config/vega-interface/urbit-files:/app/urbit-files + - ../config/vega-interface/build-app.sh:/app/build-app.sh + - urbit_app_builds:/app-builds + +volumes: + urbit_app_builds: diff --git a/stack_orchestrator/data/config/uniswap-interface/build-app.sh b/stack_orchestrator/data/config/uniswap-interface/build-app.sh index 81e306b6..dcfb9304 100755 --- a/stack_orchestrator/data/config/uniswap-interface/build-app.sh +++ b/stack_orchestrator/data/config/uniswap-interface/build-app.sh @@ -15,7 +15,5 @@ yarn build # Copy over build and other files to app-builds for urbit deployment mkdir -p /app-builds/uniswap -cp -r ./build /app-builds/uniswap/ - -cp -r mar /app-builds/uniswap/ -cp desk.docket-0 /app-builds/uniswap/ +cp -r urbit-files /app-builds/uniswap/ +cp -r ./build /app-builds/uniswap/urbit-files diff --git a/stack_orchestrator/data/config/uniswap-interface/urbit-files/app/proxy.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/app/proxy.hoon new file mode 100644 index 00000000..f10520af --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/app/proxy.hoon @@ -0,0 +1,225 @@ +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +:: Proxy server +:: ------------ +:: +:: This is a simple agent which accepts requests at the path given in the `on-init` arm-- in this +:: case, "/apps/uniswap-proxy/"-- and proxies them to the upstream, in this case, +:: "https://api.uniswap.org/". +:: +:: For example, assuming your ship is running on `localhost:8080`, a request to the url +:: +:: `http://localhost:8080/apps/uniswap-proxy/v1/graphql` +:: +:: will be proxied to +:: +:: `https://api.uniswap.org/v1/graphql` +:: +::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:: +/+ dbug, server, default-agent +:: +|% + +$ card card:agent:gall + +$ state + $% %0 + == +-- +:: +:: Path config +|% + ++ base-url-path /apps/uniswap-proxy :: HTTP path on the ship that this agent will bind to + ++ upstream-api-url "https://api.uniswap.org/" :: Upstream HTTP api that requests should be proxied to +-- +:: +%- agent:dbug +:: +=| state +=* state - +:: +^- agent:gall +=< +|_ =bowl:gall + +* this . + default ~(. (default-agent this) bowl) + :: + ++ on-init + ^- (quip card _this) + :_ this + :~ + [%pass /eyre/connect %arvo %e %connect [~ base-url-path] %proxy] + == + :: + ++ on-poke + |= [=mark =vase] + ^- (quip card _this) + :_ this :: We have no state + ?+ mark (on-poke:default mark vase) + %handle-http-request + =/ [eyre-id=@ta inbound-req=inbound-request:eyre] !<([@ta =inbound-request:eyre] vase) + ~& "Eyre id: {}" + =/ old-req request:inbound-req + =/ new-req=request:http + %= old-req + :: Remove path prefix from the url, replace with Uniswap domain and path prefix + url (rewrite-path url:old-req) + :: Change the "Origin" header to match the upstream (this is hacky as fuck and will break eventually) + header-list (rewrite-headers header-list:old-req) + == + ~& "Proxying {} to {}" + ~& "Outgoing headers: {}" + :~ + [%pass /response/[eyre-id] %arvo %i %request new-req *outbound-config:iris] + == + == + :: + ++ on-arvo + |= [=wire =sign-arvo] + ^- (quip card _this) + :_ this :: We don't have any state + ?+ sign-arvo (on-arvo:default wire sign-arvo) + :: + :: Arvo will respond when we initially connect to Eyre in `on-init`. We will accept (and ignore) + :: that and reject any other communications. + [%eyre %bound *] + ~& "Got eyre bound: {}" + ~ + [%iris %http-response %finished *] + ?+ wire (on-arvo:default wire sign-arvo) + [%response @ ~] + =/ original-eyre-id=@ta (snag 1 `(list @ta)`wire) + =/ resp=client-response:iris +:+:sign-arvo + ?> ?= %finished -.resp + =/ resp-header=response-header:http response-header:resp + =/ the-octs=octs data:(need full-file:resp) + :: + =/ thedata=@t q.the-octs + ~& resp-header + ~& "Proxied HTTP {}: {}" + %+ give-simple-payload:app:server + original-eyre-id + :- %_(resp-header headers [['Content-type'^'application/json'] ~]) + `the-octs + == + == + :: + :: Each time Eyre pokes a request to us, it will subscribe for the response. We will just accept + :: those connections (wire = /http-response/[eyre-id]) and reject any others. + :: See: https://docs.urbit.org/system/kernel/eyre/reference/tasks#connect + ++ on-watch + |= =path + ^- (quip card _this) + ?+ path (on-watch:default path) + [%http-response *] + `this + == + :: + ++ on-save on-save:default + ++ on-load on-load:default + ++ on-leave on-leave:default + ++ on-peek on-peek:default + ++ on-agent on-agent:default + ++ on-fail on-fail:default +-- +:: +:: Helpers core +|% + :: Rewrites a path like "/apps/uniswap-proxy/v1/graphql" to "https://api.uniswap.org/v1/graphql". + :: `url-path` is a path, not a full URL! + ++ rewrite-path + |= [url-path=@t] + %+ rash + url-path + :: Prepend the `upstream-api-url` base url and convert back to a cord + %+ cook + |= [a=tape] + (crip (weld upstream-api-url a)) + :: Strip the base path + ;~ pfix + (ifix [(just '/') (just '/')] (jest (crip (join '/' `(list @t)`base-url-path)))) + (star prn) + == + :: + :: Change the 'Origin' http header to "https://api.uniswap.org". + :: I don't know why this makes the request work, but it does. + :: Also drop the "x-forwarded-for" header for Red Horizon; otherwise this breaks it. + ++ rewrite-headers + |= [headers=header-list:http] + ^- header-list:http + =/ ret *header-list:http + |- + ?~ headers + ret + %= $ + ret ?+ (crip (cass (trip key:(head headers)))) + :: + :: Default: use the header + (snoc ret (head headers)) + :: + :: Drop "x-forwarded-for" header + %'x-forwarded-for' + ret + :: + :: Drop the "cookie" header, which contains the Urbit auth token (!) + %'cookie' + ret + :: + :: Rewrite "origin" header + %'origin' + (snoc ret ['origin' 'https://api.uniswap.org']) + == + headers +.headers + == + :: + :: Manually construct a card that can be passed to iris, simulating a Uniswap graphql request. + :: Can be useful for testing purposes. + ++ iris-request-card + :: + :: The resulting card produces an HTTP request equivalent to the following cURL command: + :: + :: curl 'https://api.uniswap.org/v1/graphql' \ + :: -H 'authority: interface.gateway.uniswap.org' \ + :: -H 'accept: */*' \ + :: -H 'accept-language: en-US,en;q=0.7' \ + :: -H 'content-type: application/json' \ + :: -H 'origin: https://app.uniswap.org' \ + :: -H 'referer: https://app.uniswap.org/' \ + :: -H 'sec-ch-ua: "Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121"' \ + :: -H 'sec-ch-ua-mobile: ?0' \ + :: -H 'sec-ch-ua-platform: "Linux"' \ + :: -H 'sec-fetch-dest: empty' \ + :: -H 'sec-fetch-mode: cors' \ + :: -H 'sec-fetch-site: same-site' \ + :: -H 'sec-gpc: 1' \ + :: -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36' \ + :: --data-raw $'{"operationName":"TokenSpotPrice","variables":{"address":null,"chain":"ETHEREUM"},"query":"query TokenSpotPrice($chain: Chain\u0021, $address: String = null) {\\n token(chain: $chain, address: $address) {\\n id\\n address\\n chain\\n name\\n symbol\\n project {\\n id\\n markets(currencies: [USD]) {\\n id\\n price {\\n id\\n value\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n __typename\\n }\\n}"}' \ + :: --compressed + :: + =/ the-request=request:http + :* %'POST' 'https://api.uniswap.org/v1/graphql' + :~ ['Accept-Language' 'en-US,en'] + ['Cache-Control' 'no-cache'] + ['Connection' 'keep-alive'] + ['Origin' 'http://localhost:8080'] + ['Pragma' 'no-cache'] + ['Referer' 'http://localhost:8080/'] + ['Sec-Fetch-Dest' 'empty'] + ['Sec-Fetch-Mode' 'cors'] + ['Sec-Fetch-Site' 'same-site'] + ['Sec-GPC' '1'] + ['User-Agent' 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36'] + ['accept' '*/*'] + ['content-type' 'application/json'] + ['sec-ch-ua' '"Not A(Brand";v="99", "Brave";v="121", "Chromium";v="121"'] + ['sec-ch-ua-mobile' '?0'] + ['sec-ch-ua-platform' '"Linux"'] + == + :- ~ %- as-octs:mimes:html + ''' + {"operationName":"TokenSpotPrice","variables":{"address":null,"chain":"ETHEREUM"},"query":"query TokenSpotPrice($chain: Chain\u0021, $address: String = null) {\n token(chain: $chain, address: $address) {\n id\n address\n chain\n name\n symbol\n project {\n id\n markets(currencies: [USD]) {\n id\n price {\n id\n value\n __typename\n }\n __typename\n }\n __typename\n }\n __typename\n }\n}"} + ''' + == + :~ + [%pass /response/1 %arvo %i %request the-request *outbound-config:iris] + == +-- diff --git a/stack_orchestrator/data/config/uniswap-interface/urbit-files/desk.bill b/stack_orchestrator/data/config/uniswap-interface/urbit-files/desk.bill new file mode 100644 index 00000000..24c8041f --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/desk.bill @@ -0,0 +1,2 @@ +:~ %proxy +== diff --git a/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/dbug.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/dbug.hoon new file mode 100644 index 00000000..ce98619e --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/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/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/default-agent.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/default-agent.hoon new file mode 100644 index 00000000..f2107436 --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/default-agent.hoon @@ -0,0 +1,65 @@ +|= [agent=agent:gall] +|_ =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 {} to {} on wire {}" + !! +:: +++ on-fail + |= [=term =tang] + %- (slog leaf+"error in {}" >term< tang) + `agent +-- diff --git a/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/server.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/server.hoon new file mode 100644 index 00000000..f5cf8f0c --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/lib/server.hoon @@ -0,0 +1,159 @@ +=, 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-octs: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]~] ~] + -- +-- diff --git a/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/bill.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/bill.hoon new file mode 100644 index 00000000..76cef343 --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/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/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/hoon.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/hoon.hoon new file mode 100644 index 00000000..428e1056 --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/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/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/kelvin.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/kelvin.hoon new file mode 100644 index 00000000..7f1b409c --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/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/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/map.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/map.hoon deleted file mode 100644 index e5d61eee..00000000 --- a/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/map.hoon +++ /dev/null @@ -1,18 +0,0 @@ -:: -:::: /hoon/map/mar - :: Mark for js source maps -/? 310 -:: -=, eyre -|_ mud=@ -++ grow - |% - ++ mime [/application/octet-stream (as-octs:mimes:html (@t mud))] - -- -++ grab - |% :: convert from - ++ mime |=([p=mite q=octs] (@t q.q)) - ++ noun cord :: clam from %noun - -- -++ grad %mime --- diff --git a/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/mime.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/mime.hoon new file mode 100644 index 00000000..83b4daeb --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/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/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/noun.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/noun.hoon new file mode 100644 index 00000000..ff5443ec --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/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/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/ttf.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/ttf.hoon deleted file mode 100644 index 2d29193e..00000000 --- a/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/ttf.hoon +++ /dev/null @@ -1,12 +0,0 @@ -|_ dat=octs -++ grow - |% - ++ mime [/font/ttf dat] - -- -++ grab - |% - ++ mime |=([=mite =octs] octs) - ++ noun octs - -- -++ grad %mime --- diff --git a/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/txt.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/txt.hoon new file mode 100644 index 00000000..982dce97 --- /dev/null +++ b/stack_orchestrator/data/config/uniswap-interface/urbit-files/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/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/woff.hoon b/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/woff.hoon deleted file mode 100644 index 2933aea7..00000000 --- a/stack_orchestrator/data/config/uniswap-interface/urbit-files/mar/woff.hoon +++ /dev/null @@ -1,12 +0,0 @@ -|_ dat=octs -++ grow - |% - ++ mime [/font/woff dat] - -- -++ grab - |% - ++ mime |=([=mite =octs] octs) - ++ noun octs - -- -++ grad %mime --- diff --git a/stack_orchestrator/data/config/urbit/deploy-app.sh b/stack_orchestrator/data/config/urbit/deploy-app.sh index bde6cd6f..495a2866 100755 --- a/stack_orchestrator/data/config/urbit/deploy-app.sh +++ b/stack_orchestrator/data/config/urbit/deploy-app.sh @@ -17,16 +17,10 @@ if [ -d ${app_desk_dir} ]; then exit 0 fi -app_build=/app-builds/${CERC_URBIT_APP}/build -app_mark_files=/app-builds/${CERC_URBIT_APP}/mar -app_docket_file=/app-builds/${CERC_URBIT_APP}/desk.docket-0 - -echo "Reading app build from ${app_build}" -echo "Reading additional mark files from ${app_mark_files}" -echo "Reading docket file ${app_docket_file}" +app_files=/app-builds/${CERC_URBIT_APP}/urbit-files # Loop until the app's build appears -while [ ! -d ${app_build} ]; do +while [ ! -d "${app_files}/build" ]; do echo "${CERC_URBIT_APP} app build not found, retrying in 5s..." sleep 5 done @@ -50,15 +44,16 @@ hood () { hood "merge %${CERC_URBIT_APP} our %landscape" hood "mount %${CERC_URBIT_APP}" -# Copy over build to desk data dir -cp -r ${app_build} ${app_desk_dir} - -# Copy over the additional mark files -cp ${app_mark_files}/* ${app_desk_dir}/mar/ - -rm "${app_desk_dir}/desk.bill" +rm "${app_desk_dir}/desk.bill" # Don't install the landscape apps rm "${app_desk_dir}/desk.ship" + +echo "Copying files from ${app_files}" + +# Copy over build to desk data dir +cp -r ${app_files}/* ${app_desk_dir} +rm ${app_desk_dir}/desk.docket-0 # Remove until we have a valid glob path; it's added back again below + # Commit changes and create a glob hood "commit %${CERC_URBIT_APP}" dojo "-landscape!make-glob %${CERC_URBIT_APP} /build" @@ -99,8 +94,8 @@ while true; do done # Replace the docket file for app -# Substitue the glob URL and hash -cp ${app_docket_file} ${app_desk_dir}/ +# Substitute the glob URL and hash +cp ${app_files}/desk.docket-0 ${app_desk_dir}/ sed -i "s|REPLACE_WITH_GLOB_URL|${glob_url}|g; s|REPLACE_WITH_GLOB_HASH|${glob_hash}|g" ${app_desk_dir}/desk.docket-0 # Commit changes and install the app diff --git a/stack_orchestrator/data/config/vega-interface/build-app.sh b/stack_orchestrator/data/config/vega-interface/build-app.sh new file mode 100755 index 00000000..b1a7a6fa --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/build-app.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -e +if [ -n "$CERC_SCRIPT_DEBUG" ]; then + set -x +fi + +# Check and exit if a deployment already exists (on restarts) +if [ -d /app-builds/vega/build ]; then + echo "Build already exists, remove volume to rebuild" + exit 0 +fi + +./docker/prepare-dist.sh + +# Post-process the output: rename files, e.g., `AlphaLyrae.woff2` => `alphalyrae.woff2` +while read filepath; do + filename=$(basename "$filepath") + dir=$(dirname "$filepath") + if echo "$filename" | grep -q "[A-Z]"; then + newfilename=$(tr '[:upper:]' '[:lower:]' <<< "$filename") + echo "Translating '$filepath' => $dir/$newfilename'" + mv "$filepath" "$dir/$newfilename" + find dist-result -type f | xargs sed -i "s/$filename/$newfilename/g" + fi +done < <(find dist-result/ -type f) + + +# Copy over dist-result and other files to `app-builds` volume for urbit deployment +mkdir -p /app-builds/vega +cp -r ./dist-result /app-builds/vega/build +cp -r urbit-files/* /app-builds/vega/ diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/desk.docket-0 b/stack_orchestrator/data/config/vega-interface/urbit-files/desk.docket-0 new file mode 100644 index 00000000..fdb12eea --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/desk.docket-0 @@ -0,0 +1,10 @@ +:~ title+'Vegas' + info+'vegas' + color+0xcd.75df + image+'https://vegaprotocol.eth.limo/favicon.ico' + base+'vegas' + glob-http+['REPLACE_WITH_GLOB_URL' REPLACE_WITH_GLOB_HASH] + version+[0 0 1] + website+'https://vega.xyz/' + license+'MIT' +== diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/lib/docket.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/lib/docket.hoon new file mode 100644 index 00000000..ef39b7fb --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/bill.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/bill.hoon new file mode 100644 index 00000000..76cef343 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/css.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/css.hoon new file mode 100644 index 00000000..1a870811 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/css.hoon @@ -0,0 +1,25 @@ +:: +:::: /hoon/css/mar + :: +/? 310 +=, eyre +=, mimes:html +|_ mud=@t +++ grow :: convert to + |% + ++ mime [/text/css (as-octs mud)] :: convert to %mime + ++ hymn :: convert to %hymn + |^ html + ++ style ;style + ;- (trip mud) + == + ++ html ;html:(head:"{style}" body) + -- + -- +++ grab + |% :: convert from + ++ mime |=([p=mite q=octs] (@t q.q)) + ++ noun @t :: clam from %noun + -- +++ grad %mime +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/docket-0.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/docket-0.hoon new file mode 100644 index 00000000..c3b253b3 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/hoon.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/hoon.hoon new file mode 100644 index 00000000..428e1056 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/html.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/html.hoon new file mode 100644 index 00000000..203d75f6 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/html.hoon @@ -0,0 +1,22 @@ +:: +:::: /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 +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/ico.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/ico.hoon new file mode 100644 index 00000000..e862b9b9 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/ico.hoon @@ -0,0 +1,12 @@ +|_ dat=@ +++ grow + |% + ++ mime [/image/x-icon (as-octs:mimes:html dat)] + -- +++ grab + |% + ++ mime |=([p=mite q=octs] q.q) + ++ noun @ + -- +++ grad %mime +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/jpg.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/jpg.hoon new file mode 100644 index 00000000..81a77d46 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/jpg.hoon @@ -0,0 +1,12 @@ +|_ dat=@ +++ grow + |% + ++ mime [/image/jpeg (as-octs:mimes:html dat)] + -- +++ grab + |% + ++ mime |=([p=mite q=octs] q.q) + ++ noun @ + -- +++ grad %mime +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/js.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/js.hoon new file mode 100644 index 00000000..fe010d99 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/js.hoon @@ -0,0 +1,25 @@ +:: +:::: /hoon/js/mar + :: +/? 310 +:: +=, eyre +|_ mud=@ +++ grow + |% + ++ mime [/application/javascript (as-octs:mimes:html (@t mud))] + ++ hymn :: convert to %hymn + |^ html + ++ script ;script + ;- (trip (@t mud)) + == + ++ html ;html:(head:"{script}" body) + -- + -- +++ grab + |% :: convert from + ++ mime |=([p=mite q=octs] (@t q.q)) + ++ noun cord :: clam from %noun + -- +++ grad %mime +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/json.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/json.hoon new file mode 100644 index 00000000..7d6fcbf8 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/json/rpc/response.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/json/rpc/response.hoon new file mode 100644 index 00000000..a1cf33de --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/json/rpc/response.hoon @@ -0,0 +1,42 @@ +:: +/- *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)) + %- json + ?~ r.hit + a+~ + (need (de:json:html 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) + -- +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/kelvin.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/kelvin.hoon new file mode 100644 index 00000000..7f1b409c --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/mime.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/mime.hoon new file mode 100644 index 00000000..83b4daeb --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/noun.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/noun.hoon new file mode 100644 index 00000000..ff5443ec --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/png.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/png.hoon new file mode 100644 index 00000000..6a60a6a2 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/png.hoon @@ -0,0 +1,12 @@ +|_ dat=@ +++ grow + |% + ++ mime [/image/png (as-octs:mimes:html dat)] + -- +++ grab + |% + ++ mime |=([p=mite q=octs] q.q) + ++ noun @ + -- +++ grad %mime +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/ship.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/ship.hoon new file mode 100644 index 00000000..176bcade --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/ship.hoon @@ -0,0 +1,20 @@ +|_ s=ship +++ grad %noun +++ grow + |% + ++ noun s + ++ json s+(scot %p s) + ++ mime + ^- ^mime + [/text/x-ship (as-octt:mimes:html (scow %p s))] + + -- +++ grab + |% + ++ noun ship + ++ json (su:dejs:format ;~(pfix sig fed:ag)) + ++ mime + |= [=mite len=@ tex=@] + (slav %p (snag 0 (to-wain:format tex))) + -- +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/txt-diff.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/txt-diff.hoon new file mode 100644 index 00000000..2c9a500d --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/txt-diff.hoon @@ -0,0 +1,16 @@ +:: +:::: /hoon/txt-diff/mar + :: +/? 310 +|_ txt-diff=(urge:clay cord) +:: +++ grad %noun +++ grow + |% + ++ noun txt-diff + -- +++ grab :: convert from + |% + ++ noun (urge:clay cord) :: make from %noun + -- +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/txt.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/txt.hoon new file mode 100644 index 00000000..982dce97 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/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/stack_orchestrator/data/config/vega-interface/urbit-files/mar/woff.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/woff.hoon new file mode 100644 index 00000000..c1d0d1c8 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/woff.hoon @@ -0,0 +1,12 @@ +|_ dat=octs +++ grow + |% + ++ mime [/font/woff dat] + -- +++ grab + |% + ++ mime |=([=mite =octs] octs) + ++ noun octs + -- +++ grad %mime +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/woff2.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/woff2.hoon new file mode 100644 index 00000000..7e724290 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/woff2.hoon @@ -0,0 +1,12 @@ +|_ dat=octs +++ grow + |% + ++ mime [/font/woff2 dat] + -- +++ grab + |% + ++ mime |=([=mite =octs] octs) + ++ noun octs + -- +++ grad %mime +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/mar/xhtml.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/xhtml.hoon new file mode 100644 index 00000000..b9ec0020 --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/mar/xhtml.hoon @@ -0,0 +1,5 @@ +:: +:::: /hoon/xhtml/mar + :: +/= xhtml /mar/html +xhtml diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/sur/docket.hoon b/stack_orchestrator/data/config/vega-interface/urbit-files/sur/docket.hoon new file mode 100644 index 00000000..091c8c9f --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/sur/docket.hoon @@ -0,0 +1,82 @@ +|% +:: ++$ version + [major=@ud minor=@ud patch=@ud] +:: ++$ glob (map path mime) +:: ++$ url cord +:: $glob-location: How to retrieve a glob +:: ++$ glob-reference + [hash=@uvH location=glob-location] +:: ++$ glob-location + $% [%http =url] + [%ames =ship] + == +:: $href: Where a tile links to +:: ++$ href + $% [%glob base=term =glob-reference] + [%site =path] + == +:: $chad: State of a docket +:: ++$ chad + $~ [%install ~] + $% :: Done + [%glob =glob] + [%site ~] + :: Waiting + [%install ~] + [%suspend glob=(unit glob)] + :: Error + [%hung err=cord] + == +:: +:: $charge: A realized $docket +:: ++$ charge + $: =docket + =chad + == +:: +:: $clause: A key and value, as part of a docket +:: +:: Only used to parse $docket +:: ++$ clause + $% [%title title=@t] + [%info info=@t] + [%color color=@ux] + [%glob-http url=cord hash=@uvH] + [%glob-ames =ship hash=@uvH] + [%image =url] + [%site =path] + [%base base=term] + [%version =version] + [%website website=url] + [%license license=cord] + == +:: +:: $docket: A description of JS bundles for a desk +:: ++$ docket + $: %1 + title=@t + info=@t + color=@ux + =href + image=(unit url) + =version + website=url + license=cord + == +:: ++$ charge-update + $% [%initial initial=(map desk charge)] + [%add-charge =desk =charge] + [%del-charge =desk] + == +-- diff --git a/stack_orchestrator/data/config/vega-interface/urbit-files/sys.kelvin b/stack_orchestrator/data/config/vega-interface/urbit-files/sys.kelvin new file mode 100644 index 00000000..5d8a35da --- /dev/null +++ b/stack_orchestrator/data/config/vega-interface/urbit-files/sys.kelvin @@ -0,0 +1 @@ +[%zuse 412] diff --git a/stack_orchestrator/data/container-build/cerc-vega-interface/Dockerfile b/stack_orchestrator/data/container-build/cerc-vega-interface/Dockerfile new file mode 100644 index 00000000..a08374fc --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-vega-interface/Dockerfile @@ -0,0 +1,12 @@ +from node:20.9.0 + +# RUN apk --update --no-cache add git make alpine-sdk bash + +WORKDIR /app + +# Copy the Vega monorepo fork into `/app` +COPY . . + +RUN yarn +# RUN ./docker/prepare-dist.sh + diff --git a/stack_orchestrator/data/container-build/cerc-vega-interface/build.sh b/stack_orchestrator/data/container-build/cerc-vega-interface/build.sh new file mode 100755 index 00000000..f73985df --- /dev/null +++ b/stack_orchestrator/data/container-build/cerc-vega-interface/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Build the vega-interface image +source ${CERC_CONTAINER_BASE_DIR}/build-base.sh + +# See: https://stackoverflow.com/a/246128/1701505 +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +docker build \ + -t cerc/vega-interface:local \ + -f ${SCRIPT_DIR}/Dockerfile \ + ${build_command_args} \ + ${CERC_REPO_BASE_DIR}/vega-frontend-monorepo diff --git a/stack_orchestrator/data/container-image-list.txt b/stack_orchestrator/data/container-image-list.txt index fd295be5..1523390b 100644 --- a/stack_orchestrator/data/container-image-list.txt +++ b/stack_orchestrator/data/container-image-list.txt @@ -60,3 +60,4 @@ cerc/nitro-rpc-client cerc/watcher-merkl-sushiswap-v3 cerc/watcher-sushiswap-v3 cerc/uniswap-interface +cerc/vega-interface diff --git a/stack_orchestrator/data/pod-list.txt b/stack_orchestrator/data/pod-list.txt index 9ad000c7..fa2501a3 100644 --- a/stack_orchestrator/data/pod-list.txt +++ b/stack_orchestrator/data/pod-list.txt @@ -45,3 +45,4 @@ ponder ipld-eth-server-payments merkl-sushiswap-v3 sushiswap-v3 +vega-interface diff --git a/stack_orchestrator/data/repository-list.txt b/stack_orchestrator/data/repository-list.txt index cddaccce..d56a6c5a 100644 --- a/stack_orchestrator/data/repository-list.txt +++ b/stack_orchestrator/data/repository-list.txt @@ -50,3 +50,4 @@ github.com/cerc-io/ponder github.com/cerc-io/merkl-sushiswap-v3-watcher-ts github.com/cerc-io/sushiswap-v3-watcher-ts github.com/cerc-io/uniswap-interface +git.vdb.to/LaconicNetwork/vega-frontend-monorepo diff --git a/stack_orchestrator/data/stacks/uniswap-urbit-app/README.md b/stack_orchestrator/data/stacks/uniswap-urbit-app/README.md index 187d723f..813763ba 100644 --- a/stack_orchestrator/data/stacks/uniswap-urbit-app/README.md +++ b/stack_orchestrator/data/stacks/uniswap-urbit-app/README.md @@ -40,8 +40,6 @@ stack: uniswap-urbit-app deploy-to: compose network: ports: - proxy-server: - - '4000:4000' urbit-fake-ship: - '8080:80' ipfs: @@ -86,7 +84,8 @@ Inside the deployment directory, open the file `config.env` and set the followin # Set this to GQL proxy server endpoint for uniswap app # (Eg. http://localhost:4000/v1/graphql - in case stack is being run locally with proxy enabled) # (Eg. https://abc.xyz.com/v1/graphql - in case https://abc.xyz.com is pointed to the proxy endpoint) - CERC_UNISWAP_GQL=http://localhost:4000/v1/graphql + CERC_UNISWAP_GQL=/apps/uniswap-proxy/v1/graphql + CERC_UNISWAP_API=/apps/uniswap-proxy/v2 # Optional diff --git a/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml b/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml index 1e5ad3f5..a1a47815 100644 --- a/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml +++ b/stack_orchestrator/data/stacks/uniswap-urbit-app/stack.yml @@ -2,12 +2,9 @@ version: "0.1" name: uniswap-urbit-app repos: - github.com/cerc-io/uniswap-interface@laconic # TODO: Use release - - github.com/cerc-io/watcher-ts@v0.2.78 containers: - cerc/uniswap-interface - - cerc/watcher-ts pods: - uniswap-interface - - proxy-server - fixturenet-urbit - kubo diff --git a/stack_orchestrator/data/stacks/vega-urbit-app/README.md b/stack_orchestrator/data/stacks/vega-urbit-app/README.md new file mode 100644 index 00000000..bd426eeb --- /dev/null +++ b/stack_orchestrator/data/stacks/vega-urbit-app/README.md @@ -0,0 +1,131 @@ +# Self-hosted Vega Frontend + +Instructions to setup and deploy Vega app on Urbit + +Build and deploy: + +- Urbit +- Vega app + +## Setup + +Clone required repositories: + +```bash +laconic-so --stack vega-urbit-app setup-repositories --pull + +# If this throws an error as a result of being already checked out to a branch/tag in a repo, remove the repositories and re-run the command +``` + +Build the container images: + +```bash +laconic-so --stack vega-urbit-app build-containers +``` + +## Create a deployment + +First, create a spec file for the deployment, which will map the stack's ports and volumes to the host: + +```bash +laconic-so --stack vega-urbit-app deploy init --output vega-urbit-app-spec.yml +``` + +### Ports + +Edit `vega-urbit-app-spec.yml` such that it looks like: + +```yml +stack: vega-urbit-app +deploy-to: compose +network: + ports: + urbit-fake-ship: + - '8080:80' + ipfs: + - '4001' + - '8081:8080' + - 0.0.0.0:5001:5001 +volumes: + urbit_app_builds: ./data/urbit_app_builds + urbit_data: ./data/urbit_data + ipfs-import: ./data/ipfs-import + ipfs-data: ./data/ipfs-data +``` + +Note: Skip the `ipfs` ports if using an externally running IPFS node, set via `config.env`, below. + +### Data volumes + +Container data volumes are bind-mounted to specified paths in the host filesystem. +The default setup (generated by `laconic-so deploy init`) places the volumes in the `./data` subdirectory of the deployment directory. The default mappings can be customized by editing the "spec" file generated by `laconic-so deploy init`. + +--- + +Once you've made any needed changes to the spec file, create a deployment from it: + +```bash +laconic-so --stack vega-urbit-app deploy create --spec-file vega-urbit-app-spec.yml --deployment-dir vega-urbit-app-deployment +``` + +## Set env variables + +Inside the deployment directory, open the file `config.env` and set the following env variables: + + ```bash + # App to be installed (Do not change) + CERC_URBIT_APP=vega + ``` + +## Start the stack + +Start the deployment: + +```bash +laconic-so deployment --dir vega-urbit-app-deployment start +``` + +* List and check the health status of all the containers using `docker ps` and wait for them to be `healthy` + +* Run the following to get login password for Urbit web interface: + + ```bash + laconic-so deployment --dir vega-urbit-app-deployment exec urbit-fake-ship "curl -s --data '{\"source\":{\"dojo\":\"+code\"},\"sink\":{\"stdout\":null}}' http://localhost:12321" + + # Expected output: "\n"% + ``` + +* Open the Urbit web UI at http://localhost:8080 and use the `PASSWORD` from previous step to login + +* The vega app is not available when starting stack for the first time. Check `urbit-fake-ship` logs to see that app has installed: + + ```bash + laconic-so deployment --dir vega-urbit-app-deployment logs -f + + # Expected output: + # laconic-3ccf7ee79bdae874-urbit-fake-ship-1 | docket: fetching %http glob for %vega desk + # laconic-3ccf7ee79bdae874-urbit-fake-ship-1 | ">="">="vega app installed + ``` + +* The vega app will be now visible at http://localhost:8080 + +## Clean up + +To stop all vega-urbit-app services running in the background, while preserving data: + +```bash +# Only stop the docker containers +laconic-so deployment --dir vega-urbit-app-deployment stop + +# Run 'start' to restart the deployment +``` + +To stop all vega-urbit-app services and also delete data: + +```bash +# Stop the docker containers +laconic-so deployment --dir vega-urbit-app-deployment stop --delete-volumes + +# Remove deployment directory (deployment will have to be recreated for a re-run) +rm -r vega-urbit-app-deployment +``` diff --git a/stack_orchestrator/data/stacks/vega-urbit-app/stack.yml b/stack_orchestrator/data/stacks/vega-urbit-app/stack.yml new file mode 100755 index 00000000..e39002a6 --- /dev/null +++ b/stack_orchestrator/data/stacks/vega-urbit-app/stack.yml @@ -0,0 +1,10 @@ +version: "0.1" +name: vega-urbit-app +repos: + - git.vdb.to/LaconicNetwork/vega-frontend-monorepo@urbit-build +containers: + - cerc/vega-interface +pods: + - vega-interface + - fixturenet-urbit + - kubo