Skip to content
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

gh-pages: Add method to share connection status #147

Open
wants to merge 35 commits into
base: gh-pages
Choose a base branch
from

Conversation

darkwing
Copy link
Contributor

@darkwing darkwing commented May 9, 2022

This PR adds a method for the Ledger to ensure the correct app is open during connection, as well as share track and share connectivity for the Hardware Connectivity UI (MetaMask/metamask-extension#12725)

bundle.js Show resolved Hide resolved
Copy link

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

LGTM! 👍 I can await the await this.cleanUp() before approving

ledger-bridge.js Outdated Show resolved Hide resolved
ledger-bridge.js Outdated
}
catch(e) {
console.log('LEDGER:::Transport check error', e)
this.sendConnectionMessage(false)
Copy link

@digiwand digiwand May 12, 2022

Choose a reason for hiding this comment

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

this.onDisconnect() below also appears to call this.sendConnectionMessage(false). Maybe we don't need this line? Same comment applies to similar logic added in bundle.js

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

ledger-bridge.js Outdated
// Ensure the correct (Ethereum) app is open; if not, immediately kill
// the connection as the wrong app is open and switching apps will call
// a disconnect from within the Ledger API
try {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This block needs to be skipped for Firefox because the U2F library throws on the await this.transport.send(0xb0, 0x01, 0x00, 0x00) line.

brad-decker
brad-decker previously approved these changes May 16, 2022
Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

Tested with my ledger and everything worked well. I switched between the various connection types as well just to ensure that I was testing the various code branches.

@darkwing darkwing force-pushed the gh-pages-disconnect branch 3 times, most recently from 963e99f to 1218a25 Compare June 11, 2022 21:49
@darkwing darkwing force-pushed the gh-pages-disconnect branch from 1218a25 to 94dce64 Compare June 11, 2022 21:59
Copy link

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

LGTM!

tested with Chrome x macOS

catch(e) {
console.log('LEDGER:::Transport check error', e)
// A race condition for checking connection status isn't a sign that
// connection status has changed, so don't disconnect on this type of error

Choose a reason for hiding this comment

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

[optional] It might be helpful if we add a link to the error name

@see {@link https://github.com/LedgerHQ/ledgerjs/blob/master/packages/hw-transport/src/Transport.ts#L276} 
     for more context of the 'TransportRaceCondition' error. This is subject to change.

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.

3 participants