From 5182b3634ec8b50acd66d4a41405c7414ce8a83c Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Sat, 14 Mar 2026 00:14:45 -0400 Subject: [PATCH] fix(machine): enable/disable validator on state transitions (direct HAL) The IPC path already had a watcher to enable the bill validator when entering insertingBills and disable it when leaving. The direct HAL path (initializeWithHal) was missing this, meaning the validator would accept bills in any state. Matches brain.js pattern (lines 193-196). Closes #28 Co-Authored-By: Claude Opus 4.6 --- apps/machine/src/stores/atm.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/apps/machine/src/stores/atm.ts b/apps/machine/src/stores/atm.ts index f6b1793..98d420b 100644 --- a/apps/machine/src/stores/atm.ts +++ b/apps/machine/src/stores/atm.ts @@ -665,6 +665,18 @@ export const useAtmStore = defineStore('atm', () => { }, }) + // Watch state transitions to enable/disable validator hardware + watch(nestedState, (newState, oldState) => { + if (newState === 'insertingBills' && oldState !== 'insertingBills') { + console.log('[ATM] Enabling bill validator') + hal.enableValidator() + } + if (oldState === 'insertingBills' && newState !== 'insertingBills') { + console.log('[ATM] Disabling bill validator') + hal.disableValidator() + } + }) + console.log('[ATM] Fully initialized with HAL + Lightning') } catch (error) { console.error('[ATM] HAL initialization failed:', error)