event.gno

2.57 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/u4"},
30		Gatekeepers: []string{},
31		Title: "Samouraï Friends Night",
32		Description: "**Samouraï Friends Night** is a free and open afterwork in Paris aiming to gather a diversity of humans from creative world and open source world around beers.\n\nPeople joining are composing a big patchwork of humans, like open source developers, distributed protocol engineers, film makers, designers, motion designers, smart contract hackers, builders for commons.\nYou can invite your friends, wherever they come from.\n\nThere you'll find friends to discuss open source, tech, art, and future of humanity.\n\nThis even is powered by Samouraï Coop crew : \nhttps://www.samourai.world",
33		ImageURI: "ipfs://bafybeie6evrjz2fmcpaey23t7yvp5azm5ftfx63ycp3ls4ax6657mc4zvy",
34		StartDate: 1742590800,
35		EndDate: 1742612100,
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: "150",
44				Timezone: "America/Santiago",
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}