-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve: [Ledger] Fix/extend HD pathes for ETH (#2374)
- [x] Fix/extend HD pathes for ETH - [x] Test `getDerivationPath` - [x] Update `i18n` - [x] Fix styles
- Loading branch information
Showing
17 changed files
with
92 additions
and
46 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
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,18 @@ | ||
import { getDerivationPath } from './ledger' | ||
|
||
describe('shared/eth/ledger', () => { | ||
describe('getDerivationPath', () => { | ||
it('metamask', () => { | ||
expect(getDerivationPath(0, 'metamask')).toEqual(`m/44'/60'/0'/0/0`) | ||
expect(getDerivationPath(1, 'metamask')).toEqual(`m/44'/60'/0'/0/1`) | ||
}) | ||
it('ledger live', () => { | ||
expect(getDerivationPath(0, 'ledgerlive')).toEqual(`m/44'/60'/0'/0/0`) | ||
expect(getDerivationPath(1, 'ledgerlive')).toEqual(`m/44'/60'/1'/0/0`) | ||
}) | ||
it('legacy', () => { | ||
expect(getDerivationPath(0, 'legacy')).toEqual(`m/44'/60'/0'/0`) | ||
expect(getDerivationPath(1, 'legacy')).toEqual(`m/44'/60'/0'/1`) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,8 +1,14 @@ | ||
import { EthDerivationMode } from './types' | ||
|
||
// ETH derivation pathes `Legacy` + `Ledger Live` | ||
// Based on https://github.com/LedgerHQ/ledger-live/blob/0059ab0aa6bbc2d952476e65ef9db0f557321cba/libs/ledger-live-common/src/derivation.ts#L42-L53 | ||
const DERIVATION_MAP: Record<EthDerivationMode, string> = { legacy: `m/44'/60'/0'/`, ledgerlive: `m/44'/60'/0'/0/` } | ||
// ETH derivation pathes `Legacy`, `Ledger Live`, `MetaMask` | ||
// Based on | ||
// - Definitions in LedgerLive https://github.com/LedgerHQ/ledger-live/blob/develop/libs/ledger-live-common/src/derivation.ts#L43-L55 | ||
// - Definitions in MetaMask https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/create-account/connect-hardware/index.js#L24-L31 | ||
const DERIVATION_MAP: Record<EthDerivationMode, string> = { | ||
legacy: `m/44'/60'/0'/{account}`, | ||
ledgerlive: `m/44'/60'/{account}'/0/0`, | ||
metamask: `m/44'/60'/0'/0/{account}` | ||
} | ||
|
||
export const getDerivationPath = (walletIndex: number, mode: EthDerivationMode): string => | ||
`${DERIVATION_MAP[mode]}${walletIndex}` | ||
`${DERIVATION_MAP[mode]}`.replace(/{account}/, `${walletIndex}`) |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export type EthDerivationMode = 'legacy' | 'ledgerlive' | ||
export type EthDerivationMode = 'legacy' | 'ledgerlive' | 'metamask' |