Skip to content

Comments

feat: add InitialWearersAssigned event for subgraph User creation#81

Merged
hudsonhrh merged 11 commits intomainfrom
feat/initial-wearers-event
Jan 30, 2026
Merged

feat: add InitialWearersAssigned event for subgraph User creation#81
hudsonhrh merged 11 commits intomainfrom
feat/initial-wearers-event

Conversation

@hudsonhrh
Copy link
Member

Summary

  • Adds InitialWearersAssigned event emitted after OrgDeployed with all wearer-to-hat mappings
  • Fixes timing issue where subgraph couldn't create User entities during deployment
  • Includes helper function _collectInitialWearers to collect wearers from role configurations

Problem

During deployment, WearerEligibilityUpdated events are emitted BEFORE OrgDeployed. When the subgraph processes these events, the EligibilityModuleContract entity doesn't exist yet (it's created by handleOrgDeployed), so User entities cannot be created. This results in deployers not being recognized as org members immediately after deployment.

Solution

Add a new event InitialWearersAssigned that is emitted AFTER OrgDeployed. Since events are processed in log index order, this event will be processed after EligibilityModuleContract exists, allowing proper User creation.

Changes

  1. Event Definition: Added InitialWearersAssigned(bytes32 indexed orgId, address indexed eligibilityModule, address[] wearers, uint256[] hatIds)

  2. Helper Function: Added _collectInitialWearers() that iterates through role configurations and collects:

    • Deployer address (if mintToDeployer is true)
    • Executor address (if mintToExecutor is true)
    • All additionalWearers
  3. Event Emission: Emitted after OrgDeployed in _deployFullOrgInternal()

Test plan

  • Verify smart contract compiles (forge build)
  • Deploy updated contract
  • Deploy corresponding subgraph changes
  • Test org deployment with mintToDeployer: true
  • Verify deployer appears in org's users list immediately

🤖 Generated with Claude Code

hudsonhrh and others added 8 commits December 9, 2025 16:38
Allow organizations to define initial projects and tasks in deployment config, created atomically in the same transaction as org deployment. Includes JSON parsing, role index resolution, and bootstrap infrastructure in TaskManager.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add 10 bootstrap tests to TaskManager.t.sol covering:
  - Single/multiple projects, managers, role permissions
  - Bounty tasks, application-required tasks
  - Invalid inputs, empty arrays, full task lifecycle
- Add bootstrap integration support to DeployerTest.t.sol
  - Add _emptyBootstrap() helper function
  - Update all 18 DeploymentParams to include bootstrap field
- Fix deploy script type references:
  - Import ITaskManagerBootstrap from OrgDeployer.sol
  - Change OrgDeployer.ITaskManagerBootstrap -> ITaskManagerBootstrap
- Add bootstrap parsing/building to RunOrgActions.s.sol and
  RunOrgActionsAdvanced.s.sol for full deploy script support
- Pin OpenZeppelin submodule to v5.0.2 (correct version for codebase)

All 557 tests pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Deploy deployer eligibility is now conditional on `canVote && mintToDeployer`,
matching minting behavior. Executor remains eligible for all roles as needed
for governance operations. This prevents unnecessary eligibility entries and
ensures role config intent is fully respected.

- Only set deployer eligibility when they're receiving the hat
- Executor stays eligible for all roles (required for QuickJoin)
- Update CLAUDE.md to document that upgrades/ is auto-generated by CI
- All 547 tests pass

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Run forge fmt on merged code from org-deploy-project-task branch.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Defense-in-depth security improvement for the bootstrap system:

- Add clearDeployer() function to TaskManager that can only be called
  by the deployer to permanently revoke bootstrap privileges
- OrgDeployer now calls clearDeployer() after bootstrap phase completes
- This prevents any future bootstrapProjectsAndTasks calls even if
  OrgDeployer were compromised

Tests added:
- test_ClearDeployerSuccess
- test_ClearDeployerOnlyDeployer
- test_ClearDeployerCannotBeCalledTwice
- test_BootstrapThenClear
- testFullOrgDeploymentWithBootstrapAndClearDeployer

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The executor receives admin authority via the topHat transfer, not by
wearing individual role hats. This change removes unnecessary overhead:

- Remove mintToExecutor field from RoleDistributionConfig struct
- Remove executor from eligibility setup (was added to every role)
- Remove executor from minting loop
- Update deployment scripts and JSON configs
- Update tests to reflect new struct shape

The executor can still mint hats to users via its topHat admin authority.
All 562 tests pass.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
During deployment, WearerEligibilityUpdated events are emitted before
OrgDeployed, causing a timing issue in the subgraph where User entities
cannot be created (EligibilityModuleContract doesn't exist yet).

This PR adds a new InitialWearersAssigned event emitted after OrgDeployed
that includes all addresses who received hats during deployment. The
subgraph can then process this event to create User and RoleWearer
entities with proper organization context.

Changes:
- Add InitialWearersAssigned event definition
- Add _collectInitialWearers helper function
- Emit event after OrgDeployed with wearer-to-hat mapping

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
hudsonhrh and others added 3 commits January 28, 2026 15:52
The _collectInitialWearers function referenced the removed mintToExecutor
field from RoleDistributionConfig. This fix aligns the function with
PR 80's changes that removed mintToExecutor from the struct.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@hudsonhrh hudsonhrh merged commit bf060cc into main Jan 30, 2026
8 checks passed
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.

1 participant