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): add interactive realm r/stefann/home #2918

Merged
merged 25 commits into from
Oct 22, 2024

Conversation

stefann-01
Copy link
Contributor

@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.12%. Comparing base (1154172) to head (7ff21f6).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2918      +/-   ##
==========================================
+ Coverage   63.11%   63.12%   +0.01%     
==========================================
  Files         563      563              
  Lines       79274    79274              
==========================================
+ Hits        50030    50043      +13     
+ Misses      25872    25863       -9     
+ Partials     3372     3368       -4     
Flag Coverage Δ
contribs/gnodev 60.57% <ø> (+0.62%) ⬆️
contribs/gnofaucet 15.77% <ø> (+0.94%) ⬆️
gno.land 67.38% <ø> (ø)
gnovm 67.26% <ø> (ø)
misc/genstd 79.72% <ø> (ø)
tm2 62.38% <ø> (+0.01%) ⬆️

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
Contributor 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
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
Contributor 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 😎

examples/gno.land/r/stefann/home/home_test.gno Outdated Show resolved Hide resolved
@stefann-01
Copy link
Contributor Author

I hope it’s ready now, thank you for your patience!

I tried to resolve the issue in the CI pipeline during the Go test step, but I’m not sure what’s causing it. Hopefully, it won’t appear after the new commits

Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

Not a fan of the code, but I think we should be pretty liberal on what we have in the home realms, and I think it's a good example.

You make heavy use of HTML which we have dropped support for: #2964. You can make a new PR to amend your usages; and perhaps drop the r/stefann/registry realm which I see is not actually being used much (especially wrt. the "backup address").

@thehowl thehowl changed the title feat(home-realm): add interactive home realm example feat(examples): add interactive realm r/stefann/home\ Oct 22, 2024
@thehowl thehowl changed the title feat(examples): add interactive realm r/stefann/home\ feat(examples): add interactive realm r/stefann/home Oct 22, 2024
@thehowl thehowl merged commit ec222ec into gnolang:master Oct 22, 2024
2 checks passed
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: Done
Development

Successfully merging this pull request may close these issues.

4 participants