convex-base-0.2.0.0: Base classes and types for working with cardano-api transactions
Safe HaskellSafe-Inferred
LanguageHaskell2010

Convex.Utxos

Synopsis

Utxo sets

newtype UtxoSet ctx a Source #

A set of unspent transaction outputs

Constructors

UtxoSet 

Fields

Instances

Instances details
Functor (UtxoSet ctx) Source # 
Instance details

Defined in Convex.Utxos

Methods

fmap ∷ (a → b) → UtxoSet ctx a → UtxoSet ctx b Source #

(<$) ∷ a → UtxoSet ctx b → UtxoSet ctx a Source #

(FromJSON a, FromJSON (TxOut ctx BabbageEra)) ⇒ FromJSON (UtxoSet ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

parseJSON ∷ Value → Parser (UtxoSet ctx a) Source #

parseJSONList ∷ Value → Parser [UtxoSet ctx a] Source #

(ToJSON a, ToJSON (TxOut ctx BabbageEra)) ⇒ ToJSON (UtxoSet ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

toJSON ∷ UtxoSet ctx a → Value Source #

toEncoding ∷ UtxoSet ctx a → Encoding Source #

toJSONList ∷ [UtxoSet ctx a] → Value Source #

toEncodingList ∷ [UtxoSet ctx a] → Encoding Source #

Monoid (UtxoSet ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

mempty ∷ UtxoSet ctx a Source #

mappend ∷ UtxoSet ctx a → UtxoSet ctx a → UtxoSet ctx a Source #

mconcat ∷ [UtxoSet ctx a] → UtxoSet ctx a Source #

Semigroup (UtxoSet ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

(<>) ∷ UtxoSet ctx a → UtxoSet ctx a → UtxoSet ctx a Source #

sconcat ∷ NonEmpty (UtxoSet ctx a) → UtxoSet ctx a Source #

stimes ∷ Integral b ⇒ b → UtxoSet ctx a → UtxoSet ctx a Source #

Show a ⇒ Show (UtxoSet ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

showsPrec ∷ Int → UtxoSet ctx a → ShowS Source #

show ∷ UtxoSet ctx a → String Source #

showList ∷ [UtxoSet ctx a] → ShowS Source #

Eq a ⇒ Eq (UtxoSet ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

(==) ∷ UtxoSet ctx a → UtxoSet ctx a → Bool Source #

(/=) ∷ UtxoSet ctx a → UtxoSet ctx a → Bool Source #

fromUtxoTx ∷ UtxoSet CtxTx a → UtxoSet CtxUTxO a Source #

Change the context of the outputs in this utxo set to CtxUTxO

singleton ∷ TxIn → (TxOut ctx BabbageEra, a) → UtxoSet ctx a Source #

A utxo set with one element

newtype PrettyBalance ctx a Source #

Constructors

PrettyBalance (UtxoSet ctx a) 

Instances

Instances details
Pretty a ⇒ Pretty (PrettyBalance ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

pretty ∷ PrettyBalance ctx a → Doc ann Source #

prettyList ∷ [PrettyBalance ctx a] → Doc ann Source #

_UtxoSet ∷ ∀ ctx a ctx a. Iso (UtxoSet ctx a) (UtxoSet ctx a) (Map TxIn (TxOut ctx BabbageEra, a)) (Map TxIn (TxOut ctx BabbageEra, a)) Source #

totalBalance ∷ UtxoSet ctx a → Value Source #

The combined Value of all outputs in the set

partition ∷ ((TxOut ctx BabbageEra, a) → Bool) → UtxoSet ctx a → (UtxoSet ctx a, UtxoSet ctx a) Source #

Partition the UtxoSet according to a predicate. The first UtxoSet contains all utxos that satisfy the predicate, the second all utxos that fail the predicate.

onlyAda ∷ UtxoSet ctx a → UtxoSet ctx a Source #

Restrict the UtxoSet to outputs that only have Ada values (no native assets)

onlyPubKey ∷ UtxoSet ctx a → UtxoSet ctx a Source #

Restrict the UtxoSet to public key outputs

onlyAddress ∷ AddressInEra BabbageEra → UtxoSet ctx a → UtxoSet ctx a Source #

Restrict the UtxoSet to outputs at the address

onlyCredential ∷ PaymentCredential → UtxoSet ctx a → UtxoSet ctx a Source #

Restrict the utxo set to outputs with the given payment credential

onlyCredentials ∷ Set PaymentCredential → UtxoSet ctx a → UtxoSet ctx a Source #

Restrict the utxo set to outputs locked by one of the given payment credentials

onlyStakeCredential ∷ StakeCredential → UtxoSet ctx a → UtxoSet ctx a Source #

Restrict the utxo set to outputs with the given stake credential

removeUtxos ∷ Set TxIn → UtxoSet ctx a → UtxoSet ctx a Source #

Delete some outputs from the UtxoSet

fromApiUtxo ∷ UTxO BabbageEra → UtxoSet CtxUTxO () Source #

Convert a cardano-api 'UTxO BabbageEra' to a utxo set

toApiUtxo ∷ UtxoSet CtxUTxO () → UTxO BabbageEra Source #

Convert a utxo set to a cardano-api 'UTxO BabbageEra'

selectUtxo ∷ UtxoSet ctx a → Maybe (TxIn, (TxOut ctx BabbageEra, a)) Source #

Pick an unspent output from the UtxoSet, if there is one.

Events based on transactions

type UtxoChangeEvent a = Either (AddUtxoEvent a) (RemoveUtxoEvent a) Source #

An event that caused the utxo set to change

data AddUtxoEvent a Source #

A new tx out was added

Constructors

AddUtxoEvent 

Fields

data RemoveUtxoEvent a Source #

A tx output was spent

Constructors

RemoveUtxoEvent 

Fields

extract ∷ (TxIn → TxOut CtxTx BabbageEra → Maybe a) → Maybe AddressCredential → UtxoSet CtxTx a → BlockInMode CardanoMode → [UtxoChangeEvent a] Source #

Extract from a block the UTXO changes at the given address. Returns the UtxoChange itself and a set of all transactions that affected the change.

txId ∷ UtxoChangeEvent a → TxId Source #

ID of the transaction that caused the event

Changes to utxo sets

data UtxoChange ctx a Source #

A change to the UTxO set, adding and/or removing UTxOs

Constructors

UtxoChange 

Fields

Instances

Instances details
Monoid (UtxoChange ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

mempty ∷ UtxoChange ctx a Source #

mappend ∷ UtxoChange ctx a → UtxoChange ctx a → UtxoChange ctx a Source #

mconcat ∷ [UtxoChange ctx a] → UtxoChange ctx a Source #

Semigroup (UtxoChange ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

(<>) ∷ UtxoChange ctx a → UtxoChange ctx a → UtxoChange ctx a Source #

sconcat ∷ NonEmpty (UtxoChange ctx a) → UtxoChange ctx a Source #

stimes ∷ Integral b ⇒ b → UtxoChange ctx a → UtxoChange ctx a Source #

toUtxoChangeTx ∷ UtxoChange CtxTx a → UtxoChange CtxUTxO a Source #

Change the context of the outputs in this utxo change

fromEvent ∷ UtxoChangeEvent a → UtxoChange CtxTx a Source #

The UtxoChange represented by the event.

newtype PrettyUtxoChange ctx a Source #

Constructors

PrettyUtxoChange (UtxoChange ctx a) 

Instances

Instances details
Pretty a ⇒ Pretty (PrettyUtxoChange ctx a) Source # 
Instance details

Defined in Convex.Utxos

Methods

pretty ∷ PrettyUtxoChange ctx a → Doc ann Source #

prettyList ∷ [PrettyUtxoChange ctx a] → Doc ann Source #

outputsAdded ∷ ∀ ctx a. Lens' (UtxoChange ctx a) (Map TxIn (TxOut ctx BabbageEra, a)) Source #

outputsRemoved ∷ ∀ ctx a. Lens' (UtxoChange ctx a) (Map TxIn (TxOut ctx BabbageEra, a)) Source #

null ∷ UtxoChange ctx a → Bool Source #

Is this the empty UtxoChange?

apply ∷ UtxoSet ctx a → UtxoChange ctx a → UtxoSet ctx a Source #

Change the UtxoSet

inv ∷ UtxoChange ctx a → UtxoChange ctx a Source #

Invert a UtxoChange value

extract_ ∷ AddressCredential → UtxoSet CtxTx () → BlockInMode CardanoMode → UtxoChange CtxTx () Source #

Extract from a block the UTXO changes at the given address

describeChange ∷ UtxoChange ctx a → Text Source #

Describe the UtxoChange

Changes to addresses

newtype BalanceChanges Source #

A type capturing the effect a UtxoChange has on the total balance of each address that it touches

balanceChange ∷ UtxoChange ctx a → BalanceChanges Source #

The change in currency affected by the UtxoChange on each address

changeForAddress ∷ AddressInEra BabbageEra → BalanceChanges → Value Source #

Balance change for the payment credential of a particular address. Note that this may include the change for addresses with the same payment credential and different staking credentials.