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

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

View file

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