Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

feat(examples): awesome gno#3963

Open
matijamarjanovic wants to merge25 commits intognolang:master
base:master
Choose a base branch
Loading
frommatijamarjanovic:feat/awesome-gno

Conversation

matijamarjanovic
Copy link
Contributor

@matijamarjanovicmatijamarjanovic commentedMar 18, 2025
edited
Loading

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:

  • there is a group of admins who are in charge of accepting/rejecting proposals
  • one becomes admin by getting added by another admin
  • anyone can make a proposal that some dapp is presented on awesome-gno
  • one dapp can belong to multiple categories
  • categories allow different types of realms/dapps to be present on awesome gno realm
UI (mock data):

image
image
image
image
image
image

alexiscolin and leohhhn reacted with eyes emoji
@github-actionsgithub-actionsbot added the 🧾 package/realmTag used for new Realms or Packages. labelMar 18, 2025
@Gno2D2Gno2D2 requested a review froma teamMarch 18, 2025 02:16
@Gno2D2
Copy link
Collaborator

Gno2D2 commentedMar 18, 2025
edited
Loading

🛠 PR Checks Summary

🔴 Pending initial approval by a review team member, or review from tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
  • The pull request description provides enough details
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)
🔴 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or includeBREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met└── 🟢 And    ├── 🟢 The base branch matches this pattern: ^master$    └── 🟢 The pull request was created from a fork (head branch repo: matijamarjanovic/gno)

Then

🟢 Requirement satisfied└── 🟢 Maintainer can modify this pull request
Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met└── 🟢 And    ├── 🟢 The base branch matches this pattern: ^master$    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not satisfied└── 🔴 If    ├── 🔴 Condition    │   └── 🔴 Or    │       ├── 🔴 At least 1 user(s) of the organization reviewed the pull request (with state "APPROVED")    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request    │       └── 🔴 This pull request is a draft    └── 🔴 Else        └── 🔴 And            ├── 🟢 This label is applied to pull request: review/triage-pending            └── 🔴 On no pull request
Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission
The pull request description provides enough details

If

🟢 Condition met└── 🟢 And    ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors)    └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])

Can be checked by

  • team core-contributors

@matijamarjanovicmatijamarjanovic changed the titlefeat(examples): awesome gno on chainfeat(examples): awesome gno realmMar 18, 2025
@matijamarjanovicmatijamarjanovic changed the titlefeat(examples): awesome gno realmfeat(examples): awesome gnoMar 18, 2025
@matijamarjanovicmatijamarjanovic marked this pull request as ready for reviewMarch 18, 2025 20:48
@Gno2D2Gno2D2 added the review/triage-pendingPRs opened by external contributors that are waiting for the 1st review labelMar 18, 2025
@codecovCodecov
Copy link

codecovbot commentedMar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report?Let us know!

@jefft0
Copy link
Contributor

Problem here with "not enough arguments in call to page.Picker", same as#3793 (comment) :-)

@matijamarjanovic
Copy link
ContributorAuthor

Problem here with "not enough arguments in call to page.Picker", same as#3793 (comment) :-)

Addressed in567df81. I've also added hof registration (if you remember#3479 it caused lint to break in init) which suprisingly causes no trouble here..

Comment on lines 27 to 30
admins.Set("g1ej0qca5ptsw9kfr64ey8jvfy9eacga6mpj2z0y", true)
admins.Set(std.CurrentRealm().Address().String(), true)
admins.Set(std.PreviousRealm().Address().String(), true)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

you can usep/moul/addrset for this

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hey I figured since authz is already managing admin set so I've just implemented that instead in048d3ef

Comment on lines 34 to 47
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
}
Copy link
Contributor

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

applied in048d3ef

Comment on lines 49 to 65
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
}
Copy link
Contributor

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

applied in048d3ef

Comment on lines 77 to 84
categories.Iterate("", "", func(key string, value interface{}) bool {
cat := value.(Category)
if cat.Name == name {
exists = true
return true
}
return false
})
Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Also you can useany instead ofinterface{}

matijamarjanovic reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yeah, makes sense, forgot aboutavl.Has().. implemented in4f6f4fa

DappIDs: []uint64{},
}

categories.Set(strconv.FormatUint(nextCategoryID, 10), category)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

FormatUint >strconv.Itoa

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Does this mean I should generally useFormatUint ?

Comment on lines 18 to 19
nextDappID uint64 = 1
nextProposalID uint64 = 1
Copy link
Contributor

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok implemented in9887784

Comment on lines 153 to 162
func ListCategories() []Category {
result := []Category{}

categories.Iterate("", "", func(key string, value interface{}) bool {
result = append(result, value.(Category))
return false
})

return result
}
Copy link
Contributor

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

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, that's what I was going for (but also for render), applied in6fe1d53

return result
}

func ProposeNewDapp(title, description, url string, categoryNamesStr string) (uint64, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For proposals, let's try using some DAO code that already exists.@jeronimoalbi maybe we can integrate with gno.me as we talked, but maybe we should just do commondao+datasource. wdyt?

Copy link
Member

@jeronimoalbijeronimoalbiMar 26, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Using gno.me seems to be the right approach with the caveat that before mainnet will require some small changes to your custom proposal definition methods, there are a couple of changes to be done for security that are still pending. But this way would be interesting so you can have a SubDAO within the gno.me DAO tree.

Using commondao is also valid, as a package or directly though the commondao realm. The package would require a bit more effort. If commondao is used we can also integrate with gnome space if it makes sense and list content there if you support thedatasource interface fromgno.land/p/jeronimoalbi/datasource.

matijamarjanovic reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Hey, so in381c72d I've added datasource support for Proposals, Dapps and Categories (with tests) as we talked today@leohhhn, I'd love some feedback on that as it is pretty long. Looking forward, I should wait until commonDao package/realm is merged and use that here if I understood our conversation today correctly?

Comment on lines 177 to 202
var categoryNames []string
if categoryNamesStr != "" {
for _, name := range strings.Split(categoryNamesStr, ",") {
trimmedName := strings.TrimSpace(name)
if trimmedName != "" {
categoryNames = append(categoryNames, trimmedName)
}
}
}

if len(categoryNames) > 0 {
for _, catName := range categoryNames {
categoryExists := false
categories.Iterate("", "", func(key string, value interface{}) bool {
cat := value.(Category)
if cat.Name == catName {
categoryExists = true
return true
}
return false
})
if !categoryExists {
return 0, ufmt.Errorf("category '%s' does not exist", catName)
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Too much nesting, can be simplified

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

done in29f82c1

caller := std.PreviousRealm().Address()

if !isAdmin(caller) {
return ufmt.Errorf("not authorized: only admins can update dApp categories")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this error repeats, it should be declared somewhere. speciifcally for this, either use the p/ errors for control access (ownable/authz), or declare it at top level of this package.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

4cd9637

this commit defines errors in types.gno and uses those

Comment on lines 379 to 416
for _, catName := range strings.Split(newCategories, ",") {
_, found := GetCategory(catName)
if !found {
return ufmt.Errorf("category not found: %s", catName)
}
}

for _, oldCat := range dapp.Categories {
found := false
for _, newCat := range strings.Split(newCategories, ",") {
if oldCat == newCat {
found = true
break
}
}
if !found {
err := RemoveDappFromCategory(dappID, oldCat)
if err != nil {
return err
}
}
}

for _, newCat := range strings.Split(newCategories, ",") {
found := false
for _, oldCat := range dapp.Categories {
if newCat == oldCat {
found = true
break
}
}
if !found {
err := addDappToCategory(dappID, newCat)
if err != nil {
return err
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Definitely too much nesting.

If you need to use double for loops, you're probably doing something wrong - these could be avoided with the proper use of maps/avl trees

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

yes i see what you mean, hopefully this makes more sense :27dc704

caller := std.PreviousRealm().Address()

if !isAdmin(caller) {
return ufmt.Errorf("not authorized: only admins can delete dApps")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

same comment as above for errors

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

4cd9637 this and all other non specific errors

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@leohhhnleohhhnleohhhn left review comments

@wyhaineswyhainesAwaiting requested review from wyhaines

@jeronimoalbijeronimoalbiAwaiting requested review from jeronimoalbi

At least 1 approving review is required to merge this pull request.

Labels
🧾 package/realmTag used for new Realms or Packages.review/triage-pendingPRs opened by external contributors that are waiting for the 1st review
Projects
Status: No status
Status: In Review
Status: Triage
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@matijamarjanovic@Gno2D2@jefft0@jeronimoalbi@leohhhn

[8]ページ先頭

©2009-2025 Movatter.jp