naive: add %noncefrom ship/proxy to rpc-api

This commit is contained in:
yosoyubik 2021-06-14 14:18:57 +02:00
parent e513768b90
commit 0573232726
3 changed files with 20 additions and 19 deletions

View File

@ -131,7 +131,7 @@
:: /x/pending/[~ship] -> %noun (list pend-tx)
:: /x/pending/[0xadd.ress] -> %noun (list pend-tx)
:: /x/tx/[0xke.ccak]/status -> %noun tx-status
:: /x/nonce/[~ship]/[0xadd.ress] -> %atom @
:: /x/nonce/[~ship]/[proxy] -> %noun (unit @)
:: /x/spawned/[~ship] -> %noun (list [ship address)
:: /x/next-batch -> %atom time
::
@ -192,12 +192,13 @@
[~ ~]
?. ?=(proxy:naive proxy)
[~ ~]
:: uses cached naive state
::
::TODO or should we ~ when !(~(has by points.pre) who) ?
=/ =point:naive (~(gut by points.pre) u.who *point:naive)
=+ (proxy-from-point:naive proxy point)
``atom+!>(nonce)
:+ ~ ~
:- %noun
!> ^- (unit @)
?~ point=(get:orm:naive points.pre u.who)
~
=< `nonce
(proxy-from-point:naive proxy u.point)
::
++ spawned
|= wat=@t

View File

@ -144,6 +144,7 @@
%pending-by-address [~ (addr:pending id +.params addr:pending:scry)]
%status [~ (status id +.params tx-status:scry)]
%next-batch [~ (next-batch id +.params next-batch:scry)]
%nonce [~ (nonce id +.params nonce:scry)]
:: %history [~ (history id +.params all:history:scry)]
==
::
@ -230,13 +231,12 @@
==
::
++ nonce
|= [=ship =address:naive]
:: FIXME: use proper type from aggregator/index
.^ @
|= [=ship =proxy:naive]
.^ (unit @)
%gx
%+ ~(scry agentio bowl)
%aggregator
/nonce/(scot %p ship)/[(scot %ux address)]/atom
/nonce/(scot %p ship)/[proxy]/noun
==
--
--

View File

@ -114,13 +114,13 @@
['proxy' (cu proxy:naive so)]
==
::
++ keccak
++ hash
|= params=(map @t json)
^- (unit @ux)
?~ keccak=(~(get by params) 'keccak') ~
?~ hash=(~(get by params) 'hash') ~
=; ans=(unit (unit @ux))
?~(ans ~ u.ans)
((cu to-hex so) u.keccak)
((cu to-hex so) u.hash)
::
++ raw
|= params=(map @t json)
@ -428,15 +428,15 @@
++ transfer-proxy proxy:rpc-res
:: - readNonce(from=[ship proxy]) -> @ :: automatically increment for pending wraps
::
++ read-nonce
++ nonce
|= [id=@t params=(map @t json) scry=$-([ship proxy:naive] (unit @))]
^- response:rpc
?. =((lent ~(tap by params)) 3)
?. =((lent ~(tap by params)) 1)
~(params error:json-rpc id)
?~ from=(from:from-json params)
~(parse error:json-rpc id)
?~ nonce=(scry u.from)
~(params error:json-rpc id)
~(not-found error:json-rpc id)
[%result id (numb:enjs:format u.nonce)]
::
++ pending
@ -478,9 +478,9 @@
^- response:rpc
?. =((lent ~(tap by params)) 1)
~(params error:json-rpc id)
?~ keccak=(keccak:from-json params)
?~ hash=(hash:from-json params)
~(parse error:json-rpc id)
[%result id (tx-status:to-json (scry u.keccak))]
[%result id (tx-status:to-json (scry u.hash))]
::
++ next-batch
|= [id=@t params=(map @t json) when=time]