roller-rpc: add %hash-raw-transaction rpc

the returned hash can be used to cancel pending txs
by signing the message 'cancel: 0xke.ccak'
This commit is contained in:
yosoyubik 2021-11-08 17:47:55 +01:00
parent df9827a2cb
commit 9e2e6a7aee
3 changed files with 22 additions and 2 deletions

View File

@ -173,7 +173,8 @@
%prepare-for-signing `(hash-transaction id +.params chain:scry | &)
%get-unsigned-tx `(hash-transaction id +.params chain:scry & |)
%get-predicted-state `(get-naive id +.params predicted:scry)
:: TODO: deprecated, remove]
%hash-raw-transaction `(hash-raw-transaction id +.params)
:: TODO: deprecated, remove
::
%hash-transaction `(hash-transaction id +.params chain:scry & |)
==

View File

@ -908,7 +908,7 @@
::
=; hash=@t
(met 3 hash)^hash
(crip "0x{((x-co:co 20) keccak)}")
(crip "0x{((x-co:co 65) keccak)}")
::
~
==

View File

@ -623,6 +623,25 @@
unsigned-tx:lib
prepare-for-sig:lib
::
++ hash-raw-transaction
|= [id=@t params=(map @t json)]
^- response:rpc
?. =((lent ~(tap by params)) 4)
~(params error:json-rpc id)
=+ ^- $: sig=(unit @)
l2-tx=(unit l2-tx)
from=(unit [=ship proxy:naive])
==
=, from-json
[(sig params) (tx params) (from params)]
?: |(?=(~ sig) ?=(~ from) ?=(~ l2-tx))
~(parse error:json-rpc id)
=/ tx=(unit tx:naive) (build-l2-tx u.l2-tx u.from params)
?~ tx ~(parse error:json-rpc id)
:+ %result id
%+ hex:to-json 32
(hash-raw-tx:lib u.sig (gen-tx-octs:lib u.tx) u.tx)
::
++ get-naive
|= [id=@t params=(map @t json) =^state:naive]
^- response:rpc