event.gno

2.33 Kb · 80 lines
 1package event
 2
 3import (
 4	zenaov1 "gno.land/p/zenao/zenao/v1"
 5	"gno.land/p/zenao/events"
 6	"gno.land/p/zenao/basedao"
 7	"gno.land/p/zenao/daokit"
 8	"gno.land/p/zenao/daocond"
 9	"gno.land/r/demo/profile"
10	"gno.land/r/zenao/eventreg"
11	"gno.land/r/zenao/social_feed"
12)
13
14var (
15	DAO      daokit.DAO
16	localDAO daokit.DAO
17
18	event  *events.Event // XXX: needed for backward compatibility with frontend queries
19	feedId string        // XXX: workaround for "unexpected zero object id" issue
20)
21
22func init() {
23	// XXX: workaround for "unexpected zero object id" issue
24	feedId = social_feed.NewFeed(cross, "main", false, feedAuth)
25}
26
27func init() {
28	conf := events.Config{
29		Organizers: []string{"gno.land/r/zenao/users/u14"},
30		Gatekeepers: []string{},
31		Title: "Release",
32		Description: "I'M JUST A LOST GUY – REVEAL PROJECTION FEBRUARY 25, 2025\n\nIs this the life you once imagined?\nDid you choose this path, or did it choose you?\nSometimes, getting lost is the only way to figure things out.\n\nOn February 25, 2025, take a step back and see where the journey leads.\n\n#ImJustALostGuy #ShortFilm #FindingTheWay",
33		ImageURI: "ipfs://bafybeidpd3ydnbxidme65pcyeqnlnjswbh3rgzszifwqik5vnp3j67sl24",
34		StartDate: 1740506400,
35		EndDate: 1740520800,
36		Capacity: 150,
37		Discoverable: true,
38		GetProfileString: profile.GetStringField,
39		SetProfileString: profile.SetStringField,
40		ZenaoAdminAddr: "g1djrkw9tf4px658j85cc6fhsvm50uf9s0g6kfsm",
41		Location: &zenaov1.EventLocation{
42			Address: &zenaov1.AddressCustom{
43				Address: "1 Bd Poissonnière, 75002 Paris",
44				Timezone: "Europe/Paris",
45			},
46		},
47		ParticipationPubkey: "",
48		CrossFn: crossFn,
49		SetImplemFn: setImplem,
50		FeedId: feedId,
51		PrivateVarName: "event",
52	}
53	event = events.NewEvent(&conf)
54	eventreg.Register(cross, func() *zenaov1.EventInfo { return event.Info() })
55}
56
57func Vote(_ realm, proposalID uint64, vote daocond.Vote) {
58	localDAO.Vote(proposalID, vote)
59}
60
61func Execute(_ realm, proposalID uint64) {
62	localDAO.Execute(proposalID)
63}
64
65func Render(path string) string {
66	return localDAO.Render(path)
67}
68
69func feedAuth() (string, bool) {
70	caller := event.DAOPrivate.CallerID() // XXX: this should be upgradable
71	return caller, basedao.MustGetMembersViewExtension(localDAO).IsMember(caller)
72}
73
74func crossFn(_ realm, cb func()) {
75	cb()
76}
77
78func setImplem(newLocalDAO daokit.DAO, newDAO daokit.DAO) {
79	localDAO, DAO = newLocalDAO, newDAO
80}