Added some notes/todos and changed usages of Tuple to using the new built in record type instead

This commit is contained in:
julian 2023-09-20 17:04:37 -06:00
parent 3e889a6d27
commit 8ec22ed389

View file

@ -1,6 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_libepiccash/epic_cash.dart' as lib_epiccash;
import 'package:tuple/tuple.dart';
import 'package:mutex/mutex.dart';
///
/// Wrapped up calls to flutter_libepiccash.
@ -21,35 +21,55 @@ abstract class LibEpiccash {
}
}
///
/// Fetch the mnemonic of (some? current?) wallet
///
// TODO: ensure the above documentation comment is correct
// TODO: ensure this will always return the mnemonic. If not, this function should throw an exception
// TODO: probably remove this as we don't use it in stack wallet. We store the mnemonic separately
static String getMnemonic() {
return lib_epiccash.walletMnemonic();
}
// Private function wrapper for compute
static Future<String> _initializeWalletWrapper(
Tuple4<String, String, String, String> data) async {
final String initWalletStr =
lib_epiccash.initWallet(data.item1, data.item2, data.item3, data.item4);
({
String config,
String mnemonic,
String password,
String name,
}) data,
) async {
final String initWalletStr = lib_epiccash.initWallet(
data.config,
data.mnemonic,
data.password,
data.name,
);
return initWalletStr;
}
///
/// Create and or initialize a new epiccash wallet.
///
// TODO: Complete/modify the documentation comment above
// TODO: Should return a void future. On error this function should throw and exception
static Future<String> initializeNewWallet({
required String config,
required String mnemonic,
required String password,
required String name}) async {
String result = await compute(
required String name,
}) async {
final String result = await compute(
_initializeWalletWrapper,
Tuple4(
config,
mnemonic,
password,
name,
(
config: config,
mnemonic: mnemonic,
password: password,
name: name,
),
);
return result;
}
}