@1sat/cli 0.0.30 → 0.0.31

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/cli",
3
- "version": "0.0.30",
3
+ "version": "0.0.31",
4
4
  "description": "CLI for 1Sat Ordinals SDK",
5
5
  "type": "module",
6
6
  "main": "./src/cli.ts",
@@ -16,10 +16,10 @@
16
16
  "keywords": ["1sat", "bsv", "ordinals", "cli"],
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
- "@1sat/actions": "0.0.98",
19
+ "@1sat/actions": "0.0.99",
20
20
  "@1sat/client": "0.0.21",
21
21
  "@1sat/types": "0.0.17",
22
- "@1sat/wallet-node": "0.0.28",
22
+ "@1sat/wallet-node": "0.0.29",
23
23
  "@bsv/sdk": "^2.0.13",
24
24
  "chalk": "^5.0.0",
25
25
  "@clack/prompts": "^0.8.0",
@@ -30,7 +30,6 @@ const SETTABLE_KEYS: Array<keyof OneSatCliConfig> = [
30
30
  'chain',
31
31
  'dataDir',
32
32
  'storageIdentityKey',
33
- 'monitorIntervalMinutes',
34
33
  ]
35
34
 
36
35
  export async function handleConfigCommand(
@@ -74,7 +73,6 @@ function configShow(opts: GlobalFlags): void {
74
73
  chain: config.chain,
75
74
  dataDir: config.dataDir,
76
75
  storageIdentityKey: config.storageIdentityKey ?? '(not set)',
77
- monitorIntervalMinutes: config.monitorIntervalMinutes,
78
76
  })
79
77
  console.log()
80
78
  console.log(
@@ -102,14 +100,6 @@ function configSet(args: string[], opts: GlobalFlags): void {
102
100
  if (key === 'chain' && value !== 'main' && value !== 'test') {
103
101
  fatal("chain must be 'main' or 'test'")
104
102
  }
105
- if (key === 'monitorIntervalMinutes') {
106
- const n = Number(value)
107
- if (!Number.isFinite(n) || n < 0) {
108
- fatal(
109
- 'monitorIntervalMinutes must be a non-negative number (0 to disable)',
110
- )
111
- }
112
- }
113
103
 
114
104
  const updated = updateConfig({ [key]: value })
115
105
  output(opts.json ? updated : formatSuccess(`Set ${key} = ${value}`), opts)
package/src/config.ts CHANGED
@@ -22,38 +22,11 @@ export interface OneSatCliConfig {
22
22
  backups?: string[]
23
23
  /** Storage identity key for wallet persistence */
24
24
  storageIdentityKey?: string
25
- /** How often to run the monitor refresh (minutes). 0 disables auto-refresh. */
26
- monitorIntervalMinutes: number
27
25
  }
28
26
 
29
27
  const DEFAULT_CONFIG: OneSatCliConfig = {
30
28
  chain: 'main',
31
29
  dataDir: join(CONFIG_DIR, 'data'),
32
- monitorIntervalMinutes: 5,
33
- }
34
-
35
- // Monitor state — stored separately so we don't rewrite config.json on every command
36
- const MONITOR_STATE_FILE = join(CONFIG_DIR, 'monitor-state.json')
37
-
38
- export interface MonitorState {
39
- lastMonitorRun: number // unix ms timestamp
40
- }
41
-
42
- export function loadMonitorState(): MonitorState {
43
- if (!existsSync(MONITOR_STATE_FILE)) return { lastMonitorRun: 0 }
44
- try {
45
- const raw = readFileSync(MONITOR_STATE_FILE, 'utf8')
46
- return JSON.parse(raw)
47
- } catch {
48
- return { lastMonitorRun: 0 }
49
- }
50
- }
51
-
52
- export function saveMonitorState(state: MonitorState): void {
53
- ensureConfigDir()
54
- writeFileSync(MONITOR_STATE_FILE, JSON.stringify(state, null, 2), {
55
- mode: 0o600,
56
- })
57
30
  }
58
31
 
59
32
  /**
package/src/context.ts CHANGED
@@ -7,12 +7,7 @@
7
7
  import { type OneSatContext, createContext } from '@1sat/actions'
8
8
  import { type NodeWalletResult, createNodeWallet } from '@1sat/wallet-node'
9
9
  import type { PrivateKey } from '@bsv/sdk'
10
- import {
11
- ensureDataDir,
12
- loadConfig,
13
- loadMonitorState,
14
- saveMonitorState,
15
- } from './config'
10
+ import { ensureDataDir, loadConfig } from './config'
16
11
 
17
12
  /** Extended context that includes cleanup */
18
13
  export interface CliContext {
@@ -21,48 +16,16 @@ export interface CliContext {
21
16
  destroy: () => Promise<void>
22
17
  }
23
18
 
24
- /**
25
- * Run the monitor once if the interval has elapsed.
26
- * This is called lazily by commands that need current state.
27
- */
28
- async function runMonitorIfStale(
29
- walletResult: NodeWalletResult,
30
- intervalMinutes: number,
31
- ): Promise<void> {
32
- if (!walletResult.monitor) return // remote active, monitor runs remotely
33
- if (intervalMinutes === 0) return // disabled by user
34
-
35
- const state = loadMonitorState()
36
- const now = Date.now()
37
- const elapsed = now - state.lastMonitorRun
38
- const intervalMs = intervalMinutes * 60 * 1000
39
-
40
- if (elapsed >= intervalMs) {
41
- const originalLog = console.log
42
- const originalInfo = console.info
43
- const originalWarn = console.warn
44
- console.log = () => {}
45
- console.info = () => {}
46
- console.warn = () => {}
47
-
48
- try {
49
- await walletResult.monitor.runOnce()
50
- } finally {
51
- console.log = originalLog
52
- console.info = originalInfo
53
- console.warn = originalWarn
54
- }
55
- saveMonitorState({ lastMonitorRun: Date.now() })
56
- }
57
- }
58
-
59
19
  /**
60
20
  * Create a fully initialized OneSatContext for CLI use.
61
21
  *
62
22
  * Sets up:
63
23
  * - Node wallet with SQLite storage
64
24
  * - 1Sat services for API access
65
- * - Monitor for transaction lifecycle (lazy, interval-based)
25
+ * - Monitor for transaction lifecycle. When local storage is the active
26
+ * store, the wallet factory fires `monitor.runOnce()` internally on
27
+ * creation; individual tasks self-throttle via their own intervals, so
28
+ * repeated CLI invocations are cheap.
66
29
  */
67
30
  export async function loadContext(
68
31
  privateKey: PrivateKey,
@@ -82,9 +45,6 @@ export async function loadContext(
82
45
  backups: config.backups,
83
46
  })
84
47
 
85
- // Run monitor once if interval has elapsed (lazy refresh)
86
- await runMonitorIfStale(walletResult, config.monitorIntervalMinutes)
87
-
88
48
  const ctx = createContext(walletResult.wallet, {
89
49
  services: walletResult.services,
90
50
  chain: opts.chain,