mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-02 12:53:10 +00:00
feat: npm
This commit is contained in:
parent
0102c107c3
commit
448a250cf6
69
packages/core/.npmignore
Normal file
69
packages/core/.npmignore
Normal file
@ -0,0 +1,69 @@
|
||||
# Source files
|
||||
src/
|
||||
tsconfig.json
|
||||
|
||||
# Development files
|
||||
*.test.ts
|
||||
*.test.js
|
||||
*.spec.ts
|
||||
*.spec.js
|
||||
__tests__/
|
||||
test/
|
||||
|
||||
# Build artifacts (keep dist/)
|
||||
*.tsbuildinfo
|
||||
|
||||
# Development dependencies
|
||||
node_modules/
|
||||
|
||||
# IDE files
|
||||
.vscode/
|
||||
.idea/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# Git
|
||||
.git/
|
||||
.gitignore
|
||||
|
||||
# Documentation (keep README.md)
|
||||
docs/
|
||||
*.md
|
||||
!README.md
|
||||
|
||||
# CI/CD
|
||||
.github/
|
||||
.gitlab-ci.yml
|
||||
.travis.yml
|
||||
.circleci/
|
||||
|
||||
# Linting
|
||||
.eslintrc*
|
||||
.prettierrc*
|
||||
.eslintignore
|
||||
.prettierignore
|
||||
|
||||
# Coverage
|
||||
coverage/
|
||||
.nyc_output/
|
||||
|
||||
# Temporary files
|
||||
tmp/
|
||||
temp/
|
||||
127
packages/core/README.md
Normal file
127
packages/core/README.md
Normal file
@ -0,0 +1,127 @@
|
||||
# @opchan/core
|
||||
|
||||
Core package for OpChan - A decentralized forum built on Bitcoin Ordinals and Waku protocol.
|
||||
|
||||
## Features
|
||||
|
||||
- **Waku Integration**: Complete Waku protocol implementation for decentralized messaging
|
||||
- **Bitcoin/Ethereum Wallet Support**: Multi-chain wallet integration with Reown AppKit
|
||||
- **Forum Operations**: Cell creation, posts, comments, and voting system
|
||||
- **Relevance Scoring**: Sophisticated algorithm for content ranking
|
||||
- **Moderation System**: Cell-based moderation capabilities
|
||||
- **Key Delegation**: Browser key generation for improved UX
|
||||
- **Local Storage**: IndexedDB integration for offline-first experience
|
||||
- **TypeScript**: Full TypeScript support with comprehensive type definitions
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @opchan/core
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Basic Setup
|
||||
|
||||
```typescript
|
||||
import { WakuNodeManager, ForumActions, LocalDatabase } from '@opchan/core';
|
||||
|
||||
// Initialize Waku node
|
||||
const wakuManager = new WakuNodeManager();
|
||||
await wakuManager.initialize();
|
||||
|
||||
// Initialize local database
|
||||
const db = new LocalDatabase();
|
||||
await db.initialize();
|
||||
|
||||
// Create forum actions
|
||||
const forumActions = new ForumActions(wakuManager, db);
|
||||
```
|
||||
|
||||
### Creating a Cell
|
||||
|
||||
```typescript
|
||||
import { ForumActions } from '@opchan/core';
|
||||
|
||||
const cell = await forumActions.createCell(
|
||||
'My Cell',
|
||||
'Description of my cell',
|
||||
'https://example.com/icon.png' // optional
|
||||
);
|
||||
```
|
||||
|
||||
### Creating Posts and Comments
|
||||
|
||||
```typescript
|
||||
// Create a post
|
||||
const post = await forumActions.createPost(
|
||||
cellId,
|
||||
'Post Title',
|
||||
'Post content here'
|
||||
);
|
||||
|
||||
// Create a comment
|
||||
const comment = await forumActions.createComment(
|
||||
postId,
|
||||
'Comment content here'
|
||||
);
|
||||
```
|
||||
|
||||
### Voting System
|
||||
|
||||
```typescript
|
||||
// Vote on a post
|
||||
await forumActions.votePost(postId, true); // upvote
|
||||
await forumActions.votePost(postId, false); // downvote
|
||||
|
||||
// Vote on a comment
|
||||
await forumActions.voteComment(commentId, true);
|
||||
```
|
||||
|
||||
### Wallet Integration
|
||||
|
||||
```typescript
|
||||
import { createWalletConfig } from '@opchan/core/wallet';
|
||||
|
||||
const config = createWalletConfig({
|
||||
projectId: 'your-project-id',
|
||||
// ... other wallet configuration
|
||||
});
|
||||
```
|
||||
|
||||
## API Reference
|
||||
|
||||
### Core Classes
|
||||
|
||||
- **WakuNodeManager**: Manages Waku node lifecycle and connections
|
||||
- **ForumActions**: Handles all forum operations (create, vote, moderate)
|
||||
- **LocalDatabase**: IndexedDB wrapper for local data persistence
|
||||
- **RelevanceCalculator**: Calculates content relevance scores
|
||||
- **BookmarkService**: Manages user bookmarks
|
||||
- **UserIdentityService**: Handles user identity and verification
|
||||
|
||||
### Types
|
||||
|
||||
- **Cell**: Forum cell/board structure
|
||||
- **Post**: Forum post structure
|
||||
- **Comment**: Comment structure
|
||||
- **User**: User identity and verification status
|
||||
- **Vote**: Voting system types
|
||||
|
||||
## Requirements
|
||||
|
||||
- Node.js 18+
|
||||
- Modern browser with IndexedDB support
|
||||
- Bitcoin or Ethereum wallet (for posting)
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our repository.
|
||||
|
||||
## Support
|
||||
|
||||
For questions and support, please open an issue on our GitHub repository.
|
||||
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@opchan/core",
|
||||
"name": "opchan-core",
|
||||
"version": "1.0.0",
|
||||
"description": "Core package for opchan",
|
||||
"description": "Core package for OpChan - A decentralized forum built on Waku protocol",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.js",
|
||||
@ -13,8 +13,32 @@
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
"dist",
|
||||
"README.md"
|
||||
],
|
||||
"keywords": [
|
||||
"opchan",
|
||||
"waku",
|
||||
"bitcoin",
|
||||
"ordinals",
|
||||
"ethereum",
|
||||
"decentralized",
|
||||
"forum",
|
||||
"p2p",
|
||||
"blockchain",
|
||||
"cryptocurrency"
|
||||
],
|
||||
"author": "OpChan Team",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/waku-org/OpChan.git",
|
||||
"directory": "packages/core"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/waku-org/OpChan/issues"
|
||||
},
|
||||
"homepage": "https://github.com/waku-org/OpChan#readme",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"dev": "tsc --watch",
|
||||
@ -22,7 +46,9 @@
|
||||
"lint": "eslint src --ext .ts,.tsx",
|
||||
"lint:fix": "eslint src --ext .ts,.tsx --fix",
|
||||
"check": "tsc --noEmit && eslint src --ext .ts,.tsx && prettier --check src",
|
||||
"fix": "prettier --write src && eslint src --ext .ts,.tsx --fix"
|
||||
"fix": "prettier --write src && eslint src --ext .ts,.tsx --fix",
|
||||
"prepublishOnly": "npm run build",
|
||||
"prepack": "npm run build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user