Skip to content
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

Back merge 2.2.3 to develop #1123

Merged
merged 7 commits into from
Sep 22, 2023
Merged
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 anchor-reference-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies {
implementation(libs.h2database)
implementation(libs.sqlite.jdbc)
implementation(libs.google.gson)
implementation(libs.java.stellar.sdk)
implementation(variantOf(libs.java.stellar.sdk) { classifier("uber") })
implementation(libs.okhttp3)

implementation(project(":api-schema"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javax.persistence.Converter;
import org.stellar.anchor.api.sep.sep38.RateFee;
import org.stellar.anchor.util.GsonUtils;
import shadow.com.google.common.reflect.TypeToken;
import com.google.common.reflect.TypeToken;

@Converter
public class RateFeeConverter implements AttributeConverter<RateFee, String> {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ subprojects {

allprojects {
group = "org.stellar.anchor-sdk"
version = "2.2.2"
version = "2.2.3"

tasks.jar {
manifest {
Expand Down
3 changes: 2 additions & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {

implementation(libs.commons.beanutils)
implementation(libs.commons.text)
implementation(libs.commons.io)
implementation(libs.apache.commons.lang3)
implementation(libs.log4j2.core)
implementation(libs.httpclient)
Expand All @@ -41,7 +42,7 @@ dependencies {
implementation(libs.jjwt)
implementation(libs.reactor.core)
implementation(libs.javax.jaxb.api)
implementation(libs.java.stellar.sdk)
implementation(variantOf(libs.java.stellar.sdk) { classifier("uber") })

implementation(project(":api-schema"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import java.nio.file.Path;
import java.util.*;
import lombok.NoArgsConstructor;
import org.apache.commons.io.FilenameUtils;
import org.stellar.anchor.api.exception.InvalidConfigException;
import org.stellar.anchor.api.exception.SepNotFoundException;
import org.stellar.anchor.api.sep.AssetInfo;
import org.stellar.anchor.config.AssetsConfig;
import org.stellar.anchor.util.FileUtil;
import org.stellar.anchor.util.GsonUtils;
import org.yaml.snakeyaml.Yaml;
import shadow.org.apache.commons.io.FilenameUtils;

@NoArgsConstructor
public class DefaultAssetService implements AssetService {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/stellar/anchor/auth/Sep10Jwt.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void updateAccountAndMemo() {
this.muxedAccount = sub;
byte[] pubKeyBytes = muxedAccount.getEd25519().getUint256();
this.account = KeyPair.fromPublicKey(pubKeyBytes).getAccountId();
this.muxedAccountId = muxedAccount.getId().getUint64();
this.muxedAccountId = muxedAccount.getId().getUint64().getNumber().longValue();
}
} catch (Exception ignored) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ String generateSep10Jwt(String challengeXdr, String clientDomain)
sep10Config.getHomeDomain(),
sep10Config.getWebAuthDomain());
debug("challenge:", challenge);
long issuedAt = challenge.getTransaction().getTimeBounds().getMinTime();
long issuedAt = challenge.getTransaction().getTimeBounds().getMinTime().longValue();
Memo memo = challenge.getTransaction().getMemo();
Sep10Jwt sep10Jwt =
Sep10Jwt.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.stellar.anchor.asset

import com.google.gson.Gson
import com.google.gson.JsonSyntaxException
import org.apache.commons.io.FilenameUtils
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
Expand All @@ -13,7 +14,6 @@ import org.skyscreamer.jsonassert.JSONCompareMode.LENIENT
import org.stellar.anchor.api.exception.InvalidConfigException
import org.stellar.anchor.api.exception.SepNotFoundException
import org.stellar.anchor.util.GsonUtils
import shadow.org.apache.commons.io.FilenameUtils

internal class DefaultAssetServiceTest {
private val gson: Gson = GsonUtils.getInstance()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package org.stellar.anchor.horizon

import io.mockk.every
import io.mockk.mockk
import java.util.*
import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
Expand All @@ -15,7 +16,6 @@ import org.stellar.sdk.Server
import org.stellar.sdk.requests.AccountsRequestBuilder
import org.stellar.sdk.responses.AccountResponse
import org.stellar.sdk.responses.AccountResponse.Balance
import shadow.com.google.common.base.Optional

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
internal class HorizonTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package org.stellar.anchor.sep10

import com.google.common.io.BaseEncoding
import com.google.gson.annotations.SerializedName
import io.mockk.*
import io.mockk.impl.annotations.MockK
import java.io.IOException
Expand Down Expand Up @@ -47,7 +48,6 @@ import org.stellar.sdk.*
import org.stellar.sdk.Network.TESTNET
import org.stellar.sdk.requests.ErrorResponse
import org.stellar.sdk.responses.AccountResponse
import shadow.com.google.gson.annotations.SerializedName

@Suppress("unused")
internal class TestSigner(
Expand Down
3 changes: 3 additions & 0 deletions core/src/test/kotlin/org/stellar/anchor/util/SepHelperTest.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.stellar.anchor.util

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.junit.jupiter.params.ParameterizedTest
Expand Down Expand Up @@ -43,6 +44,8 @@ internal class SepHelperTest {
"AMCEO75Y6YKE53HM6N46IJYH3LK3YYFZ4QWGNUKCSSIQSH3KOAD7BEAAAAAAAAAAAPNT2W"
]
)
@Disabled // This is disabled until AccountConverter.enableMuxed() is throwing exception on
// "MCEO75Y6YKE53HM6N46IJYH3LK3YYFZ4QWGNUKCSSIQSH3KOAD7BEAAAAAAAAAAAPNT2W___"
fun `test invalid stellar account`(strAccount: String) {
assertThrows<Exception> { SepHelper.getAccountMemo(strAccount) }
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ h2database = "2.1.214"
hibernate-types = "2.18.0"
hoplite = "2.7.0"
jackson-dataformat-yaml = "2.14.0"
java-stellar-sdk = "0.40.0"
java-stellar-sdk = "0.41.0"
javax-jaxb-api = "2.3.1"
javax-transaction-api = "1.3"
jjwt = "0.9.1"
Expand Down Expand Up @@ -54,7 +54,7 @@ aws-java-sdk-s3 = "1.12.342"
sqlite-jdbc = "3.34.0"
slf4j = "1.7.35"
slf4j2 = "2.0.5"
stellar-wallet-sdk = "0.8.1"
stellar-wallet-sdk = "0.11.0"
toml4j = "0.7.2"

# Plugin versions
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {

implementation(libs.commons.cli)
implementation(libs.dotenv)
implementation(libs.java.stellar.sdk)
implementation(variantOf(libs.java.stellar.sdk) { classifier("uber") })
implementation(libs.google.gson)
implementation(libs.okhttp3)
implementation(libs.log4j2.api)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.stellar.anchor.platform

import com.google.common.reflect.TypeToken
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody
Expand All @@ -12,7 +13,6 @@ import org.stellar.anchor.api.sep.sep12.Sep12DeleteCustomerRequest
import org.stellar.anchor.api.sep.sep12.Sep12GetCustomerResponse
import org.stellar.anchor.api.sep.sep12.Sep12PutCustomerRequest
import org.stellar.anchor.api.sep.sep12.Sep12PutCustomerResponse
import shadow.com.google.common.reflect.TypeToken

const val APPLICATION_JSON_CHARSET_UTF_8 = "application/json; charset=utf-8"
val TYPE_JSON = APPLICATION_JSON_CHARSET_UTF_8.toMediaType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import org.springframework.web.util.UriComponentsBuilder
import org.stellar.anchor.api.callback.SendEventRequest
import org.stellar.anchor.api.callback.SendEventRequestPayload
import org.stellar.anchor.api.event.AnchorEvent
import org.stellar.anchor.api.event.AnchorEvent.Type.*
import org.stellar.anchor.api.event.AnchorEvent.Type.TRANSACTION_CREATED
import org.stellar.anchor.api.event.AnchorEvent.Type.TRANSACTION_STATUS_CHANGED
import org.stellar.anchor.api.sep.SepTransactionStatus
import org.stellar.anchor.api.sep.sep24.Sep24GetTransactionResponse
import org.stellar.anchor.auth.JwtService
Expand All @@ -29,10 +30,8 @@ import org.stellar.walletsdk.ApplicationConfiguration
import org.stellar.walletsdk.InteractiveFlowResponse
import org.stellar.walletsdk.StellarConfiguration
import org.stellar.walletsdk.Wallet
import org.stellar.walletsdk.anchor.DepositTransaction
import org.stellar.walletsdk.anchor.TransactionStatus
import org.stellar.walletsdk.anchor.*
import org.stellar.walletsdk.anchor.TransactionStatus.*
import org.stellar.walletsdk.anchor.WithdrawalTransaction
import org.stellar.walletsdk.asset.IssuedAssetId
import org.stellar.walletsdk.asset.StellarAssetId
import org.stellar.walletsdk.asset.XLM
Expand Down Expand Up @@ -96,9 +95,11 @@ class Sep24CustodyEnd2EndTests(config: TestConfig, val jwt: String) {
waitForTxnStatus(response.id, COMPLETED, token)

// Check if the transaction can be listed by stellar transaction id
val fetchedTxn = anchor.getTransaction(response.id, token) as DepositTransaction
val fetchedTxn = anchor.interactive().getTransaction(response.id, token) as DepositTransaction
val transactionByStellarId =
anchor.getTransactionBy(token, stellarTransactionId = fetchedTxn.stellarTransactionId)
anchor
.interactive()
.getTransactionBy(token, stellarTransactionId = fetchedTxn.stellarTransactionId)
assertEquals(fetchedTxn.id, transactionByStellarId.id)

// Check the events sent to the reference server are recorded correctly
Expand All @@ -119,7 +120,7 @@ class Sep24CustodyEnd2EndTests(config: TestConfig, val jwt: String) {
val deposit = anchor.interactive().deposit(asset, token, mapOf("amount" to amount))

// Get transaction status and make sure it is INCOMPLETE
val transaction = anchor.getTransaction(deposit.id, token)
val transaction = anchor.interactive().getTransaction(deposit.id, token)
assertEquals(INCOMPLETE, transaction.status)
// Make sure the interactive url is valid. This will also start the reference server's
// withdrawal process.
Expand Down Expand Up @@ -184,7 +185,7 @@ class Sep24CustodyEnd2EndTests(config: TestConfig, val jwt: String) {
val withdrawTxn = anchor.interactive().withdraw(asset, token, extraFields)

// Get transaction status and make sure it is INCOMPLETE
val transaction = anchor.getTransaction(withdrawTxn.id, token)
val transaction = anchor.interactive().getTransaction(withdrawTxn.id, token)
assertEquals(INCOMPLETE, transaction.status)
// Make sure the interactive url is valid. This will also start the reference server's
// withdrawal process.
Expand All @@ -194,11 +195,12 @@ class Sep24CustodyEnd2EndTests(config: TestConfig, val jwt: String) {
// Wait for the status to change to PENDING_USER_TRANSFER_START
waitForTxnStatus(withdrawTxn.id, PENDING_USER_TRANSFER_START, token)
// Submit transfer transaction
val walletTxn = (anchor.getTransaction(withdrawTxn.id, token) as WithdrawalTransaction)
val walletTxn =
(anchor.interactive().getTransaction(withdrawTxn.id, token) as WithdrawalTransaction)
val transfer =
wallet
.stellar()
.transaction(walletTxn.from)
.transaction(walletTxn.from!!)
.transferWithdrawalTransaction(walletTxn, asset)
.build()
transfer.sign(keypair)
Expand All @@ -207,9 +209,12 @@ class Sep24CustodyEnd2EndTests(config: TestConfig, val jwt: String) {
waitForTxnStatus(withdrawTxn.id, COMPLETED, token)

// Check if the transaction can be listed by stellar transaction id
val fetchTxn = anchor.getTransaction(withdrawTxn.id, token) as WithdrawalTransaction
val fetchTxn =
anchor.interactive().getTransaction(withdrawTxn.id, token) as WithdrawalTransaction
val transactionByStellarId =
anchor.getTransactionBy(token, stellarTransactionId = fetchTxn.stellarTransactionId)
anchor
.interactive()
.getTransactionBy(token, stellarTransactionId = fetchTxn.stellarTransactionId)
assertEquals(fetchTxn.id, transactionByStellarId.id)

// Check the events sent to the reference server are recorded correctly
Expand Down Expand Up @@ -265,7 +270,7 @@ class Sep24CustodyEnd2EndTests(config: TestConfig, val jwt: String) {

for (i in 0..maxTries) {
// Get transaction info
val transaction = anchor.getTransaction(id, token)
val transaction = anchor.interactive().getTransaction(id, token)

if (status != transaction.status) {
status = transaction.status
Expand Down Expand Up @@ -312,7 +317,7 @@ class Sep24CustodyEnd2EndTests(config: TestConfig, val jwt: String) {
waitForTxnStatus(txnId, COMPLETED, token)
txnId
}
val history = anchor.getHistory(asset, token)
val history = anchor.interactive().getTransactionsForAsset(asset, token)

Assertions.assertThat(history).allMatch { deposits.contains(it.id) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ import org.stellar.walletsdk.ApplicationConfiguration
import org.stellar.walletsdk.InteractiveFlowResponse
import org.stellar.walletsdk.StellarConfiguration
import org.stellar.walletsdk.Wallet
import org.stellar.walletsdk.anchor.DepositTransaction
import org.stellar.walletsdk.anchor.TransactionStatus
import org.stellar.walletsdk.anchor.*
import org.stellar.walletsdk.anchor.TransactionStatus.*
import org.stellar.walletsdk.anchor.WithdrawalTransaction
import org.stellar.walletsdk.asset.IssuedAssetId
import org.stellar.walletsdk.asset.StellarAssetId
import org.stellar.walletsdk.asset.XLM
Expand Down Expand Up @@ -96,9 +94,11 @@ class Sep24CustodyRpcEnd2EndTests(config: TestConfig, val jwt: String) {
waitForTxnStatus(response.id, COMPLETED, token)

// Check if the transaction can be listed by stellar transaction id
val fetchedTxn = anchor.getTransaction(response.id, token) as DepositTransaction
val fetchedTxn = anchor.interactive().getTransaction(response.id, token) as DepositTransaction
val transactionByStellarId =
anchor.getTransactionBy(token, stellarTransactionId = fetchedTxn.stellarTransactionId)
anchor
.interactive()
.getTransactionBy(token, stellarTransactionId = fetchedTxn.stellarTransactionId)
assertEquals(fetchedTxn.id, transactionByStellarId.id)

// Check the events sent to the reference server are recorded correctly
Expand All @@ -119,7 +119,7 @@ class Sep24CustodyRpcEnd2EndTests(config: TestConfig, val jwt: String) {
val deposit = anchor.interactive().deposit(asset, token, mapOf("amount" to amount))

// Get transaction status and make sure it is INCOMPLETE
val transaction = anchor.getTransaction(deposit.id, token)
val transaction = anchor.interactive().getTransaction(deposit.id, token)
assertEquals(INCOMPLETE, transaction.status)
// Make sure the interactive url is valid. This will also start the reference server's
// withdrawal process.
Expand Down Expand Up @@ -184,7 +184,7 @@ class Sep24CustodyRpcEnd2EndTests(config: TestConfig, val jwt: String) {
val withdrawTxn = anchor.interactive().withdraw(asset, token, extraFields)

// Get transaction status and make sure it is INCOMPLETE
val transaction = anchor.getTransaction(withdrawTxn.id, token)
val transaction = anchor.interactive().getTransaction(withdrawTxn.id, token)
assertEquals(INCOMPLETE, transaction.status)
// Make sure the interactive url is valid. This will also start the reference server's
// withdrawal process.
Expand All @@ -194,11 +194,12 @@ class Sep24CustodyRpcEnd2EndTests(config: TestConfig, val jwt: String) {
// Wait for the status to change to PENDING_USER_TRANSFER_START
waitForTxnStatus(withdrawTxn.id, PENDING_USER_TRANSFER_START, token)
// Submit transfer transaction
val walletTxn = (anchor.getTransaction(withdrawTxn.id, token) as WithdrawalTransaction)
val walletTxn =
(anchor.interactive().getTransaction(withdrawTxn.id, token) as WithdrawalTransaction)
val transfer =
wallet
.stellar()
.transaction(walletTxn.from)
.transaction(walletTxn.from!!)
.transferWithdrawalTransaction(walletTxn, asset)
.build()
transfer.sign(keypair)
Expand All @@ -207,9 +208,12 @@ class Sep24CustodyRpcEnd2EndTests(config: TestConfig, val jwt: String) {
waitForTxnStatus(withdrawTxn.id, COMPLETED, token)

// Check if the transaction can be listed by stellar transaction id
val fetchTxn = anchor.getTransaction(withdrawTxn.id, token) as WithdrawalTransaction
val fetchTxn =
anchor.interactive().getTransaction(withdrawTxn.id, token) as WithdrawalTransaction
val transactionByStellarId =
anchor.getTransactionBy(token, stellarTransactionId = fetchTxn.stellarTransactionId)
anchor
.interactive()
.getTransactionBy(token, stellarTransactionId = fetchTxn.stellarTransactionId)
assertEquals(fetchTxn.id, transactionByStellarId.id)

// Check the events sent to the reference server are recorded correctly
Expand Down Expand Up @@ -265,7 +269,7 @@ class Sep24CustodyRpcEnd2EndTests(config: TestConfig, val jwt: String) {

for (i in 0..maxTries) {
// Get transaction info
val transaction = anchor.getTransaction(id, token)
val transaction = anchor.interactive().getTransaction(id, token)

if (status != transaction.status) {
status = transaction.status
Expand Down Expand Up @@ -312,7 +316,7 @@ class Sep24CustodyRpcEnd2EndTests(config: TestConfig, val jwt: String) {
waitForTxnStatus(txnId, COMPLETED, token)
txnId
}
val history = anchor.getHistory(asset, token)
val history = anchor.interactive().getHistory(asset, token)

Assertions.assertThat(history).allMatch { deposits.contains(it.id) }
}
Expand Down
Loading