diff --git a/lib/wallets/example/libepiccash.dart b/lib/wallets/example/libepiccash.dart index 2c0b80a76..ca7d44eef 100644 --- a/lib/wallets/example/libepiccash.dart +++ b/lib/wallets/example/libepiccash.dart @@ -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 _initializeWalletWrapper( - Tuple4 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 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; } - - }