From 580007bba825b185c2feec5bee31cba71f39e7e3 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Mon, 23 Aug 2021 16:32:26 +0200 Subject: [PATCH] roller: track ship ownership for address+proxy --- pkg/arvo/app/roller.hoon | 28 ++++++++++++++++++++++------ pkg/arvo/lib/dice.hoon | 36 +++++++++++++++++++++++++++--------- pkg/arvo/sur/dice.hoon | 5 +++-- 3 files changed, 52 insertions(+), 17 deletions(-) diff --git a/pkg/arvo/app/roller.hoon b/pkg/arvo/app/roller.hoon index b1ea60c7f7..2df6510287 100644 --- a/pkg/arvo/app/roller.hoon +++ b/pkg/arvo/app/roller.hoon @@ -268,8 +268,12 @@ !> ^- (list ship) ?~ addr=(slaw %ux wat) ~ - %~ tap in - (~(get ju own) u.addr) + =/ proxies=(list proxy:naive) + ~[%own %spawn %manage %vote %transfer] + %+ roll proxies + |= [=proxy:naive ships=(list ship)] + %+ weld ships + ~(tap in (~(get ju own) [proxy u.addr])) :: ++ config :+ ~ ~ @@ -336,9 +340,16 @@ :- %points !> ^- (list [ship point:naive]) ?~ addr=(slaw %ux wat) ~ - %+ roll - ~(tap in (~(get ju own) u.addr)) - |= [=ship points=(list [ship point:naive])] + :: %+ roll + :: ~(tap in (~(get ju own) u.addr)) + =/ proxies=(list proxy:naive) + ~[%own %spawn %manage %vote %transfer] + %+ roll proxies + |= [=proxy:naive points=(list [ship point:naive])] + %+ weld points + :: + %+ roll ~(tap in (~(get ju own) [proxy u.addr])) + |= [=ship points=_points] %+ snoc points [ship (need (get:orm:naive points.pre ship))] :: @@ -506,7 +517,12 @@ |- ^- (list card) ?~ updates ~ =* up i.updates - =/ address=@t (scot %ux address.up) + =/ address=@t + %+ scot %ux + ?- -.up + %tx address.up + %point address.owner.up + == :_ $(updates t.updates) ^- card :+ %give %fact diff --git a/pkg/arvo/lib/dice.hoon b/pkg/arvo/lib/dice.hoon index 9c66f087e4..e87512f484 100644 --- a/pkg/arvo/lib/dice.hoon +++ b/pkg/arvo/lib/dice.hoon @@ -50,27 +50,45 @@ =/ new=point:naive (need (get points.nas ship)) =* event +>.diff - =; [to=(unit @ux) from=(unit @ux)] - =? owners ?=(^ from) + =; [to=(unit owner) from=(unit owner)] + ~? =(ship ~marzod) + [-.event to+to from+from] + =? owners &(?=(^ from) !=(address.u.from 0x0)) + ~? =(ship ~marzod) ['del' u.from ship new old] (~(del ju owners) u.from ship) + ?: ?| =(~ to) + &(?=(^ to) =(address.u.to 0x0)) + == + [ups owners] ?~ to [ups owners] + ~? =(ship ~marzod) ['add' u.to ship] :- (snoc ups [%point u.to ship new]) (~(put ju owners) u.to ship) ?+ -.event [~ ~] %owner - [`+.event ?~(old ~ `address.owner.own.u.old)] - :: - %spawn-proxy - [`+.event ?~(old ~ `address.spawn-proxy.own.u.old)] + :- `[%own +.event] + ?~ old ~ + `[%own address.owner.own.u.old] :: %management-proxy - [`+.event ?~(old ~ `address.management-proxy.own.u.old)] + :- `[%manage +.event] + ?~ old ~ + `[%manage address.management-proxy.own.u.old] + :: + %spawn-proxy + :- `[%spawn +.event] + ?~ old ~ + `[%spawn address.spawn-proxy.own.u.old] :: %voting-proxy - [`+.event ?~(old ~ `address.voting-proxy.own.u.old)] + :- `[%vote +.event] + ?~ old ~ + `[%vote address.voting-proxy.own.u.old] :: %transfer-proxy - [`+.event ?~(old ~ `address.transfer-proxy.own.u.old)] + :- `[%transfer +.event] + ?~ old ~ + `[%transfer address.transfer-proxy.own.u.old] == :: ++ get-owner diff --git a/pkg/arvo/sur/dice.hoon b/pkg/arvo/sur/dice.hoon index d21eeca388..bf80b4487b 100644 --- a/pkg/arvo/sur/dice.hoon +++ b/pkg/arvo/sur/dice.hoon @@ -3,7 +3,8 @@ /+ naive, ethereum :: |% -+$ owners (jug address:naive ship) ++$ owner [=proxy:naive =address:naive] ++$ owners (jug owner ship) :: +$ roller-config $: next-batch=time @@ -43,7 +44,7 @@ == :: +$ update - $% [%point =address:ethereum =ship =point:naive] + $% [%point =owner =ship =point:naive] [%tx =address:ethereum =roller-tx] == ::