Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

matijamarjanovic
Copy link
Contributor

@matijamarjanovic matijamarjanovic commented Mar 18, 2025

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

@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Mar 18, 2025
@Gno2D2 Gno2D2 requested a review from a team March 18, 2025 02:16
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Mar 18, 2025

🛠 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 include BREAKING 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

@matijamarjanovic matijamarjanovic changed the title feat(examples): awesome gno on chain feat(examples): awesome gno realm Mar 18, 2025
@matijamarjanovic matijamarjanovic changed the title feat(examples): awesome gno realm feat(examples): awesome gno Mar 18, 2025
@matijamarjanovic matijamarjanovic marked this pull request as ready for review March 18, 2025 20:48
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Mar 18, 2025
Copy link

codecov bot commented Mar 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@jefft0
Copy link
Contributor

jefft0 commented Mar 20, 2025

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

@matijamarjanovic
Copy link
Contributor Author

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..

@michelleellen michelleellen requested a review from wyhaines March 21, 2025 11:00
@leohhhn leohhhn requested a review from jeronimoalbi March 24, 2025 11:49
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 use p/moul/addrset for this

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

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

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 use any instead of interface{}

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧾 package/realm Tag used for new Realms or Packages. review/triage-pending PRs opened by external contributors that are waiting for the 1st review
Projects
Status: No status
Status: In Review
Status: Triage
Development

Successfully merging this pull request may close these issues.

4 participants