Skip to content

Commit

Permalink
missing print statements, error fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Nov 26, 2024
1 parent 76bba3a commit 68c0697
Show file tree
Hide file tree
Showing 27 changed files with 70 additions and 74 deletions.
2 changes: 1 addition & 1 deletion cw_bitcoin/lib/electrum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class ElectrumClient {
socket = null;
},
onDone: () {
print("SOCKET CLOSED!!!!!");
printV("SOCKET CLOSED!!!!!");
unterminatedString = '';
try {
if (host == socket?.address.host || socket == null) {
Expand Down
16 changes: 8 additions & 8 deletions cw_bitcoin/lib/electrum_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ abstract class ElectrumWalletBase
_feeRates = [slowFee, mediumFee, fastFee];
return;
} catch (e) {
print(e);
printV(e);
}
}

Expand Down Expand Up @@ -1953,7 +1953,7 @@ abstract class ElectrumWalletBase
}

Future<void> updateTransactions() async {
print("updateTransactions() called!");
printV("updateTransactions() called!");
try {
if (_isTransactionUpdating) {
return;
Expand Down Expand Up @@ -2004,13 +2004,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 {
Expand All @@ -2028,7 +2028,7 @@ abstract class ElectrumWalletBase
));
}
}, onError: (e, s) {
print("sub_listen error: $e $s");
printV("sub_listen error: $e $s");
});
}));
}
Expand Down Expand Up @@ -2080,7 +2080,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);
}
Expand All @@ -2107,7 +2107,7 @@ abstract class ElectrumWalletBase
}

Future<void> updateBalance() async {
print("updateBalance() called!");
printV("updateBalance() called!");
balance[currency] = await fetchBalances();
await save();
}
Expand Down Expand Up @@ -2247,7 +2247,7 @@ abstract class ElectrumWalletBase
}

void _syncStatusReaction(SyncStatus syncStatus) async {
print("SYNC_STATUS_CHANGE: ${syncStatus}");
printV("SYNC_STATUS_CHANGE: ${syncStatus}");
if (syncStatus is SyncingSyncStatus) {
return;
}
Expand Down
13 changes: 1 addition & 12 deletions cw_bitcoin/lib/litecoin_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,6 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
}

_syncTimer?.cancel();
_syncTimer = Timer.periodic(const Duration(milliseconds: 1500), (timer) async {
if (syncStatus is FailedSyncStatus) return;

printV("SYNCING....");
printV("DONE SYNC FUNCS");
} catch (e, s) {
printV("mweb sync failed: $e $s");
mwebSyncStatus = FailedSyncStatus(error: "mweb sync failed: $e");
return;
}

_syncTimer = Timer.periodic(const Duration(milliseconds: 3000), (timer) async {
if (mwebSyncStatus is FailedSyncStatus) {
_syncTimer?.cancel();
Expand Down Expand Up @@ -1189,7 +1178,7 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
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;
Expand Down
8 changes: 4 additions & 4 deletions cw_bitcoin/lib/litecoin_wallet_addresses.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,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
Expand Down
4 changes: 2 additions & 2 deletions cw_core/lib/utils/print_verbose.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
void printV(dynamic content) {
CustomTrace programInfo = CustomTrace(StackTrace.current);
print("${programInfo.fileName}#${programInfo.lineNumber}:${programInfo.columnNumber} ${programInfo.callerFunctionName}: $content");
printV("${programInfo.fileName}#${programInfo.lineNumber}:${programInfo.columnNumber} ${programInfo.callerFunctionName}: $content");
}

// https://stackoverflow.com/a/59386101
Expand All @@ -18,7 +18,7 @@ class CustomTrace {
try {
_parseTrace();
} catch (e) {
print("Unable to parse trace (printV): $e");
printV("Unable to parse trace (printV): $e");
}
}

Expand Down
3 changes: 2 additions & 1 deletion cw_evm/lib/evm_ledger_credentials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions cw_monero/lib/ledger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ void enableLedgerExchange(monero.wallet ptr, LedgerConnection connection) {
ptr, emptyPointer.cast<UnsignedChar>(), 0);
malloc.free(emptyPointer);

// print("> ${ledgerRequest.toHexString()}");
// printV("> ${ledgerRequest.toHexString()}");
final response = await exchange(connection, ledgerRequest);
// print("< ${response.toHexString()}");
// printV("< ${response.toHexString()}");

final Pointer<Uint8> result = malloc<Uint8>(response.length);
for (var i = 0; i < response.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion cw_monero/lib/monero_wallet_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -273,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;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cw_mweb/lib/cw_mweb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CwMweb {
}

static Future<void> _initializeClient() async {
print("_initializeClient() called!");
printV("_initializeClient() called!");
final appDir = await getApplicationSupportDirectory();
const ltcNodeUri = "ltc-electrum.cakewallet.com:9333";

Expand Down
6 changes: 4 additions & 2 deletions cw_wownero/lib/mywownero.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'package:cw_core/utils/print_verbose.dart';

const prefixLength = 3;

String swapEndianBytes(String original) {
Expand Down Expand Up @@ -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 '';
}

Expand Down
Binary file added ios/ZanoWallet.framework/ZanoWallet
Binary file not shown.
1 change: 1 addition & 0 deletions ios/zano_libwallet2_api_c.dylib
2 changes: 1 addition & 1 deletion lib/bitcoin/cw_bitcoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class CWBitcoin extends Bitcoin {
try {
return hardwareWalletService.getAvailableAccounts(index: index, limit: limit);
} catch (err) {
print(err);
printV(err);
throw err;
}
}
Expand Down
11 changes: 6 additions & 5 deletions lib/buy/dfx/dfx_buy_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {};
}
}
Expand Down Expand Up @@ -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<String, dynamic> && 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;
}
}
Expand Down
7 changes: 4 additions & 3 deletions lib/buy/meld/meld_buy_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -75,11 +76,11 @@ class MeldBuyProvider extends BuyProvider {
data.map((e) => PaymentMethod.fromMeldJson(e as Map<String, dynamic>)).toList();
return paymentMethods;
} else {
print('Meld: Failed to fetch payment types');
printV('Meld: Failed to fetch payment types');
return List<PaymentMethod>.empty();
}
} catch (e) {
print('Meld: Failed to fetch payment types: $e');
printV('Meld: Failed to fetch payment types: $e');
return List<PaymentMethod>.empty();
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
15 changes: 4 additions & 11 deletions lib/buy/moonpay/moonpay_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ class MoonPayProvider extends BuyProvider {
if (response.statusCode == 200) {
return jsonDecode(response.body) as Map<String, dynamic>;
} 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 {};
}
}
Expand Down Expand Up @@ -205,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;
}
}
Expand Down Expand Up @@ -329,13 +329,6 @@ class MoonPayProvider extends BuyProvider {
return '${currency.title.toLowerCase()}_polygon';
}

try {
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
isBuyEnable = responseJSON['isBuyAllowed'] as bool;
} catch (e) {
isBuyEnable = false;
printV(e.toString());
}
if (currency.tag == 'TRX') {
return '${currency.title.toLowerCase()}_trx';
}
Expand Down
13 changes: 7 additions & 6 deletions lib/buy/onramper/onramper_buy_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -67,11 +68,11 @@ class OnRamperBuyProvider extends BuyProvider {
.map((item) => PaymentMethod.fromOnramperJson(item as Map<String, dynamic>))
.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 [];
}
}
Expand All @@ -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 {};
}
}
Expand Down Expand Up @@ -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;
}
}
Expand Down
Loading

0 comments on commit 68c0697

Please sign in to comment.