ScorexFoundation / sigmastate-interpreter

ErgoScript compiler and ErgoTree Interpreter implementation for Ergo blockchain
MIT License
62 stars 40 forks source link

[6.0] Global.deserializeTo[] method #979

Open kushti opened 3 months ago

kushti commented 3 months ago

This PR contains new Global.deserializeRaw method which is allowing to deserialize a typed object from underlying type bytes (see below).

Types supported are:

examples:

{
    val ba = fromBase16("028a5b7f7f7f7f7f7f6c");
    val b = Global.deserialize[BigInt](ba)
    b == byteArrayToBigInt(ba)
}
{
    val ba = getVar[Coll[Byte]](21).get
    val prop = Global.deserialize[SigmaProp](ba)
    prop
}

The method is called deserializeRaw as we may have deserializeTyped as well in future (to deserialize data with type information attached, e.g. Coll[Header])