Skip to content

Commit

Permalink
[ANCHOR-634] Bump Java SDK version to 0.43.0 (#1289)
Browse files Browse the repository at this point in the history
### Description

This bumps the Java SDK version from 0.42.0 to 0.43.0. This is an
attempt to resolve an issue with the payment observer getting stuck on
unparsable payment operations.

Bumping the SDK version required bumping the Kotlin to 1.9 and `ktfmt`
versions, which is why the lines changed are so large.

### Context

```
19:54:54.694 ERROR - o.s.a.p.p.o.s.StellarPaymentObserver - stellar payment observer stream error:
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Not a JSON Object: "problem"
at com.google.gson.Gson.fromJson(Gson.java:1238)
at com.google.gson.Gson.fromJson(Gson.java:1137)
at com.google.gson.Gson.fromJson(Gson.java:1047)
at com.google.gson.Gson.fromJson(Gson.java:982)
at org.stellar.sdk.requests.SSEStream$StellarEventSourceListener.onEvent(SSEStream.java:257)
at 
```

### Testing

- `./gradlew test`

### Documentation

N/A

### Known limitations

N/A
  • Loading branch information
philipliu authored Mar 12, 2024
1 parent 3488850 commit c7d1276
Show file tree
Hide file tree
Showing 58 changed files with 807 additions and 845 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ class StellarPaymentTest {
"source_account": "GAS4OW4HKJCC2D6VWUHVFR3MJRRVQBXBFQ3LCZJXBR7TWOOBJWE4SRWZ",
"destination_account": "GBQC7NCZMQIPWN6ASUJYIDKDPRK34IOIZNQE5WOHPQH536VMOMQVJTN7"
}
""".trimIndent()
"""
.trimIndent()
val actual = mapper.writeValueAsString(mockPayment1)

JSONAssert.assertEquals(expected, actual, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class StellarTransactionTest {
.createdAt(createdAt)
.envelope("here_comes_the_envelope")
.payments(listOf(mockPayment1))
.build()
.build(),
)

val wantTxList =
Expand Down Expand Up @@ -95,7 +95,7 @@ class StellarTransactionTest {
.createdAt(createdAt)
.envelope("here_comes_the_envelope")
.payments(listOf(mockPayment1))
.build()
.build(),
)

val wantTxList =
Expand Down Expand Up @@ -133,7 +133,7 @@ class StellarTransactionTest {
.createdAt(createdAt)
.envelope("here_comes_the_envelope")
.payments(listOf(mockPayment1))
.build()
.build(),
)

val wantTxList =
Expand Down Expand Up @@ -175,7 +175,7 @@ class StellarTransactionTest {
.createdAt(createdAt)
.envelope("here_comes_the_envelope")
.payments(listOf(mockPayment2, mockPayment3))
.build()
.build(),
)

val wantTxList =
Expand Down Expand Up @@ -221,7 +221,7 @@ class StellarTransactionTest {
.createdAt(createdAt)
.envelope("here_comes_the_envelope")
.payments(listOf(mockPayment3))
.build()
.build(),
)

val wantTxList =
Expand All @@ -245,7 +245,7 @@ class StellarTransactionTest {
.createdAt(createdAt)
.envelope("here_comes_the_envelope")
.payments(listOf(mockPayment3))
.build()
.build(),
)

assertEquals(wantTxList, txList)
Expand Down Expand Up @@ -279,7 +279,8 @@ class StellarTransactionTest {
"memo_type": "text",
"created_at": 1690415946.788000000
}
""".trimIndent()
"""
.trimIndent()
val actual =
mapper.writeValueAsString(
StellarTransaction.builder()
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ subprojects {
googleJavaFormat()
}

kotlin { ktfmt("0.30").googleStyle() }
kotlin { ktfmt("0.47").googleStyle() }
}

dependencies {
Expand Down Expand Up @@ -118,7 +118,7 @@ subprojects {

allprojects {
group = "org.stellar.anchor-sdk"
version = "1.2.24"
version = "1.2.25"

tasks.jar {
manifest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public ChallengeResponse createChallenge(ChallengeRequest challengeRequest) thro
}

public ValidationResponse validateChallenge(ValidationRequest validationRequest)
throws IOException, InvalidSep10ChallengeException, URISyntaxException,
throws IOException,
InvalidSep10ChallengeException,
URISyntaxException,
SepValidationException {
if (validationRequest == null || validationRequest.getTransaction() == null) {
throw new SepValidationException("{transaction} is required.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ public interface Sep24Transaction {
String getAmountOutAsset();

void setAmountOutAsset(String amountOutAsset);

/**
* Amount of fee charged by anchor.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public interface Sep24TransactionStore {
*/
List<Sep24Transaction> findTransactions(
String accountId, String accountMemo, GetTransactionsRequest request) throws SepException;

/**
* Save a transaction.
*
Expand Down
4 changes: 2 additions & 2 deletions core/src/test/kotlin/org/stellar/anchor/TestHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TestHelper {
account: String = TEST_ACCOUNT,
accountMemo: String? = null,
hostUrl: String = "",
clientDomain: String = "vibrant.stellar.org"
clientDomain: String = "vibrant.stellar.org",
): JwtToken {
val issuedAt: Long = System.currentTimeMillis() / 1000L
return JwtToken.of(
Expand All @@ -22,7 +22,7 @@ class TestHelper {
issuedAt,
issuedAt + 60,
"",
clientDomain
clientDomain,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AuthHelperTest {
JwtToken.of(
"http://localhost:8080",
currentTimeMilliseconds / 1000L,
(currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L
(currentTimeMilliseconds + JWT_EXPIRATION_MILLISECONDS) / 1000L,
)

val jwtService = JwtService("secret")
Expand Down
10 changes: 1 addition & 9 deletions core/src/test/kotlin/org/stellar/anchor/auth/JwtServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,7 @@ internal class JwtServiceTest {
every { appConfig.jwtSecretKey } returns "jwt_secret"

val jwtService = JwtService(appConfig)
val token =
JwtToken.of(
TEST_ISS,
TEST_SUB,
TEST_IAT,
TEST_EXP,
TEST_JTI,
TEST_CLIENT_DOMAIN,
)
val token = JwtToken.of(TEST_ISS, TEST_SUB, TEST_IAT, TEST_EXP, TEST_JTI, TEST_CLIENT_DOMAIN)
val cipher = jwtService.encode(token)
val dt = jwtService.decode(cipher)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ class InfoResponseTest {
val wantSellDeliveryMethod =
AssetInfo.Sep38Operation.DeliveryMethod(
"WIRE",
"Send USD directly to the Anchor's bank account."
"Send USD directly to the Anchor's bank account.",
)
assertEquals(listOf(wantSellDeliveryMethod), fiatUSD.sellDeliveryMethods)
val wantBuyDeliveryMethod =
AssetInfo.Sep38Operation.DeliveryMethod(
"WIRE",
"Have USD sent directly to your bank account."
"Have USD sent directly to your bank account.",
)
assertEquals(listOf(wantBuyDeliveryMethod), fiatUSD.buyDeliveryMethods)
wantAssets =
listOf(
"stellar:JPYC:GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
"stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
"stellar:USDC:GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP",
)
assertTrue(fiatUSD.exchangeableAssetNames.containsAll(wantAssets))
assertTrue(wantAssets.containsAll(fiatUSD.exchangeableAssetNames))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ internal class TestSigner(
@SerializedName("key") val key: String,
@SerializedName("type") val type: String,
@SerializedName("weight") val weight: Int,
@SerializedName("sponsor") val sponsor: String
@SerializedName("sponsor") val sponsor: String,
) {
fun toSigner(): AccountResponse.Signer {
val gson = GsonUtils.getInstance()
Expand Down Expand Up @@ -181,7 +181,7 @@ internal class Sep10ServiceTest {

val transaction =
TransactionBuilder(AccountConverter.enableMuxed(), sourceAccount, Network.TESTNET)
.addTimeBounds(TimeBounds.expiresAfter(900))
.setTimeout(900)
.setBaseFee(100)
.addOperation(op1DomainNameMandatory)
.addOperation(op2WebAuthDomainMandatory)
Expand Down Expand Up @@ -272,7 +272,7 @@ internal class Sep10ServiceTest {

val transaction =
TransactionBuilder(AccountConverter.enableMuxed(), sourceAccount, Network.TESTNET)
.addTimeBounds(TimeBounds.expiresAfter(900))
.setTimeout(900)
.setBaseFee(100)
.addOperation(op1DomainNameMandatory)
.addOperation(op2WebAuthDomainMandatory)
Expand Down Expand Up @@ -345,7 +345,7 @@ internal class Sep10ServiceTest {

val transaction =
TransactionBuilder(AccountConverter.enableMuxed(), sourceAccount, Network.TESTNET)
.addTimeBounds(TimeBounds.expiresAfter(900))
.setTimeout(900)
.setBaseFee(100)
.addOperation(op1DomainNameMandatory)
.addOperation(op2WebAuthDomainMandatory)
Expand Down Expand Up @@ -396,7 +396,7 @@ internal class Sep10ServiceTest {
any(),
any(),
any(),
any()
any(),
)
}
}
Expand All @@ -415,7 +415,7 @@ internal class Sep10ServiceTest {
TimeBounds(now, now + 900),
clientDomain,
if (clientDomain.isEmpty()) "" else clientDomainKeyPair.accountId,
memo
memo,
)
txn.sign(clientKeyPair)
if (clientDomain.isNotEmpty() && signWithClientDomain) {
Expand Down Expand Up @@ -448,7 +448,7 @@ internal class Sep10ServiceTest {
val signers =
arrayOf(
TestSigner(clientKeyPair.accountId, "ed25519_public_key", 1, "").toSigner(),
TestSigner(clientDomainKeyPair.accountId, "ed25519_public_key", 1, "").toSigner()
TestSigner(clientDomainKeyPair.accountId, "ed25519_public_key", 1, "").toSigner(),
)

every { accountResponse.signers } returns signers
Expand Down
16 changes: 5 additions & 11 deletions core/src/test/kotlin/org/stellar/anchor/sep24/Sep24ServiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ internal class Sep24ServiceTest {
assertEquals(slotTxn.captured.assetCode, "USDC")
assertEquals(
slotTxn.captured.assetIssuer,
"GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP"
"GDQOE23CFSUMSVQK4Y5JHPPYK73VYCNHZHA7ENKCV37P6SUEO6XQBKPP",
)
assertEquals(slotTxn.captured.sep10Account, TEST_ACCOUNT)
assertEquals(slotTxn.captured.fromAccount, TEST_ACCOUNT)
Expand All @@ -135,10 +135,7 @@ internal class Sep24ServiceTest {
assertEquals(tokenStrings.size, 1)
tokenString = tokenStrings[0].value
decodedToken = jwtService.decode(tokenString)
assertEquals(
"$TEST_ACCOUNT:$TEST_MEMO",
decodedToken.sub,
)
assertEquals("$TEST_ACCOUNT:$TEST_MEMO", decodedToken.sub)
assertEquals(TEST_CLIENT_DOMAIN, decodedToken.clientDomain)
}

Expand All @@ -151,7 +148,7 @@ internal class Sep24ServiceTest {
"amount" to "123.4",
"email_address" to "[email protected]",
"first_name" to "Jamie",
"last_name" to "Li"
"last_name" to "Li",
)
}

Expand Down Expand Up @@ -249,10 +246,7 @@ internal class Sep24ServiceTest {
assertEquals(tokenStrings.size, 1)
val tokenString = tokenStrings[0].value
val decodedToken = jwtService.decode(tokenString)
assertEquals(
"$TEST_ACCOUNT:$TEST_MEMO",
decodedToken.sub,
)
assertEquals("$TEST_ACCOUNT:$TEST_MEMO", decodedToken.sub)
assertEquals(TEST_CLIENT_DOMAIN, decodedToken.clientDomain)
}

Expand Down Expand Up @@ -354,7 +348,7 @@ internal class Sep24ServiceTest {
10,
"2021-12-20T19:30:58+00:00",
"1",
"en-US"
"en-US",
)
sep24Service.findTransactions(createJwtToken(), gtr)
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/test/kotlin/org/stellar/anchor/sep31/RefundsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class RefundsTest {
.id("B")
.amount("50")
.fee("4")
.build()
.build(),
)
)
.build()
Expand Down Expand Up @@ -118,7 +118,7 @@ class RefundsTest {
.fee(Amount("4", stellarUSDC))
.refundedAt(null)
.refundedAt(null)
.build()
.build(),
)
)
.build()
Expand Down Expand Up @@ -152,7 +152,7 @@ class RefundsTest {
.fee(Amount("4", stellarUSDC))
.refundedAt(Instant.now())
.refundedAt(Instant.now())
.build()
.build(),
)
)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class Sep31HelperTest {
"pending_sender",
"completed",
"expired",
"error"]
"error",
]
)
fun `test validate status`(status: String) {
val txn = PojoSep31Transaction()
Expand Down
Loading

0 comments on commit c7d1276

Please sign in to comment.