mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 13:54:20 +03:00
Merge branch 'yu/azimuth-rpc' into naive/aggregator
This commit is contained in:
commit
9e7cb91398
@ -90,7 +90,7 @@
|
||||
?~ data ~
|
||||
:_ ~
|
||||
^- card
|
||||
[%pass / %agent [our.bowl %dice] %poke u.data]
|
||||
[%pass / %agent [our.bowl %aggregator] %poke u.data]
|
||||
:: TODO: validate that format is e.g. 'getPoint'
|
||||
:: TODO: maybe use getPoint and translate to %get-point
|
||||
::
|
||||
@ -138,14 +138,14 @@
|
||||
%transfer-point (transfer-point id +.params)
|
||||
%configure-keys (configure-keys id +.params)
|
||||
%spawn (spawn id +.params)
|
||||
%escape (escape id +.params)
|
||||
%cancel-escape (cancel-escape id +.params)
|
||||
%adopt (adopt id +.params)
|
||||
%detach (detach id +.params)
|
||||
%reject (reject id +.params)
|
||||
%set-management-proxy (management-proxy id +.params)
|
||||
%set-spawn-proxy (spawn-proxy id +.params)
|
||||
%set-transfer-proxy (transfer-proxy id +.params)
|
||||
%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)
|
||||
%pending [~ (all:pending id +.params all:pending:scry)]
|
||||
%pending-by-ship [~ (ship:pending id +.params ship:pending:scry)]
|
||||
%pending-by-address [~ (addr:pending id +.params addr:pending:scry)]
|
||||
@ -167,21 +167,21 @@
|
||||
++ all
|
||||
.^ (list pend-tx)
|
||||
%gx
|
||||
(~(scry agentio bowl) %dice /pending/noun)
|
||||
(~(scry agentio bowl) %aggregator /pending/noun)
|
||||
==
|
||||
::
|
||||
++ ship
|
||||
|= =^ship
|
||||
.^ (list pend-tx)
|
||||
%gx
|
||||
(~(scry agentio bowl) %dice /pending/[(scot %p ship)]/noun)
|
||||
(~(scry agentio bowl) %aggregator /pending/[(scot %p ship)]/noun)
|
||||
==
|
||||
::
|
||||
++ addr
|
||||
|= =address:naive
|
||||
.^ (list pend-tx)
|
||||
%gx
|
||||
%+ ~(scry agentio bowl) %dice
|
||||
%+ ~(scry agentio bowl) %aggregator
|
||||
/pending/[(scot %ux address)]/noun
|
||||
==
|
||||
--
|
||||
@ -193,7 +193,7 @@
|
||||
::
|
||||
.^ (list tx:naive)
|
||||
%gx
|
||||
(~(scry agentio bowl) %dice /history/noun)
|
||||
(~(scry agentio bowl) %aggregator /history/noun)
|
||||
==
|
||||
::
|
||||
++ ship
|
||||
@ -202,7 +202,7 @@
|
||||
::
|
||||
.^ (list tx:naive)
|
||||
%gx
|
||||
(~(scry agentio bowl) %dice /history/[(scot %p ship)]/noun)
|
||||
(~(scry agentio bowl) %aggregator /history/[(scot %p ship)]/noun)
|
||||
==
|
||||
::
|
||||
++ addr
|
||||
@ -211,7 +211,7 @@
|
||||
::
|
||||
.^ (list tx:naive)
|
||||
%gx
|
||||
(~(scry agentio bowl) %dice /history/[(scot %ux address)]/noun)
|
||||
(~(scry agentio bowl) %aggregator /history/[(scot %ux address)]/noun)
|
||||
==
|
||||
--
|
||||
::
|
||||
@ -219,7 +219,7 @@
|
||||
|= keccak=@ux
|
||||
.^ ^tx-status
|
||||
%gx
|
||||
(~(scry agentio bowl) %dice /tx/[(scot %ux keccak)]/status/noun)
|
||||
(~(scry agentio bowl) %aggregator /tx/[(scot %ux keccak)]/status/noun)
|
||||
==
|
||||
::
|
||||
++ nonce
|
||||
@ -228,7 +228,7 @@
|
||||
.^ @
|
||||
%gx
|
||||
%+ ~(scry agentio bowl)
|
||||
%dice
|
||||
%aggregator
|
||||
/nonce/[(scot %p ship)]/[(scot %ux address)]/atom
|
||||
==
|
||||
--
|
||||
|
@ -6,6 +6,19 @@
|
||||
=> :: Utilities
|
||||
::
|
||||
|%
|
||||
+$ spawn-action
|
||||
$? %escape
|
||||
%cancel-escape
|
||||
%adopt
|
||||
%reject
|
||||
%detach
|
||||
==
|
||||
::
|
||||
+$ proxy-action
|
||||
$? %set-management-proxy
|
||||
%set-spawn-proxy
|
||||
%set-transfer-proxy
|
||||
==
|
||||
:: FIXME: import tx-status, pend-tx from aggregator
|
||||
::
|
||||
+$ tx-status
|
||||
@ -30,6 +43,8 @@
|
||||
['breach' bo]
|
||||
==
|
||||
::
|
||||
++ data
|
||||
|%
|
||||
++ address-transfer
|
||||
|= params=(map @t json)
|
||||
^- (unit [@ux ?])
|
||||
@ -45,17 +60,17 @@
|
||||
::
|
||||
++ address-ship
|
||||
|= params=(map @t json)
|
||||
^- (unit [@ux @p])
|
||||
^- (unit [@p @ux])
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
=; ans=(unit [add=(unit @ux) ship=@p])
|
||||
=; ans=(unit [ship=@p add=(unit @ux)])
|
||||
?~ ans ~
|
||||
?~ add.u.ans ~
|
||||
(some [u.add.u.ans ship.u.ans])
|
||||
(some [ship.u.ans u.add.u.ans])
|
||||
%. u.data
|
||||
=, dejs-soft:format
|
||||
%- ot
|
||||
:~ ['address' (cu to-hex so)]
|
||||
['ship' (su ;~(pfix sig fed:ag))]
|
||||
:~ ['ship' (su ;~(pfix sig fed:ag))]
|
||||
['address' (cu to-hex so)]
|
||||
==
|
||||
::
|
||||
++ address
|
||||
@ -75,6 +90,24 @@
|
||||
=, dejs-soft:format
|
||||
%. u.data
|
||||
(ot ['ship' (su ;~(pfix sig fed:ag))]~)
|
||||
--
|
||||
::
|
||||
++ ship
|
||||
|= params=(map @t json)
|
||||
^- (unit @p)
|
||||
?~ data=(~(get by params) 'ship') ~
|
||||
=, dejs-soft:format
|
||||
%. u.data
|
||||
(su ;~(pfix sig fed:ag))
|
||||
::
|
||||
++ address
|
||||
|= params=(map @t json)
|
||||
^- (unit @ux)
|
||||
?~ data=(~(get by params) 'address') ~
|
||||
=; ans=(unit (unit @ux))
|
||||
?~(ans ~ u.ans)
|
||||
=, dejs-soft:format
|
||||
((cu to-hex so) u.data)
|
||||
::
|
||||
++ sig
|
||||
|= params=(map @t json)
|
||||
@ -101,6 +134,17 @@
|
||||
?~(ans ~ u.ans)
|
||||
=, dejs-soft:format
|
||||
((cu to-hex so) u.keccak)
|
||||
::
|
||||
++ raw
|
||||
|= params=(map @t json)
|
||||
^- (unit octs)
|
||||
?~ raw=(~(get by params) 'raw') ~
|
||||
=; ans=(unit (unit @ux))
|
||||
?~ ans ~
|
||||
?~ u.ans ~
|
||||
(some (as-octs:mimes:html u.u.ans))
|
||||
=, dejs-soft:format
|
||||
((cu to-hex so) u.raw)
|
||||
--
|
||||
::
|
||||
++ to-json
|
||||
@ -251,33 +295,52 @@
|
||||
++ rpc-res
|
||||
|%
|
||||
++ sponsor
|
||||
|= [id=@t params=(map @t json)]
|
||||
|= [id=@t params=(map @t json) action=spawn-action]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. =((lent ~(tap by params)) 3)
|
||||
?. (params:validate params)
|
||||
[~ ~(params error id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [@p proxy:naive]) (from:from-json params)
|
||||
=/ data=(unit [@ux @p]) (address-ship:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
||||
=/ raw=(unit octs) (raw:from-json params)
|
||||
=/ data=(unit @p) (ship:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data))
|
||||
[~ ~(parse error id)]
|
||||
:_ [%result id s+'ok']
|
||||
%- some
|
||||
noun+!>([u.sig u.from u.data])
|
||||
:- %aggregator-action
|
||||
!>
|
||||
=; =skim-tx:naive
|
||||
[%submit | u.sig %ful u.raw u.from skim-tx]
|
||||
?- action
|
||||
%escape [%escape u.data]
|
||||
%cancel-escape [%cancel-escape u.data]
|
||||
%adopt [%adopt u.data]
|
||||
%reject [%reject u.data]
|
||||
%detach [%detach u.data]
|
||||
==
|
||||
::
|
||||
++ proxy
|
||||
|= [id=@t params=(map @t json)]
|
||||
|= [id=@t params=(map @t json) action=proxy-action]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. =((lent ~(tap by params)) 3)
|
||||
?. (params:validate params)
|
||||
[~ ~(params error id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [@p proxy:naive]) (from:from-json params)
|
||||
=/ data=(unit @ux) (address:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
||||
=/ raw=(unit octs) (raw:from-json params)
|
||||
=/ data=(unit @ux) (address:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data))
|
||||
[~ ~(parse error id)]
|
||||
:_ [%result id s+'ok']
|
||||
%- some
|
||||
noun+!>([u.sig u.from u.data])
|
||||
::
|
||||
:- %aggregator-action
|
||||
!>
|
||||
=; =skim-tx:naive
|
||||
[%submit | u.sig %ful u.raw u.from skim-tx]
|
||||
?- action
|
||||
%set-management-proxy [%set-management-proxy u.data]
|
||||
%set-spawn-proxy [%set-spawn-proxy u.data]
|
||||
%set-transfer-proxy [%set-transfer-proxy u.data]
|
||||
==
|
||||
--
|
||||
::
|
||||
++ error
|
||||
@ -291,6 +354,14 @@
|
||||
++ internal [%error id '-32603' 'Internal error']
|
||||
++ not-found [%error id '-32000' 'Resource not found']
|
||||
--
|
||||
::
|
||||
++ validate
|
||||
|%
|
||||
++ params
|
||||
|= params=(map @t json)
|
||||
^- ?
|
||||
=((lent ~(tap by params)) 4)
|
||||
--
|
||||
--
|
||||
|%
|
||||
++ get-point
|
||||
@ -309,12 +380,13 @@
|
||||
++ transfer-point
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. =((lent ~(tap by params)) 3)
|
||||
?. (params:validate params)
|
||||
[~ ~(params error id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [ship @t]) (from:from-json params)
|
||||
=/ data=(unit [@ux ?]) (address-transfer:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ data))
|
||||
=/ raw=(unit octs) (raw:from-json params)
|
||||
=/ data=(unit [@ux ?]) (address-transfer:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ raw) ?=(~ data))
|
||||
[~ ~(parse error id)]
|
||||
:_ [%result id s+'ok']
|
||||
%- some
|
||||
@ -323,19 +395,34 @@
|
||||
++ configure-keys
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. =((lent ~(tap by params)) 3)
|
||||
?. (params:validate params)
|
||||
[~ ~(params error id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [ship @t]) (from:from-json params)
|
||||
=/ raw=(unit octs) (raw:from-json params)
|
||||
=/ data=(unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
||||
(keys:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
||||
(keys:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data))
|
||||
[~ ~(parse error id)]
|
||||
:_ [%result id s+'ok']
|
||||
%- some
|
||||
noun+!>([u.sig u.from u.data])
|
||||
::
|
||||
++ spawn sponsor:rpc-res
|
||||
++ spawn
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. (params:validate params)
|
||||
[~ ~(params error id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [@p proxy:naive]) (from:from-json params)
|
||||
=/ raw=(unit octs) (raw:from-json params)
|
||||
=/ data=(unit [@p @ux]) (address-ship:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ raw) ?=(^ data))
|
||||
[~ ~(parse error id)]
|
||||
:_ [%result id s+'ok']
|
||||
%- some
|
||||
aggregator-action+!>([%submit | u.sig %ful u.raw u.from %spawn u.data])
|
||||
::
|
||||
++ escape sponsor:rpc-res
|
||||
++ cancel-escape sponsor:rpc-res
|
||||
++ adopt sponsor:rpc-res
|
||||
|
Loading…
Reference in New Issue
Block a user