All Downloads are FREE. Search and download functionalities are using the official Maven repository.

encrywm.common.ScriptSerializer.scala Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package encrywm.common

import encrywm.ast.Ast.TREE_ROOT.Contract
import encrywm.ast.AstCodec.codec
import scodec.bits.BitVector

import scala.util.Try

object ScriptSerializer {

  def serialize(contract: Contract): SerializedScript =
    codec.encode(contract).require.toByteArray

  def deserialize(bytes: SerializedScript): Try[Contract] =
    Try(codec.decode(BitVector(bytes)).require.value.asInstanceOf[Contract])
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy