liqwid-plutarch-extra-3.21.1: A collection of Plutarch extras from Liqwid Labs
Safe HaskellSafe-Inferred
LanguageHaskell2010

Plutarch.Extra.ScriptContext

Synopsis

Documentation

paddressFromScriptHash :: forall (s :: S). Term s (PScriptHash :--> (PMaybeData PStakingCredential :--> PAddress)) Source #

Construct an address from a PScriptHash and maybe a PStakingCredential.

Since: 3.20.0

paddressFromPubKeyHash :: forall (s :: S). Term s (PPubKeyHash :--> (PMaybeData PStakingCredential :--> PAddress)) Source #

Constuct an address (with a staking credential) from a PPubKeyHash and maybe a @PStakingCredential

Since: 1.1.0

pownTxOutRef :: forall (s :: S). Term s (PScriptContext :--> PTxOutRef) Source #

Since: 3.13.0

pownTxInfo :: forall (s :: S). Term s (PScriptContext :--> PTxInfo) Source #

Since: 3.13.0

ptryOwnValue :: forall (s :: S). Term s (PScriptContext :--> PValue 'Sorted 'Positive) Source #

Since: 3.13.0

pownMintValue :: forall (s :: S). Term s (PScriptContext :--> PValue 'Sorted 'NoGuarantees) Source #

Since: 3.13.0

ptryOwnInput :: forall (s :: S). Term s (PScriptContext :--> PTxInInfo) Source #

Attempts to retrieve a PScriptContext own input, blowing up if not found

Since: 3.13.0

pisTokenSpent :: forall (s :: S). Term s (PAssetClass :--> (PBuiltinList PTxInInfo :--> PBool)) Source #

Check if a particular asset class has been spent in the input list.

When using this as an authority check, you MUST ensure the authority knows how to ensure its end of the contract.

Since: 3.10.0

pisUTXOSpent :: Term s (PTxOutRef :--> (PBuiltinList PTxInInfo :--> PBool)) Source #

Determines if a given UTXO is spent.

Since: 1.1.0

pvalueSpent :: forall (s :: S). Term s (PBuiltinList PTxInInfo :--> PValue 'Sorted 'Positive) Source #

Sum of all value at input.

Since: 1.1.0

ptxSignedBy :: forall (s :: S). Term s (PBuiltinList (PAsData PPubKeyHash) :--> (PAsData PPubKeyHash :--> PBool)) Source #

Check if a PubKeyHash signs this transaction.

Since: 1.1.0

pfindTxInByTxOutRef :: forall (s :: S). Term s (PTxOutRef :--> (PBuiltinList PTxInInfo :--> PMaybe PTxInInfo)) Source #

Find the TxInInfo by a TxOutRef.

Since: 1.1.0

pscriptHashFromAddress :: forall (s :: S). Term s (PAddress :--> PMaybe PScriptHash) Source #

Get script hash from an Address. @since 1.3.0

pisScriptAddress :: forall (s :: S). Term s (PAddress :--> PBool) Source #

Return true if the given address is a script address. @since 1.3.0

pisPubKey :: forall (s :: S). Term s (PCredential :--> PBool) Source #

Return true if the given credential is a pub-key-hash. @since 1.3.0

pfindOutputsToAddress :: forall (s :: S). Term s (PBuiltinList PTxOut :--> (PAddress :--> PBuiltinList PTxOut)) Source #

Find all TxOuts sent to an Address. @since 1.3.0

pfindOwnInput :: Term s (PBuiltinList PTxInInfo :--> (PTxOutRef :--> PMaybe PTxInInfo)) Source #

Find the input being spent in the current transaction.

Takes as arguments the inputs, as well as the spending transaction referenced from a PScriptPurpose.

Note

This function is identical to the one in Api of the same name, except it is updated to work on V2 types.

Example

 ctx <- tcont $ pletFields ["txInfo", "purpose"] sc
 pmatchC (getField "purpose" ctx) >>= case
   PSpending outRef' -> do
     let outRef = pfield "_0" # outRef'
         inputs = pfield "inputs" # (getField @"txInfo" ctx)
     pure $ pfindOwnInput # inputs # outRef
   _ ->
     pure $ ptraceError "not a spending tx"
 

Since: 3.9.3

pfromPDatum :: forall (a :: S -> Type) (s :: S). PTryFrom PData a => Term s (PDatum :--> a) Source #

Convert a PDatum to the give type a.

Since: 3.0.3

presolveOutputDatum :: forall (keys :: KeyGuarantees) (s :: S). Term s (POutputDatum :--> (PMap keys PDatumHash PDatum :--> PMaybe PDatum)) Source #

Extract the datum from a POutputDatum.

Since: 3.0.3

ptryResolveOutputDatum :: forall (keys :: KeyGuarantees) (s :: S). Term s (POutputDatum :--> (PMap keys PDatumHash PDatum :--> PDatum)) Source #

As presolveOutputDatum, but error if there's no PDatum to be had.

Since: 3.6.0

pfromOutputDatum :: forall (a :: S -> Type) (s :: S). PTryFrom PData a => Term s (POutputDatum :--> (PMap 'Unsorted PDatumHash PDatum :--> PMaybe a)) Source #

Extract the datum from a POutputDatum and convert it to the given type.

Since: 3.13.0

ptryFromOutputDatum :: forall (a :: S -> Type) (s :: S). PTryFrom PData a => Term s (POutputDatum :--> (PMap 'Unsorted PDatumHash PDatum :--> a)) Source #

Extract the datum from a POutputDatum and convert it to the given type. This function will throw an error if for some reason it's not able to find the datum or convert it.

Since: 3.13.0

ptryFromDatumHash :: forall (s :: S). Term s (POutputDatum :--> PDatumHash) Source #

Extract the datum hash from a POutputDatum, throw an error if the given POuptutDatum doesn't contain a datum hash.

Since: 3.13.0

ptryFromInlineDatum :: forall (s :: S). Term s (POutputDatum :--> PDatum) Source #

Extract the inline datum from a POutputDatum, throw an error if the given POuptutDatum is not an inline datum.

Since: 3.13.0

scriptHashToTokenName :: ScriptHash -> TokenName Source #

Safely convert a PScriptHash into a PTokenName. This can be useful for tagging tokens for extra safety.

Since: 3.14.1

pscriptHashToTokenName :: forall (s :: S). Term s PScriptHash -> Term s PTokenName Source #

Safely convert a PScriptHash into a PTokenName. This can be useful for tagging tokens for extra safety.

Since: 3.14.1

ptryFromRedeemer :: forall (r :: PType) (s :: S). PTryFrom PData r => Term s (PScriptPurpose :--> (PMap 'Unsorted PScriptPurpose PRedeemer :--> PMaybe r)) Source #

Find a redeemer in the redeemer map and convert it. Typically the second argument is the redeemers field of PTxInfo.

Since: 3.14.1