Skip to content
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![License](https://badgen.net/badge/license/Apache%202/blue?icon=github&label=License)](https://github.com/stellar/anchor-platform/blob/develop/LICENSE)
[![GitHub Version](https://badgen.net/github/release/stellar/anchor-platform?icon=github&label=Latest%20release)](https://github.com/stellar/anchor-platform/releases)
[![Docker](https://badgen.net/badge/Latest%20Release/v4.1.1/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=4.1.1)
[![Docker](https://badgen.net/badge/Latest%20Release/v4.1.2/blue?icon=docker)](https://hub.docker.com/r/stellar/anchor-platform/tags?page=1&name=4.1.2)
![Develop Branch](https://github.com/stellar/anchor-platform/actions/workflows/on_push_to_develop.yml/badge.svg?branch=develop)

<div style="text-align: center">
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ subprojects {

allprojects {
group = "org.stellar.anchor-sdk"
version = "4.1.1"
version = "4.1.2"

tasks.jar {
manifest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DepositService(private val cfg: Config, private val paymentClient: Payment
amount: BigDecimal,
account: String,
asset: String,
memo: String?
memo: String?,
) {
try {
var transaction = sep24.getTransaction(transactionId)
Expand Down Expand Up @@ -57,11 +57,11 @@ class DepositService(private val cfg: Config, private val paymentClient: Payment
account,
Asset.create(asset.replace("stellar:", "")),
transaction.amountOut!!.amount!!,
memo
memo,
)

// 6. Finalize Stellar anchor transaction
finalizeStellarTransaction(transactionId, txHash)
finalizeStellarTransaction(transaction, txHash)
}
}

Expand Down Expand Up @@ -123,11 +123,6 @@ class DepositService(private val cfg: Config, private val paymentClient: Payment
"pending_anchor",
"funds received, transaction is being processed",
)
sep24.patchTransaction(
transactionId,
"pending_stellar",
"funds received, transaction is being processed",
)
}
}

Expand All @@ -148,30 +143,36 @@ class DepositService(private val cfg: Config, private val paymentClient: Payment
}

private suspend fun finalizeStellarTransaction(
transactionId: String,
stellarTransactionId: String
transaction: Transaction,
stellarTransactionId: String,
) {
// SAC transfers submitted to RPC are asynchronous, we will need to retry
// until the RPC returns a success response
if (cfg.appSettings.rpcEnabled) {
flow<Unit> {
sep24.rpcAction(
"notify_onchain_funds_sent",
NotifyOnchainFundsSentRequest(
transactionId = transactionId,
stellarTransactionId = stellarTransactionId,
),
)
}
.retryWhen { _, attempt ->
if (attempt < 5) {
delay(5_000)
return@retryWhen true
} else {
return@retryWhen false
if (transaction.status == "pending_anchor") {
flow<Unit> {
sep24.rpcAction(
"notify_onchain_funds_sent",
NotifyOnchainFundsSentRequest(
transactionId = transaction.id,
stellarTransactionId = stellarTransactionId,
),
)
}
.retryWhen { _, attempt ->
if (attempt < 5) {
delay(5_000)
return@retryWhen true
} else {
return@retryWhen false
}
}
.collect {}
} else {
log.warn {
"Transaction ${transaction.id} is in unexpected status ${transaction.status}, skipping notify_onchain_funds_sent"
}
.collect {}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.stream.Stream;
import lombok.Builder;
import lombok.Getter;
import lombok.val;
import org.stellar.anchor.api.asset.AssetInfo;
import org.stellar.anchor.api.asset.StellarAssetInfo;
import org.stellar.anchor.api.exception.AnchorException;
Expand Down Expand Up @@ -119,12 +118,14 @@ private void fetchEvents() {

try {
GetEventsResponse response = sorobanServer.getEvents(buildEventRequest(cursor));
metricLatestBlockRead.set(response.getLatestLedger());
if (response.getEvents() != null && !response.getEvents().isEmpty()) {
processEvents(response.getEvents());
}
// Save the cursor for the next request
cursor = response.getCursor();
saveCursor(cursor);
metricLatestBlockProcessed.set(response.getLatestLedger());
} catch (IOException ioex) {
warnF(
"Error fetching latest ledger: {}. ex={}. Wait for next retry.",
Expand All @@ -136,17 +137,13 @@ private void fetchEvents() {
private void processEvents(List<EventInfo> events) {
if (events == null || events.isEmpty()) return;
debugF("Processing {} 'transfer' events", events.size());
val lastEvent = events.get(events.size() - 1);
if (lastEvent != null) metricLatestBlockRead.set(lastEvent.getLedger());

for (EventInfo event : events) {
ShouldProcessResult result = shouldProcess(event);
if (result.shouldProcess) {
processTransferEvent(result);
}
}

if (lastEvent != null) metricLatestBlockProcessed.set(lastEvent.getLedger());
}

private void processTransferEvent(ShouldProcessResult result) {
Expand Down
2 changes: 1 addition & 1 deletion service-runner/src/main/resources/version-info.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=4.1.1
version=4.1.2
Loading