Expand RPC request generation to allow custom IDs.
(some (as-octt (en-json:html jon)))
::
++ batch-read-request
- |= req=(list [@ux @t (list data)])
+ |= req=(list [(unit @t) @ux @t (list data)])
^- json
a+(turn req read-request)
::
++ read-request
- |= [adr=@ux fun=@t das=(list data)]
+ |= [riq=(unit @t) adr=@ux fun=@t das=(list data)]
^- json
- %- request-to-json
+ %+ request-to-json riq
:+ %eth-call
[~ `@`adr ~ ~ ~ `tape`(encode-call fun das)]
[%label %latest]
::
++ batch-request-to-json
- |= req=(list request)
+ |= req=(list (pair (unit @t) request))
^- json
a+(turn req request-to-json)
::
++ request-to-json
=, enjs:format
- |= req=request
+ |= [riq=(unit @t) req=request]
^- json
%- pairs
- =; cal=[m=@t p=(list json)]
- :~ jsonrpc+s+'2.0'
- ::TODO allow to self-set, because batch requests.
- id+s+'use wire to id response in hoon'
- method+s+m.cal
- params+a+p.cal
+ =; r=[met=@t pas=(list json)]
+ :* jsonrpc+s+'2.0'
+ method+s+met.r
+ params+a+pas.r
+ ::TODO would just jamming the req noun for id be a bad idea?
+ ?~ riq ~
+ [id+s+u.riq]~
==
?+ -.req ~|([%unsupported-request -.req] !!)
%eth-block-number
