roller: wip support for metamask personal_sign

This commit is contained in:
yosoyubik 2021-11-03 16:58:57 +01:00
parent 07d5ddfe0c
commit aabf028b89
3 changed files with 18 additions and 4 deletions

View File

@ -166,7 +166,8 @@
%get-nonce `(nonce id +.params nonce:scry)
%get-history `(history id +.params addr:history:scry)
%get-roller-config `(get-config id +.params config:scry)
%hash-transaction `(hash-transaction id +.params chain-id:scry)
%hash-transaction `(hash-transaction id +.params chain-id:scry | &)
%unsign-transaction `(hash-transaction id +.params chain-id:scry & |)
%get-predicted-state `(get-naive id +.params predicted:scry)
==
--

View File

@ -585,7 +585,7 @@
[%result id (config:to-json roller-config)]
::
++ hash-transaction
|= [id=@t params=(map @t json) chain-id=@]
|= [id=@t params=(map @t json) chain-id=@ header=? reverse=?]
^- response:rpc
?. =((lent ~(tap by params)) 4)
~(params error:json-rpc id)
@ -599,9 +599,17 @@
~(parse error:json-rpc id)
=/ tx=(unit tx:naive) (build-l2-tx u.l2-tx u.from params)
?~ tx ~(parse error:json-rpc id)
=/ =octs (gen-tx-octs:lib u.tx)
:+ %result id
=- (hex:to-json 32 (hash-tx:lib p q))
(unsigned-tx:lib chain-id u.nonce (gen-tx-octs:lib u.tx))
=; =keccak
%+ hex:to-json 32
?. reverse keccak
(reverse-hash:lib keccak)
%- hash-tx:lib
%. [chain-id u.nonce octs]
?: header
unsigned-tx:lib
prepare-for-sig:lib
::
++ get-naive
|= [id=@t params=(map @t json) =^state:naive]

View File

@ -203,6 +203,11 @@
::
--
::
++ reverse-hash
|= keccak=@ux
^+ keccak
(rev 3 (met 3 keccak) keccak)
::
++ hash-tx keccak-256:keccak:crypto
::
++ hash-raw-tx