More structures for the Ethereum lib.

This commit is contained in:
Fang 2018-04-09 16:58:39 +02:00
parent 71eee8cb00
commit 8af91e2af6
2 changed files with 21 additions and 7 deletions

View File

@ -21,16 +21,17 @@
(some (as-octt (en-json:html jon)))
::
++ batch-read-request
|= req=(list [(unit @t) address @t (list data)])
|= req=(list proto-read-request)
^- json
a+(turn req read-request)
::
++ read-request
|= [riq=(unit @t) adr=address fun=@t das=(list data)]
|= proto-read-request
^- json
%+ request-to-json riq
%+ request-to-json id
:+ %eth-call
[~ adr ~ ~ ~ `tape`(encode-call fun das)]
^- call
[~ to ~ ~ ~ `tape`(encode-call function arguments)]
[%label %latest]
::
++ request-to-json
@ -274,12 +275,12 @@
:: https://ethereum.gitbooks.io/frontier-guide/content/abi.html
::
++ encode-call
|= [fun=@t das=(list data)]
|= call-data
^- tape
::TODO should this check to see if the data matches the function signature?
=- (weld - (encode-args das))
=- (weld - (encode-args arguments))
%+ scag 8
(render-hex-bytes 32 (keccak-256 (as-octs fun)))
(render-hex-bytes 32 (keccak-256 (as-octs function)))
::
++ encode-args
:> encode list of arguments.

View File

@ -71,6 +71,19 @@
data=tape
==
::
:: minimum data needed to construct a read call
++ proto-read-request
$: id=(unit @t)
to=address
call-data
==
::
:: raw call data
++ call-data
$: function=@t
arguments=(list data)
==
::
:: block to operate on.
++ block
$% [%number n=@ud]