trustless-sidechain-8.0.0: Smart contract code used by the partner-chains project.
Safe HaskellSafe-Inferred
LanguageHaskell2010

TrustlessSidechain.Utils

Description

This module provides utility functions for working with Plutus data structures.

Synopsis

Documentation

fromSingleton #

Arguments

:: (() -> a)

Error thunk evaluated if the list is not a singleton. We do this so the Plutus optimizer can strip out the error string when `remove-trace` is enabled. If the string is passed directly it will be included in the CBOR output even if not used.

-> [a]

Input list

-> a

The only element in the list (or error)

Unwrap a singleton list, or fail with a custom error.

fromSingletonData #

Arguments

:: UnsafeFromData a 
=> (() -> a)

Error thunk evaluated if the list is not a singleton. We do this so the Plutus optimizer can strip out the error string when `remove-trace` is enabled. If the string is passed directly it will be included in the CBOR output even if not used.

-> List a

Plutus list

-> a

The only element in the list (or error)

Unwrap a singleton Plutus list, or fail with a custom error.

fromJust #

Arguments

:: (() -> a)

Error thunk evaluated if the value is Nothing We do this so the Plutus optimizer can strip out the error string when `remove-trace` is enabled. If the string is passed directly it will be included in the CBOR output even if not used.

-> Maybe a

Input optional value

-> a

The contained value (or error)

Unwrap a Maybe value, or fail with a custom error.

currencySymbolValueOf #

Arguments

:: Value

Value to inspect

-> CurrencySymbol

Currency symbol to extract total quantity for

-> Integer

Total quantity of that currency symbol

Get the total amount of a given currency symbol in a value, ignoring token names.

oneTokenBurned #

Arguments

:: Value

The txInfoMint field of the transaction, treated as a Value

-> CurrencySymbol

Currency symbol

-> TokenName

Token name

-> Bool

True if exactly one token was burned

Check that exactly one token of the specified currency and token name was burned.

scriptToPlutusScript #

Arguments

:: SerialisedScript

Serialized script (from compile)

-> PlutusScript PlutusScriptV2

Wrapped script for use in transactions

Convert a serialized Plutus script to a PlutusScript suitable for submission via the Cardano API.

oneTokenMinted #

Arguments

:: TxInfo

Transaction info

-> CurrencySymbol

Currency symbol

-> TokenName

Token name

-> Bool

True if exactly one token was minted

Check that exactly one token of the specified currency and token name was minted.

getOutputsAt #

Arguments

:: TxInfo

Transaction info

-> Address

Address to filter for

-> List TxOut

Outputs paying to that address

Get all outputs that pay to the specified address.

getInputsAt #

Arguments

:: TxInfo

Transaction info

-> Address

Address to filter for

-> List TxOut

Inputs that were spent from that address

Get all resolved inputs that come from the specified address.