Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
4dd4a53
Expand CSP media and connect sources
willyogo Oct 17, 2025
3c060b3
Lower frame embed z-index under mobile nav
willyogo Oct 15, 2025
f5feb3c
Ensure frame image stays above card overlays
willyogo Oct 15, 2025
970122d
documentation update
j-paterson Oct 22, 2025
7efc1eb
typo correction
j-paterson Oct 22, 2025
56ee4e3
initial config consolidation
j-paterson Oct 22, 2025
81b48e6
first attempt at sourcing variables from config
j-paterson Oct 22, 2025
5c66b4d
cut out fidget specific data and trimmed config
j-paterson Oct 22, 2025
bd140a5
updated documentation
j-paterson Oct 22, 2025
70fc8af
remove future roadmap
j-paterson Oct 22, 2025
388bcf0
added example config
j-paterson Oct 22, 2025
459fcbd
updated imports
j-paterson Oct 23, 2025
a8741e4
type fix
j-paterson Oct 23, 2025
6d39477
parameter order fixed
j-paterson Oct 23, 2025
fa184e3
unused var cleanup and type safety
j-paterson Oct 23, 2025
b56e6c1
cleaned up unused imports
j-paterson Oct 23, 2025
3e08800
cleaned up unused imports
j-paterson Oct 23, 2025
98e415b
cleaned up unused imports
j-paterson Oct 23, 2025
5838596
restore home page config:
j-paterson Oct 23, 2025
f6ac17c
cleanup
j-paterson Oct 23, 2025
b857728
Close mobile nav after search selection
willyogo Oct 28, 2025
bdd3b08
Add mini app metadata and thumbnail for channel spaces
willyogo Oct 22, 2025
c036f65
Refactor ChannelCard component to ensure consistent flex display for …
sktbrd Oct 23, 2025
89678ae
Fix ImageResponse display flex requirements for channel metadata API
sktbrd Oct 23, 2025
4f9992f
Fix edge runtime compatibility and improve validation in channel meta…
sktbrd Oct 28, 2025
34d061c
Add Top 8 Farcaster friends iframe fidget (#1472)
willyogo Oct 30, 2025
302de59
Update sitemap to reflect current homepage tabs (#1500)
willyogo Oct 30, 2025
37adb29
build(deps-dev): bump @types/node from 24.0.10 to 24.9.1 (#1506)
dependabot[bot] Oct 30, 2025
70e76a8
build(deps): bump @internationalized/date from 3.9.0 to 3.10.0 (#1495)
dependabot[bot] Oct 30, 2025
96d4b2a
build(deps): bump @radix-ui/react-dropdown-menu from 2.1.15 to 2.1.16…
dependabot[bot] Oct 30, 2025
da91be7
build(deps-dev): bump prettier from 3.3.1 to 3.6.2 (#1492)
dependabot[bot] Oct 30, 2025
5f78222
Ensure all token gates check for both nOGs and $SPACE and refresh gat…
willyogo Oct 30, 2025
aa3ebf7
clanker
j-paterson Oct 30, 2025
0e00088
updated to accept clanker as config var
j-paterson Oct 30, 2025
b18f6f6
stricter typing
j-paterson Oct 30, 2025
1b7ea74
better typing across space types
j-paterson Oct 30, 2025
8a24f0d
standardize home page
j-paterson Oct 30, 2025
c356467
assets added
j-paterson Oct 30, 2025
c4ecf8e
update png to jpg
j-paterson Oct 30, 2025
2fd6811
signature fix
j-paterson Oct 30, 2025
6cf09f1
type matching for homebases
j-paterson Oct 30, 2025
6aa0c3b
type fixes in configs
j-paterson Oct 30, 2025
46e9e08
isEditable
j-paterson Oct 30, 2025
5b10eee
dynamic redirect
j-paterson Oct 30, 2025
e94188e
page loads
j-paterson Oct 30, 2025
4c2d83b
updated header
j-paterson Oct 30, 2025
ec7207b
logo size fixed
j-paterson Oct 30, 2025
56b09ee
gathered assets for nouns config
j-paterson Oct 30, 2025
21dc023
version update
j-paterson Oct 30, 2025
4982376
initial navs
j-paterson Oct 30, 2025
99b96f3
working navigation
j-paterson Oct 30, 2025
b897325
type error fix
j-paterson Oct 30, 2025
be6025c
removed hard coded sections of nav
j-paterson Oct 30, 2025
12605af
Normalize space handles for case-insensitive lookups
willyogo Nov 5, 2025
9e55496
Allow Fullstory in CSP and document analytics usage
willyogo Nov 3, 2025
0d9fe5c
build(deps): bump react-stately from 3.39.0 to 3.42.0
dependabot[bot] Nov 3, 2025
59bb7db
build(deps): bump viem from 2.35.1 to 2.38.6
dependabot[bot] Nov 3, 2025
f3d08cd
build(deps-dev): bump vitest from 1.6.1 to 4.0.6
dependabot[bot] Nov 3, 2025
0a1e5fa
build(deps): bump isomorphic-dompurify from 2.28.0 to 2.31.0 (#1527)
dependabot[bot] Nov 6, 2025
41bc2b9
Add mini app tags to brand configs and manifest (#1519)
willyogo Nov 6, 2025
bd6752b
Adjust Top 8 fidget defaults (#1520)
willyogo Nov 6, 2025
1dbd27b
build(deps): bump wagmi from 2.16.3 to 2.19.2 (#1528)
dependabot[bot] Nov 6, 2025
eb5cfed
refactor: remove TabNavigation, integrate MobileNavbar (#1523)
Jhonattan2121 Nov 6, 2025
a378772
Add Luma fidget for Luma embeds (#1535)
willyogo Nov 6, 2025
46b924e
build(deps-dev): bump lint-staged from 15.5.2 to 16.2.6 (#1549)
dependabot[bot] Nov 13, 2025
ff2d004
build(deps): bump @googleapis/youtube from 18.0.0 to 29.0.0 (#1548)
dependabot[bot] Nov 13, 2025
c8b5b33
build(deps): bump @cloudflare/workers-types from 4.20251011.0 to 4.20…
dependabot[bot] Nov 13, 2025
d4a2452
Add Clanker token search results to token API (#1546)
willyogo Nov 13, 2025
e3e7f05
Update token directory API and tests (#1558)
willyogo Nov 13, 2025
ddcc8ef
Update Clanker home tabs to Clank, Social, and Docs and apply baselin…
willyogo Nov 13, 2025
1d08bc9
Add owner address handling to chat fidget (#1537)
willyogo Nov 13, 2025
69a5856
feat: HTML/CSS prompt reimplemented (PR #1486) (#1516)
Jhonattan2121 Nov 16, 2025
006cc01
Add confirmation overlay when dismissing cast modal (#1512)
willyogo Nov 16, 2025
91b6ee2
YouTube Embed Improvements (#1552)
Jhonattan2121 Nov 16, 2025
47a9fcf
opengraph fix revert
j-paterson Nov 17, 2025
d267c09
feat(zora): normalize Zora URLs to /coin and improve embed UI
Jhonattan2121 Nov 16, 2025
4c7fac4
chore(zora): apply review fixes (router match, parser cleanup, access…
Jhonattan2121 Nov 16, 2025
cf911dd
fix: avoid unnecessary reloads for iframe embeds
willyogo Nov 6, 2025
792a270
Fix web embed iframe hook order
willyogo Nov 16, 2025
9ef096f
Stabilize web embed script rendering
willyogo Nov 17, 2025
a0f1177
Refactor CastRow: improve embed logic (#1542)
Jhonattan2121 Nov 17, 2025
30bbf1c
Add Clanker Manager fidget (#1538)
willyogo Nov 17, 2025
a8de847
Handle settlement fetch reverts without logging noise (#1540)
willyogo Nov 17, 2025
91928cf
feat: make brand tooltip configurable (#1543)
willyogo Nov 17, 2025
a53acc8
Add follow controls to directory fidget (#1563)
willyogo Nov 17, 2025
95cfb18
Implement dynamic Explore page directory(s) for all space systems & r…
willyogo Nov 17, 2025
3a94dc6
Update channel tab name for dynamic explore page (#1568)
willyogo Nov 17, 2025
e47c96f
first stab at adding userWallet aware clanker manager to homebase for…
j-paterson Nov 18, 2025
e1532e5
ui fixes (#1573)
j-paterson Nov 18, 2025
9bfc2db
Clanker mods2 (#1574)
j-paterson Nov 18, 2025
9e2cd23
remove explore
j-paterson Nov 18, 2025
005e71e
Add Empire Builder token fidget (#1579)
willyogo Nov 19, 2025
1155a2d
Handle empty contract address in Levr fidget (#1578)
willyogo Nov 19, 2025
75e3160
Add explore tabs configuration and directory data utilities (#1575)
willyogo Nov 19, 2025
aa90d02
add UI colors configuration for cast button styles across systems (#1…
sktbrd Nov 19, 2025
3656019
initial profile space for clanker
j-paterson Nov 19, 2025
ff414bf
3 cols
j-paterson Nov 19, 2025
0d002b0
Spotify Embed Cleanup (#1560)
Jhonattan2121 Nov 19, 2025
58e7d86
Clanker fidget section (#1581)
j-paterson Nov 19, 2025
437c3f6
Add Nounish Auctions fidget
willyogo Nov 27, 2025
c570f6c
Removed Lens (#1594)
j-paterson Nov 28, 2025
0df6b90
Merge remote-tracking branch 'origin/canary' into codex/create-auctio…
willyogo Nov 28, 2025
55c0194
Improve NounishAuctions layout and simplify state management
willyogo Dec 1, 2025
20f08ca
Improve auction fidget UI
willyogo Dec 3, 2025
30e5932
Revert "Improve auction fidget UI"
willyogo Dec 3, 2025
c517d85
Improve auction fidget UI
willyogo Dec 3, 2025
d81deba
fix lint error
willyogo Dec 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ APP_MNEMONIC = ''
NEYNAR_API_KEY = ''
SUPABASE_SERVICE_KEY = ''
YOUTUBE_API_KEY = ''
MORALIS_API_KEY = ''

# These are specific to the environment
# and so need to be configured locally
Expand All @@ -47,6 +48,8 @@ NEXT_PUBLIC_SUPABASE_URL = ''
NEXT_PUBLIC_SUPABASE_ANON_KEY = ''
NEXT_PUBLIC_PRIVY_API_KEY = ''
NEXT_PUBLIC_ALCHEMY_API_KEY = '' # Also used for the Nouns Home fidget RPC fallback
# Optional: used for Directory fidget (ERC20 + NFT holders)
NEXT_PUBLIC_MORALIS_API_KEY = ''

# Nouns Home fidget (optional overrides)
# NOUNS_RPC_URL = ''
Expand Down
260 changes: 260 additions & 0 deletions BRANCH_ANALYSIS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
# Branch Analysis: `codex/update-token-directory-api` vs `canary`

## Summary
- **Total Changes**: 38 files changed, 6,236 insertions(+), 31 deletions(-)
- **Main Feature**: New Token Directory fidget with API endpoint for displaying token/NFT holders, Farcaster channel members, and CSV-uploaded directories

---

## Itemized Changes

### 1. Core Feature Files

#### 1.1 New Directory Fidget Component
- **File**: `src/fidgets/token/Directory.tsx`
- **Size**: 2,373 lines (new file)
- **Purpose**: Main React component for displaying directory of token holders, Farcaster channel members, or CSV-uploaded users
- **Key Features**:
- Three data sources: token holders, Farcaster channels, CSV uploads
- Two layout styles: cards and list
- Multiple sort options (token holdings, followers)
- Pagination
- Real-time data fetching with debouncing
- Settings backfill from `lastFetchSettings`

#### 1.2 New API Endpoint
- **File**: `src/pages/api/token/directory.ts`
- **Size**: 1,105 lines (new file)
- **Purpose**: Server-side API for fetching token holder data
- **Key Features**:
- Supports ERC20 tokens and NFTs
- Multiple networks: Base, Polygon, Ethereum Mainnet
- Integrates with Moralis and Alchemy APIs
- Fetches ENS metadata
- Enriches with Neynar profile data
- Aggregates holders by FID

### 2. Supporting Utility Modules

#### 2.1 Data Transformation
- **File**: `src/common/data/api/token/transform.ts` (316 lines)
- **Purpose**: Transforms raw holder data into directory member format
- **Functions**: `transformAndAggregate`, `extractNeynarProfileData`, `extractPrimaryAddress`

#### 2.2 Type Definitions
- **File**: `src/common/data/api/token/types.ts` (113 lines)
- **Purpose**: Centralized TypeScript types for directory API

#### 2.3 Utility Functions
- **File**: `src/common/data/api/token/utils.ts` (137 lines)
- **Purpose**: Helper functions (address normalization, balance parsing, social record parsing)

#### 2.4 ENS Enrichment
- **File**: `src/common/data/api/token/enrichEns.ts` (153 lines)
- **Purpose**: Fetches ENS metadata using Enstate.rs and wagmi

#### 2.5 Neynar Enrichment
- **File**: `src/common/data/api/token/enrichNeynar.ts` (68 lines)
- **Purpose**: Fetches Farcaster profile data via Neynar API

#### 2.6 Moralis Integration
- **File**: `src/common/data/api/token/fetchMoralis.ts` (121 lines)
- **Purpose**: Fetches ERC20 token holders from Moralis API

#### 2.7 Dependency Injection
- **File**: `src/common/data/api/token/dependencies.ts` (39 lines)
- **Purpose**: Provides dependency injection for testing

### 3. Infrastructure Changes

#### 3.1 FidgetWrapper Enhancement
- **File**: `src/common/fidgets/FidgetWrapper.tsx` (+99 lines, -31 lines)
- **Changes**: Added settings backfill logic using `lastFetchSettings` from fidget data
- **Purpose**: Automatically populates empty settings from previous fetch configuration

#### 3.2 New API Endpoints
- **File**: `src/pages/api/farcaster/neynar/bulk-address.ts` (34 lines)
- **Purpose**: Bulk Farcaster user lookup by Ethereum addresses

### 4. Documentation

#### 4.1 API Cleanup Opportunities
- **File**: `docs/API_CLEANUP_OPPORTUNITIES.md` (569 lines)
- **Purpose**: Documents potential API simplifications

#### 4.2 Data Field Patterns
- **File**: `docs/SYSTEMS/FIDGETS/DATA_FIELD_PATTERNS.md` (625 lines)
- **Purpose**: Documents fidget data field patterns

### 5. Minor Updates
- Updated various components to support new Directory fidget
- Added SVG icons (ens.svg, etherscan.svg, github.svg)
- Updated package.json dependencies
- Added environment variable examples

---

## Areas of Unnecessary Complexity

### 🔴 Critical Issues

#### 1. **Massive Single File: Directory.tsx (2,373 lines)**
- **Problem**: One component file contains:
- Component logic (45+ React hooks)
- Data fetching logic (3 different sources)
- CSV parsing logic
- Data transformation logic
- UI rendering (cards + list views)
- Helper functions (duplicated from API)
- **Impact**: Extremely difficult to maintain, test, and understand
- **Recommendation**: Split into:
- `Directory.tsx` (main component, ~200 lines)
- `useDirectoryData.ts` (data fetching hook)
- `useCsvParser.ts` (CSV parsing logic)
- `DirectoryCardView.tsx` (card layout)
- `DirectoryListView.tsx` (list layout)
- `directoryUtils.ts` (shared utilities)

#### 2. **Duplicate Logic Between Component and API**
- **Problem**: Functions duplicated in both files:
- `parseSocialRecord` (exists in both Directory.tsx and API/utils.ts)
- `extractNeynarPrimaryAddress` (exists in both Directory.tsx and transform.ts)
- `extractNeynarSocialAccounts` (exists in both Directory.tsx and transform.ts)
- `normalizeAddress` (exists in both, though API version is exported)
- **Impact**: Code duplication, maintenance burden, potential inconsistencies
- **Recommendation**: Move all shared utilities to `src/common/data/api/token/utils.ts` and import

#### 3. **Complex State Management in Component**
- **Problem**: Component uses 45+ React hooks (useState, useEffect, useCallback, useMemo, useRef)
- **Specific Issues**:
- Multiple interdependent useEffects
- Complex dependency arrays
- State synchronization logic scattered throughout
- AbortController management mixed with data fetching
- **Impact**: Difficult to debug, potential race conditions, performance issues
- **Recommendation**: Extract to custom hooks:
- `useDirectoryFetch.ts` (handles all fetching logic)
- `useDirectoryState.ts` (manages local UI state)
- `useDirectoryPagination.ts` (handles pagination)

#### 4. **API Endpoint Too Large (1,105 lines)**
- **Problem**: Single API handler contains:
- Multiple data source fetchers (Moralis, Alchemy)
- ENS enrichment logic
- Neynar enrichment logic
- Data transformation
- Error handling
- **Impact**: Hard to test individual pieces, difficult to maintain
- **Recommendation**: Already partially modularized, but could further split:
- Keep main handler thin (~100 lines)
- Move fetchers to separate modules (already done)
- Create orchestration layer

### 🟡 Moderate Issues

#### 5. **Overly Complex CSV Parsing**
- **Problem**: CSV parsing logic embedded in component (~200 lines)
- **Issues**:
- Header detection logic
- Multiple type handling (address, fid, username)
- Fallback parsing logic
- Inline chunking utilities
- **Recommendation**: Extract to `src/common/data/api/token/csvParser.ts`

#### 6. **Settings Backfill Logic in FidgetWrapper**
- **Problem**: Generic backfill logic added to FidgetWrapper (~70 lines)
- **Issues**:
- Uses `isEqual` from lodash for deep comparison
- Complex serialization/deserialization logic
- May affect all fidgets, not just Directory
- **Impact**: Could cause unexpected behavior in other fidgets
- **Recommendation**: Move to Directory-specific hook or make opt-in

#### 7. **Multiple Data Source Handling**
- **Problem**: Three completely different data sources handled in one component
- **Issues**:
- Different fetch functions for each source
- Different data transformation logic
- Different error handling
- **Recommendation**: Create abstraction layer:
- `DirectoryDataSource` interface
- `TokenHoldersSource`, `FarcasterChannelSource`, `CsvSource` implementations
- Unified `fetchDirectoryData` function

#### 8. **Complex Data Enrichment Pipeline**
- **Problem**: Multiple enrichment steps with conditional logic
- **Issues**:
- ENS enrichment (Enstate.rs + wagmi fallback)
- Neynar enrichment (batched lookups)
- Social account extraction
- Primary address resolution
- **Recommendation**: Create enrichment pipeline:
- `EnrichmentPipeline` class
- Individual enrichment steps as plugins
- Configurable enrichment options

### 🟢 Minor Issues

#### 9. **Type Safety Issues**
- **Problem**: Extensive use of `any` types in CSV parsing and Neynar response handling
- **Recommendation**: Add proper types for all API responses

#### 10. **Hardcoded Constants**
- **Problem**: Magic numbers and strings scattered throughout:
- `PAGE_SIZE = 100`
- `CHANNEL_FETCH_DEBOUNCE_MS = 800`
- `STALE_AFTER_MS = 60 * 60 * 1000`
- Batch sizes (25, 50, 100)
- **Recommendation**: Move to config file or constants module

#### 11. **Error Handling Inconsistency**
- **Problem**: Different error handling patterns:
- Some functions throw errors
- Some return empty objects/arrays
- Some log and continue
- **Recommendation**: Standardize error handling strategy

#### 12. **Excessive Console Logging**
- **Problem**: Many `console.log` statements throughout code
- **Recommendation**: Use proper logging library or remove debug logs

---

## Recommendations Summary

### Immediate Actions (High Priority)
1. **Split Directory.tsx** into smaller, focused modules
2. **Remove duplicate code** between component and API
3. **Extract data fetching** to custom hooks
4. **Create data source abstraction** for the three sources

### Short-term Improvements (Medium Priority)
5. Extract CSV parsing to separate module
6. Simplify FidgetWrapper backfill logic (make opt-in)
7. Standardize error handling
8. Add proper TypeScript types

### Long-term Refactoring (Low Priority)
9. Create enrichment pipeline abstraction
10. Move constants to config
11. Implement proper logging
12. Add comprehensive unit tests

---

## Code Metrics

- **Directory.tsx**: 2,373 lines, ~179 functions/components
- **API endpoint**: 1,105 lines, ~70 functions
- **Total new code**: ~6,200 lines
- **React hooks in Directory**: 45+ (useState, useEffect, useCallback, useMemo, useRef)
- **Duplicate functions**: ~5 major functions duplicated between component and API

---

## Testing Coverage

- **Test file**: `tests/tokenDirectory.api.test.ts` (359 lines)
- **Coverage**: API endpoint tests present
- **Missing**: Component tests, integration tests, CSV parsing tests

Loading