Skip to content

Conversation

@frichards
Copy link
Contributor

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:

  1. Make sure that your Ledger stax is connected and has the correct app open.
  2. Go to send page
  3. Lock the device
  4. Fill out the send form and click Next.
  5. It does not detect that the device is locked. So the user is able to resume with the approval process

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

  1. Make sure that your Ledger stax is connected and has the correct app open.
  2. Go to send page
  3. Lock the device
  4. Fill out the send form and click Next.
  5. The Ledger is disconnected modal should pop up and prevent the user from moving forward in the approval process.
  6. Once the ledger is unlocked, the provider should recognize that the devide is ready to go on the next heartbeat check

Screenshots:

n/a

Checklist for the author

Tick each of them when done or if not applicable.

  • I've covered new/modified business logic with Jest test cases.
  • I've tested the changes myself before sending it to code review and QA.

@frichards frichards marked this pull request as ready for review October 28, 2025 17:48
@frichards frichards marked this pull request as draft October 28, 2025 17:48
@frichards frichards marked this pull request as ready for review October 28, 2025 20:40
} catch (error: any) {
// Check if this looks like a device lock error
const isLockError =
error?.statusCode === 0x5515 || // Device locked
Copy link
Contributor

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

Copy link
Contributor

@csabbee csabbee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-

@blockqa blockqa self-requested a review November 3, 2025 17:38
Copy link
Contributor

@blockqa blockqa left a 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 👍

@frichards frichards merged commit 3a61181 into main Nov 3, 2025
4 checks passed
@frichards frichards deleted the CP-11586-ledger-stax-2 branch November 3, 2025 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants