-
Notifications
You must be signed in to change notification settings - Fork 17
fix(ledger): Cp-11586 ledger lock state #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| } catch (error: any) { | ||
| // Check if this looks like a device lock error | ||
| const isLockError = | ||
| error?.statusCode === 0x5515 || // Device locked |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether these will be used elsewhere in the future, but maybe worth creating an enum/object out of it:
const LEDGER_ERROR_CODES = Object.freeze({
DEVICE_LOCKED: 0x5515,
INCORRECT_LENGTH: 0x6700,
SOMETHING_WRONG: 0x6b0c,
})#niceToHave
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this branch with Ledger Stax, and it works fine 👍

Description
CP-11586 https://ava-labs.atlassian.net/browse/CP-11586
Summary of the bug:
Once the user is already in the send flow, the LedgerProvider was not catching that the device has locked.
How to repliacate:
Changes
A heartbeat check was created.
Every 3 secs, we check to see if the device is unlocked and responding as expected.
3 secs were picked for now because Ledger does not emit any event when the device is locked.
When tried 10 sec or 5 secs, it felt too long and the user can still slip through between the heartbeat and get through the approval process.
Testing
Screenshots:
n/a
Checklist for the author
Tick each of them when done or if not applicable.