claz: Implement batch invites

For generating many sendPoint() transactions for the Delegated Sending
contract. Specify what ship to send the invites as, and a path to a file
containing lines of "~ship,~ticket,0xaddress".

Comes with a generator, |claz-invites, for generating such files, given
a star and a range of its children (and an output path).
This commit is contained in:
Fang 2019-10-09 21:28:48 +02:00
parent e6775d0907
commit 09cb5f2403
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
2 changed files with 89 additions and 2 deletions

View File

@ -42,6 +42,11 @@
:: %deed: deed ships based on json, assumes spawnable
::
[%deed deeds-json=cord]
:: %invites: sendPoint for every ship in ship,ticket,owner file
::
:: to generate such a file, try +claz|invites ~star 1 10
::
[%invites as-who=ship file=path]
:: %lock-prep: prepare for lockup by transfering ships to the ceremony address
::
[%lock-prep what=(list ship)]
@ -77,6 +82,8 @@
[%transfer-ship who=ship to=address]
[%set-transfer-proxy who=ship proxy=address]
[%adopt who=ship]
::
[%send-point as=ship point=ship to=address]
==
::
:: monadic structures
@ -224,7 +231,8 @@
::
:: constants
::
++ ecliptic `address`0x6ac0.7b7c.4601.b5ce.11de.8dfe.6335.b871.c7c4.dd4d
++ ecliptic 0x6ac0.7b7c.4601.b5ce.11de.8dfe.6335.b871.c7c4.dd4d
++ delegated-sending 0xf790.8ab1.f1e3.52f8.3c5e.bc75.051c.0565.aeae.a5fb
--
::
|_ [=bowl:gall state]
@ -411,6 +419,7 @@
?- -.batch
%single [(single nonce network as +.batch) ~]
%deed (deed nonce network as +.batch)
%invites (invites nonce network as +.batch)
%lock-prep (lock-prep nonce network as +.batch)
%lock (lock nonce network as +.batch)
::
@ -484,6 +493,8 @@
%transfer-ship (transfer-ship:dat +.call)
%set-transfer-proxy (set-transfer-proxy:dat +.call)
%adopt (adopt:dat +.call)
::
%send-point (send-point:dat +.call)
==
::
++ deed
@ -528,6 +539,33 @@
(do network (add nonce (lent txs)) ecliptic dat)
--
::
++ invites
|= [nonce=@ud =network as=address as-who=ship file=path]
^- (list transaction)
=/ friends=(list [=ship @q =address])
=+ txt=.^((list cord) %cx file)
%+ turn txt
|= line=cord
~| line
%+ rash line
;~ (glue com)
;~(pfix sig fed:ag)
;~(pfix sig feq:ag)
;~(pfix (jest '0x') hex)
==
=| txs=(list transaction)
|-
?~ friends (flop txs)
=* friend i.friends
=; tx=transaction
$(txs [tx txs], friends t.friends)
%- do
:* network
(add nonce (lent txs))
delegated-sending
(send-point:dat as-who [ship address]:friend)
==
::
++ parse-registration
|= reg=cord
^- (list [=ship rights])
@ -711,10 +749,13 @@
++ set-dns-domains (enc set-dns-domains:cal)
++ upgrade-to (enc upgrade-to:cal)
++ transfer-ownership (enc transfer-ownership:cal)
++ adopt (enc adopt:cal)
++ adopt (enc adopt:cal)
::
++ register-linear (enc register-linear:cal)
++ register-conditional (enc register-conditional:cal)
++ deposit (enc deposit:cal)
::
++ send-point (enc send-point:cal)
--
::
++ cal
@ -863,6 +904,15 @@
:~ [%address to]
[%uint `@`star]
==
::
++ send-point
|= [as=ship point=ship to=address]
^- call-data
:- 'sendPoint(uint32,uint32,address)'
:~ [%uint `@`as]
[%uint `@`point]
[%address to]
==
--
::
:: ++ peer-sole

View File

@ -0,0 +1,37 @@
:: |claz-invites:
::
/+ keygen
=, ethereum
::
:- %say
|= $: [now=@da eny=@uvJ =beak]
[star=ship min-child=@ud max-child=@ud out=path ~]
~
==
?: (gth min-child max-child)
~| [%weird-range min=min-child max=max-child]
!!
?: (gth max-child 0xffff)
~| [%max-beyond-planet-space max-child]
!!
~& 'patience, slow derivation...'
:- %kiln-info
:- "wrote generated invites to {(spud out)}"
%- some
%+ foal:space:userlib out
:- %txt
!>
%+ turn (gulf min-child max-child)
|= child=@ud
=/ who=ship (cat 4 star child)
=/ ticket=@q (end 3 8 (shas who eny))
=/ owner=address
=< addr.keys
::NOTE ~zod because invite wallet convention
(ownership-wallet-from-ticket:keygen ~zod 8^ticket ~)
%- crip
;: weld
(scow %p who) ","
(slag 1 (scow %q ticket)) ","
(address-to-hex:ethereum owner)
==