Skip to content

Add memo hash #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading