Skip to content

Governor: fix re-exports - #605

Merged
brozorec merged 1 commit into
mainfrom
governor-re-exports
Mar 5, 2026
Merged

brozorec merged 1 commit into
mainfrom
governor-re-exports

Conversation

@brozorec

@brozorec brozorec commented Mar 5, 2026 •

Copy link
Copy Markdown
Collaborator

Following the library conventions, this PR re-exports all public functions from governor storage.

Summary by CodeRabbit

Release Notes

  • Refactor
    • Reorganized and expanded the governor module's public API to expose a comprehensive set of governance operations. Newly accessible functionality includes voting mechanisms, proposal lifecycle management, configuration management through getters and setters, and state querying capabilities. This restructuring improves accessibility and integration of core governance operations throughout the platform.

@brozorec
brozorec requested a review from ozgunozerk March 5, 2026 10:50
@brozorec brozorec self-assigned this Mar 5, 2026
@coderabbitai

coderabbitai Bot commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8b11336f-7c54-484a-aa15-873a8bd0d256

📥 Commits

Reviewing files that changed from the base of the PR and between 9a2afe2 and b137294.

📒 Files selected for processing (2)
  • examples/fungible-governor/governor/src/governor.rs
  • packages/governance/src/governor/mod.rs

Walkthrough

The changes expand the public API of the governor module by re-exporting storage functions (getters, setters, and action functions) and update example code to use the governor:: namespace directly instead of storage:: for function calls, simplifying the public interface.

Changes

Cohort / File(s) Summary
Example Code Integration
examples/fungible-governor/governor/src/governor.rs
Updated all storage function calls to use governor:: namespace (e.g., storage::execute → governor::execute), including constructors and method calls for name, version, token contract, voting parameters, proposals, and execution.
Governor Module Re-exports
packages/governance/src/governor/mod.rs
Expanded re-exports from crate::governor::storage to include comprehensive public API: getters (get_name, get_version, get_voting_*, get_proposal_*, get_quorum, etc.), setters (set_name, set_version, set_token_contract, set_voting_delay, set_voting_period, set_proposal_threshold, set_quorum), action functions (cancel, cast_vote, propose, execute, etc.), and voting constants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PR #563: Introduced the governor storage functions and module structure that are being re-exported in this change.
  • PR #603: Related changes to governor exports and namespace usage patterns for consistent API surface exposure.

Poem

🐰 The governor's house now opens wide its doors,
Storage secrets spill across the floors!
No more shadows, no storage in disguise,
Functions shine bright through the governor's eyes.
A cleaner path for all to see—
Harmony in the namespace tree! 🌳

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main objective of the PR: fixing/expanding re-exports in the governor module to follow library conventions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch governor-re-exports

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@ozgunozerk ozgunozerk left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not against the changes in examples folder.

But I think we shouldn't touch the mod.rs, and fix the rest of the library.

Due to, these are internal functions, so other crates importing them as module::storage::{func1, func2, func3} is not a disadvantage, and signals the message clearer imo.

The downside of the suggested approach in this PR is, if we are exporting these, then why are we using storage::func in the trait name? It is confusing.

We know to reason is to show that the trait implementation should not confuse the people, and clearly show that it is not recursive.

But it looks weird to export the function at crate level, then not using it directly, but with the storage::func path inside that very file

@codecov

codecov Bot commented Mar 5, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.37%. Comparing base (9a2afe2) to head (b137294).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #605   +/-   ##
=======================================
  Coverage   96.37%   96.37%           
=======================================
  Files          58       58           
  Lines        5960     5960           
=======================================
  Hits         5744     5744           
  Misses        216      216           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@brozorec

brozorec commented Mar 5, 2026

Copy link
Copy Markdown
Collaborator Author

But I think we shouldn't touch the mod.rs, and fix the rest of the library.
Due to, these are internal functions, so other crates importing them as module::storage::{func1, func2, func3} is not a disadvantage, and signals the message clearer imo.

The 1st reason I'm against exposing storage is the unnecessary verbosity. storage imo is an internal matter for every module, how we call it should be less relevant to users compared to the clean API. The point of re-exports is abstracting away the internal structure and I believe the lib does a good job in that aspect.

The downside of the suggested approach in this PR is, if we are exporting these, then why are we using storage::func in the trait name? It is confusing.

I've agreed with the usage of storage:: in the default implementations to avoid some sort of visual confusion, although I can argue there's no functional confusion because if it were a recursive call, it should've been Self::my_func().

@ozgunozerk
ozgunozerk self-requested a review March 5, 2026 11:55
@brozorec
brozorec merged commit 684bb89 into main Mar 5, 2026
6 checks passed
@brozorec
brozorec deleted the governor-re-exports branch March 5, 2026 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants