Skip to content

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

Open
darkwing wants to merge 35 commits into
gh-pagesfrom
gh-pages-disconnect
Open

gh-pages: Add method to share connection status #147
darkwing wants to merge 35 commits into
gh-pagesfrom
gh-pages-disconnect

Conversation

@darkwing

@darkwing darkwing commented May 9, 2022

Copy link
Copy Markdown
Contributor

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)

Comment thread bundle.js Outdated

@digiwand digiwand left a comment

Copy link
Copy Markdown

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

Comment thread ledger-bridge.js Outdated
Comment thread ledger-bridge.js Outdated
}
catch(e) {
console.log('LEDGER:::Transport check error', e)
this.sendConnectionMessage(false)

@digiwand digiwand May 12, 2022

Copy link
Copy Markdown

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

Comment thread 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
Copy Markdown
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

@brad-decker brad-decker left a comment

Copy link
Copy Markdown
Contributor

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

@digiwand digiwand left a comment

Copy link
Copy Markdown

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

Comment thread ledger-bridge.js
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

Copy link
Copy Markdown

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