generateMnemonic method

Future<AddressIconDataWithMnemonic> generateMnemonic(
  1. int ss58, {
  2. CryptoType cryptoType = CryptoType.sr25519,
  3. String derivePath = '',
  4. String key = '',
})

Generate a set of new mnemonic.

Implementation

Future<AddressIconDataWithMnemonic> generateMnemonic(int ss58,
    {CryptoType cryptoType = CryptoType.sr25519,
    String derivePath = '',
    String key = ''}) async {
  final String crypto = cryptoType.toString().split('.')[1];
  final isAvatarSupport = (await serviceRoot.webView!.evalJavascript(
          'keyring.addressFromMnemonic ? {}:null',
          wrapPromise: false)) !=
      null;
  final dynamic acc = await serviceRoot.webView!.evalJavascript(
      isAvatarSupport
          ? 'keyring.gen("$key",$ss58,"$crypto","$derivePath")'
          : 'keyring.gen()');
  return AddressIconDataWithMnemonic.fromJson(acc);
}