Skip to content

Feature/common ground plugin#838

Open
flotob wants to merge 3 commits into1Hive:mainfrom
flotob:feature/common-ground-plugin
Open

Feature/common ground plugin#838
flotob wants to merge 3 commits into1Hive:mainfrom
flotob:feature/common-ground-plugin

Conversation

@flotob
Copy link

@flotob flotob commented Mar 6, 2026

Common Ground Plugin Integration

Summary

This PR adds support for running the Gardens app as a Common Ground plugin inside an iframe. When loaded through CG, the app can access the CG runtime API to retrieve user and community data.

What's implemented

  • CG plugin library integration: Installed @common-ground-dao/cg-plugin-lib (client) and @common-ground-dao/cg-plugin-lib-host (server) packages
  • Signing endpoint (app/api/sign/route.ts): Next.js API route that signs requests with the plugin private key, required by the CG client lib to authenticate with the CG runtime
  • Plugin context providers: CgPluginLibProvider initializes the CG client lib when ?iframeUid= is present in the URL; CgDataProvider fetches and caches user/community info from CG. Both gracefully no-op when the app runs standalone (outside the iframe)
  • User greeting: The gardens front page shows a "Hello, {name}!" banner with the user's avatar when loaded inside CG
  • Community name pre-fill: The create community form auto-populates the community name field with the CG community title

What's missing / next steps

1. Community-scoped view instead of global list

Currently, when Gardens loads inside a CG community, it still shows the global list of all Gardens communities across all chains. Instead, it should detect whether the current CG community already has a linked Gardens community and navigate directly to it.

2. CG community <-> Gardens community mapping

To make the above work, we need a reliable way to match a CG community to its corresponding Gardens community. Name matching is too fragile. Two options:

  • Store the CG community ID on-chain: Add a cgCommunityId field to the RegistryCommunity contract (or its metadata) so we can look up a Gardens community by CG community ID. This is the most reliable approach but requires a contract change.
  • Match by governance token address: If CG communities expose a token address, we could match on that. Less robust (multiple Gardens communities could share a token) but avoids contract changes.

The CG community ID is available via communityInfo.id from the plugin API.

3. Conditional UX based on community state and user role

Once the mapping exists, the plugin should handle two cases when a CG community loads Gardens:

  • Community exists: Skip the global list entirely and go straight to that community's dashboard
  • Community does not exist:
    • If the CG user has the Admin role (isAdmin from useCgData()): show the create community form with all available fields pre-filled from CG data (name, and potentially token address or other fields the CG API provides)
    • If the CG user is a regular member: show a message like "This community hasn't set up Gardens yet" (or similar), optionally with a prompt to ask their community admins to set it up

flotob and others added 2 commits March 6, 2026 19:59
Add CG plugin lib integration so Gardens can run as an iframe plugin
inside app.cg. Includes client-side plugin initialization, CG data
context (user/community info), server-side signing endpoint, and a
greeting banner on the gardens page. Gracefully no-ops when running
standalone (no iframeUid).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
When running as a CG plugin, the create community form now
auto-populates the community name field with the CG community title.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@vercel
Copy link

vercel bot commented Mar 6, 2026

@flotob is attempting to deploy a commit to the 1hive Team on Vercel.

A member of the Team first needs to authorize it.

@Corantin
Copy link
Contributor

Corantin commented Mar 7, 2026

Hey @flotob thanks for setuping that up. I just have some interogations,
What would be the implication of having anyone can craft a signature with the PK for the sign api call, is this PK currently managing or holding something ? you dont think it could be emptied systematically ?

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