2021-05-03 14:35:21 +03:00
|
|
|
:: azimuth-rpc: command parsing and utilities
|
|
|
|
::
|
2021-04-29 12:14:32 +03:00
|
|
|
/- rpc=json-rpc
|
|
|
|
/+ naive
|
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
=> :: Utilities
|
|
|
|
::
|
|
|
|
|%
|
|
|
|
++ extract
|
|
|
|
|%
|
|
|
|
++ keys
|
|
|
|
|= params=(map @t json)
|
|
|
|
^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
|
|
|
?~ data=(~(get by params) 'data') ~
|
|
|
|
%. u.data
|
2021-05-04 11:08:44 +03:00
|
|
|
=, dejs-soft:format
|
2021-05-03 14:35:21 +03:00
|
|
|
%- ot
|
|
|
|
:~ ['encrypt' so]
|
|
|
|
['auth' so]
|
|
|
|
['crypto-suite' so]
|
|
|
|
['breach' bo]
|
|
|
|
==
|
2021-04-29 12:14:32 +03:00
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
++ address-ship
|
|
|
|
|= params=(map @t json)
|
|
|
|
^- (unit [@ux ship])
|
|
|
|
?~ data=(~(get by params) 'data') ~
|
2021-05-04 11:08:44 +03:00
|
|
|
=; ans=(unit [add=(unit @ux) =ship])
|
|
|
|
?~ ans ~
|
|
|
|
?~ add.u.ans ~
|
|
|
|
(some [u.add.u.ans ship.u.ans])
|
2021-05-03 14:35:21 +03:00
|
|
|
%. u.data
|
2021-05-04 11:08:44 +03:00
|
|
|
=, dejs-soft:format
|
2021-05-03 14:35:21 +03:00
|
|
|
%- ot
|
|
|
|
:~ ['address' (cu to-hex so)]
|
|
|
|
['ship' (su ;~(pfix sig fed:ag))]
|
2021-04-29 12:14:32 +03:00
|
|
|
==
|
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
++ address
|
|
|
|
|= params=(map @t json)
|
|
|
|
^- (unit @ux)
|
|
|
|
?~ data=(~(get by params) 'data') ~
|
2021-05-04 11:08:44 +03:00
|
|
|
=; ans=(unit (unit @ux))
|
|
|
|
?~ ans ~
|
|
|
|
?~ u.ans ~
|
|
|
|
(some u.u.ans)
|
|
|
|
=, dejs-soft:format
|
2021-05-03 14:35:21 +03:00
|
|
|
%. u.data
|
|
|
|
(ot ['address' (cu to-hex so)]~)
|
2021-05-04 11:08:44 +03:00
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
++ sig
|
|
|
|
|= params=(map @t json)
|
|
|
|
^- (unit @)
|
2021-05-04 11:08:44 +03:00
|
|
|
=, dejs-soft:format
|
2021-05-03 14:35:21 +03:00
|
|
|
?~ sig=(~(get by params) 'sig') ~
|
2021-05-04 11:08:44 +03:00
|
|
|
(so:dejs-soft:format u.sig)
|
2021-05-03 14:35:21 +03:00
|
|
|
::
|
|
|
|
++ from
|
|
|
|
|= params=(map @t json)
|
2021-05-06 09:14:04 +03:00
|
|
|
^- (unit [ship proxy:naive])
|
2021-05-03 14:35:21 +03:00
|
|
|
?~ from=(~(get by params) 'from') ~
|
2021-05-04 11:08:44 +03:00
|
|
|
=, dejs-soft:format
|
2021-05-03 14:35:21 +03:00
|
|
|
%. u.from
|
|
|
|
%- ot
|
|
|
|
:~ ['ship' (su ;~(pfix sig fed:ag))]
|
2021-05-06 09:14:04 +03:00
|
|
|
['proxy' (cu proxy:naive so)]
|
2021-05-03 14:35:21 +03:00
|
|
|
==
|
|
|
|
--
|
2021-04-29 12:14:32 +03:00
|
|
|
::
|
2021-05-03 14:35:21 +03:00
|
|
|
++ point-to-json
|
|
|
|
|= =point:naive
|
2021-04-29 12:14:32 +03:00
|
|
|
^- json
|
2021-05-04 11:36:50 +03:00
|
|
|
=, enjs:format
|
2021-05-03 14:35:21 +03:00
|
|
|
|^
|
2021-05-04 11:36:50 +03:00
|
|
|
%- pairs
|
2021-05-03 14:35:21 +03:00
|
|
|
:~ ['dominion' s+dominion.point]
|
|
|
|
::
|
|
|
|
:- 'ownership'
|
2021-05-04 11:36:50 +03:00
|
|
|
%- pairs
|
2021-05-03 14:35:21 +03:00
|
|
|
=* own own.point
|
|
|
|
^- (list [@t json])
|
|
|
|
:~ ['owner' (own-to-json owner.own)]
|
|
|
|
['spawnProxy' (own-to-json spawn-proxy.own)]
|
|
|
|
['managementProxy' (own-to-json management-proxy.own)]
|
|
|
|
['votingProxy' (own-to-json voting-proxy.own)]
|
|
|
|
['transferProxy' (own-to-json transfer-proxy.own)]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:- 'network'
|
2021-05-04 11:36:50 +03:00
|
|
|
%- pairs
|
2021-05-03 14:35:21 +03:00
|
|
|
=* net net.point
|
|
|
|
:* ['rift' (numb rift.net)]
|
|
|
|
::
|
|
|
|
:- 'keys'
|
2021-05-04 11:36:50 +03:00
|
|
|
%- pairs
|
2021-05-03 14:35:21 +03:00
|
|
|
:~ ['life' (numb life.keys.net)]
|
|
|
|
['suite' (numb suite.keys.net)]
|
|
|
|
['auth' (numb auth.keys.net)]
|
|
|
|
['crypt' (numb crypt.keys.net)]
|
|
|
|
==
|
|
|
|
::
|
|
|
|
['rift' (numb rift.net)]
|
|
|
|
:- 'sponsor'
|
2021-05-04 11:36:50 +03:00
|
|
|
%- pairs
|
2021-05-03 14:35:21 +03:00
|
|
|
~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]]
|
|
|
|
::
|
|
|
|
?~ escape.net ~
|
|
|
|
['escape' (ship u.escape.net)]~
|
|
|
|
== ==
|
|
|
|
::
|
|
|
|
++ own-to-json
|
|
|
|
|= [=address:naive =nonce:naive]
|
|
|
|
^- json
|
2021-05-04 11:36:50 +03:00
|
|
|
%- pairs
|
2021-05-03 14:35:21 +03:00
|
|
|
:~ ['address' s+(crip "0x{((x-co:co 20) address)}")]
|
|
|
|
['nonce' (numb:enjs:format nonce)]
|
|
|
|
==
|
|
|
|
--
|
|
|
|
::
|
|
|
|
++ to-hex
|
|
|
|
|= =cord
|
|
|
|
^- (unit @ux)
|
|
|
|
=/ parsed=(unit (pair @ud @ux)) (de:base16:mimes:html cord)
|
|
|
|
?~ parsed
|
|
|
|
::~|(%non-hex-cord !!)
|
|
|
|
~
|
|
|
|
(some q.u.parsed)
|
|
|
|
::
|
|
|
|
++ sponsor-call
|
|
|
|
|= [id=@t params=(map @t json)]
|
2021-05-04 11:08:44 +03:00
|
|
|
^- [(unit cage) response:rpc]
|
|
|
|
?. =((lent ~(tap by params)) 3)
|
|
|
|
[~ ~(params error id)]
|
2021-05-03 14:35:21 +03:00
|
|
|
=/ sig=(unit @) (sig:extract params)
|
|
|
|
=/ from=(unit [ship @t]) (from:extract params)
|
|
|
|
=/ data=(unit [@ux ship]) (address-ship:extract params)
|
2021-05-04 11:08:44 +03:00
|
|
|
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
|
|
|
[~ ~(parse error id)]
|
2021-05-03 14:35:21 +03:00
|
|
|
:_ [%result id s+'ok']
|
|
|
|
%- some
|
|
|
|
noun+!>([u.sig u.from u.data])
|
|
|
|
::
|
|
|
|
++ proxy-call
|
|
|
|
|= [id=@t params=(map @t json)]
|
|
|
|
^- [(unit cage) response:rpc]
|
2021-05-04 11:08:44 +03:00
|
|
|
?. =((lent ~(tap by params)) 3)
|
|
|
|
[~ ~(params error id)]
|
2021-05-03 14:35:21 +03:00
|
|
|
=/ sig=(unit @) (sig:extract params)
|
|
|
|
=/ from=(unit [ship @t]) (from:extract params)
|
|
|
|
=/ data=(unit @ux) (address:extract params)
|
2021-05-04 11:08:44 +03:00
|
|
|
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
|
|
|
[~ ~(parse error id)]
|
2021-05-03 14:35:21 +03:00
|
|
|
:_ [%result id s+'ok']
|
|
|
|
%- some
|
|
|
|
noun+!>([u.sig u.from u.data])
|
2021-05-04 11:08:44 +03:00
|
|
|
::
|
|
|
|
++ error
|
|
|
|
|_ id=@t
|
|
|
|
:: https://www.jsonrpc.org/specification#error_object
|
|
|
|
::
|
|
|
|
++ parse [%error id '-32700' 'Failed to parsed']
|
|
|
|
++ request [%error id '-32600' 'Invalid Request']
|
|
|
|
++ method [%error id '-32601' 'Method not found']
|
|
|
|
++ params [%error id '-32602' 'Invalid params']
|
|
|
|
++ internal [%error id '-32603' 'Internal error']
|
|
|
|
--
|
2021-04-29 12:14:32 +03:00
|
|
|
--
|
2021-05-03 14:35:21 +03:00
|
|
|
|%
|
|
|
|
++ get-point
|
|
|
|
|= [id=@t params=(map @t json) scry=$-(ship (unit point:naive))]
|
|
|
|
^- response:rpc
|
2021-05-04 11:08:44 +03:00
|
|
|
?. =((lent ~(tap by params)) 1)
|
|
|
|
~(params error id)
|
|
|
|
?~ ship=(~(get by params) 'ship')
|
|
|
|
~(params error id)
|
2021-05-03 14:35:21 +03:00
|
|
|
?~ ship=(rush (so:dejs:format u.ship) ;~(pfix sig fed:ag))
|
2021-05-04 11:08:44 +03:00
|
|
|
~(params error id)
|
|
|
|
?~ point=(scry u.ship)
|
|
|
|
~(params error id)
|
2021-05-03 14:35:21 +03:00
|
|
|
[%result id (point-to-json u.point)]
|
|
|
|
::
|
|
|
|
++ transfer-point
|
|
|
|
|= [id=@t params=(map @t json)]
|
|
|
|
^- [(unit cage) response:rpc]
|
2021-05-04 11:08:44 +03:00
|
|
|
?. =((lent ~(tap by params)) 3)
|
|
|
|
[~ ~(params error id)]
|
|
|
|
=/ sig=(unit @) (sig:extract params)
|
|
|
|
=/ from=(unit [ship @t]) (from:extract params)
|
2021-05-03 14:35:21 +03:00
|
|
|
=/ data=(unit [@ux ?])
|
|
|
|
?~ data=(~(get by params) 'data') ~
|
|
|
|
=; [add=(unit @ux) r=?]
|
|
|
|
?~ add ~
|
|
|
|
(some [u.add r])
|
|
|
|
%. u.data
|
2021-05-04 11:08:44 +03:00
|
|
|
=, dejs:format
|
2021-05-03 14:35:21 +03:00
|
|
|
%- ot
|
|
|
|
~[['address' (cu to-hex so)] ['reset' bo]]
|
2021-05-04 11:08:44 +03:00
|
|
|
?: |(?=(~ sig) ?=(~ from) ?=(~ data))
|
|
|
|
[~ ~(parse error id)]
|
2021-05-03 14:35:21 +03:00
|
|
|
:_ [%result id s+'ok']
|
|
|
|
%- some
|
|
|
|
noun+!>([u.sig u.from u.data])
|
|
|
|
::
|
|
|
|
++ configure-keys
|
|
|
|
|= [id=@t params=(map @t json)]
|
|
|
|
^- [(unit cage) response:rpc]
|
2021-05-04 11:08:44 +03:00
|
|
|
?. =((lent ~(tap by params)) 3)
|
|
|
|
[~ ~(params error id)]
|
2021-05-03 14:35:21 +03:00
|
|
|
=/ sig=(unit @) (sig:extract params)
|
|
|
|
=/ from=(unit [ship @t]) (from:extract params)
|
|
|
|
=/ data=(unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
|
|
|
(keys:extract params)
|
2021-05-04 11:08:44 +03:00
|
|
|
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
|
|
|
[~ ~(parse error id)]
|
2021-05-03 14:35:21 +03:00
|
|
|
:_ [%result id s+'ok']
|
|
|
|
%- some
|
|
|
|
noun+!>([u.sig u.from u.data])
|
|
|
|
::
|
|
|
|
++ spawn sponsor-call
|
|
|
|
++ escape sponsor-call
|
|
|
|
++ cancel-escape sponsor-call
|
|
|
|
++ adopt sponsor-call
|
|
|
|
++ detach sponsor-call
|
|
|
|
++ reject sponsor-call
|
|
|
|
++ management-proxy proxy-call
|
|
|
|
++ spawn-proxy proxy-call
|
|
|
|
++ transfer-proxy proxy-call
|
|
|
|
--
|