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

remove depracations and reorganize #24

Merged
merged 12 commits into from
Nov 20, 2024
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -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.*

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package network.xyo.client
package network.xyo.client.payload

import android.content.Context
import androidx.test.platform.app.InstrumentationRegistry
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.xyo.client
package network.xyo.client.witness

import android.Manifest
import android.content.Context
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions sdk/src/main/java/network/xyo/client/XyoApiConfig.kt

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.xyo.client
package network.xyo.client.ec

import java.math.BigInteger

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.xyo.client
package network.xyo.client.ec

import java.math.BigInteger
import java.security.spec.ECFieldFp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.xyo.client
package network.xyo.client.ec

import java.math.BigInteger
import java.security.spec.ECPoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.xyo.client
package network.xyo.client.ec

import java.math.BigInteger

Expand Down Expand Up @@ -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)
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.xyo.client
package network.xyo.client.lib

import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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(",", "[", "]")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package network.xyo.client
package network.xyo.client.lib

import android.content.Context
import android.content.pm.PackageManager
Expand Down
Loading
Loading