saveMnemonic method
Persists the mnemonic to disk.
mnemonic
is the mnemonic to persist.
mnemonicName
is the filepath to persist the mnemonic to.
Returns nothing if successful. If persisting fails due to an underlying cause, returns a WalletKeyException.
Implementation
@override
Future<Either<WalletKeyException, Unit>> saveMnemonic(
List<String> mnemonic, String mnemonicName) async {
if (await _storage.containsKey(key: mnemonicName)) {
await _storage.write(key: mnemonicName, value: jsonEncode(mnemonic));
return Either.unit();
} else {
return Either.left(
WalletKeyException.mnemonicDoesNotExist(context: mnemonicName));
}
}