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(home-realm): add interactive home realm example #2918

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

Conversation

stefann-01
Copy link

@stefann-01 stefann-01 commented Oct 7, 2024

Description:

This PR finalizes the core functionality of my home realm project, focusing on a dynamic and interactive home realm experience, driven by GNOT donations. The following key features and enhancements are introduced in this PR:

Key Features:

  • Dynamic Background Change:

    • Implemented sequential background changes triggered by GNOT donations. Each donation updates the city background in a fixed order, cycling through a predefined set of cities. The background change is seamless, offering a "traveling" experience for donors.
  • Sponsor Leaderboard:

    • Added a sponsor leaderboard to showcase the top contributors based on their GNOT donations. The list displays the addresses of the top sponsors, formatted for readability (first and last characters with ellipses), and limits the displayed sponsors to the configurable maxSponsors setting.
  • Donation Validation:

    • Introduced a strict GNOT validation check. The system now rejects any donation attempts that don't include GNOT, ensuring only valid contributions update the state of the realm.
  • Owner Withdrawal of Donations:

    • Implemented a feature that allows the realm owner to withdraw accumulated GNOT donations, providing control over the funds contributed by supporters.
  • Home Realm Configurations:

    • Cities: Cities can be dynamically updated to refresh the possible backgrounds.
    • Maximum Sponsors: Admins can configure the number of sponsors shown on the leaderboard with the maxSponsors setting.
    • Jar Link: Admins can update the link to the donation jar.

@stefann-01 stefann-01 requested review from a team as code owners October 7, 2024 05:28
@stefann-01 stefann-01 requested review from jaekwon and petar-dambovaliev and removed request for a team October 7, 2024 05:28
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Oct 7, 2024
@stefann-01 stefann-01 changed the title feat(home-realm): introduce interactive donation-based home realm with background change and sponsor leaderboard feat(home-realm): interactive home realm with background change and sponsor leaderboard Oct 7, 2024
@stefann-01 stefann-01 changed the title feat(home-realm): interactive home realm with background change and sponsor leaderboard feat(home-realm): add interactive home realm example Oct 7, 2024
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.08%. Comparing base (b655cd2) to head (22f9526).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2918      +/-   ##
==========================================
+ Coverage   63.07%   63.08%   +0.01%     
==========================================
  Files         563      563              
  Lines       79254    79254              
==========================================
+ Hits        49986    49996      +10     
+ Misses      25904    25895       -9     
+ Partials     3364     3363       -1     
Flag Coverage Δ
contribs/gnodev 60.62% <ø> (+0.62%) ⬆️
contribs/gnofaucet 14.82% <ø> (ø)
gno.land 67.56% <ø> (ø)
gnovm 67.25% <ø> (ø)
misc/genstd 79.72% <ø> (ø)
misc/logos 19.95% <ø> (+0.50%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- Add profile picture, background image, and about section rendering
- Implement dynamic background and tip jar rendering
- Add functions to update cities and tip jar link
- Integrate sponsor leaderboard
- Home realm is still a work in progress
- Ensure city index increments with each donation, resetting after the last city
- Implement full GNOT validation to enforce valid donations
- Complete sponsor leaderboard functionality with maxSponsors limit
- Refine sponsor list display logic to prevent visual issues
- Fully integrate tip jar mechanics with donation tracking
- Fix AssertAuth issue in config
@zivkovicmilos zivkovicmilos marked this pull request as draft October 8, 2024 14:51
examples/gno.land/r/stefann/config/config.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
examples/gno.land/r/stefann/home/home.gno Outdated Show resolved Hide resolved
- Remove ownership management logic from `config` and rename it to `registar`.
- Integrate `Ownable` for ownership management in the home package.
- Add a comment to clarify the purpose of `jarLink` and its expected update process.
- Remove the unused `caption` parameter in the `UpdatePFP` function.
- Replace `OrigPkgAddr()` with `CurrentRealm()` in `CollectDonations`.
- Run `gno mod tidy` to clean up dependencies.
- Run `gno fmt -C ./examples` to format code.
- Clean up by fixing the undefined `owner` reference and other minor bugs.
@stefann-01
Copy link
Author

stefann-01 commented Oct 11, 2024

I’ve resolved some issues with the latest commits and will be addressing the remaining problems soon. Thank you for your comprehensive suggestions!

- Refactor the `currentCityIndex` update using modulo (`%`) to prevent manual resetting and ensure correct rendering.
- Merge sponsor and donation logic into a single structure, simplifying data handling.
- Replace sponsor list iteration with a map for direct access, enhancing performance.
- Remove `CollectDonations` function; `Donate` now directly sends funds to the owner, simplifying fund management.
- Move sponsor sorting from the donation step to the render step, reducing gas fees for donors.
- Generalize the `UpdateAboutMe` method to support dynamic content updates without column restrictions.
- Group related variables (e.g., `pfp`, `cities`, `aboutMe`, `jarLink`) into common objects for improved organization.
- Apply minor optimizations and clean up code for better readability and maintainability.
- Re-add UpdateMaxSponsors function, accidentally removed earlier.
- Replace DonationStats with DonationsCount field.
- Update logic to derive total donations directly from the sponsors map by summing "ugnot" coins.
@zivkovicmilos zivkovicmilos marked this pull request as ready for review October 15, 2024 10:06
Comment on lines 239 to 241
if len(sponsorship.sponsors) == 0 {
out += `<p style="text-align: center;">No sponsors yet. Be the first to tip the jar!</p>` + "\n"
} else {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if len(sponsorship.sponsors) == 0 {
out += `<p style="text-align: center;">No sponsors yet. Be the first to tip the jar!</p>` + "\n"
} else {
if len(sponsorship.sponsors) == 0 {
return out + `<p style="text-align: center;">No sponsors yet. Be the first to tip the jar!</p>` + "\n"
}
// ...

Copy link
Author

Choose a reason for hiding this comment

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

Fixed! 22531c7

Copy link
Member

Choose a reason for hiding this comment

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

You can drop the else, since you return in the if

Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Thank you for applying the suggestions 🙏

@zivkovicmilos
Copy link
Member

@stefann-01
You gotta run gno mod tidy in the registry package folder to make the CI pass 🙏

@zivkovicmilos
Copy link
Member

@stefann-01 Can you check the leftover comments, so we can merge? 🙏

@stefann-01
Copy link
Author

stefann-01 commented Oct 16, 2024

Yes, I will fix them all tonight. Thanks! @zivkovicmilos

- Add AddCities function to append one or more cities to the travel list without replacing the existing entries.
- Add AddAboutMeRows function to append one or more rows to the aboutMe section.
- Implemented unit tests for home realm.
Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

Looking good 😎

)

func TestUpdatePFP(t *testing.T) {
std.TestSetOrigCaller(std.Address("g1sd5ezmxt4rwpy52u6wl3l3y085n8x0p6nllxm8"))
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: you should use testutils.TestAddress(...) to create an std.Address in tests

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.
Projects
Status: In Progress
Status: In Review
Development

Successfully merging this pull request may close these issues.

3 participants