cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.Skeleton.Withdrawal

Description

This module exposes the withdrawing constructs used in a TxSkel and their associated utilities. To issue withdrawals in a skeleton, the usual way is to invoke txSkelWithdrawals = txSkelWithdrawalsFromList [pubKeyWithdrawal pk amount, scriptWithdrawal script redeemer amount, ...]

Synopsis

Data types

data Withdrawal where Source #

A single Withdrawal, owned by a pubkey or redeemed script

Constructors

Withdrawal 

Fields

  • :: { withdrawalUser :: User IsEither Redemption

    The user making a withdrawals of their rewards

  •    , withdrawalAmount :: Maybe Lovelace

    The amount of lovelace to withdraw. If set to Nothing, cooked will attempt to fill this out with the current rewards for the user, which is the only acceptable amount ledger-wise. Manually setting this value is only left as a possibility for testing purposes.

  •    } -> Withdrawal
     

data TxSkelWithdrawals Source #

Withdrawals associate either a script or a private key with a redeemer and a certain amount of ada. They are uniquely identified by the hash of either.

Optics

withdrawalMAmountL :: Lens' Withdrawal (Maybe Lovelace) Source #

Focuses on the optional amount in a Withdrawal

txSkelWithdrawalsListI :: Iso' TxSkelWithdrawals [Withdrawal] Source #

Transforms a [Withdrawal] to a 'TxSkelWithdrawals and vice versa. Accumulates amount of withdrawals with similar owners, and keep the latest found redeemer in the case of scripts, discarding the previous ones.

Smart constructors

pubKeyWithdrawal :: (ToPubKeyHash pkh, Typeable pkh) => pkh -> Withdrawal Source #

Creates a Withdrawal from a private key hash

scriptWithdrawal :: (ToVScript script, Typeable script, RedeemerConstrs red) => script -> red -> Withdrawal Source #

Creates a Withdrawal from a redeemed script and lovelace amount

txSkelWithdrawalsFromList :: [Withdrawal] -> TxSkelWithdrawals Source #

Builds a TxSkelWithdrawals from a list of Withdrawal. This is equivalent to calling review txSkelWithdrawalsListI

Utilities

fillAmount :: Lovelace -> Withdrawal -> Withdrawal Source #

Fills a given amount of lovelace to withdraw, if not already set