BuiltinValueOps

scalus.uplc.eval.BuiltinValueOps

Internal helpers for BuiltinValue operations in CEK machine.

CIP-0153 MaryEraValue implementation.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def fromData(data: Data): BuiltinValue

Convert Data to BuiltinValue.

Convert Data to BuiltinValue.

Attributes

Throws
BuiltinException

if data is not in the expected format, or validation fails

def insertCoin(currency: ByteString, token: ByteString, amount: BigInt, value: BuiltinValue): BuiltinValue

Insert or update a token amount in a value.

Insert or update a token amount in a value.

If amount is 0, the token is removed. If the inner map becomes empty, the currency is removed.

Attributes

Throws
BuiltinException

if currency or token name exceeds 32 bytes, or quantity overflows 128-bit range

def isValidKey(bs: ByteString): Boolean
def isValidQuantity(i: BigInt): Boolean
def lookupCoin(currency: ByteString, token: ByteString, value: BuiltinValue): BigInt

Lookup a token amount in a value.

Lookup a token amount in a value.

Returns 0 if the token is not found.

Attributes

def maxInnerSize(v: BuiltinValue): Int
def outerSize(v: BuiltinValue): Int
def scaleValue(scalar: BigInt, value: BuiltinValue): BuiltinValue

Multiply all amounts in a value by a scalar.

Multiply all amounts in a value by a scalar.

If scalar is 0, returns empty value.

Attributes

Throws
BuiltinException

if any resulting quantity overflows 128-bit range

def toData(value: BuiltinValue): Data

Convert BuiltinValue to Data representation.

Convert BuiltinValue to Data representation.

Data encoding: Map ByteString (Map ByteString Integer)

Delegates to BuiltinValue.toData.

Attributes

def totalSize(v: BuiltinValue): Int

Merge two values, adding amounts for matching tokens.

Merge two values, adding amounts for matching tokens.

Zero-sum tokens are removed. Empty inner maps are removed.

Attributes

Throws
BuiltinException

if any resulting quantity overflows 128-bit range

def unsafeFromMap(m: SortedMap[ByteString, SortedMap[ByteString, BigInt]]): BuiltinValue
def valueContains(v1: BuiltinValue, v2: BuiltinValue): Boolean

Check if v1 contains at least the amounts in v2.

Check if v1 contains at least the amounts in v2.

For each token in v2, check that v1 has at least that amount.

Attributes

Concrete fields

val maxKeyLen: Int
val quantityMax: BigInt
val quantityMin: BigInt