-
Notifications
You must be signed in to change notification settings - Fork 385
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
# Conflicts: # examples/gno.land/r/demo/users/users.gno
|
||
// ResolveAddressOrName | ||
// Note: unlike ResolveName, input must be "@" prefixed for names | ||
func ResolveAddressOrName(aon string) *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.
I say we completely remove this function, its annoying to handle and can lead to bugs. Let's leave it up to the users if they want to provide a named lookup or only an address lookup
) | ||
|
||
const ( | ||
adminAddr = "g1u7y667z64x2h7vc6fmpcprgey4ck233jaww9zq" // @moul |
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.
Since the goal is to have a DAO managing it, I prefer using the existing GovDAO system or implementing panic("not implemented")
instead of relying on an outdated centralized admin.
WhitelistAddEvent = "WhitelistAdd" | ||
WhitelistDeleteEvent = "WhitelistDelete" |
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.
If you want to implement a whitelisting system, please write a p/
library for this. However, I prefer not to include advanced logic and event handling inline in the core implementation of an r/sys/
contract. Let's keep the implementation concise.
) | ||
|
||
var ( | ||
Ownable = ownable.NewWithAddress(adminAddr) // Until a DAO is formed to manage this contract |
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 UserData struct { | ||
addr std.Address | ||
username string | ||
alias *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.
alias *UserData | |
aliasTo *UserData |
std.TestSetOrigCaller(whitelistedCallerAddr) | ||
|
||
t.Run("valid_registration", func(t *testing.T) { | ||
t.Parallel() |
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.
we should not have to set this, please remove.
} | ||
|
||
// GetReadonlyStore exposes the username store in readonly mode | ||
func GetReadonlyStore() *rotree.ReadOnlyTree { |
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 GetReadonlyStore() *rotree.ReadOnlyTree { | |
func GetReadonlyNameStore() avl.ITree { |
} | ||
|
||
// RegisterAlias adds an Alias pointing to an existing user. | ||
func RegisterAlias(alias string, address std.Address) 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.
The action is not to register an alias, but to replace a name and transform the existing one into an alias for the newly created name.
It takes the newName, previousName string
signature.
Description
Addresses: #2827
WIP
This PR refactors the current
r/demo/users
&r/sys/users
system in accordance to the issue mentioned above. Here is the high-level overview:r/demo/users
package in favor ofr/gnoland/users
r/gnoland/users
becomes the main entry-point for users registering their usernamesr/sys/users
:r/gnoland/users
) can be agnostic and upgradeable, by providing a whitelist mechanism which allows write access to the store to certain addressesr/sys/users
&r/gnoland/users
areownable
&pausable
, currently by a single address, which could become a DAO at one pointContributors' checklist...
BREAKING CHANGE: xxx
message was included in the description