diff --git a/cw_wownero/lib/wownero_wallet.dart b/cw_wownero/lib/wownero_wallet.dart index 0524a9348..6946d2138 100644 --- a/cw_wownero/lib/wownero_wallet.dart +++ b/cw_wownero/lib/wownero_wallet.dart @@ -19,9 +19,6 @@ import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wownero_amount_format.dart'; import 'package:cw_core/wownero_balance.dart'; -import 'package:cw_core/wownero_amount_format.dart'; -import 'package:cw_core/wownero_balance.dart'; -import 'package:cw_wownero/api/account_list.dart'; import 'package:cw_wownero/api/coins_info.dart'; import 'package:cw_wownero/api/structs/pending_transaction.dart'; import 'package:cw_wownero/api/transaction_history.dart' as transaction_history; @@ -49,11 +46,11 @@ const MIN_RESTORE_HEIGHT = 1000; class WowneroWallet = WowneroWalletBase with _$WowneroWallet; -abstract class WowneroWalletBase extends WalletBase with Store { +abstract class WowneroWalletBase + extends WalletBase + with Store { WowneroWalletBase( - {required WalletInfo walletInfo, - required Box unspentCoinsInfo}) + {required WalletInfo walletInfo, required Box unspentCoinsInfo}) : balance = ObservableMap.of({ CryptoCurrency.xmr: WowneroBalance( fullBalance: wownero_wallet.getFullBalance(accountIndex: 0), @@ -69,17 +66,13 @@ abstract class WowneroWalletBase extends WalletBase walletAddresses.account, (Account? account) { + _onAccountChangeReaction = reaction((_) => walletAddresses.account, (Account? account) { if (account == null) return; - balance = ObservableMap.of({ + balance = ObservableMap.of({ currency: WowneroBalance( - fullBalance: - wownero_wallet.getFullBalance(accountIndex: account.id), - unlockedBalance: - wownero_wallet.getUnlockedBalance(accountIndex: account.id)) + fullBalance: wownero_wallet.getFullBalance(accountIndex: account.id), + unlockedBalance: wownero_wallet.getUnlockedBalance(accountIndex: account.id)) }); _updateSubAddress(isEnabledAutoGenerateSubaddress, account: account); _askForUpdateTransactionHistory(); @@ -134,13 +127,11 @@ abstract class WowneroWalletBase extends WalletBase init() async { await walletAddresses.init(); - balance = ObservableMap.of({ + balance = ObservableMap.of({ currency: WowneroBalance( - fullBalance: wownero_wallet.getFullBalance( - accountIndex: walletAddresses.account!.id), - unlockedBalance: wownero_wallet.getUnlockedBalance( - accountIndex: walletAddresses.account!.id)) + fullBalance: wownero_wallet.getFullBalance(accountIndex: walletAddresses.account!.id), + unlockedBalance: + wownero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account!.id)) }); _setListeners(); await updateTransactions(); @@ -149,13 +140,12 @@ abstract class WowneroWalletBase extends WalletBase await save()); + _autoSaveTimer = + Timer.periodic(Duration(seconds: _autoSaveInterval), (_) async => await save()); } @override @@ -227,8 +217,8 @@ abstract class WowneroWalletBase extends WalletBase[]; final outputs = _credentials.outputs; final hasMultiDestination = outputs.length > 1; - final unlockedBalance = wownero_wallet.getUnlockedBalance( - accountIndex: walletAddresses.account!.id); + final unlockedBalance = + wownero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account!.id); var allInputsAmount = 0; PendingTransactionDescription pendingTransactionDescription; @@ -250,17 +240,15 @@ abstract class WowneroWalletBase extends WalletBase item.sendAll || (item.formattedCryptoAmount ?? 0) <= 0)) { + if (outputs.any((item) => item.sendAll || (item.formattedCryptoAmount ?? 0) <= 0)) { throw WowneroTransactionCreationException( 'You do not have enough XMR to send this amount.'); } - final int totalAmount = outputs.fold( - 0, (acc, value) => acc + (value.formattedCryptoAmount ?? 0)); + final int totalAmount = + outputs.fold(0, (acc, value) => acc + (value.formattedCryptoAmount ?? 0)); - final estimatedFee = - calculateEstimatedFee(_credentials.priority, totalAmount); + final estimatedFee = calculateEstimatedFee(_credentials.priority, totalAmount); if (unlockedBalance < totalAmount) { throw WowneroTransactionCreationException( 'You do not have enough XMR to send this amount.'); @@ -271,28 +259,22 @@ abstract class WowneroWalletBase extends WalletBase changePassword(String password) async => - wownero_wallet.setPasswordSync(password); + Future changePassword(String password) async => wownero_wallet.setPasswordSync(password); Future getNodeHeight() async => wownero_wallet.getNodeHeight(); @@ -482,8 +456,7 @@ abstract class WowneroWalletBase extends WalletBase _refreshUnspentCoinsInfo() async { try { final List keys = []; - final currentWalletUnspentCoins = unspentCoinsInfo.values.where( - (element) => - element.walletId.contains(id) && - element.accountIndex == walletAddresses.account!.id); + final currentWalletUnspentCoins = unspentCoinsInfo.values.where((element) => + element.walletId.contains(id) && element.accountIndex == walletAddresses.account!.id); if (currentWalletUnspentCoins.isNotEmpty) { currentWalletUnspentCoins.forEach((element) { - final existUnspentCoins = unspentCoins - .where((coin) => element.keyImage!.contains(coin.keyImage!)); + final existUnspentCoins = + unspentCoins.where((coin) => element.keyImage!.contains(coin.keyImage!)); if (existUnspentCoins.isEmpty) { keys.add(element.key); @@ -570,17 +541,14 @@ abstract class WowneroWalletBase extends WalletBase - wownero_wallet.getAddress( - accountIndex: accountIndex, addressIndex: addressIndex); + wownero_wallet.getAddress(accountIndex: accountIndex, addressIndex: addressIndex); @override Future> fetchTransactions() async { transaction_history.refreshTransactions(); return _getAllTransactionsOfAccount(walletAddresses.account?.id) - .fold>( - {}, - (Map acc, - WowneroTransactionInfo tx) { + .fold>({}, + (Map acc, WowneroTransactionInfo tx) { acc[tx.id] = tx; return acc; }); @@ -607,17 +575,14 @@ abstract class WowneroWalletBase extends WalletBase wownero_wallet.getSubaddressLabel(accountIndex, addressIndex); - List _getAllTransactionsOfAccount( - int? accountIndex) => + List _getAllTransactionsOfAccount(int? accountIndex) => transaction_history .getAllTransactions() .map( (row) => WowneroTransactionInfo( row.hash, row.blockheight, - row.isSpend - ? TransactionDirection.outgoing - : TransactionDirection.incoming, + row.isSpend ? TransactionDirection.outgoing : TransactionDirection.incoming, row.timeStamp, row.isPending, row.amount, @@ -670,8 +635,7 @@ abstract class WowneroWalletBase extends WalletBase _askForUpdateTransactionHistory() async => - await updateTransactions(); + Future _askForUpdateTransactionHistory() async => await updateTransactions(); - int _getFullBalance() => - wownero_wallet.getFullBalance(accountIndex: walletAddresses.account!.id); + int _getFullBalance() => wownero_wallet.getFullBalance(accountIndex: walletAddresses.account!.id); - int _getUnlockedBalance() => wownero_wallet.getUnlockedBalance( - accountIndex: walletAddresses.account!.id); + int _getUnlockedBalance() => + wownero_wallet.getUnlockedBalance(accountIndex: walletAddresses.account!.id); int _getFrozenBalance() { var frozenBalance = 0; for (var coin in unspentCoinsInfo.values.where((element) => - element.walletId == id && - element.accountIndex == walletAddresses.account!.id)) { + element.walletId == id && element.accountIndex == walletAddresses.account!.id)) { if (coin.isFrozen) frozenBalance += coin.value; } diff --git a/howto-build-android.md b/howto-build-android.md index c3fe415ee..4ad88ea0d 100644 --- a/howto-build-android.md +++ b/howto-build-android.md @@ -8,7 +8,7 @@ The following are the system requirements to build CakeWallet for your Android d Ubuntu >= 20.04 Android SDK 29 or higher (better to have the latest one 33) Android NDK 17c -Flutter 3.10.x or earlier +Flutter 3.19.x or earlier ``` ## Building CakeWallet on Android @@ -55,7 +55,7 @@ You may download and install the latest version of Android Studio [here](https:/ ### 3. Installing Flutter -Need to install flutter with version `3.7.x`. For this please check section [Install Flutter manually](https://docs.flutter.dev/get-started/install/linux#install-flutter-manually). +Need to install flutter with version `3.19.x`. For this please check section [Install Flutter manually](https://docs.flutter.dev/get-started/install/linux#install-flutter-manually). ### 4. Verify Installations @@ -66,7 +66,7 @@ Verify that the Android toolchain, Flutter, and Android Studio have been correct The output of this command will appear like this, indicating successful installations. If there are problems with your installation, they **must** be corrected before proceeding. ``` Doctor summary (to see all details, run flutter doctor -v): -[✓] Flutter (Channel stable, 3.10.x, on Linux, locale en_US.UTF-8) +[✓] Flutter (Channel stable, 3.19.x, on Linux, locale en_US.UTF-8) [✓] Android toolchain - develop for Android devices (Android SDK version 29 or higher) [✓] Android Studio (version 4.0 or higher) ``` @@ -116,10 +116,6 @@ Build the Monero libraries and their dependencies: `$ ./build_all.sh` -Now the dependencies need to be copied into the CakeWallet project with this command: - -`$ ./copy_monero_deps.sh` - It is now time to change back to the base directory of the CakeWallet source code: `$ cd ../../` diff --git a/howto-build-ios.md b/howto-build-ios.md index 3abf3e915..3bb345861 100644 --- a/howto-build-ios.md +++ b/howto-build-ios.md @@ -7,7 +7,7 @@ The following are the system requirements to build CakeWallet for your iOS devic ``` macOS >= 14.0 Xcode 15.3 -Flutter 3.10.x +Flutter 3.19.x ``` ## Building CakeWallet on iOS @@ -30,7 +30,7 @@ You may download and install the latest version of [Xcode](https://developer.app ### 3. Installing Flutter -Need to install flutter with version `3.10.x`. For this please check section [Install Flutter](https://docs.flutter.dev/get-started/install/macos/mobile-ios?tab=download). +Need to install flutter with version `3.19.x`. For this please check section [Install Flutter](https://docs.flutter.dev/get-started/install/macos/mobile-ios?tab=download). ### 4. Verify Installations @@ -41,7 +41,7 @@ Verify that the Flutter and Xcode have been correctly installed on your system w The output of this command will appear like this, indicating successful installations. If there are problems with your installation, they **must** be corrected before proceeding. ``` Doctor summary (to see all details, run flutter doctor -v): -[✓] Flutter (Channel stable, 3.10.x, on macOS 14.x.x) +[✓] Flutter (Channel stable, 3.19.x, on macOS 14.x.x) [✓] Xcode - develop for iOS and macOS (Xcode 15.3) ``` diff --git a/lib/view_model/wallet_keys_view_model.dart b/lib/view_model/wallet_keys_view_model.dart index 99fe719e2..5102ba8eb 100644 --- a/lib/view_model/wallet_keys_view_model.dart +++ b/lib/view_model/wallet_keys_view_model.dart @@ -254,8 +254,7 @@ abstract class WalletKeysViewModelBase with Store { case WalletType.wownero: return 'wownero-wallet'; default: - throw Exception( - 'Unexpected wallet type: ${_appStore.wallet!.toString()}'); + throw Exception('Unexpected wallet type: ${_appStore.wallet!.type.toString()}'); } } diff --git a/lib/view_model/wallet_new_vm.dart b/lib/view_model/wallet_new_vm.dart index 9ea871427..4729a38b2 100644 --- a/lib/view_model/wallet_new_vm.dart +++ b/lib/view_model/wallet_new_vm.dart @@ -58,7 +58,7 @@ abstract class WalletNewVMBase extends WalletCreationVM with Store { } } - bool get hasSeedType => type == WalletType.monero; + bool get hasSeedType => type == WalletType.monero || type == WalletType.wownero; @override WalletCredentials getCredentials(dynamic _options) { diff --git a/scripts/android/pubspec_gen.sh b/scripts/android/pubspec_gen.sh index f20f5886e..468f548f3 100755 --- a/scripts/android/pubspec_gen.sh +++ b/scripts/android/pubspec_gen.sh @@ -10,7 +10,10 @@ case $APP_ANDROID_TYPE in CONFIG_ARGS="--monero" ;; $CAKEWALLET) - CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero" #TODO: fix and add back --haven + CONFIG_ARGS="--monero --bitcoin --ethereum --polygon --nano --bitcoinCash --solana --tron --wownero" + if [ "$CW_WITH_HAVEN" = true ];then + CONFIG_ARGS="$CONFIG_ARGS --haven" + fi ;; $HAVEN) CONFIG_ARGS="--haven"