Skip to content

Commit

Permalink
try 3 times (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
harshjv committed Mar 20, 2019
1 parent 43b2d6a commit 29e36b2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/providers/LedgerProvider.js
Expand Up @@ -7,10 +7,18 @@ export default class LedgerProvider extends WalletProvider {
return Transport.isSupported()
}

async claimLedgerInterface () {
async claimLedgerInterface (attempt = 1, maxAttempts = 3) {
if (this._webUsbDevice) {
if (this._webUsbDevice.configuration.interfaces[2].claimed) return
await this._webUsbDevice.claimInterface(2)
try {
await this._webUsbDevice.claimInterface(2)
} catch (e) {
if (maxAttempts <= attempt) {
await this.claimLedgerInterface(attempt++)
} else {
throw e
}
}
}
}

Expand Down

0 comments on commit 29e36b2

Please sign in to comment.