From fe49b46f3ab3818e4abea381f458586ab7cce3c2 Mon Sep 17 00:00:00 2001 From: MrNerdHair Date: Fri, 11 Feb 2022 21:49:36 -0500 Subject: [PATCH] metamask: derive metamask-style account paths --- integration/src/wallets/metamask.ts | 14 +++++++------- packages/hdwallet-metamask/src/ethereum.ts | 6 +++--- packages/hdwallet-metamask/src/metamask.ts | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/integration/src/wallets/metamask.ts b/integration/src/wallets/metamask.ts index 5792c5ae4..4172d74b5 100644 --- a/integration/src/wallets/metamask.ts +++ b/integration/src/wallets/metamask.ts @@ -53,7 +53,7 @@ export function selfTest(get: () => core.HDWallet): void { expect(await wallet.ethSupportsSecureTransfer()).toEqual(false); }); - it("uses correct eth bip44 paths", () => { + it("uses metamask-style account derivation paths", () => { if (!wallet) return; [0, 1, 3, 27].forEach((account) => { let paths = wallet.ethGetAccountPaths({ @@ -62,9 +62,9 @@ export function selfTest(get: () => core.HDWallet): void { }); expect(paths).toEqual([ { - addressNList: core.bip32ToAddressNList(`m/44'/60'/${account}'/0/0`), - hardenedPath: core.bip32ToAddressNList(`m/44'/60'/${account}'`), - relPath: [0, 0], + addressNList: core.bip32ToAddressNList(`m/44'/60'/0'/0/${account}`), + hardenedPath: core.bip32ToAddressNList(`m/44'/60'/0'`), + relPath: [0, account], description: "MetaMask", }, ]); @@ -97,7 +97,7 @@ export function selfTest(get: () => core.HDWallet): void { expect( wallet.describePath({ - path: core.bip32ToAddressNList("m/44'/60'/3'/0/0"), + path: core.bip32ToAddressNList("m/44'/60'/0'/0/3"), coin: "Ethereum", }) ).toEqual({ @@ -111,11 +111,11 @@ export function selfTest(get: () => core.HDWallet): void { expect( wallet.describePath({ - path: core.bip32ToAddressNList("m/44'/60'/0'/0/3"), + path: core.bip32ToAddressNList("m/44'/60'/3'/0/0"), coin: "Ethereum", }) ).toEqual({ - verbose: "m/44'/60'/0'/0/3", + verbose: "m/44'/60'/3'/0/0", coin: "Ethereum", isKnown: false, }); diff --git a/packages/hdwallet-metamask/src/ethereum.ts b/packages/hdwallet-metamask/src/ethereum.ts index 3c84c0e65..db5c47639 100644 --- a/packages/hdwallet-metamask/src/ethereum.ts +++ b/packages/hdwallet-metamask/src/ethereum.ts @@ -11,9 +11,9 @@ export function ethGetAccountPaths(msg: core.ETHGetAccountPath): Array