fluxy-bot 0.10.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,10 +2,13 @@ import { Command } from 'commander';
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import pc from 'picocolors';
5
+ import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
5
6
 
6
- import { pkg, DATA_DIR, createConfig } from '../core/config.js';
7
+ import { pkg, DATA_DIR, CONFIG_PATH, createConfig } from '../core/config.js';
7
8
  import { runTunnelSetup } from './tunnel.js';
8
9
 
10
+ import type { BotConfig } from '../../shared/config.js';
11
+
9
12
  export function registerInitCommand(program: Command) {
10
13
  program
11
14
  .command('init')
@@ -17,6 +20,19 @@ export function registerInitCommand(program: Command) {
17
20
 
18
21
  console.log(pc.green('✓ Initialized base config.\n'));
19
22
 
23
+ // Generate USDC wallet (skip if one already exists)
24
+ const cfg: BotConfig = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
25
+ if (cfg.wallet?.privateKey) {
26
+ console.log(pc.green('✓ Wallet exists') + pc.dim(` (${cfg.wallet.address})\n`));
27
+ } else {
28
+ const privateKey = generatePrivateKey();
29
+ const account = privateKeyToAccount(privateKey);
30
+ cfg.wallet = { privateKey, address: account.address };
31
+ fs.writeFileSync(CONFIG_PATH, JSON.stringify(cfg, null, 2));
32
+ console.log(pc.green('✓ Wallet created') + pc.dim(` (${account.address})`));
33
+ console.log(pc.dim(' Fund your wallet to enable autonomous purchases.\n'));
34
+ }
35
+
20
36
  await runTunnelSetup();
21
37
 
22
38
  console.log(pc.dim('Run ' + pc.magenta('fluxy start') + ' to launch the server.'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "releaseNotes": [
5
5
  "Adding a way for users to claim their fluxies on the fluxy.bot dashboard",
6
6
  "2. ",
@@ -82,6 +82,7 @@
82
82
  "tailwindcss": "^4.2.0",
83
83
  "three": "^0.183.1",
84
84
  "tsx": "^4.21.0",
85
+ "viem": "^2.47.6",
85
86
  "vite": "^7.3.1",
86
87
  "vite-plugin-pwa": "^1.2.0",
87
88
  "web-push": "^3.6.7",
package/shared/config.ts CHANGED
@@ -21,6 +21,10 @@ export interface BotConfig {
21
21
  tier: string;
22
22
  url: string;
23
23
  };
24
+ wallet?: {
25
+ privateKey: string;
26
+ address: string;
27
+ };
24
28
  tunnelUrl?: string;
25
29
  }
26
30
 
package/shared/relay.ts CHANGED
@@ -7,11 +7,15 @@ const RELAY_API = 'https://api.fluxy.bot/api';
7
7
  export async function registerHandle(
8
8
  username: string,
9
9
  tier: string,
10
+ walletAddress?: string,
10
11
  ): Promise<{ token: string; relayUrl: string }> {
12
+ const payload: Record<string, string> = { username, tier };
13
+ if (walletAddress) payload.walletAddress = walletAddress;
14
+
11
15
  const res = await fetch(`${RELAY_API}/register`, {
12
16
  method: 'POST',
13
17
  headers: { 'Content-Type': 'application/json' },
14
- body: JSON.stringify({ username, tier }),
18
+ body: JSON.stringify(payload),
15
19
  });
16
20
 
17
21
  const data = await res.json();
@@ -41,11 +45,15 @@ export async function checkAvailability(
41
45
  export async function claimReservedHandle(
42
46
  handle: string,
43
47
  hash: string,
48
+ walletAddress?: string,
44
49
  ): Promise<{ token: string; relayUrl: string }> {
50
+ const payload: Record<string, string> = { handle, hash };
51
+ if (walletAddress) payload.walletAddress = walletAddress;
52
+
45
53
  const res = await fetch(`${RELAY_API}/handle/claim-reserved`, {
46
54
  method: 'POST',
47
55
  headers: { 'Content-Type': 'application/json' },
48
- body: JSON.stringify({ handle, hash }),
56
+ body: JSON.stringify(payload),
49
57
  });
50
58
 
51
59
  const data = await res.json();
package/worker/index.ts CHANGED
@@ -234,11 +234,11 @@ app.post('/api/handle/register', async (req, res) => {
234
234
  }
235
235
 
236
236
  try {
237
- const result = await registerHandle(username, tier);
237
+ const cfg = loadConfig();
238
+ const result = await registerHandle(username, tier, cfg.wallet?.address);
238
239
  log.ok(`Handle registered with relay: url=${result.relayUrl}, token=${result.token ? 'received' : 'MISSING'}`);
239
240
 
240
241
  // Save to config
241
- const cfg = loadConfig();
242
242
  cfg.username = username;
243
243
  cfg.relay = { token: result.token, tier, url: result.relayUrl };
244
244
  saveConfig(cfg);
@@ -287,7 +287,7 @@ app.post('/api/handle/change', async (req, res) => {
287
287
  }
288
288
 
289
289
  // Register new handle
290
- const result = await registerHandle(username, tier);
290
+ const result = await registerHandle(username, tier, cfg.wallet?.address);
291
291
 
292
292
  cfg.username = username;
293
293
  cfg.relay = { token: result.token, tier, url: result.relayUrl };
@@ -319,10 +319,8 @@ app.post('/api/handle/claim-reserved', async (req, res) => {
319
319
  }
320
320
 
321
321
  try {
322
- const result = await claimReservedHandle(handle, hash);
323
-
324
- // Save to config (same as normal registration)
325
322
  const cfg = loadConfig();
323
+ const result = await claimReservedHandle(handle, hash, cfg.wallet?.address);
326
324
 
327
325
  // Release old handle if one exists
328
326
  if (cfg.relay?.token) {