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

Allow the triggering of make-app via message #125

Merged
merged 7 commits into from
Nov 3, 2021
Merged

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Oct 29, 2021

This PR does two things:

  1. Adds a handle for a 'ledger-make-app' message, which calls a new wrapper around the makeApp method. This allows external callers to attempt to create a transport and device connection and then see whether that attempt succeeded or failed, decoupled from any action.
  2. Ensures that no unnecessary attempt to connect the ledger device via webhid is made if a webhid transport already exists and is open

@darkwing
Copy link
Contributor

Still testing this but this will require a bundle update

@@ -47,6 +47,8 @@ export default class LedgerBridge {
this.updateTransportTypePreference(replyAction, 'u2f')
}
break
case 'ledger-make-app':
this.attemptMakeApp(replyAction);
Copy link
Contributor

Choose a reason for hiding this comment

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

This requires a break afterward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in ed2be6b

@@ -91,6 +110,12 @@ export default class LedgerBridge {
this.app = new LedgerEth(this.transport)
}
} else if (this.transportType === 'webhid') {
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 handles a pre-existing bug, but one that was only noticeable with the changes made in this PR

@danjm danjm changed the base branch from gh-pages to gh-pages-staging November 2, 2021 07:38
@danjm danjm marked this pull request as ready for review November 2, 2021 07:39
this.app = null
if (this.transport) {
this.transport.close()
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 is a pre-existing issue, but also needed for this PR to work correctly

ledger-bridge.js Outdated
}

async makeApp (config) {
config = config || {};
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this line, can we do:

async makeApp (config = {}) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 3c5d3ad

@danjm danjm merged commit f3c6bdc into gh-pages-staging Nov 3, 2021
@danjm danjm deleted the make-app-api branch November 3, 2021 16:02
danjm added a commit that referenced this pull request Nov 3, 2021
… of error detection (#125)

* Allow the triggering of make-app via message

* Update bundle.js

* Break on ledger-make-app inswitch

* Don't create new webhid transport if it already exists and is open

* Fix attemptMakeApp

* Only attempt to open existing webhid device in attemptMakeApp

* Use default parameter in makeApp
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.

2 participants