Skip to content

Commit 1953baa

Browse files
committed
feat: add TypeScript types for whole app (components, functions, etc)
- Update eslint - Add husky
1 parent b422aff commit 1953baa

Some content is hidden

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

45 files changed

+904
-492
lines changed

.github/workflows/build_and_release.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,24 @@ jobs:
1212
permissions:
1313
contents: write
1414
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v4.2.2
17-
- name: Set up Docker Buildx
18-
uses: docker/setup-buildx-action@v3.10.0
19-
- name: Get version
20-
id: get_version
21-
run: |
22-
echo "VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
23-
- name: Build Linux
24-
run: DOCKER_BUILDKIT=1 docker build . -f dockerfiles/linux.dockerfile --output build
25-
- name: Build Windows
26-
run: DOCKER_BUILDKIT=1 docker build . -f dockerfiles/win.dockerfile --output build
27-
- name: Release
28-
uses: softprops/action-gh-release@v2.2.1
29-
with:
30-
tag_name: ${{ env.VERSION }}
31-
generate_release_notes: true
32-
files: |
33-
./build/wartlock.AppImage
34-
./build/wartlock.exe
35-
./build/win-portable.zip
36-
15+
- name: Checkout code
16+
uses: actions/checkout@v4.2.2
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3.10.0
19+
- name: Get version
20+
id: get_version
21+
run: |
22+
echo "VERSION=$(jq -r '.version' package.json)" >> $GITHUB_ENV
23+
- name: Build Linux
24+
run: DOCKER_BUILDKIT=1 docker build . -f dockerfiles/linux.dockerfile --output build
25+
- name: Build Windows
26+
run: DOCKER_BUILDKIT=1 docker build . -f dockerfiles/win.dockerfile --output build
27+
- name: Release
28+
uses: softprops/action-gh-release@v2.2.1
29+
with:
30+
tag_name: ${{ env.VERSION }}
31+
generate_release_notes: true
32+
files: |
33+
./build/wartlock.AppImage
34+
./build/wartlock.exe
35+
./build/win-portable.zip

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ dist
33
out
44
.DS_Store
55
.eslintcache
6-
pacakge-lock.json
76
*.log*
87
.vscode
98
*.bak
109
*.db
1110
*.original
1211
.idea
12+
13+
# Lock files
14+
package-lock.json
1315
pnpm-lock.yaml
16+
bun.lock

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bun lint-staged
2+
bun run build

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,96 @@
11
# <img src="resources/wartlock_logo.png" width="30" height="30"> Wartlock
2+
23
Wartlock is a user-friendly and secure cryptocurrency wallet designed specifically for the WART blockchain. It provides a graphical interface for managing WART assets, sending and receiving transactions, and ensuring private key security.
34

45
> Beta Notice: Wartlock is currently in its beta phase. Some security features are still in development, and the wallet is not yet fully audited. Use it at your own risk.
56
67
> **Warning: Light mode is currently non-functional. Please avoid using it until the next update, which will include fixes.**
78
89
## Features
10+
911
- User-Friendly Interface – Simple and intuitive design for easy navigation.
1012
- Secure Key Management – Your private keys remain under your control.
1113
- Send & Receive WART – Easily manage your transactions with a seamless experience.
1214
- Lightweight & Fast – Optimized for performance without compromising security.
1315
- Cross Platform - Wartlock is supported for (Windows, Linux and MacOS)
1416

1517
## Installation & Setup
18+
1619
### Build from source
20+
1721
> Choose the command for your system to build, then run the setup
22+
1823
```
1924
bun i
2025
bun run build:win
2126
bun run build:linux
2227
bun run build:mac
2328
```
29+
2430
OR
2531

2632
> Wartlock is in beta. Avoid using it with large amounts of WART until a full security audit is completed.
33+
2734
1. Download the latest release from [Releases](https://github.com/riven-labs/Wartlock/releases).
2835
2. Install & Run
2936
3. Create or Import Wallet
3037

3138
## Import from other wallets
39+
3240
If you were already using [andrewcrypto777/wart-wallet](https://github.com/andrewcrypto777/wart-wallet) you can import your wallet by your mnemonic using the **Recover Wallet** option, **Yet it's also still possible to import your wallets by copying `wartlock.db` into Wartlock directory**, Wartlock do have an almost identical database integrations to andrew's wallet and we do have migrations in place to make `wartwallet.db` work for wartlock.
3341

3442
> Note: **Copying the database would leave all your wallets without names, if you want to name your wallet you must edit `wartwallet.db` manually using something like DB SQLite browser**
3543
3644
## Docker build
45+
3746
### Build Linux:
47+
3848
```
3949
DOCKER_BUILDKIT=1 docker build . -f dockerfiles/linux.dockerfile --output build
4050
```
51+
4152
### Build Windows:
53+
4254
```
4355
DOCKER_BUILDKIT=1 docker build . -f dockerfiles/win.dockerfile --output build
4456
```
4557

4658
## Contributing
59+
4760
We welcome feedback and contributions! If you find bugs or have feature suggestions, open an issue or submit a pull request
4861

4962
## Developer fees (Optional)
63+
5064
To keep Wartlock growing and improving, we’ve included an optional 5% developer fee on wallet transactions. This small contribution helps **fund ongoing development, security enhancements, and new features.**
5165

5266
When sending a transaction, the developer fee is automatically calculated—but you’re in full control! **You can adjust it to any amount, even zero, or increase it if you’d like to give back more.**
5367

5468
Every contribution, big or small, helps make Wartlock even better. Thank you for your support! ❤️
69+
5570
> Developer donations don’t include network fees—your full contribution goes to Wartlock. The transaction is optimized for low network fees, but since it’s sent from your wallet, the fee will be deducted from your balance separately.
5671
5772
## Support Wartlock
5873

5974
Wartlock is an open-source project, and community support helps drive its development. If you find value in Wartlock and would like to contribute, consider donating or mining to support ongoing improvements.
6075

6176
## Donate WART
77+
6278
Send WART to the developer address:
79+
6380
```
6481
aca4916c89b8fb47784d37ad592d378897f616569d3ee0d4
6582
```
6683

6784
## Mine to Support Wartlock
85+
6886
You can also support Wartlock by mining on the developer address using **BZMiner**:
87+
6988
```bash
7089
bzminer -a warthog -p stratum+tcp://de.warthog.herominers.com:1143 -w aca4916c89b8fb47784d37ad592d378897f616569d3ee0d4.donation --nc 1
7190
```
7291

7392
Or janusminer ( Make sure to replace `YOUR_NODE_IP` and `YOUR_NODE_PORT` with your node information )
93+
7494
```bash
7595
janusminer -a aca4916c89b8fb47784d37ad592d378897f616569d3ee0d4 -h YOUR_NODE_IP -p YOUR_NODE_PORT
7696
```

eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ export default tseslint.config(
2020
files: ['**/*.{ts,tsx}'],
2121
plugins: {
2222
'react-hooks': eslintPluginReactHooks,
23+
'react-refresh': eslintPluginReactRefresh,
2324
},
2425
rules: {
2526
...eslintPluginReactHooks.configs.recommended.rules,
2627
...eslintPluginReactRefresh.configs.vite.rules,
28+
'react-refresh/only-export-components': 'off',
2729
},
2830
},
2931
eslintConfigPrettier,

package.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"build:unpack": "npm run build && electron-builder --dir",
2121
"build:win": "npm run build && electron-builder --win",
2222
"build:mac": "electron-vite build && electron-builder --mac",
23-
"build:linux": "electron-vite build && electron-builder --linux"
23+
"build:linux": "electron-vite build && electron-builder --linux",
24+
"prepare": "husky"
2425
},
2526
"dependencies": {
2627
"@electron-toolkit/preload": "^3.0.1",
@@ -59,13 +60,15 @@
5960
"@types/react-dom": "^18.3.5",
6061
"@vitejs/plugin-react": "^4.3.4",
6162
"autoprefixer": "^10.4.21",
63+
"electron": "^35.0.3",
6264
"electron-builder": "^25.1.8",
6365
"electron-vite": "^3.0.0",
64-
"electron": "^35.0.3",
6566
"eslint": "^9.22.0",
6667
"eslint-plugin-react": "^7.37.4",
6768
"eslint-plugin-react-hooks": "^5.2.0",
6869
"eslint-plugin-react-refresh": "^0.4.19",
70+
"husky": "^9.1.7",
71+
"lint-staged": "^15.5.0",
6972
"postcss": "^8.5.3",
7073
"prettier": "^3.5.3",
7174
"prettier-plugin-organize-imports": "^4.1.0",
@@ -83,5 +86,14 @@
8386
],
8487
"singleQuote": true,
8588
"semi": false
89+
},
90+
"lint-staged": {
91+
"*.{js,jsx,ts,tsx}": [
92+
"eslint --fix",
93+
"prettier --write"
94+
],
95+
"*.{json,yml,yaml,md}": [
96+
"prettier --write"
97+
]
8698
}
8799
}

src/main/backend/crypto.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
1+
/* eslint-disable @typescript-eslint/no-require-imports */
12
import base64url from 'base64url' // Install via `npm install base64url`
23
import crypto from 'crypto'
34

4-
55
const { Secret, Token } = require('fernet')
66
const PBKDF2_ITERATIONS = 480000
77
const KEY_LENGTH = 32
8-
const SALT_LENGTH = 16;
8+
const SALT_LENGTH = 16
99

1010
/**
1111
* Encrypts a private key using Fernet-like encryption.
1212
*/
13-
export function encryptPrivateKey(pk: string, password: string): { encrypted: string; salt: string } {
13+
export function encryptPrivateKey(
14+
pk: string,
15+
password: string,
16+
): { encrypted: string; salt: string } {
1417
// Generate a random salt (16 bytes)
15-
const salt = crypto.randomBytes(SALT_LENGTH);
18+
const salt = crypto.randomBytes(SALT_LENGTH)
1619

1720
// Derive a 32-byte key using PBKDF2-HMAC-SHA256
18-
const key = crypto.pbkdf2Sync(password, salt, PBKDF2_ITERATIONS, KEY_LENGTH, "sha256");
21+
const key = crypto.pbkdf2Sync(
22+
password,
23+
salt,
24+
PBKDF2_ITERATIONS,
25+
KEY_LENGTH,
26+
'sha256',
27+
)
1928

2029
// Encode key in base64 (Fernet requires 32-byte base64-encoded keys)
21-
const fernetKey = base64url.encode(key);
30+
const fernetKey = base64url.encode(key)
2231

2332
// Create a Fernet token and encrypt the private key
24-
const secret = new Secret(fernetKey);
25-
const token = new Token({ secret });
26-
const encrypted = token.encode(pk); // Encrypt the private key
33+
const secret = new Secret(fernetKey)
34+
const token = new Token({ secret })
35+
const encrypted = token.encode(pk) // Encrypt the private key
2736

2837
return {
2938
encrypted, // Encrypted private key (Fernet format)
30-
salt: salt.toString("base64"), // Convert salt to base64 string
31-
};
39+
salt: salt.toString('base64'), // Convert salt to base64 string
40+
}
3241
}
3342

3443
/**
@@ -38,7 +47,7 @@ export function decryptPrivateKey(
3847
encrypted: string,
3948
password: string,
4049
salt: string,
41-
) {
50+
): string | null {
4251
const key = crypto.pbkdf2Sync(
4352
password,
4453
Buffer.from(salt, 'base64'),
@@ -58,7 +67,7 @@ export function decryptPrivateKey(
5867

5968
try {
6069
return token.decode()
61-
} catch (err) {
70+
} catch {
6271
return null // Wrong password or corrupted data
6372
}
6473
}

src/main/backend/db.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ if (fs.existsSync('wartwallet.db')) {
88
// Function to check if a column exists in a table
99
function columnExists(table: string, column: string): boolean {
1010
const columns = db.prepare(`PRAGMA table_info(${table});`).all()
11-
return columns.some(col => col.name === column)
11+
return columns.some((col) => col.name === column)
1212
}
1313

1414
// Function to check if a table exists
@@ -20,7 +20,10 @@ if (fs.existsSync('wartwallet.db')) {
2020
}
2121

2222
// Fix missing columns by migrating the wallets table
23-
if (!columnExists('wallets', 'name') || !columnExists('wallets', 'last_modified')) {
23+
if (
24+
!columnExists('wallets', 'name') ||
25+
!columnExists('wallets', 'last_modified')
26+
) {
2427
console.log("Migrating 'wallets' table to add missing columns...")
2528

2629
// Drop incomplete migration tables if they exist
@@ -120,45 +123,50 @@ if (count.count === 0) {
120123
}
121124

122125
export class WalletDB {
123-
static getWallets() {
126+
static getWallets(): unknown[] {
124127
return db
125128
.prepare('SELECT *, last_modified as lastModified FROM wallets;')
126129
.all()
127130
}
128131

129-
static getWalletByAddress(address: string) {
132+
static getWalletByAddress(address: string): unknown {
130133
return db
131134
.prepare(
132135
'SELECT *, last_modified as lastModified FROM wallets WHERE address = ?;',
133136
)
134137
.get(address)
135138
}
136139

137-
static getWalletById(id: number) {
140+
static getWalletById(id: number): unknown {
138141
return db
139142
.prepare(
140143
'SELECT *, last_modified as lastModified FROM wallets WHERE id = ?;',
141144
)
142145
.get(id)
143146
}
144147

145-
static insertWallet(name: string, address: string, pk: string, salt: string) {
148+
static insertWallet(
149+
name: string,
150+
address: string,
151+
pk: string,
152+
salt: string,
153+
): void {
146154
db.prepare(
147155
'INSERT INTO wallets (name, address, pk, salt, last_modified) VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP);',
148156
).run(name, address, pk, salt)
149157
}
150158

151-
static updateBalance(address: string, balance: string) {
159+
static updateBalance(address: string, balance: string): void {
152160
db.prepare(
153161
'UPDATE wallets SET last_balance = ?, last_modified = CURRENT_TIMESTAMP WHERE address = ?;',
154162
).run(balance, address)
155163
}
156164

157-
static deleteWallet(address: string) {
165+
static deleteWallet(address: string): void {
158166
db.prepare('DELETE FROM wallets WHERE address = ?;').run(address)
159167
}
160168

161-
static updatePeer(peer: string) {
169+
static updatePeer(peer: string): void {
162170
db.prepare(
163171
"UPDATE data SET value = ?, last_modified = CURRENT_TIMESTAMP WHERE key = 'peer';",
164172
).run(peer)

src/main/backend/mnemo.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
import * as bip39 from "bip39";
1+
import * as bip39 from 'bip39'
22

3-
export function generateMnemonic(strength: 256 | 128 | 160 | 192 | 224 = 256): string {
4-
return bip39.generateMnemonic(strength);
3+
export function generateMnemonic(
4+
strength: 256 | 128 | 160 | 192 | 224 = 256,
5+
): string {
6+
return bip39.generateMnemonic(strength)
57
}
68

7-
export function mnemonicToSeed(mnemonic: string, passphrase: string = ""): Buffer {
8-
return bip39.mnemonicToSeedSync(mnemonic, passphrase);
9-
}
9+
export function mnemonicToSeed(
10+
mnemonic: string,
11+
passphrase: string = '',
12+
): Buffer {
13+
return bip39.mnemonicToSeedSync(mnemonic, passphrase)
14+
}

0 commit comments

Comments
 (0)