Skip to content

Fix token gate to use community-config tokens with systemConfig fallback#1763

Draft
Jhonattan2121 wants to merge 1 commit intocanaryfrom
fix/token-gate-community-config-fallback
Draft

Fix token gate to use community-config tokens with systemConfig fallback#1763
Jhonattan2121 wants to merge 1 commit intocanaryfrom
fix/token-gate-community-config-fallback

Conversation

@Jhonattan2121
Copy link
Collaborator

@Jhonattan2121 Jhonattan2121 commented Feb 9, 2026

Description

Summary

This PR fixes a token gate regression where access checks could fail even for eligible users (e.g. holding $SPACE and/or nOGs) when systemConfig was not explicitly passed to certain client components.

Root Cause

Token gate logic depends on systemConfig.community.tokens (from community_configs).
Some UI paths rendered gate components without a systemConfig prop, causing token resolution to fail in those contexts.

Changes

  • Added a client-side SystemConfig context:
    • src/common/providers/SystemConfigProvider.tsx
  • Wired app providers to expose the runtime systemConfig globally:
    • src/common/providers/index.tsx
    • src/app/layout.tsx
  • Updated token gate hook to resolve config via fallback:
    • prop systemConfig -> SystemConfig context
    • src/common/lib/hooks/useTokenGate.ts
  • Updated NogsGateButton to use the same fallback for both ERC20 and NFT checks:
    • src/common/components/organisms/NogsGateButton.tsx

Impact

Token gate now consistently uses the current community token config from community_configs, including flows where systemConfig was previously not passed down explicitly.

Summary by CodeRabbit

  • New Features

    • Introduced system configuration context provider for application-wide configuration management
  • Chores

    • Updated Nouns community NFT token configuration with new contract address, updated token symbol ('nOGs'), and network designation (Base blockchain)
    • Enhanced provider architecture to support context-based configuration propagation and improved token gating support

@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
space-system Ready Ready Preview, Comment Feb 9, 2026 8:21pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 9, 2026

📝 Walkthrough

Walkthrough

The changes implement a SystemConfig context provider pattern, enabling components to access system configuration through context or props with fallback support. Additionally, the Nouns community NFT token configuration is updated with a new contract address, symbol (nOGs), and network (base).

Changes

Cohort / File(s) Summary
Context Provider Foundation
src/common/providers/SystemConfigProvider.tsx
New React context provider for SystemConfig with a hook (useSystemConfigContext) for consuming config values. Supports null fallback when context is unavailable.
Provider Integration
src/common/providers/index.tsx, src/app/layout.tsx
Updated Providers component to accept and propagate systemConfig prop, wrapping the provider tree with SystemConfigProvider. Layout component now passes systemConfig to Providers.
Component Context Adoption
src/common/components/organisms/NogsGateButton.tsx, src/common/lib/hooks/useTokenGate.ts
Components updated to support both prop-based and context-based systemConfig access with fallback pattern (prefer prop > context > undefined). Enables token gating logic to retrieve config dynamically.
Seed Data Update
scripts/seed-data/communities/nouns.ts
Nouns NFT token configuration updated: address changed to 0xD094D5D45c06c1581f5f429462eE7cCe72215616, symbol changed to 'nOGs', network changed from 'eth' to 'base'.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A context flows through component trees so bright,
Where config finds its place both left and right,
With fallbacks gentle, props take precedence true,
Nouns hops to base with addresses fresh and new!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing token gate logic to use community-config tokens with a systemConfig fallback, which aligns with the core objective of the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/token-gate-community-config-fallback

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
src/common/components/organisms/NogsGateButton.tsx (2)

53-60: Duplicated effectiveConfig resolution — consider extracting to a shared utility or relying solely on the hook.

Both NogsGateButton and useTokenGate independently resolve effectiveConfig with the same systemConfig ?? contextConfig ?? undefined pattern. Since useTokenGate already resolves this internally, passing effectiveConfig to it is redundant (it would just prefer the passed value over context, arriving at the same result).

The getNftTokens call on line 60 does justify needing the config locally. A cleaner approach could be to have useTokenGate also return the effectiveConfig (or the NFT tokens), so NogsGateButton doesn't need to duplicate the resolution.


72-111: isHoldingNogs is not memoized but is called from useCallback (checkForNogs).

isHoldingNogs is recreated on every render and closes over nftTokens and store setters. checkForNogs (a useCallback) calls it but doesn't list it as a dependency — instead it lists nftTokens directly. This works because the function only reads nftTokens from the closure, and checkForNogs is already re-created when nftTokens changes. Not a bug currently, but wrapping isHoldingNogs in useCallback with [nftTokens] would make the dependency relationship explicit and less fragile.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Jhonattan2121 Jhonattan2121 marked this pull request as draft February 9, 2026 20:29
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