2021-05-11 14:28:26 +03:00
|
|
|
:: Azimuth JSON-RPC API
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
2021-05-21 16:07:08 +03:00
|
|
|
/- rpc=json-rpc, *aggregator
|
2021-04-29 12:14:32 +03:00
|
|
|
/+ naive,
|
|
|
|
azimuth-rpc,
|
|
|
|
json-rpc,
|
|
|
|
*server,
|
|
|
|
default-agent,
|
|
|
|
verb,
|
|
|
|
dbug,
|
2021-04-29 13:10:58 +03:00
|
|
|
version,
|
|
|
|
agentio
|
2021-04-25 16:37:40 +03:00
|
|
|
|%
|
2021-05-11 14:28:26 +03:00
|
|
|
::
|
2021-04-25 16:37:40 +03:00
|
|
|
+$ card card:agent:gall
|
|
|
|
::
|
|
|
|
+$ state-0 [%0 ~]
|
|
|
|
--
|
|
|
|
::
|
|
|
|
%+ verb |
|
|
|
|
%- agent:dbug
|
|
|
|
::
|
|
|
|
=| state-0
|
2021-05-21 13:34:29 +03:00
|
|
|
=* state -
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
|
|
|
^- agent:gall
|
|
|
|
=<
|
|
|
|
|_ =bowl:gall
|
|
|
|
+* this .
|
|
|
|
do ~(. +> bowl)
|
|
|
|
def ~(. (default-agent this %|) bowl)
|
|
|
|
::
|
|
|
|
++ on-init
|
|
|
|
^- (quip card _this)
|
|
|
|
~& > 'init'
|
|
|
|
:_ this
|
2021-05-21 13:28:54 +03:00
|
|
|
[%pass /bind %arvo %e %connect [~ /v1/azimuth] dap.bowl]~
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
|
|
|
++ on-save !>(state)
|
|
|
|
++ on-load
|
|
|
|
|= old=vase
|
|
|
|
^- (quip card _this)
|
|
|
|
[~ this(state !<(state-0 old))]
|
|
|
|
::
|
|
|
|
++ on-poke
|
|
|
|
|= [=mark =vase]
|
|
|
|
^- (quip card _this)
|
|
|
|
|^
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
?+ mark (on-poke:def mark vase)
|
|
|
|
%handle-http-request
|
|
|
|
=+ !<([id=@ta req=inbound-request:eyre] vase)
|
|
|
|
:_ this
|
2021-05-03 14:35:21 +03:00
|
|
|
(handle-http-request id req)
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
|
|
|
%azimuth-action
|
|
|
|
=+ !<([%disconnect bind=binding:eyre] vase)
|
|
|
|
~& >>> "disconnecting at {<bind>}"
|
|
|
|
:_ this
|
2021-05-21 13:34:29 +03:00
|
|
|
[%pass /bind %arvo %e %disconnect bind]~
|
2021-04-25 16:37:40 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ handle-http-request
|
2021-05-03 14:35:21 +03:00
|
|
|
|= [id=@ta =inbound-request:eyre]
|
|
|
|
^- (list card)
|
2021-04-25 16:37:40 +03:00
|
|
|
|^
|
|
|
|
=* req request.inbound-request
|
|
|
|
=* headers header-list.req
|
|
|
|
=/ req-line (parse-request-line url.req)
|
|
|
|
?. =(method.req %'POST')
|
|
|
|
:: TODO: method not supported
|
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
(give-simple-payload:app id not-found:gen)
|
2021-04-29 12:23:50 +03:00
|
|
|
?~ rpc-request=(validate-request:json-rpc body.req parse-method)
|
2021-04-25 16:37:40 +03:00
|
|
|
:: TODO: malformed request
|
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
(give-simple-payload:app id not-found:gen)
|
|
|
|
=/ [data=(unit cage) response=simple-payload:http]
|
|
|
|
(process-rpc-request:do u.rpc-request)
|
|
|
|
%+ weld
|
|
|
|
(give-simple-payload:app id response)
|
|
|
|
?~ data ~
|
|
|
|
:_ ~
|
|
|
|
^- card
|
2021-05-17 18:49:41 +03:00
|
|
|
[%pass / %agent [our.bowl %aggregator] %poke u.data]
|
2021-04-29 12:23:50 +03:00
|
|
|
:: TODO: validate that format is e.g. 'getPoint'
|
|
|
|
:: TODO: maybe use getPoint and translate to %get-point
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
++ parse-method |=(t=@t `term`t)
|
2021-04-25 16:37:40 +03:00
|
|
|
--
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ on-watch
|
|
|
|
|= =path
|
|
|
|
^- (quip card _this)
|
|
|
|
?> (team:title our.bowl src.bowl)
|
|
|
|
?+ path (on-watch:def path)
|
|
|
|
[%http-response *] [~ this]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-arvo
|
|
|
|
|= [=wire =sign-arvo]
|
|
|
|
^- (quip card _this)
|
|
|
|
?+ sign-arvo (on-arvo:def wire sign-arvo)
|
|
|
|
[%eyre %bound *]
|
|
|
|
~? !accepted.sign-arvo
|
|
|
|
[dap.bowl 'bind rejected!' binding.sign-arvo]
|
|
|
|
[~ this]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
++ on-leave on-leave:def
|
|
|
|
++ on-peek on-peek:def
|
|
|
|
++ on-agent on-agent:def
|
|
|
|
++ on-fail on-fail:def
|
|
|
|
--
|
|
|
|
::
|
|
|
|
|_ =bowl:gall
|
|
|
|
++ process-rpc-request
|
2021-05-03 14:35:21 +03:00
|
|
|
|= request:rpc
|
|
|
|
^- [(unit cage) simple-payload:http]
|
|
|
|
=; [data=(unit cage) =response:rpc]
|
|
|
|
:- data
|
2021-04-25 16:37:40 +03:00
|
|
|
%- json-response:gen
|
2021-05-03 14:35:21 +03:00
|
|
|
(response-to-json:json-rpc response)
|
|
|
|
=, azimuth-rpc
|
2021-05-21 13:34:29 +03:00
|
|
|
?. ?=([%map *] params)
|
2021-05-21 14:39:06 +03:00
|
|
|
[~ ~(parse error:json-rpc id)]
|
|
|
|
?+ method [~ ~(method error:json-rpc id)]
|
2021-05-11 14:28:26 +03:00
|
|
|
%get-point [~ (get-point id +.params point:scry)]
|
2021-06-04 12:41:59 +03:00
|
|
|
%get-spawned [~ (get-spawned id +.params spawned:scry)]
|
2021-05-03 14:35:21 +03:00
|
|
|
%transfer-point (transfer-point id +.params)
|
|
|
|
%configure-keys (configure-keys id +.params)
|
|
|
|
%spawn (spawn id +.params)
|
2021-05-17 18:49:41 +03:00
|
|
|
%escape (escape id +.params method)
|
|
|
|
%cancel-escape (cancel-escape id +.params method)
|
|
|
|
%adopt (adopt id +.params method)
|
|
|
|
%detach (detach id +.params method)
|
|
|
|
%reject (reject id +.params method)
|
|
|
|
%set-management-proxy (management-proxy id +.params method)
|
|
|
|
%set-spawn-proxy (spawn-proxy id +.params method)
|
|
|
|
%set-transfer-proxy (transfer-proxy id +.params method)
|
2021-05-11 14:28:26 +03:00
|
|
|
%pending [~ (all:pending id +.params all:pending:scry)]
|
2021-05-21 13:34:29 +03:00
|
|
|
%pending-by-ship [~ (ship:pending id +.params ship:pending:scry)]
|
|
|
|
%pending-by-address [~ (addr:pending id +.params addr:pending:scry)]
|
|
|
|
%status [~ (status id +.params tx-status:scry)]
|
|
|
|
:: %history [~ (history id +.params all:history:scry)]
|
2021-05-03 14:35:21 +03:00
|
|
|
==
|
2021-04-25 16:37:40 +03:00
|
|
|
::
|
2021-05-11 14:28:26 +03:00
|
|
|
++ scry
|
2021-05-06 14:20:13 +03:00
|
|
|
|%
|
2021-05-11 14:28:26 +03:00
|
|
|
++ point
|
|
|
|
|= =ship
|
2021-05-21 13:34:29 +03:00
|
|
|
.^ (unit point:naive)
|
|
|
|
%gx
|
2021-05-21 14:00:45 +03:00
|
|
|
(~(scry agentio bowl) %azimuth /nas/(scot %p ship)/noun)
|
2021-05-06 14:20:13 +03:00
|
|
|
==
|
2021-05-11 14:28:26 +03:00
|
|
|
::
|
2021-06-04 12:41:59 +03:00
|
|
|
++ spawned
|
|
|
|
|= =ship
|
|
|
|
.^ (list [@p @ux])
|
|
|
|
%gx
|
|
|
|
(~(scry agentio bowl) %aggregator /spawned/(scot %p ship)/noun)
|
|
|
|
==
|
|
|
|
::
|
2021-05-11 14:28:26 +03:00
|
|
|
++ pending
|
|
|
|
|%
|
|
|
|
++ all
|
2021-05-21 13:34:29 +03:00
|
|
|
.^ (list pend-tx)
|
|
|
|
%gx
|
2021-05-17 18:49:41 +03:00
|
|
|
(~(scry agentio bowl) %aggregator /pending/noun)
|
2021-05-11 14:28:26 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ ship
|
|
|
|
|= =^ship
|
|
|
|
.^ (list pend-tx)
|
2021-05-21 13:34:29 +03:00
|
|
|
%gx
|
2021-05-21 14:00:45 +03:00
|
|
|
(~(scry agentio bowl) %aggregator /pending/(scot %p ship)/noun)
|
2021-05-11 14:28:26 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
++ addr
|
|
|
|
|= =address:naive
|
|
|
|
.^ (list pend-tx)
|
2021-05-21 13:34:29 +03:00
|
|
|
%gx
|
2021-05-17 18:49:41 +03:00
|
|
|
%+ ~(scry agentio bowl) %aggregator
|
2021-05-11 14:28:26 +03:00
|
|
|
/pending/[(scot %ux address)]/noun
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ history
|
|
|
|
|%
|
|
|
|
++ all
|
|
|
|
:: FIXME: use proper type from aggregator/index
|
|
|
|
::
|
|
|
|
.^ (list tx:naive)
|
2021-05-21 13:34:29 +03:00
|
|
|
%gx
|
2021-05-17 18:49:41 +03:00
|
|
|
(~(scry agentio bowl) %aggregator /history/noun)
|
2021-05-21 13:34:29 +03:00
|
|
|
==
|
2021-05-11 14:28:26 +03:00
|
|
|
::
|
|
|
|
++ ship
|
|
|
|
|= =^ship
|
|
|
|
:: FIXME: use proper type from aggregator/index
|
|
|
|
::
|
|
|
|
.^ (list tx:naive)
|
2021-05-21 13:34:29 +03:00
|
|
|
%gx
|
2021-05-21 14:00:45 +03:00
|
|
|
(~(scry agentio bowl) %aggregator /history/(scot %p ship)/noun)
|
2021-05-21 13:34:29 +03:00
|
|
|
==
|
2021-05-11 14:28:26 +03:00
|
|
|
::
|
|
|
|
++ addr
|
|
|
|
|= =address:naive
|
|
|
|
:: FIXME: use proper type from aggregator/index
|
|
|
|
::
|
|
|
|
.^ (list tx:naive)
|
2021-05-21 13:34:29 +03:00
|
|
|
%gx
|
2021-05-21 14:00:45 +03:00
|
|
|
(~(scry agentio bowl) %aggregator /history/(scot %ux address)/noun)
|
2021-05-21 13:34:29 +03:00
|
|
|
==
|
2021-05-11 14:28:26 +03:00
|
|
|
--
|
|
|
|
::
|
|
|
|
++ tx-status
|
|
|
|
|= keccak=@ux
|
|
|
|
.^ ^tx-status
|
2021-05-21 13:34:29 +03:00
|
|
|
%gx
|
2021-05-21 14:00:45 +03:00
|
|
|
(~(scry agentio bowl) %aggregator /tx/(scot %ux keccak)/status/noun)
|
2021-05-06 14:20:13 +03:00
|
|
|
==
|
2021-05-06 17:47:38 +03:00
|
|
|
::
|
2021-05-11 14:28:26 +03:00
|
|
|
++ nonce
|
|
|
|
|= [=ship =address:naive]
|
|
|
|
:: FIXME: use proper type from aggregator/index
|
|
|
|
.^ @
|
2021-05-21 13:34:29 +03:00
|
|
|
%gx
|
|
|
|
%+ ~(scry agentio bowl)
|
2021-05-17 18:49:41 +03:00
|
|
|
%aggregator
|
2021-05-21 14:00:45 +03:00
|
|
|
/nonce/(scot %p ship)/[(scot %ux address)]/atom
|
2021-05-11 14:28:26 +03:00
|
|
|
==
|
|
|
|
--
|
2021-04-25 16:37:40 +03:00
|
|
|
--
|