Skip to content

Commit 42563df

Browse files
Copilot0xrinegade
andcommitted
Integrate openSVM ProgramMetadataEntry model with IDL storage
Co-authored-by: 0xrinegade <[email protected]>
1 parent f0b7e9d commit 42563df

File tree

6 files changed

+439
-79
lines changed

6 files changed

+439
-79
lines changed

NETLIFY.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,27 @@ The `netlify.toml` file configures:
9393

9494
Once Qdrant is initialized, IDLHub gains:
9595

96-
- **Semantic search** for protocols
97-
- **Similar protocol discovery**
96+
- **Semantic search** for programs and protocols
97+
- **Similar program discovery**
9898
- **Fast metadata queries**
99-
- **Search history tracking**
99+
- **Full IDL storage** within program metadata
100+
- **openSVM compatibility** - Uses the same ProgramMetadataEntry model
100101

101102
### Qdrant Collections
102103

103-
The following collections are created:
104+
The following collections are created (matching aldrin-labs/openSVM structure):
104105

105-
1. **idl_metadata** - Protocol metadata and information
106-
2. **protocol_search** - Optimized search index
107-
3. **user_searches** - User search history
108-
4. **idl_cache** - Cached IDL content
106+
1. **program_metadata** - Program metadata with full IDL objects (ProgramMetadataEntry model)
107+
2. **token_metadata** - Token metadata (for future expansion)
108+
3. **idl_cache** - Additional IDL caching layer
109+
110+
### openSVM Compatibility
111+
112+
IDLHub uses the same database model as aldrin-labs/openSVM:
113+
- **ProgramMetadataEntry** interface for all programs
114+
- IDL stored as part of program metadata (`idl` field)
115+
- Same collection names and structure
116+
- Compatible search and retrieval patterns
109117

110118
## Testing the Deployment
111119

lib/README.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# IDLHub Library
2+
3+
This directory contains shared utilities and type definitions for IDLHub, following the aldrin-labs/openSVM model for compatibility.
4+
5+
## Structure
6+
7+
```
8+
lib/
9+
├── qdrant.js # Qdrant database utilities
10+
├── types/ # TypeScript type definitions
11+
│ ├── program.ts # Program and IDL types (openSVM compatible)
12+
│ └── index.ts # Type exports
13+
└── README.md # This file
14+
```
15+
16+
## Qdrant Integration
17+
18+
### Collections
19+
20+
IDLHub uses the same collection structure as aldrin-labs/openSVM:
21+
22+
- **program_metadata** - Main collection storing programs with full IDL data
23+
- **token_metadata** - Token metadata (for future expansion)
24+
- **idl_cache** - Additional caching layer
25+
26+
### ProgramMetadataEntry Model
27+
28+
The core data model matches openSVM's `ProgramMetadataEntry`:
29+
30+
```typescript
31+
interface ProgramMetadataEntry {
32+
id: string; // Program ID
33+
programId: string; // Same as id
34+
name: string; // Program name
35+
description?: string; // Program description
36+
githubUrl?: string; // GitHub repository URL
37+
websiteUrl?: string; // Official website
38+
docsUrl?: string; // Documentation URL
39+
category?: string; // Category (defi, nft, etc.)
40+
idl?: any; // Full IDL JSON object
41+
verified: boolean; // Verification status
42+
cached: boolean; // Cache status
43+
lastUpdated: number; // Timestamp
44+
cacheExpiry: number; // Cache expiration
45+
tags?: string[]; // Tags for search
46+
}
47+
```
48+
49+
### Key Features
50+
51+
1. **IDL Storage** - IDLs are stored as part of program metadata in the `idl` field
52+
2. **Semantic Search** - Vector-based search for programs
53+
3. **Cache Management** - Automatic cache expiration and refresh
54+
4. **Batch Operations** - Efficient bulk storage and retrieval
55+
5. **openSVM Compatibility** - Uses identical data structures
56+
57+
## Usage
58+
59+
### Initialize Collections
60+
61+
```javascript
62+
const qdrant = require('./lib/qdrant');
63+
64+
await qdrant.initializeCollections();
65+
```
66+
67+
### Store Program Metadata
68+
69+
```javascript
70+
const protocol = {
71+
id: 'jupiter',
72+
name: 'Jupiter',
73+
description: 'Jupiter Aggregator',
74+
category: 'dex-aggregator',
75+
idlPath: 'IDLs/jupiterIDL.json',
76+
status: 'available',
77+
repo: 'https://github.com/jup-ag/jupiter-core'
78+
};
79+
80+
// Stores program with IDL automatically loaded
81+
await qdrant.storeProgramMetadata(protocol);
82+
```
83+
84+
### Search Programs
85+
86+
```javascript
87+
// Search by text query
88+
const results = await qdrant.searchPrograms('dex trading', 10);
89+
```
90+
91+
### Get Program by ID
92+
93+
```javascript
94+
const program = await qdrant.getProgramMetadata('jupiter');
95+
console.log(program.idl); // Full IDL object
96+
```
97+
98+
### Batch Operations
99+
100+
```javascript
101+
// Store multiple programs
102+
await qdrant.batchStorePrograms(protocols);
103+
104+
// Retrieve multiple programs
105+
const programs = await qdrant.batchGetProgramMetadata(['jupiter', 'orca']);
106+
```
107+
108+
## Type Definitions
109+
110+
TypeScript types are available in `lib/types/`:
111+
112+
```typescript
113+
import { ProgramMetadataEntry, IDL, IDLProtocol } from './lib/types';
114+
```
115+
116+
These types ensure compatibility with aldrin-labs/openSVM when integrating with shared databases.
117+
118+
## Environment Variables
119+
120+
```bash
121+
QDRANT_URL=http://localhost:6333 # Qdrant server URL
122+
QDRANT_API_KEY=your_api_key # Qdrant API key
123+
QDRANT_SERVER=http://localhost:6333 # Alternative (openSVM compatible)
124+
QDRANT=your_api_key # Alternative (openSVM compatible)
125+
```
126+
127+
## Compatibility
128+
129+
This implementation is designed to be compatible with aldrin-labs/openSVM:
130+
- Same collection names and structure
131+
- Identical ProgramMetadataEntry model
132+
- Compatible search patterns
133+
- Shared database can be used by both projects

0 commit comments

Comments
 (0)