-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
made timestamp in bw optional, but this causes a problem with the archivist, so round trip fails until archivist fixed
- Loading branch information
Showing
25 changed files
with
199 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
sdk/src/main/java/network/xyo/client/boundwitness/BoundWitness.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package network.xyo.client.boundwitness | ||
|
||
import com.squareup.moshi.Json | ||
import com.squareup.moshi.JsonClass | ||
import network.xyo.client.payload.model.WithMeta | ||
import network.xyo.client.types.HashHex | ||
|
||
@JsonClass(generateAdapter = true) | ||
open class BoundWitness: WithMeta<BoundWitnessMeta>, BoundWitnessBody() { | ||
@Json(name = "\$meta") | ||
override var _meta = BoundWitnessMeta() | ||
|
||
@Json(name = "\$hash") | ||
override var _hash: HashHex | ||
get() { | ||
return this.dataHash() | ||
} | ||
set(value){} | ||
|
||
override fun dataHash(): String { | ||
return getBodyJson().dataHash() | ||
} | ||
|
||
fun rootHash(): String { | ||
return sha256String(this) | ||
} | ||
|
||
open fun getBodyJson(): BoundWitnessBody { | ||
return BoundWitnessBody(this.addresses, this.previous_hashes, this.payload_hashes, this.payload_schemas, this.timestamp) | ||
} | ||
} |
42 changes: 32 additions & 10 deletions
42
sdk/src/main/java/network/xyo/client/boundwitness/BoundWitnessBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
package network.xyo.client.boundwitness | ||
|
||
import network.xyo.client.payload.model.Payload | ||
|
||
interface BoundWitnessBodyFields : Payload { | ||
var addresses: List<String> | ||
var payload_hashes: List<String> | ||
var payload_schemas: List<String> | ||
var previous_hashes: List<String?> | ||
// Note: Long is a higher precision type than JavaScript's Number type but it is the default type from | ||
// Kotlin's System.currentTimeMillis(). | ||
var timestamp: Long | ||
import com.squareup.moshi.JsonClass | ||
import network.xyo.client.boundwitness.model.BoundWitnessBody | ||
import network.xyo.client.payload.Payload | ||
|
||
@JsonClass(generateAdapter = true) | ||
open class BoundWitnessBody(): BoundWitnessBody, Payload(SCHEMA) { | ||
final override var addresses = emptyList<String>() | ||
final override var payload_hashes = emptyList<String>() | ||
final override var payload_schemas = emptyList<String>() | ||
final override var previous_hashes = emptyList<String?>() | ||
final override var timestamp: Long? = null | ||
|
||
override fun dataHash(): String { | ||
return sha256String(this) | ||
} | ||
|
||
constructor ( | ||
addresses: List<String>, | ||
previous_hashes: List<String?>, | ||
payload_hashes: List<String>, | ||
payload_schemas: List<String>, | ||
timestamp: Long? = null, | ||
) : this() { | ||
this.addresses = addresses | ||
this.previous_hashes = previous_hashes | ||
this.payload_hashes = payload_hashes | ||
this.payload_schemas = payload_schemas | ||
} | ||
|
||
companion object { | ||
const val SCHEMA = "network.xyo.boundwitness" | ||
} | ||
} |
29 changes: 0 additions & 29 deletions
29
sdk/src/main/java/network/xyo/client/boundwitness/BoundWitnessBodyJson.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 0 additions & 34 deletions
34
sdk/src/main/java/network/xyo/client/boundwitness/BoundWitnessJson.kt
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
sdk/src/main/java/network/xyo/client/boundwitness/BoundWitnessMeta.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package network.xyo.client.boundwitness | ||
|
||
import com.squareup.moshi.JsonClass | ||
import network.xyo.client.boundwitness.model.BoundWitnessMeta | ||
import network.xyo.client.lib.JsonSerializable | ||
|
||
@JsonClass(generateAdapter = true) | ||
class BoundWitnessMeta: BoundWitnessMeta, JsonSerializable() { | ||
override var signatures: List<String>? = null | ||
override var client: String? = null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
sdk/src/main/java/network/xyo/client/boundwitness/QueryBoundWitnessBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package network.xyo.client.boundwitness | ||
|
||
import com.squareup.moshi.JsonClass | ||
|
||
@JsonClass(generateAdapter = true) | ||
open class QueryBoundWitnessBody( | ||
addresses: List<String>, | ||
previous_hashes: List<String?>, | ||
payload_hashes: List<String>, | ||
payload_schemas: List<String>, | ||
val query: String, | ||
timestamp: Long? | ||
): BoundWitnessBody(addresses, previous_hashes, payload_hashes, payload_schemas, timestamp) |
8 changes: 0 additions & 8 deletions
8
sdk/src/main/java/network/xyo/client/boundwitness/QueryBoundWitnessBodyJson.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
sdk/src/main/java/network/xyo/client/boundwitness/XyoBoundWitnessMetaInterface.kt
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
sdk/src/main/java/network/xyo/client/boundwitness/model/BoundWitnessBody.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package network.xyo.client.boundwitness.model | ||
|
||
import network.xyo.client.payload.model.Payload | ||
|
||
interface BoundWitnessBody : Payload { | ||
var addresses: List<String> | ||
var payload_hashes: List<String> | ||
var payload_schemas: List<String> | ||
var previous_hashes: List<String?> | ||
// Note: Long is a higher precision type than JavaScript's Number type but it is the default type from | ||
// Kotlin's System.currentTimeMillis(). | ||
var timestamp: Long? | ||
} |
Oops, something went wrong.