Skip to content

Commit f1513e6

Browse files
authored
Merge pull request #137 from threefoldtech/development_add_memo_hash
Add memo hash
2 parents 77f8f56 + 170359e commit f1513e6

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

packages/stellar_client/lib/src/client.dart

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ class Client {
1313
Uint8List? get privateKey => _keyPair.privateKey;
1414

1515
var logger = Logger(
16-
printer: PrettyPrinter(),
16+
printer: PrettyPrinter(
17+
methodCount: 2,
18+
errorMethodCount: 8,
19+
lineLength: 120,
20+
colors: true,
21+
printEmojis: true,
22+
printTime: true),
23+
level: Level.debug,
24+
filter: ProductionFilter(),
1725
);
1826

1927
Client(this._network, String secretSeed) {
@@ -161,12 +169,15 @@ class Client {
161169
{required String destinationAddress,
162170
required String amount,
163171
required String currency,
164-
String? memoText}) async {
172+
String? memoText,
173+
Uint8List? memoHash}) async {
165174
try {
166175
Transaction? transaction = await _buildTransaction(
167176
destinationAddress: destinationAddress,
168177
amount: amount,
169178
currency: currency,
179+
memoText: memoText,
180+
memoHash: memoHash,
170181
funded: false);
171182

172183
transaction!.sign(_keyPair, _stellarNetwork);
@@ -293,6 +304,7 @@ class Client {
293304
required String amount,
294305
required String currency,
295306
String? memoText,
307+
Uint8List? memoHash,
296308
required bool funded}) async {
297309
// check if I have enough balance
298310
final accountBalances = await this.getBalance();
@@ -332,14 +344,22 @@ class Client {
332344
.addOperation(
333345
PaymentOperationBuilder(destinationAddress, tftAsset, amount)
334346
.build())
335-
.addMemo(memoText != null ? Memo.text(memoText) : Memo.none())
347+
.addMemo(memoText != null
348+
? Memo.text(memoText)
349+
: memoHash != null
350+
? Memo.hash(memoHash)
351+
: Memo.none())
336352
.build();
337353
} else {
338354
transaction = TransactionBuilder(sender)
339355
.addOperation(
340356
PaymentOperationBuilder(destinationAddress, tftAsset, amount)
341357
.build())
342-
.addMemo(memoText != null ? Memo.text(memoText) : Memo.none())
358+
.addMemo(memoText != null
359+
? Memo.text(memoText)
360+
: memoHash != null
361+
? Memo.hash(memoHash)
362+
: Memo.none())
343363
.build();
344364
}
345365

@@ -350,12 +370,14 @@ class Client {
350370
{required String destinationAddress,
351371
required String amount,
352372
required String currency,
353-
String? memoText}) async {
373+
String? memoText,
374+
Uint8List? memoHash}) async {
354375
Transaction? fundedTransaction = await _buildTransaction(
355376
destinationAddress: destinationAddress,
356377
amount: amount,
357378
currency: currency,
358379
memoText: memoText,
380+
memoHash: memoHash,
359381
funded: true);
360382

361383
fundedTransaction!.sign(_keyPair, _stellarNetwork);

0 commit comments

Comments
 (0)