CW 781 replace all print statements with printV (#1733)

* replace all print statements with printV

* restore backup error message

* missing print statements, error fixes

* Update cw_core/lib/utils/print_verbose.dart [skip ci]

* Update cw_core/lib/utils/print_verbose.dart [skip ci]

* CW-846: Correctly display balance (#1848)

* Correctly display balance even with frozen coins

* remove package= from AndroidMainfest.xml

* update namespace

* print -> printV

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
cyan 2024-12-09 12:23:59 -06:00 committed by GitHub
parent c74194abf4
commit c78662fbfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
124 changed files with 578 additions and 343 deletions

View file

@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:ffi';
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/setup_wallet_exception.dart';
import 'package:monero/wownero.dart' as wownero;
@ -10,7 +11,7 @@ import 'package:mutex/mutex.dart';
int getSyncingHeight() {
// final height = wownero.WOWNERO_cw_WalletListener_height(getWlptr());
final h2 = wownero.Wallet_blockChainHeight(wptr!);
// print("height: $height / $h2");
// printV("height: $height / $h2");
return h2;
}
@ -71,7 +72,7 @@ Map<int, Map<int, Map<int, String>>> 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<bool> setupNodeSync(
bool useSSL = false,
bool isLightWallet = false,
String? socksProxyAddress}) async {
print('''
printV('''
{
wptr!,
daemonAddress: $address,
@ -125,7 +126,7 @@ Future<bool> setupNodeSync(
if (status != 0) {
final error = wownero.Wallet_errorString(wptr!);
print("error: $error");
printV("error: $error");
throw SetupWalletException(message: error);
}

View file

@ -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;

View file

@ -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 '';
}

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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<void>.delayed(Duration(seconds: 1));
} catch (e) {
print(e.toString());
printV(e.toString());
}
}

View file

@ -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());
}
}

View file

@ -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());
}
}
}