@johngalt5/bsv-overlay 0.2.2 → 0.2.4

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.
Files changed (2) hide show
  1. package/index.ts +15 -20
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -78,9 +78,9 @@ async function startAutoImport(env, cliPath, logger) {
78
78
  const network = env.BSV_NETWORK === 'testnet' ? 'test' : 'main';
79
79
  const controller = new AbortController();
80
80
  const timeout = setTimeout(() => controller.abort(), 15000);
81
- try {
82
- const resp = await fetch(`https://api.whatsonchain.com/v1/bsv/${network}/address/${address}/unspent`, { signal: controller.signal });
83
- if (!resp.ok) return;
81
+ const resp = await fetch(`https://api.whatsonchain.com/v1/bsv/${network}/address/${address}/unspent`, { signal: controller.signal });
82
+ clearTimeout(timeout);
83
+ if (!resp.ok) return;
84
84
  const utxos = await resp.json();
85
85
 
86
86
  for (const utxo of utxos) {
@@ -118,8 +118,6 @@ async function startAutoImport(env, cliPath, logger) {
118
118
  }
119
119
  } catch (err) {
120
120
  // WoC API error — just skip this cycle
121
- } finally {
122
- clearTimeout(timeout);
123
121
  }
124
122
  }, 60000); // Check every 60 seconds
125
123
  } catch (err) {
@@ -196,7 +194,7 @@ function stopBackgroundService() {
196
194
  stopAutoImport();
197
195
  }
198
196
 
199
- export default async function register(api) {
197
+ export default function register(api) {
200
198
  // Capture config at registration time (api.getConfig may not be available later)
201
199
  const pluginConfig = api.getConfig?.()?.plugins?.entries?.['bsv-overlay']?.config || api.config || {};
202
200
 
@@ -474,26 +472,23 @@ export default async function register(api) {
474
472
  });
475
473
  }, { commands: ["overlay"] });
476
474
 
477
- // Auto-setup: ensure wallet exists (best-effort, non-fatal)
478
- try {
479
- const config = pluginConfig;
480
- const walletDir = config?.walletDir || path.join(process.env.HOME || '', '.clawdbot', 'bsv-wallet');
481
- const identityFile = path.join(walletDir, 'wallet-identity.json');
482
- if (!fs.existsSync(identityFile)) {
483
- api.log?.info?.('[bsv-overlay] No wallet found — running auto-setup...');
484
- try {
475
+ // Auto-setup: ensure wallet exists (best-effort, non-fatal, fire-and-forget)
476
+ (async () => {
477
+ try {
478
+ const config = pluginConfig;
479
+ const walletDir = config?.walletDir || path.join(process.env.HOME || '', '.clawdbot', 'bsv-wallet');
480
+ const identityFile = path.join(walletDir, 'wallet-identity.json');
481
+ if (!fs.existsSync(identityFile)) {
482
+ api.log?.info?.('[bsv-overlay] No wallet found — running auto-setup...');
485
483
  const env = buildEnvironment(config || {});
486
484
  const cliPath = path.join(__dirname, 'scripts', 'overlay-cli.mjs');
487
485
  await execFileAsync('node', [cliPath, 'setup'], { env });
488
486
  api.log?.info?.('[bsv-overlay] Wallet initialized. Fund it and run: overlay({ action: "register" })');
489
- } catch (err: any) {
490
- api.log?.warn?.('[bsv-overlay] Auto-setup failed:', err.message);
491
487
  }
488
+ } catch (err: any) {
489
+ api.log?.debug?.('[bsv-overlay] Auto-setup skipped:', err.message);
492
490
  }
493
- } catch (err: any) {
494
- // Non-fatal — plugin still loads if auto-setup fails
495
- api.log?.debug?.('[bsv-overlay] Auto-setup skipped:', err.message);
496
- }
491
+ })();
497
492
  }
498
493
 
499
494
  async function executeOverlayAction(params, config, api) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johngalt5/bsv-overlay",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Clawdbot BSV Overlay — agent discovery, service marketplace, and micropayments on the BSV blockchain",
5
5
  "type": "module",
6
6
  "files": [