diff --git a/.github/workflows/no_print_in_dart.yaml b/.github/workflows/no_print_in_dart.yaml new file mode 100644 index 000000000..8cd24edfe --- /dev/null +++ b/.github/workflows/no_print_in_dart.yaml @@ -0,0 +1,21 @@ +name: No print statements in dart files + +on: + pull_request: + branches: [main] + +jobs: + PR_test_build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + - name: Check for print() statements in dart code (use printV() instead) + if: github.event_name == 'pull_request' + run: | + GIT_GREP_OUT="$(git grep ' print(' | (grep .dart: || test $? = 1) | (grep -v print_verbose.dart || test $? = 1) || true)" + [[ "x$GIT_GREP_OUT" == "x" ]] && exit 0 + echo "$GIT_GREP_OUT" + echo "There are .dart files which use print() statements" + echo "Please use printV from package: cw_core/utils/print_verbose.dart" + exit 1 diff --git a/cw_bitcoin/lib/bitcoin_hardware_wallet_service.dart b/cw_bitcoin/lib/bitcoin_hardware_wallet_service.dart index a02c51c69..c8715b239 100644 --- a/cw_bitcoin/lib/bitcoin_hardware_wallet_service.dart +++ b/cw_bitcoin/lib/bitcoin_hardware_wallet_service.dart @@ -6,6 +6,7 @@ import 'package:cw_bitcoin/utils.dart'; import 'package:cw_core/hardware/hardware_account_data.dart'; import 'package:ledger_bitcoin/ledger_bitcoin.dart'; import 'package:ledger_flutter_plus/ledger_flutter_plus.dart'; +import 'package:cw_core/utils/print_verbose.dart'; class BitcoinHardwareWalletService { BitcoinHardwareWalletService(this.ledgerConnection); diff --git a/cw_bitcoin/lib/electrum.dart b/cw_bitcoin/lib/electrum.dart index df8e14119..28e3f47be 100644 --- a/cw_bitcoin/lib/electrum.dart +++ b/cw_bitcoin/lib/electrum.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:bitcoin_base/bitcoin_base.dart'; import 'package:cw_bitcoin/bitcoin_amount_format.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/foundation.dart'; import 'package:rxdart/rxdart.dart'; @@ -117,17 +118,17 @@ class ElectrumClient { _parseResponse(message); } } catch (e) { - print("socket.listen: $e"); + printV("socket.listen: $e"); } }, onError: (Object error) { final errorMsg = error.toString(); - print(errorMsg); + printV(errorMsg); unterminatedString = ''; socket = null; }, onDone: () { - print("SOCKET CLOSED!!!!!"); + printV("SOCKET CLOSED!!!!!"); unterminatedString = ''; try { if (host == socket?.address.host || socket == null) { @@ -136,7 +137,7 @@ class ElectrumClient { socket = null; } } catch (e) { - print("onDone: $e"); + printV("onDone: $e"); } }, cancelOnError: true, @@ -181,7 +182,7 @@ class ElectrumClient { unterminatedString = ''; } } catch (e) { - print("parse $e"); + printV("parse $e"); } } @@ -403,7 +404,7 @@ class ElectrumClient { } on RequestFailedTimeoutException catch (_) { return null; } catch (e) { - print("getCurrentBlockChainTip: ${e.toString()}"); + printV("getCurrentBlockChainTip: ${e.toString()}"); return null; } } @@ -434,7 +435,7 @@ class ElectrumClient { return subscription; } catch (e) { - print("subscribe $e"); + printV("subscribe $e"); return null; } } @@ -473,7 +474,7 @@ class ElectrumClient { return completer.future; } catch (e) { - print("callWithTimeout $e"); + printV("callWithTimeout $e"); rethrow; } } diff --git a/cw_bitcoin/lib/electrum_transaction_history.dart b/cw_bitcoin/lib/electrum_transaction_history.dart index b688f097b..658f83f8a 100644 --- a/cw_bitcoin/lib/electrum_transaction_history.dart +++ b/cw_bitcoin/lib/electrum_transaction_history.dart @@ -5,6 +5,7 @@ import 'package:cw_bitcoin/electrum_transaction_info.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/transaction_history.dart'; import 'package:cw_core/utils/file.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/transaction_history.dart'; @@ -51,7 +52,7 @@ abstract class ElectrumTransactionHistoryBase final data = json.encode({'height': _height, 'transactions': txjson}); await encryptionFileUtils.write(path: path, password: _password, data: data); } catch (e) { - print('Error while save bitcoin transaction history: ${e.toString()}'); + printV('Error while save bitcoin transaction history: ${e.toString()}'); } } @@ -88,7 +89,7 @@ abstract class ElectrumTransactionHistoryBase _height = content['height'] as int; } catch (e) { - print(e); + printV(e); } } diff --git a/cw_bitcoin/lib/electrum_wallet.dart b/cw_bitcoin/lib/electrum_wallet.dart index 771d135a0..d4f0e4adc 100644 --- a/cw_bitcoin/lib/electrum_wallet.dart +++ b/cw_bitcoin/lib/electrum_wallet.dart @@ -4,6 +4,8 @@ import 'dart:io'; import 'dart:isolate'; import 'package:bitcoin_base/bitcoin_base.dart'; +import 'package:cw_bitcoin/litecoin_wallet_addresses.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_bitcoin/bitcoin_wallet.dart'; import 'package:cw_bitcoin/litecoin_wallet.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -479,8 +481,8 @@ abstract class ElectrumWalletBase syncStatus = SyncedSyncStatus(); } } catch (e, stacktrace) { - print(stacktrace); - print("startSync $e"); + printV(stacktrace); + printV("startSync $e"); syncStatus = FailedSyncStatus(); } } @@ -506,7 +508,7 @@ abstract class ElectrumWalletBase _feeRates = [slowFee, mediumFee, fastFee]; return; } catch (e) { - print(e); + printV(e); } } @@ -588,8 +590,8 @@ abstract class ElectrumWalletBase await electrumClient.connectToUri(node.uri, useSSL: node.useSSL); } catch (e, stacktrace) { - print(stacktrace); - print("connectToNode $e"); + printV(stacktrace); + printV("connectToNode $e"); syncStatus = FailedSyncStatus(); } } @@ -1492,7 +1494,7 @@ abstract class ElectrumWalletBase await unspentCoinsInfo.deleteAll(keys); } } catch (e) { - print("refreshUnspentCoinsInfo $e"); + printV("refreshUnspentCoinsInfo $e"); } } @@ -1935,7 +1937,7 @@ abstract class ElectrumWalletBase return historiesWithDetails; } catch (e) { - print("fetchTransactions $e"); + printV("fetchTransactions $e"); return {}; } } @@ -2059,7 +2061,7 @@ abstract class ElectrumWalletBase } Future updateTransactions() async { - print("updateTransactions() called!"); + printV("updateTransactions() called!"); try { if (_isTransactionUpdating) { return; @@ -2091,8 +2093,8 @@ abstract class ElectrumWalletBase walletAddresses.updateReceiveAddresses(); _isTransactionUpdating = false; } catch (e, stacktrace) { - print(stacktrace); - print(e); + printV(stacktrace); + printV(e); _isTransactionUpdating = false; } } @@ -2110,13 +2112,13 @@ abstract class ElectrumWalletBase try { await _scripthashesUpdateSubject[sh]?.close(); } catch (e) { - print("failed to close: $e"); + printV("failed to close: $e"); } } try { _scripthashesUpdateSubject[sh] = await electrumClient.scripthashUpdate(sh); } catch (e) { - print("failed scripthashUpdate: $e"); + printV("failed scripthashUpdate: $e"); } _scripthashesUpdateSubject[sh]?.listen((event) async { try { @@ -2126,7 +2128,7 @@ abstract class ElectrumWalletBase await _fetchAddressHistory(address, await getCurrentChainTip()); } catch (e, s) { - print("sub error: $e"); + printV("sub error: $e"); _onError?.call(FlutterErrorDetails( exception: e, stack: s, @@ -2134,7 +2136,7 @@ abstract class ElectrumWalletBase )); } }, onError: (e, s) { - print("sub_listen error: $e $s"); + printV("sub_listen error: $e $s"); }); })); } @@ -2186,7 +2188,7 @@ abstract class ElectrumWalletBase if (balances.isNotEmpty && balances.first['confirmed'] == null) { // if we got null balance responses from the server, set our connection status to lost and return our last known balance: - print("got null balance responses from the server, setting connection status to lost"); + printV("got null balance responses from the server, setting connection status to lost"); syncStatus = LostConnectionSyncStatus(); return balance[currency] ?? ElectrumBalance(confirmed: 0, unconfirmed: 0, frozen: 0); } @@ -2213,7 +2215,7 @@ abstract class ElectrumWalletBase } Future updateBalance() async { - print("updateBalance() called!"); + printV("updateBalance() called!"); balance[currency] = await fetchBalances(); await save(); } @@ -2353,7 +2355,7 @@ abstract class ElectrumWalletBase } void _syncStatusReaction(SyncStatus syncStatus) async { - print("SYNC_STATUS_CHANGE: ${syncStatus}"); + printV("SYNC_STATUS_CHANGE: ${syncStatus}"); if (syncStatus is SyncingSyncStatus) { return; } diff --git a/cw_bitcoin/lib/electrum_wallet_addresses.dart b/cw_bitcoin/lib/electrum_wallet_addresses.dart index c29579436..6774a5036 100644 --- a/cw_bitcoin/lib/electrum_wallet_addresses.dart +++ b/cw_bitcoin/lib/electrum_wallet_addresses.dart @@ -3,6 +3,8 @@ import 'dart:io' show Platform; import 'package:bitcoin_base/bitcoin_base.dart'; import 'package:blockchain_utils/blockchain_utils.dart'; import 'package:cw_bitcoin/bitcoin_address_record.dart'; +import 'package:cw_bitcoin/electrum_wallet.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_bitcoin/bitcoin_unspent.dart'; import 'package:cw_core/wallet_addresses.dart'; import 'package:cw_core/wallet_info.dart'; @@ -193,7 +195,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store { receiveAddresses.remove(addressRecord); receiveAddresses.insert(0, addressRecord); } catch (e) { - print("ElectrumWalletAddressBase: set address ($addr): $e"); + printV("ElectrumWalletAddressBase: set address ($addr): $e"); } } @@ -483,7 +485,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store { await saveAddressesInBox(); } catch (e) { - print("updateAddresses $e"); + printV("updateAddresses $e"); } } diff --git a/cw_bitcoin/lib/litecoin_wallet.dart b/cw_bitcoin/lib/litecoin_wallet.dart index 86228fc83..e55516e9a 100644 --- a/cw_bitcoin/lib/litecoin_wallet.dart +++ b/cw_bitcoin/lib/litecoin_wallet.dart @@ -9,6 +9,7 @@ import 'package:crypto/crypto.dart'; import 'package:cw_bitcoin/bitcoin_transaction_credentials.dart'; import 'package:cw_core/cake_hive.dart'; import 'package:cw_core/mweb_utxo.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/node.dart'; import 'package:cw_mweb/mwebd.pbgrpc.dart'; import 'package:fixnum/fixnum.dart'; @@ -283,7 +284,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { } Future waitForMwebAddresses() async { - print("waitForMwebAddresses() called!"); + printV("waitForMwebAddresses() called!"); // ensure that we have the full 1000 mweb addresses generated before continuing: // should no longer be needed, but leaving here just in case await (walletAddresses as LitecoinWalletAddresses).ensureMwebAddressUpToIndexExists(1020); @@ -302,8 +303,8 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { @action @override Future startSync() async { - print("startSync() called!"); - print("STARTING SYNC - MWEB ENABLED: $mwebEnabled"); + printV("startSync() called!"); + printV("STARTING SYNC - MWEB ENABLED: $mwebEnabled"); if (!mwebEnabled) { try { // in case we're switching from a litecoin wallet that had mweb enabled @@ -317,33 +318,33 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { return; } - print("STARTING SYNC - MWEB ENABLED: $mwebEnabled"); + printV("STARTING SYNC - MWEB ENABLED: $mwebEnabled"); _syncTimer?.cancel(); try { mwebSyncStatus = SyncronizingSyncStatus(); try { await subscribeForUpdates(); } catch (e) { - print("failed to subcribe for updates: $e"); + printV("failed to subcribe for updates: $e"); } updateFeeRates(); _feeRatesTimer?.cancel(); _feeRatesTimer = Timer.periodic(const Duration(minutes: 1), (timer) async => await updateFeeRates()); - print("START SYNC FUNCS"); + printV("START SYNC FUNCS"); await waitForMwebAddresses(); await processMwebUtxos(); await updateTransactions(); await updateUnspent(); await updateBalance(); - print("DONE SYNC FUNCS"); - } catch (e, s) { - print("mweb sync failed: $e $s"); - mwebSyncStatus = FailedSyncStatus(error: "mweb sync failed: $e"); + } catch (e) { + printV("failed to start mweb sync: $e"); + syncStatus = FailedSyncStatus(); return; } + _syncTimer?.cancel(); _syncTimer = Timer.periodic(const Duration(milliseconds: 3000), (timer) async { if (mwebSyncStatus is FailedSyncStatus) { _syncTimer?.cancel(); @@ -401,7 +402,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { for (var coin in tx.unspents!) { final utxo = mwebUtxosBox.get(coin.address); if (utxo != null) { - print("deleting utxo ${coin.address} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); + printV("deleting utxo ${coin.address} @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"); await mwebUtxosBox.delete(coin.address); } } @@ -428,7 +429,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { return; } } catch (e) { - print("error syncing: $e"); + printV("error syncing: $e"); mwebSyncStatus = FailedSyncStatus(error: e.toString()); } }); @@ -437,12 +438,12 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { @action @override Future stopSync() async { - print("stopSync() called!"); + printV("stopSync() called!"); _syncTimer?.cancel(); _utxoStream?.cancel(); _feeRatesTimer?.cancel(); await CwMweb.stop(); - print("stopped syncing!"); + printV("stopped syncing!"); } Future initMwebUtxosBox() async { @@ -514,7 +515,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { } Future handleIncoming(MwebUtxo utxo) async { - print("handleIncoming() called!"); + printV("handleIncoming() called!"); final status = await CwMweb.status(StatusRequest()); var date = DateTime.now(); var confirmations = 0; @@ -559,7 +560,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { final addressRecord = walletAddresses.allAddresses .firstWhereOrNull((addressRecord) => addressRecord.address == utxo.address); if (addressRecord == null) { - print("we don't have this address in the wallet! ${utxo.address}"); + printV("we don't have this address in the wallet! ${utxo.address}"); return; } @@ -580,13 +581,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { } Future processMwebUtxos() async { - print("processMwebUtxos() called!"); + printV("processMwebUtxos() called!"); if (!mwebEnabled) { return; } int restoreHeight = walletInfo.restoreHeight; - print("SCANNING FROM HEIGHT: $restoreHeight"); + printV("SCANNING FROM HEIGHT: $restoreHeight"); final req = UtxosRequest(scanSecret: scanSecret, fromHeight: restoreHeight); // process new utxos as they come in: @@ -621,7 +622,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { // but do update the utxo height if it's somehow different: final existingUtxo = mwebUtxosBox.get(utxo.outputId); if (existingUtxo!.height != utxo.height) { - print( + printV( "updating utxo height for $utxo.outputId: ${existingUtxo.height} -> ${utxo.height}"); existingUtxo.height = utxo.height; await mwebUtxosBox.put(utxo.outputId, existingUtxo); @@ -644,7 +645,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { await handleIncoming(utxo); }, onError: (error) { - print("error in utxo stream: $error"); + printV("error in utxo stream: $error"); mwebSyncStatus = FailedSyncStatus(error: error.toString()); }, cancelOnError: true, @@ -652,7 +653,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { } Future deleteSpentUtxos() async { - print("deleteSpentUtxos() called!"); + printV("deleteSpentUtxos() called!"); final chainHeight = await electrumClient.getCurrentBlockChainTip(); final status = await CwMweb.status(StatusRequest()); if (chainHeight == null || status.blockHeaderHeight != chainHeight) return; @@ -676,7 +677,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { } Future checkMwebUtxosSpent() async { - print("checkMwebUtxosSpent() called!"); + printV("checkMwebUtxosSpent() called!"); if (!mwebEnabled) { return; } @@ -791,7 +792,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { } Future updateUnspent() async { - print("updateUnspent() called!"); + printV("updateUnspent() called!"); await checkMwebUtxosSpent(); await updateAllUnspents(); } @@ -822,7 +823,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { .firstWhereOrNull((addressRecord) => addressRecord.address == utxo.address); if (addressRecord == null) { - print("utxo contains an address that is not in the wallet: ${utxo.address}"); + printV("utxo contains an address that is not in the wallet: ${utxo.address}"); return; } final unspent = BitcoinUnspent( @@ -863,7 +864,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { mwebUtxosBox.values.forEach((utxo) { bool isConfirmed = utxo.height > 0; - print( + printV( "utxo: ${isConfirmed ? "confirmed" : "unconfirmed"} ${utxo.spent ? "spent" : "unspent"} ${utxo.outputId} ${utxo.height} ${utxo.value}"); if (isConfirmed) { @@ -1001,7 +1002,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { final sum1 = _sumOutputAmounts(outputs.map((e) => e.toOutput).toList()) + fee; final sum2 = utxos.sumOfUtxosValue(); if (sum1 != sum2) { - print("@@@@@ WE HAD TO ADJUST THE FEE! @@@@@@@@"); + printV("@@@@@ WE HAD TO ADJUST THE FEE! @@@@@@@@"); final diff = sum2 - sum1; // add the difference to the fee (abs value): fee += diff.abs(); @@ -1166,7 +1167,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { addressRecord.balance -= utxo.value.toInt(); }); transaction.inputAddresses?.addAll(addresses); - print("isPegIn: $isPegIn, isPegOut: $isPegOut"); + printV("isPegIn: $isPegIn, isPegOut: $isPegOut"); transaction.additionalInfo["isPegIn"] = isPegIn; transaction.additionalInfo["isPegOut"] = isPegOut; transactionHistory.addOne(transaction); @@ -1174,10 +1175,10 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store { await updateBalance(); }); } catch (e, s) { - print(e); - print(s); + printV(e); + printV(s); if (e.toString().contains("commit failed")) { - print(e); + printV(e); throw Exception("Transaction commit failed (no peers responded), please try again."); } rethrow; diff --git a/cw_bitcoin/lib/litecoin_wallet_addresses.dart b/cw_bitcoin/lib/litecoin_wallet_addresses.dart index 062c590ba..afe3c75b8 100644 --- a/cw_bitcoin/lib/litecoin_wallet_addresses.dart +++ b/cw_bitcoin/lib/litecoin_wallet_addresses.dart @@ -9,6 +9,7 @@ import 'package:cw_bitcoin/bitcoin_unspent.dart'; import 'package:cw_bitcoin/electrum_wallet.dart'; import 'package:cw_bitcoin/utils.dart'; import 'package:cw_bitcoin/electrum_wallet_addresses.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_mweb/cw_mweb.dart'; import 'package:flutter/foundation.dart'; @@ -35,7 +36,7 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with for (int i = 0; i < mwebAddresses.length; i++) { mwebAddrs.add(mwebAddresses[i].address); } - print("initialized with ${mwebAddrs.length} mweb addresses"); + printV("initialized with ${mwebAddrs.length} mweb addresses"); } final Bip32Slip10Secp256k1? mwebHd; @@ -73,25 +74,25 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with } while (generating) { - print("generating....."); + printV("generating....."); // this function was called multiple times in multiple places: await Future.delayed(const Duration(milliseconds: 100)); } - print("Generating MWEB addresses up to index $index"); + printV("Generating MWEB addresses up to index $index"); generating = true; try { while (mwebAddrs.length <= (index + 1)) { final addresses = await CwMweb.addresses(scan, spend, mwebAddrs.length, mwebAddrs.length + 50); - print("generated up to index ${mwebAddrs.length}"); + printV("generated up to index ${mwebAddrs.length}"); // sleep for a bit to avoid making the main thread unresponsive: await Future.delayed(Duration(milliseconds: 200)); mwebAddrs.addAll(addresses!); } } catch (_) {} generating = false; - print("Done generating MWEB addresses len: ${mwebAddrs.length}"); + printV("Done generating MWEB addresses len: ${mwebAddrs.length}"); // ensure mweb addresses are up to date: // This is the Case if the Litecoin Wallet is a hardware Wallet @@ -109,7 +110,7 @@ abstract class LitecoinWalletAddressesBase extends ElectrumWalletAddresses with )) .toList(); addMwebAddresses(addressRecords); - print("set ${addressRecords.length} mweb addresses"); + printV("set ${addressRecords.length} mweb addresses"); } } diff --git a/cw_bitcoin/lib/psbt_transaction_builder.dart b/cw_bitcoin/lib/psbt_transaction_builder.dart index 81efb792e..8cb979730 100644 --- a/cw_bitcoin/lib/psbt_transaction_builder.dart +++ b/cw_bitcoin/lib/psbt_transaction_builder.dart @@ -2,6 +2,7 @@ import 'dart:typed_data'; import 'package:bitcoin_base/bitcoin_base.dart'; import 'package:convert/convert.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:ledger_bitcoin/psbt.dart'; class PSBTTransactionBuild { @@ -16,6 +17,10 @@ class PSBTTransactionBuild { for (var i = 0; i < inputs.length; i++) { final input = inputs[i]; + printV(input.utxo.isP2tr()); + printV(input.utxo.isSegwit()); + printV(input.utxo.isP2shSegwit()); + psbt.setInputPreviousTxId(i, Uint8List.fromList(hex.decode(input.utxo.txHash).reversed.toList())); psbt.setInputOutputIndex(i, input.utxo.vout); psbt.setInputSequence(i, enableRBF ? 0x1 : 0xffffffff); diff --git a/cw_core/lib/battery_optimization_native.dart b/cw_core/lib/battery_optimization_native.dart index edd04d3f4..8e476ea6a 100644 --- a/cw_core/lib/battery_optimization_native.dart +++ b/cw_core/lib/battery_optimization_native.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/services.dart'; const MethodChannel _channel = MethodChannel('com.cake_wallet/native_utils'); @@ -6,17 +7,17 @@ Future requestDisableBatteryOptimization() async { try { await _channel.invokeMethod('disableBatteryOptimization'); } on PlatformException catch (e) { - print("Failed to disable battery optimization: '${e.message}'."); + printV("Failed to disable battery optimization: '${e.message}'."); } } Future isBatteryOptimizationDisabled() async { try { final bool isDisabled = await _channel.invokeMethod('isBatteryOptimizationDisabled') as bool; - print('It\'s actually disabled? $isDisabled'); + printV('It\'s actually disabled? $isDisabled'); return isDisabled; } on PlatformException catch (e) { - print("Failed to check battery optimization status: '${e.message}'."); + printV("Failed to check battery optimization status: '${e.message}'."); return false; } } diff --git a/cw_core/lib/get_height_by_date.dart b/cw_core/lib/get_height_by_date.dart index 7929d7cbd..aee12b423 100644 --- a/cw_core/lib/get_height_by_date.dart +++ b/cw_core/lib/get_height_by_date.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:intl/intl.dart'; import 'dart:convert'; import 'package:http/http.dart' as http; @@ -152,7 +153,7 @@ int getMoneroHeigthByDate({required DateTime date}) { height = startHeight + daysHeight - heightPerDay; } } catch (e) { - print(e.toString()); + printV(e.toString()); } return height; diff --git a/cw_core/lib/utils/print_verbose.dart b/cw_core/lib/utils/print_verbose.dart new file mode 100644 index 000000000..a5c3337e5 --- /dev/null +++ b/cw_core/lib/utils/print_verbose.dart @@ -0,0 +1,84 @@ +void printV(dynamic content) { + CustomTrace programInfo = CustomTrace(StackTrace.current); + print("${programInfo.fileName}#${programInfo.lineNumber}:${programInfo.columnNumber} ${programInfo.callerFunctionName}: $content"); +} + +// https://stackoverflow.com/a/59386101 + +class CustomTrace { + final StackTrace _trace; + + String? fileName; + String? functionName; + String? callerFunctionName; + int? lineNumber; + int? columnNumber; + + CustomTrace(this._trace) { + try { + _parseTrace(); + } catch (e) { + print("Unable to parse trace (printV): $e"); + } + } + + String _getFunctionNameFromFrame(String frame) { + /* Just giving another nickname to the frame */ + var currentTrace = frame; + /* To get rid off the #number thing, get the index of the first whitespace */ + var indexOfWhiteSpace = currentTrace.indexOf(' '); + + /* Create a substring from the first whitespace index till the end of the string */ + var subStr = currentTrace.substring(indexOfWhiteSpace); + + /* Grab the function name using reg expr */ + var indexOfFunction = subStr.indexOf(RegExp(r'[A-Za-z0-9_]')); + + /* Create a new substring from the function name index till the end of string */ + subStr = subStr.substring(indexOfFunction); + + indexOfWhiteSpace = subStr.indexOf(RegExp(r'[ .]')); + + /* Create a new substring from start to the first index of a whitespace. This substring gives us the function name */ + subStr = subStr.substring(0, indexOfWhiteSpace); + + return subStr; + } + + void _parseTrace() { + /* The trace comes with multiple lines of strings, (each line is also known as a frame), so split the trace's string by lines to get all the frames */ + var frames = this._trace.toString().split("\n"); + + /* The first frame is the current function */ + this.functionName = _getFunctionNameFromFrame(frames[0]); + + /* The second frame is the caller function */ + this.callerFunctionName = _getFunctionNameFromFrame(frames[1]); + + /* The first frame has all the information we need */ + var traceString = frames[1]; + + /* Search through the string and find the index of the file name by looking for the '.dart' regex */ + var indexOfFileName = traceString.indexOf(RegExp(r'[/A-Za-z_]+.dart'), 1); // 1 to offest and not print the printV function name + + var fileInfo = traceString.substring(indexOfFileName); + + var listOfInfos = fileInfo.split(":"); + + /* Splitting fileInfo by the character ":" separates the file name, the line number and the column counter nicely. + Example: main.dart:5:12 + To get the file name, we split with ":" and get the first index + To get the line number, we would have to get the second index + To get the column number, we would have to get the third index + */ + try { + this.fileName = listOfInfos[0]; + this.lineNumber = int.tryParse(listOfInfos[1]); + var columnStr = listOfInfos[2]; + columnStr = columnStr.replaceFirst(")", ""); + this.columnNumber = int.tryParse(columnStr); + } catch (e) { + + } + } +} diff --git a/cw_core/lib/wallet_addresses.dart b/cw_core/lib/wallet_addresses.dart index 714d229d9..b0da0e7a1 100644 --- a/cw_core/lib/wallet_addresses.dart +++ b/cw_core/lib/wallet_addresses.dart @@ -1,4 +1,5 @@ import 'package:cw_core/address_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_type.dart'; @@ -71,7 +72,7 @@ abstract class WalletAddresses { await walletInfo.save(); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/cw_core/lib/window_size.dart b/cw_core/lib/window_size.dart index a0f192f66..dffbfab99 100644 --- a/cw_core/lib/window_size.dart +++ b/cw_core/lib/window_size.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/services.dart'; const MethodChannel _channel = MethodChannel('com.cake_wallet/native_utils'); @@ -14,9 +15,9 @@ Future setDefaultMinimumWindowSize() async { ) as bool; if (!result) { - print("Failed to set minimum window size."); + printV("Failed to set minimum window size."); } } on PlatformException catch (e) { - print("Failed to set minimum window size: '${e.message}'."); + printV("Failed to set minimum window size: '${e.message}'."); } } diff --git a/cw_evm/lib/evm_chain_wallet.dart b/cw_evm/lib/evm_chain_wallet.dart index cfaf39d98..eeb86c5bd 100644 --- a/cw_evm/lib/evm_chain_wallet.dart +++ b/cw_evm/lib/evm_chain_wallet.dart @@ -14,6 +14,7 @@ import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/pending_transaction.dart'; import 'package:cw_core/sync_status.dart'; import 'package:cw_core/transaction_priority.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_addresses.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_info.dart'; @@ -200,7 +201,7 @@ abstract class EVMChainWalletBase } else { // MaxFeePerGas with gasPrice; maxFeePerGas = gasPrice; - debugPrint('MaxFeePerGas with gasPrice: $maxFeePerGas'); + printV('MaxFeePerGas with gasPrice: $maxFeePerGas'); } final totalGasFee = estimatedGasUnits * maxFeePerGas; diff --git a/cw_evm/lib/evm_ledger_credentials.dart b/cw_evm/lib/evm_ledger_credentials.dart index a0b7788dc..b579b9108 100644 --- a/cw_evm/lib/evm_ledger_credentials.dart +++ b/cw_evm/lib/evm_ledger_credentials.dart @@ -3,6 +3,7 @@ import 'dart:typed_data'; import 'package:cw_core/hardware/device_not_connected_exception.dart' as exception; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:ledger_ethereum/ledger_ethereum.dart'; import 'package:ledger_flutter_plus/ledger_flutter_plus.dart'; import 'package:web3dart/crypto.dart'; @@ -96,7 +97,7 @@ class EvmLedgerCredentials extends CredentialsWithKnownAddress { await ethereumLedgerApp!.getAndProvideERC20TokenInformation( erc20ContractAddress: erc20ContractAddress, chainId: chainId); } catch (e) { - print(e); + printV(e); rethrow; // if (e.errorCode != -28672) rethrow; } diff --git a/cw_haven/lib/haven_account_list.dart b/cw_haven/lib/haven_account_list.dart index 9399efc27..41e3bbf57 100644 --- a/cw_haven/lib/haven_account_list.dart +++ b/cw_haven/lib/haven_account_list.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/account.dart'; import 'package:cw_core/account_list.dart'; @@ -77,7 +78,7 @@ abstract class HavenAccountListBase extends AccountList with Store { _isRefreshing = false; } catch (e) { _isRefreshing = false; - print(e); + printV(e); rethrow; } } diff --git a/cw_haven/lib/haven_subaddress_list.dart b/cw_haven/lib/haven_subaddress_list.dart index b40b3484c..8a5125a55 100644 --- a/cw_haven/lib/haven_subaddress_list.dart +++ b/cw_haven/lib/haven_subaddress_list.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_haven/api/structs/subaddress_row.dart'; import 'package:flutter/services.dart'; import 'package:mobx/mobx.dart'; @@ -79,7 +80,7 @@ abstract class HavenSubaddressListBase with Store { _isRefreshing = false; } on PlatformException catch (e) { _isRefreshing = false; - print(e); + printV(e); rethrow; } } diff --git a/cw_haven/lib/haven_wallet.dart b/cw_haven/lib/haven_wallet.dart index e2e598bbe..734a6da9c 100644 --- a/cw_haven/lib/haven_wallet.dart +++ b/cw_haven/lib/haven_wallet.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/transaction_priority.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_haven/haven_transaction_creation_credentials.dart'; import 'package:cw_core/monero_amount_format.dart'; import 'package:cw_haven/haven_transaction_creation_exception.dart'; @@ -130,7 +131,7 @@ abstract class HavenWalletBase syncStatus = ConnectedSyncStatus(); } catch (e) { syncStatus = FailedSyncStatus(); - print(e); + printV(e); } } @@ -147,7 +148,7 @@ abstract class HavenWalletBase _listener?.start(); } catch (e) { syncStatus = FailedSyncStatus(); - print(e); + printV(e); rethrow; } } @@ -324,7 +325,7 @@ abstract class HavenWalletBase await transactionHistory.save(); _isTransactionUpdating = false; } catch (e) { - print(e); + printV(e); _isTransactionUpdating = false; } } @@ -403,7 +404,7 @@ abstract class HavenWalletBase syncStatus = SyncingSyncStatus(blocksLeft, ptc); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } @@ -413,7 +414,7 @@ abstract class HavenWalletBase _askForUpdateBalance(); await Future.delayed(Duration(seconds: 1)); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/cw_haven/lib/haven_wallet_addresses.dart b/cw_haven/lib/haven_wallet_addresses.dart index c3d1ef46c..192c09ef7 100644 --- a/cw_haven/lib/haven_wallet_addresses.dart +++ b/cw_haven/lib/haven_wallet_addresses.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_addresses_with_account.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/account.dart'; @@ -60,7 +61,7 @@ abstract class HavenWalletAddressesBase extends WalletAddressesWithAccount e.address).toList(); final amounts = outputs.map((e) => monero.Wallet_amountFromString(e.amount)).toList(); - // print("multDest: dstAddrs: $dstAddrs"); - // print("multDest: amounts: $amounts"); + // printV("multDest: dstAddrs: $dstAddrs"); + // printV("multDest: amounts: $amounts"); final txptr = monero.Wallet_createTransactionMultDest( wptr!, diff --git a/cw_monero/lib/api/wallet.dart b/cw_monero/lib/api/wallet.dart index 667a1ff69..f57beb5fc 100644 --- a/cw_monero/lib/api/wallet.dart +++ b/cw_monero/lib/api/wallet.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:ffi'; import 'dart:isolate'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart'; import 'package:flutter/foundation.dart'; @@ -11,7 +12,7 @@ import 'package:mutex/mutex.dart'; int getSyncingHeight() { // final height = monero.MONERO_cw_WalletListener_height(getWlptr()); final h2 = monero.Wallet_blockChainHeight(wptr!); - // print("height: $height / $h2"); + // printV("height: $height / $h2"); return h2; } @@ -70,9 +71,9 @@ String getSeedLegacy(String? language) { Map>> addressCache = {}; String getAddress({int accountIndex = 0, int addressIndex = 0}) { - // print("getaddress: ${accountIndex}/${addressIndex}: ${monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex)}: ${monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex)}"); + // printV("getaddress: ${accountIndex}/${addressIndex}: ${monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex)}: ${monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex)}"); while (monero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex)-1 < addressIndex) { - print("adding subaddress"); + printV("adding subaddress"); monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex); } addressCache[wptr!.address] ??= {}; @@ -101,7 +102,7 @@ Future setupNodeSync( bool useSSL = false, bool isLightWallet = false, String? socksProxyAddress}) async { - print(''' + printV(''' { wptr!, daemonAddress: $address, @@ -126,7 +127,7 @@ Future setupNodeSync( if (status != 0) { final error = monero.Wallet_errorString(wptr!); - print("error: $error"); + printV("error: $error"); throw SetupWalletException(message: error); } diff --git a/cw_monero/lib/api/wallet_manager.dart b/cw_monero/lib/api/wallet_manager.dart index 3a47132c5..530d58d62 100644 --- a/cw_monero/lib/api/wallet_manager.dart +++ b/cw_monero/lib/api/wallet_manager.dart @@ -2,6 +2,7 @@ import 'dart:ffi'; import 'dart:io'; import 'dart:isolate'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/exceptions/wallet_creation_exception.dart'; import 'package:cw_monero/api/exceptions/wallet_opening_exception.dart'; @@ -50,9 +51,9 @@ final monero.WalletManager wmPtr = Pointer.fromAddress((() { // than plugging gdb in. Especially on windows/android. monero.printStarts = false; _wmPtr ??= monero.WalletManagerFactory_getWalletManager(); - print("ptr: $_wmPtr"); + printV("ptr: $_wmPtr"); } catch (e) { - print(e); + printV(e); rethrow; } return _wmPtr!.address; @@ -223,7 +224,7 @@ void restoreWalletFromSpendKeySync( if (status != 0) { final err = monero.Wallet_errorString(newWptr); - print("err: $err"); + printV("err: $err"); throw WalletRestoreFromKeysException(message: err); } @@ -301,7 +302,7 @@ Future loadWallet( ); final status = monero.WalletManager_errorString(wmPtr); if (status != "") { - print("loadWallet:"+status); + printV("loadWallet:"+status); throw WalletOpeningException(message: status); } } else { @@ -326,7 +327,7 @@ Future loadWallet( final status = monero.Wallet_status(newWptr); if (status != 0) { final err = monero.Wallet_errorString(newWptr); - print("loadWallet:"+err); + printV("loadWallet:"+err); throw WalletOpeningException(message: err); } diff --git a/cw_monero/lib/ledger.dart b/cw_monero/lib/ledger.dart index c947d0944..e7af9f390 100644 --- a/cw_monero/lib/ledger.dart +++ b/cw_monero/lib/ledger.dart @@ -28,9 +28,9 @@ void enableLedgerExchange(monero.wallet ptr, LedgerConnection connection) { ptr, emptyPointer.cast(), 0); malloc.free(emptyPointer); - // print("> ${ledgerRequest.toHexString()}"); + // printV("> ${ledgerRequest.toHexString()}"); final response = await exchange(connection, ledgerRequest); - // print("< ${response.toHexString()}"); + // printV("< ${response.toHexString()}"); final Pointer result = malloc(response.length); for (var i = 0; i < response.length; i++) { diff --git a/cw_monero/lib/monero_account_list.dart b/cw_monero/lib/monero_account_list.dart index 29d096efd..aa23e276f 100644 --- a/cw_monero/lib/monero_account_list.dart +++ b/cw_monero/lib/monero_account_list.dart @@ -1,4 +1,5 @@ import 'package:cw_core/monero_amount_format.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/account.dart'; import 'package:cw_monero/api/account_list.dart' as account_list; @@ -74,7 +75,7 @@ abstract class MoneroAccountListBase with Store { _isRefreshing = false; } catch (e) { _isRefreshing = false; - print(e); + printV(e); rethrow; } } diff --git a/cw_monero/lib/monero_subaddress_list.dart b/cw_monero/lib/monero_subaddress_list.dart index c20b23b5e..bc6f223d7 100644 --- a/cw_monero/lib/monero_subaddress_list.dart +++ b/cw_monero/lib/monero_subaddress_list.dart @@ -1,4 +1,5 @@ import 'package:cw_core/subaddress.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_monero/api/coins_info.dart'; import 'package:cw_monero/api/subaddress_list.dart' as subaddress_list; import 'package:cw_monero/api/wallet.dart'; @@ -87,7 +88,7 @@ abstract class MoneroSubaddressListBase with Store { _isRefreshing = false; } on PlatformException catch (e) { _isRefreshing = false; - print(e); + printV(e); rethrow; } } diff --git a/cw_monero/lib/monero_unspent.dart b/cw_monero/lib/monero_unspent.dart index f45fcddaf..8a104edf4 100644 --- a/cw_monero/lib/monero_unspent.dart +++ b/cw_monero/lib/monero_unspent.dart @@ -1,4 +1,5 @@ import 'package:cw_core/unspent_transaction_output.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_monero/api/coins_info.dart'; import 'package:monero/monero.dart' as monero; @@ -10,7 +11,7 @@ class MoneroUnspent extends Unspent { @override set isFrozen(bool freeze) { - print("set isFrozen: $freeze ($keyImage): $freeze"); + printV("set isFrozen: $freeze ($keyImage): $freeze"); final coinId = getCoinByKeyImage(keyImage!); if (coinId == null) throw Exception("Unable to find a coin for address $address"); if (freeze) { @@ -22,7 +23,7 @@ class MoneroUnspent extends Unspent { @override bool get isFrozen { - print("get isFrozen"); + printV("get isFrozen"); final coinId = getCoinByKeyImage(keyImage!); if (coinId == null) throw Exception("Unable to find a coin for address $address"); final coin = getCoin(coinId); diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index d7a67c47d..83d9504ad 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -17,6 +17,7 @@ import 'package:cw_core/pending_transaction.dart'; import 'package:cw_core/sync_status.dart'; import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/unspent_coins_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_monero/api/account_list.dart'; @@ -198,7 +199,7 @@ abstract class MoneroWalletBase extends WalletBase.delayed(Duration(seconds: 1)); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/cw_monero/lib/monero_wallet_addresses.dart b/cw_monero/lib/monero_wallet_addresses.dart index ae78132d3..14b8a2b9b 100644 --- a/cw_monero/lib/monero_wallet_addresses.dart +++ b/cw_monero/lib/monero_wallet_addresses.dart @@ -1,6 +1,7 @@ import 'package:cw_core/account.dart'; import 'package:cw_core/address_info.dart'; import 'package:cw_core/subaddress.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_addresses.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_monero/api/subaddress_list.dart' as subaddress_list; @@ -96,7 +97,7 @@ abstract class MoneroWalletAddressesBase extends WalletAddresses with Store { await saveAddressesInBox(); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/cw_monero/lib/monero_wallet_service.dart b/cw_monero/lib/monero_wallet_service.dart index 0fb2e9aee..6f2435258 100644 --- a/cw_monero/lib/monero_wallet_service.dart +++ b/cw_monero/lib/monero_wallet_service.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:cw_core/monero_wallet_utils.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/unspent_coins_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; @@ -110,7 +111,7 @@ class MoneroWalletService extends WalletService< return wallet; } catch (e) { // TODO: Implement Exception for wallet list service. - print('MoneroWalletsManager Error: ${e.toString()}'); + printV('MoneroWalletsManager Error: ${e.toString()}'); rethrow; } } @@ -122,7 +123,7 @@ class MoneroWalletService extends WalletService< return monero_wallet_manager.isWalletExist(path: path); } catch (e) { // TODO: Implement Exception for wallet list service. - print('MoneroWalletsManager Error: $e'); + printV('MoneroWalletsManager Error: $e'); rethrow; } } @@ -177,7 +178,7 @@ class MoneroWalletService extends WalletService< final path = await pathForWalletDir(name: wallet, type: getType()); if (openedWalletsByPath["$path/$wallet"] != null) { // NOTE: this is realistically only required on windows. - print("closing wallet"); + printV("closing wallet"); final wmaddr = wmPtr.address; final waddr = openedWalletsByPath["$path/$wallet"]!.address; // await Isolate.run(() { @@ -185,7 +186,7 @@ class MoneroWalletService extends WalletService< Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), false); // }); openedWalletsByPath.remove("$path/$wallet"); - print("wallet closed"); + printV("wallet closed"); } final file = Directory(path); @@ -241,7 +242,7 @@ class MoneroWalletService extends WalletService< return wallet; } catch (e) { // TODO: Implement Exception for wallet list service. - print('MoneroWalletsManager Error: $e'); + printV('MoneroWalletsManager Error: $e'); rethrow; } } @@ -272,7 +273,7 @@ class MoneroWalletService extends WalletService< return wallet; } catch (e) { // TODO: Implement Exception for wallet list service. - print('MoneroWalletsManager Error: $e'); + printV('MoneroWalletsManager Error: $e'); rethrow; } } @@ -301,7 +302,7 @@ class MoneroWalletService extends WalletService< return wallet; } catch (e) { // TODO: Implement Exception for wallet list service. - print('MoneroWalletsManager Error: $e'); + printV('MoneroWalletsManager Error: $e'); rethrow; } } @@ -318,7 +319,7 @@ class MoneroWalletService extends WalletService< path, credentials.password!, polyseed, credentials.walletInfo!, lang); } catch (e) { // TODO: Implement Exception for wallet list service. - print('MoneroWalletsManager Error: $e'); + printV('MoneroWalletsManager Error: $e'); rethrow; } } @@ -381,7 +382,7 @@ class MoneroWalletService extends WalletService< newFile.writeAsBytesSync(file.readAsBytesSync()); }); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/cw_mweb/lib/cw_mweb.dart b/cw_mweb/lib/cw_mweb.dart index 75cc0bcca..594197018 100644 --- a/cw_mweb/lib/cw_mweb.dart +++ b/cw_mweb/lib/cw_mweb.dart @@ -4,6 +4,7 @@ import 'dart:developer'; import 'dart:io'; import 'dart:typed_data'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:grpc/grpc.dart'; import 'package:path_provider/path_provider.dart'; import 'cw_mweb_platform_interface.dart'; @@ -39,18 +40,18 @@ class CwMweb { final fileStream = file.openRead(lastLength, currentLength); final newLines = await fileStream.transform(utf8.decoder).join(); lastLength = currentLength; - log(newLines); + printV(newLines); } } on GrpcError catch (e) { - log('Caught grpc error: ${e.message}'); + printV('Caught grpc error: ${e.message}'); } catch (e) { - log('The mwebd debug log probably is not initialized yet.'); + printV('The mwebd debug log probably is not initialized yet.'); } }); } static Future _initializeClient() async { - print("_initializeClient() called!"); + printV("_initializeClient() called!"); final appDir = await getApplicationSupportDirectory(); const ltcNodeUri = "ltc-electrum.cakewallet.com:9333"; @@ -61,14 +62,14 @@ class CwMweb { if (_port == null || _port == 0) { throw Exception("Failed to start server"); } - log("Attempting to connect to server on port: $_port"); + printV("Attempting to connect to server on port: $_port"); // wait for the server to finish starting up before we try to connect to it: await Future.delayed(const Duration(seconds: 8)); _clientChannel = ClientChannel('127.0.0.1', port: _port!, channelShutdownHandler: () { _rpcClient = null; - log("Channel is shutting down!"); + printV("Channel is shutting down!"); }, options: const ChannelOptions( credentials: ChannelCredentials.insecure(), @@ -90,14 +91,14 @@ class CwMweb { } return _rpcClient!; } on GrpcError catch (e) { - log("Attempt $i failed: $e"); - log('Caught grpc error: ${e.message}'); + printV("Attempt $i failed: $e"); + printV('Caught grpc error: ${e.message}'); _rpcClient = null; // necessary if the database isn't open: await stop(); await Future.delayed(const Duration(seconds: 3)); } catch (e) { - log("Attempt $i failed: $e"); + printV("Attempt $i failed: $e"); _rpcClient = null; await stop(); await Future.delayed(const Duration(seconds: 3)); @@ -111,9 +112,9 @@ class CwMweb { await CwMwebPlatform.instance.stop(); await cleanup(); } on GrpcError catch (e) { - log('Caught grpc error: ${e.message}'); + printV('Caught grpc error: ${e.message}'); } catch (e) { - log("Error stopping server: $e"); + printV("Error stopping server: $e"); } } @@ -123,9 +124,9 @@ class CwMweb { ?.split(',') .first; } on GrpcError catch (e) { - log('Caught grpc error: ${e.message}'); + printV('Caught grpc error: ${e.message}'); } catch (e) { - log("Error getting address: $e"); + printV("Error getting address: $e"); } return null; } @@ -159,9 +160,9 @@ class CwMweb { _rpcClient = await stub(); return await _rpcClient!.spent(request, options: CallOptions(timeout: TIMEOUT_DURATION)); } on GrpcError catch (e) { - log('Caught grpc error: ${e.message}'); + printV('Caught grpc error: ${e.message}'); } catch (e) { - log("Error getting spent: $e"); + printV("Error getting spent: $e"); } return SpentResponse(); } @@ -172,9 +173,9 @@ class CwMweb { _rpcClient = await stub(); return await _rpcClient!.status(request, options: CallOptions(timeout: TIMEOUT_DURATION)); } on GrpcError catch (e) { - log('Caught grpc error: ${e.message}'); + printV('Caught grpc error: ${e.message}'); } catch (e) { - log("Error getting status: $e"); + printV("Error getting status: $e"); } return StatusResponse(); } @@ -185,9 +186,9 @@ class CwMweb { _rpcClient = await stub(); return await _rpcClient!.create(request, options: CallOptions(timeout: TIMEOUT_DURATION)); } on GrpcError catch (e) { - log('Caught grpc error: ${e.message}'); + printV('Caught grpc error: ${e.message}'); } catch (e) { - log("Error getting create: $e"); + printV("Error getting create: $e"); } return CreateResponse(); } @@ -201,9 +202,9 @@ class CwMweb { log("got utxo stream"); return resp; } on GrpcError catch (e) { - log('Caught grpc error: ${e.message}'); + printV('Caught grpc error: ${e.message}'); } catch (e) { - log("Error getting utxos: $e"); + printV("Error getting utxos: $e"); } return null; } @@ -217,7 +218,7 @@ class CwMweb { log('Caught grpc error: ${e.message}'); throw "error from broadcast mweb: $e"; } catch (e) { - log("Error getting create: $e"); + printV("Error getting utxos: $e"); rethrow; } } diff --git a/cw_mweb/pubspec.yaml b/cw_mweb/pubspec.yaml index cfe43c70b..2b71264ee 100644 --- a/cw_mweb/pubspec.yaml +++ b/cw_mweb/pubspec.yaml @@ -13,6 +13,8 @@ dependencies: grpc: ^3.2.4 path_provider: ^2.1.2 plugin_platform_interface: ^2.0.2 + cw_core: + path: ../cw_core dev_dependencies: flutter_test: diff --git a/cw_nano/lib/nano_client.dart b/cw_nano/lib/nano_client.dart index 7f8e1d0a9..8b62273da 100644 --- a/cw_nano/lib/nano_client.dart +++ b/cw_nano/lib/nano_client.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'dart:convert'; import 'package:cw_core/nano_account_info_response.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_nano/nano_block_info_response.dart'; import 'package:cw_core/n2_node.dart'; import 'package:cw_nano/nano_balance.dart'; @@ -106,7 +107,7 @@ class NanoClient { final data = await jsonDecode(response.body); return AccountInfoResponse.fromJson(data as Map); } catch (e) { - print("error while getting account info $e"); + printV("error while getting account info $e"); return null; } } @@ -127,7 +128,7 @@ class NanoClient { final data = await jsonDecode(response.body); return BlockContentsResponse.fromJson(data["contents"] as Map); } catch (e) { - print("error while getting block info $e"); + printV("error while getting block info $e"); return null; } } @@ -508,7 +509,7 @@ class NanoClient { .map((transaction) => NanoTransactionModel.fromJson(transaction)) .toList(); } catch (e) { - print(e); + printV(e); return []; } } diff --git a/cw_nano/lib/nano_transaction_history.dart b/cw_nano/lib/nano_transaction_history.dart index 44d64f7d4..7b4c5bc12 100644 --- a/cw_nano/lib/nano_transaction_history.dart +++ b/cw_nano/lib/nano_transaction_history.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'dart:core'; import 'package:cw_core/pathForWallet.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/encryption_file_utils.dart'; import 'package:mobx/mobx.dart'; @@ -37,7 +38,7 @@ abstract class NanoTransactionHistoryBase extends TransactionHistoryBase>> addressCache = {}; String getAddress({int accountIndex = 0, int addressIndex = 1}) { while (wownero.Wallet_numSubaddresses(wptr!, accountIndex: accountIndex)-1 < addressIndex) { - print("adding subaddress"); + printV("adding subaddress"); wownero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex); } addressCache[wptr!.address] ??= {}; @@ -100,7 +101,7 @@ Future setupNodeSync( bool useSSL = false, bool isLightWallet = false, String? socksProxyAddress}) async { - print(''' + printV(''' { wptr!, daemonAddress: $address, @@ -125,7 +126,7 @@ Future setupNodeSync( if (status != 0) { final error = wownero.Wallet_errorString(wptr!); - print("error: $error"); + printV("error: $error"); throw SetupWalletException(message: error); } diff --git a/cw_wownero/lib/api/wallet_manager.dart b/cw_wownero/lib/api/wallet_manager.dart index ed6d86823..6681652db 100644 --- a/cw_wownero/lib/api/wallet_manager.dart +++ b/cw_wownero/lib/api/wallet_manager.dart @@ -2,6 +2,7 @@ import 'dart:ffi'; import 'dart:io'; import 'dart:isolate'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_wownero/api/account_list.dart'; import 'package:cw_wownero/api/exceptions/wallet_creation_exception.dart'; import 'package:cw_wownero/api/exceptions/wallet_opening_exception.dart'; @@ -53,9 +54,9 @@ final wownero.WalletManager wmPtr = Pointer.fromAddress((() { // than plugging gdb in. Especially on windows/android. wownero.printStarts = false; _wmPtr ??= wownero.WalletManagerFactory_getWalletManager(); - print("ptr: $_wmPtr"); + printV("ptr: $_wmPtr"); } catch (e) { - print(e); + printV(e); rethrow; } return _wmPtr!.address; @@ -230,7 +231,7 @@ void restoreWalletFromSpendKeySync( if (status != 0) { final err = wownero.Wallet_errorString(newWptr); - print("err: $err"); + printV("err: $err"); throw WalletRestoreFromKeysException(message: err); } @@ -299,7 +300,7 @@ void loadWallet( final status = wownero.Wallet_status(newWptr); if (status != 0) { final err = wownero.Wallet_errorString(newWptr); - print(err); + printV(err); throw WalletOpeningException(message: err); } wptr = newWptr; diff --git a/cw_wownero/lib/mywownero.dart b/cw_wownero/lib/mywownero.dart index d50e48b64..afbb9b375 100644 --- a/cw_wownero/lib/mywownero.dart +++ b/cw_wownero/lib/mywownero.dart @@ -1,3 +1,5 @@ +import 'package:cw_core/utils/print_verbose.dart'; + const prefixLength = 3; String swapEndianBytes(String original) { @@ -37,14 +39,14 @@ String mnemonicDecode(String seed) { .indexOf(wlist[i + 2].substring(0, prefixLength)); if (w1 == -1 || w2 == -1 || w3 == -1) { - print("invalid word in mnemonic"); + printV("invalid word in mnemonic"); return ''; } final x = w1 + n * (((n - w1) + w2) % n) + n * n * (((n - w2) + w3) % n); if (x % n != w1) { - print("Something went wrong when decoding your private key, please try again"); + printV("Something went wrong when decoding your private key, please try again"); return ''; } diff --git a/cw_wownero/lib/wownero_account_list.dart b/cw_wownero/lib/wownero_account_list.dart index 6d408ba8f..cf1554b7a 100644 --- a/cw_wownero/lib/wownero_account_list.dart +++ b/cw_wownero/lib/wownero_account_list.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wownero_amount_format.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/account.dart'; @@ -74,7 +75,7 @@ abstract class WowneroAccountListBase with Store { _isRefreshing = false; } catch (e) { _isRefreshing = false; - print(e); + printV(e); rethrow; } } diff --git a/cw_wownero/lib/wownero_subaddress_list.dart b/cw_wownero/lib/wownero_subaddress_list.dart index 2ef4f2045..876e4bfcf 100644 --- a/cw_wownero/lib/wownero_subaddress_list.dart +++ b/cw_wownero/lib/wownero_subaddress_list.dart @@ -1,4 +1,5 @@ import 'package:cw_core/subaddress.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_wownero/api/coins_info.dart'; import 'package:cw_wownero/api/subaddress_list.dart' as subaddress_list; import 'package:cw_wownero/api/wallet.dart'; @@ -95,7 +96,7 @@ abstract class WowneroSubaddressListBase with Store { _isRefreshing = false; } on PlatformException catch (e) { _isRefreshing = false; - print(e); + printV(e); rethrow; } } diff --git a/cw_wownero/lib/wownero_wallet.dart b/cw_wownero/lib/wownero_wallet.dart index 5927d6434..db0fe7bd8 100644 --- a/cw_wownero/lib/wownero_wallet.dart +++ b/cw_wownero/lib/wownero_wallet.dart @@ -15,6 +15,7 @@ import 'package:cw_core/sync_status.dart'; import 'package:cw_core/transaction_direction.dart'; import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/unspent_coins_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wownero_amount_format.dart'; @@ -185,7 +186,7 @@ abstract class WowneroWalletBase syncStatus = ConnectedSyncStatus(); } catch (e) { syncStatus = FailedSyncStatus(); - print(e); + printV(e); } } @@ -216,7 +217,7 @@ abstract class WowneroWalletBase _listener?.start(); } catch (e) { syncStatus = FailedSyncStatus(); - print(e); + printV(e); rethrow; } } @@ -349,8 +350,8 @@ abstract class WowneroWalletBase try { await backupWalletFiles(name); } catch (e) { - print("¯\\_(ツ)_/¯"); - print(e); + printV("¯\\_(ツ)_/¯"); + printV(e); } } @@ -359,7 +360,7 @@ abstract class WowneroWalletBase final currentWalletDirPath = await pathForWalletDir(name: name, type: type); if (openedWalletsByPath["$currentWalletDirPath/$name"] != null) { // NOTE: this is realistically only required on windows. - print("closing wallet"); + printV("closing wallet"); final wmaddr = wmPtr.address; final waddr = openedWalletsByPath["$currentWalletDirPath/$name"]!.address; await Isolate.run(() { @@ -367,7 +368,7 @@ abstract class WowneroWalletBase Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), true); }); openedWalletsByPath.remove("$currentWalletDirPath/$name"); - print("wallet closed"); + printV("wallet closed"); } try { // -- rename the waller folder -- @@ -499,7 +500,7 @@ abstract class WowneroWalletBase await _refreshUnspentCoinsInfo(); _askForUpdateBalance(); } catch (e, s) { - print(e.toString()); + printV(e.toString()); onError?.call(FlutterErrorDetails( exception: e, stack: s, @@ -546,7 +547,7 @@ abstract class WowneroWalletBase await unspentCoinsInfo.deleteAll(keys); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } @@ -577,7 +578,7 @@ abstract class WowneroWalletBase await transactionHistory.save(); _isTransactionUpdating = false; } catch (e) { - print(e); + printV(e); _isTransactionUpdating = false; } } @@ -717,7 +718,7 @@ abstract class WowneroWalletBase syncStatus = SyncingSyncStatus(blocksLeft, ptc); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } @@ -727,7 +728,7 @@ abstract class WowneroWalletBase _askForUpdateBalance(); await Future.delayed(Duration(seconds: 1)); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/cw_wownero/lib/wownero_wallet_addresses.dart b/cw_wownero/lib/wownero_wallet_addresses.dart index eed81eb45..0b2ade073 100644 --- a/cw_wownero/lib/wownero_wallet_addresses.dart +++ b/cw_wownero/lib/wownero_wallet_addresses.dart @@ -1,6 +1,7 @@ import 'package:cw_core/account.dart'; import 'package:cw_core/address_info.dart'; import 'package:cw_core/subaddress.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_addresses.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_wownero/api/transaction_history.dart'; @@ -94,7 +95,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { await saveAddressesInBox(); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/cw_wownero/lib/wownero_wallet_service.dart b/cw_wownero/lib/wownero_wallet_service.dart index 6f0fafc88..1cd462cd9 100644 --- a/cw_wownero/lib/wownero_wallet_service.dart +++ b/cw_wownero/lib/wownero_wallet_service.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:cw_core/monero_wallet_utils.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/unspent_coins_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; @@ -99,7 +100,7 @@ class WowneroWalletService extends WalletService< return wallet; } catch (e) { // TODO: Implement Exception for wallet list service. - print('WowneroWalletsManager Error: ${e.toString()}'); + printV('WowneroWalletsManager Error: ${e.toString()}'); rethrow; } } @@ -111,7 +112,7 @@ class WowneroWalletService extends WalletService< return wownero_wallet_manager.isWalletExist(path: path); } catch (e) { // TODO: Implement Exception for wallet list service. - print('WowneroWalletsManager Error: $e'); + printV('WowneroWalletsManager Error: $e'); rethrow; } } @@ -182,7 +183,7 @@ class WowneroWalletService extends WalletService< final path = await pathForWalletDir(name: wallet, type: getType()); if (openedWalletsByPath["$path/$wallet"] != null) { // NOTE: this is realistically only required on windows. - print("closing wallet"); + printV("closing wallet"); final wmaddr = wmPtr.address; final waddr = openedWalletsByPath["$path/$wallet"]!.address; // await Isolate.run(() { @@ -190,7 +191,7 @@ class WowneroWalletService extends WalletService< Pointer.fromAddress(wmaddr), Pointer.fromAddress(waddr), false); // }); openedWalletsByPath.remove("$path/$wallet"); - print("wallet closed"); + printV("wallet closed"); } final file = Directory(path); @@ -241,7 +242,7 @@ class WowneroWalletService extends WalletService< return wallet; } catch (e) { // TODO: Implement Exception for wallet list service. - print('WowneroWalletsManager Error: $e'); + printV('WowneroWalletsManager Error: $e'); rethrow; } } @@ -274,7 +275,7 @@ class WowneroWalletService extends WalletService< return wallet; } catch (e) { // TODO: Implement Exception for wallet list service. - print('WowneroWalletsManager Error: $e'); + printV('WowneroWalletsManager Error: $e'); rethrow; } } @@ -291,7 +292,7 @@ class WowneroWalletService extends WalletService< path, credentials.password!, polyseed, credentials.walletInfo!, lang); } catch (e) { // TODO: Implement Exception for wallet list service. - print('WowneroWalletsManager Error: $e'); + printV('WowneroWalletsManager Error: $e'); rethrow; } } @@ -348,7 +349,7 @@ class WowneroWalletService extends WalletService< newFile.writeAsBytesSync(file.readAsBytesSync()); }); } catch (e) { - print(e.toString()); + printV(e.toString()); } } } diff --git a/ios/ZanoWallet.framework/ZanoWallet b/ios/ZanoWallet.framework/ZanoWallet new file mode 100644 index 000000000..701878274 Binary files /dev/null and b/ios/ZanoWallet.framework/ZanoWallet differ diff --git a/ios/zano_libwallet2_api_c.dylib b/ios/zano_libwallet2_api_c.dylib new file mode 120000 index 000000000..ed324a208 --- /dev/null +++ b/ios/zano_libwallet2_api_c.dylib @@ -0,0 +1 @@ +../scripts/monero_c/release/zano/host-apple-ios_libwallet2_api_c.dylib \ No newline at end of file diff --git a/lib/bitcoin/cw_bitcoin.dart b/lib/bitcoin/cw_bitcoin.dart index 60364c289..d098ea0e4 100644 --- a/lib/bitcoin/cw_bitcoin.dart +++ b/lib/bitcoin/cw_bitcoin.dart @@ -404,8 +404,8 @@ class CWBitcoin extends Bitcoin { list.add(dInfoCopy); } catch (e, s) { - print("derivationInfoError: $e"); - print("derivationInfoStack: $s"); + printV("derivationInfoError: $e"); + printV("derivationInfoStack: $s"); } } } @@ -498,7 +498,7 @@ class CWBitcoin extends Bitcoin { try { return hardwareWalletService.getAvailableAccounts(index: index, limit: limit); } catch (err) { - print(err); + printV(err); throw err; } } @@ -510,7 +510,7 @@ class CWBitcoin extends Bitcoin { try { return hardwareWalletService.getAvailableAccounts(index: index, limit: limit); } catch (err) { - print(err); + printV(err); throw err; } } diff --git a/lib/buy/dfx/dfx_buy_provider.dart b/lib/buy/dfx/dfx_buy_provider.dart index c1ed762b1..c11a0d771 100644 --- a/lib/buy/dfx/dfx_buy_provider.dart +++ b/lib/buy/dfx/dfx_buy_provider.dart @@ -12,6 +12,7 @@ import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/material.dart'; @@ -136,7 +137,7 @@ class DFXBuyProvider extends BuyProvider { return {}; } } catch (e) { - print('DFX Error fetching fiat currencies: $e'); + printV('DFX Error fetching fiat currencies: $e'); return {}; } } @@ -266,19 +267,19 @@ class DFXBuyProvider extends BuyProvider { quote.setCryptoCurrency = cryptoCurrency; return [quote]; } else { - print('DFX: Unexpected data type: ${responseData.runtimeType}'); + printV('DFX: Unexpected data type: ${responseData.runtimeType}'); return null; } } else { if (responseData is Map && responseData.containsKey('message')) { - print('DFX Error: ${responseData['message']}'); + printV('DFX Error: ${responseData['message']}'); } else { - print('DFX Failed to fetch buy quote: ${response.statusCode}'); + printV('DFX Failed to fetch buy quote: ${response.statusCode}'); } return null; } } catch (e) { - print('DFX Error fetching buy quote: $e'); + printV('DFX Error fetching buy quote: $e'); return null; } } diff --git a/lib/buy/meld/meld_buy_provider.dart b/lib/buy/meld/meld_buy_provider.dart index 1ac3931d1..a9759aab8 100644 --- a/lib/buy/meld/meld_buy_provider.dart +++ b/lib/buy/meld/meld_buy_provider.dart @@ -9,6 +9,7 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:flutter/material.dart'; import 'dart:developer'; @@ -75,11 +76,11 @@ class MeldBuyProvider extends BuyProvider { data.map((e) => PaymentMethod.fromMeldJson(e as Map)).toList(); return paymentMethods; } else { - print('Meld: Failed to fetch payment types'); + printV('Meld: Failed to fetch payment types'); return List.empty(); } } catch (e) { - print('Meld: Failed to fetch payment types: $e'); + printV('Meld: Failed to fetch payment types: $e'); return List.empty(); } } @@ -132,7 +133,7 @@ class MeldBuyProvider extends BuyProvider { return null; } } catch (e) { - print('Error fetching buy quote: $e'); + printV('Error fetching buy quote: $e'); return null; } } diff --git a/lib/buy/moonpay/moonpay_provider.dart b/lib/buy/moonpay/moonpay_provider.dart index b93c0f02d..5794e0794 100644 --- a/lib/buy/moonpay/moonpay_provider.dart +++ b/lib/buy/moonpay/moonpay_provider.dart @@ -18,6 +18,7 @@ import 'package:cake_wallet/themes/theme_base.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -113,11 +114,11 @@ class MoonPayProvider extends BuyProvider { if (response.statusCode == 200) { return jsonDecode(response.body) as Map; } else { - print('MoonPay does not support fiat: $fiatCurrency'); + printV('MoonPay does not support fiat: $fiatCurrency'); return {}; } } catch (e) { - print('MoonPay Error fetching fiat currencies: $e'); + printV('MoonPay Error fetching fiat currencies: $e'); return {}; } } @@ -204,11 +205,11 @@ class MoonPayProvider extends BuyProvider { return [quote]; } else { - print('Moon Pay: Error fetching buy quote: '); + printV('Moon Pay: Error fetching buy quote: '); return null; } } catch (e) { - print('Moon Pay: Error fetching buy quote: $e'); + printV('Moon Pay: Error fetching buy quote: $e'); return null; } } diff --git a/lib/buy/onramper/onramper_buy_provider.dart b/lib/buy/onramper/onramper_buy_provider.dart index 827a5d448..f229cb833 100644 --- a/lib/buy/onramper/onramper_buy_provider.dart +++ b/lib/buy/onramper/onramper_buy_provider.dart @@ -11,6 +11,7 @@ import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; @@ -67,11 +68,11 @@ class OnRamperBuyProvider extends BuyProvider { .map((item) => PaymentMethod.fromOnramperJson(item as Map)) .toList(); } else { - print('Failed to fetch available payment types'); + printV('Failed to fetch available payment types'); return []; } } catch (e) { - print('Failed to fetch available payment types: $e'); + printV('Failed to fetch available payment types: $e'); return []; } } @@ -98,11 +99,11 @@ class OnRamperBuyProvider extends BuyProvider { return result; } else { - print('Failed to fetch onramp metadata'); + printV('Failed to fetch onramp metadata'); return {}; } } catch (e) { - print('Error occurred: $e'); + printV('Error occurred: $e'); return {}; } } @@ -178,11 +179,11 @@ class OnRamperBuyProvider extends BuyProvider { return validQuotes; } else { - print('Onramper: Failed to fetch rate'); + printV('Onramper: Failed to fetch rate'); return null; } } catch (e) { - print('Onramper: Failed to fetch rate $e'); + printV('Onramper: Failed to fetch rate $e'); return null; } } diff --git a/lib/buy/robinhood/robinhood_buy_provider.dart b/lib/buy/robinhood/robinhood_buy_provider.dart index a64c9d736..271b9c090 100644 --- a/lib/buy/robinhood/robinhood_buy_provider.dart +++ b/lib/buy/robinhood/robinhood_buy_provider.dart @@ -13,6 +13,7 @@ import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/material.dart'; @@ -176,7 +177,7 @@ class RobinhoodBuyProvider extends BuyProvider { if (responseData.containsKey('message')) { log('Robinhood Error: ${responseData['message']}'); } else { - print('Robinhood Failed to fetch $action quote: ${response.statusCode}'); + printV('Robinhood Failed to fetch $action quote: ${response.statusCode}'); } return null; } diff --git a/lib/cake_pay/cake_pay_api.dart b/lib/cake_pay/cake_pay_api.dart index ea44d3335..cc04a0ca1 100644 --- a/lib/cake_pay/cake_pay_api.dart +++ b/lib/cake_pay/cake_pay_api.dart @@ -3,6 +3,7 @@ import 'dart:convert'; import 'package:cake_wallet/cake_pay/cake_pay_order.dart'; import 'package:cake_wallet/cake_pay/cake_pay_user_credentials.dart'; import 'package:cake_wallet/cake_pay/cake_pay_vendor.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cake_wallet/entities/country.dart'; import 'package:http/http.dart' as http; @@ -140,7 +141,7 @@ class CakePayApi { final response = await http.get(uri, headers: headers); - print('Response: ${response.statusCode}'); + printV('Response: ${response.statusCode}'); if (response.statusCode != 200) { throw Exception('Unexpected http status: ${response.statusCode}'); @@ -167,7 +168,7 @@ class CakePayApi { throw Exception('Unexpected http status: ${response.statusCode}'); } } catch (e) { - print('Caught exception: $e'); + printV('Caught exception: $e'); } } diff --git a/lib/core/auth_service.dart b/lib/core/auth_service.dart index 791701395..378c52ec0 100644 --- a/lib/core/auth_service.dart +++ b/lib/core/auth_service.dart @@ -4,6 +4,7 @@ import 'package:cake_wallet/core/secure_storage.dart'; import 'package:cake_wallet/core/totp_request_details.dart'; import 'package:cake_wallet/routes.dart'; import 'package:cake_wallet/src/screens/auth/auth_page.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:mobx/mobx.dart'; import 'package:shared_preferences/shared_preferences.dart'; @@ -51,7 +52,7 @@ class AuthService with Store { try { password = await secureStorage.read(key: key) ?? ''; } catch (e) { - print(e); + printV(e); } return walletName.isNotEmpty && password.isNotEmpty; diff --git a/lib/core/backup_service.dart b/lib/core/backup_service.dart index 3413ec1d3..f101ed7e1 100644 --- a/lib/core/backup_service.dart +++ b/lib/core/backup_service.dart @@ -7,6 +7,7 @@ import 'package:cake_wallet/entities/transaction_description.dart'; import 'package:cake_wallet/themes/theme_list.dart'; import 'package:cw_core/root_dir.dart'; import 'package:cake_wallet/utils/device_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/foundation.dart'; import 'package:hive/hive.dart'; @@ -110,11 +111,11 @@ class BackupService { for (var ignore in ignoreFiles) { final filename = entity.absolute.path; if (filename.endsWith(ignore) && !filename.contains("wallets/")) { - print("ignoring backup file: $filename"); + printV("ignoring backup file: $filename"); return; } } - print("restoring: $filename"); + printV("restoring: $filename"); if (entity.statSync().type == FileSystemEntityType.directory) { zipEncoder.addDirectory(Directory(entity.path)); } else { @@ -175,11 +176,11 @@ class BackupService { final filename = file.name; for (var ignore in ignoreFiles) { if (filename.endsWith(ignore) && !filename.contains("wallets/")) { - print("ignoring backup file: $filename"); + printV("ignoring backup file: $filename"); continue outer; } } - print("restoring: $filename"); + printV("restoring: $filename"); if (file.isFile) { final content = file.content as List; File('${appDir.path}/' + filename) @@ -193,7 +194,7 @@ class BackupService { await _verifyWallets(); await _importKeychainDumpV2(password); await _importPreferencesDump(); - await _importTransactionDescriptionDump(); + await _importTransactionDescriptionDump(); // HiveError: Box has already been closed } Future _verifyWallets() async { diff --git a/lib/core/wallet_connect/chain_service/solana/solana_chain_service.dart b/lib/core/wallet_connect/chain_service/solana/solana_chain_service.dart index efbf9df74..d7fe53c73 100644 --- a/lib/core/wallet_connect/chain_service/solana/solana_chain_service.dart +++ b/lib/core/wallet_connect/chain_service/solana/solana_chain_service.dart @@ -8,6 +8,7 @@ import 'package:cake_wallet/src/screens/wallet_connect/widgets/message_display_w import 'package:cake_wallet/core/wallet_connect/models/connection_model.dart'; import 'package:cake_wallet/src/screens/wallet_connect/widgets/connection_widget.dart'; import 'package:cake_wallet/src/screens/wallet_connect/widgets/modals/web3_request_modal.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:solana/base58.dart'; import 'package:solana/solana.dart'; import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart'; @@ -127,7 +128,7 @@ class SolanaChainServiceImpl implements ChainService { commitment: Commitment.confirmed, ); - print(signature); + printV(signature); bottomSheetService.queueBottomSheet( isModalDismissible: true, @@ -165,7 +166,7 @@ class SolanaChainServiceImpl implements ChainService { try { sign = await ownerKeyPair?.sign(base58decode(solanaSignMessage.message)); } catch (e) { - print(e); + printV(e); } if (sign == null) { diff --git a/lib/core/wallet_connect/web3wallet_service.dart b/lib/core/wallet_connect/web3wallet_service.dart index ba4785643..ad892a594 100644 --- a/lib/core/wallet_connect/web3wallet_service.dart +++ b/lib/core/wallet_connect/web3wallet_service.dart @@ -17,6 +17,7 @@ import 'package:cake_wallet/src/screens/wallet_connect/widgets/connection_reques import 'package:cake_wallet/src/screens/wallet_connect/widgets/message_display_widget.dart'; import 'package:cake_wallet/src/screens/wallet_connect/widgets/modals/web3_request_modal.dart'; import 'package:cake_wallet/store/app_store.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:eth_sig_util/eth_sig_util.dart'; import 'package:flutter/material.dart'; @@ -260,7 +261,7 @@ abstract class Web3WalletServiceBase with Store { @action void _refreshPairings() { - print('Refreshing pairings'); + printV('Refreshing pairings'); pairings.clear(); final allPairings = _web3Wallet.pairings.getAll(); @@ -397,10 +398,10 @@ abstract class Web3WalletServiceBase with Store { // Get all pairing topics attached to this key final pairingTopicsForWallet = getPairingTopicsForWallet(key); - print(pairingTopicsForWallet); + printV(pairingTopicsForWallet); bool isPairingTopicAlreadySaved = pairingTopicsForWallet.contains(pairingTopic); - print('Is Pairing Topic Saved: $isPairingTopicAlreadySaved'); + printV('Is Pairing Topic Saved: $isPairingTopicAlreadySaved'); if (!isPairingTopicAlreadySaved) { // Update the list with the most recent pairing topic diff --git a/lib/core/wallet_loading_service.dart b/lib/core/wallet_loading_service.dart index 3a60197de..6b1553443 100644 --- a/lib/core/wallet_loading_service.dart +++ b/lib/core/wallet_loading_service.dart @@ -12,6 +12,7 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/utils/exception_handler.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cw_core/cake_hive.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_service.dart'; @@ -97,7 +98,7 @@ class WalletLoadingService { // if found a wallet that is not corrupted, then still display the seeds of the corrupted ones authenticatedErrorStreamController.add(corruptedWalletsSeeds); } catch (e) { - print(e); + printV(e); // save seeds and show corrupted wallets' seeds to the user try { final seeds = await _getCorruptedWalletSeeds(walletInfo.name, walletInfo.type); diff --git a/lib/entities/background_tasks.dart b/lib/entities/background_tasks.dart index a373ca0ad..60e4c86cd 100644 --- a/lib/entities/background_tasks.dart +++ b/lib/entities/background_tasks.dart @@ -8,6 +8,7 @@ import 'package:cake_wallet/utils/feature_flag.dart'; import 'package:cake_wallet/view_model/settings/sync_mode.dart'; import 'package:cake_wallet/view_model/wallet_list/wallet_list_item.dart'; import 'package:cake_wallet/view_model/wallet_list/wallet_list_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/foundation.dart'; @@ -83,8 +84,8 @@ void callbackDispatcher() { return Future.value(true); } catch (error, stackTrace) { - print(error); - print(stackTrace); + printV(error); + printV(stackTrace); return Future.error(error); } }); @@ -149,8 +150,8 @@ class BackgroundTasks { constraints: constraints, ); } catch (error, stackTrace) { - print(error); - print(stackTrace); + printV(error); + printV(stackTrace); } } @@ -158,8 +159,8 @@ class BackgroundTasks { try { Workmanager().cancelByUniqueName(moneroSyncTaskKey); } catch (error, stackTrace) { - print(error); - print(stackTrace); + printV(error); + printV(stackTrace); } } } diff --git a/lib/entities/biometric_auth.dart b/lib/entities/biometric_auth.dart index 353cd0492..ca9205f2a 100644 --- a/lib/entities/biometric_auth.dart +++ b/lib/entities/biometric_auth.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/services.dart'; import 'package:flutter_local_authentication/flutter_local_authentication.dart'; @@ -9,7 +10,7 @@ class BiometricAuth { final authenticated = await _flutterLocalAuthenticationPlugin.authenticate(); return authenticated; } catch (e) { - print(e); + printV(e); } return false; } @@ -20,7 +21,7 @@ class BiometricAuth { canAuthenticate = await _flutterLocalAuthenticationPlugin.canAuthenticate(); await _flutterLocalAuthenticationPlugin.setTouchIDAuthenticationAllowableReuseDuration(0); } catch (error) { - print("Exception checking support. $error"); + printV("Exception checking support. $error"); canAuthenticate = false; } diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 7f0679625..f2cfe79b7 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -7,6 +7,7 @@ import 'package:cake_wallet/entities/fiat_api_mode.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cake_wallet/entities/secret_store_key.dart'; import 'package:cw_core/root_dir.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:hive/hive.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:cake_wallet/entities/preferences_key.dart'; @@ -296,7 +297,7 @@ Future defaultSettingsMigration( await sharedPreferences.setInt( PreferencesKey.currentDefaultSettingsMigrationVersion, version); } catch (e) { - print('Migration error: ${e.toString()}'); + printV('Migration error: ${e.toString()}'); } }); @@ -714,7 +715,7 @@ Future insecureStorageMigration({ await secureStorage.write( key: SecureKey.lastAuthTimeMilliseconds, value: lastAuthTimeMilliseconds.toString()); } catch (e) { - print("Error migrating shared preferences to secure storage!: $e"); + printV("Error migrating shared preferences to secure storage!: $e"); // this actually shouldn't be that big of a problem since we don't delete the old keys in this update // and we read and write to the new locations when loading storage, the migration is just for extra safety } @@ -870,7 +871,7 @@ Future addAddressesForMoneroWallets(Box walletInfoSource) asyn info.address = addressText; await info.save(); } catch (e) { - print(e.toString()); + printV(e.toString()); } }); } diff --git a/lib/entities/ens_record.dart b/lib/entities/ens_record.dart index b2ce51806..e07d0731f 100644 --- a/lib/entities/ens_record.dart +++ b/lib/entities/ens_record.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/ethereum/ethereum.dart'; import 'package:cake_wallet/polygon/polygon.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:ens_dart/ens_dart.dart'; @@ -45,7 +46,7 @@ class EnsRecord { final addr = await ens.withName(name).getAddress(); return addr.hex; } catch (e) { - print(e); + printV(e); return ""; } } diff --git a/lib/entities/fs_migration.dart b/lib/entities/fs_migration.dart index ba3541561..a7604f4f1 100644 --- a/lib/entities/fs_migration.dart +++ b/lib/entities/fs_migration.dart @@ -2,6 +2,7 @@ import 'dart:io'; import 'dart:convert'; import 'package:cake_wallet/core/secure_storage.dart'; import 'package:collection/collection.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:hive/hive.dart'; import 'package:path_provider/path_provider.dart'; @@ -171,7 +172,7 @@ Future ios_migrate_wallet_passwords() async { await keyService.saveWalletPassword(walletName: name, password: password!); } } catch (e) { - print(e.toString()); + printV(e.toString()); } }); @@ -326,7 +327,7 @@ Future ios_migrate_wallet_info(Box walletsInfoSource) async { return walletInfo; } } catch (e) { - print(e.toString()); + printV(e.toString()); return null; } }) @@ -336,7 +337,7 @@ Future ios_migrate_wallet_info(Box walletsInfoSource) async { await walletsInfoSource.addAll(infoRecords); await prefs.setBool('ios_migration_wallet_info_completed', true); } catch (e) { - print(e.toString()); + printV(e.toString()); } } @@ -403,7 +404,7 @@ Future ios_migrate_trades_list(Box tradeSource) async { await tradeSource.addAll(trades); await prefs.setBool('ios_migration_trade_list_completed', true); } catch (e) { - print(e.toString()); + printV(e.toString()); } } @@ -437,6 +438,6 @@ Future ios_migrate_address_book(Box contactSource) async { await contactSource.addAll(contacts); await prefs.setBool('ios_migration_address_book_completed', true); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/lib/entities/openalias_record.dart b/lib/entities/openalias_record.dart index 6d8b759f5..b2af2e53d 100644 --- a/lib/entities/openalias_record.dart +++ b/lib/entities/openalias_record.dart @@ -1,4 +1,5 @@ import 'package:basic_utils/basic_utils.dart'; +import 'package:cw_core/utils/print_verbose.dart'; class OpenaliasRecord { OpenaliasRecord({ @@ -27,7 +28,7 @@ class OpenaliasRecord { return txtRecord; } catch (e) { - print("${e.toString()}"); + printV("${e.toString()}"); return null; } } diff --git a/lib/entities/parse_address_from_domain.dart b/lib/entities/parse_address_from_domain.dart index 42ab19b31..54fa4e75a 100644 --- a/lib/entities/parse_address_from_domain.dart +++ b/lib/entities/parse_address_from_domain.dart @@ -11,6 +11,7 @@ import 'package:cake_wallet/nostr/nostr_api.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/twitter/twitter_api.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/entities/fio_address_provider.dart'; @@ -283,7 +284,7 @@ class AddressResolver { } } } catch (e) { - print(e.toString()); + printV(e.toString()); } return ParsedAddress(addresses: [text]); diff --git a/lib/entities/qr_scanner.dart b/lib/entities/qr_scanner.dart index 2e2637566..311bc498a 100644 --- a/lib/entities/qr_scanner.dart +++ b/lib/entities/qr_scanner.dart @@ -5,6 +5,7 @@ import 'package:cake_wallet/main.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:fast_scanner/fast_scanner.dart'; import 'package:flutter/material.dart'; import 'package:flutter/scheduler.dart'; @@ -61,7 +62,7 @@ class _BarcodeScannerSimpleState extends State { ); }, ); - print(e); + printV(e); } } diff --git a/lib/entities/unstoppable_domain_address.dart b/lib/entities/unstoppable_domain_address.dart index 6966fdd75..a047c85d9 100644 --- a/lib/entities/unstoppable_domain_address.dart +++ b/lib/entities/unstoppable_domain_address.dart @@ -1,5 +1,6 @@ import 'dart:convert'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:http/http.dart' as http; Future fetchUnstoppableDomainAddress(String domain, String ticker) async { @@ -20,7 +21,7 @@ Future fetchUnstoppableDomainAddress(String domain, String ticker) async return records[key] as String? ?? ''; } catch (e) { - print('Unstoppable domain error: ${e.toString()}'); + printV('Unstoppable domain error: ${e.toString()}'); address = ''; } diff --git a/lib/ethereum/cw_ethereum.dart b/lib/ethereum/cw_ethereum.dart index 7a06a1679..413cafc30 100644 --- a/lib/ethereum/cw_ethereum.dart +++ b/lib/ethereum/cw_ethereum.dart @@ -205,7 +205,7 @@ class CWEthereum extends Ethereum { try { return await hardwareWalletService.getAvailableAccounts(index: index, limit: limit); } catch (err) { - print(err); + printV(err); throw err; } } diff --git a/lib/exchange/provider/changenow_exchange_provider.dart b/lib/exchange/provider/changenow_exchange_provider.dart index 255767fa1..79f8d70d4 100644 --- a/lib/exchange/provider/changenow_exchange_provider.dart +++ b/lib/exchange/provider/changenow_exchange_provider.dart @@ -15,6 +15,7 @@ import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/utils/distribution_info.dart'; import 'package:cake_wallet/wallet_type_utils.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:http/http.dart'; class ChangeNowExchangeProvider extends ExchangeProvider { @@ -127,7 +128,7 @@ class ChangeNowExchangeProvider extends ExchangeProvider { return isReverse ? (amount / fromAmount) : (toAmount / amount); } catch (e) { - print(e.toString()); + printV(e.toString()); return 0.0; } } diff --git a/lib/exchange/provider/exolix_exchange_provider.dart b/lib/exchange/provider/exolix_exchange_provider.dart index 5eeb6f9cf..49aa56195 100644 --- a/lib/exchange/provider/exolix_exchange_provider.dart +++ b/lib/exchange/provider/exolix_exchange_provider.dart @@ -10,6 +10,7 @@ import 'package:cake_wallet/exchange/trade_request.dart'; import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/exchange/utils/currency_pairs_utils.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:http/http.dart'; class ExolixExchangeProvider extends ExchangeProvider { @@ -124,7 +125,7 @@ class ExolixExchangeProvider extends ExchangeProvider { return responseJSON['rate'] as double; } catch (e) { - print(e.toString()); + printV(e.toString()); return 0.0; } } diff --git a/lib/exchange/provider/quantex_exchange_provider.dart b/lib/exchange/provider/quantex_exchange_provider.dart index a4d8bafe5..ee3473360 100644 --- a/lib/exchange/provider/quantex_exchange_provider.dart +++ b/lib/exchange/provider/quantex_exchange_provider.dart @@ -11,6 +11,7 @@ import 'package:cake_wallet/exchange/trade_request.dart'; import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/exchange/utils/currency_pairs_utils.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:http/http.dart'; class QuantexExchangeProvider extends ExchangeProvider { @@ -86,7 +87,7 @@ class QuantexExchangeProvider extends ExchangeProvider { // coin not found: return Limits(min: 0, max: 0); } catch (e) { - print(e.toString()); + printV(e.toString()); return Limits(min: 0, max: 0); } } @@ -121,7 +122,7 @@ class QuantexExchangeProvider extends ExchangeProvider { double rate = double.parse(data['price'].toString()); return rate; } catch (e) { - print("error fetching rate: ${e.toString()}"); + printV("error fetching rate: ${e.toString()}"); return 0.0; } } @@ -178,7 +179,7 @@ class QuantexExchangeProvider extends ExchangeProvider { isSendAll: isSendAll, ); } catch (e) { - print("error creating trade: ${e.toString()}"); + printV("error creating trade: ${e.toString()}"); throw TradeNotCreatedException(description, description: e.toString()); } } @@ -225,7 +226,7 @@ class QuantexExchangeProvider extends ExchangeProvider { state: state, ); } catch (e) { - print("error getting trade: ${e.toString()}"); + printV("error getting trade: ${e.toString()}"); throw TradeNotFoundException( id, provider: description, diff --git a/lib/exchange/provider/thorchain_exchange.provider.dart b/lib/exchange/provider/thorchain_exchange.provider.dart index 99b9dcf9f..aa7ab2d27 100644 --- a/lib/exchange/provider/thorchain_exchange.provider.dart +++ b/lib/exchange/provider/thorchain_exchange.provider.dart @@ -8,6 +8,7 @@ import 'package:cake_wallet/exchange/trade_request.dart'; import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/exchange/utils/currency_pairs_utils.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; @@ -86,7 +87,7 @@ class ThorChainExchangeProvider extends ExchangeProvider { return _thorChainAmountToDouble(expectedAmountOut) / amount; } catch (e) { - print(e.toString()); + printV(e.toString()); return 0.0; } } diff --git a/lib/exchange/provider/trocador_exchange_provider.dart b/lib/exchange/provider/trocador_exchange_provider.dart index 5529d824a..b01ce9eae 100644 --- a/lib/exchange/provider/trocador_exchange_provider.dart +++ b/lib/exchange/provider/trocador_exchange_provider.dart @@ -9,6 +9,7 @@ import 'package:cake_wallet/exchange/trade_request.dart'; import 'package:cake_wallet/exchange/trade_state.dart'; import 'package:cake_wallet/exchange/utils/currency_pairs_utils.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:http/http.dart'; class TrocadorExchangeProvider extends ExchangeProvider { @@ -148,7 +149,7 @@ class TrocadorExchangeProvider extends ExchangeProvider { return isReceiveAmount ? (amount / fromAmount) : (toAmount / amount); } catch (e) { - print(e.toString()); + printV(e.toString()); return 0.0; } } diff --git a/lib/mastodon/mastodon_api.dart b/lib/mastodon/mastodon_api.dart index 8326ce05d..a2fdc97bd 100644 --- a/lib/mastodon/mastodon_api.dart +++ b/lib/mastodon/mastodon_api.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:http/http.dart' as http; import 'package:cake_wallet/mastodon/mastodon_user.dart'; @@ -27,7 +28,7 @@ class MastodonAPI { return MastodonUser.fromJson(responseJSON); } catch (e) { - print('Error in lookupUserByUserName: $e'); + printV('Error in lookupUserByUserName: $e'); return null; } } @@ -56,7 +57,7 @@ class MastodonAPI { return responseJSON.map((json) => PinnedPost.fromJson(json as Map)).toList(); } catch (e) { - print('Error in getPinnedPosts: $e'); + printV('Error in getPinnedPosts: $e'); throw e; } } diff --git a/lib/nano/cw_nano.dart b/lib/nano/cw_nano.dart index 9e47edc04..9a2243d00 100644 --- a/lib/nano/cw_nano.dart +++ b/lib/nano/cw_nano.dart @@ -249,7 +249,7 @@ class CWNanoUtil extends NanoUtil { try { mnemonic = NanoDerivations.standardSeedToMnemonic(seedKey); } catch (e) { - print("not a valid 'nano' seed key"); + printV("not a valid 'nano' seed key"); } } if (derivationType == DerivationType.bip39) { @@ -306,7 +306,7 @@ class CWNanoUtil extends NanoUtil { try { mnemonic = NanoDerivations.standardSeedToMnemonic(seedKey!); } catch (e) { - print("not a valid 'nano' seed key"); + printV("not a valid 'nano' seed key"); } } diff --git a/lib/nostr/nostr_api.dart b/lib/nostr/nostr_api.dart index 7c0eea5ef..be59f0eba 100644 --- a/lib/nostr/nostr_api.dart +++ b/lib/nostr/nostr_api.dart @@ -5,6 +5,7 @@ import 'package:cake_wallet/nostr/nostr_user.dart'; import 'package:cake_wallet/src/widgets/alert_with_one_action.dart'; import 'package:cake_wallet/src/widgets/picker.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:nostr_tools/nostr_tools.dart'; @@ -83,7 +84,7 @@ class NostrProfileHandler { relay.close(); return null; } catch (e) { - print('[!] Error with relay $relayUrl: $e'); + printV('[!] Error with relay $relayUrl: $e'); return null; } } @@ -115,7 +116,7 @@ class NostrProfileHandler { var uri = Uri.parse(relayUrl); return uri.host; } catch (e) { - print('Error parsing URL: $e'); + printV('Error parsing URL: $e'); return ''; } } diff --git a/lib/polygon/cw_polygon.dart b/lib/polygon/cw_polygon.dart index 74b4026eb..7c447406d 100644 --- a/lib/polygon/cw_polygon.dart +++ b/lib/polygon/cw_polygon.dart @@ -204,7 +204,7 @@ class CWPolygon extends Polygon { try { return await hardwareWalletService.getAvailableAccounts(index: index, limit: limit); } catch (err) { - print(err); + printV(err); throw err; } } diff --git a/lib/reactions/check_connection.dart b/lib/reactions/check_connection.dart index 570b96864..d60037543 100644 --- a/lib/reactions/check_connection.dart +++ b/lib/reactions/check_connection.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/sync_status.dart'; import 'package:cw_core/wallet_type.dart'; @@ -36,7 +37,7 @@ void startCheckConnectionReaction(WalletBase wallet, SettingsStore settingsStore } } } catch (e) { - print(e.toString()); + printV(e.toString()); } }); } diff --git a/lib/reactions/fiat_rate_update.dart b/lib/reactions/fiat_rate_update.dart index e46ef4b64..62710c515 100644 --- a/lib/reactions/fiat_rate_update.dart +++ b/lib/reactions/fiat_rate_update.dart @@ -11,6 +11,7 @@ import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/tron/tron.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/erc20_token.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:mobx/mobx.dart'; @@ -71,7 +72,7 @@ Future startFiatRateUpdate( } } } catch (e) { - print(e); + printV(e); } }; diff --git a/lib/reactions/on_current_node_change.dart b/lib/reactions/on_current_node_change.dart index 59a1e4897..730fba674 100644 --- a/lib/reactions/on_current_node_change.dart +++ b/lib/reactions/on_current_node_change.dart @@ -1,3 +1,4 @@ +import 'package:cw_core/utils/print_verbose.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/node.dart'; import 'package:cake_wallet/store/app_store.dart'; @@ -10,14 +11,14 @@ void startOnCurrentNodeChangeReaction(AppStore appStore) { try { await appStore.wallet!.connectToNode(node: change.newValue!); } catch (e) { - print(e.toString()); + printV(e.toString()); } }); appStore.settingsStore.powNodes.observe((change) async { try { await appStore.wallet!.connectToPowNode(node: change.newValue!); } catch (e) { - print(e.toString()); + printV(e.toString()); } }); } diff --git a/lib/reactions/on_current_wallet_change.dart b/lib/reactions/on_current_wallet_change.dart index b804ff14e..3840b042e 100644 --- a/lib/reactions/on_current_wallet_change.dart +++ b/lib/reactions/on_current_wallet_change.dart @@ -9,6 +9,7 @@ import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/transaction_history.dart'; import 'package:cw_core/balance.dart'; import 'package:cw_core/transaction_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/reactions/check_connection.dart'; import 'package:cake_wallet/reactions/on_wallet_sync_status_change.dart'; @@ -46,7 +47,7 @@ void startCurrentWalletChangeReaction( // appStore.wallet.walletInfo.yatLastUsedAddress = address; // await appStore.wallet.walletInfo.save(); //} catch (e) { - // print(e.toString()); + // printV(e.toString()); //} //}); @@ -91,7 +92,7 @@ void startCurrentWalletChangeReaction( } } } catch (e) { - print(e.toString()); + printV(e.toString()); } }); @@ -138,7 +139,7 @@ void startCurrentWalletChangeReaction( } } } catch (e) { - print(e.toString()); + printV(e.toString()); } }); } diff --git a/lib/reactions/on_wallet_sync_status_change.dart b/lib/reactions/on_wallet_sync_status_change.dart index 96305de04..072602e5f 100644 --- a/lib/reactions/on_wallet_sync_status_change.dart +++ b/lib/reactions/on_wallet_sync_status_change.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/entities/update_haven_rate.dart'; import 'package:cake_wallet/store/dashboard/fiat_conversion_store.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:mobx/mobx.dart'; import 'package:cw_core/transaction_history.dart'; @@ -31,7 +32,7 @@ void startWalletSyncStatusChangeReaction( await WakelockPlus.disable(); } } catch (e) { - print(e.toString()); + printV(e.toString()); } }); } diff --git a/lib/src/screens/buy/buy_webview_page.dart b/lib/src/screens/buy/buy_webview_page.dart index ad6970861..5bca7a2ed 100644 --- a/lib/src/screens/buy/buy_webview_page.dart +++ b/lib/src/screens/buy/buy_webview_page.dart @@ -5,6 +5,7 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/store/dashboard/orders_store.dart'; import 'package:cake_wallet/view_model/buy/buy_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; @@ -103,7 +104,7 @@ class BuyWebViewPageBodyState extends State { } } catch (e) { _isSaving = false; - print(e); + printV(e); } }); } diff --git a/lib/src/screens/connect_device/connect_device_page.dart b/lib/src/screens/connect_device/connect_device_page.dart index c2cc40229..109c5eee2 100644 --- a/lib/src/screens/connect_device/connect_device_page.dart +++ b/lib/src/screens/connect_device/connect_device_page.dart @@ -10,6 +10,7 @@ import 'package:cake_wallet/themes/extensions/cake_text_theme.dart'; import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -127,7 +128,7 @@ class ConnectDevicePageBodyState extends State { _bleRefreshTimer = null; } } catch (e) { - print(e); + printV(e); } } diff --git a/lib/src/screens/connect_device/debug_device_page.dart b/lib/src/screens/connect_device/debug_device_page.dart index bed9d59a7..d5af9f2f6 100644 --- a/lib/src/screens/connect_device/debug_device_page.dart +++ b/lib/src/screens/connect_device/debug_device_page.dart @@ -223,10 +223,10 @@ // setState(() => status = "Sending..."); // final acc = await func(); // setState(() => status = "$method: $acc"); -// print("$method: $acc"); +// printV("$method: $acc"); // } on LedgerException catch (ex) { // setState(() => status = "${ex.errorCode.toRadixString(16)} ${ex.message}"); -// print("${ex.errorCode.toRadixString(16)} ${ex.message}"); +// printV("${ex.errorCode.toRadixString(16)} ${ex.message}"); // } // }, // color: Theme.of(context).primaryColor, diff --git a/lib/src/screens/dashboard/pages/cake_features_page.dart b/lib/src/screens/dashboard/pages/cake_features_page.dart index 07d023b28..bd96fd534 100644 --- a/lib/src/screens/dashboard/pages/cake_features_page.dart +++ b/lib/src/screens/dashboard/pages/cake_features_page.dart @@ -7,6 +7,7 @@ import 'package:cake_wallet/src/widgets/dashboard_card_widget.dart'; import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/view_model/dashboard/cake_features_view_model.dart'; import 'package:flutter/material.dart'; @@ -105,7 +106,7 @@ class CakeFeaturesPage extends StatelessWidget { mode: LaunchMode.externalApplication, ); } catch (e) { - print(e); + printV(e); } } diff --git a/lib/src/screens/root/root.dart b/lib/src/screens/root/root.dart index 6b62435d0..0e37c8570 100644 --- a/lib/src/screens/root/root.dart +++ b/lib/src/screens/root/root.dart @@ -4,6 +4,7 @@ import 'package:cake_wallet/core/auth_service.dart'; import 'package:cake_wallet/core/totp_request_details.dart'; import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/view_model/link_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/material.dart'; @@ -91,7 +92,7 @@ class RootState extends State with WidgetsBindingObserver { handleDeepLinking(await getInitialUri()); } catch (e) { - print(e); + printV(e); } } diff --git a/lib/src/screens/send/send_page.dart b/lib/src/screens/send/send_page.dart index 7003ceafb..1941c8061 100644 --- a/lib/src/screens/send/send_page.dart +++ b/lib/src/screens/send/send_page.dart @@ -28,6 +28,7 @@ import 'package:cake_wallet/utils/request_review_handler.dart'; import 'package:cake_wallet/utils/responsive_layout_util.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cake_wallet/view_model/send/output.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/unspent_coin_type.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/view_model/send/send_view_model.dart'; @@ -584,7 +585,7 @@ class SendPage extends BasePage { mode: LaunchMode.externalApplication, ); } catch (e) { - print(e); + printV(e); } } } diff --git a/lib/src/screens/settings/tor_page.dart b/lib/src/screens/settings/tor_page.dart index 2f544be35..2eb8d6c11 100644 --- a/lib/src/screens/settings/tor_page.dart +++ b/lib/src/screens/settings/tor_page.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/store/app_store.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; // import 'package:tor/tor.dart'; @@ -57,7 +58,7 @@ class _TorPageBodyState extends State { // } // widget.appStore.wallet!.connectToNode(node: node); - print('Done awaiting; tor should be running'); + printV('Done awaiting; tor should be running'); } Future endTor() async { @@ -69,7 +70,7 @@ class _TorPageBodyState extends State { // torEnabled = Tor.instance.enabled; // Update flag // }); // - // print('Done awaiting; tor should be stopped'); + // printV('Done awaiting; tor should be stopped'); } // // @override diff --git a/lib/src/screens/setup_2fa/setup_2fa_enter_code_page.dart b/lib/src/screens/setup_2fa/setup_2fa_enter_code_page.dart index 70660c59d..fad86e94d 100644 --- a/lib/src/screens/setup_2fa/setup_2fa_enter_code_page.dart +++ b/lib/src/screens/setup_2fa/setup_2fa_enter_code_page.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/core/execution_state.dart'; import 'package:cake_wallet/core/totp_request_details.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:cake_wallet/view_model/auth_state.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:cake_wallet/generated/i18n.dart'; @@ -53,7 +54,7 @@ class TotpAuthCodePageState extends State { } if (state is FailureState) { - print(state.error); + printV(state.error); widget.totpArguments.onTotpAuthenticationFinished!(false, this); } diff --git a/lib/src/screens/support_chat/support_chat_page.dart b/lib/src/screens/support_chat/support_chat_page.dart index 97d59a2d9..203b75775 100644 --- a/lib/src/screens/support_chat/support_chat_page.dart +++ b/lib/src/screens/support_chat/support_chat_page.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/screens/base_page.dart'; import 'package:cake_wallet/src/screens/support_chat/widgets/chatwoot_widget.dart'; import 'package:cake_wallet/view_model/support_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; @@ -22,7 +23,7 @@ class SupportChatPage extends BasePage { Widget body(BuildContext context) => FutureBuilder( future: getCookie(), builder: (BuildContext context, AsyncSnapshot snapshot) { - print(snapshot.data); + printV(snapshot.data); if (snapshot.hasData) return ChatwootWidget( secureStorage, diff --git a/lib/src/screens/support_chat/widgets/chatwoot_widget.dart b/lib/src/screens/support_chat/widgets/chatwoot_widget.dart index b49993f7f..4f5e58c97 100644 --- a/lib/src/screens/support_chat/widgets/chatwoot_widget.dart +++ b/lib/src/screens/support_chat/widgets/chatwoot_widget.dart @@ -1,6 +1,7 @@ import 'dart:convert'; import 'package:cake_wallet/core/secure_storage.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; @@ -38,7 +39,7 @@ class ChatwootWidgetState extends State { final eventType = parsedMessage["event"]; if (eventType == 'loaded') { final authToken = parsedMessage["config"]["authToken"]; - print(authToken); + printV(authToken); storeCookie(authToken as String); } } diff --git a/lib/store/settings_store.dart b/lib/store/settings_store.dart index 1ecaf50cc..93299a575 100644 --- a/lib/store/settings_store.dart +++ b/lib/store/settings_store.dart @@ -36,6 +36,7 @@ import 'package:cake_wallet/wownero/wownero.dart'; import 'package:cw_core/node.dart'; import 'package:cw_core/set_app_secure_native.dart'; import 'package:cw_core/transaction_priority.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/material.dart'; @@ -1663,8 +1664,8 @@ abstract class SettingsStoreBase with Store { final windowsInfo = await deviceInfoPlugin.windowsInfo; deviceName = windowsInfo.productName; } catch (e) { - print(e); - print( + printV(e); + printV( 'likely digitalProductId is null wait till https://github.com/fluttercommunity/plus_plugins/pull/3188 is merged'); deviceName = "Windows Device"; } diff --git a/lib/store/yat/yat_store.dart b/lib/store/yat/yat_store.dart index 81c5de3b5..964b96db3 100644 --- a/lib/store/yat/yat_store.dart +++ b/lib/store/yat/yat_store.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/core/secure_storage.dart'; import 'package:cw_core/transaction_history.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/balance.dart'; import 'package:cw_core/transaction_info.dart'; @@ -250,7 +251,7 @@ abstract class YatStoreBase with Store { walletInfo!.save(); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } @@ -265,7 +266,7 @@ abstract class YatStoreBase with Store { // apiKey = await fetchYatApiKey(accessToken); // await secureStorage.write(key: yatApiKey(_wallet.walletInfo.name), value: accessToken); //} catch (e) { - // print(e.toString()); + // printV(e.toString()); //} } diff --git a/lib/utils/distribution_info.dart b/lib/utils/distribution_info.dart index 5a2cb8e9d..2fbb6a175 100644 --- a/lib/utils/distribution_info.dart +++ b/lib/utils/distribution_info.dart @@ -1,5 +1,6 @@ import 'dart:io'; import 'package:cake_wallet/utils/package_info.dart'; +import 'package:cw_core/utils/print_verbose.dart'; enum DistributionType { googleplay, github, appstore, fdroid } @@ -32,7 +33,7 @@ class DistributionInfo { final packageInfo = await PackageInfo.fromPlatform(); return packageInfo.packageName == 'com.android.vending'; } catch (e) { - print('Error: $e'); + printV('Error: $e'); return false; } } diff --git a/lib/utils/exception_handler.dart b/lib/utils/exception_handler.dart index 7fdbf9307..f7fc3684e 100644 --- a/lib/utils/exception_handler.dart +++ b/lib/utils/exception_handler.dart @@ -7,6 +7,7 @@ import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:cake_wallet/utils/show_pop_up.dart'; import 'package:cw_core/root_dir.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:device_info_plus/device_info_plus.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; @@ -67,7 +68,7 @@ class ExceptionHandler { final bool canSend = await FlutterMailer.canSendMail(); if (Platform.isIOS && !canSend) { - debugPrint('Mail app is not available'); + printV('Mail app is not available'); return; } @@ -99,7 +100,7 @@ class ExceptionHandler { static Future onError(FlutterErrorDetails errorDetails) async { if (kDebugMode || kProfileMode) { FlutterError.presentError(errorDetails); - debugPrint(errorDetails.toString()); + printV(errorDetails.toString()); return; } diff --git a/lib/view_model/anonpay_details_view_model.dart b/lib/view_model/anonpay_details_view_model.dart index fe4b9da3d..e83b939cd 100644 --- a/lib/view_model/anonpay_details_view_model.dart +++ b/lib/view_model/anonpay_details_view_model.dart @@ -11,6 +11,7 @@ import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:mobx/mobx.dart'; @@ -47,7 +48,7 @@ abstract class AnonpayDetailsViewModelBase with Store { invoiceDetail.status = data.status; _updateItems(); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/lib/view_model/backup_view_model.dart b/lib/view_model/backup_view_model.dart index bbd147e2b..53e2864d4 100644 --- a/lib/view_model/backup_view_model.dart +++ b/lib/view_model/backup_view_model.dart @@ -5,6 +5,7 @@ import 'package:cake_wallet/core/secure_storage.dart'; import 'package:cake_wallet/entities/secret_store_key.dart'; import 'package:cake_wallet/store/secret_store.dart'; import 'package:cw_core/root_dir.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/foundation.dart'; import 'package:mobx/mobx.dart'; import 'package:intl/intl.dart'; @@ -67,7 +68,7 @@ abstract class BackupViewModelBase with Store { return BackupExportFile(backupContent.toList(), name: fileName); } catch (e) { - print(e.toString()); + printV(e.toString()); state = FailureState(e.toString()); return null; } diff --git a/lib/view_model/buy/buy_item.dart b/lib/view_model/buy/buy_item.dart index 97bd661f2..b6e7523b9 100644 --- a/lib/view_model/buy/buy_item.dart +++ b/lib/view_model/buy/buy_item.dart @@ -2,6 +2,7 @@ import 'package:cake_wallet/buy/buy_amount.dart'; import 'package:cake_wallet/buy/buy_provider.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; import 'package:cake_wallet/view_model/buy/buy_amount_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; class BuyItem { BuyItem({required this.provider, required this.buyAmountViewModel}); @@ -21,7 +22,7 @@ class BuyItem { .calculateAmount(amount?.toString() ?? '', fiatCurrency.title); } catch (e) { _buyAmount = BuyAmount(sourceAmount: 0.0, destAmount: 0.0); - print(e.toString()); + printV(e.toString()); } return _buyAmount; diff --git a/lib/view_model/buy/buy_view_model.dart b/lib/view_model/buy/buy_view_model.dart index 7c2591cbb..181276ed5 100644 --- a/lib/view_model/buy/buy_view_model.dart +++ b/lib/view_model/buy/buy_view_model.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/moonpay/moonpay_provider.dart'; import 'package:cake_wallet/buy/wyre/wyre_buy_provider.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cake_wallet/entities/fiat_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/view_model/buy/buy_item.dart'; @@ -63,7 +64,7 @@ abstract class BuyViewModelBase with Store { try { _url = await selectedProvider!.requestUrl(doubleAmount.toString(), fiatCurrency.title); } catch (e) { - print(e.toString()); + printV(e.toString()); } return _url; @@ -77,7 +78,7 @@ abstract class BuyViewModelBase with Store { await ordersSource.add(order); ordersStore.setOrder(order); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/lib/view_model/dashboard/home_settings_view_model.dart b/lib/view_model/dashboard/home_settings_view_model.dart index 1aeacd28f..0c3a611eb 100644 --- a/lib/view_model/dashboard/home_settings_view_model.dart +++ b/lib/view_model/dashboard/home_settings_view_model.dart @@ -15,6 +15,7 @@ import 'package:cake_wallet/tron/tron.dart'; import 'package:cake_wallet/view_model/dashboard/balance_view_model.dart'; import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/erc20_token.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:mobx/mobx.dart'; import 'package:http/http.dart' as http; @@ -236,7 +237,7 @@ abstract class HomeSettingsViewModelBase with Store { return false; } catch (e) { - print('Error while checking scam via moralis: ${e.toString()}'); + printV('Error while checking scam via moralis: ${e.toString()}'); return true; } } @@ -277,7 +278,7 @@ abstract class HomeSettingsViewModelBase with Store { return false; } catch (e) { - print('Error while checking scam via explorers: ${e.toString()}'); + printV('Error while checking scam via explorers: ${e.toString()}'); return true; } } @@ -303,21 +304,21 @@ abstract class HomeSettingsViewModelBase with Store { final decodedResponse = jsonDecode(response.body) as Map; if (decodedResponse['status'] == '0') { - print('${response.body}\n'); - print('${decodedResponse['result']}\n'); + printV('${response.body}\n'); + printV('${decodedResponse['result']}\n'); return true; } if (decodedResponse['status'] == '1' && decodedResponse['result'][0]['ABI'] == 'Contract source code not verified') { - print('Call is valid but contract is not verified'); + printV('Call is valid but contract is not verified'); return true; // Contract is not verified } else { - print('Call is valid and contract is verified'); + printV('Call is valid and contract is verified'); return false; // Contract is verified } } catch (e) { - print('Error while checking contract verification: ${e.toString()}'); + printV('Error while checking contract verification: ${e.toString()}'); return true; } } diff --git a/lib/view_model/exchange/exchange_trade_view_model.dart b/lib/view_model/exchange/exchange_trade_view_model.dart index 4cb7e4cad..ac0456440 100644 --- a/lib/view_model/exchange/exchange_trade_view_model.dart +++ b/lib/view_model/exchange/exchange_trade_view_model.dart @@ -16,6 +16,7 @@ import 'package:cake_wallet/src/screens/exchange_trade/exchange_trade_item.dart' import 'package:cake_wallet/store/dashboard/trades_store.dart'; import 'package:cake_wallet/view_model/send/send_view_model.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; @@ -139,7 +140,7 @@ abstract class ExchangeTradeViewModelBase with Store { _updateItems(); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/lib/view_model/exchange/exchange_view_model.dart b/lib/view_model/exchange/exchange_view_model.dart index d29b7df6b..ee8a88b6b 100644 --- a/lib/view_model/exchange/exchange_view_model.dart +++ b/lib/view_model/exchange/exchange_view_model.dart @@ -9,6 +9,7 @@ import 'package:cake_wallet/exchange/provider/stealth_ex_exchange_provider.dart' import 'package:cw_core/crypto_currency.dart'; import 'package:cw_core/sync_status.dart'; import 'package:cw_core/transaction_priority.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:hive/hive.dart'; import 'package:http/http.dart' as http; @@ -944,7 +945,7 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with return isContractAddress; } catch (e) { - print(e); + printV(e); return false; } } diff --git a/lib/view_model/hardware_wallet/ledger_view_model.dart b/lib/view_model/hardware_wallet/ledger_view_model.dart index 3cd131efa..9a4bb6a45 100644 --- a/lib/view_model/hardware_wallet/ledger_view_model.dart +++ b/lib/view_model/hardware_wallet/ledger_view_model.dart @@ -9,6 +9,7 @@ import 'package:cake_wallet/polygon/polygon.dart'; import 'package:cake_wallet/utils/device_info.dart'; import 'package:cake_wallet/wallet_type_utils.dart'; import 'package:cw_core/hardware/device_connection_type.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; @@ -95,7 +96,7 @@ abstract class LedgerViewModelBase with Store { if (_connectionChangeListener == null) { _connectionChangeListener = ledger.deviceStateChanges.listen((event) { - print('Ledger Device State Changed: $event'); + printV('Ledger Device State Changed: $event'); if (event == sdk.BleConnectionState.disconnected) { _connection = null; if (type == WalletType.monero) { diff --git a/lib/view_model/order_details_view_model.dart b/lib/view_model/order_details_view_model.dart index 1eab2f861..a7cd98a21 100644 --- a/lib/view_model/order_details_view_model.dart +++ b/lib/view_model/order_details_view_model.dart @@ -3,6 +3,7 @@ import 'package:cake_wallet/buy/buy_provider.dart'; import 'package:cake_wallet/buy/buy_provider_description.dart'; import 'package:cake_wallet/buy/order.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:mobx/mobx.dart'; import 'package:cake_wallet/generated/i18n.dart'; import 'package:cake_wallet/src/screens/transaction_details/standart_list_item.dart'; @@ -65,7 +66,7 @@ abstract class OrderDetailsViewModelBase with Store { _updateItems(); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/lib/view_model/send/output.dart b/lib/view_model/send/output.dart index e53127e0c..f977ef003 100644 --- a/lib/view_model/send/output.dart +++ b/lib/view_model/send/output.dart @@ -11,6 +11,7 @@ import 'package:cake_wallet/src/screens/send/widgets/extract_address_from_parsed import 'package:cake_wallet/tron/tron.dart'; import 'package:cake_wallet/wownero/wownero.dart'; import 'package:cw_core/crypto_currency.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:mobx/mobx.dart'; @@ -180,7 +181,7 @@ abstract class OutputBase with Store { return polygon!.formatterPolygonAmountToDouble(amount: BigInt.from(fee)); } } catch (e) { - print(e.toString()); + printV(e.toString()); } return 0; diff --git a/lib/view_model/send/send_view_model.dart b/lib/view_model/send/send_view_model.dart index fb96b2545..70958fb99 100644 --- a/lib/view_model/send/send_view_model.dart +++ b/lib/view_model/send/send_view_model.dart @@ -27,6 +27,7 @@ import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/unspent_coin_type.dart'; import 'package:cake_wallet/view_model/send/output.dart'; import 'package:cake_wallet/view_model/send/send_template_view_model.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import 'package:mobx/mobx.dart'; @@ -672,7 +673,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor lamportsNeeded != null ? ((lamportsNeeded + 5000) / lamportsPerSol) : 0.0; return S.current.insufficient_lamports(solValueNeeded.toString()); } else { - print("No match found."); + printV("No match found."); return S.current.insufficient_lamport_for_tx; } } diff --git a/lib/view_model/trade_details_view_model.dart b/lib/view_model/trade_details_view_model.dart index 19315f40d..59813090d 100644 --- a/lib/view_model/trade_details_view_model.dart +++ b/lib/view_model/trade_details_view_model.dart @@ -22,6 +22,7 @@ import 'package:cake_wallet/store/settings_store.dart'; import 'package:cake_wallet/utils/date_formatter.dart'; import 'package:cake_wallet/utils/show_bar.dart'; import 'package:collection/collection.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:hive/hive.dart'; @@ -134,7 +135,7 @@ abstract class TradeDetailsViewModelBase with Store { _updateItems(); } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/lib/view_model/transaction_details_view_model.dart b/lib/view_model/transaction_details_view_model.dart index e675acf17..9ec542361 100644 --- a/lib/view_model/transaction_details_view_model.dart +++ b/lib/view_model/transaction_details_view_model.dart @@ -1,5 +1,6 @@ import 'package:cake_wallet/tron/tron.dart'; import 'package:cake_wallet/wownero/wownero.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/transaction_info.dart'; import 'package:cw_core/wallet_type.dart'; @@ -279,7 +280,7 @@ abstract class TransactionDetailsViewModelBase with Store { )); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } @@ -769,7 +770,7 @@ abstract class TransactionDetailsViewModelBase with Store { ); } } catch (e) { - print(e.toString()); + printV(e.toString()); } } diff --git a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart index 6c15511b5..52820adcb 100644 --- a/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart +++ b/lib/view_model/unspent_coins/unspent_coins_list_view_model.dart @@ -6,6 +6,7 @@ import 'package:cake_wallet/wownero/wownero.dart'; import 'package:cw_core/unspent_coin_type.dart'; import 'package:cw_core/unspent_coins_info.dart'; import 'package:cw_core/unspent_transaction_output.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_type.dart'; import 'package:flutter/cupertino.dart'; @@ -82,7 +83,7 @@ abstract class UnspentCoinsListViewModelBase with Store { await existingInfo.save(); _updateUnspentCoinsInfo(); } catch (e) { - print('Error saving coin info: $e'); + printV('Error saving coin info: $e'); } } @@ -151,7 +152,7 @@ abstract class UnspentCoinsListViewModelBase with Store { isSilentPayment: existingItem.isSilentPayment ?? false, ); } catch (e, s) { - print('Error: $e\nStack: $s'); + printV('Error: $e\nStack: $s'); ExceptionHandler.onError( FlutterErrorDetails(exception: e, stack: s), ); diff --git a/lib/view_model/wallet_creation_vm.dart b/lib/view_model/wallet_creation_vm.dart index 17a8d6d28..68548b64a 100644 --- a/lib/view_model/wallet_creation_vm.dart +++ b/lib/view_model/wallet_creation_vm.dart @@ -12,6 +12,7 @@ import 'package:cake_wallet/view_model/restore/restore_mode.dart'; import 'package:cake_wallet/view_model/restore/restore_wallet.dart'; import 'package:cake_wallet/view_model/seed_settings_view_model.dart'; import 'package:cw_core/pathForWallet.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; @@ -116,8 +117,8 @@ abstract class WalletCreationVMBase with Store { _appStore.authenticationStore.allowed(); state = ExecutedSuccessfullyState(); } catch (e, s) { - print("error: $e"); - print("stack: $s"); + printV("error: $e"); + printV("stack: $s"); state = FailureState(e.toString()); } } diff --git a/lib/view_model/wallet_hardware_restore_view_model.dart b/lib/view_model/wallet_hardware_restore_view_model.dart index 0971622a5..541e169d0 100644 --- a/lib/view_model/wallet_hardware_restore_view_model.dart +++ b/lib/view_model/wallet_hardware_restore_view_model.dart @@ -10,6 +10,7 @@ import 'package:cake_wallet/view_model/hardware_wallet/ledger_view_model.dart'; import 'package:cake_wallet/view_model/seed_settings_view_model.dart'; import 'package:cake_wallet/view_model/wallet_creation_vm.dart'; import 'package:cw_core/hardware/hardware_account_data.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; @@ -82,7 +83,7 @@ abstract class WalletHardwareRestoreViewModelBase extends WalletCreationVM with // } on LedgerException catch (e) { // error = ledgerViewModel.interpretErrorCode(e.errorCode.toRadixString(16)); } catch (e) { - print(e); + printV(e); error = S.current.ledger_connection_error; } diff --git a/tool/append_translation.dart b/tool/append_translation.dart index 5a3658cd0..8ef646502 100644 --- a/tool/append_translation.dart +++ b/tool/append_translation.dart @@ -1,3 +1,5 @@ +import 'package:cw_core/utils/print_verbose.dart'; + import 'utils/translation/arb_file_utils.dart'; import 'utils/translation/translation_constants.dart'; import 'utils/translation/translation_utils.dart'; @@ -14,7 +16,7 @@ void main(List args) async { final text = args[1]; final force = args.last == "--force"; - print('Appending "$name": "$text"'); + printV('Appending "$name": "$text"'); // add translation to all languages: for (var lang in langs) { @@ -24,12 +26,12 @@ void main(List args) async { appendStringToArbFile(fileName, name, translation, force: force); } - print('Alphabetizing all files...'); + printV('Alphabetizing all files...'); for (var lang in langs) { final fileName = getArbFileName(lang); alphabetizeArbFile(fileName); } - print('Done!'); + printV('Done!'); } \ No newline at end of file diff --git a/tool/configure.dart b/tool/configure.dart index 7199b8a82..d9d5c6667 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -95,6 +95,7 @@ import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_service.dart'; import 'package:cw_core/wallet_type.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:cw_core/get_height_by_date.dart'; import 'package:hive/hive.dart'; import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger; @@ -834,6 +835,7 @@ import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_service.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:hive/hive.dart'; import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger; import 'package:web3dart/web3dart.dart'; @@ -938,6 +940,7 @@ import 'package:cw_core/wallet_base.dart'; import 'package:cw_core/wallet_credentials.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_service.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:hive/hive.dart'; import 'package:ledger_flutter_plus/ledger_flutter_plus.dart' as ledger; import 'package:web3dart/web3dart.dart'; @@ -1100,6 +1103,7 @@ import 'package:cw_core/wallet_service.dart'; import 'package:cw_core/output_info.dart'; import 'package:cw_core/nano_account_info_response.dart'; import 'package:cw_core/n2_node.dart'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:mobx/mobx.dart'; import 'package:hive/hive.dart'; import 'package:cake_wallet/view_model/send/output.dart'; diff --git a/tool/download_moneroc_prebuilds.dart b/tool/download_moneroc_prebuilds.dart index 9df0b4e7b..5169ea687 100644 --- a/tool/download_moneroc_prebuilds.dart +++ b/tool/download_moneroc_prebuilds.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:cw_core/utils/print_verbose.dart'; import 'package:dio/dio.dart'; import 'package:archive/archive_io.dart'; @@ -29,7 +30,7 @@ Future main() async { final resp = await _dio.get("https://api.github.com/repos/mrcyjanek/monero_c/releases"); final data = resp.data[0]; final tagName = data['tag_name']; - print("Downloading artifacts for: ${tagName}"); + printV("Downloading artifacts for: ${tagName}"); final assets = data['assets'] as List; for (var i = 0; i < assets.length; i++) { for (var triplet in triplets) { @@ -40,9 +41,9 @@ Future main() async { String localFilename = filename.replaceAll("${coin}_${triplet}_", ""); localFilename = "scripts/monero_c/release/${coin}/${triplet}_${localFilename}"; final url = asset["browser_download_url"] as String; - print("- downloading $localFilename"); + printV("- downloading $localFilename"); await _dio.download(url, localFilename); - print(" extracting $localFilename"); + printV(" extracting $localFilename"); final inputStream = InputFileStream(localFilename); final archive = XZDecoder().decodeBuffer(inputStream); final outputStream = OutputFileStream(localFilename.replaceAll(".xz", "")); @@ -50,11 +51,11 @@ Future main() async { } } if (Platform.isMacOS) { - print("Generating ios framework"); + printV("Generating ios framework"); final result = Process.runSync("bash", [ "-c", "cd scripts/ios && ./gen_framework.sh && cd ../.." ]); - print((result.stdout+result.stderr).toString().trim()); + printV((result.stdout+result.stderr).toString().trim()); } } \ No newline at end of file diff --git a/tool/generate_localization.dart b/tool/generate_localization.dart index 530b316ac..0f9af8366 100644 --- a/tool/generate_localization.dart +++ b/tool/generate_localization.dart @@ -1,5 +1,7 @@ import 'dart:io'; import 'dart:convert'; +import 'package:cw_core/utils/print_verbose.dart'; + import 'localization/localization_constants.dart'; import 'utils/utils.dart'; @@ -35,7 +37,7 @@ Future main(List args) async { extraInfo.forEach((key, dynamic value) async { if (key != srcDir) { - print('Wrong key: $key'); + printV('Wrong key: $key'); return; } @@ -43,7 +45,7 @@ Future main(List args) async { final dir = Directory(dirPath); if (!await dir.exists()) { - print('Wrong directory path: $dirPath'); + printV('Wrong directory path: $dirPath'); return; } @@ -53,12 +55,12 @@ Future main(List args) async { final shortLocale = element.path.split('_',)[1].split('.')[0]; localePath[shortLocale] = element.path; } catch (e) { - print('Wrong file: ${element.path}'); + printV('Wrong file: ${element.path}'); } }); if (!localePath.keys.contains(defaultLocale)) { - print("Locale list doesn't contain $defaultLocale"); + printV("Locale list doesn't contain $defaultLocale"); return; } @@ -115,7 +117,7 @@ Future main(List args) async { await File(outputPath + localeListFileName).writeAsString(locales); } catch (e) { - print(e.toString()); + printV(e.toString()); } }); } diff --git a/tool/translation_add_lang.dart b/tool/translation_add_lang.dart index 8b392df6e..96f22158d 100644 --- a/tool/translation_add_lang.dart +++ b/tool/translation_add_lang.dart @@ -1,5 +1,7 @@ import 'dart:io'; +import 'package:cw_core/utils/print_verbose.dart'; + import 'utils/translation/arb_file_utils.dart'; import 'utils/translation/translation_constants.dart'; import 'utils/translation/translation_utils.dart'; @@ -32,5 +34,5 @@ void main(List args) async { } appendStringsToArbFile(targetFileName, translations); - print("Success! Please add your Language Code to lib/entities/language_service.dart"); + printV("Success! Please add your Language Code to lib/entities/language_service.dart"); } diff --git a/tool/translation_consistence.dart b/tool/translation_consistence.dart index 7f3ac130e..df24cce15 100644 --- a/tool/translation_consistence.dart +++ b/tool/translation_consistence.dart @@ -1,18 +1,20 @@ import 'dart:io'; +import 'package:cw_core/utils/print_verbose.dart'; + import 'utils/translation/arb_file_utils.dart'; import 'utils/translation/translation_constants.dart'; import 'utils/translation/translation_utils.dart'; void main(List args) async { - print('Checking Consistency of all arb-files. Default: $defaultLang'); + printV('Checking Consistency of all arb-files. Default: $defaultLang'); final doFix = args.contains("--fix"); if (doFix) - print('Auto fixing enabled!\n'); + printV('Auto fixing enabled!\n'); else - print('Auto fixing disabled!\nRun with arg "--fix" to enable autofix\n'); + printV('Auto fixing disabled!\nRun with arg "--fix" to enable autofix\n'); final fileName = getArbFileName(defaultLang); final file = File(fileName); @@ -25,7 +27,7 @@ void main(List args) async { final missingDefaults = {}; missingKeys.forEach((key) { - print('Missing in "$lang": "$key"'); + printV('Missing in "$lang": "$key"'); if (doFix) missingDefaults[key] = arbObj[key] as String; }); diff --git a/tool/utils/translation/arb_file_utils.dart b/tool/utils/translation/arb_file_utils.dart index 414d318dd..0fe31d85d 100644 --- a/tool/utils/translation/arb_file_utils.dart +++ b/tool/utils/translation/arb_file_utils.dart @@ -1,12 +1,14 @@ import 'dart:convert'; import 'dart:io'; +import 'package:cw_core/utils/print_verbose.dart'; + void appendStringToArbFile(String fileName, String name, String text, {bool force = false}) { final file = File(fileName); final arbObj = readArbFile(file); if (arbObj.containsKey(name) && !force) { - print("String $name already exists in $fileName!"); + printV("String $name already exists in $fileName!"); return; }