Skip to content

Commit

Permalink
Merge pull request #137 from threefoldtech/development_add_memo_hash
Browse files Browse the repository at this point in the history
Add memo hash
  • Loading branch information
zaelgohary authored Jan 29, 2025
2 parents 77f8f56 + 170359e commit f1513e6
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions packages/stellar_client/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@ class Client {
Uint8List? get privateKey => _keyPair.privateKey;

var logger = Logger(
printer: PrettyPrinter(),
printer: PrettyPrinter(
methodCount: 2,
errorMethodCount: 8,
lineLength: 120,
colors: true,
printEmojis: true,
printTime: true),
level: Level.debug,
filter: ProductionFilter(),
);

Client(this._network, String secretSeed) {
Expand Down Expand Up @@ -161,12 +169,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);
Expand Down Expand Up @@ -293,6 +304,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();
Expand Down Expand Up @@ -332,14 +344,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();
}

Expand All @@ -350,12 +370,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);
Expand Down

0 comments on commit f1513e6

Please sign in to comment.