Skip to content

Commit

Permalink
fix: generateMnemonic words length (#3630)
Browse files Browse the repository at this point in the history
  • Loading branch information
sidmorizon authored Oct 11, 2023
1 parent 19872aa commit 0d8cf15
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions packages/engine/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ import type {
import type { Token } from './types/token';
import type { Wallet } from './types/wallet';
import type { IUnsignedMessageBtc } from './vaults/impl/btc/types';
import type VaultEvm from './vaults/impl/evm/Vault';
import type {
IEncodedTxEvm,
IUnsignedMessageEvm,
} from './vaults/impl/evm/Vault';
import type VaultEvm from './vaults/impl/evm/Vault';
import type VaultSol from './vaults/impl/sol/Vault';
import type {
IClientEndpointStatus,
Expand Down Expand Up @@ -206,7 +206,11 @@ class Engine {

@backgroundMethod()
generateMnemonic(): Promise<string> {
return Promise.resolve(bip39.generateMnemonic(256));
// 24 words
// return Promise.resolve(bip39.generateMnemonic(256));

// 12 words
return Promise.resolve(bip39.generateMnemonic());
}

@backgroundMethod()
Expand Down Expand Up @@ -372,7 +376,9 @@ class Engine {
await this.validator.validatePasswordStrength(password);

const [usedMnemonic] = await Promise.all([
this.validator.validateMnemonic(mnemonic || bip39.generateMnemonic(256)),
this.validator.validateMnemonic(
mnemonic || (await this.generateMnemonic()),
),
this.validator.validateHDWalletNumber(),
]);

Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/secret/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ test('Basic mnemonic & seed tests', () => {
});

test('Mnemonic generation', () => {
const mnemonic = bip39.generateMnemonic(256);
const mnemonic = bip39.generateMnemonic();
const rs = revealableSeedFromMnemonic(mnemonic, password);
expect(
mnemonicFromEntropy(rs.entropyWithLangPrefixed, password),
Expand Down

0 comments on commit 0d8cf15

Please sign in to comment.