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

Add a way to fetch a realm object via package path #3164

Open
leohhhn opened this issue Nov 20, 2024 · 6 comments
Open

Add a way to fetch a realm object via package path #3164

leohhhn opened this issue Nov 20, 2024 · 6 comments

Comments

@leohhhn
Copy link
Contributor

leohhhn commented Nov 20, 2024

Description

I want to be able to check if a certain pkgpath actually contains a realm (or a p/, maybe), from within Gno. To give a simple example, I would use it to check whether or not a user has created their home realm.

Proposed API: std.GetRealmAt(pkgpath string) *std.Realm

Usage:

rlm := std.GetRealmAt("gno.land/r/leon/home")
if rlm != nil {
	// exists
}

Could also be a way to say, automatically deposit coins in case a specific realm exists, like rewarding users who've deployed a realm to a specific pkgpath.

WDYT?

@thehowl
Copy link
Member

thehowl commented Nov 20, 2024

the idea sounds good, I don't see any obvious reason why not to.

Maybe there could be a better name

@leohhhn
Copy link
Contributor Author

leohhhn commented Nov 20, 2024

RealmFromPkgPath? Also not sure what to do if a p/ is requested. Would be cool to check for it, but there is no Package object in Gno (and there will not be one), so not sure how to relay this info and have a good function name.

@moul
Copy link
Member

moul commented Nov 20, 2024

Can we first:

  • Continue listing ideas and, if possible, provide evidence that this is a necessary feature, such as examples from other web2/web3 ecosystems.
  • Start listing alternatives if we decide not to add this feature, like the "Register" pattern we're using for grc20reg and hof.

@notJoon
Copy link
Member

notJoon commented Nov 20, 2024

This pattern is frequently used in the Gnoswap contracts as well. it could help reduce code duplication. 👍

@moul
Copy link
Member

moul commented Nov 20, 2024

Do you have links where we can check out some examples?

@notJoon
Copy link
Member

notJoon commented Nov 22, 2024

Do you have links where we can check out some examples?

@moul Sorry for the late answer. Actually, I had confused it with a different pattern. but still, I think it could be useful for other functions if it added.

https://github.com/gnoswap-labs/gnoswap/blob/main/_deploy/r/gnoswap/common/access.gno

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Triage
Development

No branches or pull requests

4 participants