Skip to content

Commit

Permalink
fix: bnr disable and event handling (#1212)
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelTaranto authored Nov 6, 2024
1 parent 9e488db commit ec8b971
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 66 deletions.
9 changes: 9 additions & 0 deletions lib/mei/bnr_advance.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const _ = require('lodash/fp')
const denominationsTable = require('./denominations')
const BN = require('../bn')

const CASH_UNIT_CHANGED = 6154

const BnrAdvance = function () {
EventEmitter.call(this)
this.fiatCode = null
Expand Down Expand Up @@ -72,6 +74,13 @@ BnrAdvance.prototype.run = function run (cb) {
.then(emitter => {
console.log('BNR is ready')
this.bnrEmitter = emitter
this.bnrEmitter.on('event', it => {
if (it.type === 'status' && it.status === CASH_UNIT_CHANGED) {
this.emit('stackerOpen')
this.emit('actionRequiredMaintenance')
}
})

})
.catch(err => {
console.error('Error initializing BNR:', err)
Expand Down
101 changes: 36 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"xstate": "^3.0.4"
},
"optionalDependencies": {
"@lamassu/bnr-advance": "1.2.0",
"@lamassu/bnr-advance": "1.4.0",
"@lamassu/genmega": "^1.2.0"
},
"devDependencies": {
Expand Down

0 comments on commit ec8b971

Please sign in to comment.