import * as bip39 from 'bip39' ; import { seedToId } from '@transmute/universal-wallet' ; import * as sidetreeCrypto from '@sidetree/crypto' ; import { Mnemonic } from '../types' ; import { UNIVERSAL_WALLET_CONTEXT_URL , placeHolderImage } from '../constants' ; export const toMnemonic = async ( mnemonic ? ) : Promise < Mnemonic > => { if ( ! mnemonic ) { mnemonic = await sidetreeCrypto . generateMnemonic ( ) ; } const seed = await bip39 . mnemonicToSeed ( mnemonic ) ; const id = await seedToId ( seed ) ; return { '@context' : [ UNIVERSAL_WALLET_CONTEXT_URL ] , id , type : 'Mnemonic' , name : 'Sidetree Mnemonic' , image : placeHolderImage , description : 'Generated by @sidetree/wallet.' , tags : [ ] , value : mnemonic } ; } ;