mirror of
https://github.com/urbit/shrub.git
synced 2024-12-25 04:52:06 +03:00
dawn: update for azimuth-rpc, wip
Contains the bulk of the changes, but is missing escape parsing, doesn't handle missing optional fields nicely, and is mostly untested.
This commit is contained in:
parent
cb1a7cb76a
commit
f3b57d7b61
@ -1,7 +1,7 @@
|
|||||||
:: runtime support code
|
:: runtime support code
|
||||||
::
|
::
|
||||||
/+ ethereum, azimuth
|
/+ ethereum, azimuth, json-rpc
|
||||||
=> [ethereum=ethereum azimuth=azimuth ..zuse] =>
|
=> [ethereum=ethereum azimuth=azimuth json-rpc=json-rpc ..zuse] =>
|
||||||
|%
|
|%
|
||||||
::
|
::
|
||||||
:: |dawn: pre-boot request/response de/serialization and validation
|
:: |dawn: pre-boot request/response de/serialization and validation
|
||||||
@ -44,64 +44,45 @@
|
|||||||
:: |give:dawn: produce requests for pre-boot validation
|
:: |give:dawn: produce requests for pre-boot validation
|
||||||
::
|
::
|
||||||
++ give
|
++ give
|
||||||
=, rpc:ethereum
|
|
||||||
=, abi:ethereum
|
|
||||||
=/ tract azimuth:contracts:azimuth
|
=/ tract azimuth:contracts:azimuth
|
||||||
|%
|
|%
|
||||||
:: +bloq:give:dawn: Eth RPC for latest block number
|
|
||||||
::
|
|
||||||
++ bloq
|
|
||||||
^- octs
|
|
||||||
%- as-octt:mimes:html
|
|
||||||
%- en-json:html
|
|
||||||
%+ request-to-json
|
|
||||||
`~.0
|
|
||||||
[%eth-block-number ~]
|
|
||||||
:: +czar:give:dawn: Eth RPC for galaxy table
|
:: +czar:give:dawn: Eth RPC for galaxy table
|
||||||
::
|
::
|
||||||
++ czar
|
++ czar
|
||||||
|= boq=@ud
|
|
||||||
^- octs
|
^- octs
|
||||||
%- as-octt:mimes:html
|
%- as-octt:mimes:html
|
||||||
%- en-json:html
|
%- en-json:html
|
||||||
:- %a
|
:- %a
|
||||||
%+ turn (gulf 0 255)
|
%+ turn (gulf 0 255)
|
||||||
|= gal=@
|
|= gal=@
|
||||||
%+ request-to-json
|
%+ request-to-json:json-rpc
|
||||||
`(cat 3 'gal-' (scot %ud gal))
|
(cat 3 'gal-' (scot %ud gal))
|
||||||
:+ %eth-call
|
:+ 'xx version field remove me!'
|
||||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
'getPoint'
|
||||||
(encode-call 'points(uint32)' [%uint gal]~)
|
map+(~(put by *(map @t json)) 'ship' s+(scot %p gal))
|
||||||
[%number boq]
|
|
||||||
:: +point:give:dawn: Eth RPC for ship's contract state
|
:: +point:give:dawn: Eth RPC for ship's contract state
|
||||||
::
|
::
|
||||||
++ point
|
++ point
|
||||||
|= [boq=@ud who=ship]
|
|= who=ship
|
||||||
^- octs
|
^- octs
|
||||||
%- as-octt:mimes:html
|
%- as-octt:mimes:html
|
||||||
%- en-json:html
|
%- en-json:html
|
||||||
%+ request-to-json
|
%+ request-to-json:json-rpc
|
||||||
`~.0
|
~.
|
||||||
:+ %eth-call
|
:+ 'xx version field remove me!'
|
||||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
'getPoint'
|
||||||
(encode-call 'points(uint32)' [%uint `@`who]~)
|
map+(~(put by *(map @t json)) 'ship' s+(scot %p who))
|
||||||
[%number boq]
|
|
||||||
:: +turf:give:dawn: Eth RPC for network domains
|
:: +turf:give:dawn: Eth RPC for network domains
|
||||||
::
|
::
|
||||||
++ turf
|
++ turf
|
||||||
|= boq=@ud
|
|
||||||
^- octs
|
^- octs
|
||||||
%- as-octt:mimes:html
|
%- as-octt:mimes:html
|
||||||
%- en-json:html
|
%- en-json:html
|
||||||
:- %a
|
%+ request-to-json:json-rpc
|
||||||
%+ turn (gulf 0 2)
|
'turf'
|
||||||
|= idx=@
|
:+ 'xx version field remove me!'
|
||||||
%+ request-to-json
|
'getDns'
|
||||||
`(cat 3 'turf-' (scot %ud idx))
|
map+~
|
||||||
:+ %eth-call
|
|
||||||
=- [from=~ to=tract gas=~ price=~ value=~ data=-]
|
|
||||||
(encode-call 'dnsDomains(uint256)' [%uint idx]~)
|
|
||||||
[%number boq]
|
|
||||||
--
|
--
|
||||||
:: |take:dawn: parse responses for pre-boot validation
|
:: |take:dawn: parse responses for pre-boot validation
|
||||||
::
|
::
|
||||||
@ -111,23 +92,6 @@
|
|||||||
=, azimuth
|
=, azimuth
|
||||||
=, dejs-soft:format
|
=, dejs-soft:format
|
||||||
|%
|
|%
|
||||||
:: +bloq:take:dawn: parse block number
|
|
||||||
::
|
|
||||||
++ bloq
|
|
||||||
|= rep=octs
|
|
||||||
^- (unit @ud)
|
|
||||||
=/ jon=(unit json) (de-json:html q.rep)
|
|
||||||
?~ jon
|
|
||||||
~&([%bloq-take-dawn %invalid-json] ~)
|
|
||||||
=/ res=(unit cord) ((ot result+so ~) u.jon)
|
|
||||||
?~ res
|
|
||||||
~&([%bloq-take-dawn %invalid-response rep] ~)
|
|
||||||
=/ out
|
|
||||||
%- mule |.
|
|
||||||
(hex-to-num:ethereum u.res)
|
|
||||||
?: ?=(%& -.out)
|
|
||||||
(some p.out)
|
|
||||||
~&([%bloq-take-dawn %invalid-block-number] ~)
|
|
||||||
:: +czar:take:dawn: parse galaxy table
|
:: +czar:take:dawn: parse galaxy table
|
||||||
::
|
::
|
||||||
++ czar
|
++ czar
|
||||||
@ -136,58 +100,94 @@
|
|||||||
=/ jon=(unit json) (de-json:html q.rep)
|
=/ jon=(unit json) (de-json:html q.rep)
|
||||||
?~ jon
|
?~ jon
|
||||||
~&([%czar-take-dawn %invalid-json] ~)
|
~&([%czar-take-dawn %invalid-json] ~)
|
||||||
=/ res=(unit (list [@t @t]))
|
=/ res=(unit (list [@t @ud @ud @]))
|
||||||
((ar (ot id+so result+so ~)) u.jon)
|
%. u.jon
|
||||||
|
=, dejs-soft:format
|
||||||
|
=- (ar (ot id+so result+(ot network+- ~) ~))
|
||||||
|
%- ot
|
||||||
|
:~ :- 'rift' ni
|
||||||
|
:- 'keys' (ot 'life'^ni ~)
|
||||||
|
:- 'keys' %+ cu pass-from-eth:azimuth
|
||||||
|
%- ot
|
||||||
|
:~ 'crypt'^(cu (lead 32) ni)
|
||||||
|
'auth'^(cu (lead 32) ni)
|
||||||
|
'suite'^ni
|
||||||
|
==
|
||||||
|
==
|
||||||
?~ res
|
?~ res
|
||||||
~&([%czar-take-dawn %invalid-response rep] ~)
|
~&([%czar-take-dawn %invalid-json] ~)
|
||||||
=/ dat=(unit (list [who=@p point:azimuth-types]))
|
|
||||||
=- ?:(?=(%| -.out) ~ (some p.out))
|
|
||||||
^= out %- mule |.
|
|
||||||
%+ turn u.res
|
|
||||||
|= [id=@t result=@t]
|
|
||||||
^- [who=ship point:azimuth-types]
|
|
||||||
=/ who `@p`(slav %ud (rsh [3 4] id))
|
|
||||||
:- who
|
|
||||||
%+ point-from-eth
|
|
||||||
who
|
|
||||||
:_ *deed:eth-noun
|
|
||||||
%+ decode-results
|
|
||||||
result
|
|
||||||
point:eth-type
|
|
||||||
?~ dat
|
|
||||||
~&([%bloq-take-dawn %invalid-galaxy-table] ~)
|
|
||||||
:- ~
|
:- ~
|
||||||
%+ roll u.dat
|
%+ roll u.res
|
||||||
|= $: [who=ship =point:azimuth-types]
|
|= $: [id=@t deet=[rift life =pass]]
|
||||||
kyz=(map ship [=rift =life =pass])
|
kyz=(map ship [=rift =life =pass])
|
||||||
==
|
==
|
||||||
^+ kyz
|
^+ kyz
|
||||||
?~ net.point
|
?: =(0 life.deet)
|
||||||
kyz
|
kyz
|
||||||
(~(put by kyz) who [continuity-number life pass]:u.net.point)
|
%+ ~(put by kyz)
|
||||||
|
(slav %ud (rsh [3 4] id))
|
||||||
|
deet
|
||||||
:: +point:take:dawn: parse ship's contract state
|
:: +point:take:dawn: parse ship's contract state
|
||||||
::
|
::
|
||||||
++ point
|
++ point
|
||||||
|= [who=ship rep=octs]
|
|= [who=ship rep=octs]
|
||||||
^- (unit point:azimuth)
|
^- (unit point:azimuth)
|
||||||
|
~! *point:azimuth
|
||||||
=/ jon=(unit json) (de-json:html q.rep)
|
=/ jon=(unit json) (de-json:html q.rep)
|
||||||
?~ jon
|
?~ jon
|
||||||
~&([%point-take-dawn %invalid-json] ~)
|
~&([%point-take-dawn %invalid-json] ~)
|
||||||
=/ res=(unit cord) ((ot result+so ~) u.jon)
|
=; ^= res
|
||||||
?~ res
|
%- unit
|
||||||
~&([%point-take-dawn %invalid-response rep] ~)
|
$: [spawn=@ own=[@ @ @ @]]
|
||||||
~? =(u.res '0x')
|
[=rift =life =pass sponsor=[? ship]]
|
||||||
:- 'bad result from node; is azimuth address correct?'
|
==
|
||||||
azimuth:contracts
|
?~ res
|
||||||
=/ out
|
~&([%point-take-dawn %incomplete-json] ~)
|
||||||
%- mule |.
|
=, u.res
|
||||||
%+ point-from-eth
|
%- some
|
||||||
who
|
:+ own
|
||||||
:_ *deed:eth-noun ::TODO call rights to fill
|
?: =(0 life) ~
|
||||||
(decode-results u.res point:eth-type)
|
`[life pass rift sponsor ~] ::NOTE escape unknown ::TODO could be!
|
||||||
?: ?=(%& -.out)
|
?. (gth who 0xffff) ~
|
||||||
(some p.out)
|
`[spawn ~] ::NOTE spawned unknown
|
||||||
~&([%point-take-dawn %invalid-point] ~)
|
%. u.jon
|
||||||
|
=, dejs-soft:format
|
||||||
|
=- (ot result+- ~)
|
||||||
|
%- ot
|
||||||
|
:~ :- 'ownership'
|
||||||
|
%- ot
|
||||||
|
|^ :~ 'spawnProxy'^address
|
||||||
|
'owner'^address
|
||||||
|
'managementProxy'^address
|
||||||
|
'votingProxy'^address
|
||||||
|
'transferProxy'^address
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ address
|
||||||
|
(ot 'address'^(cu hex-to-num:ethereum so) ~)
|
||||||
|
--
|
||||||
|
::
|
||||||
|
:- 'network'
|
||||||
|
%- ot
|
||||||
|
::TODO dedupe with +czar
|
||||||
|
:~ 'rift'^ni
|
||||||
|
'keys'^(ot 'life'^ni ~)
|
||||||
|
::
|
||||||
|
:- 'keys'
|
||||||
|
%+ cu pass-from-eth:azimuth
|
||||||
|
%- ot
|
||||||
|
:~ 'crypt'^(cu (lead 32) ni)
|
||||||
|
'auth'^(cu (lead 32) ni)
|
||||||
|
'suite'^ni
|
||||||
|
==
|
||||||
|
::
|
||||||
|
::TODO inconsistent @p string
|
||||||
|
'sponsor'^(ot 'has'^bo 'who'^(su fed:ag) ~)
|
||||||
|
::
|
||||||
|
::TODO escape
|
||||||
|
::TODO what if escape or sponsor not present? possible?
|
||||||
|
==
|
||||||
|
==
|
||||||
:: +turf:take:dawn: parse network domains
|
:: +turf:take:dawn: parse network domains
|
||||||
::
|
::
|
||||||
++ turf
|
++ turf
|
||||||
@ -196,38 +196,21 @@
|
|||||||
=/ jon=(unit json) (de-json:html q.rep)
|
=/ jon=(unit json) (de-json:html q.rep)
|
||||||
?~ jon
|
?~ jon
|
||||||
~&([%turf-take-dawn %invalid-json] ~)
|
~&([%turf-take-dawn %invalid-json] ~)
|
||||||
=/ res=(unit (list [@t @t]))
|
=/ res=(unit (list @t))
|
||||||
((ar (ot id+so result+so ~)) u.jon)
|
((ot result+(ar so) ~) u.jon)
|
||||||
?~ res
|
?~ res
|
||||||
~&([%turf-take-dawn %invalid-response rep] ~)
|
~&([%turf-take-dawn %invalid-response rep] ~)
|
||||||
=/ dat=(unit (list (pair @ud ^turf)))
|
:: remove duplicates, parse into turfs
|
||||||
=- ?:(?=(%| -.out) ~ (some p.out))
|
|
||||||
^= out %- mule |.
|
|
||||||
%+ turn u.res
|
|
||||||
|= [id=@t result=@t]
|
|
||||||
^- (pair @ud ^turf)
|
|
||||||
:- (slav %ud (rsh [3 5] id))
|
|
||||||
=/ dom=tape
|
|
||||||
(decode-results result [%string]~)
|
|
||||||
=/ hot=host:eyre
|
|
||||||
(scan dom thos:de-purl:html)
|
|
||||||
?>(?=(%& -.hot) p.hot)
|
|
||||||
?~ dat
|
|
||||||
~&([%turf-take-dawn %invalid-domains] ~)
|
|
||||||
:- ~
|
|
||||||
=* dom u.dat
|
|
||||||
:: sort by id, ascending, removing duplicates
|
|
||||||
::
|
::
|
||||||
=| tuf=(map ^turf @ud)
|
=- `doz
|
||||||
|- ^- (list ^turf)
|
%+ roll u.res
|
||||||
?~ dom
|
|= [dom=@t doh=(set @t) doz=(list ^turf)]
|
||||||
%+ turn
|
?: (~(has in doh) dom) [doh doz]
|
||||||
%+ sort ~(tap by tuf)
|
:- (~(put in doh) dom)
|
||||||
|=([a=(pair ^turf @ud) b=(pair ^turf @ud)] (lth q.a q.b))
|
=/ hot=host:eyre
|
||||||
head
|
(rash dom thos:de-purl:html)
|
||||||
=? tuf !(~(has by tuf) q.i.dom)
|
?. ?=(%& -.hot) doz
|
||||||
(~(put by tuf) q.i.dom p.i.dom)
|
(snoc doz p.hot)
|
||||||
$(dom t.dom)
|
|
||||||
--
|
--
|
||||||
:: +veri:dawn: validate keys, life, discontinuity, &c
|
:: +veri:dawn: validate keys, life, discontinuity, &c
|
||||||
::
|
::
|
||||||
|
Loading…
Reference in New Issue
Block a user