mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-01 03:23:09 +03:00
aggregator-rpc: add +unsign-transaction
This commit is contained in:
parent
722ce969a5
commit
38d207c797
@ -145,22 +145,13 @@
|
||||
?. ?=([%map *] params)
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ method=@tas (enkebab method)
|
||||
?: ?=(l2-tx method)
|
||||
(process-rpc id +.params method)
|
||||
?+ method [~ ~(method error:json-rpc id)]
|
||||
%get-point `(get-point id +.params point:scry)
|
||||
%get-points `(get-points id +.params points:scry)
|
||||
%transfer-point (transfer-point id +.params)
|
||||
%cancel-transaction (cancel-tx id +.params)
|
||||
%get-spawned `(get-spawned id +.params spawned:scry)
|
||||
%configure-keys (configure-keys id +.params)
|
||||
%spawn (spawn id +.params)
|
||||
%escape (escape id +.params method)
|
||||
%cancel-escape (cancel-escape id +.params method)
|
||||
%adopt (adopt id +.params method)
|
||||
%detach (detach id +.params method)
|
||||
%reject (reject id +.params method)
|
||||
%set-management-proxy (management-proxy id +.params method)
|
||||
%set-spawn-proxy (spawn-proxy id +.params method)
|
||||
%set-transfer-proxy (transfer-proxy id +.params method)
|
||||
%get-all-pending `(all:pending id +.params all:pending:scry)
|
||||
%get-pending-by-ship `(ship:pending id +.params ship:pending:scry)
|
||||
%get-pending-by-address `(addr:pending id +.params addr:pending:scry)
|
||||
@ -169,6 +160,7 @@
|
||||
%get-nonce `(nonce id +.params nonce:scry)
|
||||
%get-history `(history id +.params addr:history:scry)
|
||||
%get-roller-config `(get-config id +.params config:scry)
|
||||
%unsign-transaction `(unsign-transaction id +.params chain-id:scry)
|
||||
==
|
||||
--
|
||||
::
|
||||
@ -183,7 +175,7 @@
|
||||
::
|
||||
++ points
|
||||
|= =address:naive
|
||||
.^ (list [ship point:naive])
|
||||
.^ (list ship)
|
||||
%gx
|
||||
(~(scry agentio bowl) %aggregator /points/(scot %ux address)/noun)
|
||||
==
|
||||
@ -258,5 +250,13 @@
|
||||
%aggregator
|
||||
/config/noun
|
||||
==
|
||||
::
|
||||
++ chain-id
|
||||
.^ @
|
||||
%gx
|
||||
%+ ~(scry agentio bowl)
|
||||
%aggregator
|
||||
/chain-id/noun
|
||||
==
|
||||
--
|
||||
--
|
||||
|
@ -49,20 +49,20 @@
|
||||
++ from-json
|
||||
=, dejs-soft:format
|
||||
|%
|
||||
++ keys
|
||||
|= params=(map @t json)
|
||||
^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
%. u.data
|
||||
%- ot
|
||||
:~ ['encrypt' so]
|
||||
['auth' so]
|
||||
['cryptoSuite' so]
|
||||
['breach' bo]
|
||||
==
|
||||
::
|
||||
++ data
|
||||
|%
|
||||
++ keys
|
||||
|= params=(map @t json)
|
||||
^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
||||
?~ data=(~(get by params) 'data') ~
|
||||
%. u.data
|
||||
%- ot
|
||||
:~ ['encrypt' so]
|
||||
['auth' so]
|
||||
['cryptoSuite' so]
|
||||
['breach' bo]
|
||||
==
|
||||
::
|
||||
++ address-transfer
|
||||
|= params=(map @t json)
|
||||
^- (unit [@ux ?])
|
||||
@ -160,6 +160,21 @@
|
||||
?~ ans=((cu to-hex so) u.raw) ~
|
||||
?~ u.ans ~
|
||||
(some (as-octs:mimes:html u.u.ans))
|
||||
::
|
||||
++ tx
|
||||
|= params=(map @t json)
|
||||
^- (unit l2-tx)
|
||||
?~ data=(~(get by params) 'tx') ~
|
||||
?~ tx=(so u.data) ~
|
||||
=/ method=@tas (enkebab u.tx)
|
||||
?. ?=(l2-tx method) ~
|
||||
`method
|
||||
::
|
||||
++ nonce
|
||||
|= params=(map @t json)
|
||||
^- (unit @ud)
|
||||
?~ nonce=(~(get by params) 'nonce') ~
|
||||
(ni u.nonce)
|
||||
--
|
||||
::
|
||||
++ to-json
|
||||
@ -301,6 +316,11 @@
|
||||
['point' (^point point)]
|
||||
==
|
||||
::
|
||||
++ ships
|
||||
|= ships=(list @p)
|
||||
^- json
|
||||
a+(turn ships ship)
|
||||
::
|
||||
++ ownership
|
||||
|= [=address:naive =nonce:naive]
|
||||
^- json
|
||||
@ -339,55 +359,6 @@
|
||||
^- (unit @ux)
|
||||
(rush (rsh [3 2] cord) hex)
|
||||
::
|
||||
++ rpc-res
|
||||
|%
|
||||
++ sponsor
|
||||
|= [id=@t params=(map @t json) action=spawn-action]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. (params:validate params)
|
||||
[~ ~(params error:json-rpc id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [@p proxy:naive]) (from:from-json params)
|
||||
=/ addr=(unit @ux) (address:from-json params)
|
||||
=/ data=(unit @p) (ship:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ addr) ?=(~ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ =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+!>([%submit | u.addr u.sig %don tx])
|
||||
::
|
||||
++ proxy
|
||||
|= [id=@t params=(map @t json) action=proxy-action]
|
||||
^- [(unit cage) response:rpc]
|
||||
?. (params:validate params)
|
||||
[~ ~(params error:json-rpc id)]
|
||||
=/ sig=(unit @) (sig:from-json params)
|
||||
=/ from=(unit [@p proxy:naive]) (from:from-json params)
|
||||
=/ addr=(unit @ux) (address:from-json params)
|
||||
=/ data=(unit @ux) (address:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ addr) ?=(~ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ =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+!>([%submit | u.addr u.sig %don tx])
|
||||
--
|
||||
::
|
||||
++ validate
|
||||
|%
|
||||
++ params
|
||||
@ -395,10 +366,46 @@
|
||||
^- ?
|
||||
=((lent ~(tap by params)) 4)
|
||||
--
|
||||
::
|
||||
++ l2-hash
|
||||
|= =keccak
|
||||
^- json
|
||||
s+(crip "0x{((x-co:co 20) keccak)}")
|
||||
::
|
||||
++ build-l2-tx
|
||||
|= [=l2-tx from=[@p proxy:naive] params=(map @t json)]
|
||||
^- (unit tx:naive)
|
||||
?: =(l2-tx %transfer-point)
|
||||
?~ data=(address-transfer:data:from-json params)
|
||||
~
|
||||
`[from %transfer-point u.data]
|
||||
?: =(l2-tx %spawn)
|
||||
?~ data=(address-ship:data:from-json params)
|
||||
~
|
||||
`[from %spawn u.data]
|
||||
?: =(l2-tx %configure-keys)
|
||||
?~ data=(keys:data:from-json params)
|
||||
~
|
||||
`[from %configure-keys u.data]
|
||||
?: ?=(spawn-action l2-tx)
|
||||
?~ data=(ship:data:from-json params)
|
||||
~
|
||||
?- l2-tx
|
||||
%escape `[from %escape u.data]
|
||||
%cancel-escape `[from %cancel-escape u.data]
|
||||
%adopt `[from %adopt u.data]
|
||||
%reject `[from %reject u.data]
|
||||
%detach `[from %detach u.data]
|
||||
==
|
||||
?. ?=(proxy-action l2-tx)
|
||||
~
|
||||
?~ data=(address:data:from-json params)
|
||||
~
|
||||
?- l2-tx
|
||||
%set-management-proxy `[from %set-management-proxy u.data]
|
||||
%set-spawn-proxy `[from %set-spawn-proxy u.data]
|
||||
%set-transfer-proxy `[from %set-transfer-proxy u.data]
|
||||
==
|
||||
--
|
||||
|%
|
||||
++ get-point
|
||||
@ -415,13 +422,13 @@
|
||||
[%result id (point:to-json u.point)]
|
||||
::
|
||||
++ get-points
|
||||
|= [id=@t params=(map @t json) scry=$-(@ux (list [@p point:naive]))]
|
||||
|= [id=@t params=(map @t json) scry=$-(@ux (list @p))]
|
||||
^- response:rpc
|
||||
?. =(~(wyt by params) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ address=(address:from-json params)
|
||||
~(parse error:json-rpc id)
|
||||
[%result id (points:to-json (scry u.address))]
|
||||
[%result id (ships:to-json (scry u.address))]
|
||||
::
|
||||
++ get-dns
|
||||
|= [id=@t params=(map @t json) dns=(list @t)]
|
||||
@ -444,78 +451,39 @@
|
||||
%- some
|
||||
aggregator-action+!>([%cancel u.sig u.keccak u.data])
|
||||
::
|
||||
++ 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)
|
||||
=/ addr=(unit @ux) (address:from-json params)
|
||||
=/ data=(unit [@ux ?]) (address-transfer:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ addr) ?=(~ 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.addr u.sig %don tx])
|
||||
::
|
||||
++ get-spawned
|
||||
|= [id=@t params=(map @t json) scry=$-(ship (list [ship @ux]))]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 1)
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(~(get by params) 'ship')
|
||||
~(params error:json-rpc id)
|
||||
?~ ship=(parse-ship u.ship)
|
||||
:: ?~ ship=(~(get by params) 'ship')
|
||||
:: ~(params error:json-rpc id)
|
||||
:: ?~ ship=(parse-ship u.ship)
|
||||
:: ~(params error:json-rpc id)
|
||||
?~ ship=(ship:from-json params)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (spawned:to-json (scry u.ship))]
|
||||
::
|
||||
++ configure-keys
|
||||
|= [id=@t params=(map @t json)]
|
||||
++ process-rpc
|
||||
|= [id=@t params=(map @t json) action=l2-tx]
|
||||
^- [(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)
|
||||
=/ addr=(unit @ux) (address:from-json params)
|
||||
=/ data=(unit [encrypt=@ auth=@ crypto-suite=@ breach=?])
|
||||
(keys:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ addr) ?=(~ data))
|
||||
=+ ^- $: sig=(unit @)
|
||||
from=(unit [ship proxy:naive])
|
||||
addr=(unit @ux)
|
||||
==
|
||||
=, from-json
|
||||
[(sig params) (from params) (address params)]
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ addr))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ =tx:naive [u.from %configure-keys u.data]
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib tx))
|
||||
=/ tx=(unit tx:naive) (build-l2-tx action u.from params)
|
||||
?~ tx [~ ~(parse error:json-rpc id)]
|
||||
=/ =keccak (hash-tx:lib (gen-tx-octs:lib u.tx))
|
||||
:_ [%result id (l2-hash:to-json keccak)]
|
||||
%- some
|
||||
aggregator-action+!>([%submit | u.addr u.sig %don tx])
|
||||
::
|
||||
++ spawn
|
||||
|= [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 [@p proxy:naive]) (from:from-json params)
|
||||
=/ addr=(unit @ux) (address:from-json params)
|
||||
=/ data=(unit [@p @ux]) (address-ship:data:from-json params)
|
||||
?: |(?=(~ sig) ?=(~ from) ?=(~ addr) ?=(~ data))
|
||||
[~ ~(parse error:json-rpc id)]
|
||||
=/ =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.addr u.sig %don tx])
|
||||
::
|
||||
++ escape sponsor:rpc-res
|
||||
++ cancel-escape sponsor:rpc-res
|
||||
++ adopt sponsor:rpc-res
|
||||
++ detach sponsor:rpc-res
|
||||
++ reject sponsor:rpc-res
|
||||
++ management-proxy proxy:rpc-res
|
||||
++ spawn-proxy proxy:rpc-res
|
||||
++ transfer-proxy proxy:rpc-res
|
||||
::
|
||||
++ nonce
|
||||
|= [id=@t params=(map @t json) scry=$-([ship proxy:naive] (unit @))]
|
||||
^- response:rpc
|
||||
@ -587,4 +555,24 @@
|
||||
?. =((lent ~(tap by params)) 0)
|
||||
~(params error:json-rpc id)
|
||||
[%result id (config:to-json roller-config)]
|
||||
::
|
||||
++ unsign-transaction
|
||||
|= [id=@t params=(map @t json) chain-id=@]
|
||||
^- response:rpc
|
||||
?. =((lent ~(tap by params)) 4)
|
||||
~(params error:json-rpc id)
|
||||
=+ ^- $: l2-tx=(unit l2-tx)
|
||||
nonce=(unit @ud)
|
||||
from=(unit [@p proxy:naive])
|
||||
==
|
||||
:+ (tx:from-json params)
|
||||
(nonce:from-json params)
|
||||
(from:from-json params)
|
||||
?: |(?=(~ nonce) ?=(~ 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
|
||||
%- l2-hash:to-json
|
||||
(unsign-tx:lib u.nonce chain-id (gen-tx-octs:lib u.tx))
|
||||
--
|
||||
|
@ -50,18 +50,22 @@
|
||||
[(end bite sig) (rsh bite sig)]
|
||||
--
|
||||
::
|
||||
++ unsign-tx
|
||||
|= [chain-id=@ud =nonce tx=octs]
|
||||
^- @u
|
||||
=/ prepared-data (prepare-for-sig chain-id nonce tx)
|
||||
=/ len (rsh [3 2] (scot %ui p.prepared-data))
|
||||
%- hash-tx
|
||||
%: cad:naive 3
|
||||
26^'\19Ethereum Signed Message:\0a'
|
||||
(met 3 len)^len
|
||||
prepared-data
|
||||
~
|
||||
==
|
||||
::
|
||||
++ sign-tx
|
||||
|= [pk=@ =nonce tx=octs] ^- octs
|
||||
=/ prepared-data (prepare-for-sig 1.337 nonce tx)
|
||||
=/ sign-data
|
||||
=/ len (rsh [3 2] (scot %ui p.prepared-data))
|
||||
%- hash-tx
|
||||
%: cad:naive 3
|
||||
26^'\19Ethereum Signed Message:\0a'
|
||||
(met 3 len)^len
|
||||
prepared-data
|
||||
~
|
||||
==
|
||||
=/ sign-data (unsign-tx 1.337 nonce tx)
|
||||
=+ (ecdsa-raw-sign:secp256k1:secp:crypto sign-data pk)
|
||||
(cad:naive 3 1^v 32^s 32^r tx ~)
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user