various: removed unused/wip files

This commit is contained in:
yosoyubik 2021-11-10 06:23:36 +01:00
parent 185fd1f979
commit 48fd671b9a
2 changed files with 0 additions and 669 deletions

View File

@ -1,594 +0,0 @@
:: roller-cli: CLI for L2 Azimuth Rollers
::
:: TODO: commands
::
:: client | roller
:: _________|___________
:: - CLI command
:: [%track 0x1234.abcd]
:: - init subscriptions to the roller
:: watch --> /point/[0x1234.abcd] - point updates
:: watch --> /tx/[0x1234.abcd] - tx status updates
::
:: ----------------------
:: Submit Txs
:: poke --tx--> +take-tx
::
:: ---------------------
:: Receive Tx status updates
:: watch /tx/[0x1234.abcd]
::
:: <--(list roller-tx:dice)-- - init
:: <--[address roller-tx:dice]-- - update
:: <--%kick-sub-- ?: ?=(?(%confirmed %failed) tx-status)
:: ---------------------
:: Receive Point updates (i.e. nonces)
:: watch /point/[0x1234.abcd]
::
:: <-(list point:naive)- - init
:: <-[address point:naive]- - update
::
/- *dice
/+ *dice,
naive,
lib=naive-transactions,
*fake-roller,
shoe,
verb,
dbug,
default-agent,
ethereum
|%
+$ app-state
$: %0
:: TODO: keep track of sessions
::
:: sessions=(map sole-id session)
points=(jug address:ethereum [ship point:naive])
history=(jug address:ethereum roller-tx)
unsigned-txs=(jug address:ethereum [keccak tx:naive])
:: TODO: track pub/prv keys
::
:: keys=(list (pair address:ethereum address:ethereum)
==
::
+$ card card:shoe
::
+$ command
$% :: List all possible L2 tx types
::
[%l2-tx ~] :: ?
:: Loads a new address (login?)
:: — should require signing?
:: - it subscribes to the Roller, for updates to it
:: - innitially receives a list of points (if any) it controls
::
:: [%track pubkey=address:ethereum prvkey=address:ethereum]
[%track address:ethereum]
:: Table of all submitted txs, by address
::
[%history address:ethereum]
:: Table of all unsigned txs, by address
::
[%show-unsigned ~]
:: Signs and Submit an unsigned txs (signed)
::
[%submit address:ethereum tx:naive]
:: Cancels a submitted (but pending) txs
::
[%cancel ~]
:: Ships owned by an address
::
[%ships address:ethereum]
:: Point data for a given ship
::
[%point address:ethereum ship]
:: Example flow
::
[%example-flow ~]
==
--
=| app-state
=* state -
::
%+ verb |
%- agent:dbug
^- agent:gall
%- (agent:shoe command)
^- (shoe:shoe command)
:: => |%
:: ++ get-address-points
:: |= [roller=@p =address:ethereum]
:: :* %pass
:: /roller-points
:: %agent
:: [roller %azimuth]
:: %watch
:: /address/[address]
:: ==
:: --
|_ =bowl:gall
+* this .
def ~(. (default-agent this %|) bowl)
des ~(. (default:shoe this command) bowl)
::
++ on-init on-init:def
++ on-save !>(state)
++ on-load
|= old=vase
^- (quip card _this)
[~ this(state !<(app-state old))]
:: |^
:: =+ !<(old-state=app-states old)
:: |-
:: ?- -.old-state
:: %0 $(old-state [%1 ~ ~ ~])
:: %1 $(old-state [%2 ~ ~ ~])
:: %2 [~ this(state old-state)]
:: ==
:: ++ app-states $%([%0 ~] [%1 *] app-state)
:: --
::
++ on-poke
|= [=mark =vase]
^- (quip card _this)
~&
=/ addr=@ux
0x6def.fb0c.afdb.11d1.75f1.23f6.891a.a64f.01c2.4f7d
:: %+ turn
~(tap in (~(get ju points) addr))
:: head
[~ this]
++ on-watch on-watch:def
++ on-leave on-leave:def
:: +on-peek: scry paths
::
:: /x/ships/[0x1234.abcd] -> %noun (list ship)
::
++ on-peek
|= =path
^- (unit (unit cage))
|^
?+ path ~
[%x %ships @ ~] (ships i.t.t.path)
==
::
++ ships
|= wat=@t
:+ ~ ~
:- %noun
!> ^- (list ship)
?~ addr=(slaw %ux wat) ~
%+ turn
~(tap in (~(get ju points) u.addr))
head
--
::
++ on-agent
|= [=wire =sign:agent:gall]
^- (quip card _this)
|^
?+ wire (on-agent:def wire sign)
[%points @ ~] (get-points i.t.wire sign)
[%txs @ ~] (get-txs i.t.wire sign)
==
::
++ get-points
|= [wat=@t =sign:agent:gall]
^- (quip card _this)
?+ -.sign (on-agent:def wire sign)
%fact
?+ p.cage.sign (on-agent:def wire sign)
%points
?~ addr=(slaw %ux wat) (on-agent:def wire sign)
=+ !<(points=(list [ship point:naive]) q.cage.sign)
=. points.state
%- ~(gas ju points.state)
(turn points (cork same (lead u.addr)))
[~ this]
::
%point
?~ addr=(slaw %ux wat) (on-agent:def wire sign)
=+ !<(new-point=[=ship =point:naive] q.cage.sign)
:: TODO: handle multiple sole sessions?
::
:: =/ sez=(list [=sole-id =session])
:: ~(tap by sessions)
=/ console=tape
"Point update ({(scow %p ship.new-point)})"
=. points.state
:: FIXME: doesn't properly update point
:: handle proper insert/deletion of points
:: to account for ownership changes/nonce updates
::
=; [is-owner=? old=(unit [=ship =point:naive])]
?~ old points.state
=. points.state
(~(del ju points.state) u.addr u.old)
?. is-owner points.state
(~(put ju points.state) [u.addr new-point])
=/ points=(list [=ship =point:naive])
~(tap in (~(get ju points.state) u.addr))
|- ^- [? (unit [ship point:naive])]
|^
?~ points [| ~]
?. =(ship.i.points ship.new-point)
$(points t.points)
:- is-owner
`[ship.new-point point.i.points]
::
++ is-owner
=* own own.point.new-point
?| =(u.addr address.owner.own)
=(u.addr address.spawn-proxy.own)
=(u.addr address.management-proxy.own)
=(u.addr address.voting-proxy.own)
=(u.addr address.transfer-proxy.own)
==
--
:: %- ~(run in points)
:: |= old=[=ship =point:naive]
:: ?. =(ship.old ship.new)
:: old
:: point.new
:: (~(put ju points.state) [u.addr point])
~& :- %ships
(turn ~(tap in (~(get ju points.state) u.addr)) head)
:_ this
:_ ~
:- %shoe
:- ~
:- %sole
?. =(src our):bowl
[%txt console]
[%klr [[`%br ~ `%g] [(crip console)]~]~]
==
==
::
++ get-txs
|= [wat=@t =sign:agent:gall]
^- (quip card _this)
?+ -.sign (on-agent:def wire sign)
%fact
?~ addr=(slaw %ux wat) (on-agent:def wire sign)
?+ p.cage.sign (on-agent:def wire sign)
%txs
=+ !<(txs=(list roller-tx) q.cage.sign)
=. history.state
%- ~(gas ju history.state)
(turn txs (cork same (lead u.addr)))
[~ this]
::
%tx
?~ addr=(slaw %ux wat) (on-agent:def wire sign)
=+ !<(=roller-tx q.cage.sign)
=/ hash=tape
=+ hash=(scow %ux hash.roller-tx)
=+ len=(lent hash)
;: weld
(swag [0 6] hash)
"..."
(swag [(sub len 4) len] hash)
==
=/ console=tape
"Tx hash: {hash} -> {(trip status.roller-tx)}"
=. history.state (update-tx u.addr roller-tx)
:: ~& console
:_ this
:_ ~
:- %shoe
:- ~
:- %sole
?. =(src our):bowl
[%txt console]
[%klr [[`%br ~ `%g] [(crip console)]~]~]
==
==
::
++ update-tx
|= [=address:ethereum =roller-tx]
%. [address roller-tx]
?+ status.roller-tx ~(put ju history.state)
%pending
~(put ju history.state)
::
%sending
%~ put ju
%- ~(del ju history.state)
[address roller-tx(status %pending)]
::
%confirmed
%~ put ju
%- ~(del ju history.state)
[address roller-tx(status %sending)]
::
%failed
:: TODO: make it not ugly
::
%~ put ju
%- %~ del ju
%- ~(del ju history.state)
[address roller-tx(status %sending)]
[address roller-tx(status %pending)]
==
--
::
++ on-arvo on-arvo:def
++ on-fail on-fail:def
::
++ command-parser
|= sole-id=@ta
^+ |~(nail *(like [? command]))
:: wait for 'enter' to run the command
::
|^
%+ stag |
:: (perk %demo %row %table %track %submit %history ~)
;~ pose
;~(plug (tag %track) ;~(pfix (jest ' 0x') hex))
;~(plug (tag %example-flow) (easy ~))
;~(plug (tag %history) ;~(pfix (jest ' 0x') hex))
;~((glue ace) (tag %submit) submit)
;~((glue ace) (tag %ships) address)
;~((glue ace) (tag %point) address ;~(pfix sig fed:ag))
==
::
++ tag |*(a=@tas (cold a (jest a))) :: TODO (from /app/chat-cli) into stdlib
++ address ;~(pfix (jest '0x') hex)
++ sponsorship
%- perk
:~ %escape
%cancel-escape
%adopt
%reject
%detach
==
::
++ ownership
%- perk
:~ %set-management-proxy
%set-spawn-proxy
%set-transfer-proxy
==
::
++ proxies
(perk %own %spawn %manage %vote %transfer ~)
++ submit
%+ cook ,[address:naive tx:naive]
;~ (glue ace)
address
:: from=[ship proxy:naive]
::
%+ cook ,[ship proxy:naive]
%+ ifix [sel ser]
;~((glue ace) ;~(pfix sig fed:ag) proxies)
:: skim-tx:naive
::
%+ cook ,skim-tx:naive
;~ pose
:: [%transfer-point =address reset=?]
::
;~ (glue ace)
(perk %transfer-point ~)
address
;~(pose (cold & (just 'y')) (cold | (just 'n')))
==
:: [%spawn ship address:naive]
::
;~ (glue ace)
(perk %spawn ~)
;~(pfix sig fed:ag)
address
==
:: [%configure-keys encrypt=@ auth=@ crypto-suite=@ breach=?]
::
;~ (glue ace)
(perk %configure-keys ~)
address
address
dem
;~(pose (cold & (just 'y')) (cold | (just 'n')))
==
:: [?([%escape %cancel-escape %adopt %reject %detach]) ship]
::
;~((glue ace) sponsorship ;~(pfix sig fed:ag))
:: $: ?([%set-management-proxy %set-spawn-proxy %set-transfer-proxy])
:: address
:: ==
::
;~((glue ace) ownership address)
==
==
--
::
++ tab-list
|= sole-id=@ta
^- (list [@t tank])
:~ ['txs' leaf+"list available L2 transaction"]
['submit' leaf+"sends| a L2 transaction to the Roller"]
['cancel' leaf+"cancels a (pending) L2 transaction"]
['history' leaf+"shows all current submitted transactions"]
['track' leaf+"loads an ethereum address and tracks points and L2 txs"]
==
::
++ on-command
|= [sole-id=@ta =command]
^- (quip card _this)
|^
?+ -.command !!
%track (track +.command)
%submit (submit +.command)
%history (history +.command)
%ships (ships +.command)
%point (point +.command)
%example-flow example-flow
==
::
++ example-flow
^- (quip card _this)
=/ address=@t '0x6deffb0cafdb11d175f123f6891aa64f01c24f7d '
=/ spawn=@t '0xf48062ae8bafd6ef19cd6cb89db93a0d0ca6ce26'
=/ track=@t 'track 0x6deffb0cafdb11d175f123f6891aa64f01c24f7d'
=/ ships=@t 'ships 0x6deffb0cafdb11d175f123f6891aa64f01c24f7d'
=/ tx1=@t
%- crip
:~ 'submit '
address
'[~wanzod own] '
'set-spawn-proxy '
address
==
=/ tx2=@t
%- crip
:~ 'submit '
address
'[~wanzod own] '
'spawn '
'~modlep-fosreg '
spawn
==
=/ failed-tx=@t
%- crip
:~ 'submit '
'0x6deffb0cafdb11d175f123f6891aa64f01c24f7d '
'[~wanzod own] '
'spawn '
'~marzod '
'0xf'
==
=/ example-a=@t '- lists ships controlled by the given address :: '
=/ example-b=@t '- receives updates signed by the given address :: '
=/ example-c=@t '- this tx will fail :: '
:_ this
:_ ~
^- card
:- %shoe
^- [(list _sole-id) shoe-effect:shoe]
:- [sole-id]~
^- shoe-effect:shoe
:- %sole
?. =(src our):bowl
[%txt "1234"]
:- %mor
:~ [%klr ~[[[~ ~ `%g] [example-a]~] [``~ [ships]~]]]
[%klr ~[[[~ ~ `%b] [example-b]~] [``~ [track]~]]]
[%klr ~[[[~ ~ `%r] [example-c]~] [``~ [failed-tx]~]]]
==
::
++ submit
|= [=address:ethereum =tx:naive]
^- (quip card _this)
=/ owner=(unit [=nonce:naive =point:naive])
=/ points=(list [=ship =point:naive])
~(tap in (~(get ju points) address))
|- ^- (unit [nonce:naive point:naive])
?~ points ~
?. =(ship.from.tx ship.i.points)
$(points t.points)
`(get-owner point.i.points proxy.from.tx)
:: =< `[nonce point.i.points]
:: (proxy-from-point:naive proxy.from.tx point.i.points)
?~ owner ~& "empty points" [~ this]
=/ =keccak
%- hash-tx:lib
(unsigned-tx:lib 1.337 nonce.u.owner (gen-tx-octs:lib tx))
=/ sig=octs (fake-sig tx address nonce.u.owner)
=. points
%+ ~(put ju points) address
[ship.from.tx point.u.owner]
:_ this
:_ ~
:* %pass
/pokepath
%agent
[our.bowl %roller]
%poke
roller-action+!>([%submit | address q.sig %don tx])
==
::
++ track
|= =address:ethereum
^- (quip card _this)
=/ [to=(list _sole-id) fec=shoe-effect:shoe]
:- [sole-id]~
:- %sole
=/ =tape "Listening to updates for {(scow %ux address)}"
?. =(src our):bowl
[%txt tape]
[%klr [[`%br ~ `%g] [(crip tape)]~]~]
:: :_ this(keys (snoc keys address))
:_ this
:~ [%shoe to fec]
:^ %pass /points/[(scot %ux address)] %agent
[[our.bowl %roller] %watch /points/[(scot %ux address)]]
::
:^ %pass /txs/[(scot %ux address)] %agent
[[our.bowl %roller] %watch /txs/[(scot %ux address)]]
==
::
++ history
|= =address:ethereum
^- (quip card _this)
:_ this
=; [to=(list _sole-id) fec=shoe-effect:shoe]
[%shoe to fec]~
:- [sole-id]~
:^ %table
:: ~[t+'address' t+'signing ship' t+'type' t+'status' t+'hash']
~[t+'signing ship' t+'type' t+'status' t+'hash' t+'time']
~[14 20 9 13 26]
%+ turn
%+ sort ~(tap in (~(get ju history.state) address))
|=([a=roller-tx b=roller-tx] (lth time.a time.b))
|= roller-tx
|^ ~[p+ship t+type t+status pack-hash t+(scot %da time)]
::
++ pack-address
=+ addr=(scow %ux address)
=+ len=(lent addr)
:- %t
%- crip
;: weld
(swag [0 6] addr)
"..."
(swag [(sub len 4) len] addr)
==
::
++ pack-hash
=+ hash=(scow %ux hash)
=+ len=(lent hash)
:- %t
%- crip
;: weld
(swag [0 6] hash)
"..."
(swag [(sub len 4) len] hash)
==
--
::
++ ships
|= =address:ethereum
^- (quip card _this)
~& ships+(turn ~(tap in (~(get ju points) address)) head)
[~ this]
::
++ point
|= [=address:ethereum =ship]
^- (quip card _this)
=/ points=(set [@p point:naive])
(~(get ju points.state) address)
~& %+ skim ~(tap in points)
|=([s=@p =point:naive] =(s ship))
[~ this]
--
::
++ can-connect
|= sole-id=@ta
^- ?
?| =(~zod src.bowl)
(team:title [our src]:bowl)
==
::
++ on-connect on-connect:des
++ on-disconnect on-disconnect:des
--

View File

@ -1,75 +0,0 @@
/- *dice
/+ naive, lib=naive-transactions
::
:: Addresses derived from mnemonic:
::
:: benefit crew supreme gesture quantum web
:: media hazard theory mercy wing kitten
::
:: Available Accounts
:: ==================
:: (0) 0x6deffb0cafdb11d175f123f6891aa64f01c24f7d (100 eth)
:: (1) 0xd53208cf45fc9bd7938b200bff8814a26146688f (100 eth)
:: (2) 0x7b2a2d51e4d8fac602e20a5f6907ff9fbd88e1fd (100 eth)
:: (3) 0xf48062ae8bafd6ef19cd6cb89db93a0d0ca6ce26 (100 eth)
:: (4) 0xf84a77aeb351c49dfa87e805a659d2daddff7606 (100 eth)
:: (5) 0x167e357cf8b845370d0d408f9b389b66185b7b5b (100 eth)
:: (6) 0xcbecf3abc9878f07afc851aead2d8f1c436cc71d (100 eth)
:: (7) 0x0afc0c3f4eeea500871f464ca71eef5e54a9af36 (100 eth)
:: (8) 0x6d654ef2489674d21aed428e8a4ad8ca4820f125 (100 eth)
:: (9) 0x218f6f87683db546ad47a5dc8b480e5a9b694866 (100 eth)
:: private keys
:: ==================
:: (0) 0xa44de2416ee6beb2f323fab48b432925c9785808d33a6ca6d7ba00b45e9370c3
:: (1) 0x420b20f3538f7ddf4527770acbd33ed8aa858ba24eec5038bd22158f23a8a002
:: (2) 0x655eae6e301ebe9da6384f717f774f6addb165606a6990ce13e86ead710fff8b
:: (3) 0x2480c5256d843c73cba67cc966a11a647c943a41db2fa138de4e4f16d0861a6b
:: (4) 0xd6abd8fbab1db8714f1e284c11b8621cf95d0e319b4f38c54de4247f2150f1ba
:: (5) 0x95f48754f44e6930473367a0802bdac7389e7749df2b3a6dd6e87bcbe0d0e0bc
:: (6) 0x92596e42f9ee7a47e0d8c48291c768945fede98874cc250202a1f19f12c97be3
:: (7) 0xa0ae1d77d89854a55a4abdc1300e989b1981728e8e669cfb4b4179f0af1ac389
:: (8) 0x7aec9f8027edaa2408ac5ca74b5ed929e271570a0eeed848f47bcee842902c16
:: (9) 0x58d62eb79797502bc0f66cd3e7a49d00287bff53a2734b799ef09cb746340ed0
::
|%
++ prv-from-address
|= =address:naive
^- @
?: =(address 0x6def.fb0c.afdb.11d1.75f1.23f6.891a.a64f.01c2.4f7d)
0xa44d.e241.6ee6.beb2.f323.fab4.8b43.2925.
c978.5808.d33a.6ca6.d7ba.00b4.5e93.70c3
?: =(address 0xd532.08cf.45fc.9bd7.938b.200b.ff88.14a2.6146.688f)
0x420b.20f3.538f.7ddf.4527.770a.cbd3.3ed8.
aa85.8ba2.4eec.5038.bd22.158f.23a8.a002
?: =(address 0x7b2a.2d51.e4d8.fac6.02e2.0a5f.6907.ff9f.bd88.e1fd)
0x655e.ae6e.301e.be9d.a638.4f71.7f77.4f6a.
ddb1.6560.6a69.90ce.13e8.6ead.710f.ff8b
?: =(address 0xf480.62ae.8baf.d6ef.19cd.6cb8.9db9.3a0d.0ca6.ce26)
0x2480.c525.6d84.3c73.cba6.7cc9.66a1.1a64.
7c94.3a41.db2f.a138.de4e.4f16.d086.1a6b
?: =(address 0xf84a.77ae.b351.c49d.fa87.e805.a659.d2da.ddff.7606)
0xd6ab.d8fb.ab1d.b871.4f1e.284c.11b8.621c.
f95d.0e31.9b4f.38c5.4de4.247f.2150.f1ba
?: =(address 0x167e.357c.f8b8.4537.0d0d.408f.9b38.9b66.185b.7b5b)
0x95f4.8754.f44e.6930.4733.67a0.802b.dac7.
389e.7749.df2b.3a6d.d6e8.7bcb.e0d0.e0bc
?: =(address 0xcbec.f3ab.c987.8f07.afc8.51ae.ad2d.8f1c.436c.c71d)
0x9259.6e42.f9ee.7a47.e0d8.c482.91c7.6894.
5fed.e988.74cc.2502.02a1.f19f.12c9.7be3
?: =(address 0xafc.0c3f.4eee.a500.871f.464c.a71e.ef5e.54a9.af36)
0xa0ae.1d77.d898.54a5.5a4a.bdc1.300e.989b.
1981.728e.8e66.9cfb.4b41.79f0.af1a.c389
?: =(address 0x6d65.4ef2.4896.74d2.1aed.428e.8a4a.d8ca.4820.f125)
0x7aec.9f80.27ed.aa24.08ac.5ca7.4b5e.d929.
e271.570a.0eee.d848.f47b.cee8.4290.2c16
?. =(address 0x218f.6f87.683d.b546.ad47.a5dc.8b48.0e5a.9b69.4866) !!
0x58d6.2eb7.9797.502b.c0f6.6cd3.e7a4.9d00.287b.
ff53.a273.4b79.9ef0.9cb7.4634.0ed0
::
++ fake-sig
|= [=tx:naive =address:naive =nonce:naive]
^- octs
(gen-tx:lib nonce tx (prv-from-address address))
::
--