-
Notifications
You must be signed in to change notification settings - Fork 391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: r/demo/users
#3166
base: master
Are you sure you want to change the base?
refactor: r/demo/users
#3166
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
# Conflicts: # examples/gno.land/r/demo/users/users.gno # examples/gno.land/r/demo/users/z_10_filetest.gno # examples/gno.land/r/demo/users/z_11_filetest.gno # examples/gno.land/r/demo/users/z_11b_filetest.gno # examples/gno.land/r/demo/users/z_2_filetest.gno # examples/gno.land/r/demo/users/z_3_filetest.gno # examples/gno.land/r/demo/users/z_4_filetest.gno # examples/gno.land/r/demo/users/z_5_filetest.gno # examples/gno.land/r/demo/users/z_6_filetest.gno # examples/gno.land/r/demo/users/z_7_filetest.gno # examples/gno.land/r/demo/users/z_7b_filetest.gno # examples/gno.land/r/demo/users/z_8_filetest.gno # examples/gno.land/r/demo/users/z_9_filetest.gno # examples/gno.land/r/sys/users/verify.gno
Considerations:
|
ErrInvalidUsername = errors.New("r/gnoland/users: invalid username") | ||
ErrPaused = errors.New("r/gnoland/users: paused") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep it like this for now 👍 , but the need to prefix with "package realm" shows that we are not using gno errors as much as we should, yet.
|
||
// DeleteUser makes all names associated with the `PrevRealm()` address unresolvable. | ||
// WARN: After deletion, the same address WILL NOT be able to register a new name. | ||
func DeleteUser() error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for now; make it a GovDAO feature until we determine the appropriate requirements.
authorDisplayText := prop.Author().String() | ||
if user != nil { | ||
authorDisplayText = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) | ||
authorDisplayText = ufmt.Sprintf("[%s](/r/sys/users:%s)", user.Name(), user.Name()) | ||
} | ||
|
||
out += ufmt.Sprintf("**Author: %s**\n\n", authorDisplayText) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole thing should be done like this:
user := users.GetUserByAddress(prop.Author())
out += ufmt.Sprintf("**Author: %s**\n\n", user.RenderLink())
authorDisplayText := prop.Author().String() | ||
if user != nil { | ||
authorDisplayText = ufmt.Sprintf("[%s](/r/demo/users:%s)", user.Name, user.Name) | ||
authorDisplayText = ufmt.Sprintf("[%s](/r/sys/users:%s)", user.Name(), user.Name()) | ||
} | ||
|
||
out += ufmt.Sprintf("**Author: %s**\n\n", authorDisplayText) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this whole thing should be done like this, because a very common workflow:
user := users.GetUserByAddress(prop.Author())
out += ufmt.Sprintf("**Author: %s**\n\n", user.String())
} | ||
|
||
if authorUsername != "" { | ||
out += ufmt.Sprintf("**Author: [%s](/r/demo/users:%s)**\n\n", authorUsername, authorUsername) | ||
out += ufmt.Sprintf("**Author: [%s](/r/gnoland/users/v1:%s)**\n\n", authorUsername, authorUsername) | ||
} else { | ||
out += ufmt.Sprintf("**Author: %s**\n\n", p.Author().String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type verifierFunc func(address std.Address, name string) bool | ||
|
||
var ( | ||
Ownable = ownable.NewWithAddress("g1manfred47kzduec920z88wfr64ylksmdcedlf5") // @moul > dropped in genesis via Enable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
govdao or #3700
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohhhhh, no sorry, it's for the enable fuse, that's ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be better to be a random address, not mine. ideally one without a private key if this is a genesis msg without signature.
enabled = false // set to true in genesis | ||
) | ||
|
||
const VerifyFuncUpdatedEvent = "VerifyFuncUpdated" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this
} | ||
|
||
// NewVerifyCallExecutor allows updating the verifier function via a GovDAO proposal | ||
func NewVerifyCallExecutor(newVerifyCall func(enabled bool, address std.Address, name string) bool) dao.Executor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should remove this and deploy a r/sys/names/v2 if we want to change the logic. It's very easy to modify using the params keeper, which simply points to an arbitrary realm address.
} | ||
|
||
func makeUserDataSafe(data interface{}) interface{} { | ||
u := data.(*UserData) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
u := data.(*UserData) | |
u := *(data.(*UserData)) |
|
||
const gusersv1 = "gno.land/r/gnoland/users/v1" // preregistered with store write perms | ||
|
||
var callerWhitelist = addrset.Set{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var callerWhitelist = addrset.Set{} | |
var controllers = addrset.Set{} // caller whitelist |
// IsOnWhitelist checks if the given address has | ||
// permission to write to the user store | ||
func IsOnWhitelist(addr std.Address) bool { | ||
return callerWhitelist.Has(addr) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this.
} | ||
|
||
// NewAddWhitelistedAddrExecutor allows GovDAO to add a whitelisted caller | ||
func NewAddWhitelistedAddrExecutor(addr std.Address) dao.Executor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
func NewAddWhitelistedAddrExecutor(addr std.Address) dao.Executor { | |
func ProposeNewController(addr std.Address) dao.Executor { |
|
||
// Validate validates username and address passed in | ||
func validateName(username string) error { | ||
if strings.TrimSpace(username) == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space trimming shouldn't be for validation but for sanitization. Make validateName a helper function that also sanitizes, and use it for every function that could set a new name in the store.
Description
Addresses: #2827
This PR refactors the current
r/demo/users
&r/sys/users
system in accordance to the issue mentioned above. Below is the high-level overview of the new system.It also makes a small change to the
p/demo/releases
lib.r/gnoland/users/v1
r/demo/users
r/sys/users
Mainnet v1 (mvp) & v2 #2827r/demo/profile
for displaying extra information about a user (to be moved tor/nt/profiles
orr/gnoland/profiles
)r/sys/users
r/sys/names
r/gnoland/users/v1
, etc.r/gov/dao/bridge
#3523 was resolved)r/sys/names
r/sys/users
), added tests, as discussed with @moulVerify functionality is now not pausable and on by default, as per discussions with @moul. This means Portal Loop will need to be patched upon merging this PR, as many txs will fail due to not having proper namespace permissions.The namespace verify functionality is off by default, but should be enabled in genesis viar/sys/names.Enable()
. The Portal Loop will indeed need to be patched if we enable this functionality.Keeper
& genesis paramsr/sys/names
for the namespace check instead ofr/sys/users
r/sys/names
, which the keeper will callr/gnoland/users/v1
r/gnoland/users
Currently this is the "releases" page for the user registration systems (example data):
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description