Skip to content

feat(commondao): extension to create callback based proposal definitions#5014

Open
jeronimoalbi wants to merge 12 commits intognolang:masterfrom
jeronimoalbi:dev/commondao-proposal-extension
Open

feat(commondao): extension to create callback based proposal definitions#5014
jeronimoalbi wants to merge 12 commits intognolang:masterfrom
jeronimoalbi:dev/commondao-proposal-extension

Conversation

@jeronimoalbi
Copy link
Member

@jeronimoalbi jeronimoalbi commented Dec 30, 2025

Adds a gno.land/p/nt/commondao/exts/definition package which is an extension of gno.land/p/nt/commondao that provides an alternative approach for creating custom proposal types.

The main CommonDAO package supports different proposal types though the ProposalDefinition interface, so new proposal types require the definition of a custom type that implements this interface. The Definition type introduced in the new definition extension package is a callback based alternative to the type based approach offered by CommonDAO.

Custom proposal definitions can be created using any of the following public package functions:

// New creates a new custom proposal definition or returns an error
func New(title, body string, options ...Option) (Definition, error)

// MustNew creates a new custom proposal definition or panics on error
func MustNew(title, body string, options ...Option) Definition

Default definition behavior can be configured by using custom options that configures the following proposal parameters:

  • Custom vote choices
  • Voting period
  • Tally behavior
  • Pre-execution and render validation
  • Execution behavior

Support defining executable proposal definitions which could be either
crossing or non crossing. This is required to be able to define proposal
types within pure packages, because crossing methods and functions can
only be defined within realms.

When a proposal definition is defined in a realm it can implement the
crossing execution method, otherwise it must implement non crossing
methods.

Defining non crossing executable proposal types is useful when the
proposal type is defined within a pure package where the definition
execution is defined by a crossing callback for example. Technically it
would also be possible that a proposal definition just updates local
properties on execution, instead of realm state globals.
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Dec 30, 2025

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: jeronimoalbi/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

Comment on lines +118 to +137
A proposal can be executable implementing either the **Executable** interface
or the **CrossExecutable** one as part of the new proposal definition:

```go
type Executable interface {
// Execute executes the proposal.
Execute() error
}

type CrossExecutable interface {
// Execute executes the proposal.
Execute(realm) error
}
```

**CrossExecutable** can only be implemented when the proposal definition is
defined within a realm instead of a package, Gno only allows defining crossing
functions and methods within realms. So, executable proposal definitions
defined within packages must implement **Executable** instead, and when
crossing is required it must be done explicitly within the `Execute()` method.
Copy link
Member Author

Choose a reason for hiding this comment

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

Updated commondao to allow proposal definitions to be executable without having to be defined as crossing.
This was required to be able to define a proposal definition within a package.

This opens up two possibilities, one is to define new proposal types within realms, as it was the case until now, and the other to define them within a package. When defined within a package crossing must be done explicitly, for example within the Execute() error method.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be supported; or if it is, a proposal should first go through a realm, and then that realm calls the pure package

@jeronimoalbi jeronimoalbi marked this pull request as ready for review December 30, 2025 19:25
jeronimoalbi and others added 2 commits January 2, 2026 19:11
Co-authored-by: MikaelVallenet <mikael.vallenetpro@gmail.com>
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment on lines +258 to 261
case Executable:
err = e.Execute()
case CrossExecutable:
err = e.Execute(cross)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should add this. Proposals should be assumed to be potentially malicious, so I would always cross-call them. Any specific use case?

Comment on lines +118 to +137
A proposal can be executable implementing either the **Executable** interface
or the **CrossExecutable** one as part of the new proposal definition:

```go
type Executable interface {
// Execute executes the proposal.
Execute() error
}

type CrossExecutable interface {
// Execute executes the proposal.
Execute(realm) error
}
```

**CrossExecutable** can only be implemented when the proposal definition is
defined within a realm instead of a package, Gno only allows defining crossing
functions and methods within realms. So, executable proposal definitions
defined within packages must implement **Executable** instead, and when
crossing is required it must be done explicitly within the `Execute()` method.
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this should be supported; or if it is, a proposal should first go through a realm, and then that realm calls the pure package

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

Development

Successfully merging this pull request may close these issues.

5 participants