Skip to content

Commit 895eac5

Browse files
committed
Refactor memo
1 parent f1513e6 commit 895eac5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/stellar_client/lib/src/client.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,14 @@ class Client {
308308
required bool funded}) async {
309309
// check if I have enough balance
310310
final accountBalances = await this.getBalance();
311+
Memo memo = Memo.none();
312+
313+
if (memoText != null) {
314+
memo = Memo.text(memoText);
315+
} else if (memoHash != null) {
316+
memo = Memo.hash(memoHash);
317+
}
318+
311319
accountBalances.firstWhere(
312320
(b) =>
313321
b.assetCode == currency &&
@@ -344,22 +352,14 @@ class Client {
344352
.addOperation(
345353
PaymentOperationBuilder(destinationAddress, tftAsset, amount)
346354
.build())
347-
.addMemo(memoText != null
348-
? Memo.text(memoText)
349-
: memoHash != null
350-
? Memo.hash(memoHash)
351-
: Memo.none())
355+
.addMemo(memo)
352356
.build();
353357
} else {
354358
transaction = TransactionBuilder(sender)
355359
.addOperation(
356360
PaymentOperationBuilder(destinationAddress, tftAsset, amount)
357361
.build())
358-
.addMemo(memoText != null
359-
? Memo.text(memoText)
360-
: memoHash != null
361-
? Memo.hash(memoHash)
362-
: Memo.none())
362+
.addMemo(memo)
363363
.build();
364364
}
365365

0 commit comments

Comments
 (0)