-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "Custom HD Path for account recovery""
- Loading branch information
1 parent
01eb104
commit d16414c
Showing
9 changed files
with
85 additions
and
19 deletions.
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
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import TransportU2F from '@ledgerhq/hw-transport-u2f'; | ||
import { createClient } from 'near-ledger-js'; | ||
|
||
import { WalletError } from './walletError'; | ||
|
||
async function createLedgerU2FTransport() { | ||
let transport; | ||
try { | ||
transport = await TransportU2F.create(); | ||
} catch (error) { | ||
if (error.id === 'U2FNotSupported') { | ||
throw new WalletError(error.message, 'getLedgerAccountIds.U2FNotSupported'); | ||
} | ||
throw error; | ||
} | ||
transport.setScrambleKey('NEAR'); | ||
return transport; | ||
} | ||
|
||
async function createLedgerU2FClient() { | ||
const transport = await createLedgerU2FTransport(); | ||
const client = await createClient(transport); | ||
return client; | ||
} | ||
|
||
function getLedgerHDPath(confirmedPath){ | ||
return confirmedPath ? `44'/397'/0'/0'/${confirmedPath}'` : null; | ||
} | ||
|
||
export { createLedgerU2FClient, getLedgerHDPath }; |
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