Kind Realm (renderable)
Name v0
Namespace sys / namereg
Exported functions 11
Module gno.land/r/sys/namereg/v0
gno 0.9 admin.gno gno
⧉
1 package namereg 2 3 import ( 4 "gno.land/p/nt/ufmt/v0" 5 "gno.land/r/gov/dao" 6 susers "gno.land/r/sys/users" 7 ) 8 Canonicalize (s string) string
IsPaused () bool
IsReserved (stem string) bool
NewSetPausedExecutor (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, newPausedValue bool) struct{title string; description string; executor gno.land/r/gov/dao.Executor; filter gno.land/r/gov/dao.Filter}
ProposeDeleteUser (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, addr string, reason string) struct{title string; description string; executor gno.land/r/gov/dao.Executor; filter gno.land/r/gov/dao.Filter}
ProposeNewName (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, addr string, newName string) struct{title string; description string; executor gno.land/r/gov/dao.Executor; filter gno.land/r/gov/dao.Filter}
ProposeNewRegisterPrice (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, newPrice int64) struct{title string; description string; executor gno.land/r/gov/dao.Executor; filter gno.land/r/gov/dao.Filter}
Register (cur interface {.seal func(); Address func() .uverse.address; IsCode func() bool; IsCurrent func() bool; IsEphemeral func() bool; IsUser func() bool; IsUserCall func() bool; IsUserRun func() bool; PkgPath func() string; Previous func() .uverse.realm; String func() string; Sub func(string) .uverse.realm; Subpath func() string}, username string)
Render (path string) string
RenderLatestUsersWidget (num int) string
ValidateNymFormat (username string) interface {Error func() string}
Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.
9 var paused = false // XXX: replace with p/moul/authz
10
11 //----------------------------------------
12 // Privileged mutators.
13
14 func setPaused(cur realm, newPausedValue bool ) {
15 paused = newPausedValue
16 }
17
18 func updateUsername(cur realm, userData *susers.UserData, newName string ) error {
19 // UpdateName must be called from this realm.
20 return userData.UpdateName( 0 , cur, newName)
21 }
22
23 func deleteUserdata(cur realm, userData *susers.UserData) error {
24 // Delete must be called from this realm.
25 return userData.Delete( 0 , cur)
26 }
27
28 func setRegisterPrice(cur realm, newPrice int64 ) {
29 registerPrice = newPrice
30 }
31
32 //----------------------------------------
33 // Public API
34
35 // NewSetPausedExecutor allows GovDAO to pause or unpause this realm
36 func NewSetPausedExecutor(cur realm, newPausedValue bool ) dao.ProposalRequest {
37 cb := func (cur realm) error {
38 setPaused(cur, newPausedValue)
39 return nil
40 }
41
42 e := dao.NewSimpleExecutor( 0 , cur, cb, "" )
43
44 if newPausedValue {
45 return dao.NewProposalRequest( "User Registry V0: Pause" , "" , e)
46 }
47
48 return dao.NewProposalRequest( "User Registry V0: Unpause" , "" , e)
49 }
50
51 // ProposeNewName allows GovDAO to propose a new name for an existing user.
52 // The associated address and all previous names of a user that changes a
53 // name are preserved, and all resolve to the new name.
54 //
55 // Governance renames bypass the Open Nym Tier `nym-...\d{3}` format intentionally.
56 // The DAO is the trust root for this realm; if voters approve a rename to
57 // `vitalik` (e.g. for trademark dispute resolution or system reservations),
58 // the validation here imposes no further opinion. The new name is still
59 // subject to the base shape enforced by `r/sys/users.validateName`
60 // (`^[a-z][a-z0-9]*([_-][a-z0-9]+)*$`, max 64 chars), which runs inside
61 // the updateUsername callback below.
62 func ProposeNewName(cur realm, addr address, newName string ) dao.ProposalRequest {
63 userData := susers.ResolveAddress(addr)
64 if userData == nil {
65 panic(susers.ErrUserNotExistOrDeleted)
66 }
67
68 cb := func (cur realm) error {
69 err := updateUsername(cur, userData, newName)
70 return err
71 }
72
73 e := dao.NewSimpleExecutor( 0 , cur, cb, "" )
74
75 return dao.NewProposalRequest(
76 ufmt.Sprintf( "User Registry V0: Rename user `%s` to `%s`" , userData.Name(), newName),
77 "" ,
78 e,
79 )
80 }
81
82 // ProposeDeleteUser allows GovDAO to propose deletion of a user
83 // This will make the associated address and names unresolvable.
84 // WARN: After deletion, the same address WILL NOT be able to register a new name.
85 func ProposeDeleteUser(cur realm, addr address, reason string ) dao.ProposalRequest {
86 userData := susers.ResolveAddress(addr)
87 if userData == nil {
88 panic(susers.ErrUserNotExistOrDeleted)
89 }
90
91 cb := func (cur realm) error {
92 return deleteUserdata(cur, userData)
93 }
94
95 e := dao.NewSimpleExecutor( 0 , cur, cb, "" )
96
97 return dao.NewProposalRequest(
98 ufmt.Sprintf( "User Registry V0: Delete user `%s`" , userData.Name()),
99 reason,
100 e,
101 )
102 }
103
104 // ProposeNewRegisterPrice allows GovDAO to update the price of registration.
105 // Rejects prices below MinRegisterPrice (currently 0) at proposal-creation
106 // time. (audit finding #14: original code only rejected negative values,
107 // which would have been arithmetically nonsensical.)
108 func ProposeNewRegisterPrice(cur realm, newPrice int64 ) dao.ProposalRequest {
109 if newPrice < MinRegisterPrice {
110 panic(ufmt.Sprintf( "price below floor: %d ugnot < %d ugnot (MinRegisterPrice)" ,
111 newPrice, MinRegisterPrice))
112 }
113
114 cb := func (cur realm) error {
115 setRegisterPrice(cur, newPrice)
116 return nil
117 }
118
119 e := dao.NewSimpleExecutor( 0 , cur, cb, "" )
120
121 return dao.NewProposalRequest(
122 ufmt.Sprintf( "User Registry V0: Update registration price to `%d`" , newPrice),
123 "" ,
124 e,
125 )
126 }
127
vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.