From 4f1dc9ef1cf2e03141dcc62c8193a2b5c1fecab1 Mon Sep 17 00:00:00 2001 From: Anderson Juhasc Date: Sun, 26 May 2024 23:04:10 -0300 Subject: [PATCH] fixing formatting with Prettier --- nip06.test.ts | 22 ++++++++++++++++------ nip06.ts | 25 ++++++++++++++++++------- relay.ts | 2 +- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/nip06.test.ts b/nip06.test.ts index 4cf4620..e5b6c16 100644 --- a/nip06.test.ts +++ b/nip06.test.ts @@ -3,7 +3,7 @@ import { privateKeyFromSeedWords, accountFromSeedWords, extendedKeysFromSeedWords, - accountFromExtendedKey + accountFromExtendedKey, } from './nip06.ts' test('generate private key from a mnemonic', async () => { @@ -44,14 +44,23 @@ test('generate extended keys from mnemonic', () => { const mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about' const passphrase = '' const extendedAccountIndex = 0 - const { privateExtendedKey, publicExtendedKey } = extendedKeysFromSeedWords(mnemonic, passphrase, extendedAccountIndex) + const { privateExtendedKey, publicExtendedKey } = extendedKeysFromSeedWords( + mnemonic, + passphrase, + extendedAccountIndex, + ) - expect(privateExtendedKey).toBe('xprv9z78fizET65qsCaRr1MSutTSGk1fcKfSt1sBqmuWShtkjRJJ4WCKcSnha6EmgNzFSsyom3MWtydHyPtJtSLZQUtictVQtM2vkPcguh6TQCH') - expect(publicExtendedKey).toBe('xpub6D6V5EX8HTe95getx2tTH2QApmrA1nPJFEnneAK813RjcDdSc3WaAF7BRNpTF7o7zXjVm3DD3VMX66jhQ7wLaZ9sS6NzyfiwfzqDZbxvpDN') + expect(privateExtendedKey).toBe( + 'xprv9z78fizET65qsCaRr1MSutTSGk1fcKfSt1sBqmuWShtkjRJJ4WCKcSnha6EmgNzFSsyom3MWtydHyPtJtSLZQUtictVQtM2vkPcguh6TQCH', + ) + expect(publicExtendedKey).toBe( + 'xpub6D6V5EX8HTe95getx2tTH2QApmrA1nPJFEnneAK813RjcDdSc3WaAF7BRNpTF7o7zXjVm3DD3VMX66jhQ7wLaZ9sS6NzyfiwfzqDZbxvpDN', + ) }) test('generate account from extended private key', () => { - const xprv = 'xprv9z78fizET65qsCaRr1MSutTSGk1fcKfSt1sBqmuWShtkjRJJ4WCKcSnha6EmgNzFSsyom3MWtydHyPtJtSLZQUtictVQtM2vkPcguh6TQCH' + const xprv = + 'xprv9z78fizET65qsCaRr1MSutTSGk1fcKfSt1sBqmuWShtkjRJJ4WCKcSnha6EmgNzFSsyom3MWtydHyPtJtSLZQUtictVQtM2vkPcguh6TQCH' const { privateKey, publicKey } = accountFromExtendedKey(xprv) expect(privateKey).toBe('5f29af3b9676180290e77a4efad265c4c2ff28a5302461f73597fda26bb25731') @@ -59,7 +68,8 @@ test('generate account from extended private key', () => { }) test('generate account from extended public key', () => { - const xpub = 'xpub6D6V5EX8HTe95getx2tTH2QApmrA1nPJFEnneAK813RjcDdSc3WaAF7BRNpTF7o7zXjVm3DD3VMX66jhQ7wLaZ9sS6NzyfiwfzqDZbxvpDN' + const xpub = + 'xpub6D6V5EX8HTe95getx2tTH2QApmrA1nPJFEnneAK813RjcDdSc3WaAF7BRNpTF7o7zXjVm3DD3VMX66jhQ7wLaZ9sS6NzyfiwfzqDZbxvpDN' const { publicKey } = accountFromExtendedKey(xpub) expect(publicKey).toBe('e8bcf3823669444d0b49ad45d65088635d9fd8500a75b5f20b59abefa56a144f') diff --git a/nip06.ts b/nip06.ts index 960035e..a04c744 100644 --- a/nip06.ts +++ b/nip06.ts @@ -12,9 +12,13 @@ export function privateKeyFromSeedWords(mnemonic: string, passphrase?: string, a return bytesToHex(privateKey) } -export function accountFromSeedWords(mnemonic: string, passphrase?: string, accountIndex = 0): { - privateKey: string, - publicKey: string, +export function accountFromSeedWords( + mnemonic: string, + passphrase?: string, + accountIndex = 0, +): { + privateKey: string + publicKey: string } { const root = HDKey.fromMasterSeed(mnemonicToSeedSync(mnemonic, passphrase)) const seed = root.derive(`${DERIVATION_PATH}/${accountIndex}'/0/0`) @@ -26,8 +30,12 @@ export function accountFromSeedWords(mnemonic: string, passphrase?: string, acco return { privateKey, publicKey } } -export function extendedKeysFromSeedWords(mnemonic: string, passphrase?: string, extendedAccountIndex = 0): { - privateExtendedKey: string, +export function extendedKeysFromSeedWords( + mnemonic: string, + passphrase?: string, + extendedAccountIndex = 0, +): { + privateExtendedKey: string publicExtendedKey: string } { let root = HDKey.fromMasterSeed(mnemonicToSeedSync(mnemonic, passphrase)) @@ -38,8 +46,11 @@ export function extendedKeysFromSeedWords(mnemonic: string, passphrase?: string, return { privateExtendedKey, publicExtendedKey } } -export function accountFromExtendedKey(base58key: string, accountIndex = 0): { - privateKey?: string, +export function accountFromExtendedKey( + base58key: string, + accountIndex = 0, +): { + privateKey?: string publicKey: string } { let extendedKey = HDKey.fromExtendedKey(base58key) diff --git a/relay.ts b/relay.ts index 2753b5e..3cb0dea 100644 --- a/relay.ts +++ b/relay.ts @@ -20,6 +20,6 @@ export class Relay extends AbstractRelay { } } -export type RelayRecord = Record; +export type RelayRecord = Record export * from './abstract-relay.ts'