Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _watchdogCallback() {
console.log(`Hardwallet<${this.uid}> Watchdog: state='${this.state}' busy='${this.busy}'`)
if(!this.transport) {
try {
const transport = await Transport.open(this.descriptor);
const str = new Str(transport);
this.transport = transport;
this.str = str;
console.info(`Hardwallet<${this.uid}>: Transport open.`)
} catch(e) {
console.warn(`Hardwallet<${this.uid}> Watchdog: recovering from error... (${e.message})`)
return; // Skip the rest try again later.
}
}
let newState;
try {
if(this.subaccount) {
if(!this.publicKey && !this.busy) await this.selectSubaccount(this.subaccount)
if(!this.busy) await this.ping();
newState = HWW_STATE.READY;