From 1ff0e552cb4a55a0921aca817b8cbf43c49a4ced Mon Sep 17 00:00:00 2001 From: baryon2 Date: Tue, 24 Dec 2024 13:56:05 +0530 Subject: [PATCH] pass keytype in custom keygen function --- package.json | 2 +- src/keychain/keychain.ts | 3 ++- src/types/keychain.ts | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index d42a9d3..8b071dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@leapwallet/leap-keychain", - "version": "0.3.3-beta.1", + "version": "0.3.3-beta.2", "description": "A javascript library for crypto key management", "scripts": { "test:coverage": "nyc mocha", diff --git a/src/keychain/keychain.ts b/src/keychain/keychain.ts index ba8f721..2cf1a6c 100644 --- a/src/keychain/keychain.ts +++ b/src/keychain/keychain.ts @@ -118,7 +118,7 @@ export class KeyChain { const pubKeys: Record = {}; for (const chainInfo of chainInfos) { if (chainInfo.customKeygenfn) { - const key = await chainInfo.customKeygenfn(privateKey, getFullHDPath('44', chainInfo.coinType)); + const key = await chainInfo.customKeygenfn(privateKey, getFullHDPath('44', chainInfo.coinType), 'privateKey'); addresses[chainInfo.key] = key.address; pubKeys[chainInfo.key] = key.pubkey; continue; @@ -324,6 +324,7 @@ export class KeyChain { const key = await chainInfo.customKeygenfn( mnemonic, getFullHDPath(purpose, chainInfo.coinType, addressIndex.toString()), + 'seedPhrase', ); addresses[chainInfo.key] = key.address; pubKeys[chainInfo.key] = key.pubkey; diff --git a/src/types/keychain.ts b/src/types/keychain.ts index bf1f3f2..c6a2fa3 100644 --- a/src/types/keychain.ts +++ b/src/types/keychain.ts @@ -39,6 +39,7 @@ export type ChainInfo = { customKeygenfn?: ( key: string, path: string, + keyType: 'privateKey' | 'seedPhrase', ) => Promise<{ address: string; pubkey: string;