Gno.land
| 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 | |
| 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 | } |
| Function | Parameters |
|---|---|
| NewSetPausedExecutor | (newPausedValue bool) |
| ProposeNewName | (addr string, newName string) |
| ProposeDeleteUser | (addr string, reason string) |
| ProposeNewRegisterPrice | (newPrice int64) |
| IsReserved | (stem string) |
| ValidateNymFormat | (username string) |
| IsPaused | () |
| Canonicalize | (s string) |
| Render | (path string) |
| RenderLatestUsersWidget | (num int) |
| Register | (username string) |
Gno.land User Registry
Welcome to the Gno.land User Registry (v0). Please register a username.
Registering a username grants the registering address the right to deploy packages and realms under that username’s namespace. For example, if an address registers the username nym-alice123, it will gain permission to deploy packages and realms to package paths with the pattern gno.land/{p,r}/nym-alice123/*.
In V0, usernames must match nym-<stem><digits>, where:
<stem> is 5 to 13 lowercase ASCII letters<digits> is exactly 3 decimal digitsgno, gl, atom, atone, photon, or cosmos (reserved prefixes)vitaiik vs vitalik via l↔i) are blocked via canonical-form collision detectiong1... addresses, which are always 40 chars)Vanity names outside this format may be allocated by GovDAO governance through ProposeNewName.
[[Click here to register]](/r/sys/namereg/v0$help&func=Register)
Registration price: 0.000000 GNOT (0ugnot)
Latest registrations
| Function | Caller | Age |
|---|---|---|
| Register | g1p4r3es…vf9znu | 21h ago |
| Register | g1qgslse…u75kye | 3d ago |
| Register | g13kytw9…4p89zg | 7d ago |
| Register | g1lyejww…9yeh3z | 8d ago |
| Register | g1747t5m…gkx59c | 15d ago |
| Register | g15nf66l…zps8yn | 16d ago |
| Register | g19v5rs8…sktg9z | 17d ago |
| Register | g1tdjqmt…8yety7 | 17d ago |
| Register | g1wlureh…7lqveu | 17d ago |
| Register | g1dkuxl3…mwumnv | 17d ago |
| Register | g1tlljkn…ek2ttr | 18d ago |
| Register | g1xc2t36…uwhk3w | 19d ago |