mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-02 20:15:27 +03:00
azimuth-rpc: return hash of succesful l2 transaction
This commit is contained in:
parent
fc04623d00
commit
794a14a12b
@ -200,7 +200,7 @@
|
||||
[?:(known %pending %unknown) ~]
|
||||
%+ lien pending
|
||||
|= pend-tx
|
||||
=(u.keccak (hash-tx raw.raw-tx))
|
||||
=(u.keccak (hash-tx:lib raw.raw-tx))
|
||||
::
|
||||
++ history
|
||||
|= wat=@t
|
||||
@ -455,13 +455,6 @@
|
||||
[%pass path %agent [our.bowl %spider] %leave ~]
|
||||
--
|
||||
::
|
||||
++ hash-tx keccak-256:keccak:crypto
|
||||
::
|
||||
++ hash-raw-tx
|
||||
|= =raw-tx:naive
|
||||
^- @ux
|
||||
(hash-tx raw.raw-tx)
|
||||
::
|
||||
++ part-tx-to-full
|
||||
|= =part-tx
|
||||
^- [octs tx:naive]
|
||||
@ -539,7 +532,7 @@
|
||||
?~ txs [valid state]
|
||||
::
|
||||
=* tx i.txs
|
||||
=/ hash=@ux (hash-raw-tx raw-tx.tx)
|
||||
=/ hash=@ux (hash-raw-tx:lib raw-tx)
|
||||
?: (~(has in local) hash)
|
||||
:: if tx was already seen here, skip
|
||||
::
|
||||
@ -696,7 +689,7 @@
|
||||
=. pending
|
||||
%+ skip pending
|
||||
|= pend-tx
|
||||
=(keccak (hash-raw-tx raw-tx))
|
||||
=(keccak (hash-raw-tx:lib raw-tx))
|
||||
[~ state]
|
||||
:: TODO: move to /lib/naive-transactions
|
||||
::
|
||||
@ -734,7 +727,7 @@
|
||||
:: TODO: add tx to the history as failed?
|
||||
::
|
||||
[~ state]
|
||||
=/ hash=@ux (hash-raw-tx raw-tx)
|
||||
=/ hash=@ux (hash-raw-tx:lib raw-tx)
|
||||
:: TODO: what if this hash/tx is already in the history?
|
||||
:: e.g. if previously failed, but now it will go through
|
||||
:: a) check in :finding that hash doesn't exist and if so, skip ?
|
||||
@ -786,14 +779,14 @@
|
||||
%- ~(gas by finding)
|
||||
%+ turn pending
|
||||
|= pend-tx
|
||||
(hash-raw-tx raw-tx)^[address nonce]
|
||||
(hash-raw-tx:lib raw-tx)^[address nonce]
|
||||
::
|
||||
history
|
||||
%+ roll pending
|
||||
|= [pend-tx hist=_history]
|
||||
=/ tx=roller-tx
|
||||
:+ [%pending ~]
|
||||
(hash-raw-tx raw-tx)
|
||||
(hash-raw-tx:lib raw-tx)
|
||||
(l2-tx +<.tx.raw-tx)
|
||||
%+ ~(put ju (~(del ju hist) address tx))
|
||||
address
|
||||
@ -868,7 +861,7 @@
|
||||
[(wait:b:sys /owners (add ~m5 now.bowl))]~
|
||||
?. ?=(%tx -.diff)
|
||||
[~ state]
|
||||
=/ =keccak (hash-raw-tx raw-tx.diff)
|
||||
=/ =keccak (hash-raw-tx:lib raw-tx.diff)
|
||||
?~ wer=(~(get by finding) keccak)
|
||||
[~ state]
|
||||
:: if we had already seen the tx, no-op
|
||||
|
@ -362,19 +362,18 @@
|
||||
=/ data=(unit @p) (ship:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
:_ [%result id s+'ok']
|
||||
=/ =tx:naive
|
||||
?- action
|
||||
%escape [u.from %escape u.data]
|
||||
%cancel-escape [u.from %cancel-escape u.data]
|
||||
%adopt [u.from %adopt u.data]
|
||||
%reject [u.from %reject u.data]
|
||||
%detach [u.from %detach u.data]
|
||||
==
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib tx))
|
||||
:_ [%result id (l2-hash:to-json keccak)]
|
||||
%- some
|
||||
:- %aggregator-action
|
||||
!>
|
||||
=; =skim-tx:naive
|
||||
[%submit | u.sig %don u.from skim-tx]
|
||||
?- action
|
||||
%escape [%escape u.data]
|
||||
%cancel-escape [%cancel-escape u.data]
|
||||
%adopt [%adopt u.data]
|
||||
%reject [%reject u.data]
|
||||
%detach [%detach u.data]
|
||||
==
|
||||
aggregator-action+!>([%submit | u.sig %don tx])
|
||||
::
|
||||
++ proxy
|
||||
|= [id=@t params=(map @t json) action=proxy-action]
|
||||
@ -387,16 +386,16 @@
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
:_ [%result id s+'ok']
|
||||
=/ =tx:naive
|
||||
?- action
|
||||
%set-management-proxy [u.from %set-management-proxy u.data]
|
||||
%set-spawn-proxy [u.from %set-spawn-proxy u.data]
|
||||
%set-transfer-proxy [u.from %set-transfer-proxy u.data]
|
||||
==
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib tx))
|
||||
:_ [%result id (l2-hash:to-json keccak)]
|
||||
%- some
|
||||
:- %aggregator-action
|
||||
!>
|
||||
=; =skim-tx:naive
|
||||
[%submit | u.sig %don u.from skim-tx]
|
||||
?- action
|
||||
%set-management-proxy [%set-management-proxy u.data]
|
||||
%set-spawn-proxy [%set-spawn-proxy u.data]
|
||||
%set-transfer-proxy [%set-transfer-proxy u.data]
|
||||
==
|
||||
aggregator-action+!>([%submit | u.sig %don tx])
|
||||
--
|
||||
::
|
||||
++ validate
|
||||
@ -406,6 +405,10 @@
|
||||
^- ?
|
||||
=((lent ~(tap by params)) 3)
|
||||
--
|
||||
++ l2-hash
|
||||
|= =keccak
|
||||
^- json
|
||||
s+(crip "0x{((x-co:co 20) keccak)}")
|
||||
--
|
||||
|%
|
||||
++ get-point
|
||||
@ -438,21 +441,6 @@
|
||||
~(params error:json-rpc id)
|
||||
[%result id a+(turn dns (cork same (lead %s)))]
|
||||
::
|
||||
++ transfer-point
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. (params:validate params)
|
||||
[~ ~(params error:json-rpc id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [ship proxy:naive]) (from:from-json params)
|
||||
=/ data=(unit [@ux ?]) (address-transfer:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
:_ [%result id s+'ok']
|
||||
%- some
|
||||
:- %aggregator-action
|
||||
!>([%submit | u.sig %don u.from %transfer-point u.data])
|
||||
::
|
||||
++ cancel-tx
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- [(unit cage) response:rpc]
|
||||
@ -468,6 +456,21 @@
|
||||
:- %aggregator-action
|
||||
!>([%cancel u.sig u.keccak u.l2])
|
||||
::
|
||||
++ transfer-point
|
||||
|= [id=@t params=(map @t json)]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. (params:validate params)
|
||||
[~ ~(params error:json-rpc id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [ship proxy:naive]) (from:from-json params)
|
||||
=/ data=(unit [@ux ?]) (address-transfer:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ =tx:naive [u.from %transfer-point u.data]
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib tx))
|
||||
:_ [%result id (l2-hash:to-json keccak)]
|
||||
%- some
|
||||
aggregator-action+!>([%submit | u.sig %don tx])
|
||||
++ get-spawned
|
||||
|= [id=@t params=(map @t json) scry=$-(ship (list [ship @ux]))]
|
||||
^- response:rpc
|
||||
@ -490,10 +493,11 @@
|
||||
(keys:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
:_ [%result id s+'ok']
|
||||
=/ =tx:naive [u.from %configure-keys u.data]
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib tx))
|
||||
:_ [%result id (l2-hash:to-json keccak)]
|
||||
%- some
|
||||
:- %aggregator-action
|
||||
!>([%submit | u.sig %don u.from %configure-keys u.data])
|
||||
aggregator-action+!>([%submit | u.sig %don tx])
|
||||
::
|
||||
++ spawn
|
||||
|= [id=@t params=(map @t json)]
|
||||
@ -505,10 +509,11 @@
|
||||
=/ data=(unit [@p @ux]) (address-ship:data:from-json params)
|
||||
?. &(?=(^ sig) ?=(^ from) ?=(^ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
:_ [%result id s+'ok']
|
||||
=/ =tx:naive [u.from %spawn u.data]
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib tx))
|
||||
:_ [%result id (l2-hash:to-json keccak)]
|
||||
%- some
|
||||
:- %aggregator-action
|
||||
!>([%submit | u.sig %done u.from %spawn u.data])
|
||||
aggregator-action+!>([%submit | u.sig %done tx])
|
||||
::
|
||||
++ escape sponsor:rpc-res
|
||||
++ cancel-escape sponsor:rpc-res
|
||||
|
@ -19,7 +19,7 @@
|
||||
=, secp256k1:secp:crypto
|
||||
%- address-from-pub:key:ethereum
|
||||
%- serialize-point
|
||||
(ecdsa-raw-recover (keccak-256:keccak:crypto dat) v r s)
|
||||
(ecdsa-raw-recover (hash-tx dat) v r s)
|
||||
?- -.result
|
||||
%| ~
|
||||
%& `p.result
|
||||
@ -30,7 +30,7 @@
|
||||
=/ prepared-data (prepare-for-sig 1.337 nonce tx)
|
||||
=/ sign-data
|
||||
=/ len (rsh [3 2] (scot %ui p.prepared-data))
|
||||
%- keccak-256:keccak:crypto
|
||||
%- hash-tx
|
||||
%: cad:naive 3
|
||||
26^'\19Ethereum Signed Message:\0a'
|
||||
(met 3 len)^len
|
||||
@ -161,4 +161,11 @@
|
||||
::
|
||||
--
|
||||
::
|
||||
++ hash-tx keccak-256:keccak:crypto
|
||||
::
|
||||
++ hash-raw-tx
|
||||
|= =raw-tx:naive
|
||||
^- @ux
|
||||
(hash-tx raw.raw-tx)
|
||||
::
|
||||
--
|
||||
|
Loading…
Reference in New Issue
Block a user