Skip to content

Feat/configurable governance parameters#942

Open
Opulencechuks wants to merge 3 commits into
bakeronchain:mainfrom
Opulencechuks:feat/configurable-governance-parameters
Open

Feat/configurable governance parameters#942
Opulencechuks wants to merge 3 commits into
bakeronchain:mainfrom
Opulencechuks:feat/configurable-governance-parameters

Conversation

@Opulencechuks
Copy link
Copy Markdown
Contributor

This PR closes #599
PR Description: Configurable Governance Parameters

Description
This pull request makes the DAO governance parameters (quorum threshold, approval BPS, and voting period) dynamically configurable. Previously, these parameters were hardcoded in the smart contract. They are now stored in the contract's instance storage and can be configured at runtime by the admin. The values are fetched from the blockchain via frontend hooks and displayed dynamically in a new Governance Parameters card on the DAO dashboard page.

Key Changes
Smart Contract (contracts/scholarship_treasury/src/lib.rs)

  • Added on-chain storage key (VOTING_PERIOD_KEY) and getters/setters for quorum, approval_bps, and voting_period.
  • Implemented admin functions: set_quorum, set_approval_bps, and set_voting_period (with validation).
  • Introduced ProposalKind (Disbursement vs ParameterChange) and extended the Proposal struct with variants/fields to allow modifying contract parameters via passed proposals.
  • Updated execute_proposal to apply parameter changes if a ParameterChange proposal is approved.

Frontend Hook & Mock (src/hooks/useGovernance.ts & src/hooks/useGovernance.test.tsx)

  • Updated src/contracts/scholarship_treasury.ts (shim) with stub methods for the new getters.
  • Added a useQuery block in useGovernance hook to fetch quorum, approvalBps, and votingPeriod from the contract client.
  • Updated the tests' mock return values to maintain compatibility and successful compilation of test suites.

UI Integration (src/pages/Dao.tsx)

  • Imported useGovernance inside the Dao page component.
  • Extracted and formatted quorum (using the 7-decimal formatGov helper) and votingPeriod (using locale formatting).
  • Wired the values into the Governance Parameters card display.

How to Test

  1. Smart Contract Tests (Rust)
    Run the Rust unit tests inside the contracts/scholarship_treasury directory:
cargo test

Verify that all tests compile and pass successfully.

  1. Frontend Unit Tests (Vitest)
    Verify that the React mock testing for the governance hook passes:
npm run test:frontend
 or
npx vitest run
  1. Manual Verification (UI Dashboard)
  2. Start the development server:
npm run dev
  1. Open the browser and navigate to the DAO page (e.g., http://localhost:3000/dao).
  2. Locate the new Governance Parameters card under the header.
  3. Verify that:
    • The Quorum (GOV), Approval BPS, and Voting Period (ledgers) statistics render without undefined values.
    • The quorum amount is formatted correctly with proper decimals (e.g., displaying 100 instead of a raw 1000000000 value).
    • The voting period ledgers count is formatted using locale-appropriate separators.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@Opulencechuks Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Anuoluwapo25
Copy link
Copy Markdown
Contributor

Kindly fix conflicts @Opulencechuks

1 similar comment
@benfoster-dev
Copy link
Copy Markdown
Contributor

Kindly fix conflicts @Opulencechuks

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.

feat: implement configurable quorum and threshold parameters in governance

3 participants