Skip to content

Commit e7510a2

Browse files
committed
Initial commit
0 parents  commit e7510a2

108 files changed

Lines changed: 15789 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# WalletConnect Project ID (Reown)
2+
# Get your free project ID from: https://cloud.reown.com/
3+
# Note: WalletConnect is now Reown - same protocol, new name
4+
VITE_WALLETCONNECT_PROJECT_ID=your_project_id_here

.eslintrc.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"browser": true,
5+
"es2021": true,
6+
"node": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:@typescript-eslint/recommended",
11+
"plugin:vue/vue3-recommended",
12+
"@vue/typescript/recommended"
13+
],
14+
"parser": "vue-eslint-parser",
15+
"parserOptions": {
16+
"ecmaVersion": "latest",
17+
"parser": "@typescript-eslint/parser",
18+
"sourceType": "module"
19+
},
20+
"rules": {
21+
"vue/multi-word-component-names": "off"
22+
}
23+
}

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Deploy Web App
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: '20'
21+
22+
- name: Clean install dependencies
23+
run: |
24+
rm -rf node_modules package-lock.json
25+
npm install
26+
27+
- name: Build web app
28+
env:
29+
VITE_WALLETCONNECT_PROJECT_ID: ${{ secrets.VITE_WALLETCONNECT_PROJECT_ID }}
30+
run: npm run build:web
31+
32+
- name: Setup SSH
33+
run: |
34+
mkdir -p ~/.ssh
35+
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/deploy_key
36+
chmod 600 ~/.ssh/deploy_key
37+
ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
38+
39+
- name: Deploy to server
40+
run: |
41+
rsync -avz --delete \
42+
-e "ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=no" \
43+
apps/web/dist/ \
44+
${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEPLOY_PATH }}
45+
46+
- name: Cleanup
47+
if: always()
48+
run: rm -f ~/.ssh/deploy_key

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
dist
3+
dist-extension
4+
.DS_Store
5+
*.local
6+
.vscode
7+
.idea
8+
*.log
9+
.env

.prettierrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"trailingComma": "es5",
5+
"printWidth": 100,
6+
"tabWidth": 2
7+
}

README.md

Lines changed: 248 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
1+
# NoM Wallet Monorepo
2+
3+
A TypeScript Vue.js wallet that works as both a browser extension and a web app, built with npm workspaces.
4+
5+
## Project Structure
6+
7+
```
8+
nom-webwallet/
9+
├── packages/
10+
│ ├── types/ # Shared TypeScript types
11+
│ ├── core/ # Wallet logic, storage abstraction
12+
│ └── ui/ # Shared Vue components with shadcn-vue
13+
└── apps/
14+
├── extension/ # Browser extension (Manifest V3)
15+
└── web/ # Web app
16+
```
17+
18+
## Prerequisites
19+
20+
- Node.js 18+
21+
- npm 7+ (for workspace support)
22+
23+
## Getting Started
24+
25+
### 1. Install Dependencies
26+
27+
From the root directory:
28+
29+
```bash
30+
npm install
31+
```
32+
33+
This will install dependencies for all packages and apps in the workspace.
34+
35+
### 2. Run the Web App
36+
37+
```bash
38+
npm run dev:web
39+
```
40+
41+
The web app will be available at `http://localhost:5173`
42+
43+
### 3. Build the Extension
44+
45+
```bash
46+
npm run build:extension
47+
```
48+
49+
Or run in watch mode for development:
50+
51+
```bash
52+
npm run dev:extension
53+
```
54+
55+
### 4. Install the Extension Locally
56+
57+
1. Build the extension (see above)
58+
2. Open Chrome/Edge and navigate to `chrome://extensions/`
59+
3. Enable "Developer mode" (toggle in top right)
60+
4. Click "Load unpacked"
61+
5. Select the `apps/extension/dist-extension` directory
62+
6. The extension icon should appear in your toolbar
63+
64+
## Available Scripts
65+
66+
From the root directory:
67+
68+
- `npm run dev:web` - Start web app in development mode
69+
- `npm run dev:extension` - Build extension in watch mode
70+
- `npm run build:web` - Build web app for production
71+
- `npm run build:extension` - Build extension for production
72+
- `npm run build:all` - Build all apps
73+
- `npm run lint` - Run ESLint
74+
- `npm run format` - Format code with Prettier
75+
76+
## Package Overview
77+
78+
### @nom-wallet/types
79+
80+
Shared TypeScript types and interfaces used across all packages.
81+
82+
**Key exports:**
83+
- `Wallet` - Wallet data structure
84+
- `StorageAdapter` - Storage interface
85+
- `WalletStorage` - Storage data structure
86+
87+
### @nom-wallet/core
88+
89+
Core wallet functionality with full Zenon Network integration, storage abstraction, and WalletConnect support.
90+
91+
**Core Services:**
92+
93+
- **`WalletService`** - Complete wallet management (create, import, unlock, derive accounts, sign data)
94+
- **`SessionManager`** - Secure in-memory session management with auto-timeout (30min default)
95+
- **`ZenonService`** - Singleton Zenon SDK connection manager with auto-initialization
96+
- **`AccountService`** - Account balance, plasma info, unreceived blocks, delegation info
97+
- **`TransactionService`** - Send/receive transactions and embedded contract calls
98+
- **`PlasmaService`** - Fuse/cancel QSR for plasma generation
99+
- **`StakeService`** - Stake/cancel ZNN staking entries
100+
- **`RewardsService`** - Collect rewards from pillars, sentinels, stakes, and liquidity
101+
- **`PillarService`** - Pillar delegation, pillar list, total delegated ZNN
102+
- **`WalletConnectService`** - Full WalletConnect v2 integration for dApp connections
103+
104+
**Storage Adapters:**
105+
106+
- **`LocalStorageAdapter`** - Browser localStorage implementation (web app)
107+
- **`ChromeStorageAdapter`** - Chrome extension storage implementation
108+
109+
**Vue Composables:**
110+
111+
All services are wrapped in Vue 3 composables for easy reactive integration:
112+
113+
- **`useWallet()`** - Reactive wallet management with loading/error states
114+
- **`useAccount()`** - Reactive account info, balances, and plasma data
115+
- **`useNetwork()`** - Network connection state and node management
116+
- **`useTransaction()`** - Transaction sending with status tracking
117+
- **`usePlasma()`** - Plasma fusion/cancellation operations
118+
- **`useStake()`** - Staking operations and stake entries
119+
- **`usePillar()`** - Pillar delegation and pillar list
120+
- **`useWalletConnect()`** - WalletConnect session management
121+
122+
**Why Composables?**
123+
124+
Composables provide a clean Vue 3 Composition API interface with:
125+
- Automatic reactivity for UI updates
126+
- Built-in loading and error states
127+
- Simplified async operation handling
128+
- Reusable business logic across components
129+
130+
**Example:**
131+
```typescript
132+
import { WalletService, LocalStorageAdapter } from '@nom-wallet/core'
133+
134+
const service = new WalletService(new LocalStorageAdapter())
135+
const wallet = await service.createWallet('password123', 'My Wallet')
136+
```
137+
138+
**Example with Composable:**
139+
```vue
140+
<script setup>
141+
import { useWallet } from '@nom-wallet/core'
142+
143+
const { wallets, activeWallet, createWallet, isLoading } = useWallet()
144+
145+
await createWallet('password123', 'My Wallet')
146+
</script>
147+
```
148+
149+
### @nom-wallet/ui
150+
151+
Shared Vue 3 components styled with shadcn-vue, Radix Vue, and Tailwind CSS.
152+
153+
**Key components:**
154+
- `Button` - Button component with variants
155+
- `Card`, `CardHeader`, `CardContent` - Card components
156+
- `Input` - Input component
157+
- `WalletCard` - Wallet display card
158+
159+
**Usage:**
160+
```vue
161+
<script setup>
162+
import { Button, Card, WalletCard } from '@nom-wallet/ui'
163+
import '@nom-wallet/ui/style.css'
164+
</script>
165+
```
166+
167+
### @nom-wallet/extension
168+
169+
Browser extension with Manifest V3.
170+
171+
**Features:**
172+
- Popup interface (375x600px)
173+
- Background service worker
174+
- Chrome storage integration
175+
- Routes: Home, Send, Receive
176+
177+
### @nom-wallet/web
178+
179+
Web application.
180+
181+
**Features:**
182+
- Full-page responsive layout
183+
- LocalStorage integration
184+
- Routes: Home, Send, Receive
185+
186+
## Architecture Highlights
187+
188+
### Storage Abstraction
189+
190+
Both apps use the same `WalletService` but with different storage adapters:
191+
192+
- **Web app** uses `LocalStorageAdapter` (browser localStorage)
193+
- **Extension** uses `ChromeStorageAdapter` (chrome.storage.local)
194+
195+
This allows the core wallet logic to be completely platform-agnostic.
196+
197+
### Shared UI Components
198+
199+
Both apps import the same Vue components from `@nom-wallet/ui`, ensuring consistent design and reducing code duplication.
200+
201+
### Type Safety
202+
203+
All packages are written in TypeScript with strict mode enabled, with shared types in `@nom-wallet/types`.
204+
205+
## Development Notes
206+
207+
### Hot Module Replacement (HMR)
208+
209+
- Web app supports HMR out of the box
210+
- Extension requires reload after changes (use dev mode with watch)
211+
212+
### Extension Debugging
213+
214+
1. Open extension popup
215+
2. Right-click → "Inspect"
216+
3. Console logs will appear in DevTools
217+
218+
### Adding New Shared Components
219+
220+
1. Create component in `packages/ui/src/components/`
221+
2. Export from `packages/ui/src/index.ts`
222+
3. Import in apps: `import { Component } from '@nom-wallet/ui'`
223+
224+
## Features Implemented
225+
226+
✅ Complete wallet management (create, import, derive accounts)
227+
✅ Secure key storage with password encryption
228+
✅ In-memory session management with auto-timeout
229+
✅ Full Zenon Network integration (send/receive, staking, plasma, rewards)
230+
✅ WalletConnect v2 support for dApp connections
231+
✅ Transaction signing with KeyPair cryptography
232+
✅ Network node connection management
233+
✅ Reactive Vue composables for all functionality
234+
✅ Cross-platform storage abstraction (web + extension)
235+
236+
## Tech Stack
237+
238+
- **Framework:** Vue 3 (Composition API)
239+
- **Build Tool:** Vite
240+
- **UI Library:** shadcn-vue + Radix Vue
241+
- **Styling:** Tailwind CSS
242+
- **Language:** TypeScript
243+
- **Package Manager:** npm workspaces
244+
- **Extension Tooling:** @crxjs/vite-plugin
245+
246+
## License
247+
248+
MIT

apps/extension/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>NoM Wallet</title>
7+
</head>
8+
<body style="width: 375px; height: 600px; margin: 0;">
9+
<div id="app"></div>
10+
<script type="module" src="/src/main.ts"></script>
11+
</body>
12+
</html>

apps/extension/manifest.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "NoM Wallet",
4+
"version": "1.0.0",
5+
"description": "A secure cryptocurrency wallet for the Nom network",
6+
"permissions": ["storage"],
7+
"action": {
8+
"default_popup": "index.html",
9+
"default_title": "NoM Wallet"
10+
},
11+
"background": {
12+
"service_worker": "src/background.ts",
13+
"type": "module"
14+
},
15+
"icons": {
16+
"16": "icons/icon-16.png",
17+
"48": "icons/icon-48.png",
18+
"128": "icons/icon-128.png"
19+
}
20+
}

apps/extension/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@nom-wallet/extension",
3+
"version": "1.0.0",
4+
"type": "module",
5+
"scripts": {
6+
"dev": "vite build --watch --mode development",
7+
"build": "vite build"
8+
},
9+
"dependencies": {
10+
"@nom-wallet/core": "*",
11+
"@nom-wallet/types": "*",
12+
"@nom-wallet/ui": "*"
13+
},
14+
"devDependencies": {
15+
"@types/chrome": "^0.0.260",
16+
"@crxjs/vite-plugin": "^2.0.0-beta.23"
17+
}
18+
}

0 commit comments

Comments
 (0)