users.gno
1.16 Kb ยท 50 lines
1package users
2
3import (
4 "std"
5 "strings"
6
7 "gno.land/p/demo/releases"
8 "gno.land/r/gov/dao"
9)
10
11var (
12 cd = std.ChainDomain()
13 changelog = releases.NewChangelog("r/gnoland/users")
14)
15
16const usersPrefix = "gno.land/r/gnoland/users/"
17
18func init() {
19 changelog.NewRelease("v1", "/r/gnoland/users/v1", "[Original PR](https://github.com/gnolang/gno/pull/3166)")
20}
21
22func Render(_ string) string {
23 return changelog.RenderAsTable(10)
24}
25
26func LatestRelease() string {
27 return cd + changelog.Latest().URL()
28}
29
30// ProposeNewRelease allows a GovDAO proposal to add a release to the changelog
31func ProposeNewRelease(newVerPkgPath, note string) dao.ProposalRequest {
32 ver := strings.TrimPrefix(newVerPkgPath, usersPrefix)
33 if ver == newVerPkgPath || // TrimPrefix returns unchanged newVerPkgPath if !HasPrefix
34 strings.Contains(ver, "/") { // if has prefix, has to be first child under
35 panic("r/gnoland/users: invalid version pkgpath")
36 }
37
38 cb := func() error {
39 changelog.NewRelease(ver, strings.TrimPrefix(newVerPkgPath, "gno.land"), note)
40 return nil
41 }
42
43 e := dao.NewSimpleExecutor(cb, "")
44
45 return dao.NewProposalRequest(
46 "Propose a new release for gnoland/users realm",
47 "",
48 e,
49 )
50}