From 16456c99d4ab3697030c3fb9603b7decb59bfae7 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Mon, 27 Jan 2025 18:37:46 +0200 Subject: [PATCH 1/2] Add memo hash --- packages/stellar_client/lib/src/client.dart | 33 +++++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/stellar_client/lib/src/client.dart b/packages/stellar_client/lib/src/client.dart index ae60fe0..f5359e7 100644 --- a/packages/stellar_client/lib/src/client.dart +++ b/packages/stellar_client/lib/src/client.dart @@ -13,8 +13,15 @@ class Client { Uint8List? get privateKey => _keyPair.privateKey; var logger = Logger( - printer: PrettyPrinter(), - ); + printer: PrettyPrinter( + methodCount: 2, // Number of method calls to be displayed + errorMethodCount: 8, // Number of method calls if stacktrace is provided + lineLength: 120, // Width of the output + colors: true, // Colorful log messages + printEmojis: true, // Print an emoji for each log message + // Should each log print contain a timestamp + dateTimeFormat: DateTimeFormat.onlyTimeAndSinceStart, + )); Client(this._network, String secretSeed) { _keyPair = KeyPair.fromSecretSeed(secretSeed); @@ -161,12 +168,15 @@ class Client { {required String destinationAddress, required String amount, required String currency, - String? memoText}) async { + String? memoText, + Uint8List? memoHash}) async { try { Transaction? transaction = await _buildTransaction( destinationAddress: destinationAddress, amount: amount, currency: currency, + memoText: memoText, + memoHash: memoHash, funded: false); transaction!.sign(_keyPair, _stellarNetwork); @@ -293,6 +303,7 @@ class Client { required String amount, required String currency, String? memoText, + Uint8List? memoHash, required bool funded}) async { // check if I have enough balance final accountBalances = await this.getBalance(); @@ -332,14 +343,22 @@ class Client { .addOperation( PaymentOperationBuilder(destinationAddress, tftAsset, amount) .build()) - .addMemo(memoText != null ? Memo.text(memoText) : Memo.none()) + .addMemo(memoText != null + ? Memo.text(memoText) + : memoHash != null + ? Memo.hash(memoHash) + : Memo.none()) .build(); } else { transaction = TransactionBuilder(sender) .addOperation( PaymentOperationBuilder(destinationAddress, tftAsset, amount) .build()) - .addMemo(memoText != null ? Memo.text(memoText) : Memo.none()) + .addMemo(memoText != null + ? Memo.text(memoText) + : memoHash != null + ? Memo.hash(memoHash) + : Memo.none()) .build(); } @@ -350,12 +369,14 @@ class Client { {required String destinationAddress, required String amount, required String currency, - String? memoText}) async { + String? memoText, + Uint8List? memoHash}) async { Transaction? fundedTransaction = await _buildTransaction( destinationAddress: destinationAddress, amount: amount, currency: currency, memoText: memoText, + memoHash: memoHash, funded: true); fundedTransaction!.sign(_keyPair, _stellarNetwork); From 170359e72848ff1306ef8e47a5ebf66a47410645 Mon Sep 17 00:00:00 2001 From: zaelgohary Date: Tue, 28 Jan 2025 12:50:30 +0200 Subject: [PATCH 2/2] Fix logger --- packages/stellar_client/lib/src/client.dart | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/stellar_client/lib/src/client.dart b/packages/stellar_client/lib/src/client.dart index f5359e7..4ca9bc9 100644 --- a/packages/stellar_client/lib/src/client.dart +++ b/packages/stellar_client/lib/src/client.dart @@ -13,15 +13,16 @@ class Client { Uint8List? get privateKey => _keyPair.privateKey; var logger = Logger( - printer: PrettyPrinter( - methodCount: 2, // Number of method calls to be displayed - errorMethodCount: 8, // Number of method calls if stacktrace is provided - lineLength: 120, // Width of the output - colors: true, // Colorful log messages - printEmojis: true, // Print an emoji for each log message - // Should each log print contain a timestamp - dateTimeFormat: DateTimeFormat.onlyTimeAndSinceStart, - )); + printer: PrettyPrinter( + methodCount: 2, + errorMethodCount: 8, + lineLength: 120, + colors: true, + printEmojis: true, + printTime: true), + level: Level.debug, + filter: ProductionFilter(), + ); Client(this._network, String secretSeed) { _keyPair = KeyPair.fromSecretSeed(secretSeed);