Skip to content

Commit

Permalink
Merge pull request #8 from solana-mobile/fix-signature-size
Browse files Browse the repository at this point in the history
fix sig length
  • Loading branch information
Funkatronics authored Jan 10, 2024
2 parents 5a836d9 + 226da0f commit 78237e6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ import com.solana.serialization.ByteStringSerializer
import com.solana.serialization.TransactionFormat
import kotlinx.serialization.*

object SignatureSerializer : ByteStringSerializer(64)
object SignatureSerializer : ByteStringSerializer(Transaction.SIGNATURE_LENGTH_BYTES)

@Serializable
data class Transaction(
val signatures: List<@Serializable(with = SignatureSerializer::class) ByteArray>,
@Serializable(with = MessageSerializer::class) val message: Message
) {

constructor(message: Message): this(buildList(message.signatureCount.toInt()) { ByteArray(size) }, message)
constructor(message: Message):
this(buildList(message.signatureCount.toInt()) { ByteArray(SIGNATURE_LENGTH_BYTES) }, message)

companion object {
const val SIGNATURE_LENGTH_BYTES = 64
fun from(bytes: ByteArray) = TransactionFormat.decodeFromByteArray(serializer(), bytes)
}

Expand Down

0 comments on commit 78237e6

Please sign in to comment.