diff --git a/packages/faucet/src/hdpaths.spec.ts b/packages/faucet/src/hdpaths.spec.ts deleted file mode 100644 index fb60694a..00000000 --- a/packages/faucet/src/hdpaths.spec.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Slip10RawIndex } from "@iov/crypto"; - -import { debugPath } from "./hdpaths"; - -describe("hdpaths", () => { - describe("debugPath", () => { - it("works for no component", () => { - // See https://github.com/bitcoin/bips/blob/master/bip-0032/derivation.png from BIP32 - expect(debugPath([])).toEqual("m"); - }); - - it("works for normal components", () => { - const one = Slip10RawIndex.normal(1); - expect(debugPath([one])).toEqual("m/1"); - expect(debugPath([one, one])).toEqual("m/1/1"); - expect(debugPath([one, one, one])).toEqual("m/1/1/1"); - - const min = Slip10RawIndex.normal(0); - expect(debugPath([min])).toEqual("m/0"); - - const max = Slip10RawIndex.normal(2 ** 31 - 1); - expect(debugPath([max])).toEqual("m/2147483647"); - }); - - it("works for hardened components", () => { - const one = Slip10RawIndex.hardened(1); - expect(debugPath([one])).toEqual("m/1'"); - expect(debugPath([one, one])).toEqual("m/1'/1'"); - expect(debugPath([one, one, one])).toEqual("m/1'/1'/1'"); - - const min = Slip10RawIndex.hardened(0); - expect(debugPath([min])).toEqual("m/0'"); - - const max = Slip10RawIndex.hardened(2 ** 31 - 1); - expect(debugPath([max])).toEqual("m/2147483647'"); - }); - - it("works for mixed components", () => { - const one = Slip10RawIndex.normal(1); - const two = Slip10RawIndex.hardened(2); - expect(debugPath([one, two, two, one])).toEqual("m/1/2'/2'/1"); - }); - }); -}); diff --git a/packages/faucet/src/hdpaths.ts b/packages/faucet/src/hdpaths.ts deleted file mode 100644 index f61e35ba..00000000 --- a/packages/faucet/src/hdpaths.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Slip10RawIndex } from "@iov/crypto"; - -export function debugPath(path: readonly Slip10RawIndex[]): string { - return path.reduce((current, component): string => { - const componentString = component.isHardened() - ? `${component.toNumber() - 2 ** 31}'` - : component.toString(); - return current + "/" + componentString; - }, "m"); -} diff --git a/packages/faucet/src/profile.ts b/packages/faucet/src/profile.ts index 2a870c50..186993f0 100644 --- a/packages/faucet/src/profile.ts +++ b/packages/faucet/src/profile.ts @@ -1,6 +1,5 @@ import { makeCosmoshubPath, Pen, Secp256k1Pen } from "@cosmjs/sdk38"; - -import { debugPath } from "./hdpaths"; +import { pathToString } from "@iov/crypto"; export async function createPens( mnemonic: string, @@ -18,7 +17,7 @@ export async function createPens( const address = pen.address(addressPrefix); if (logging) { const role = i === 0 ? "token holder " : `distributor ${i}`; - console.info(`Created ${role} (${debugPath(path)}): ${address}`); + console.info(`Created ${role} (${pathToString(path)}): ${address}`); } pens.push([address, pen]); }