Skip to content

Commit 70c7c7d

Browse files
authored
Merge pull request #70 from openSVM/copilot/fix-64
Add comprehensive API and smart contract documentation with versioning
2 parents 34ea86c + 72615ef commit 70c7c7d

File tree

14 files changed

+6517
-4197
lines changed

14 files changed

+6517
-4197
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,29 @@ A peer-to-peer cryptocurrency exchange platform for trading across Solana Virtua
5454
3. Run the development server: `npm run dev`
5555
4. Connect your wallet to start trading
5656

57+
## 📚 Documentation
58+
59+
### API Documentation
60+
Comprehensive API and smart contract documentation is available:
61+
62+
- **[Complete API Reference](docs/api/README.md)** - Main API documentation hub
63+
- **[Smart Contract API](docs/api/smart-contracts.md)** - Detailed smart contract instructions
64+
- **[Wallet Operations](docs/api/wallet-operations.md)** - Wallet integration patterns
65+
- **[Account Structures](docs/api/account-structures.md)** - Data structure specifications
66+
- **[Error Codes](docs/api/error-codes.md)** - Error handling reference
67+
- **[Transaction Flows](docs/api/transaction-flows.md)** - Implementation examples
68+
- **[API Changelog](docs/api/CHANGELOG.md)** - Version history and updates
69+
70+
### Quick Start Guides
71+
- **[Examples Directory](docs/api/examples/)** - Ready-to-use code examples
72+
- **[Installation Guide](docs/installation-guide.md)** - Detailed setup instructions
73+
- **[Contributing Guide](docs/contributing.md)** - Development workflow
74+
75+
### Developer Resources
76+
- **Program ID**: `FKkTQLgBE9vDZqgXKWrXZfAv5HgCQdsjDZDzPfJosPt9`
77+
- **Documentation Version**: 1.0.0
78+
- **API Support**: Full smart contract and wallet integration coverage
79+
5780
## Requirements
5881

5982
- Node.js >= 18.17.0 (required by Next.js 14)

docs/README.md

Lines changed: 52 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -224,95 +224,65 @@ The Solana program consists of several key components:
224224

225225
## API Reference
226226

227-
### Frontend Components API
228-
229-
#### NotificationContext
230-
```javascript
231-
// Import
232-
import { useNotifications } from './components/notifications/NotificationContext';
233-
234-
// Usage
235-
const {
236-
notifications,
237-
notifySuccess,
238-
notifyError,
239-
markAsRead,
240-
removeNotification
241-
} = useNotifications();
242-
243-
// Methods
244-
notifySuccess(title, message, options);
245-
notifyError(title, message, options);
246-
markAsRead(notificationId);
247-
removeNotification(notificationId);
248-
```
249-
250-
#### OfferCreation
251-
```javascript
252-
// Import
253-
import OfferCreation from './components/OfferCreation';
254-
255-
// Props
256-
<OfferCreation
257-
onSubmit={handleSubmit}
258-
initialValues={initialValues}
259-
isLoading={isLoading}
260-
/>
261-
```
262-
263-
#### UserProfile
264-
```javascript
265-
// Import
266-
import UserProfile from './components/UserProfile';
267-
268-
// Props
269-
<UserProfile
270-
userId={userId}
271-
isCurrentUser={isCurrentUser}
272-
/>
273-
```
274-
275-
### Smart Contract API
276-
277-
#### Creating an Offer
278-
```javascript
279-
// Import
280-
import { createOffer } from './api/solana';
281-
282-
// Usage
283-
const result = await createOffer({
284-
assetType: 'SOL',
285-
amount: 1.5,
286-
price: 100,
287-
paymentMethods: ['USDC', 'Bank Transfer'],
288-
terms: 'Payment must be completed within 30 minutes'
227+
### 📚 Comprehensive API Documentation
228+
229+
We provide extensive API documentation for developers integrating with SVMP2P:
230+
231+
#### **[Complete API Documentation Hub](api/README.md)**
232+
Central hub for all API documentation with version information and navigation.
233+
234+
#### Core API References
235+
- **[Smart Contract API](api/smart-contracts.md)** - Complete instruction reference with parameters, behaviors, and examples
236+
- **[Account Structures](api/account-structures.md)** - Detailed account specifications and TypeScript interfaces
237+
- **[Wallet Operations](api/wallet-operations.md)** - Wallet connection, transaction signing, and security patterns
238+
- **[Error Codes](api/error-codes.md)** - Complete error reference with recovery strategies
239+
- **[Events](api/events.md)** - Smart contract event monitoring and handling
240+
- **[Transaction Flows](api/transaction-flows.md)** - End-to-end implementation examples
241+
242+
#### Developer Resources
243+
- **[Code Examples](api/examples/)** - Ready-to-use TypeScript examples
244+
- **[API Changelog](api/CHANGELOG.md)** - Version history and migration guides
245+
- **Program ID**: `FKkTQLgBE9vDZqgXKWrXZfAv5HgCQdsjDZDzPfJosPt9`
246+
- **Current API Version**: 1.0.0
247+
248+
### Legacy Documentation
249+
- **[Basic Smart Contract API](smart-contract-api.md)** - Basic API overview (see comprehensive docs above)
250+
- **[Frontend Components](frontend-components.md)** - UI component documentation
251+
- **[Enhanced Reward System](enhanced-reward-system.md)** - Reward system details
252+
253+
### Quick Start Examples
254+
255+
#### Creating an Offer (TypeScript)
256+
```typescript
257+
import { Program, BN } from '@coral-xyz/anchor';
258+
import { createAndListOffer } from './api/examples/basic-trading/create-offer';
259+
260+
const result = await createAndListOffer(program, seller, {
261+
amount: new BN(1 * LAMPORTS_PER_SOL), // 1 SOL
262+
fiatAmount: new BN(50000), // $500.00 in cents
263+
currency: 'USD',
264+
paymentMethod: 'Bank transfer - Chase Bank'
289265
});
290266
```
291267

292-
#### Accepting an Offer
293-
```javascript
294-
// Import
295-
import { acceptOffer } from './api/solana';
268+
#### Wallet Connection
269+
```typescript
270+
import { useWallet } from '@solana/wallet-adapter-react';
296271

297-
// Usage
298-
const result = await acceptOffer({
299-
offerId: 'offer123',
300-
buyerWallet: 'buyer_wallet_address'
301-
});
302-
```
272+
const { connect, connected, publicKey } = useWallet();
303273

304-
#### Completing a Trade
305-
```javascript
306-
// Import
307-
import { completeTrade } from './api/solana';
308-
309-
// Usage
310-
const result = await completeTrade({
311-
tradeId: 'trade123',
312-
feedback: 'Smooth transaction, great trader!'
313-
});
274+
const handleConnect = async () => {
275+
try {
276+
await connect();
277+
console.log('Connected:', publicKey?.toString());
278+
} catch (error) {
279+
console.error('Connection failed:', error);
280+
}
281+
};
314282
```
315283

284+
For complete examples and advanced patterns, see the [examples directory](api/examples/).
285+
316286
## Troubleshooting
317287

318288
### Common Issues

0 commit comments

Comments
 (0)