Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- newtype UtxoSet ctx a = UtxoSet {
- _utxos ∷ Map TxIn (TxOut ctx BabbageEra, a)
- fromUtxoTx ∷ UtxoSet CtxTx a → UtxoSet CtxUTxO a
- singleton ∷ TxIn → (TxOut ctx BabbageEra, a) → UtxoSet ctx a
- newtype PrettyBalance ctx a = PrettyBalance (UtxoSet ctx a)
- _UtxoSet ∷ ∀ ctx a ctx a. Iso (UtxoSet ctx a) (UtxoSet ctx a) (Map TxIn (TxOut ctx BabbageEra, a)) (Map TxIn (TxOut ctx BabbageEra, a))
- totalBalance ∷ UtxoSet ctx a → Value
- partition ∷ ((TxOut ctx BabbageEra, a) → Bool) → UtxoSet ctx a → (UtxoSet ctx a, UtxoSet ctx a)
- onlyAda ∷ UtxoSet ctx a → UtxoSet ctx a
- onlyPubKey ∷ UtxoSet ctx a → UtxoSet ctx a
- onlyAddress ∷ AddressInEra BabbageEra → UtxoSet ctx a → UtxoSet ctx a
- onlyCredential ∷ PaymentCredential → UtxoSet ctx a → UtxoSet ctx a
- onlyCredentials ∷ Set PaymentCredential → UtxoSet ctx a → UtxoSet ctx a
- onlyStakeCredential ∷ StakeCredential → UtxoSet ctx a → UtxoSet ctx a
- removeUtxos ∷ Set TxIn → UtxoSet ctx a → UtxoSet ctx a
- fromApiUtxo ∷ UTxO BabbageEra → UtxoSet CtxUTxO ()
- toApiUtxo ∷ UtxoSet CtxUTxO () → UTxO BabbageEra
- selectUtxo ∷ UtxoSet ctx a → Maybe (TxIn, (TxOut ctx BabbageEra, a))
- type UtxoChangeEvent a = Either (AddUtxoEvent a) (RemoveUtxoEvent a)
- data AddUtxoEvent a = AddUtxoEvent {}
- data RemoveUtxoEvent a = RemoveUtxoEvent {
- rueEvent ∷ !a
- rueTxOut ∷ !(TxOut CtxTx BabbageEra)
- rueTxIn ∷ !TxIn
- rueTxId ∷ !TxId
- rueTx ∷ Tx BabbageEra
- rueRedeemer ∷ Maybe (HashableScriptData, ExecutionUnits)
- extract ∷ (TxIn → TxOut CtxTx BabbageEra → Maybe a) → Maybe AddressCredential → UtxoSet CtxTx a → BlockInMode CardanoMode → [UtxoChangeEvent a]
- txId ∷ UtxoChangeEvent a → TxId
- data UtxoChange ctx a = UtxoChange {
- _outputsAdded ∷ !(Map TxIn (TxOut ctx BabbageEra, a))
- _outputsRemoved ∷ !(Map TxIn (TxOut ctx BabbageEra, a))
- toUtxoChangeTx ∷ UtxoChange CtxTx a → UtxoChange CtxUTxO a
- fromEvent ∷ UtxoChangeEvent a → UtxoChange CtxTx a
- newtype PrettyUtxoChange ctx a = PrettyUtxoChange (UtxoChange ctx a)
- outputsAdded ∷ ∀ ctx a. Lens' (UtxoChange ctx a) (Map TxIn (TxOut ctx BabbageEra, a))
- outputsRemoved ∷ ∀ ctx a. Lens' (UtxoChange ctx a) (Map TxIn (TxOut ctx BabbageEra, a))
- null ∷ UtxoChange ctx a → Bool
- apply ∷ UtxoSet ctx a → UtxoChange ctx a → UtxoSet ctx a
- inv ∷ UtxoChange ctx a → UtxoChange ctx a
- extract_ ∷ AddressCredential → UtxoSet CtxTx () → BlockInMode CardanoMode → UtxoChange CtxTx ()
- describeChange ∷ UtxoChange ctx a → Text
- newtype BalanceChanges = BalanceChanges {}
- balanceChange ∷ UtxoChange ctx a → BalanceChanges
- invBalanceChange ∷ BalanceChanges → BalanceChanges
- changeFor ∷ PaymentCredential → BalanceChanges → Value
- changeForAddress ∷ AddressInEra BabbageEra → BalanceChanges → Value
Utxo sets
newtype UtxoSet ctx a Source #
A set of unspent transaction outputs
Instances
Functor (UtxoSet ctx) Source # | |
(FromJSON a, FromJSON (TxOut ctx BabbageEra)) ⇒ FromJSON (UtxoSet ctx a) Source # | |
(ToJSON a, ToJSON (TxOut ctx BabbageEra)) ⇒ ToJSON (UtxoSet ctx a) Source # | |
Monoid (UtxoSet ctx a) Source # | |
Semigroup (UtxoSet ctx a) Source # | |
Show a ⇒ Show (UtxoSet ctx a) Source # | |
Eq a ⇒ Eq (UtxoSet ctx a) Source # | |
fromUtxoTx ∷ UtxoSet CtxTx a → UtxoSet CtxUTxO a Source #
Change the context of the outputs in this utxo set to CtxUTxO
newtype PrettyBalance ctx a Source #
PrettyBalance (UtxoSet ctx a) |
Instances
Pretty a ⇒ Pretty (PrettyBalance ctx a) Source # | |
Defined in Convex.Utxos 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 #
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)
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
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 RemoveUtxoEvent a Source #
A tx output was spent
RemoveUtxoEvent | |
|
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
UtxoChange | |
|
Instances
Monoid (UtxoChange ctx a) Source # | |
Defined in Convex.Utxos 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 # | |
Defined in Convex.Utxos (<>) ∷ 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 #
PrettyUtxoChange (UtxoChange ctx a) |
Instances
Pretty a ⇒ Pretty (PrettyUtxoChange ctx a) Source # | |
Defined in Convex.Utxos 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
?
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
Instances
Monoid BalanceChanges Source # | |
Defined in Convex.Utxos | |
Semigroup BalanceChanges Source # | |
Defined in Convex.Utxos | |
Show BalanceChanges Source # | |
Defined in Convex.Utxos | |
Eq BalanceChanges Source # | |
Defined in Convex.Utxos (==) ∷ BalanceChanges → BalanceChanges → Bool Source # (/=) ∷ BalanceChanges → BalanceChanges → Bool Source # | |
Pretty BalanceChanges Source # | |
Defined in Convex.Utxos pretty ∷ BalanceChanges → Doc ann Source # prettyList ∷ [BalanceChanges] → Doc ann Source # |
balanceChange ∷ UtxoChange ctx a → BalanceChanges Source #
The change in currency affected by the UtxoChange
on each address
changeFor ∷ PaymentCredential → BalanceChanges → Value Source #
Change for a PaymentCredential
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.