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

WIP feat: initial r/profile dapp #181

Closed
wants to merge 5 commits into from

Conversation

moul
Copy link
Member

@moul moul commented May 9, 2022

This PR intends to let users define custom metadata that can be reused across
the whole ecosystem.

This realm is intended to be used by people that owns a r/user entry or
not (works well with just an std.Address).

This is a preliminary realm for bigger projects that would to rely on Gno,
including a twitter clone, or maybe an ENS that could store IP addresses, etc.

The goal is to pack the contract with default fields that are the expected most common ones for customization (profile_picture, name, primary_color, is_dev (to enable more debug), etc. But the contract should support a way to set new fields, basically a key/value store associated with a profile.

Exected usage API from another contract:

import "gno.land/r/demo/profile"

func MyHandler() {
    caller := std.GetOrigCaller()
    settings := profile.ByAddr(caller)
    username, _ := settings.Get(profile.FieldUsername)
    customField, _ := settings.Get("my-custom-key")
}

Depends on #145
Depends on #149

Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
@thehowl
Copy link
Member

thehowl commented Jun 16, 2023

Are you still interested in working on this? Shall we keep it open? @moul

@moul
Copy link
Member Author

moul commented Jun 17, 2023

Yes, I will continue.

@moul
Copy link
Member Author

moul commented Aug 3, 2023

@n0izn0iz needs something like this for Teritori.

@gfanton you were asking for contract ideas for your onboarding, I think this one makes sense.

@moul moul assigned moul and gfanton and unassigned moul Aug 3, 2023
@github-actions github-actions bot added the 🧾 package/realm Tag used for new Realms or Packages. label Aug 3, 2023

// TODO: makes sense to implement an allowance system?

var profiles *avl.MutTree // std.Address.String() -> *Profile
Copy link
Member Author

Choose a reason for hiding this comment

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

using the old avl API

@moul
Copy link
Member Author

moul commented Mar 1, 2024

Quick update:
I suggest making this realm function like Go context, allowing any package/realm to define a new type with a key and generate new entries. Additionally, I aim to have the storage cost controlled by the calling package/realm. I am still considering the best approach for this.

-> https://medium.com/@matryer/context-keys-in-go-5312346a868d

@moul
Copy link
Member Author

moul commented Apr 17, 2024

ping @gnolang/24-zone01-1

@kazai777 kazai777 mentioned this pull request Apr 25, 2024
7 tasks
@moul moul closed this in #1983 Jul 14, 2024
@moul moul closed this in 5c57f21 Jul 14, 2024
gfanton pushed a commit to gfanton/gno that referenced this pull request Jul 23, 2024
Following this
[PR](gnolang#181 (comment))
concerning the creation of a realm `profile` I created this realm which
allows the creation of profile as well as the associated functions to
display the information of a profile with an address or a username. I
have some questions concerning this realm:

- Currently, if a user modifies his username, his old username is not
freed and is therefore no longer available, even if it is no longer in
use. Should I free the old username when the user has changed username?
- To make it possible to search by username and address, I've created a
second avl tree containing both username and address, so that I can find
the profile indexed by its address by searching for it by its username.
This is the most efficient solution I've found. I'd like to get some
feedback on this and know if I should do things differently so that
searching by username is more optimized.
- Do you have any other suggestions for completing the profile fields,
or other interesting features to add?

Thanks in advance for your feedback

<details><summary>Contributors' checklist...</summary>

- [ ] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>

Closes gnolang#181

---------

Co-authored-by: kazai <kazai@777>
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
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
Status: 🌟 Wanted for Launch
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants