Conversation
Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
|
@copilot Please read below review thoroughly and follow up on each point. pull-request 299 is referring to this: GoodDollar/GoodProtocol#299 Follow-up: GovernanceWidget first-pass fix (v2)Update GoodWidget PR #77 so its runtime is contract-correct, maintainable, and free of production mock data. Work only in the governance-widget package, its stories, and its tests. Keep the existing visual design unless a real loading, empty, error, or transaction state requires different copy. 1. Make the package build and establish clean boundaries
Checkpoint: the package builds declarations and ABI/mapping tests pass. 2. Fix membership and onboarding
Checkpoint: an eligible HoA wallet and a Citizen wallet can complete their correct mocked-RPC onboarding paths, and failed receipts never show success. 3. Replace mock voting with contract-derived statesRead:
Then implement:
Checkpoint: every voting state is derived from mocked contract responses, and submitted recipients are valid addresses. 4. Add live “funding received so far”
Use this exact query: query FundingStreams($receiver: String!, $token: String!, $first: Int!, $skip: Int!) {
streams(
first: $first
skip: $skip
where: { receiver: $receiver, token: $token }
) {
sender { id }
currentFlowRate
streamedUntilUpdatedAt
updatedAtTimestamp
}
}
Checkpoint: subgraph fixtures cover active, stopped, multiple, empty, paginated, and failed stream queries. 5. Finish QA and evidence
Run: pnpm install
pnpm build
pnpm lint
pnpm test:demo tests/widgets/governance-widgetDocument unrelated root lint failures instead of changing unrelated packages. Done when
|
Co-authored-by: L03TJ3 <6606028+L03TJ3@users.noreply.github.com>
Addressed in 55ba33a. Updated the governance-widget runtime to use the final GoodDaoHouses ABI/mappers, split contract/transaction/voting/funding concerns, use HoA eligibility separately from GoodID, wait for transferAndCall receipts for registration/restake, derive voting/funding from contract/subgraph data, and added focused mapper/transaction/funding tests plus refreshed affected screenshots. Validation: |
…99) * feat(governance): finalize membership lifecycle * fix(governance): harden transaction lifecycle (#80) Guard registration, unstake, and voting receipts by wallet scope and prevent duplicate submissions. Enforce current house stake thresholds and chain-time locks, expand real-adapter coverage, and stabilize screenshot evidence. * fix(governance): address review feedback (#80) * fix(governance): remove obsolete HoA eligibility gate (#80)
…plan-wire-governancewidget-to-gooddaohouses
There was a problem hiding this comment.
Pull request overview
This PR introduces a production-style runtime boundary for @goodwidget/governance-widget that wires the GovernanceWidget to GoodDaoHouses contracts (via viem + SDK helpers), while keeping the widget mockable for Storybook and testable via Playwright.
Changes:
- Added a governance runtime adapter layer (contract address resolution, reads/mappers, transactions, identity verification link generation, and Superfluid funding aggregation).
- Added an app-level
GovernanceWidgetcomposed of runtime-aware states (onboarding/membership/voting/funding/unstake, including transaction state handling and guarded single-flight transactions). - Expanded QA coverage with Storybook runtime fixtures plus Playwright runtime + adapter-logic tests and deterministic screenshot capture.
Reviewed changes
Copilot reviewed 32 out of 80 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/widgets/governance-widget/runtime.spec.ts | Adds end-to-end runtime smoke coverage over Storybook runtime fixtures, including RPC/subgraph mocking and screenshots. |
| tests/widgets/governance-widget/onboarding.spec.ts | Updates onboarding Playwright tests for new copy/flow controls and more deterministic screenshots (animations disabled + retries). |
| tests/widgets/governance-widget/adapter-logic.spec.ts | Adds Playwright-run logic tests for mappers, receipt handling, vote validation, funding aggregation, and membership/voting edge cases. |
| pnpm-lock.yaml | Locks new governance-widget dependencies (@goodsdks/citizen-sdk, viem). |
| packages/governance-widget/src/widgetRuntimeContract.ts | Defines the public adapter state/actions contract for the runtime widget boundary. |
| packages/governance-widget/src/types.ts | Extends onboarding + funding props to support house-specific stake labels and identity verification callbacks. |
| packages/governance-widget/src/sdks/transactions.ts | Implements receipt-aware membership/vote transaction helpers (transferAndCall, unstake, castVote). |
| packages/governance-widget/src/sdks/identity.ts | Adds GoodID SDK wrapper + verification link helper. |
| packages/governance-widget/src/sdks/funding.ts | Implements Superfluid subgraph pagination + bigint funding aggregation and formatting. |
| packages/governance-widget/src/sdks/contracts.ts | Adds contract ABIs, address resolution, mappers, receipt helper, and Celo switch helper. |
| packages/governance-widget/src/sdks/contractReads.ts | Implements membership/schedule/vote/flow config reads and vote window derivation. |
| packages/governance-widget/src/onboarding/steps/WelcomeStepContent.tsx | Wires identity verification CTA callback into the welcome step. |
| packages/governance-widget/src/onboarding/steps/StakeStepContent.tsx | Adjusts stake step layout to match updated shell copy and simplified header. |
| packages/governance-widget/src/onboarding/steps/ProfileStepContent.tsx | Removes a now-obsolete CTA comment. |
| packages/governance-widget/src/onboarding/steps/HouseStepContent.tsx | Moves to per-house stake labels and removes disabled-house behavior. |
| packages/governance-widget/src/onboarding/OnboardingIdentityCard.tsx | Adds a dedicated “Verify with GoodID” CTA when unverified. |
| packages/governance-widget/src/onboarding/HouseSelectionCard.tsx | Simplifies UI (removes disabled + “Selected” badge) and adjusts heading level. |
| packages/governance-widget/src/onboarding/GovernanceOnboardingFlow.tsx | Adds runtime callbacks (house change/profile submit/identity verify), updates copy, and gates “Continue to success” until steps complete. |
| packages/governance-widget/src/onboarding/copy.ts | Updates per-house labels used in selection UI. |
| packages/governance-widget/src/index.ts | Exports GovernanceWidget, adapter contract types, and SDK helpers publicly. |
| packages/governance-widget/src/hooks/useGovernanceVoting.ts | Adds voting state derivation, ballot validation, guarded vote submission, and schedule-based labels. |
| packages/governance-widget/src/hooks/useGovernanceTransactionGuard.ts | Adds single-flight transaction guard keyed by account/chain/contract scope. |
| packages/governance-widget/src/hooks/useGovernanceMembership.ts | Adds membership runtime reads, onboarding state, registration/unstake flows, and identity verification start logic. |
| packages/governance-widget/src/hooks/useGovernanceFunding.ts | Adds funding runtime state + periodic refresh behavior backed by subgraph reads. |
| packages/governance-widget/src/GovernanceWidget.tsx | Adds the app-level runtime widget UI that routes between runtime states and composes dashboard/onboarding/vote detail. |
| packages/governance-widget/src/GovernanceOnboardingWidget.tsx | Updates onboarding widget prop plumbing for house stake labels and runtime callbacks. |
| packages/governance-widget/src/FundingDistributionChart.tsx | Adds optional stateLabel rendering to explain funding refresh/availability states. |
| packages/governance-widget/src/adapter.ts | Implements useGovernanceAdapter composing membership/voting/funding hooks into a single adapter contract. |
| packages/governance-widget/package.json | Adds @goodsdks/citizen-sdk and viem as runtime dependencies. |
| examples/storybook/src/stories/governance-widget/GovernanceRuntime.stories.tsx | Adds runtime fixture stories covering disconnected/loading/onboarding/active/voting/funding/unstake/error states. |
| examples/storybook/src/stories/governance-widget/GovernanceOnboarding.stories.tsx | Tightens story frame typing/layout and sets initial house for interactive onboarding story. |
| examples/storybook/src/fixtures/governanceRuntimeMock.ts | Adds an RPC-read mock encoder used by runtime Playwright tests. |
| AGENTS.md | Updates QA summary to reflect tracked per-widget Playwright screenshot output location. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
| onboardingStepId: 'stake', | ||
| profileDraft, | ||
| transactionSteps: createTransactionSteps('failed', error), | ||
| transaction: { kind: 'registration', status: 'failed', hash: null, error }, |
| function readConfiguredAddress(key: keyof GovernanceEnvironmentConfig, envNames: string[]): Address | undefined { | ||
| const runtimeGlobal = globalThis as RuntimeGlobal | ||
| const explicitAddress = runtimeGlobal.__GOODWIDGET_GOVERNANCE__?.[key] | ||
| if (explicitAddress) return explicitAddress | ||
|
|
||
| const publicEnv = runtimeGlobal.process?.env | ||
| const configuredValue = envNames.map((envName) => publicEnv?.[envName]).find(Boolean) | ||
| return configuredValue as Address | undefined | ||
| } |
| publicClient.readContract({ | ||
| address: housesAddress, | ||
| abi: GOODDAO_HOUSES_ABI, | ||
| functionName: 'getActiveMembers', | ||
| args: [houseToContractValue('citizenship')], | ||
| }), | ||
| publicClient.readContract({ | ||
| address: housesAddress, | ||
| abi: GOODDAO_HOUSES_ABI, | ||
| functionName: 'getActiveMembers', | ||
| args: [houseToContractValue('alignment')], | ||
| }), |
| if (rawRecipients.length === 0 && isVotingPeriod && voteStartTime) { | ||
| // Before the first ballot creates the on-chain snapshot, mirror the | ||
| // contract rule so late-joining HoA members are never submitted. | ||
| const provisionalRecords = await Promise.all( | ||
| activeAlignment.map(async (recipient) => ({ | ||
| recipient, | ||
| member: mapMemberRecord( | ||
| await publicClient.readContract({ | ||
| address: housesAddress, | ||
| abi: GOODDAO_HOUSES_ABI, | ||
| functionName: 'getMember', | ||
| args: [recipient], | ||
| }), | ||
| ), | ||
| })), | ||
| ) | ||
| recipients = provisionalRecords | ||
| .filter(({ member }) => | ||
| member.status === 'active' && | ||
| member.house === 'alignment' && | ||
| member.joinedAt !== null && | ||
| member.joinedAt <= voteStartTime, | ||
| ) | ||
| .map(({ recipient }) => recipient) | ||
| } |
Implements the reviewed GovernanceWidget plan by adding a contract-correct app-level runtime boundary for GoodDaoHouses membership, onboarding, dashboard, Alignment voting states, and live funding totals. The widget remains mockable for Storybook/Playwright while keeping contract and SDK logic out of presentational cards.
Runtime adapter + SDK layer
useGovernanceAdapterwith mockable adapter-factory contract.App-level GovernanceWidget
Governance flows
bigintvalues and derives labels only for display.getHoaEligibility(account)while keeping GoodID verification as a separate onboarding requirement with an actionable verification button.transferAndCall, waits for receipts, and reflects wallet-confirmation, submitted, confirmed, rejected, and reverted states.isVotingPeriod,getCurrentVoteId,getVoteConfig,getVoteRecipients, active HoA members,getHasVoted, and finalized units.Funding received so far
flowSplitterConfig.poolAddressas the Superfluid receiver.QA coverage