-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
display plaintext messages attached to tx history item
- Loading branch information
Showing
21 changed files
with
505 additions
and
103 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...ain/java/com/babylon/wallet/android/data/gateway/coreapi/BinaryPlaintextMessageContent.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,38 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import kotlinx.serialization.Contextual | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* | ||
* | ||
* @param type | ||
* @param valueHex The hex-encoded value of a message that the author decided to provide as raw bytes. | ||
*/ | ||
@Serializable | ||
data class BinaryPlaintextMessageContent( | ||
|
||
@Contextual @SerialName(value = "type") | ||
override val type: PlaintextMessageContentType, | ||
|
||
/* The hex-encoded value of a message that the author decided to provide as raw bytes. */ | ||
@SerialName(value = "value_hex") | ||
val valueHex: kotlin.String | ||
|
||
) : PlaintextMessageContent() |
39 changes: 39 additions & 0 deletions
39
.../main/java/com/babylon/wallet/android/data/gateway/coreapi/EncryptedTransactionMessage.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,39 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* | ||
* | ||
* @param type | ||
* @param encryptedHex The hex-encoded (128-bit) AES-GCM encrypted bytes of an SBOR-encoded `PlaintextTransactionMessage`. The bytes are serialized as the concatenation `Nonce/IV (12 bytes) || Cipher (variable length) || Tag/MAC (16 bytes)`: | ||
* @param curveDecryptorSets | ||
*/ | ||
@Serializable | ||
@SerialName("Plaintext") | ||
data class EncryptedTransactionMessage( | ||
|
||
/* The hex-encoded (128-bit) AES-GCM encrypted bytes of an SBOR-encoded `PlaintextTransactionMessage`. The bytes are serialized as the concatenation `Nonce/IV (12 bytes) || Cipher (variable length) || Tag/MAC (16 bytes)`: */ | ||
@SerialName(value = "encrypted_hex") | ||
val encryptedHex: kotlin.String, | ||
|
||
// @SerialName(value = "curve_decryptor_sets") | ||
// val curveDecryptorSets: Any? = null | ||
|
||
) : TransactionMessage() |
34 changes: 34 additions & 0 deletions
34
app/src/main/java/com/babylon/wallet/android/data/gateway/coreapi/PlaintextMessageContent.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,34 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import com.babylon.wallet.android.data.gateway.serialisers.PlaintextMessageContentSerializer | ||
import kotlinx.serialization.Contextual | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* | ||
* | ||
* @param type | ||
*/ | ||
@Serializable(with = PlaintextMessageContentSerializer::class) | ||
abstract class PlaintextMessageContent { | ||
|
||
@Contextual | ||
@SerialName(value = "type") | ||
abstract val type: PlaintextMessageContentType | ||
} |
60 changes: 60 additions & 0 deletions
60
.../main/java/com/babylon/wallet/android/data/gateway/coreapi/PlaintextMessageContentType.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,60 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* | ||
* | ||
* Values: string,binary | ||
*/ | ||
@Serializable | ||
enum class PlaintextMessageContentType(val value: kotlin.String) { | ||
|
||
@SerialName(value = "String") | ||
string("String"), | ||
|
||
@SerialName(value = "Binary") | ||
binary("Binary"); | ||
|
||
/** | ||
* Override [toString()] to avoid using the enum variable name as the value, and instead use | ||
* the actual value defined in the API spec file. | ||
* | ||
* This solves a problem when the variable name and its value are different, and ensures that | ||
* the client sends the correct enum values to the server always. | ||
*/ | ||
override fun toString(): kotlin.String = value | ||
|
||
companion object { | ||
/** | ||
* Converts the provided [data] to a [String] on success, null otherwise. | ||
*/ | ||
fun encode(data: kotlin.Any?): kotlin.String? = if (data is PlaintextMessageContentType) "$data" else null | ||
|
||
/** | ||
* Returns a valid [PlaintextMessageContentType] for [data], null otherwise. | ||
*/ | ||
fun decode(data: kotlin.Any?): PlaintextMessageContentType? = data?.let { | ||
val normalizedData = "$it".lowercase() | ||
values().firstOrNull { value -> | ||
it == value || normalizedData == "$value".lowercase() | ||
} | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
.../main/java/com/babylon/wallet/android/data/gateway/coreapi/PlaintextTransactionMessage.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,39 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* | ||
* | ||
* @param type | ||
* @param mimeType Intended to represent the RFC 2046 MIME type of the `content`. A client cannot trust that this field is a valid mime type - in particular, the choice between `String` or `Binary` representation of the content is not enforced by this `mime_type`. | ||
* @param content | ||
*/ | ||
@Serializable | ||
@SerialName("Plaintext") | ||
data class PlaintextTransactionMessage( | ||
|
||
/* Intended to represent the RFC 2046 MIME type of the `content`. A client cannot trust that this field is a valid mime type - in particular, the choice between `String` or `Binary` representation of the content is not enforced by this `mime_type`. */ | ||
@SerialName(value = "mime_type") | ||
val mimeType: kotlin.String, | ||
|
||
@SerialName(value = "content") | ||
val content: PlaintextMessageContent | ||
|
||
) : TransactionMessage() |
38 changes: 38 additions & 0 deletions
38
...ain/java/com/babylon/wallet/android/data/gateway/coreapi/StringPlaintextMessageContent.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,38 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import kotlinx.serialization.Contextual | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* | ||
* | ||
* @param type | ||
* @param `value` The value of a message that the author decided to provide as a UTF-8 string. | ||
*/ | ||
@Serializable | ||
data class StringPlaintextMessageContent( | ||
|
||
@Contextual @SerialName(value = "type") | ||
override val type: PlaintextMessageContentType, | ||
|
||
/* The value of a message that the author decided to provide as a UTF-8 string. */ | ||
@SerialName(value = "value") | ||
val `value`: kotlin.String | ||
|
||
) : PlaintextMessageContent() |
29 changes: 29 additions & 0 deletions
29
app/src/main/java/com/babylon/wallet/android/data/gateway/coreapi/TransactionMessage.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,29 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import com.babylon.wallet.android.data.gateway.serialisers.TransactionMessageSerializer | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonClassDiscriminator | ||
|
||
/** | ||
* | ||
* | ||
* @param type | ||
*/ | ||
@Serializable(with = TransactionMessageSerializer::class) | ||
@JsonClassDiscriminator("type") | ||
sealed class TransactionMessage |
60 changes: 60 additions & 0 deletions
60
app/src/main/java/com/babylon/wallet/android/data/gateway/coreapi/TransactionMessageType.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,60 @@ | ||
/** | ||
* | ||
* Please note: | ||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* Do not edit this file manually. | ||
* | ||
*/ | ||
|
||
@file:Suppress( | ||
"ArrayInDataClass", | ||
"EnumEntryName", | ||
"RemoveRedundantQualifierName", | ||
"UnusedImport" | ||
) | ||
|
||
package com.babylon.wallet.android.data.gateway.coreapi | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* | ||
* | ||
* Values: plaintext,encrypted | ||
*/ | ||
@Serializable | ||
enum class TransactionMessageType(val value: kotlin.String) { | ||
|
||
@SerialName(value = "Plaintext") | ||
plaintext("Plaintext"), | ||
|
||
@SerialName(value = "Encrypted") | ||
encrypted("Encrypted"); | ||
|
||
/** | ||
* Override [toString()] to avoid using the enum variable name as the value, and instead use | ||
* the actual value defined in the API spec file. | ||
* | ||
* This solves a problem when the variable name and its value are different, and ensures that | ||
* the client sends the correct enum values to the server always. | ||
*/ | ||
override fun toString(): kotlin.String = value | ||
|
||
companion object { | ||
/** | ||
* Converts the provided [data] to a [String] on success, null otherwise. | ||
*/ | ||
fun encode(data: kotlin.Any?): kotlin.String? = if (data is TransactionMessageType) "$data" else null | ||
|
||
/** | ||
* Returns a valid [TransactionMessageType] for [data], null otherwise. | ||
*/ | ||
fun decode(data: kotlin.Any?): TransactionMessageType? = data?.let { | ||
val normalizedData = "$it".lowercase() | ||
values().firstOrNull { value -> | ||
it == value || normalizedData == "$value".lowercase() | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...n/java/com/babylon/wallet/android/data/gateway/extensions/TransactionMessageExtensions.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,18 @@ | ||
import com.babylon.wallet.android.data.gateway.coreapi.BinaryPlaintextMessageContent | ||
import com.babylon.wallet.android.data.gateway.coreapi.EncryptedTransactionMessage | ||
import com.babylon.wallet.android.data.gateway.coreapi.PlaintextTransactionMessage | ||
import com.babylon.wallet.android.data.gateway.coreapi.StringPlaintextMessageContent | ||
import com.babylon.wallet.android.data.gateway.coreapi.TransactionMessage | ||
|
||
fun TransactionMessage.message(): String? { | ||
return when (this) { | ||
is EncryptedTransactionMessage -> null | ||
is PlaintextTransactionMessage -> { | ||
when (content) { | ||
is StringPlaintextMessageContent -> content.value | ||
is BinaryPlaintextMessageContent -> content.valueHex | ||
else -> 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
Oops, something went wrong.