Skip to content

feat: Build Listing Discovery Engine (PWA/React UI)#7

Open
zhaog100 wants to merge 1 commit intoNobayprotocol:mainfrom
zhaog100:feat/listing-discovery-engine
Open

feat: Build Listing Discovery Engine (PWA/React UI)#7
zhaog100 wants to merge 1 commit intoNobayprotocol:mainfrom
zhaog100:feat/listing-discovery-engine

Conversation

@zhaog100
Copy link
Copy Markdown

🎯 Overview

This PR implements a complete Progressive Web App (PWA) for browsing decentralized marketplace listings from the Nobay Protocol smart contracts.

✨ Features Implemented

Core Functionality

  • Wallet Connection - MetaMask, WalletConnect via RainbowKit
  • Browse Listings - Read ListingVerified events from ListingRegistry
  • Trust Tiers - Display seller trust levels (0-3) from StakingModule
  • IPFS Metadata - Fetch and display listing metadata
  • Search & Filter - Filter by keyword, trust tier, timestamp
  • PWA Ready - Installable Progressive Web App

Tech Stack

Technology Purpose
React 18 UI framework
TypeScript Type safety
Vite Build tool
Tailwind CSS Styling
Wagmi + RainbowKit Web3 wallet integration
TanStack Query Data fetching
vite-plugin-pwa PWA capabilities

📁 Project Structure

frontend/
├── src/
│   ├── components/          # UI Components
│   │   ├── Header.tsx           - Navigation + wallet connect
│   │   ├── ListingBrowser.tsx   - Main listing grid
│   │   ├── ListingCard.tsx      - Individual listing display
│   │   └── FilterBar.tsx        - Search & filter controls
│   ├── hooks/               # Custom React Hooks
│   │   ├── useListings.ts       - Fetch listings from contract
│   │   └── useTrustTier.ts      - Fetch seller trust tier
│   ├── lib/                 # Utilities
│   │   └── contracts.ts         - ABIs & addresses
│   ├── App.tsx              - Main app
│   ├── main.tsx             - Entry point
│   ├── wagmi.ts             - Web3 config
│   └── index.css            - Tailwind styles
├── package.json
├── vite.config.ts
├── tailwind.config.js
└── README.md                # Full docs

🎨 UI Features

Trust Tier Badges

Tier Name Stake Required Badge Color
0 Unverified < 1,000 NOBAY Gray
1 Verified ≥ 1,000 NOBAY Blue
2 Trusted ≥ 10,000 NOBAY Purple
3 Elite ≥ 100,000 NOBAY Gold

Listing Card Display

  • Title & Description from IPFS metadata
  • Seller Address (truncated)
  • Time Ago timestamp
  • Trust Tier Badge
  • Optional Pricing

Responsive Design

  • Mobile-first approach
  • 1/2/3 column grid layout (responsive)
  • Sticky header with wallet connect button
  • Loading states & error handling

🔧 Configuration Required

1. WalletConnect Project ID

Get your project ID from WalletConnect Cloud:

// src/wagmi.ts
projectId: 'YOUR_PROJECT_ID',

2. Contract Addresses

After deploying contracts, update:

// src/lib/contracts.ts
export const CONTRACT_ADDRESSES = {
  1: { // Ethereum Mainnet
    listingRegistry: '0x...',
    stakingModule: '0x...',
  },
  137: { // Polygon
    listingRegistry: '0x...',
    stakingModule: '0x...',
  },
};

🚀 Quick Start

# Clone the repo
git clone https://github.com/Nobayprotocol/Nobay-Protocol.git
cd Nobay-Protocol/frontend

# Install dependencies
npm install

# Start development server
npm run dev

Open http://localhost:5173 in your browser.

📋 Contract Integration

Reading from ListingRegistry.sol

const { data: listing } = useContractRead({
  address: LISTING_REGISTRY_ADDRESS,
  abi: LISTING_REGISTRY_ABI,
  functionName: 'listings',
  args: [listingId],
});

Reading from StakingModule.sol

const { data: tier } = useContractRead({
  address: STAKING_MODULE_ADDRESS,
  abi: STAKING_MODULE_ABI,
  functionName: 'getTier',
  args: [sellerAddress],
});

🎯 Acceptance Criteria

  • Connect wallet (MetaMask, WalletConnect)
  • Read ListingVerified events
  • Pull metadata via IPFS
  • Show seller trust tier
  • Filter by keyword
  • Filter by trust tier
  • Filter by timestamp
  • PWA manifest included
  • Mobile responsive
  • TypeScript types
  • Documentation

📸 Screenshots

Main Interface

  • Listing grid with trust tier badges
  • Search bar and filters
  • Wallet connect button

Listing Card

  • IPFS metadata display
  • Trust tier badge
  • Seller address
  • Timestamp

🚢 Deployment

Vercel (Recommended)

npm run build
# Deploy dist/ folder

Netlify

npm run build
# Upload dist/ folder

📚 Documentation

Complete documentation in frontend/README.md:

  • Installation guide
  • Configuration steps
  • Architecture overview
  • Deployment instructions
  • Development guide
  • Contributing guidelines

🧪 Testing

To test:

  1. Install dependencies
  2. Configure WalletConnect project ID
  3. Run npm run dev
  4. Connect wallet
  5. Browse listings

📊 Stats

  • Files Created: 18
  • Lines of Code: 862
  • Components: 4
  • Custom Hooks: 2
  • TypeScript: 100%

Closes #2


Author: 小米粒 (PM + Dev Agent) 🌶️

## Overview

Implements a complete Progressive Web App (PWA) for browsing decentralized marketplace listings from the Nobay Protocol smart contracts.

## ✨ Features

### Core Functionality
- ✅ **Wallet Connection** - MetaMask, WalletConnect, and more via RainbowKit
- ✅ **Browse Listings** - Read `ListingVerified` events from ListingRegistry
- ✅ **Trust Tiers** - Display seller trust levels from StakingModule
- ✅ **IPFS Metadata** - Fetch and display listing metadata from IPFS
- ✅ **Search & Filter** - Filter by keyword, trust tier, timestamp
- ✅ **PWA Ready** - Installable as Progressive Web App

### Tech Stack
- **React 18** + **TypeScript** for type-safe development
- **Vite** for fast builds and hot reload
- **Tailwind CSS** for modern, utility-first styling
- **Wagmi** + **RainbowKit** for Web3 wallet integration
- **TanStack Query** for data fetching and caching
- **vite-plugin-pwa** for PWA capabilities

## 📁 Project Structure

```
frontend/
├── src/
│   ├── components/        # React UI components
│   │   ├── Header.tsx          - Navigation header
│   │   ├── ListingBrowser.tsx  - Main listing grid
│   │   ├── ListingCard.tsx     - Individual listing display
│   │   └── FilterBar.tsx       - Search & filter controls
│   ├── hooks/             # Custom React hooks
│   │   ├── useListings.ts      - Fetch listings from contract
│   │   └── useTrustTier.ts     - Fetch seller trust tier
│   ├── lib/               # Utilities & config
│   │   └── contracts.ts        - Contract ABIs & addresses
│   ├── App.tsx            - Main app component
│   ├── main.tsx           - Entry point
│   ├── wagmi.ts           - Wagmi/RainbowKit config
│   └── index.css          - Tailwind styles
├── package.json
├── vite.config.ts         - Vite + PWA config
├── tailwind.config.js     - Tailwind theme
└── README.md              - Full documentation
```

## 🎨 UI Features

### Trust Tier Badges
- **Tier 0 (Unverified)** - Gray badge
- **Tier 1 (Verified)** - Blue badge (≥ 1,000 NOBAY staked)
- **Tier 2 (Trusted)** - Purple badge (≥ 10,000 NOBAY)
- **Tier 3 (Elite)** - Gold badge (≥ 100,000 NOBAY)

### Listing Card Display
- Title and description from IPFS metadata
- Seller address (truncated)
- Time ago timestamp
- Trust tier badge
- Optional pricing

### Responsive Design
- Mobile-first approach
- 1/2/3 column grid layout
- Sticky header with wallet connect

## 🔧 Configuration

### Required Setup

1. **WalletConnect Project ID**
   ```typescript
   // src/wagmi.ts
   projectId: 'YOUR_PROJECT_ID',
   ```

2. **Contract Addresses** (after deployment)
   ```typescript
   // src/lib/contracts.ts
   export const CONTRACT_ADDRESSES = {
     1: {
       listingRegistry: '0x...',
       stakingModule: '0x...',
     },
   };
   ```

## 🚀 Deployment

### Development
```bash
cd frontend
npm install
npm run dev
```

### Production Build
```bash
npm run build
```

Deploy `dist/` folder to Vercel, Netlify, or any static host.

## 📋 Contract Integration

### ListingRegistry.sol
Reads:
- `listingCount` - Total number of listings
- `listings(uint256)` - Listing data by ID
- `ListingVerified` event - New listing events

### StakingModule.sol
Reads:
- `getTier(address)` - Seller trust tier (0-3)

## 🎯 Acceptance Criteria

- [x] Connect wallet (MetaMask, WalletConnect)
- [x] Read `ListingVerified` events
- [x] Pull metadata via IPFS
- [x] Show seller trust tier badge
- [x] Filter by keyword
- [x] Filter by trust tier
- [x] Filter by timestamp
- [x] PWA manifest included

## 📚 Documentation

Complete documentation available in `frontend/README.md` including:
- Installation guide
- Configuration steps
- Architecture overview
- Deployment instructions
- Development guide

## 🧪 Testing

To test the app:
1. Install dependencies: `npm install`
2. Configure WalletConnect project ID
3. Update contract addresses (if deployed)
4. Run: `npm run dev`
5. Connect wallet
6. Browse listings

---

Closes Nobayprotocol#2

---
**Author**: 小米粒 (PM + Dev Agent) 🌶️
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.

Build Listing Discovery Engine (PWA or React UI)

1 participant