Skip to content

Commit

Permalink
v5.0.11-fix1: rollback changes in decoders
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Sep 28, 2023
1 parent 770d297 commit 7de88b0
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ trait JsonCodecs {

implicit val ergoLikeTransactionEncoder: Encoder[ErgoLikeTransaction] = Encoder.instance({ tx =>
Json.obj(
"type" -> "ELT".asJson, // ErgoLikeTransaction
"id" -> tx.id.asJson,
"inputs" -> tx.inputs.asJson,
"dataInputs" -> tx.dataInputs.asJson,
Expand All @@ -387,7 +386,6 @@ trait JsonCodecs {

implicit val unsignedErgoLikeTransactionEncoder: Encoder[UnsignedErgoLikeTransaction] = Encoder.instance({ tx =>
Json.obj(
"type" -> "UELT".asJson, // UnsignedErgoLikeTransaction
"id" -> tx.id.asJson,
"inputs" -> tx.inputs.asJson,
"dataInputs" -> tx.dataInputs.asJson,
Expand All @@ -409,15 +407,10 @@ trait JsonCodecs {
case t => throw new SigmaException(s"Don't know how to encode transaction $t")
})

implicit val ergoLikeTransactionTemplateDecoder: Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]] = Decoder.instance({ implicit cursor =>
for {
t <- cursor.downField("type").as[String]
tx <- t match {
case "ELT" => ergoLikeTransactionDecoder(cursor)
case "UELT" => unsignedErgoLikeTransactionDecoder(cursor)
}
} yield tx
})
implicit val ergoLikeTransactionTemplateDecoder: Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]] = {
ergoLikeTransactionDecoder.asInstanceOf[Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]]] or
unsignedErgoLikeTransactionDecoder.asInstanceOf[Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]]]
}

implicit val sigmaValidationSettingsEncoder: Encoder[SigmaValidationSettings] = Encoder.instance({ v =>
SigmaValidationSettingsSerializer.toBytes(v).asJson
Expand Down

0 comments on commit 7de88b0

Please sign in to comment.