Skip to content

Commit

Permalink
display plaintext messages attached to tx history item
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-rdx committed Mar 6, 2024
1 parent 4153d7e commit 78ed933
Show file tree
Hide file tree
Showing 21 changed files with 505 additions and 103 deletions.
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()
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()
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
}
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()
}
}
}
}
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()
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()
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
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()
}
}
}
}
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
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@

package com.babylon.wallet.android.data.gateway.generated.models

import com.babylon.wallet.android.data.gateway.coreapi.TransactionMessage
import com.babylon.wallet.android.data.gateway.generated.models.ManifestClass
import com.babylon.wallet.android.data.gateway.generated.models.TransactionBalanceChanges
import com.babylon.wallet.android.data.gateway.generated.models.TransactionReceipt
import com.babylon.wallet.android.data.gateway.generated.models.TransactionStatus
import com.babylon.wallet.android.data.gateway.serialisers.StateEntityDetailsResponseItemDetailsSerializer

import kotlinx.serialization.Serializable
import kotlinx.serialization.SerialName
Expand Down Expand Up @@ -101,11 +103,10 @@ data class CommittedTransactionInfo (
val manifestClasses: kotlin.collections.List<@Contextual ManifestClass>? = null,

/* The optional transaction message. This type is defined in the Core API as `TransactionMessage`. See the Core API documentation for more details. */
// @Contextual @SerialName(value = "message")
// val message: kotlin.Any? = null,
@Contextual @SerialName(value = "message")
val message: TransactionMessage? = null,

@SerialName(value = "balance_changes")
val balanceChanges: TransactionBalanceChanges? = null

)

)
Loading

0 comments on commit 78ed933

Please sign in to comment.