importAccount method

Future<Map?> importAccount(
  1. Keyring keyring, {
  2. required KeyType keyType,
  3. required String key,
  4. required String name,
  5. required String password,
  6. CryptoType cryptoType = CryptoType.sr25519,
  7. String derivePath = '',
})

Import account from mnemonic/rawSeed/keystore and we get a JSON object. param cryptoType can be sr25519(default) or ed25519. throw error if import failed. return null if keystore password check failed.

Implementation

Future<Map?> importAccount(
  Keyring keyring, {
  required KeyType keyType,
  required String key,
  required String name,
  required String password,
  CryptoType cryptoType = CryptoType.sr25519,
  String derivePath = '',
}) async {
  final acc = await service!.importAccount(
    keyType: keyType,
    key: key,
    name: name,
    password: password,
    cryptoType: cryptoType,
    derivePath: derivePath,
  );
  if (acc == null) {
    return null;
  }
  if (acc['error'] != null) {
    throw Exception(acc['error']);
  }

  return acc;
}