Skip to content

Commit

Permalink
port #427 from develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeUrban committed Sep 5, 2023
1 parent de71c6c commit 0912407
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ target/
*/out/**
*.class
.jpb
*/bin/*
*/bin/*
.vscode
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ List<? extends Sep31Transaction> findByTransactionIds(@NonNull Collection<String
*/
Sep31Transaction findByStellarMemo(@NonNull String memo) throws AnchorException;

Sep31Transaction findByStellarAccountIdAndMemoAndStatus(
String accountId, String memo, String status) throws AnchorException;

/**
* Save a transaction.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public interface JdbcSep31TransactionRepo extends CrudRepository<JdbcSep31Transa

Optional<Sep31Transaction> findByStellarMemo(String stellarMemo);

Optional<Sep31Transaction> findByStellarAccountIdAndMemoAndStatus(
String stellarAccountId, String stellarMemo, String status);

@Query(value = "SELECT COUNT(t) FROM JdbcSep31Transaction t WHERE t.status = :status")
Integer findByStatusCount(@Param("status") String status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public Sep31Transaction findByStellarMemo(@NonNull String memo) throws AnchorExc
return transactionRepo.findByStellarMemo(memo).orElse(null);
}

@Override
public Sep31Transaction findByStellarAccountIdAndMemoAndStatus(
String accountId, String memo, String status) throws AnchorException {
return transactionRepo
.findByStellarAccountIdAndMemoAndStatus(accountId, memo, status)
.orElse(null);
}

@Override
public Sep31Transaction save(Sep31Transaction transaction) throws SepException {
if (!(transaction instanceof JdbcSep31Transaction)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public void onReceived(ObservedPayment payment) throws EventPublishException {
// Find a transaction matching the memo
Sep31Transaction txn;
try {
txn = transactionStore.findByStellarMemo(memo);
txn =
transactionStore.findByStellarAccountIdAndMemoAndStatus(
payment.getTo(), memo, TransactionEvent.Status.PENDING_SENDER.toString());
if (txn == null) {
Log.infoF("Not expecting any transaction with the memo {}.", payment.getTransactionMemo());
return;
Expand Down

0 comments on commit 0912407

Please sign in to comment.