plutus-ledger-constraints-0.1.0.0: Ledger Constraints
Safe HaskellNone
LanguageHaskell2010

Ledger.Constraints.OffChain

Synopsis

Lookups

data ScriptLookups a Source #

Constructors

ScriptLookups 

Fields

Instances

Instances details
Show (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Generic (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Associated Types

type Rep (ScriptLookups a) :: Type -> Type Source #

Semigroup (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Monoid (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

ToJSON (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

FromJSON (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep (ScriptLookups a) Source # 
Instance details

Defined in Ledger.Constraints.OffChain

typedValidatorLookups :: TypedValidator a -> ScriptLookups a Source #

A script lookups value with a script instance. For convenience this also includes the minting policy script that forwards all checks to the instance's validator.

If called multiple times, only the first typed validator is kept:

typedValidatorLookups tv1 <> typedValidatorLookups tv2 <> ...
    == typedValidatorLookups tv1

unspentOutputs :: Map TxOutRef ChainIndexTxOut -> ScriptLookups a Source #

A script lookups value that uses the map of unspent outputs to resolve input constraints.

mintingPolicy :: MintingPolicy -> ScriptLookups a Source #

A script lookups value with a minting policy script.

otherScript :: Validator -> ScriptLookups a Source #

A script lookups value with a validator script.

otherData :: Datum -> ScriptLookups a Source #

A script lookups value with a datum.

ownPaymentPubKeyHash :: PaymentPubKeyHash -> ScriptLookups a Source #

A script lookups value with a payment public key hash.

If called multiple times, only the payment public key hash is kept:

ownPaymentPubKeyHash pkh1 <> ownPaymentPubKeyHash pkh2 <> ...
    == ownPaymentPubKeyHash pkh1

ownStakePubKeyHash :: StakePubKeyHash -> ScriptLookups a Source #

A script lookups value with a stake public key hash.

If called multiple times, only the stake public key hash is kept:

ownStakePubKeyHash skh1 <> ownStakePubKeyHash skh2 <> ...
    == ownStakePubKeyHash skh1

paymentPubKey :: PaymentPubKey -> ScriptLookups a Source #

A script lookups value with a payment public key

Constraints resolution

data UnbalancedTx Source #

An unbalanced transaction. It needs to be balanced and signed before it can be submitted to the ledger. See note [Submitting transactions from Plutus contracts] in Wallet.

Constructors

UnbalancedTx 

Fields

Instances

Instances details
Eq UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Show UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Generic UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Associated Types

type Rep UnbalancedTx :: Type -> Type Source #

ToJSON UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

FromJSON UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

ToSchema UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Pretty UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep UnbalancedTx Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep UnbalancedTx = D1 ('MetaData "UnbalancedTx" "Ledger.Constraints.OffChain" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (C1 ('MetaCons "UnbalancedTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "unBalancedTxTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Tx) :*: S1 ('MetaSel ('Just "unBalancedTxRequiredSignatories") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map PaymentPubKeyHash (Maybe PaymentPubKey)))) :*: (S1 ('MetaSel ('Just "unBalancedTxUtxoIndex") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Map TxOutRef TxOut)) :*: S1 ('MetaSel ('Just "unBalancedTxValidityTimeRange") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 POSIXTimeRange))))

adjustUnbalancedTx :: UnbalancedTx -> UnbalancedTx Source #

Each transaction output should contain a minimum amount of Ada (this is a restriction on the real Cardano network).

TODO: In the future, the minimum Ada value should be configurable.

data MkTxError Source #

Instances

Instances details
Eq MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Show MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Generic MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Associated Types

type Rep MkTxError :: Type -> Type Source #

ToJSON MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

FromJSON MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Pretty MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

Methods

pretty :: MkTxError -> Doc ann Source #

prettyList :: [MkTxError] -> Doc ann Source #

type Rep MkTxError Source # 
Instance details

Defined in Ledger.Constraints.OffChain

type Rep MkTxError = D1 ('MetaData "MkTxError" "Ledger.Constraints.OffChain" "plutus-ledger-constraints-0.1.0.0-AdCuTwHqkQFFnwldCwEXkg" 'False) (((C1 ('MetaCons "TypeCheckFailed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ConnectionError)) :+: C1 ('MetaCons "TxOutRefNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef))) :+: (C1 ('MetaCons "TxOutRefWrongType" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxOutRef)) :+: (C1 ('MetaCons "DatumNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatumHash)) :+: C1 ('MetaCons "MintingPolicyNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 MintingPolicyHash))))) :+: ((C1 ('MetaCons "ValidatorHashNotFound" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidatorHash)) :+: C1 ('MetaCons "OwnPubKeyMissing" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "TypedValidatorMissing" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "DatumWrongHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DatumHash) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Datum)) :+: C1 ('MetaCons "CannotSatisfyAny" 'PrefixI 'False) (U1 :: Type -> Type)))))

mkTx :: (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Either MkTxError UnbalancedTx Source #

Turn a TxConstraints value into an unbalanced transaction that satisfies the constraints. To use this in a contract, see submitTxConstraints and related functions.

mkSomeTx :: [SomeLookupsAndConstraints] -> Either MkTxError UnbalancedTx Source #

Given a list of SomeLookupsAndConstraints describing the constraints for several scripts, build a single transaction that runs all the scripts.

Internals exposed for testing

data ValueSpentBalances Source #

The balances we track for computing the missing Value (if any) that needs to be added to the transaction. See note [Balance of value spent].

Constructors

ValueSpentBalances 

Fields