diff --git a/sdk/src/androidTest/java/network/xyo/client/XyoBoundWitnessTest.kt b/sdk/src/androidTest/java/network/xyo/client/boundwitness/XyoBoundWitnessTest.kt similarity index 86% rename from sdk/src/androidTest/java/network/xyo/client/XyoBoundWitnessTest.kt rename to sdk/src/androidTest/java/network/xyo/client/boundwitness/XyoBoundWitnessTest.kt index d7a2c22..0643d5d 100644 --- a/sdk/src/androidTest/java/network/xyo/client/XyoBoundWitnessTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/boundwitness/XyoBoundWitnessTest.kt @@ -1,13 +1,15 @@ -package network.xyo.client +package network.xyo.client.boundwitness import android.content.Context import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.GrantPermissionRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking +import network.xyo.client.payload.TestPayload1 import network.xyo.client.account.Account -import network.xyo.client.boundwitness.XyoBoundWitnessBuilder +import network.xyo.client.node.client.DiscoverPayload import network.xyo.client.datastore.previous_hash_store.PreviousHashStorePrefsRepository +import network.xyo.client.lib.XyoSerializable import network.xyo.client.node.client.NodeClient import network.xyo.client.payload.XyoPayload import org.junit.Before @@ -71,7 +73,9 @@ class XyoBoundWitnessTest { @Test fun testBoundWitnessHash() { runBlocking { - val bw = XyoBoundWitnessBuilder(appContext).signer(Account.random()).payloads(listOf(TestPayload1())).build() + val bw = XyoBoundWitnessBuilder(appContext).signer(Account.random()).payloads(listOf( + TestPayload1() + )).build() val hashableFields = bw.getBodyJson() assert(bw._hash !== null) assert(bw._hash!! == XyoSerializable.sha256String(hashableFields)) @@ -83,8 +87,12 @@ class XyoBoundWitnessTest { fun testBoundWitnessPreviousHash() { runBlocking { val testAccount = Account.random() - val bw = XyoBoundWitnessBuilder(appContext).signer(testAccount).payloads(listOf(TestPayload1())).build() - val bw2 = XyoBoundWitnessBuilder(appContext).signer(testAccount).payloads(listOf(TestPayload1())).build() + val bw = XyoBoundWitnessBuilder(appContext).signer(testAccount).payloads(listOf( + TestPayload1() + )).build() + val bw2 = XyoBoundWitnessBuilder(appContext).signer(testAccount).payloads(listOf( + TestPayload1() + )).build() assert(bw2.previous_hashes.first() == bw._hash) } } diff --git a/sdk/src/androidTest/java/network/xyo/client/Constants.kt b/sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt similarity index 95% rename from sdk/src/androidTest/java/network/xyo/client/Constants.kt rename to sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt index 6f0435a..bc01136 100644 --- a/sdk/src/androidTest/java/network/xyo/client/Constants.kt +++ b/sdk/src/androidTest/java/network/xyo/client/lib/Constants.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.lib import network.xyo.client.account.Account import network.xyo.client.payload.XyoPayload @@ -26,6 +26,5 @@ class TestConstants { const val nodeUrlBeta = "https://beta.api.archivist.xyo.network" const val queryResponseJson = "{\"data\":[{\"addresses\":[\"cddaa9e8922142dfd53e5067f5b9e5de5c2ea0cf\",\"6cfeb02624f01112892e02f18a5e3409ae0a0739\"],\"payload_hashes\":[\"09a4dda042973bcb69f7a7f63a8a79763760e0e2ca9b0d486d7edf72ac2288be\"],\"payload_schemas\":[\"network.xyo.boundwitness\"],\"previous_hashes\":[\"09a4dda042973bcb69f7a7f63a8a79763760e0e2ca9b0d486d7edf72ac2288be\",null],\"schema\":\"network.xyo.boundwitness\",\"timestamp\":1682101895916,\"_signatures\":[\"5c94a98e2da7a4d3750c54c6a3a539900d7722c49419555f0563227876fc7eb3c67718b20bce7ba84913754557eea1a7864a1bc60aa5de5184f1e711a5b54637\",\"02910768ebb01049ccc10e957cbc70c32b71d1891bee66dcb71bedee284f796ca82c791e0efd361d49b34c10afce2aecacf9f27655c3496c91a83f5ad6ed8398\"]},[{\"addresses\":[\"cddaa9e8922142dfd53e5067f5b9e5de5c2ea0cf\"],\"payload_hashes\":[\"a83df3b9d9e92a391d6e172817762a90f1f6ca19da226e7a4679284d6af91f9b\",\"89dafadc4fa4249d73fce1bae21fe14ecff36175564fcbb8dc343982402f4d7e\",\"3cef5677c2f800d6603cebebab17e1cb459e086b81a50fd8d154a5dd5f279d2d\"],\"payload_schemas\":[\"network.xyo.boundwitness\",\"network.xyo.system.info\",\"network.xyo.query.archivist.insert\"],\"previous_hashes\":[null],\"schema\":\"network.xyo.boundwitness\",\"timestamp\":1682101895915,\"_signatures\":[\"5cd4359570fd0273f79a9181c3345aa034481e62c01e6f29e29861eeb167fbf0c2451fc9096c2c9d99b2a5e1ad3e53318fb6a47647fb083842cc82ead6d7c58c\"]}]],\"meta\":{\"profile\":{\"duration\":37,\"endTime\":1682101895919,\"startTime\":1682101895882}}}" const val queryResponseBWHash = "eb5bcbf881e5f91f8b10bb360bcb660b6e70b9ed429ac3c5c0f9b74150b59a07" - const val panelBwHash = "09a4dda042973bcb69f7a7f63a8a79763760e0e2ca9b0d486d7edf72ac2288be" } } diff --git a/sdk/src/androidTest/java/network/xyo/client/NodeClientTest.kt b/sdk/src/androidTest/java/network/xyo/client/node/client/NodeClientTest.kt similarity index 95% rename from sdk/src/androidTest/java/network/xyo/client/NodeClientTest.kt rename to sdk/src/androidTest/java/network/xyo/client/node/client/NodeClientTest.kt index f648600..7467451 100644 --- a/sdk/src/androidTest/java/network/xyo/client/NodeClientTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/node/client/NodeClientTest.kt @@ -1,12 +1,12 @@ -package network.xyo.client +package network.xyo.client.node.client import android.content.Context import androidx.test.platform.app.InstrumentationRegistry import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking +import network.xyo.client.lib.TestConstants import network.xyo.client.account.Account import network.xyo.client.archivist.wrapper.ArchivistWrapper -import network.xyo.client.node.client.NodeClient import network.xyo.client.payload.XyoPayload import org.junit.Before import org.junit.Test @@ -57,7 +57,8 @@ class NodeClientTest { @Test fun archivistInsertTest() { - val archivist = ArchivistWrapper(NodeClient(apiDomainBeta, TestConstants.TestAccount, appContext)) + val archivist = ArchivistWrapper(NodeClient(apiDomainBeta, + TestConstants.TestAccount, appContext)) val payloads = arrayListOf(TestConstants.debugPayload) diff --git a/sdk/src/androidTest/java/network/xyo/client/QueryResponseWrapperTest.kt b/sdk/src/androidTest/java/network/xyo/client/node/client/QueryResponseWrapperTest.kt similarity index 83% rename from sdk/src/androidTest/java/network/xyo/client/QueryResponseWrapperTest.kt rename to sdk/src/androidTest/java/network/xyo/client/node/client/QueryResponseWrapperTest.kt index c3beccd..269c469 100644 --- a/sdk/src/androidTest/java/network/xyo/client/QueryResponseWrapperTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/node/client/QueryResponseWrapperTest.kt @@ -1,6 +1,6 @@ -package network.xyo.client +package network.xyo.client.node.client -import network.xyo.client.node.client.QueryResponseWrapper +import network.xyo.client.lib.TestConstants import org.junit.Test import org.junit.jupiter.api.Assertions.* diff --git a/sdk/src/main/java/network/xyo/client/XyoEventPayload.kt b/sdk/src/androidTest/java/network/xyo/client/payload/XyoEventPayload.kt similarity index 76% rename from sdk/src/main/java/network/xyo/client/XyoEventPayload.kt rename to sdk/src/androidTest/java/network/xyo/client/payload/XyoEventPayload.kt index 4c74153..96c852e 100644 --- a/sdk/src/main/java/network/xyo/client/XyoEventPayload.kt +++ b/sdk/src/androidTest/java/network/xyo/client/payload/XyoEventPayload.kt @@ -1,7 +1,6 @@ -package network.xyo.client +package network.xyo.client.payload import com.squareup.moshi.JsonClass -import network.xyo.client.payload.XyoPayload import java.util.* @JsonClass(generateAdapter = true) diff --git a/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt b/sdk/src/androidTest/java/network/xyo/client/payload/XyoPayloadTest.kt similarity index 94% rename from sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt rename to sdk/src/androidTest/java/network/xyo/client/payload/XyoPayloadTest.kt index d97ffa8..d4ff0ca 100644 --- a/sdk/src/androidTest/java/network/xyo/client/XyoPayloadTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/payload/XyoPayloadTest.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.payload import android.content.Context import androidx.test.platform.app.InstrumentationRegistry @@ -6,9 +6,12 @@ import androidx.test.rule.GrantPermissionRule import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch +import network.xyo.client.lib.BasicPayload +import network.xyo.client.lib.TestConstants import network.xyo.client.account.Account import network.xyo.client.boundwitness.XyoBoundWitnessBuilder -import network.xyo.client.payload.XyoPayload +import network.xyo.client.lib.XyoSerializable +import network.xyo.client.witness.XyoWitness import org.junit.Before import org.junit.Rule import org.junit.Test diff --git a/sdk/src/androidTest/java/network/xyo/client/prefs/AccountPrefsRepositoryTest.kt b/sdk/src/androidTest/java/network/xyo/client/prefs/AccountPrefsRepositoryTest.kt index 1bc6ba0..9538518 100644 --- a/sdk/src/androidTest/java/network/xyo/client/prefs/AccountPrefsRepositoryTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/prefs/AccountPrefsRepositoryTest.kt @@ -3,8 +3,8 @@ package network.xyo.client.prefs import android.content.Context import androidx.test.platform.app.InstrumentationRegistry import kotlinx.coroutines.runBlocking -import network.xyo.client.TestConstants -import network.xyo.client.XyoPanel +import network.xyo.client.lib.TestConstants +import network.xyo.client.witness.XyoPanel import network.xyo.client.account.Account import network.xyo.client.boundwitness.XyoBoundWitnessBuilder import network.xyo.client.datastore.accounts.AccountPrefsRepository diff --git a/sdk/src/androidTest/java/network/xyo/client/prefs/PreviousHashStorePrefsRepositoryTest.kt b/sdk/src/androidTest/java/network/xyo/client/prefs/PreviousHashStorePrefsRepositoryTest.kt index 48c0f5d..3600bf2 100644 --- a/sdk/src/androidTest/java/network/xyo/client/prefs/PreviousHashStorePrefsRepositoryTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/prefs/PreviousHashStorePrefsRepositoryTest.kt @@ -3,7 +3,7 @@ package network.xyo.client.prefs import android.content.Context import androidx.test.platform.app.InstrumentationRegistry import kotlinx.coroutines.runBlocking -import network.xyo.client.TestConstants +import network.xyo.client.lib.TestConstants import network.xyo.client.account.Account import network.xyo.client.account.hexStringToByteArray import network.xyo.client.datastore.previous_hash_store.PreviousHashStorePrefsRepository diff --git a/sdk/src/androidTest/java/network/xyo/client/settings/XyoSdkTest.kt b/sdk/src/androidTest/java/network/xyo/client/settings/XyoSdkTest.kt index f32b294..63fbf06 100644 --- a/sdk/src/androidTest/java/network/xyo/client/settings/XyoSdkTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/settings/XyoSdkTest.kt @@ -4,8 +4,8 @@ import android.content.Context import androidx.test.platform.app.InstrumentationRegistry import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking -import network.xyo.client.XyoEventPayload -import network.xyo.client.XyoPanel +import network.xyo.client.payload.XyoEventPayload +import network.xyo.client.witness.XyoPanel import network.xyo.client.account.model.AccountInstance import org.junit.Before import org.junit.Test diff --git a/sdk/src/androidTest/java/network/xyo/client/witness/WitnessLocationHandlerTest.kt b/sdk/src/androidTest/java/network/xyo/client/witness/WitnessLocationHandlerTest.kt index 64644fc..ac2d535 100644 --- a/sdk/src/androidTest/java/network/xyo/client/witness/WitnessLocationHandlerTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/witness/WitnessLocationHandlerTest.kt @@ -7,7 +7,7 @@ import androidx.test.ext.junit.rules.ActivityScenarioRule import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.GrantPermissionRule import kotlinx.coroutines.runBlocking -import network.xyo.client.TestConstants +import network.xyo.client.lib.TestConstants import network.xyo.client.account.Account import network.xyo.client.boundwitness.XyoBoundWitnessBodyJson import network.xyo.client.datastore.previous_hash_store.PreviousHashStorePrefsRepository diff --git a/sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt b/sdk/src/androidTest/java/network/xyo/client/witness/XyoPanelTest.kt similarity index 96% rename from sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt rename to sdk/src/androidTest/java/network/xyo/client/witness/XyoPanelTest.kt index d9b61ae..f6a91e3 100644 --- a/sdk/src/androidTest/java/network/xyo/client/XyoPanelTest.kt +++ b/sdk/src/androidTest/java/network/xyo/client/witness/XyoPanelTest.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.witness import android.Manifest import android.content.Context @@ -7,6 +7,9 @@ import androidx.test.platform.app.InstrumentationRegistry import androidx.test.rule.GrantPermissionRule import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.runBlocking +import network.xyo.client.lib.BasicPayload +import network.xyo.client.lib.TestConstants +import network.xyo.client.payload.XyoEventPayload import network.xyo.client.account.Account import network.xyo.client.boundwitness.XyoBoundWitnessJson import network.xyo.client.datastore.previous_hash_store.PreviousHashStorePrefsRepository diff --git a/sdk/src/main/java/network/xyo/client/XyoApiConfig.kt b/sdk/src/main/java/network/xyo/client/XyoApiConfig.kt deleted file mode 100644 index 289a6e2..0000000 --- a/sdk/src/main/java/network/xyo/client/XyoApiConfig.kt +++ /dev/null @@ -1,4 +0,0 @@ -package network.xyo.client - -@Deprecated("Use NodeClient.class instead") -open class XyoApiConfig(val apiDomain: String, var token: String? = null) \ No newline at end of file diff --git a/sdk/src/main/java/network/xyo/client/archivist/api/XyoArchivistApiClient.kt b/sdk/src/main/java/network/xyo/client/archivist/api/XyoArchivistApiClient.kt deleted file mode 100644 index 7f771d2..0000000 --- a/sdk/src/main/java/network/xyo/client/archivist/api/XyoArchivistApiClient.kt +++ /dev/null @@ -1,98 +0,0 @@ -package network.xyo.client.archivist.api - -import android.util.Log -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.suspendCancellableCoroutine -import kotlinx.coroutines.withContext -import network.xyo.client.boundwitness.XyoBoundWitnessJson -import okhttp3.MediaType.Companion.toMediaType -import okhttp3.OkHttpClient -import okhttp3.Request -import okhttp3.RequestBody.Companion.toRequestBody -import okio.IOException - -import network.xyo.client.XyoSerializable -import network.xyo.client.payload.XyoPayload - -@Deprecated("Use PostQueryResult instead") -open class PostBoundWitnessesResult ( - val count: Int, - val errors: ArrayList? = null - ): XyoSerializable() - -@Deprecated("Use NodeClient instead") -open class XyoArchivistApiClient(private val config: XyoArchivistApiConfig) { - - private val okHttp = OkHttpClient() - - val authenticated: Boolean - get() { - return this.token != null - } - - var token: String? - get() { - return this.config.token - } - set(value) { - this.config.token = value - } - - @ExperimentalCoroutinesApi - private suspend fun postBoundWitnessesAsync ( - entries: List - ): PostBoundWitnessesResult { - val bodyString = XyoSerializable.toJson(entries) - val apiDomain = config.apiDomain - val archive = config.archive - - val request = Request.Builder() - .url("$apiDomain/archive/$archive/block") - .post(bodyString.toRequestBody(MEDIA_TYPE_JSON)) - .build() - - return withContext(Dispatchers.IO) { - return@withContext suspendCancellableCoroutine { continuation -> - try { - okHttp.newCall(request).execute().use { response -> - if (!response.isSuccessful) { - continuation.resume( - PostBoundWitnessesResult( - 0, - arrayListOf(Error(response.message)) - ) - ) { cause, _, _ -> null?.let { it(cause) } } - } else { - continuation.resume(PostBoundWitnessesResult(1)) { cause, _, _ -> - Log.w("postBoundWitnessesAsync", cause) - } - } - } - } catch (ex: IOException) { - Log.e("xyoClient", ex.message ?: ex.toString()) - continuation.resume( - PostBoundWitnessesResult( - 0, - arrayListOf(Error(ex.message)) - ) - ) { cause, _, _ -> Log.w("postBoundWitnessesAsync", cause) } - } - } - } - } - - @kotlinx.coroutines.ExperimentalCoroutinesApi - suspend fun postBoundWitnessAsync( - entry: XyoBoundWitnessJson - ): PostBoundWitnessesResult { - return postBoundWitnessesAsync(listOf(entry)) - } - - companion object { - val MEDIA_TYPE_JSON = "application/json; charset=utf-8".toMediaType() - fun get(config: XyoArchivistApiConfig): XyoArchivistApiClient { - return XyoArchivistApiClient(config) - } - } -} \ No newline at end of file diff --git a/sdk/src/main/java/network/xyo/client/archivist/api/XyoArchivistApiConfig.kt b/sdk/src/main/java/network/xyo/client/archivist/api/XyoArchivistApiConfig.kt deleted file mode 100644 index 2e81740..0000000 --- a/sdk/src/main/java/network/xyo/client/archivist/api/XyoArchivistApiConfig.kt +++ /dev/null @@ -1,6 +0,0 @@ -package network.xyo.client.archivist.api - -import network.xyo.client.XyoApiConfig - -@Deprecated("Use NodeClient.class instead") -class XyoArchivistApiConfig(val archive: String, apiDomain: String, token: String? = null): XyoApiConfig(apiDomain, token) \ No newline at end of file diff --git a/sdk/src/main/java/network/xyo/client/boundwitness/QueryBoundWitnessBuilder.kt b/sdk/src/main/java/network/xyo/client/boundwitness/QueryBoundWitnessBuilder.kt index d485e65..ef24213 100644 --- a/sdk/src/main/java/network/xyo/client/boundwitness/QueryBoundWitnessBuilder.kt +++ b/sdk/src/main/java/network/xyo/client/boundwitness/QueryBoundWitnessBuilder.kt @@ -3,7 +3,7 @@ package network.xyo.client.boundwitness import android.content.Context import android.os.Build import androidx.annotation.RequiresApi -import network.xyo.client.XyoSerializable +import network.xyo.client.lib.XyoSerializable import network.xyo.client.account.model.AccountInstance import network.xyo.client.payload.XyoPayload diff --git a/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBodyJson.kt b/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBodyJson.kt index 1c96be6..492091e 100644 --- a/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBodyJson.kt +++ b/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBodyJson.kt @@ -1,7 +1,6 @@ package network.xyo.client.boundwitness import com.squareup.moshi.JsonClass -import network.xyo.client.XyoSerializable import network.xyo.client.payload.XyoPayload @JsonClass(generateAdapter = true) diff --git a/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBuilder.kt b/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBuilder.kt index f5bfd63..644fb0f 100644 --- a/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBuilder.kt +++ b/sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessBuilder.kt @@ -3,7 +3,7 @@ package network.xyo.client.boundwitness import android.content.Context import android.os.Build import androidx.annotation.RequiresApi -import network.xyo.client.XyoSerializable +import network.xyo.client.lib.XyoSerializable import network.xyo.client.account.hexStringToByteArray import network.xyo.client.account.model.AccountInstance import network.xyo.client.datastore.previous_hash_store.PreviousHashStorePrefsRepository diff --git a/sdk/src/main/java/network/xyo/client/datastore/accounts/AccountPrefsRepository.kt b/sdk/src/main/java/network/xyo/client/datastore/accounts/AccountPrefsRepository.kt index 10e5e3f..905094a 100644 --- a/sdk/src/main/java/network/xyo/client/datastore/accounts/AccountPrefsRepository.kt +++ b/sdk/src/main/java/network/xyo/client/datastore/accounts/AccountPrefsRepository.kt @@ -13,7 +13,7 @@ import network.xyo.client.account.model.AccountInstance import network.xyo.client.settings.AccountPreferences import network.xyo.client.settings.SettingsInterface import network.xyo.client.settings.defaultXyoSdkSettings -import network.xyo.client.xyoScope +import network.xyo.client.lib.xyoScope class AccountPrefsRepository(context: Context, settings: SettingsInterface = defaultXyoSdkSettings) { diff --git a/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashStorePrefsRepository.kt b/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashStorePrefsRepository.kt index 2bb4e88..b1f212c 100644 --- a/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashStorePrefsRepository.kt +++ b/sdk/src/main/java/network/xyo/client/datastore/previous_hash_store/PreviousHashStorePrefsRepository.kt @@ -9,7 +9,7 @@ import network.xyo.client.account.model.PreviousHashStore import network.xyo.client.settings.PreviousHashStorePreferences import network.xyo.client.settings.SettingsInterface import network.xyo.client.settings.defaultXyoSdkSettings -import network.xyo.client.xyoScope +import network.xyo.client.lib.xyoScope import network.xyo.data.PreviousHashPrefsDataStoreProtos.PreviousHashPrefsDataStore diff --git a/sdk/src/main/java/network/xyo/client/EcConstants.kt b/sdk/src/main/java/network/xyo/client/ec/EcConstants.kt similarity index 91% rename from sdk/src/main/java/network/xyo/client/EcConstants.kt rename to sdk/src/main/java/network/xyo/client/ec/EcConstants.kt index bc52eb6..f60aca8 100644 --- a/sdk/src/main/java/network/xyo/client/EcConstants.kt +++ b/sdk/src/main/java/network/xyo/client/ec/EcConstants.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.ec import java.math.BigInteger diff --git a/sdk/src/main/java/network/xyo/client/EcCurve.kt b/sdk/src/main/java/network/xyo/client/ec/EcCurve.kt similarity index 99% rename from sdk/src/main/java/network/xyo/client/EcCurve.kt rename to sdk/src/main/java/network/xyo/client/ec/EcCurve.kt index ed5ddda..a73fad2 100644 --- a/sdk/src/main/java/network/xyo/client/EcCurve.kt +++ b/sdk/src/main/java/network/xyo/client/ec/EcCurve.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.ec import java.math.BigInteger import java.security.spec.ECFieldFp diff --git a/sdk/src/main/java/network/xyo/client/EcPoint.kt b/sdk/src/main/java/network/xyo/client/ec/EcPoint.kt similarity index 95% rename from sdk/src/main/java/network/xyo/client/EcPoint.kt rename to sdk/src/main/java/network/xyo/client/ec/EcPoint.kt index 3dbcfbc..63a5f46 100644 --- a/sdk/src/main/java/network/xyo/client/EcPoint.kt +++ b/sdk/src/main/java/network/xyo/client/ec/EcPoint.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.ec import java.math.BigInteger import java.security.spec.ECPoint diff --git a/sdk/src/main/java/network/xyo/client/EcPointMath.kt b/sdk/src/main/java/network/xyo/client/ec/EcPointMath.kt similarity index 94% rename from sdk/src/main/java/network/xyo/client/EcPointMath.kt rename to sdk/src/main/java/network/xyo/client/ec/EcPointMath.kt index 416fac5..ed15277 100644 --- a/sdk/src/main/java/network/xyo/client/EcPointMath.kt +++ b/sdk/src/main/java/network/xyo/client/ec/EcPointMath.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.ec import java.math.BigInteger @@ -39,7 +39,7 @@ object EcPointMath { * @return The slope of the tangent line at the point */ fun tangent (point: EcPoint, curve: EcCurve) : BigInteger { - return divide(point.affineX * point.affineX*EcConstants.THREE+curve.a, point.affineY * EcConstants.TWO, curve.p) + return divide(point.affineX * point.affineX* EcConstants.THREE +curve.a, point.affineY * EcConstants.TWO, curve.p) } /** diff --git a/sdk/src/main/java/network/xyo/client/XyoClientCoroutineScope.kt b/sdk/src/main/java/network/xyo/client/lib/XyoClientCoroutineScope.kt similarity index 94% rename from sdk/src/main/java/network/xyo/client/XyoClientCoroutineScope.kt rename to sdk/src/main/java/network/xyo/client/lib/XyoClientCoroutineScope.kt index 1b52e64..d67d8b6 100644 --- a/sdk/src/main/java/network/xyo/client/XyoClientCoroutineScope.kt +++ b/sdk/src/main/java/network/xyo/client/lib/XyoClientCoroutineScope.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.lib import kotlinx.coroutines.* import kotlin.coroutines.CoroutineContext diff --git a/sdk/src/main/java/network/xyo/client/XyoSerializable.kt b/sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt similarity index 98% rename from sdk/src/main/java/network/xyo/client/XyoSerializable.kt rename to sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt index c1cef29..1720f18 100644 --- a/sdk/src/main/java/network/xyo/client/XyoSerializable.kt +++ b/sdk/src/main/java/network/xyo/client/lib/XyoSerializable.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.lib import com.squareup.moshi.Moshi import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory @@ -69,7 +69,7 @@ abstract class XyoSerializable: Serializable { .addLast(KotlinJsonAdapterFactory()) .build() val adapter = moshi.adapter(obj.first().javaClass) - val items = obj.map {item -> sortJson(adapter.toJson(item), removeMeta)} + val items = obj.map {item -> sortJson(adapter.toJson(item), removeMeta) } return items.joinToString(",", "[", "]") } diff --git a/sdk/src/main/java/network/xyo/client/hasPermission.kt b/sdk/src/main/java/network/xyo/client/lib/hasPermission.kt similarity index 94% rename from sdk/src/main/java/network/xyo/client/hasPermission.kt rename to sdk/src/main/java/network/xyo/client/lib/hasPermission.kt index f2bab16..3ca706a 100644 --- a/sdk/src/main/java/network/xyo/client/hasPermission.kt +++ b/sdk/src/main/java/network/xyo/client/lib/hasPermission.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.lib import android.content.Context import android.content.pm.PackageManager diff --git a/sdk/src/main/java/network/xyo/client/node/client/NodeClient.kt b/sdk/src/main/java/network/xyo/client/node/client/NodeClient.kt index 648a0f6..df9fdda 100644 --- a/sdk/src/main/java/network/xyo/client/node/client/NodeClient.kt +++ b/sdk/src/main/java/network/xyo/client/node/client/NodeClient.kt @@ -8,7 +8,7 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withContext -import network.xyo.client.XyoSerializable +import network.xyo.client.lib.XyoSerializable import network.xyo.client.account.Account import network.xyo.client.account.model.AccountInstance import network.xyo.client.boundwitness.QueryBoundWitnessBuilder diff --git a/sdk/src/main/java/network/xyo/client/node/client/PostQueryResult.kt b/sdk/src/main/java/network/xyo/client/node/client/PostQueryResult.kt index 39fec6d..f270708 100644 --- a/sdk/src/main/java/network/xyo/client/node/client/PostQueryResult.kt +++ b/sdk/src/main/java/network/xyo/client/node/client/PostQueryResult.kt @@ -1,6 +1,6 @@ package network.xyo.client.node.client -import network.xyo.client.XyoSerializable +import network.xyo.client.lib.XyoSerializable class PostQueryResult( val response: QueryResponseWrapper?, diff --git a/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt b/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt index 7b7e399..f175f88 100644 --- a/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt +++ b/sdk/src/main/java/network/xyo/client/payload/XyoPayload.kt @@ -1,7 +1,7 @@ package network.xyo.client.payload import com.squareup.moshi.JsonClass -import network.xyo.client.XyoSerializable +import network.xyo.client.lib.XyoSerializable open class XyoException(message: String): Throwable(message) open class XyoValidationException(message: String): XyoException(message) diff --git a/sdk/src/main/java/network/xyo/client/XyoPanel.kt b/sdk/src/main/java/network/xyo/client/witness/XyoPanel.kt similarity index 51% rename from sdk/src/main/java/network/xyo/client/XyoPanel.kt rename to sdk/src/main/java/network/xyo/client/witness/XyoPanel.kt index 3facb9e..e0b5611 100644 --- a/sdk/src/main/java/network/xyo/client/XyoPanel.kt +++ b/sdk/src/main/java/network/xyo/client/witness/XyoPanel.kt @@ -1,15 +1,10 @@ -package network.xyo.client +package network.xyo.client.witness import android.content.Context import android.os.Build import android.util.Log import androidx.annotation.RequiresApi -import kotlinx.coroutines.launch -import network.xyo.client.account.Account import network.xyo.client.account.model.AccountInstance -import network.xyo.client.archivist.api.PostBoundWitnessesResult -import network.xyo.client.archivist.api.XyoArchivistApiClient -import network.xyo.client.archivist.api.XyoArchivistApiConfig import network.xyo.client.archivist.wrapper.ArchivistWrapper import network.xyo.client.boundwitness.XyoBoundWitnessBuilder import network.xyo.client.boundwitness.XyoBoundWitnessJson @@ -17,59 +12,25 @@ import network.xyo.client.node.client.NodeClient import network.xyo.client.node.client.PostQueryResult import network.xyo.client.payload.XyoPayload -data class XyoPanelReportResult(val bw: XyoBoundWitnessJson, val apiResults: List) data class XyoPanelReportQueryResult(val bw: XyoBoundWitnessJson, val apiResults: List?, val payloads: List?) @RequiresApi(Build.VERSION_CODES.M) class XyoPanel( val context: Context, val account: AccountInstance, - private val archivists: List?, private val witnesses: List>?, private val nodeUrlsAndAccounts: ArrayList>? ) { private var nodes: MutableList? = null - @Deprecated("use constructors without deprecated archive field") constructor( context: Context, account: AccountInstance, - archive: String? = null, - apiDomain: String? = null, - witnesses: List>? = null - ) : - this( - context, - account, - listOf( - XyoArchivistApiClient.get( - XyoArchivistApiConfig( - archive ?: DefaultArchive, - apiDomain ?: DefaultApiDomain - ) - ) - ), - witnesses, - null - ) - - constructor( - context: Context, - account: AccountInstance, - // ArrayList to not cause compiler confusion with other class constructor signatures nodeUrlsAndAccounts: ArrayList>, witnesses: List>? = null ): this( context, account, - listOf( - XyoArchivistApiClient.get( - XyoArchivistApiConfig( - DefaultArchive, - DefaultApiDomain - ) - ) - ), witnesses, nodeUrlsAndAccounts ) @@ -77,12 +38,12 @@ class XyoPanel( constructor( context: Context, account: AccountInstance, - observe: ((context: Context) -> List?)? + observe: ((context: Context) -> List?)? ): this( context, account, - arrayListOf(Pair("$DefaultApiDomain/Archivist", Account.random())), listOf(XyoWitness(observe)), + null, ) fun resolveNodes(resetNodes: Boolean = false) { @@ -99,42 +60,6 @@ class XyoPanel( } } - @kotlinx.coroutines.ExperimentalCoroutinesApi - fun event() { - xyoScope.launch { - this@XyoPanel.eventAsync() - } - } - - @kotlinx.coroutines.ExperimentalCoroutinesApi - suspend fun eventAsync(): XyoPanelReportResult { - return this.reportAsync() - } - - @kotlinx.coroutines.ExperimentalCoroutinesApi - suspend fun eventAsyncQuery(event: String): XyoPanelReportQueryResult { - val adhocWitnessList = listOf( - XyoWitness({ - _, -> listOf(XyoEventPayload(event)) - }) - ) - return reportAsyncQuery(adhocWitnessList) - } - - @kotlinx.coroutines.ExperimentalCoroutinesApi - fun report() { - xyoScope.launch { - reportAsync() - } - } - - @kotlinx.coroutines.ExperimentalCoroutinesApi - fun reportQuery(adhocWitnesses: List> = emptyList()) { - xyoScope.launch { - reportAsyncQuery(adhocWitnesses) - } - } - private suspend fun generateBoundWitnessJson(): XyoBoundWitnessJson { val payloads = generatePayloads() return XyoBoundWitnessBuilder(context) @@ -153,17 +78,6 @@ class XyoPanel( return payloads.mapNotNull { payload -> payload }.flatten() } - @Deprecated("use reportAsyncQuery instead") - @kotlinx.coroutines.ExperimentalCoroutinesApi - suspend fun reportAsync(): XyoPanelReportResult { - val bw = generateBoundWitnessJson() - val results = mutableListOf() - archivists?.forEach { archivist -> - results.add(archivist.postBoundWitnessAsync(bw)) - } - return XyoPanelReportResult(bw, results) - } - @kotlinx.coroutines.ExperimentalCoroutinesApi suspend fun reportAsyncQuery(adhocWitnesses: List> = emptyList()): XyoPanelReportQueryResult { if (nodes == null) resolveNodes() @@ -183,9 +97,4 @@ class XyoPanel( } return XyoPanelReportQueryResult(bw, results, payloads) } - - companion object { - const val DefaultApiDomain = "https://api.archivist.xyo.network" - const val DefaultArchive = "temp" - } } \ No newline at end of file diff --git a/sdk/src/main/java/network/xyo/client/XyoWitness.kt b/sdk/src/main/java/network/xyo/client/witness/XyoWitness.kt similarity index 97% rename from sdk/src/main/java/network/xyo/client/XyoWitness.kt rename to sdk/src/main/java/network/xyo/client/witness/XyoWitness.kt index 59050d7..226716c 100644 --- a/sdk/src/main/java/network/xyo/client/XyoWitness.kt +++ b/sdk/src/main/java/network/xyo/client/witness/XyoWitness.kt @@ -1,4 +1,4 @@ -package network.xyo.client +package network.xyo.client.witness import android.content.Context import android.os.Build diff --git a/sdk/src/main/java/network/xyo/client/witness/location/info/Handler.kt b/sdk/src/main/java/network/xyo/client/witness/location/info/Handler.kt index 9286b08..8f303d6 100644 --- a/sdk/src/main/java/network/xyo/client/witness/location/info/Handler.kt +++ b/sdk/src/main/java/network/xyo/client/witness/location/info/Handler.kt @@ -8,7 +8,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.withContext import network.xyo.client.witness.types.WitnessHandlerInterface import network.xyo.client.witness.types.WitnessResult -import network.xyo.client.XyoPanel +import network.xyo.client.witness.XyoPanel import network.xyo.client.account.model.AccountInstance import network.xyo.client.boundwitness.XyoBoundWitnessBodyJson import network.xyo.client.payload.XyoPayload diff --git a/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationCurrent.kt b/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationCurrent.kt index 3c8bb22..23a9b26 100644 --- a/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationCurrent.kt +++ b/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationCurrent.kt @@ -9,7 +9,7 @@ import androidx.annotation.RequiresApi import com.google.android.gms.location.LocationServices import com.squareup.moshi.JsonClass import kotlinx.coroutines.suspendCancellableCoroutine -import network.xyo.client.XyoSerializable +import network.xyo.client.lib.XyoSerializable import kotlin.coroutines.resumeWithException @JsonClass(generateAdapter = true) diff --git a/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt b/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt index 9cd33be..5dc4c81 100644 --- a/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt +++ b/sdk/src/main/java/network/xyo/client/witness/location/info/XyoLocationWitness.kt @@ -4,8 +4,8 @@ import android.content.Context import android.os.Build import android.util.Log import androidx.annotation.RequiresApi -import network.xyo.client.DeferredObserver -import network.xyo.client.XyoWitness +import network.xyo.client.witness.DeferredObserver +import network.xyo.client.witness.XyoWitness import network.xyo.client.account.Account import network.xyo.client.account.model.AccountInstance import network.xyo.client.payload.XyoPayload diff --git a/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoNetworkWifi.kt b/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoNetworkWifi.kt index dede49b..869025a 100644 --- a/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoNetworkWifi.kt +++ b/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoNetworkWifi.kt @@ -12,7 +12,7 @@ import android.net.wifi.WifiInfo import android.os.Build import androidx.annotation.RequiresApi import com.squareup.moshi.JsonClass -import network.xyo.client.hasPermission +import network.xyo.client.lib.hasPermission import java.net.NetworkInterface import java.util.concurrent.CountDownLatch import java.util.concurrent.TimeUnit diff --git a/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt b/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt index 1193cee..783e364 100644 --- a/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt +++ b/sdk/src/main/java/network/xyo/client/witness/system/info/XyoSystemInfoWitness.kt @@ -3,7 +3,7 @@ package network.xyo.client.witness.system.info import android.content.Context import android.os.Build import androidx.annotation.RequiresApi -import network.xyo.client.XyoWitness +import network.xyo.client.witness.XyoWitness import network.xyo.client.account.Account import network.xyo.client.account.model.AccountInstance