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 <noreply@anthropic.com>
This commit is contained in:
Patrick Mulligan 2026-03-14 00:14:45 -04:00
commit 5182b3634e

View file

@ -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') console.log('[ATM] Fully initialized with HAL + Lightning')
} catch (error) { } catch (error) {
console.error('[ATM] HAL initialization failed:', error) console.error('[ATM] HAL initialization failed:', error)