Skip to content

Commit

Permalink
Merge pull request #145 from tocwex/sl/v1.3.X/interface-polish-r1
Browse files Browse the repository at this point in the history
v1.4.0: transaction actions, ui improvements, bug fixes
  • Loading branch information
sidnym-ladrut authored Sep 20, 2024
2 parents 65e651a + 0aac72b commit a99af6b
Show file tree
Hide file tree
Showing 89 changed files with 1,567 additions and 415 deletions.
125 changes: 95 additions & 30 deletions desk/bare/app/fund.hoon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/- f=fund, p=pals
/- fd=fund-data, fd-1=fund-data-1, fd-0=fund-data-0
/+ fh=fund-http, fc=fund-chain, fj=fund-proj, fp=fund-prof
/+ fh=fund-http, fc=fund-chain, fj=fund-proj, fp=fund-prof, fx=fund-xtra
/+ config, default-agent, rudder, *sss
/+ dbug, verb, tonic, vita-client
/~ pagz page:fd /web/fund/page
Expand Down Expand Up @@ -340,7 +340,7 @@
?~ p.syn cor
((slog u.p.syn) cor)
:: scan response ::
[%scan typ=@ ~]
[%scan typ=@ sob=@ tob=@ ~]
?> =(our.bol sip)
?> ?=(xfer:f typ.pat.pat)
?+ -.syn cor
Expand All @@ -364,11 +364,18 @@
=/ loz=loglist:fc ?+(-.dif loglist.dif %disavow ~)
=* por (pj-abed:pj-core sip nam)
=/ pro=proj:proj:f pro:por
:: NOTE: Worker is assumed to initiate all withdrawal transactions
=/ wad=addr:f work:(need contract.pro)
:: NOTE: Unused for now, but may be useful for notifications later
=/ [sob=(unit bloq:f) tob=(unit bloq:f)]
=+ par=|=(v=@ `(unit bloq:f)`?:(=(%$ v) ~ `(slav %ud v)))
[(par sob.pat.pat) (par tob.pat.pat)]
:: NOTE: We group by transaction for multisend cases (which
:: always occur for withdrawals)
:: NOTE: We assume that all incoming transactions are single send
=/ xap=(map xact:f (list [addr:f @]))
%+ roll loz
|= [nex=event-log:rpc:ethereum:fc acc=(map xact:f (list [addr:f cash:f]))]
|= [nex=event-log:rpc:ethereum:fc acc=(map xact:f (list [addr:f @]))]
=/ act=xact:f [block-number transaction-hash]:(need mined.nex)
=/ who=addr:f (snag ?-(typ.pat.pat %depo 1, %with 2) `(list @ux)`topics.nex)
:: NOTE: If there are 4 topics, then this is an NFT transfer, for
Expand All @@ -387,12 +394,16 @@
%- ~(rep by xap)
|= [[act=xact:f fez=(list [addr:f @])] acc=(list card)]
:_ acc
=/ fom=addr:f ?-(typ.pat.pat %depo -:(head fez), %with wad)
=/ nfz=(list [@ tape]) (turn fez |=([a=addr:f i=@] [i (uri.payment.pro i)]))
:* %pass `path`(welp pat /(scot %ud p.act)/(scot %ux q.act))
:* %pass `path`(welp pat /(scot %ud p.act)/(scot %ux q.act)/(scot %ux fom))
%arvo %k %fard q.byk.bol
%nfz-okay noun+!>([~ nfz limits.payment.pro ~])
==
%- turn :_ |=([x=xact:f c=cash:f a=(set addr:f)] (pj-mk-pruf:por x c typ.pat.pat))
%- turn :_
|= [act=xact:f cas=cash:f adz=(set addr:f)]
=/ fom=addr:f ?-(typ.pat.pat %depo (head ~(tap in adz)), %with wad)
(pj-mk-pruf:por act fom cas typ.pat.pat)
^- (list [xact:f cash:f (set addr:f)])
%- ~(rep by xap)
|= [[act=xact:f fez=(list [addr:f cash:f])] acc=(list [xact:f cash:f (set addr:f)])]
Expand All @@ -417,24 +428,28 @@
renew-surl:action
==
::
[%fund %proj sip=@ nam=@ %scan typ=@ boq=@ adr=@ ~]
[%fund %proj sip=@ nam=@ %scan typ=@ sob=@ tob=@ boq=@ hax=@ fom=@ ~]
?+ syn cor
[%khan %arow *]
?: ?=(%.n -.p.syn) ((slog leaf+<p.p.syn> ~) cor)
=/ lag=flag:f [(slav %p sip.pat) (slav %tas nam.pat)]
=/ typ=xfer:f ;;(xfer:f typ.pat)
=/ act=xact:f [(slav %ud boq.pat) (slav %ux adr.pat)]
=/ act=xact:f [(slav %ud boq.pat) (slav %ux hax.pat)]
=/ fom=addr:f (slav %ux fom.pat)
=+ !<(gud=(set @) q.p.p.syn)
(emit (pj-mk-pruf:(pj-abed:pj-core lag) act ~(wyt in gud) typ))
(emit (pj-mk-pruf:(pj-abed:pj-core lag) act fom ~(wyt in gud) typ))
==
==
::
++ open
^+ cor
=/ old=? !(~(has by pf-myn) our.bol)
=/ kiq=?
?| !(~(has by pf-myn) our.bol) :: pre-v1.1 need any watch paths
=>(scan-vold:watch:audit ?=(^ .)) :: pre-%6 %proj need new-style watch paths
==
=. cor renew-surl:action
=. cor watch-pals:action
=. cor (renew-projs:action old)
=. cor (renew-projs:action kiq)
cor
++ action
|%
Expand Down Expand Up @@ -471,7 +486,7 @@
?=(^ (find /gall/use/fund pat))
==
++ renew-projs :: invoke project level triggers
|= kiq=?
|= kiq=bean
^+ cor
=/ lis=(list flag:f) ~(tap in ~(key by pj-our))
|-
Expand All @@ -481,7 +496,7 @@
::
cor
?. &(kiq =(p.i.lis our.bol)) pj-abet:(pj-abed:pj-core i.lis)
pj-abet:(pj-push:(pj-abed:pj-core i.lis) [%redo ~])
pj-abet:(pj-push:(pj-abed:pj-core i.lis) [%redo ~ ~])
==
++ toggle-profs :: toggle profile follow status
|= [ahn=? siz=(set @p)]
Expand All @@ -493,6 +508,47 @@
$(cor pf-abet:(pf-push:(pf-abed:pf-core i.lis) pod), lis t.lis)
--
::
++ audit
|%
++ watch
|%
++ boat :: filtered outgoing watch paths
|= fil=$-([wire @p @tas] ?) ~+
^- (set path)
%- ~(rep in ~(key by wex.bol))
|= [[wyr=(pole knot) sip=@p dap=@tas] acc=(set path)]
?.((fil wyr sip dap) acc (~(put in acc) wyr))
++ scan-vold :: %fund-watcher old-style watch paths
~+
^- (set path)
%- boat
|= [wyr=(pole knot) sip=@p dap=@tas]
?& =(sip our.bol)
=(dap %fund-watcher)
?=([%fund %proj sip=@ nam=@ %scan typ=@ ~] wyr)
?=(^ (slaw %p sip.wyr))
?=(xfer:f typ.wyr)
==
++ scan-vnow :: %fund-watcher new-style watch paths
~+
^- (set path)
%- boat
|= [wyr=(pole knot) sip=@p dap=@tas]
^- bean
?& =(sip our.bol)
=(dap %fund-watcher)
?=([%fund %proj sip=@ nam=@ %scan typ=@ sob=@ tob=@ ~] wyr)
?=(^ (slaw %p sip.wyr))
?=(xfer:f typ.wyr)
?=(%$ tob.wyr) :: NOTE: empty end indicates ongoing watch path
==
++ scan-vany :: %fund-watcher any-style watch paths
~+
^- (set path)
(~(uni in scan-vold) scan-vnow)
--
--
::
++ pj-core
|_ [lag=flag:f pro=proj:proj:f gon=_|]
++ pj-core .
Expand Down Expand Up @@ -534,9 +590,13 @@
++ pj-pj-bloq
^- @
=/ pre=path (en-beam [our.bol %fund-watcher da+now.bol] /)
=/ pat=path (welp pj-pa-pub /scan/depo)
=- ?~(pat 0 .^(@ %gx :(welp pre /block u.pat /atom)))
^- pat=(unit path)
=+ .^(pap=(map path *) %gx (welp pre /dogs/configs/noun))
?.((~(has by pap) pat) 0 .^(@ %gx :(welp pre /block pat /atom)))
%+ find:fx ~(tap in ~(key by pap))
=/ pre=path (welp pj-pa-pub /scan/depo)
=/ pen=@ud (lent pre)
|=(n=path &(=(pre (scag pen n)) =(%$ (rear n))))
++ pj-pj-push
|= pod=prod:proj:f
^+ pj-core
Expand All @@ -557,26 +617,31 @@
%poke fund-poke+!>([%proj lag pod])
==
++ pj-mk-pruf
|= [act=xact:f amo=cash:f dir=xfer:f]
|= [act=xact:f fom=addr:f amo=cash:f dir=xfer:f]
^- card
=* con (need contract:pro)
:: FIXME: Assumes that all withdrawals are prompted by the worker
=/ adr=addr:f ?-(dir %depo safe:con, %with work:con)
(pj-mk-card p.lag [%mula %pruf ship=~ cash=amo when=[act adr] note=dir])
(pj-mk-card p.lag [%mula %pruf ship=~ cash=amo when=[act fom] note=dir])
++ pj-mk-scan
|= oat=(unit oath:f)
|= [oat=(unit oath:f) sob=(unit bloq:f) tob=(unit bloq:f)]
^- (list card)
=+ oaf=(fall (clap oat contract.pro head) *oath:f)
%- zing
%+ turn (scan-cfgz:fc oaf payment.pro)
%- zing %+ turn (scan-cfgz:fc oaf sob tob payment.pro)
|= [suf=path cfg=config:fc]
^- (list card)
=/ pat=path (welp pj-pa-pub suf)
=+ car=[%pass pat %agent [our.bol %fund-watcher] act=~]
;: welp
?.((~(has by wex.bol) pat our.bol %fund-watcher) ~ [car(act [%leave ~])]~)
[car(act [%poke %fund-watcher-poke !>([%watch pat cfg])])]~
==
=/ pen=@ud (sub (lent pat) 2) :: path w/o start/end delimiters
=+ car=[%pass pat=~ %agent [our.bol %fund-watcher] act=~]
%- snoc :_ `card`car(pat pat, act [%poke %fund-watcher-poke !>([%watch pat cfg])])
^- (list card)
?^ tob ~
%- zing %+ turn
(skim ~(tap in scan-vany:watch:audit) |=(p=path =((scag pen pat) (scag pen p))))
|= old=path
:- car(pat old, act [%leave ~]) :: clear out:
?. ?| (~(has in scan-vold:watch:audit) old) :: - all old watch paths
&(!=(old pat) =(~ tob) =(%$ (rear old))) :: - all new indefinite paths
==
~
[car(pat old, act [%poke %fund-watcher-poke !>([%clear old])])]~
::
++ pj-do-read
|= pod=prod:proj:f
Expand Down Expand Up @@ -638,7 +703,7 @@
(pj-pj-push pod(p.dif pj-pj-bloq))
::
%redo
=? cor !?=(?(%born %prop) ~(stat pj:fj pro)) (emil (pj-mk-scan ~))
=? cor !?=(?(%born %prop) ~(stat pj:fj pro)) (emil (pj-mk-scan ~ +.pod))
(pj-pj-push pod)
::
%mula
Expand Down Expand Up @@ -673,7 +738,7 @@
::
%lock
=- pj-core(cor (emil -))
(pj-mk-scan oat.pod)
(pj-mk-scan oat.pod ~ ~)
==
==
:: meta prods ::
Expand All @@ -692,7 +757,7 @@
?< ~|(bad-pj-push+mes (~(has by pj-our) pag))
?: pj-is-myn pj-core
=. cor (proj-push ~ (copy:pj-puz proj-subs pj-pa-sub wat))
=. cor (emit [%pass wat %agent [our dap]:bol %poke fund-poke+!>([%proj pag %redo ~])])
=. cor (emit [%pass wat %agent [our dap]:bol %poke fund-poke+!>([%proj pag %redo ~ ~])])
pj-core
::
?(%join %exit)
Expand Down
7 changes: 6 additions & 1 deletion desk/bare/cfg/base.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
::
%- malt
^- (list [@tas vase])
=/ alc=tape (flop ~['2' '2' 'B' 'W' '4' '-' 'c' 'W' 'F' 'F' 'B' 'J' 'n' 'b' 'b' '3' '1' 'r' 'L' 'n' 'V' 'W' 'F' 'i' 'j' 'C' 'l' 'G' 'u' '1' 'E' '3'])
:~ [%debug !>(%|)]
[%point !>(~tocwex)]
[%sign-addr !>(0x78e6.603f.0393.3e0f.ebc6.88a7.734e.a8b4.b63f.42d0)]
[%safe-addr !>(0x944a.5ba3.3bd9.5a5e.45e5.41c3.dd5a.0732.e90d.58e6)]
[%uprl-herz !>(~h1)]
[%scan-herz !>(~s30)]
[%scan-herz !>(~m2)]
[%scan-tout !>(~m1)]
[%scan-bloq !>(10)]
[%alch-akey !>(`@t`(crip alc))]
[%rpce-ethe !>(`@t`(crip "https://eth-mainnet.g.alchemy.com/v2/{alc}"))]
[%rpce-sepo !>(`@t`(crip "https://eth-sepolia.g.alchemy.com/v2/{alc}"))]
[%feat-oraz !>(`(list @p)`~[~reb ~bitdeg ~roswet ~nisfeb ~hosdys ~ridlyd ~darlur ~mocbel ~posdeg ~dalten ~firbex ~moddux ~pandux ~fogbus])]
[%meta-site !>('https://tocwexsyndicate.com')]
[%meta-help !>('https://docs.tocwexsyndicate.com')]
[%meta-tlon !>('https://tlon.network/lure/~tocwex/syndicate-public')]
Expand Down
7 changes: 6 additions & 1 deletion desk/bare/cfg/xtra/fake.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
::
%- malt
^- (list [@tas vase])
=/ alc=tape (flop ~['E' 'f' 'd' 't' 'J' 'X' 'S' 'C' 'H' 'I' 'C' 'F' 'D' 'B' 'w' '4' '3' 'R' 'H' 'f' 'y' 'f' 'b' 'y' '1' 'S' 'A' 'E' 'E' 'E' 'R' '2'])
:~ [%debug !>(%&)]
[%point !>(~zod)]
[%sign-addr !>(0xcbbd.2aab.5ee5.09e8.531a.b407.d48f.c93c.dc25.e1ad)]
[%safe-addr !>(0xcbbd.2aab.5ee5.09e8.531a.b407.d48f.c93c.dc25.e1ad)]
[%uprl-herz !>(~m1)]
[%scan-herz !>(~s10)]
[%scan-tout !>(~s30)]
[%scan-tout !>(~s10)]
[%scan-bloq !>(5)]
[%alch-akey !>(`@t`(crip alc))]
[%rpce-ethe !>(`@t`(crip "https://eth-mainnet.g.alchemy.com/v2/{alc}"))]
[%rpce-sepo !>(`@t`(crip "https://eth-sepolia.g.alchemy.com/v2/{alc}"))]
[%feat-oraz !>(`(list @p)`(gulf 0 255))]
==
2 changes: 1 addition & 1 deletion desk/bare/desk.docket-0
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
info+'A sovereign P2P work completion funder/tracker with on-chain settlement.'
color+0x11.1111
image+'https://sfo3.digitaloceanspaces.com/sarlev-sarsen/sarlev-sarsen/2024.4.29..23.58.31..2b02.0c49.ba5e.353f-IMG_4726.jpeg'
version+[1 3 0]
version+[1 4 0]
website+'https://www.tocwexsyndicate.com/'
license+'GNU GPLv3'
base+'fund'
Expand Down
19 changes: 13 additions & 6 deletions desk/bare/lib/config.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,19 @@
=- "export const FUND_{var} = {dat};"
^- [var=tape dat=tape]
:- (cuss (turn (trip key) |=(t=@tD ?.(=('-' t) t '_'))))
?+ -.val !!
[%atom %f *] ?:(!<(bean val) "true" "false")
[%atom %ux *] "'{['0' 'x' ((x-co:co 40) !<(@ux val))]}'"
[%atom %ud *] "'{(a-co:co !<(@ val))}'"
[%atom %p *] "'{(scow %p !<(@ val))}'"
[%atom %dr *] "'{(a-co:co !<(@ val))}'" :: FIXME: Doesn't really work
?+ -.val "undefined"
[%atom %f *] ?:(!<(bean val) "true" "false")
[%atom %ux *] "'{['0' 'x' ((x-co:co 40) !<(@ux val))]}'"
[%atom %ud *] "'{(a-co:co !<(@ val))}'"
[%atom %p *] "'{(scow %p !<(@ val))}'"
[%atom %dr *] "'{(a-co:co !<(@ val))}'" :: FIXME: Doesn't really work
[%atom dim=@ ~] "'{(scow %tas !<(@ val))}'"
:: ::
:: [%hold *]
:: =/ typ=type ~(repo ut -.val)
:: ?+ typ "undefined"
:: :: [%hint *]
:: [%fork [%atom [%| %~ %0]] [%cell *]] ""
:: ==
==
--
64 changes: 64 additions & 0 deletions desk/bare/lib/fund/alien.hoon
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
:: /lib/fund/alien/hoon: foreign/external interface helper functions for %fund
::
/- cn=contacts, se=settings
/+ ff=fund-form
|_ bol=bowl:gall
::
:: +contacts-rolo: %contacts app "rolodex" data (ship/info map)
::
++ contacts-rolo
~+
^- rolodex:cn
=/ pre=path (en-beam [our.bol %contacts da+now.bol] /)
?. .^(? %gu (snoc pre %$)) *rolodex:cn
=+ .^(non=noun %gx (weld pre /all/noun))
(fall ((soft rolodex:cn) non) *rolodex:cn)
::
:: +contacts-ship: %contacts app ship data (index into "rolodex")
::
++ contacts-ship
|= sip=@p ~+
^- (unit contact:cn)
=/ rol=rolodex:cn contacts-rolo
?~ con=(~(get by rol) sip) ~
?@ for.u.con ~
?@ con.for.u.con ~
`con.for.u.con
::
:: +settings-calm: %settings app "calm engine" data (key/value map)
::
++ settings-calm
~+
^- bucket:se
=/ pre=path (en-beam [our.bol %settings da+now.bol] /)
?. .^(? %gu (snoc pre %$)) *bucket:se
?. .^(? %gx (weld pre /has-bucket/landscape/'calmEngine'/noun)) *bucket:se
=+ .^(non=noun %gx (weld pre /bucket/landscape/'calmEngine'/noun))
=/ dat=data:se (fall ((soft data:se) non) [%bucket *bucket:se])
?.(?=(%bucket -.dat) *bucket:se bucket.dat)
::
:: +ship-tytl: ship title, derived from %settings and %contacts
::
++ ship-tytl
|= sip=@p ~+
^- tape
=/ dis=val:se (~(gut by settings-calm) 'disableNicknames' [%b |])
=/ def=tape "{<sip>}"
?: &(?=(%b -.dis) p.dis) def
?~ con=(contacts-ship sip) def
?: =(%$ nickname.u.con) def
(trip nickname.u.con)
::
:: +ship-logo: ship logo (as url), derived from %settings and %contacts
::
++ ship-logo
|= sip=@p ~+
^- tape
=/ dis=val:se (~(gut by settings-calm) 'disableAvatars' [%b |])
=/ def=tape (surt:enrl:ff sip)
?: &(?=(%b -.dis) p.dis) def
?~ con=(contacts-ship sip) def
?~ avatar.u.con def
?: =(%$ u.avatar.u.con) def
(trip u.avatar.u.con)
--
Loading

0 comments on commit a99af6b

Please sign in to comment.