Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,29 @@ fun MainPreview() {

private fun testSDK(): String {
return try {
// send request to horizon server
val server = Server("https://horizon.stellar.org")
val horizonResp = server.root().execute()
if (horizonResp == null || horizonResp.networkPassphrase != Network.PUBLIC.networkPassphrase) {
throw Exception("Query Horizon failed")
}

// send request to Soroban RPC server
val sorobanServer = SorobanServer("https://soroban-testnet.stellar.org:443")
if (sorobanServer.network.passphrase != Network.TESTNET.networkPassphrase) {
throw Exception("Query Soroban Server failed")
}

// Test Federation
// Not enabled if Android SDK version is less than 26,
// see https://stackoverflow.com/questions/64844311/certpathvalidatorexception-connecting-to-a-lets-encrypt-host-on-android-m-or-ea
if (Build.VERSION.SDK_INT >= 26) {
// send request to horizon server
val server = Server("https://horizon.stellar.org")
val horizonResp = server.root().execute()
if (horizonResp == null || horizonResp.networkPassphrase != Network.PUBLIC.networkPassphrase) {
throw Exception("Query Horizon failed")
}

// send request to Soroban RPC server
val sorobanServer = SorobanServer("https://soroban-testnet.stellar.org:443")
if (sorobanServer.network.passphrase != Network.TESTNET.networkPassphrase) {
throw Exception("Query Soroban Server failed")
}

val xdr =
server.transactions().limit(1).includeFailed(false).execute().records.get(0).envelopeXdr
val tx: Transaction = Transaction.fromEnvelopeXdr(xdr, Network.PUBLIC) as Transaction
val resp = server.submitTransaction(tx)
Log.d("MainActivity", "testSDK resp: $resp")

// Test Federation
val fedResp = Federation().resolveAddress("example*lobstr.co")
if (fedResp == null || fedResp.accountId == null) {
throw Exception("Query Federation failed")
Expand Down Expand Up @@ -280,13 +286,6 @@ private fun testSDK(): String {
.rootInvocation(invocation)
.build()
Auth.authorizeEntry(entry.toXdrBase64(), signer, validUntilLedgerSeq, network)

// send real transaction
val xdr =
server.transactions().limit(1).includeFailed(false).execute().records.get(0).envelopeXdr
val tx: Transaction = Transaction.fromEnvelopeXdr(xdr, Network.PUBLIC) as Transaction
val resp = server.submitTransaction(tx)
Log.d("MainActivity", "testSDK resp: $resp")
"SUCCESS"
} catch (e: Exception) {
Log.e("MainActivity", "testSDK ERROR", e)
Expand Down