naive: add units for endpoint and nonce in aggregator
[next-gas-price=@ud txs=(list raw-tx:naive)]
::
finding=(map keccak $?(%confirmed %failed l1-tx-pointer))
- next-nonce=@ud
+ next-nonce=(unit @ud)
next-batch=time
pre=^state:naive
::
::
pk=@
frequency=@dr
- endpoint=@t
+ endpoint=(unit @t)
contract=@ux
chain-id=@
==
::
++ on-init
^- (quip card _this)
- ::TODO set endpoint?
=. frequency ~h1
=. contract naive:local-contracts:azimuth
=. chain-id chain-id:local-contracts:azimuth
::
%thread-done
=+ !<(nonce=@ud q.cage.sign)
- [~ this(next-nonce nonce)]
+ [~ this(next-nonce `nonce)]
==
==
--
[force nas]
[& +.u.nex]
::
-++ get-l1-pointer
+++ get-l1-address
|= [=tx:naive nas=^state:naive]
- ^- l1-tx-pointer
+ ^- address:ethereum
?~ point=(~(get by points.nas) ship.from.tx)
!!
- :_ next-nonce
=< address
(proxy-from-point:naive proxy.from.tx u.point)
::
^- (quip card _state)
?- -.config
%frequency [~ state(frequency frequency.config)]
- %endpoint [~ state(endpoint endpoint.config)]
+ %endpoint [~ state(endpoint `endpoint.config)]
::
%network
:- ~
state(contract contract, chain-id chain-id)
::
%setkey
- ::TODO what about existing sending entries?
?~ pk=(de:base16:mimes:html pk.config)
`state
[(get-nonce q.u.pk) state(pk q.u.pk)]
^- (quip card _state)
=^ cards state
?: =(~ pending) [~ state]
- =/ nonce=@ud next-nonce
+ ?~ next-nonce
+ ~&([dap.bowl %no-nonce] [~ state])
+ =/ nonce=@ud u.next-nonce
=: pending ~
- next-nonce +(next-nonce)
+ next-nonce `+(u.next-nonce)
::
sending
%+ ~(put by sending)
%- ~(gas by finding)
%+ turn pending
|= [* =raw-tx:naive]
- [(hash-raw-tx raw-tx) (get-l1-pointer tx.raw-tx pre)]
+ :- (hash-raw-tx raw-tx)
+ [(get-l1-address tx.raw-tx pre) nonce]
==
[(send-roll get-address nonce) state]
=^ card next-batch set-timer
++ get-nonce
|= pk=@
^- (list card)
- (start-thread:spider /nonce [%aggregator-nonce !>([endpoint pk])])
+ ?~ endpoint ~&([dap.bowl %no-endpoint] ~)
+ (start-thread:spider /nonce [%aggregator-nonce !>([u.endpoint pk])])
::
:: +send-roll: start thread to submit roll from :sending to l1
::
~
:: start the thread, passing in the l2 txs to use
::
+ ?~ endpoint ~&([dap.bowl %no-endpoint] ~)
::TODO should go ahead and set resend timer in case thread hangs, or nah?
%+ start-thread:spider
/send/(scot %ux address)/(scot %ud nonce)
:- %aggregator-send
!> ^- rpc-send-roll
- :* endpoint
+ :* u.endpoint
contract
chain-id
pk
