-
Notifications
You must be signed in to change notification settings - Fork 100
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
Fabo/cross network ledger #3338
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
2bf7869
basis for cross network account creation
faboweb b8e650c
cleanup and refactor
faboweb b43dcb4
changelog
faboweb ae01d11
cleanup
faboweb 80ac2b4
approach for cross network ledger usage
faboweb 7865b5c
steps towards having ledger corss network
faboweb ca93cba
linted
faboweb 235e6dc
Merge remote-tracking branch 'origin/develop' into fabo/cross-network…
faboweb 50aedfe
fix ledger account creation
faboweb 849d493
linted
faboweb 4c91569
tests
faboweb cbf188f
changelog
faboweb b04197b
fixed keystore tests
faboweb f6bb568
fixed signup test
faboweb 4d6fa7a
Merge remote-tracking branch 'origin/develop' into fabo/cross-network…
faboweb f276e9c
added some tests
faboweb 5a35956
added shallow test for show address for coverage
faboweb 884d10a
test for clearing warnings in appmenu for show address
faboweb ad56684
Merge branch 'develop' into fabo/cross-network-ledger
faboweb 462da69
added back emoney
faboweb a4aa915
Merge branch 'fabo/cross-network-ledger' of https://github.com/lunieh…
faboweb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Added] [#3392](https://github.com/cosmos/lunie/issues/3392) Use Ledger across networks @faboweb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import config from "src/../config" | ||
|
||
function parseLedgerErrors(error) { | ||
// TODO move this error rewrite into the ledger lib | ||
/* istanbul ignore next: specific error rewrite */ | ||
if (error.message.trim().startsWith("Device is already open")) { | ||
throw new Error( | ||
"Something went wrong connecting to your Ledger. Please refresh your page and try again." | ||
) | ||
} | ||
throw error | ||
} | ||
|
||
export const getAddressFromLedger = async network => { | ||
const ledger = await getLedgerConnector(network) | ||
|
||
try { | ||
const address = await ledger.getCosmosAddress() // TODO this should become `getAddress` to also work for not Cosmos networks | ||
|
||
return address | ||
} catch (err) { | ||
parseLedgerErrors(err) | ||
} finally { | ||
// cleanup. if we leave this open, the next connection will brake for HID | ||
// TODO move this into the leder lib | ||
ledger.cosmosApp.transport.close() | ||
} | ||
} | ||
|
||
export async function showAddressOnLedger(network) { | ||
const ledger = await getLedgerConnector(network) | ||
|
||
try { | ||
await ledger.confirmLedgerAddress() | ||
} catch (err) { | ||
parseLedgerErrors(err) | ||
} finally { | ||
// cleanup. if we leave this open, the next connection will brake for HID | ||
// TODO move this into the leder lib | ||
ledger.cosmosApp.transport.close() | ||
} | ||
} | ||
|
||
async function getLedgerConnector(network) { | ||
switch (network) { | ||
case "cosmos-hub-mainnet": | ||
case "cosmos-hub-testnet": | ||
case "regen-testnet": | ||
case "regen-mainnet": | ||
case "terra-testnet": | ||
case "terra-mainnet": { | ||
const { default: Ledger } = await import("@lunie/cosmos-ledger") | ||
|
||
const HDPATH = [44, 118, 0, 0, 0] | ||
const ledger = new Ledger( | ||
{ | ||
testModeAllowed: config.testModeAllowed | ||
}, | ||
HDPATH, | ||
config.bech32Prefixes[network] | ||
) | ||
|
||
return ledger | ||
} | ||
default: | ||
throw new Error( | ||
"Lunie doesn't support connecting to the Ledger for this network." | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This should be received from the API. I will create an issue.
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.
#3402