mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-24 15:34:10 +03:00
naive: add ownership index to /app/azimuth
This commit is contained in:
parent
8ea0ee004e
commit
5eb07edde5
@ -163,7 +163,7 @@
|
|||||||
|= =address:naive
|
|= =address:naive
|
||||||
.^ (list [ship point:naive])
|
.^ (list [ship point:naive])
|
||||||
%gx
|
%gx
|
||||||
(~(scry agentio bowl) %aggregator /points/(scot %ux address)/noun)
|
(~(scry agentio bowl) %azimuth /points/(scot %ux address)/noun)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ spawned
|
++ spawned
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
=, jael
|
=, jael
|
||||||
|%
|
|%
|
||||||
++ app-state
|
++ app-state
|
||||||
$: %2
|
$: %3
|
||||||
url=@ta
|
url=@ta
|
||||||
whos=(set ship)
|
whos=(set ship)
|
||||||
nas=^state:naive
|
nas=^state:naive
|
||||||
|
own=owners
|
||||||
logs=(list =event-log:rpc:ethereum)
|
logs=(list =event-log:rpc:ethereum)
|
||||||
==
|
==
|
||||||
+$ poke-data
|
+$ poke-data
|
||||||
@ -29,6 +30,7 @@
|
|||||||
+$ tagged-diff [=id:block diff:naive]
|
+$ tagged-diff [=id:block diff:naive]
|
||||||
::
|
::
|
||||||
+$ network ?(%mainnet %ropsten %local)
|
+$ network ?(%mainnet %ropsten %local)
|
||||||
|
+$ owners (jug address:naive [ship point:naive])
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
|%
|
|%
|
||||||
@ -68,15 +70,43 @@
|
|||||||
?: =(data '0x') *@ux
|
?: =(data '0x') *@ux
|
||||||
(hex-to-num:ethereum data)
|
(hex-to-num:ethereum data)
|
||||||
::
|
::
|
||||||
|
++ update-ownership
|
||||||
|
|= [=diff:naive own=owners old=(unit point:naive) new=point:naive]
|
||||||
|
^+ own
|
||||||
|
?. ?=([%point *] diff) own
|
||||||
|
=* event +>.diff
|
||||||
|
=; [to=@ux from=@ux]
|
||||||
|
=? own !=(from 0x0)
|
||||||
|
?> ?=(^ old)
|
||||||
|
(~(del ju own) from [ship.diff u.old])
|
||||||
|
?: =(to 0x0) own
|
||||||
|
(~(put ju own) to [ship.diff new])
|
||||||
|
?+ -.event [0x0 0x0]
|
||||||
|
%owner
|
||||||
|
[+.event ?~(old 0x0 address.owner.own.u.old)]
|
||||||
|
::
|
||||||
|
%spawn-proxy
|
||||||
|
[+.event ?~(old 0x0 address.transfer-proxy.own.u.old)]
|
||||||
|
::
|
||||||
|
%management-proxy
|
||||||
|
[+.event ?~(old 0x0 address.management-proxy.own.u.old)]
|
||||||
|
::
|
||||||
|
%voting-proxy
|
||||||
|
[+.event ?~(old 0x0 address.voting-proxy.own.u.old)]
|
||||||
|
::
|
||||||
|
%transfer-proxy
|
||||||
|
[+.event ?~(old 0x0 address.spawn-proxy.own.u.old)]
|
||||||
|
==
|
||||||
|
::
|
||||||
++ run-logs
|
++ run-logs
|
||||||
|= [nas=^state:naive logs=(list event-log:rpc:ethereum) =network]
|
|= [state=app-state logs=(list event-log:rpc:ethereum)]
|
||||||
^- [(list tagged-diff) ^state:naive]
|
^- [(list tagged-diff) _state]
|
||||||
=/ [contract=@ux * chain-id=@ *] (get-network network)
|
=/ [contract=@ux * chain-id=@ *] (get-network net)
|
||||||
?~ logs
|
?~ logs
|
||||||
`nas
|
`state
|
||||||
?~ mined.i.logs
|
?~ mined.i.logs
|
||||||
$(logs t.logs)
|
$(logs t.logs)
|
||||||
=^ raw-effects nas
|
=/ [raw-effects=effects:naive new-nas=_nas.state]
|
||||||
=/ =^input:naive
|
=/ =^input:naive
|
||||||
?: =(contract address.i.logs)
|
?: =(contract address.i.logs)
|
||||||
=/ data (data-to-hex data.i.logs)
|
=/ data (data-to-hex data.i.logs)
|
||||||
@ -88,16 +118,26 @@
|
|||||||
[%bat u.input.u.mined.i.logs]
|
[%bat u.input.u.mined.i.logs]
|
||||||
=/ res
|
=/ res
|
||||||
%- mule
|
%- mule
|
||||||
|.((%*(. naive lac |) verifier chain-id nas input))
|
|.((%*(. naive lac |) verifier chain-id nas.state input))
|
||||||
?- -.res
|
?- -.res
|
||||||
%& p.res
|
%& p.res
|
||||||
%| ((slog 'naive-fail' p.res) `nas)
|
%| ((slog 'naive-fail' p.res) `nas.state)
|
||||||
==
|
==
|
||||||
|
=. own.state
|
||||||
|
%+ roll raw-effects
|
||||||
|
|= [=diff:naive own=_own.state]
|
||||||
|
^+ own
|
||||||
|
=, orm:naive
|
||||||
|
?. ?=([%point *] diff) own
|
||||||
|
=/ old=(unit point:naive) (get points.nas.state ship.diff)
|
||||||
|
=/ new=point:naive (need (get points.new-nas ship.diff))
|
||||||
|
(update-ownership diff own old new)
|
||||||
|
=. nas.state new-nas
|
||||||
=/ effects-1
|
=/ effects-1
|
||||||
=/ =id:block [block-hash block-number]:u.mined.i.logs
|
=/ =id:block [block-hash block-number]:u.mined.i.logs
|
||||||
(turn raw-effects |=(=diff:naive [id diff]))
|
(turn raw-effects |=(=diff:naive [id diff]))
|
||||||
=^ effects-2 nas $(logs t.logs)
|
=^ effects-2 state $(logs t.logs)
|
||||||
[(welp effects-1 effects-2) nas]
|
[(welp effects-1 effects-2) state]
|
||||||
::
|
::
|
||||||
++ to-udiffs
|
++ to-udiffs
|
||||||
|= effects=(list tagged-diff)
|
|= effects=(list tagged-diff)
|
||||||
@ -199,14 +239,28 @@
|
|||||||
- %2
|
- %2
|
||||||
nas *^state:naive
|
nas *^state:naive
|
||||||
==
|
==
|
||||||
`this(state ?>(?=(%2 -.old-state) old-state))
|
=? old-state ?=(%2 -.old-state)
|
||||||
|
%= old-state
|
||||||
|
- %3
|
||||||
|
own *owners
|
||||||
|
==
|
||||||
|
`this(state ?>(?=(%3 -.old-state) old-state))
|
||||||
::
|
::
|
||||||
++ app-states $%(app-state-0 app-state-1 app-state)
|
++ app-states $%(app-state-0 app-state-1 app-state-2 app-state)
|
||||||
|
++ app-state-2
|
||||||
|
$: %2
|
||||||
|
url=@ta
|
||||||
|
whos=(set ship)
|
||||||
|
nas=^state:naive
|
||||||
|
own=*
|
||||||
|
logs=(list =event-log:rpc:ethereum)
|
||||||
|
==
|
||||||
++ app-state-1
|
++ app-state-1
|
||||||
$: %1
|
$: %1
|
||||||
url=@ta
|
url=@ta
|
||||||
whos=(set ship)
|
whos=(set ship)
|
||||||
nas=*
|
nas=*
|
||||||
|
own=*
|
||||||
logs=(list =event-log:rpc:ethereum)
|
logs=(list =event-log:rpc:ethereum)
|
||||||
==
|
==
|
||||||
++ app-state-0
|
++ app-state-0
|
||||||
@ -214,6 +268,7 @@
|
|||||||
url=@ta
|
url=@ta
|
||||||
whos=(set ship)
|
whos=(set ship)
|
||||||
nas=*
|
nas=*
|
||||||
|
own=*
|
||||||
logs=(list =event-log-0)
|
logs=(list =event-log-0)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
@ -239,7 +294,7 @@
|
|||||||
?+ q.vase !!
|
?+ q.vase !!
|
||||||
%rerun
|
%rerun
|
||||||
~& [%rerunning (lent logs.state)]
|
~& [%rerunning (lent logs.state)]
|
||||||
=^ effects nas.state (run-logs *^state:naive logs.state net)
|
=^ effects state (run-logs state logs.state)
|
||||||
`this
|
`this
|
||||||
::
|
::
|
||||||
%resub
|
%resub
|
||||||
@ -288,8 +343,17 @@
|
|||||||
|= =path
|
|= =path
|
||||||
^- (unit (unit cage))
|
^- (unit (unit cage))
|
||||||
?+ path (on-peek:def path)
|
?+ path (on-peek:def path)
|
||||||
[%x %logs ~] ``logs+!>(logs.state)
|
[%x %logs ~] ``logs+!>(logs.state)
|
||||||
[%x %nas ~] ``nas+!>(nas.state)
|
[%x %nas ~] ``nas+!>(nas.state)
|
||||||
|
[%x %points @ ~]
|
||||||
|
=* wat i.t.t.path
|
||||||
|
:+ ~ ~
|
||||||
|
:- %noun
|
||||||
|
!> ^- (list [ship point:naive])
|
||||||
|
?~ addr=(slaw %ux wat)
|
||||||
|
~
|
||||||
|
%~ tap in
|
||||||
|
(~(get ju own.state) u.addr)
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ on-agent
|
++ on-agent
|
||||||
@ -311,9 +375,9 @@
|
|||||||
%logs (welp logs.state loglist.diff)
|
%logs (welp logs.state loglist.diff)
|
||||||
==
|
==
|
||||||
=? nas.state ?=(%history -.diff) *^state:naive
|
=? nas.state ?=(%history -.diff) *^state:naive
|
||||||
=^ effects nas.state
|
=^ effects state
|
||||||
=; nas=^state:naive
|
=; nas=^state:naive
|
||||||
(run-logs nas loglist.diff net)
|
(run-logs state(nas nas) loglist.diff)
|
||||||
?- -.diff
|
?- -.diff
|
||||||
:: %history *^state:naive
|
:: %history *^state:naive
|
||||||
%history nas.state
|
%history nas.state
|
||||||
|
@ -176,12 +176,10 @@
|
|||||||
+$ state
|
+$ state
|
||||||
$: =points
|
$: =points
|
||||||
=operators
|
=operators
|
||||||
=owners
|
|
||||||
dns=(list @t)
|
dns=(list @t)
|
||||||
==
|
==
|
||||||
+$ points (tree [ship point])
|
+$ points (tree [ship point])
|
||||||
+$ operators (jug address address)
|
+$ operators (jug address address)
|
||||||
+$ owners (jug address [ship point])
|
|
||||||
+$ effects (list diff)
|
+$ effects (list diff)
|
||||||
+$ proxy ?(%own %spawn %manage %vote %transfer)
|
+$ proxy ?(%own %spawn %manage %vote %transfer)
|
||||||
+$ roll (list raw-tx)
|
+$ roll (list raw-tx)
|
||||||
@ -468,35 +466,6 @@
|
|||||||
==
|
==
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
::
|
|
||||||
++ is-ownership-log
|
|
||||||
|= log=@ux
|
|
||||||
^- ?
|
|
||||||
=, log-names
|
|
||||||
?| =(log owner-changed)
|
|
||||||
=(log changed-transfer-proxy)
|
|
||||||
=(log changed-management-proxy)
|
|
||||||
=(log changed-voting-proxy)
|
|
||||||
=(log changed-spawn-proxy)
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ address-from-log
|
|
||||||
|= [log=@ux point]
|
|
||||||
^- (unit address)
|
|
||||||
=, log-names
|
|
||||||
?: =(log owner-changed)
|
|
||||||
`address.owner.own
|
|
||||||
?: =(log changed-transfer-proxy)
|
|
||||||
`address.transfer-proxy.own
|
|
||||||
?: =(log changed-management-proxy)
|
|
||||||
`address.management-proxy.own
|
|
||||||
?: =(log changed-voting-proxy)
|
|
||||||
`address.voting-proxy.own
|
|
||||||
?. =(log changed-spawn-proxy)
|
|
||||||
:: TODO: better way to handle this?
|
|
||||||
::
|
|
||||||
~>(%slog.[0 %unknown-log] ~)
|
|
||||||
`address.spawn-proxy.own
|
|
||||||
-- =>
|
-- =>
|
||||||
|%
|
|%
|
||||||
:: Receive log from L1 transaction
|
:: Receive log from L1 transaction
|
||||||
@ -539,19 +508,8 @@
|
|||||||
=/ the-point (get-point state ship)
|
=/ the-point (get-point state ship)
|
||||||
?> ?=(^ the-point)
|
?> ?=(^ the-point)
|
||||||
=* point u.the-point
|
=* point u.the-point
|
||||||
=; [=effects new-point=^point]
|
=- [effects state(points (put:orm points.state ship new-point))]
|
||||||
=? owners.state (is-ownership-log log-name)
|
^- [=effects new-point=^point]
|
||||||
?> ?=([@ ~] t.t.topics.log)
|
|
||||||
=* to i.t.t.topics.log
|
|
||||||
?~ address=(address-from-log log-name new-point)
|
|
||||||
owners.state
|
|
||||||
?: =(deposit-address to)
|
|
||||||
(~(put ju owners.state) u.address [ship new-point])
|
|
||||||
:: remove point from previous owner and add it to new one
|
|
||||||
::
|
|
||||||
%. [to ship new-point]
|
|
||||||
~(put ju (~(del ju owners.state) u.address [ship point]))
|
|
||||||
[effects state(points (put:orm points.state ship new-point))]
|
|
||||||
::
|
::
|
||||||
?: =(log-name changed-spawn-proxy:log-names)
|
?: =(log-name changed-spawn-proxy:log-names)
|
||||||
?> ?=(%l1 -.point)
|
?> ?=(%l1 -.point)
|
||||||
@ -738,9 +696,7 @@
|
|||||||
=/ res=(unit [=effects new-point=^point]) (fun u.point rest)
|
=/ res=(unit [=effects new-point=^point]) (fun u.point rest)
|
||||||
?~ res
|
?~ res
|
||||||
~
|
~
|
||||||
:- ~
|
`[effects.u.res state(points (put:orm points.state ship new-point.u.res))]
|
||||||
:- effects.u.res
|
|
||||||
state(points (put:orm points.state ship new-point.u.res))
|
|
||||||
::
|
::
|
||||||
++ process-transfer-point
|
++ process-transfer-point
|
||||||
|= [=point to=address reset=?]
|
|= [=point to=address reset=?]
|
||||||
@ -749,7 +705,6 @@
|
|||||||
::
|
::
|
||||||
?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
|
?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
|
||||||
(debug %bad-permission ~)
|
(debug %bad-permission ~)
|
||||||
=/ previous-owner address.owner.own.point
|
|
||||||
:: Execute transfer
|
:: Execute transfer
|
||||||
::
|
::
|
||||||
=/ effects-1
|
=/ effects-1
|
||||||
@ -757,17 +712,10 @@
|
|||||||
=: address.owner.own.point to
|
=: address.owner.own.point to
|
||||||
address.transfer-proxy.own.point *address
|
address.transfer-proxy.own.point *address
|
||||||
==
|
==
|
||||||
=; [=effects new-point=^point]
|
|
||||||
=. owners.state
|
|
||||||
:: remove point from previous owner and add it to new one
|
|
||||||
::
|
|
||||||
%. [to ship new-point]
|
|
||||||
~(put ju (~(del ju owners.state) previous-owner [ship point]))
|
|
||||||
`[effects point]
|
|
||||||
:: Execute reset if requested
|
:: Execute reset if requested
|
||||||
::
|
::
|
||||||
?. reset
|
?. reset
|
||||||
[effects-1 point]
|
`[effects-1 point]
|
||||||
::
|
::
|
||||||
=^ effects-2 net.point
|
=^ effects-2 net.point
|
||||||
?: =([0 0 0] +.keys.net.point)
|
?: =([0 0 0] +.keys.net.point)
|
||||||
@ -791,7 +739,7 @@
|
|||||||
address.voting-proxy.own.point *address
|
address.voting-proxy.own.point *address
|
||||||
address.transfer-proxy.own.point *address
|
address.transfer-proxy.own.point *address
|
||||||
==
|
==
|
||||||
[:(welp effects-1 effects-2 effects-3 effects-4) point]
|
`[:(welp effects-1 effects-2 effects-3 effects-4) point]
|
||||||
::
|
::
|
||||||
++ process-spawn
|
++ process-spawn
|
||||||
|= [=ship to=address]
|
|= [=ship to=address]
|
||||||
@ -818,7 +766,7 @@
|
|||||||
?. =(+((ship-rank parent)) (ship-rank ship)) (debug %bad-rank ~)
|
?. =(+((ship-rank parent)) (ship-rank ship)) (debug %bad-rank ~)
|
||||||
:: TODO check spawnlimit
|
:: TODO check spawnlimit
|
||||||
::
|
::
|
||||||
=^ [=effects new-point=point] owners.state
|
=/ [=effects new-point=point]
|
||||||
=/ point=(unit point) (get-point state ship)
|
=/ point=(unit point) (get-point state ship)
|
||||||
?> ?=(^ point) :: only parsed 4 bytes
|
?> ?=(^ point) :: only parsed 4 bytes
|
||||||
:: If spawning to self, just do it
|
:: If spawning to self, just do it
|
||||||
@ -830,30 +778,19 @@
|
|||||||
=(to address.spawn-proxy.own.u.parent-point)
|
=(to address.spawn-proxy.own.u.parent-point)
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
=+ new-point=u.point(address.owner.own to)
|
|
||||||
:: TODO: use get-point or duplicate sponsor logic
|
:: TODO: use get-point or duplicate sponsor logic
|
||||||
::
|
::
|
||||||
:_ (~(put ju owners.state) to [ship new-point])
|
:- ~[[%point ship %dominion %l2] [%point ship %owner to]]
|
||||||
:_ new-point
|
u.point(address.owner.own to)
|
||||||
~[[%point ship %dominion %l2] [%point ship %owner to]]
|
|
||||||
:: Else spawn to parent and set transfer proxy
|
:: Else spawn to parent and set transfer proxy
|
||||||
::
|
::
|
||||||
=* parent-address address.owner.own.u.parent-point
|
:- :~ [%point ship %dominion %l2]
|
||||||
=/ new-point
|
[%point ship %owner address.owner.own.u.parent-point]
|
||||||
%= u.point
|
[%point ship %transfer-proxy to]
|
||||||
address.owner.own parent-address
|
|
||||||
address.transfer-proxy.own to
|
|
||||||
==
|
|
||||||
:: TODO: use put instead so gas is not in /lib/std?
|
|
||||||
::
|
|
||||||
:_ %- ~(gas ju owners.state)
|
|
||||||
:~ [to [ship new-point]]
|
|
||||||
[parent-address [ship new-point]]
|
|
||||||
==
|
==
|
||||||
:_ new-point
|
%= u.point
|
||||||
:~ [%point ship %dominion %l2]
|
address.owner.own address.owner.own.u.parent-point
|
||||||
[%point ship %owner parent-address]
|
address.transfer-proxy.own to
|
||||||
[%point ship %transfer-proxy to]
|
|
||||||
==
|
==
|
||||||
`[effects state(points (put:orm points.state ship new-point))]
|
`[effects state(points (put:orm points.state ship new-point))]
|
||||||
::
|
::
|
||||||
@ -935,42 +872,24 @@
|
|||||||
|= [=point =address]
|
|= [=point =address]
|
||||||
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
?. |(=(%own proxy.from.tx) =(%manage proxy.from.tx))
|
||||||
(debug %bad-permission ~)
|
(debug %bad-permission ~)
|
||||||
=* ship ship.from.tx
|
::
|
||||||
=/ previous address.management-proxy.own.point
|
:+ ~ [%point ship.from.tx %management-proxy address]~
|
||||||
=; [=effects new-point=^point]
|
|
||||||
=. owners.state
|
|
||||||
%. [address ship new-point]
|
|
||||||
~(put ju (~(del ju owners.state) previous [ship point]))
|
|
||||||
`[effects new-point]
|
|
||||||
:- [%point ship.from.tx %management-proxy address]~
|
|
||||||
point(address.management-proxy.own address)
|
point(address.management-proxy.own address)
|
||||||
::
|
::
|
||||||
++ process-set-spawn-proxy
|
++ process-set-spawn-proxy
|
||||||
|= [=point =address]
|
|= [=point =address]
|
||||||
?. |(=(%own proxy.from.tx) =(%spawn proxy.from.tx))
|
?. |(=(%own proxy.from.tx) =(%spawn proxy.from.tx))
|
||||||
(debug %bad-permission ~)
|
(debug %bad-permission ~)
|
||||||
=* ship ship.from.tx
|
::
|
||||||
=/ previous address.spawn-proxy.own.point
|
:+ ~ [%point ship.from.tx %spawn-proxy address]~
|
||||||
=; [=effects new-point=^point]
|
|
||||||
=. owners.state
|
|
||||||
%. [address ship new-point]
|
|
||||||
~(put ju (~(del ju owners.state) previous [ship point]))
|
|
||||||
`[effects new-point]
|
|
||||||
:- [%point ship.from.tx %spawn-proxy address]~
|
|
||||||
point(address.spawn-proxy.own address)
|
point(address.spawn-proxy.own address)
|
||||||
::
|
::
|
||||||
++ process-set-transfer-proxy
|
++ process-set-transfer-proxy
|
||||||
|= [=point =address]
|
|= [=point =address]
|
||||||
?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
|
?. |(=(%own proxy.from.tx) =(%transfer proxy.from.tx))
|
||||||
(debug %bad-permission ~)
|
(debug %bad-permission ~)
|
||||||
=* ship ship.from.tx
|
::
|
||||||
=/ previous address.transfer-proxy.own.point
|
:+ ~ [%point ship.from.tx %transfer-proxy address]~
|
||||||
=; [=effects new-point=^point]
|
|
||||||
=. owners.state
|
|
||||||
%. [address ship new-point]
|
|
||||||
~(put ju (~(del ju owners.state) previous [ship point]))
|
|
||||||
`[effects new-point]
|
|
||||||
:- [%point ship.from.tx %transfer-proxy address]~
|
|
||||||
point(address.transfer-proxy.own address)
|
point(address.transfer-proxy.own address)
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
@ -759,14 +759,5 @@
|
|||||||
^+ a
|
^+ a
|
||||||
=+ d=(get b)
|
=+ d=(get b)
|
||||||
(~(put by a) b (~(put in d) c))
|
(~(put by a) b (~(put in d) c))
|
||||||
:: TODO: remove in favour of only using put?
|
|
||||||
::
|
|
||||||
++ gas
|
|
||||||
|* b=(list [p=* q=*])
|
|
||||||
=> .(b `(list _?>(?=([[* ^] ^] a) [p=p q=n.q]:n.a))`b)
|
|
||||||
|- ^+ a
|
|
||||||
?~ b
|
|
||||||
a
|
|
||||||
$(b t.b, a (put p.i.b q.i.b))
|
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user