Governance Proposal

A proposal with its tally. Quorum is tracked separately from the majority because they are separate tests — a 92% "for" reads as passing right up until it fails for turnout.

src/components/ui/governance-proposal.tsx

About

From the component's own source, where it was written.

A governance proposal with its tally.

Quorum is tracked separately from the majority, because they are separate tests and a proposal routinely passes one and fails the other. A bar showing 92% "for" reads as passing right up until it fails for turnout, so the quorum line is always rendered — never hidden once met.

Abstain counts toward quorum but not toward the majority. That is the whole point of an abstain vote, and a component that folds it into "against" gets the outcome wrong.

Install

npx astralyx-ui add governance-proposal

Usage

import { GovernanceProposal } from '@/components/ui/governance-proposal'

<GovernanceProposal id="AIP-42" title="…" state="active" forVotes={820000} againstVotes={64000} quorum={1200000} />

Composer

Change the props and the source below follows.

AIP-42Activeends

Raise the treasury allocation for ecosystem grants to 5%

For 820k · 93%Against 64kAbstain 42k
Quorum not met926k / 1.2m

Without quorum this proposal fails regardless of the vote.

Proposed by stablelab.eth

Props
tsx
<GovernanceProposal
  id="AIP-42"
  title="…"
  state="active"
  forVotes={820000}
  againstVotes={64000}
  quorum={1200000}
/>

Examples

Proposal

API

Generated from the source, so it cannot fall behind the code. One table per exported component, then hooks, functions and types.

GovernanceProposal

A governance proposal with its tally.

Extends Omit<ComponentProps<'article'>, 'title' | 'id'>.

PropTypeDefaultDescription
idReactNoderequired—
titleReactNoderequired—
stateProposalStaterequiredVoting controls appear only while active.
forVotesnumberrequiredAbstain counts toward quorum but never toward the majority — folding it into "against" gets the outcome wrong.
againstVotesnumberrequiredAbstain counts toward quorum but never toward the majority — folding it into "against" gets the outcome wrong.
abstainVotesnumber0Abstain counts toward quorum but never toward the majority — folding it into "against" gets the outcome wrong.
quorumnumber—Always rendered, including once met.
endsAtDate——
nowDate——
summaryReactNode——
proposerReactNode——
onVote(choice: 'for' | 'against' | 'abstain') => void——
localestring'en-GB'—
endsLabelReactNode'ends'Precedes the closing time.
forLabelReactNode'For'—
againstLabelReactNode'Against'—
abstainLabelReactNode'Abstain'—
quorumNoteReactNode'Without quorum this proposal fails regardless of the vote.'Shown while the vote is short of quorum.
proposedByLabelReactNode'Proposed by'Precedes the proposer.

Types

TypeDefinitionDescription
ProposalState
'pending' | 'active' | 'passed' | 'defeated' | 'executed' | 'cancelled'
—