-
Notifications
You must be signed in to change notification settings - Fork 396
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
feat(examples): awesome gno #3963
base: master
Are you sure you want to change the base?
feat(examples): awesome gno #3963
Conversation
🛠 PR Checks Summary🔴 Pending initial approval by a review team member, or review from tech-staff Manual Checks (for Reviewers):
Read More🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers. ✅ Automated Checks (for Contributors):🟢 Maintainers must be able to edit this pull request (more info) ☑️ Contributor Actions:
☑️ Reviewer Actions:
📚 Resources:Debug
|
Codecov ReportAll modified and coverable lines are covered by tests ✅ 📢 Thoughts on this report? Let us know! |
Problem here with "not enough arguments in call to page.Picker", same as #3793 (comment) :-) |
Addressed in 567df81. I've also added hof registration (if you remember #3479 it caused lint to break in init) which suprisingly causes no trouble here.. |
admins.Set("g1ej0qca5ptsw9kfr64ey8jvfy9eacga6mpj2z0y", true) | ||
admins.Set(std.CurrentRealm().Address().String(), true) | ||
admins.Set(std.PreviousRealm().Address().String(), true) | ||
|
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.
you can use p/moul/addrset
for this
func AddAdmin(addr std.Address) error { | ||
caller := std.PreviousRealm().Address() | ||
|
||
if !isAdmin(caller) { | ||
return ufmt.Errorf("not authorized: only admins can add new admins") | ||
} | ||
if !addr.IsValid() { | ||
return ufmt.Errorf("invalid address") | ||
} | ||
|
||
admins.Set(addr.String(), true) | ||
std.Emit("AdminAdded", "address", addr.String()) | ||
return nil | ||
} |
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.
Should be handled with authorizable or with p/moul/authz
func RemoveAdmin(addr std.Address) error { | ||
caller := std.PreviousRealm().Address() | ||
|
||
if !isAdmin(caller) { | ||
return ufmt.Errorf("not authorized: only admins can remove admins") | ||
} | ||
if !addr.IsValid() { | ||
return ufmt.Errorf("invalid address") | ||
} | ||
if admins.Size() <= 1 { | ||
return ufmt.Errorf("cannot remove the last admin") | ||
} | ||
|
||
admins.Remove(addr.String()) | ||
std.Emit("AdminRemoved", "address", addr.String()) | ||
return nil | ||
} |
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 as above, use a package for privileged actions. I suggest you dig into p/moul/authz; we are slowly moving away from ownable and authorizable
categories.Iterate("", "", func(key string, value interface{}) bool { | ||
cat := value.(Category) | ||
if cat.Name == name { | ||
exists = true | ||
return true | ||
} | ||
return false | ||
}) |
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.
Definitely not like this; you should use the fact that AVL tree has a lookup of O(1) - just use the category name as the key. Make sure that you sanitize the key properly (ie no spaces,etc)
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.
Also you can use any
instead of interface{}
DappIDs: []uint64{}, | ||
} | ||
|
||
categories.Set(strconv.FormatUint(nextCategoryID, 10), category) |
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.
FormatUint
> strconv.Itoa
nextDappID uint64 = 1 | ||
nextProposalID uint64 = 1 |
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.
seqid is more practical when working with AVL trees
func ListCategories() []Category { | ||
result := []Category{} | ||
|
||
categories.Iterate("", "", func(key string, value interface{}) bool { | ||
result = append(result, value.(Category)) | ||
return false | ||
}) | ||
|
||
return result | ||
} |
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.
If you need this to be a getter for someone outside of this realm, check out avl/rotree, which exposes a tree without setter functions
implementation of #3928
This is an on chain representation of the Awesome Gno repo which serves a purpose of showcasing dApp built in the community. The way this implementation works is:
UI (mock data):