Skip to content

Commit 4fa6238

Browse files
CopilotSteake
andauthored
SvelteKit block explorer with real RPC integration (#110)
* Initial plan * Add block explorer API endpoints and UI Co-authored-by: Steake <530040+Steake@users.noreply.github.com> * Add block explorer documentation and finalize implementation Co-authored-by: Steake <530040+Steake@users.noreply.github.com> * Fix SearchResult enum serialization for proper JavaScript interop Co-authored-by: Steake <530040+Steake@users.noreply.github.com> * Refactor to SvelteKit-based explorer with real RPC calls - Remove mock data API endpoints from bitcell-admin - Remove inline HTML/JS explorer - Create new SvelteKit application in crates/bitcell-explorer/ - Connect to real BitCell node RPC endpoints - No SSR, client-side only SPA - Proper input validation and XSS protection - Accessibility improvements (ARIA labels, keyboard nav) - Updated documentation Addresses code review comments: - Removed all mock/dummy data - Added hex validation for addresses and hashes - Fixed XSS vulnerabilities - Added proper accessibility features - Using modern web framework (Svelte, not React) Co-authored-by: Steake <530040+Steake@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Steake <530040+Steake@users.noreply.github.com>
1 parent 95ad25d commit 4fa6238

12 files changed

Lines changed: 1015 additions & 0 deletions

File tree

crates/bitcell-explorer/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Dependencies
2+
node_modules/
3+
4+
# Build output
5+
/build
6+
/.svelte-kit
7+
/package
8+
9+
# Environment
10+
.env
11+
.env.local
12+
.env.*.local
13+
14+
# Editor
15+
.vscode/
16+
.idea/
17+
*.swp
18+
*.swo
19+
*~
20+
21+
# OS
22+
.DS_Store
23+
Thumbs.db
24+
25+
# Logs
26+
*.log
27+
npm-debug.log*
28+
yarn-debug.log*
29+
yarn-error.log*

crates/bitcell-explorer/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# BitCell Block Explorer
2+
3+
A SvelteKit-based block explorer for the BitCell blockchain.
4+
5+
## Features
6+
7+
- Real-time block viewing
8+
- Transaction search and details
9+
- Account balance and transaction history
10+
- Tournament battle visualization
11+
- Trust score display (EBSL)
12+
- Universal search (block height, hash, tx hash, address)
13+
14+
## Development
15+
16+
```bash
17+
# Install dependencies
18+
npm install
19+
20+
# Run development server
21+
npm run dev
22+
23+
# Build for production
24+
npm run build
25+
```
26+
27+
## Configuration
28+
29+
The explorer connects to a BitCell node RPC endpoint. By default, it expects the node to be running on `localhost:9545`.
30+
31+
To change the RPC endpoint, edit `vite.config.js`:
32+
33+
```javascript
34+
server: {
35+
proxy: {
36+
'/rpc': {
37+
target: 'http://your-node:port',
38+
changeOrigin: true
39+
}
40+
}
41+
}
42+
```
43+
44+
## Architecture
45+
46+
- **No SSR**: This is a client-side only application (SPA)
47+
- **Real RPC calls**: All data comes from the BitCell node via JSON-RPC
48+
- **No mock data**: Every piece of information is fetched from the live blockchain
49+
50+
## API Integration
51+
52+
The explorer uses these RPC methods:
53+
54+
- `eth_blockNumber` - Get current block height
55+
- `eth_getBlockByNumber` - Get block details
56+
- `eth_getTransactionByHash` - Get transaction details
57+
- `eth_getBalance` - Get account balance
58+
- `eth_getTransactionCount` - Get account nonce
59+
- `bitcell_getNodeInfo` - Get node information
60+
- `bitcell_getTournamentState` - Get tournament state
61+
- `bitcell_getBattleReplay` - Get battle replay data
62+
- `bitcell_getMinerStats` - Get miner statistics
63+
64+
## Security
65+
66+
- All user input is validated and sanitized
67+
- XSS protection through proper escaping
68+
- ARIA labels for accessibility
69+
- Keyboard navigation support
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "bitcell-explorer",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "vite dev",
7+
"build": "vite build",
8+
"preview": "vite preview",
9+
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
10+
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./jsconfig.json --watch"
11+
},
12+
"devDependencies": {
13+
"@sveltejs/adapter-static": "^3.0.1",
14+
"@sveltejs/kit": "^2.0.0",
15+
"@sveltejs/vite-plugin-svelte": "^3.0.0",
16+
"svelte": "^4.2.7",
17+
"svelte-check": "^3.6.0",
18+
"typescript": "^5.0.0",
19+
"vite": "^5.0.3"
20+
},
21+
"type": "module"
22+
}

0 commit comments

Comments
 (0)