Skip to content

Commit

Permalink
wallet-ext:ts-sdk: use named exports from bip39
Browse files Browse the repository at this point in the history
* it seems that `@scure/bip39` doesn't have a default export and that break the wallet
  • Loading branch information
pchrysochoidis committed Sep 30, 2022
1 parent 6356c6d commit 67e2325
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions apps/wallet/src/shared/utils/bip39.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import bip39 from '@scure/bip39';
import {
generateMnemonic as bip39GenerateMnemonic,
validateMnemonic as bip39ValidateMnemonic,
} from '@scure/bip39';
import { wordlist } from '@scure/bip39/wordlists/english';

/**
Expand All @@ -9,7 +12,7 @@ import { wordlist } from '@scure/bip39/wordlists/english';
* @returns a 12 words string separated by spaces.
*/
export function generateMnemonic(): string {
return bip39.generateMnemonic(wordlist);
return bip39GenerateMnemonic(wordlist);
}

/**
Expand All @@ -20,7 +23,7 @@ export function generateMnemonic(): string {
* @returns true if the mnemonic is valid, false otherwise.
*/
export function validateMnemonics(mnemonics: string): boolean {
return bip39.validateMnemonic(mnemonics, wordlist);
return bip39ValidateMnemonic(mnemonics, wordlist);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions sdk/typescript/src/cryptography/mnemonics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
import bip39 from '@scure/bip39';
import { mnemonicToSeedSync as bip39MnemonicToSeedSync } from '@scure/bip39';

/**
* Parse and validate a path that is compliant to SLIP-0010 in form m/44'/784'/{account_index}'/{change_index}'/{address_index}'.
Expand Down Expand Up @@ -33,7 +33,7 @@ export function isValidBIP32Path(path: string): boolean {
* @param mnemonics 12 words string split by spaces.
*/
export function mnemonicToSeed(mnemonics: string): Uint8Array {
return bip39.mnemonicToSeedSync(mnemonics, '');
return bip39MnemonicToSeedSync(mnemonics, '');
}

/**
Expand Down

0 comments on commit 67e2325

Please sign in to comment.