NFT marketplace application with collection browsing and filtering capabilities.
Implementing metadata-based filtering for NFT collections to help users find tokens by traits.
- Frontend: React 18, TypeScript
- State: Zustand
- UI: @cartridge/ui components
- Routing: React Router v6
- Performance: @tanstack/react-virtual
useMarketTokensFetcher: Fetches NFT tokens with incremental loadinguseMetadataFilters(new): Manages metadata filtering logic- Pattern: Custom hooks for business logic
- Zustand stores for global state
- URL params for shareable state
- Pattern: Separate stores by domain
client/src/components/items/index.tsx: Main NFT display componentclient/src/components/filters/index.tsx: Filter UI (DO NOT MODIFY)- Pattern: Container/presentational separation
- Extract during token fetch in
batchProcessTokens - Build index incrementally as tokens load
- Schema:
{ [trait]: { [value]: [token_ids[]] } }
- AND between different traits
- OR within same trait values
- Persist state in URL params
- Virtual scrolling for large lists
- Memoize filter computations
- Batch state updates
- ✅ Implemented metadata filtering for NFT collections
- ✅ Created metadata indexer utilities with trait-value-tokenId mapping
- ✅ Added Zustand store for filter state management
- ✅ Built useMetadataFilters hook with URL persistence
- ✅ Integrated filtering into marketplace-tokens-fetcher
- ✅ Updated Items component with filter indicators
- ✅ Added comprehensive test coverage including edge cases and performance tests
- Builds index during token fetch in
batchProcessTokens - Schema:
{ [trait]: { [value]: [token_ids[]] } } - Handles edge cases: null metadata, special characters, duplicates
- AND logic between different traits
- OR logic within same trait values
- URL persistence format:
?filters=rarity:legendary,epic|background:gold
- Incremental index updates for streaming tokens
- Memoized filter calculations
- Virtual scrolling for large collections
- RequestIdleCallback for 1000+ tokens
- Contract tests for all utilities and hooks
- Integration tests for filter scenarios
- Edge case tests for malformed data
- Performance tests for 10k+ tokens
- Modify existing filter component (
client/src/components/filters/index.tsx) - Change core token fetching logic beyond metadata indexing
- Add unnecessary dependencies
- Run tests:
pnpm test - Check performance:
pnpm test:performance - Deploy and monitor for production usage
/review- Code review for PRs or staged files/cairo-check- Cairo contract analysis and security/ci-fix- Diagnose and fix CI failures/refactor- Analyze code for refactoring opportunities/test-gen- Generate tests for source files/create-pr- Create PR with conventional commits/update-pr- Respond to PR feedback/feature- Develop new features following patterns