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: DAO SDK #1925

Draft
wants to merge 111 commits into
base: master
Choose a base branch
from
Draft

feat: DAO SDK #1925

wants to merge 111 commits into from

Conversation

n0izn0iz
Copy link
Contributor

@n0izn0iz n0izn0iz commented Apr 12, 2024

This implement a DAO SDK inspired by DA0-DA0

The code in this PR has been extracted from #1154 and cleaned (reviews on the previous PR should have been addressed)

It includes:

  • Interfaces for the DAO gno.land/p/demo/dao_maker/dao_interfaces
  • A reference implementation for the core of the DAO gno.land/p/demo/dao_maker/dao_core
  • A membership-based voting module gno.land/p/demo/dao_maker/dao_voting_group
  • A single-choice proposal module gno.land/p/demo/dao_maker/dao_proposal_single
  • An example DAO gno.land/r/demo/dao_maker/dao_realm
  • A registry to dynamically interact with any registered DAO using it's address gno.land/r/demo/dao_maker/dao_registry

For usage see the tutorial, it is integrated into docusaurus

Screenshot 2024-04-12 at 18 41 10

There is an example membership-based DAO at gno.land/r/demo/teritori/dao_realm that can administer itself and a grc20 token at gno.land/r/demo/teritori/tori

Here is it's GnoWeb Render:
Screenshot 2024-04-12 at 18 28 41


This powers the "Organizations" feature of Teritori dApp on Gno as shown below

The DAO creation UI uses a Gno template and instantiates a new realm.

Screenshot 2024-04-12 at 18 43 23 Screenshot 2024-04-12 at 18 44 50 Screenshot 2024-04-12 at 18 44 15 Screenshot 2024-04-12 at 18 42 26
Contributors' checklist...
  • 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, if any. More info here.

Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@berty.tech>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
@n0izn0iz
Copy link
Contributor Author

n0izn0iz commented May 4, 2024

Thanks for the review @leohhhn, I addressed your comments

I have two remarks to spark discussion around guidelines:

  • Adding periods everywhere is considered a bad ux practice by google

  • Tutorials should be playful instead of formal

    The use of humor in the college classroom has been researched extensively (see Segrist & Hupp, 2015 who summarized 41 years of literature on humor in the college classroom) and has been shown to have many benefits for students (Banas, Dunbar, Rodriguez & Liu, 2011; Garner, 2006; Huss & Estep, 2016; Pollio, 2002), some of which are:
    An increase in learning.
    An increase in self-motivation.
    An increase in class attendance.
    An increase in test performance.
    An increase in divergent thinking.
    An increase of interest in learning.
    A reduction of anxiety and stress in dealing with difficult material.
    The creation of a positive social and emotional learning environment.
    The creation of a common psychological bond between students and faculty.

Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
…alm name

Signed-off-by: Norman Meier <norman@samourai.coop>
@elix1er
Copy link

elix1er commented May 7, 2024

impressive work, keep grinding

Copy link
Contributor

@leohhhn leohhhn left a comment

Choose a reason for hiding this comment

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

Left some minor suggestions to the docs page. Otherwise we should be good to go.

Sorry for the delay, and great work.

docs/how-to-guides/creating-dao.md Outdated Show resolved Hide resolved
docs/how-to-guides/creating-dao.md Outdated Show resolved Hide resolved
docs/how-to-guides/creating-dao.md Outdated Show resolved Hide resolved
docs/how-to-guides/creating-dao.md Show resolved Hide resolved
docs/how-to-guides/creating-dao.md Outdated Show resolved Hide resolved
n0izn0iz and others added 2 commits June 17, 2024 19:03
Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
@@ -12,3 +16,14 @@ func (aon AddressOrName) GetName() (string, bool) {
}
return "", false
}

func (aon AddressOrName) IsValid() bool {
Copy link
Member

Choose a reason for hiding this comment

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

what about using users.Resolve(aon).IsValid()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can't call the realm method users.Resolve from a p package

@@ -0,0 +1,133 @@
package havl
Copy link
Member

@moul moul Jul 7, 2024

Choose a reason for hiding this comment

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

can you add more info about what is this package about?

it looks like something that should be located in p/demo/havl.

and add some tests.

-> could eventually have it's own PR.

@@ -0,0 +1,7 @@
module gno.land/p/demo/dao_maker/jsonutil
Copy link
Member

Choose a reason for hiding this comment

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

The current p/demo/json library should be suitable for your needs.

I'm against having any JSON library written in userland because I expect that we can use @gfanton's #1776 and avoid any boilerplate code that isn't either for humans (rendering) or for other contracts (imports). Generally, anything about marshalling doesn't fall into these categories.

In the meantime, you can reuse the existing JSON library if needed. However, as soon as possible, I expect we can delete it completely. Additionally, if possible, I expect we don't merge any new JSON library in the meantime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this extends p/demo/json

func (v *VotingGroup) Render(path string) string {
sb := strings.Builder{}
sb.WriteString("Member count: ")
sb.WriteString(strconv.FormatUint(uint64(v.MemberCount(havl.Latest)), 10))
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
sb.WriteString(strconv.FormatUint(uint64(v.MemberCount(havl.Latest)), 10))
sb.WriteString(ufmt.Sprintf("%d", havl.Latest))

Comment on lines +138 to +141
g.powerByAddr.Iterate(start, end, height, func(k string, v interface{}) bool {
if limit > 0 && uint64(len(members)) >= limit {
return true
}
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 use avl.Tree.IterateByOffset.

}

func (g *VotingGroup) MemberCount(height int64) uint32 {
val, ok := g.memberCount.Get("", height)
Copy link
Member

Choose a reason for hiding this comment

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

isn't avl.Tree.Size enough for you?

Copy link
Member

Choose a reason for hiding this comment

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

can you move this to gno.land/r/teritori/tori?

Comment on lines +7 to +13
type ExecutableMessage interface {
ToJSON() *json.Node
FromJSON(ast *json.Node)

String() string
Type() string
}
Copy link
Member

Choose a reason for hiding this comment

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

why is this needed?

Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

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

There are several interesting aspects in that PR, but there is too much work to review at the moment. Therefore, I will mark it as "request changes" to allow more time for a thorough review.

A high-level suggestion I can provide is to:

  • Simplify the codebase by reducing the number of packages, files, functions, types, and boilerplate, and avoiding the use of JSON, etc. Consider merging some packages together.
  • Improve the naming conventions. For instance, use more specific names like "Teritori Realms" and "Daomaker" (a better name could facilitate faster merging, as "Daomaker" is currently too generic and sounds overly official, while "Teritori" would make it easier to integrate).

@moul moul marked this pull request as draft July 8, 2024 01:12
n0izn0iz added a commit to TERITORI/teritori-dapp that referenced this pull request Sep 8, 2024
from gnolang/gno#1925

Signed-off-by: Norman Meier <norman@samourai.coop>
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: No status
Status: In Progress
Status: No status
Status: In Progress
Development

Successfully merging this pull request may close these issues.

None yet

6 participants