Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
adonesky1 committed Dec 7, 2022
1 parent eaabaf3 commit dec8e7c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,14 @@ class HdKeyring {
const appKeyAddress = normalize(
publicToAddress(wallet.publicKey).toString('hex'),
);

return appKeyAddress;
}

// exportAccount should return a hex-encoded private key:
async exportAccount(address, opts = {}) {
const wallet = this._getWalletForAccount(address, opts);
return bytesToHex(wallet.privKeyBytes);
return bytesToHex(wallet.privateKey);
}

// tx is an instance of the ethereumjs-transaction class.
Expand Down Expand Up @@ -188,8 +189,9 @@ class HdKeyring {
// For eth_decryptMessage:
async decryptMessage(withAccount, encryptedData) {
const wallet = this._getWalletForAccount(withAccount);
const { privateKey } = wallet;
const sig = decrypt({ privateKey, encryptedData });
const { privateKey: privateKeyAsUint8Array } = wallet;
const privateKeyAsHex = Buffer.from(privateKeyAsUint8Array).toString('hex');
const sig = decrypt({ privateKey: privateKeyAsHex, encryptedData });
return sig;
}

Expand All @@ -208,7 +210,8 @@ class HdKeyring {
return signTypedData({ privateKey, data: typedData, version });
}

removeAccount(address) {
removeAccount(account) {
const address = normalize(account);
if (
!this._wallets
.map(({ publicKey }) => this._addressfromPublicKey(publicKey))
Expand Down Expand Up @@ -293,7 +296,9 @@ class HdKeyring {

// small helper function to convert publicKey in Uint8Array form to a publicAddress as a hex
_addressfromPublicKey(publicKey) {
return bufferToHex(publicToAddress(Buffer.from(publicKey), true));
return bufferToHex(
publicToAddress(Buffer.from(publicKey), true),
).toLowerCase();
}
}

Expand Down

0 comments on commit dec8e7c

Please sign in to comment.