Skip to content

Commit 528e022

Browse files
modifying all functions to accept an object as a parameter and return object too
1 parent 4842a0e commit 528e022

10 files changed

+140
-80
lines changed

README.md

+8-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const mnemonic = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong'
2121
const passphrase = 'your super secure passphrase' // optional
2222
const accountIndex = 0
2323

24-
const { privateKey, publicKey } = accountFromSeedWords(mnemonic, passphrase, accountIndex)
24+
const { privateKey, publicKey } = accountFromSeedWords({ mnemonic, passphrase, accountIndex })
2525
```
2626

2727
```js
@@ -41,11 +41,11 @@ import {
4141

4242
const privateKey = '5f29af3b9676180290e77a4efad265c4c2ff28a5302461f73597fda26bb25731'
4343

44-
const { publicKey } = getPublicKey(privateKey)
45-
const nsec = getBech32PrivateKey(privateKey)
46-
const npub = getBech32PublicKey(publicKey.hex)
44+
const { publicKey } = getPublicKey({ privateKey })
45+
const { bech32PrivateKey } = getBech32PrivateKey({ privateKey })
46+
const { bech32PublicKey } = getBech32PublicKey({ publicKey.hex })
4747
// or
48-
const npub = publicKey.bech32
48+
const bech32PublicKey2 = publicKey.bech32
4949
```
5050

5151
```js
@@ -56,12 +56,11 @@ import {
5656

5757
const mnemonic = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong'
5858
const passphrase = 'your super secure passphrase' // optional
59-
6059
const extendedAccountIndex = 0
6160
const accountIndex = 0
6261

63-
const { privateExtendedKey, publicExtendedKey } = extendedKeysFromSeedWords(mnemonic, passphrase, extendedAccountIndex)
64-
const { privateKey, publicKey } = accountFromExtendedKey(privateExtendedKey, accountIndex)
62+
const { privateExtendedKey, publicExtendedKey } = extendedKeysFromSeedWords({ mnemonic, passphrase, extendedAccountIndex })
63+
const { privateKey, publicKey } = accountFromExtendedKey({ base58Key: privateExtendedKey, accountIndex })
6564
```
6665

6766
```js
@@ -72,5 +71,5 @@ import {
7271
const publicExtendedKey = 'xpub6C2FTj1fmB2GES9CSxbXYtrve372NjoHLLQxYRGb9qXbMWBLdDH5qQ7pm29LQuYaF4HzFUsdkcj4jurBU3ebF7xkVNbVTY3MCp9mEiX4Te5'
7372
const accountIndex = 0
7473

75-
const { publicKey } = accountFromExtendedKey(publicExtendedKey, accountIndex)
74+
const { publicKey } = accountFromExtendedKey({ base58Key: publicExtendedKey, accountIndex })
7675
```

src/index.ts

+65-40
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,39 @@ import {
88
} from '@scure/bip39'
99
import { bech32 } from 'bech32'
1010
import { wordlist } from '@scure/bip39/wordlists/english'
11-
import { DERIVATION_PATH, PUBLIC_KEY_PREFIX, SECRET_KEY_PREFIX } from './constants'
11+
import {
12+
DERIVATION_PATH,
13+
PUBLIC_KEY_PREFIX,
14+
SECRET_KEY_PREFIX
15+
} from './constants'
1216

13-
type ExtendedKeys = {
14-
privateExtendedKey: string,
15-
publicExtendedKey: string
16-
}
17-
type PrivateKey = { hex: string, bech32: string }
18-
type PublicKey = { hex: string, bech32: string }
19-
type Account = {
20-
privateKey: PrivateKey,
21-
publicKey: PublicKey
22-
}
17+
import {
18+
ExtendedKeys,
19+
Key,
20+
Account,
21+
} from './types'
2322

24-
export function accountFromSeedWords(mnemonic: string, passphrase?: string, accountIndex = 0): Account {
23+
export function accountFromSeedWords({
24+
mnemonic,
25+
passphrase,
26+
accountIndex = 0
27+
} : {
28+
mnemonic: string,
29+
passphrase?: string,
30+
accountIndex?: number
31+
}): Account {
2532
const root = HDKey.fromMasterSeed(mnemonicToSeedSync(mnemonic, passphrase))
2633
const seed = root.derive(`${DERIVATION_PATH}/${accountIndex}'/0/0`)
2734
const privateKeyHex = bytesToHex(seed.privateKey!)
2835
const publicKeyHex = bytesToHex(seed.publicKey!.slice(1))
2936
if (!privateKeyHex && !publicKeyHex) {
3037
throw new Error('could not derive key pair')
3138
}
32-
const privateKeyBech32 = getBech32PrivateKey(privateKeyHex)
33-
const publicKeyBech32 = getBech32PublicKey(publicKeyHex)
39+
const { bech32PrivateKey } = getBech32PrivateKey({ privateKey: privateKeyHex })
40+
const { bech32PublicKey } = getBech32PublicKey({ publicKey: publicKeyHex })
3441
return {
35-
privateKey: { hex: privateKeyHex, bech32: privateKeyBech32 },
36-
publicKey: { hex: publicKeyHex, bech32: publicKeyBech32 }
42+
privateKey: { hex: privateKeyHex, bech32: bech32PrivateKey },
43+
publicKey: { hex: publicKeyHex, bech32: bech32PublicKey }
3744
}
3845
}
3946

@@ -43,28 +50,36 @@ export function accountFromRandomKey(): Account {
4350
if (!privateKeyHex && !publicKeyHex) {
4451
throw new Error('could not derive key pair')
4552
}
46-
const privateKeyBech32 = getBech32PrivateKey(privateKeyHex)
47-
const publicKeyBech32 = getBech32PublicKey(publicKeyHex)
53+
const { bech32PrivateKey } = getBech32PrivateKey({ privateKey: privateKeyHex })
54+
const { bech32PublicKey } = getBech32PublicKey({ publicKey: publicKeyHex })
4855
return {
49-
privateKey: { hex: privateKeyHex, bech32: privateKeyBech32 },
50-
publicKey: { hex: publicKeyHex, bech32: publicKeyBech32 }
56+
privateKey: { hex: privateKeyHex, bech32: bech32PrivateKey },
57+
publicKey: { hex: publicKeyHex, bech32: bech32PublicKey }
5158
}
5259
}
5360

54-
export function getPublicKey(privateKey: string): {
55-
publicKey: PublicKey
61+
export function getPublicKey({ privateKey }: { privateKey: string }): {
62+
publicKey: Key
5663
} {
5764
const publicKeyHex = bytesToHex(schnorr.getPublicKey(privateKey))
5865
if (!publicKeyHex) {
5966
throw new Error('could not generate public key')
6067
}
61-
const publicKeyBech32 = getBech32PublicKey(publicKeyHex)
68+
const { bech32PublicKey } = getBech32PublicKey({ publicKey: publicKeyHex })
6269
return {
63-
publicKey: { hex: publicKeyHex, bech32: publicKeyBech32 }
70+
publicKey: { hex: publicKeyHex, bech32: bech32PublicKey }
6471
}
6572
}
6673

67-
export function extendedKeysFromSeedWords(mnemonic: string, passphrase?: string, extendedAccountIndex = 0): ExtendedKeys {
74+
export function extendedKeysFromSeedWords({
75+
mnemonic,
76+
passphrase,
77+
extendedAccountIndex = 0
78+
} : {
79+
mnemonic: string,
80+
passphrase?: string,
81+
extendedAccountIndex?: number
82+
}): ExtendedKeys {
6883
let root = HDKey.fromMasterSeed(mnemonicToSeedSync(mnemonic, passphrase))
6984
let seed = root.derive(`${DERIVATION_PATH}/${extendedAccountIndex}'`)
7085
let privateExtendedKey = seed.privateExtendedKey
@@ -73,39 +88,49 @@ export function extendedKeysFromSeedWords(mnemonic: string, passphrase?: string,
7388
return { privateExtendedKey, publicExtendedKey }
7489
}
7590

76-
export function accountFromExtendedKey(base58key: string, accountIndex = 0): {
77-
privateKey?: PrivateKey,
78-
publicKey: PublicKey
91+
export function accountFromExtendedKey({
92+
base58Key,
93+
accountIndex = 0
94+
} : {
95+
base58Key: string,
96+
accountIndex?: number
97+
}): {
98+
privateKey?: Key,
99+
publicKey: Key
79100
} {
80-
let extendedKey = HDKey.fromExtendedKey(base58key)
81-
let version = base58key.slice(0, 4)
101+
let extendedKey = HDKey.fromExtendedKey(base58Key)
102+
let version = base58Key.slice(0, 4)
82103
let child = extendedKey.deriveChild(0).deriveChild(accountIndex)
83104
let publicKeyHex = bytesToHex(child.publicKey!.slice(1))
84105
if (!publicKeyHex) throw new Error('could not derive public key')
85-
let publicKeyBech32 = getBech32PublicKey(publicKeyHex)
106+
const { bech32PublicKey } = getBech32PublicKey({ publicKey: publicKeyHex })
86107
if (version === 'xprv') {
87108
let privateKeyHex = bytesToHex(child.privateKey!)
88109
if (!privateKeyHex) throw new Error('could not derive private key')
89-
let privateKeyBech32 = getBech32PrivateKey(privateKeyHex)
110+
const { bech32PrivateKey } = getBech32PrivateKey({ privateKey: privateKeyHex })
90111
return {
91-
privateKey: { hex: privateKeyHex, bech32: privateKeyBech32 },
92-
publicKey: { hex: publicKeyHex, bech32: publicKeyBech32 }
112+
privateKey: { hex: privateKeyHex, bech32: bech32PrivateKey },
113+
publicKey: { hex: publicKeyHex, bech32: bech32PublicKey }
93114
}
94115
}
95-
return { publicKey: { hex: publicKeyHex, bech32: publicKeyBech32 } }
116+
return { publicKey: { hex: publicKeyHex, bech32: bech32PublicKey } }
96117
}
97118

98119
function hexToBech32(key: string, prefix: string) {
99120
const words = bech32.toWords(hexToBytes(key))
100121
return bech32.encode(prefix, words)
101122
}
102123

103-
export function getBech32PrivateKey(privateKey: string): string {
104-
return hexToBech32(privateKey, SECRET_KEY_PREFIX)
124+
export function getBech32PrivateKey({ privateKey }: { privateKey: string }): { bech32PrivateKey: string } {
125+
return {
126+
bech32PrivateKey: hexToBech32(privateKey, SECRET_KEY_PREFIX)
127+
}
105128
}
106129

107-
export function getBech32PublicKey(publicKey: string): string {
108-
return hexToBech32(publicKey, PUBLIC_KEY_PREFIX)
130+
export function getBech32PublicKey({ publicKey }: { publicKey: string }): { bech32PublicKey: string } {
131+
return {
132+
bech32PublicKey: hexToBech32(publicKey, PUBLIC_KEY_PREFIX)
133+
}
109134
}
110135

111136
export function generateSeedWords(): { mnemonic: string } {
@@ -114,7 +139,7 @@ export function generateSeedWords(): { mnemonic: string } {
114139
}
115140
}
116141

117-
export function validateWords(mnemonic: string): { isMnemonicValid: boolean } {
142+
export function validateWords({ mnemonic }: { mnemonic: string }): { isMnemonicValid: boolean } {
118143
return {
119144
isMnemonicValid: validateMnemonic(mnemonic, wordlist)
120145
}

src/types.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export type Key = {
2+
hex: string,
3+
bech32: string
4+
}
5+
export type Account = {
6+
privateKey: Key,
7+
publicKey: Key
8+
}
9+
export type ExtendedKeys = {
10+
privateExtendedKey: string,
11+
publicExtendedKey: string
12+
}

tests/accountFromExtendedKey.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { accountFromExtendedKey } from '../src/index'
33

44
describe('accountFromExtendedKey', () => {
55
it('should get account from extended private key', () => {
6-
const { privateKey, publicKey } = accountFromExtendedKey('xprv9z78fizET65qsCaRr1MSutTSGk1fcKfSt1sBqmuWShtkjRJJ4WCKcSnha6EmgNzFSsyom3MWtydHyPtJtSLZQUtictVQtM2vkPcguh6TQCH')
6+
const base58Key = 'xprv9z78fizET65qsCaRr1MSutTSGk1fcKfSt1sBqmuWShtkjRJJ4WCKcSnha6EmgNzFSsyom3MWtydHyPtJtSLZQUtictVQtM2vkPcguh6TQCH'
7+
const { privateKey, publicKey } = accountFromExtendedKey({ base58Key })
78

89
expect(privateKey?.hex).toBe('5f29af3b9676180290e77a4efad265c4c2ff28a5302461f73597fda26bb25731')
910
expect(privateKey?.bech32).toBe('nsec1tu567wukwcvq9y880f8045n9cnp07299xqjxrae4jl76y6aj2ucs2mkupq')
@@ -12,7 +13,8 @@ describe('accountFromExtendedKey', () => {
1213
})
1314

1415
it('should get account from extended public key', () => {
15-
const { publicKey } = accountFromExtendedKey('xpub6D6V5EX8HTe95getx2tTH2QApmrA1nPJFEnneAK813RjcDdSc3WaAF7BRNpTF7o7zXjVm3DD3VMX66jhQ7wLaZ9sS6NzyfiwfzqDZbxvpDN')
16+
const base58Key = 'xpub6D6V5EX8HTe95getx2tTH2QApmrA1nPJFEnneAK813RjcDdSc3WaAF7BRNpTF7o7zXjVm3DD3VMX66jhQ7wLaZ9sS6NzyfiwfzqDZbxvpDN'
17+
const { publicKey } = accountFromExtendedKey({ base58Key })
1618

1719
expect(publicKey.hex).toBe('e8bcf3823669444d0b49ad45d65088635d9fd8500a75b5f20b59abefa56a144f')
1820
expect(publicKey.bech32).toBe('npub1az708q3kd9zy6z6f44zav5ygvdwelkzspf6mtusttx47lft2z38sghk0w7')

tests/accountFromSeedWords.test.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,35 @@ describe('accountFromSeedWords', () => {
88
})
99

1010
it('should get a 64 bytes hex private key from mnemonic', () => {
11-
const accountIndex = 0
12-
const { privateKey: sk1 } = accountFromSeedWords('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', '', accountIndex)
13-
const { privateKey: sk2 } = accountFromSeedWords('zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong', '', accountIndex)
14-
const { privateKey: sk3 } = accountFromSeedWords('bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon', '', accountIndex)
11+
const { privateKey: sk1 } = accountFromSeedWords({
12+
mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
13+
accountIndex: 0
14+
})
15+
const { privateKey: sk2 } = accountFromSeedWords({
16+
mnemonic: 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong',
17+
accountIndex: 0
18+
})
19+
const { privateKey: sk3 } = accountFromSeedWords({
20+
mnemonic: 'bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon',
21+
accountIndex: 0
22+
})
1523

1624
expect(sk1.hex).toBe('5f29af3b9676180290e77a4efad265c4c2ff28a5302461f73597fda26bb25731')
1725
expect(sk2.hex).toBe('c26cf31d8ba425b555ca27d00ca71b5008004f2f662470f8c8131822ec129fe2')
1826
expect(sk3.hex).toBe('45049983ec1e38aa8a4a7d76b0203a4484d9a1d3120017cfd455e80aac2d52e4')
1927
})
2028

2129
it('should get a 64 bytes hex private key from mnemonic and passphrase', () => {
22-
const { privateKey } = accountFromSeedWords('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about', '123')
30+
const { privateKey } = accountFromSeedWords({
31+
mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about',
32+
passphrase: '123'
33+
})
2334
expect(privateKey.hex).toBe('60ecd7942071530818b4f3cf42e402b5c946b3ce387606d134c4613e59fa0196')
2435
})
2536

2637
it('should thow an error when a invalid mnemonic is provided', () => {
2738
const fn = () => {
28-
accountFromSeedWords('invalid words')
39+
accountFromSeedWords({ mnemonic: 'invalid words' })
2940
}
3041
expect(fn).toThrowError('Invalid mnemonic')
3142
})

tests/bech32.test.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,23 @@ describe('bech32 formats', () => {
1212
})
1313

1414
it('should generate a valid bech32 private and public key', () => {
15-
const mnemonic = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
16-
const { privateKey } = accountFromSeedWords(mnemonic)
17-
const { publicKey } = getPublicKey(privateKey.hex)
18-
const bech32PrivateKey = getBech32PrivateKey(privateKey.hex)
19-
const bech32PublicKey = getBech32PublicKey(publicKey.hex)
15+
const { privateKey } = accountFromSeedWords({
16+
mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
17+
})
18+
const { publicKey } = getPublicKey({ privateKey: privateKey.hex })
19+
const { bech32PrivateKey } = getBech32PrivateKey({ privateKey: privateKey.hex })
20+
const { bech32PublicKey } = getBech32PublicKey({ publicKey: publicKey.hex })
2021
expect(bech32PrivateKey).toBe('nsec1tu567wukwcvq9y880f8045n9cnp07299xqjxrae4jl76y6aj2ucs2mkupq')
2122
expect(bech32PublicKey).toBe('npub1az708q3kd9zy6z6f44zav5ygvdwelkzspf6mtusttx47lft2z38sghk0w7')
2223
})
2324

2425
it('should generate a valid bech32 private and public key', () => {
25-
const mnemonic = 'bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon'
26-
const { privateKey } = accountFromSeedWords(mnemonic)
27-
const { publicKey } = getPublicKey(privateKey.hex)
28-
const bech32PrivateKey = getBech32PrivateKey(privateKey.hex)
29-
const bech32PublicKey = getBech32PublicKey(publicKey.hex)
26+
const { privateKey } = accountFromSeedWords({
27+
mnemonic: 'bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon'
28+
})
29+
const { publicKey } = getPublicKey({ privateKey: privateKey.hex })
30+
const { bech32PrivateKey } = getBech32PrivateKey({ privateKey: privateKey.hex })
31+
const { bech32PublicKey } = getBech32PublicKey({ publicKey: publicKey.hex })
3032
expect(bech32PrivateKey).toBe('nsec1g5zfnqlvrcu24zj204mtqgp6gjzdngwnzgqp0n752h5q4tpd2tjq5khznp')
3133
expect(bech32PublicKey).toBe('npub1s566ayhl06xkt4k3fk5ttvygjjhtkj8gndfflf3qmv2qpq7xhd2sy3ukkd')
3234
})

tests/extendedKeysFromSeedWords.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { extendedKeysFromSeedWords } from '../src/index'
33

44
describe('extendedPairFromSeedWords', () => {
55
it('should get extended keys pair from mnemonic', () => {
6-
const { privateExtendedKey, publicExtendedKey } = extendedKeysFromSeedWords('abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about')
6+
const { privateExtendedKey, publicExtendedKey } = extendedKeysFromSeedWords({
7+
mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
8+
})
79

810
expect(privateExtendedKey).toBe('xprv9z78fizET65qsCaRr1MSutTSGk1fcKfSt1sBqmuWShtkjRJJ4WCKcSnha6EmgNzFSsyom3MWtydHyPtJtSLZQUtictVQtM2vkPcguh6TQCH')
911
expect(publicExtendedKey).toBe('xpub6D6V5EX8HTe95getx2tTH2QApmrA1nPJFEnneAK813RjcDdSc3WaAF7BRNpTF7o7zXjVm3DD3VMX66jhQ7wLaZ9sS6NzyfiwfzqDZbxvpDN')

tests/generateSeedWords.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { generateSeedWords, validateWords } from '../src/index'
44
describe('generateSeedWords', () => {
55
it('should generate a valid mnemonic', () => {
66
const { mnemonic } = generateSeedWords()
7-
const { isMnemonicValid } = validateWords(mnemonic)
7+
const { isMnemonicValid } = validateWords({ mnemonic })
88
expect(isMnemonicValid).toBeTruthy()
99
})
1010
})

tests/getPublicKey.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const PUBLIC_KEY = '8a82a85afb75adb8544cb32b8ff7172803922308b59fa06d66d1120ead61
77
describe('getPublicKey', () => {
88
it('should generate a 64 bytes hex', () => {
99
const privateKey = PRIVATE_KEY
10-
const { publicKey } = getPublicKey(privateKey)
10+
const { publicKey } = getPublicKey({ privateKey })
1111
expect(publicKey.hex).toHaveLength(64)
1212
expect(publicKey.hex).toBe(PUBLIC_KEY)
1313
})

tests/validateWords.test.ts

+17-10
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,28 @@ import { validateWords } from '../src/index'
33

44
describe('validateWords', () => {
55
it('should return false when words are invalid', () => {
6-
const mnemonic1 = 'invalid words'
7-
const { isMnemonicValid: isInvalid1 } = validateWords(mnemonic1)
8-
const mnemonic2 = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon zebra'
9-
const { isMnemonicValid: isInvalid2 } = validateWords(mnemonic2)
6+
const { isMnemonicValid: isInvalid1 } = validateWords({
7+
mnemonic: 'invalid words'
8+
})
9+
const { isMnemonicValid: isInvalid2 } = validateWords({
10+
mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon zebra'
11+
})
12+
1013
expect(isInvalid1).toBeFalsy()
1114
expect(isInvalid2).toBeFalsy()
1215
})
1316

1417
it('should return true when words are valid', () => {
15-
const mnemonic1 = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
16-
const mnemonic2 = 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong'
17-
const mnemonic3 = 'bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon'
18-
const { isMnemonicValid: isValid1 } = validateWords(mnemonic1)
19-
const { isMnemonicValid: isValid2 } = validateWords(mnemonic2)
20-
const { isMnemonicValid: isValid3 } = validateWords(mnemonic3)
18+
const { isMnemonicValid: isValid1 } = validateWords({
19+
mnemonic: 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about'
20+
})
21+
const { isMnemonicValid: isValid2 } = validateWords({
22+
mnemonic: 'zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong'
23+
})
24+
const { isMnemonicValid: isValid3 } = validateWords({
25+
mnemonic: 'bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon bacon'
26+
})
27+
2128
expect(isValid1).toBeTruthy()
2229
expect(isValid2).toBeTruthy()
2330
expect(isValid3).toBeTruthy()

0 commit comments

Comments
 (0)