Skip to content

Commit

Permalink
Refactor memo
Browse files Browse the repository at this point in the history
  • Loading branch information
zaelgohary committed Jan 29, 2025
1 parent f1513e6 commit 895eac5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions packages/stellar_client/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,14 @@ class Client {
required bool funded}) async {
// check if I have enough balance
final accountBalances = await this.getBalance();
Memo memo = Memo.none();

if (memoText != null) {
memo = Memo.text(memoText);
} else if (memoHash != null) {
memo = Memo.hash(memoHash);
}

accountBalances.firstWhere(
(b) =>
b.assetCode == currency &&
Expand Down Expand Up @@ -344,22 +352,14 @@ class Client {
.addOperation(
PaymentOperationBuilder(destinationAddress, tftAsset, amount)
.build())
.addMemo(memoText != null
? Memo.text(memoText)
: memoHash != null
? Memo.hash(memoHash)
: Memo.none())
.addMemo(memo)
.build();
} else {
transaction = TransactionBuilder(sender)
.addOperation(
PaymentOperationBuilder(destinationAddress, tftAsset, amount)
.build())
.addMemo(memoText != null
? Memo.text(memoText)
: memoHash != null
? Memo.hash(memoHash)
: Memo.none())
.addMemo(memo)
.build();
}

Expand Down

0 comments on commit 895eac5

Please sign in to comment.