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

parseJSONValueParser (UtxoSet ctx a) Source #

parseJSONListValueParser [UtxoSet ctx a] Source #

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

Defined in Convex.Utxos

Methods

toJSONUtxoSet ctx a → Value Source #

toEncodingUtxoSet 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

memptyUtxoSet ctx a Source #

mappendUtxoSet 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 #

sconcatNonEmpty (UtxoSet ctx a) → UtxoSet ctx a Source #

stimesIntegral b ⇒ b → UtxoSet ctx a → UtxoSet ctx a Source #

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

Defined in Convex.Utxos

Methods

showsPrecIntUtxoSet ctx a → ShowS Source #

showUtxoSet 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 #

fromUtxoTxUtxoSet CtxTx a → UtxoSet CtxUTxO a Source #

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

singletonTxIn → (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

prettyPrettyBalance 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 #

totalBalanceUtxoSet 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.

onlyAdaUtxoSet ctx a → UtxoSet ctx a Source #

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

onlyPubKeyUtxoSet ctx a → UtxoSet ctx a Source #

Restrict the UtxoSet to public key outputs

onlyAddressAddressInEra BabbageEraUtxoSet ctx a → UtxoSet ctx a Source #

Restrict the UtxoSet to outputs at the address

onlyCredentialPaymentCredentialUtxoSet ctx a → UtxoSet ctx a Source #

Restrict the utxo set to outputs with the given payment credential

onlyCredentialsSet PaymentCredentialUtxoSet ctx a → UtxoSet ctx a Source #

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

onlyStakeCredentialStakeCredentialUtxoSet ctx a → UtxoSet ctx a Source #

Restrict the utxo set to outputs with the given stake credential

removeUtxosSet TxInUtxoSet ctx a → UtxoSet ctx a Source #

Delete some outputs from the UtxoSet

fromApiUtxoUTxO BabbageEraUtxoSet CtxUTxO () Source #

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

toApiUtxoUtxoSet CtxUTxO () → UTxO BabbageEra Source #

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

selectUtxoUtxoSet 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 ∷ (TxInTxOut CtxTx BabbageEraMaybe 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.

txIdUtxoChangeEvent 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

memptyUtxoChange ctx a Source #

mappendUtxoChange 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 #

sconcatNonEmpty (UtxoChange ctx a) → UtxoChange ctx a Source #

stimesIntegral b ⇒ b → UtxoChange ctx a → UtxoChange ctx a Source #

toUtxoChangeTxUtxoChange CtxTx a → UtxoChange CtxUTxO a Source #

Change the context of the outputs in this utxo change

fromEventUtxoChangeEvent 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

prettyPrettyUtxoChange 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 #

nullUtxoChange ctx a → Bool Source #

Is this the empty UtxoChange?

applyUtxoSet ctx a → UtxoChange ctx a → UtxoSet ctx a Source #

Change the UtxoSet

invUtxoChange ctx a → UtxoChange ctx a Source #

Invert a UtxoChange value

extract_ ∷ AddressCredential → UtxoSet CtxTx () → BlockInMode CardanoModeUtxoChange CtxTx () Source #

Extract from a block the UTXO changes at the given address

describeChangeUtxoChange 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

balanceChangeUtxoChange ctx a → BalanceChanges Source #

The change in currency affected by the UtxoChange on each address

changeForAddressAddressInEra BabbageEraBalanceChangesValue 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.