Add org background color from metadata#125
Open
hudsonhrh wants to merge 11 commits intohudsonhrh/edit-org-metadatafrom
Open
Add org background color from metadata#125hudsonhrh wants to merge 11 commits intohudsonhrh/edit-org-metadatafrom
hudsonhrh wants to merge 11 commits intohudsonhrh/edit-org-metadatafrom
Conversation
…ph (#120) * feat: Add org metadata editing for admins - Add Settings page with OrgMetadataEditor component - Allow org metadata admin hat wearers to edit name, description, logo, and links - Add useIsOrgAdmin hook to check if user wears metadata admin hat - Update NavBar to show Settings link for admins - Update OrgRegistry ABI with new admin functions - Add METADATA_UPDATED refresh event Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: Update frontend web3 calls to match latest smart contract changes (#121) * feat: Update frontend web3 calls to match latest smart contract changes This update aligns the frontend service layer and ABIs with significant smart contract changes including security audit fixes, removal of the ECDSA vouch path, and new functionality. ## Major Changes ### ABI Updates (18 files from Foundry artifacts) - **QuickJoin**: BREAKING - `quickJoinNoUser()` no longer accepts username parameter - **UniversalAccountRegistry**: BREAKING - `registerAccountQuickJoin()` and `setAuthorizedCaller()` removed; kept `registerAccount()` for explicit registration - **EligibilityModule**: NEW - `applyForRole(hatId, applicationHash)` and `withdrawApplication(hatId)` for role applications - **TaskManager**: NEW - `rejectTask(taskId, rejectionHash)` for task rejection - **Executor**: NEW - `proposeCaller()`, `acceptCaller()`, `cancelCallerChange()` with 2-day timelock for caller changes - **PaymasterHub**: BREAKING - `registerOrgWithVoucher()`, `setVoucherHat()`, `isVouchUsed()` removed (ECDSA vouch path eliminated) - 12 additional ABIs synced (ParticipationToken, EducationHub, HybridVoting, DirectDemocracyVoting, OrgRegistry, PoaManager, etc.) ### Service Layer Updates **OrganizationService** (CRITICAL): - Rewrote `quickJoinNoUser()` as two-step transaction flow: 1. Register username via `UniversalAccountRegistry.registerAccount(username)` 2. On success, join organization via `QuickJoin.quickJoinNoUser()` (empty args) - Public method signature unchanged - UI call sites need no changes - Added `registryAddress` constructor parameter and factory function support **TaskService**: - Added `rejectTask(contractAddress, taskId, rejectionCid, options)` method - Follows existing pattern: converts IPFS CID to bytes32 hash **EligibilityService**: - Added `applyForRole(contractAddress, hatId, applicationHash, options)` method - Added `withdrawApplication(contractAddress, hatId, options)` method - Enables new on-chain role application system ### Hook Updates - Updated `useWeb3Services` to wire `registryAddress` as third parameter to `OrganizationService` constructor ### Component Fixes - Fixed ABI import paths in OrgMetadataEditor.jsx and useIsOrgAdmin.js (changed from `@/abi/` path alias to relative paths, as ABIs are in `poa-app/abi/` not `src/`) - Updated UI pending message in user page to reflect two-step nature: "Registering username and joining organization..." ## Gas Sponsorship Note The new two-step flow results in two sequential transactions rather than bundled. This means: - `registerAccount()` transactions cannot be sponsored standalone for EOA users (regression from old system) - Smart account users could theoretically batch via `executeBatch()` but this is not implemented in current frontend - Impact: New EOA users must pay for their own registration transaction ## Testing - Build verified: `npx next build` succeeds with no import or compilation errors - ABI verification: - QuickJoinNew.json no longer contains username parameters - UniversalAccountRegistry no longer has registerAccountQuickJoin - New methods present in TaskManagerNew, EligibilityModuleNew, Executor Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: Add task rejection UI, role application flow, and sync ABIs - Add task rejection UI with inline textarea and permission-gated Reject button in TaskCardModal, using project-level canReviewTask permissions - Add rejectTask handler to TaskBoardContext with optimistic UI updates - Add role application flow: RoleApplicationModal, Apply/Applied button states in ClaimRoleButton, IPFS-backed application data upload - Add applyForRole, withdrawApplication, and hasActiveApplication to useClaimRole hook with contract-read status checks on mount - Add hasActiveApplication read method to EligibilityService - Sync QuickJoinNew.json and UniversalAccountRegistry.json ABIs with latest Foundry output (additive: registerAndQuickJoin*, registerBy*Sig) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> * feat: Update frontend queries and hooks to use subgraph data Replace RPC calls with subgraph queries for better performance: - Add metadataAdminHatId to FETCH_ORG_FULL_DATA and FETCH_ORG_STRUCTURE_DATA - Simplify useIsOrgAdmin to read from POContext instead of RPC calls - Update useClaimRole to use FETCH_USER_ROLE_APPLICATIONS subgraph query - Add task rejection fields (rejectionHash, rejectionCount) to project queries - Add application detail fields (applicantUsername, applicationHash, etc.) - Add FETCH_USER_ROLE_APPLICATIONS and FETCH_ALL_ROLE_APPLICATIONS queries - Transform task applications to applicants format in ProjectContext - Expose metadataAdminHatId and logoUrl from POContext Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: Address review issues in OrgMetadataEditor and cleanup - Use txManager.execute() instead of raw contract call so executeWithNotification receives proper { success, transactionHash } result (was broken: result.success was always undefined) - Add URL validation on links to prevent XSS via javascript: URLs - Remove duplicate success toast (executeWithNotification handles it) - Replace ethers.utils.toUtf8Bytes with stringToBytes for consistency - Remove unused ethers import from OrgMetadataEditor - Fix checkApplicationStatuses call to match new parameterless signature - Remove dead removeNotification destructuring in TaskBoardContext Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: Passkey wallet integration with gas sponsorship + simplifications (#122) Implement ERC-4337 smart account wallet powered by WebAuthn/passkeys with org-level gas sponsorship. Also simplifies ethers/viem dependencies and removes dead code. ## Features - Passkey (WebAuthn) account creation and signing via @simplewebauthn/browser - ERC-4337 UserOp submission via Pimlico bundler - PaymasterHub integration for org-level gas sponsorship (gas-free transactions) - Dual auth: supports both EOA (RainbowKit/wagmi) and passkey wallets seamlessly - Homepage/NavBar entry points for passkey reconnection (returning users) ## Simplifications - Remove redundant orgId sync in useWeb3Services (orgId already in useMemo deps) - Migrate ethers → viem across passkey service layer (keccak256, encodePacked, pad, encodeAbiParameters) - Extract shared credentialId utility (computeCredentialId) to eliminate duplication - Replace custom bytesToHex with viem's toHex (consistent hex conversion) ## Fixes - Add mounted guard for localStorage-dependent rendering to prevent hydration mismatches - Consolidate hex conversion utilities to eliminate inconsistent implementations ## Files Added - AuthContext: manages EOA vs passkey authentication state - SmartAccountTransactionManager: mirrors TransactionManager API for passkey accounts - PasskeyOnboardingService: orchestrates passkey creation, deployment, and onboarding - PasskeyLoginButton, PasskeyOnboardingModal, PasskeyAccountInfo, GasSponsorshipBadge: UI components - Passkey config, hooks, utilities, and service layer files Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
…unt (#123) When deploying an org without any authentication, now shows "Create an Account or Sign In" with passkey as primary option and wallet sign-in as secondary option. Updated deploy page to recognize both passkey and EOA wallet addresses via AuthContext. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Use wagmi's isConnected flag to determine if address is viable for deployment. This prevents stale localStorage wallet connections from bypassing the auth UI. When wagmi auto-reconnects to a previous wallet session but the connection isn't fully established, the deploy button was appearing but non-functional. Now only treat the address as deployable when isConnected is true. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Wagmi auto-reconnects from localStorage on page load, making previously-connected wallets appear active even when the user didn't explicitly connect this session. This prevented the auth UI (passkey + wallet sign-in options) from showing. Now explicitly disconnect any auto-reconnected wallet on mount, requiring users to choose their auth method. Passkey sessions are unaffected (managed separately in AuthContext). Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive console logs to trace: - wagmi connection status and wallet reconnect logic - deployerAddress computation - Whether auth UI shows correctly Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Worker and Creative Collective templates had roles set to vouch for themselves (voucherRoleIndex pointing to their own index), which violates the validation rule that a role cannot be its own voucher. Changes: - Worker Cooperative: Worker role now vouched by Steward (index 0→1) - Creative Collective: Artist role now vouched by Curator (index 0→1) This allows these templates to deploy without validation errors. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
* feat: Add visual rejection indicators to tasks - Show red "Rejected" badge on task cards when rejectionCount > 0 - Display rejection reason and history in task modal detail view - Include who rejected and when (from rejection history) - Add IPFS fallback for rejection metadata if not indexed yet - Query rejection field from task metadata and rejections subquery from subgraph This provides clear visual feedback to users when their task submissions are rejected, and allows them to see the rejection reason when viewing task details. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * fix: Fix IPFS key mismatch for rejection reason indexing The subgraph parses rejection reasons from IPFS using the key "rejection", but the frontend was uploading with the key "rejectionReason". This meant rejection reasons were never indexed by the subgraph and never displayed. - Change upload key from "rejectionReason" to "rejection" to match subgraph - Add backward-compat fallback for old "rejectionReason" key in IPFS display Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
#130) Sets default Pimlico API key for Hoodi testnet to enable passkey/ERC-4337 operations when NEXT_PUBLIC_PIMLICO_API_KEY env var is not set. Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
…131) * feat: Add visual rejection indicators to tasks - Show red "Rejected" badge on task cards when rejectionCount > 0 - Display rejection reason and history in task modal detail view - Include who rejected and when (from rejection history) - Add IPFS fallback for rejection metadata if not indexed yet - Query rejection field from task metadata and rejections subquery from subgraph This provides clear visual feedback to users when their task submissions are rejected, and allows them to see the rejection reason when viewing task details. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * fix: Fix IPFS key mismatch for rejection reason indexing The subgraph parses rejection reasons from IPFS using the key "rejection", but the frontend was uploading with the key "rejectionReason". This meant rejection reasons were never indexed by the subgraph and never displayed. - Change upload key from "rejectionReason" to "rejection" to match subgraph - Add backward-compat fallback for old "rejectionReason" key in IPFS display Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: Fix crash from treating metadata as array instead of object task.metadata is a singular TaskMetadata object in the schema, not an array. Calling .map() on it threw TypeError crashing the page. Changed to use task.metadata?.rejection consistent with existing field access. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
Now that TaskRejection links to its TaskMetadata entity, query the
rejection reason via rejections { metadata { rejection } } instead of
relying solely on IPFS fallback. The IPFS path remains as a fallback
for tasks rejected before the subgraph update.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Admin users can now set a custom background color for their org via metadata editing. The color is stored in IPFS metadata and indexed by the subgraph, making it available to all org pages without additional IPFS fetches. Changes include: - Frontend queries: Add backgroundColor to metadata GraphQL fragments - Context: Expose backgroundColor via POContext and set from metadata - Editor: Add color picker UI to metadata editor (hex + gradient support) - Pages: Apply dynamic background to all org pages consistently - Hook: Extract useOrgTheme() hook for clean, reusable theme abstraction - Bug fix: Consistent background on loading states to prevent visual flash Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
4b88232 to
2a61a9b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the ability for org admins to set a custom background color via metadata editing. The color is stored in IPFS, indexed by the subgraph, and applied dynamically to all org pages.
Key Changes
backgroundColorfield to OrgMetadata, parse from IPFS JSONuseOrgTheme()hook for clean, extensible theme value managementArchitecture
The implementation follows the existing pattern for indexed metadata fields:
useOrgTheme()hook abstracts away the implementationThis establishes a foundation for adding future theme fields (accent color, font family, etc.) without requiring changes to page files — only hook, context, schema, and IPFS handler updates.
🤖 Generated with Claude Code