ProgramFlatCodec

scalus.uplc.ProgramFlatCodec

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

case class DecodeResult(program: DeBruijnedProgram, remainder: Array[Byte])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def decodeFlat(encoded: Array[Byte]): DeBruijnedProgram

Decodes Flat-encoded DeBruijnedProgram from bytes.

Decodes Flat-encoded DeBruijnedProgram from bytes.

The bytes must hold the program and its filler and nothing else, as unflat in Plutus requires: the filler, any number of 0 bits and then a 1 bit, ends on the last bit of the input. A filler longer than it needs to be is allowed. Use decodeFlatWithRemainingBytes when other bytes follow the program.

Attributes

Throws
IllegalArgumentException

see requireVersionCanCarry

scalus.serialization.flat.FlatDecodingError

if the filler is missing or ends inside a byte, or if bytes follow it

def decodeFlatWithRemainingBytes(encoded: Array[Byte]): DecodeResult

Decodes Flat-encoded DeBruijnedProgram from bytes, returning any remaining bytes that were not part of the program.

Decodes Flat-encoded DeBruijnedProgram from bytes, returning any remaining bytes that were not part of the program.

Attributes

Throws
IllegalArgumentException

see requireVersionCanCarry

scalus.serialization.flat.FlatDecodingError

if the filler is missing or ends inside a byte

def encodeFlat(deBruijned: DeBruijnedProgram): Array[Byte]

Encodes DeBruijnedProgram as Flat encoded bytes.

Encodes DeBruijnedProgram as Flat encoded bytes.

Attributes

Throws
IllegalArgumentException

see requireVersionCanCarry

Rejects a program that declares a version below 1.1.0 but contains constr/case.

Rejects a program that declares a version below 1.1.0 but contains constr/case.

This is the check the Plutus decoder makes ("'constr' is not allowed before version 1.1.0"), applied on both sides of this codec: on encode, so Scalus cannot produce bytes the ledger will reject; on decode, so Scalus does not accept bytes the ledger would not.

Attributes

Throws
IllegalArgumentException

if the program version is below 1.1.0 and the term uses constr or case

def unsafeEncodeFlat(program: Program): Array[Byte]

Encodes Program as Flat encoded bytes. It assumes the program is correctly de-bruijned. Use it if you know what you're doing.

Encodes Program as Flat encoded bytes. It assumes the program is correctly de-bruijned. Use it if you know what you're doing.

Attributes

Concrete fields

val minVersionForConstrCase: (Int, Int, Int)

The first UPLC version that can carry constr/case terms.

The first UPLC version that can carry constr/case terms.

Attributes