Skip to content

Commit

Permalink
Fix encoders
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Gostkin committed Sep 13, 2019
1 parent 84828f2 commit e07c9c5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/scala/sigmastate/serialization/DataJsonEncoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.circe._
import io.circe.syntax._
import org.ergoplatform.ErgoBox
import org.ergoplatform.ErgoBox.NonMandatoryRegisterId
import org.ergoplatform.settings.ErgoAlgos
import scalan.RType
import scalan.RType.PairType
import scorex.crypto.hash.Digest32
Expand All @@ -32,7 +33,7 @@ object DataJsonEncoder {
}

private def encodeBytes: Encoder[Array[Byte]] = (bytes: Array[Byte]) => {
scorex.util.encode.Base16.encode(bytes).asJson
ErgoAlgos.encode(bytes).asJson
}

private def encodeData[T <: SType](v: T#WrappedType, tpe: T): Json = tpe match {
Expand Down Expand Up @@ -134,7 +135,7 @@ object DataJsonEncoder {
private def decodeBytes(json: Json): Array[Byte] = {
val jsonStr = json.as[String]
jsonStr match {
case Right(jsonStr) => scorex.util.encode.Base16.decode(jsonStr).get
case Right(jsonStr) => ErgoAlgos.decode(jsonStr).get
case Left(error) => throw new SerializerException(error.getMessage)
}
}
Expand Down

0 comments on commit e07c9c5

Please sign in to comment.