addAccount method
Future<EthWalletData>
addAccount(
- KeyringEVM keyring, {
- required EVMKeyType keyType,
- required Map<
String, dynamic> acc, - required String password,
Add account to local storage.
Implementation
Future<EthWalletData> addAccount(
KeyringEVM keyring, {
required EVMKeyType keyType,
required Map<String, dynamic> acc,
required String password,
}) async {
// save seed and remove it before add account
final type = keyType.toString().split('.')[1];
if (keyType == EVMKeyType.mnemonic || keyType == EVMKeyType.privateKey) {
final String? seed = acc[type];
if (seed != null && seed.isNotEmpty) {
keyring.store
.encryptSeedAndSave(acc['address'], acc[type], type, password);
}
}
acc.remove(type);
// save keystore to storage
await keyring.store.addAccount(acc);
await updateIconsMap(keyring, [acc['address']]);
return EthWalletData.fromJson(acc);
}