From 9996bd3e39225f814d6610bb3dcc7b6381123b84 Mon Sep 17 00:00:00 2001 From: Pavel Prichodko <14926950+prichodko@users.noreply.github.com> Date: Mon, 13 Jun 2022 19:19:15 +0200 Subject: [PATCH] fix: add username to account --- packages/status-js/src/account.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/status-js/src/account.ts b/packages/status-js/src/account.ts index e292e767..bd18a02e 100644 --- a/packages/status-js/src/account.ts +++ b/packages/status-js/src/account.ts @@ -2,10 +2,13 @@ import { keccak256 } from 'ethereum-cryptography/keccak' import { getPublicKey, sign, utils } from 'ethereum-cryptography/secp256k1' import { bytesToHex, concatBytes } from 'ethereum-cryptography/utils' +import { generateUsername } from './utils/generate-username' + export class Account { public privateKey: string public publicKey: string public chatKey: string + public username: string constructor() { const privateKey = utils.randomPrivateKey() @@ -14,9 +17,9 @@ export class Account { this.privateKey = bytesToHex(privateKey) this.publicKey = bytesToHex(publicKey) - // TODO?: add 0x prefix to public key this.chatKey = bytesToHex(chatKey) + this.username = generateUsername('0x' + this.publicKey) } // sig must be a 65-byte compact ECDSA signature containing the recovery id as the last element.