plutus-contract-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.Contract.Request

Synopsis

PAB requests

Waiting

awaitSlot :: forall w s e. AsContractError e => Slot -> Contract w s e Slot Source #

Wait until the slot

isSlot :: forall w s e. AsContractError e => Slot -> Promise w s e Slot Source #

Wait until the slot

currentSlot :: forall w s e. AsContractError e => Contract w s e Slot Source #

Get the current slot number

waitNSlots :: forall w s e. AsContractError e => Natural -> Contract w s e Slot Source #

Wait for a number of slots to pass

awaitTime :: forall w s e. AsContractError e => POSIXTime -> Contract w s e POSIXTime Source #

Wait until the slot where the given time falls into and return latest time we know has passed.

Example: if starting time is 0 and slot length is 3s, then `awaitTime 4` waits until slot 2 and returns the value `POSIXTime 5`.

isTime :: forall w s e. AsContractError e => POSIXTime -> Promise w s e POSIXTime Source #

Wait until the slot where the given time falls into and return latest time we know has passed.

currentTime :: forall w s e. AsContractError e => Contract w s e POSIXTime Source #

Get the latest time of the current slot.

Example: if slot length is 3s and current slot is 2, then currentTime returns the value `POSIXTime 5`

waitNMilliSeconds :: forall w s e. AsContractError e => DiffMilliSeconds -> Contract w s e POSIXTime Source #

Wait for a number of milliseconds starting at the ending time of the current slot, and return the latest time we know has passed.

Example: if starting time is 0, slot length is 3000ms and current slot is 0, then `waitNMilliSeconds 0` returns the value `POSIXTime 2000` and `waitNMilliSeconds 1000` returns the value `POSIXTime 5`.

Chain index queries

utxoRefsAt :: forall w s e. AsContractError e => PageQuery TxOutRef -> Address -> Contract w s e UtxosResponse Source #

Get the unspent transaction output references at an address.

utxoRefsWithCurrency :: forall w s e. AsContractError e => PageQuery TxOutRef -> AssetClass -> Contract w s e UtxosResponse Source #

Get the unspent transaction output references with a specific currrency (AssetClass).

utxosAt :: forall w s e. AsContractError e => Address -> Contract w s e (Map TxOutRef ChainIndexTxOut) Source #

Get the unspent transaction outputs at an address.

utxosTxOutTxFromTx :: AsContractError e => ChainIndexTx -> Contract w s e [(TxOutRef, (ChainIndexTxOut, ChainIndexTx))] Source #

Get the unspent transaction outputs from a ChainIndexTx.

txoRefsAt :: forall w s e. AsContractError e => PageQuery TxOutRef -> Address -> Contract w s e TxosResponse Source #

Get the transaction outputs at an address.

getTip :: forall w s e. AsContractError e => Contract w s e Tip Source #

Waiting for changes to the UTXO set

fundsAtAddressGt :: forall w s e. AsContractError e => Address -> Value -> Contract w s e (Map TxOutRef ChainIndexTxOut) Source #

Watch an address for changes, and return the outputs at that address when the total value at the address has surpassed the given value.

fundsAtAddressGeq :: forall w s e. AsContractError e => Address -> Value -> Contract w s e (Map TxOutRef ChainIndexTxOut) Source #

Watch an address for changes, and return the outputs at that address when the total value at the address has reached or surpassed the given value.

watchAddressUntilSlot :: forall w s e. AsContractError e => Address -> Slot -> Contract w s e (Map TxOutRef ChainIndexTxOut) Source #

Wait until the target slot and get the unspent transaction outputs at an address.

watchAddressUntilTime :: forall w s e. AsContractError e => Address -> POSIXTime -> Contract w s e (Map TxOutRef ChainIndexTxOut) Source #

Wait until the target time and get the unspent transaction outputs at an address.

awaitUtxoSpent :: forall w s e. AsContractError e => TxOutRef -> Contract w s e ChainIndexTx Source #

Wait until the UTXO has been spent, returning the transaction that spends it.

utxoIsSpent :: forall w s e. AsContractError e => TxOutRef -> Promise w s e ChainIndexTx Source #

Wait until the UTXO has been spent, returning the transaction that spends it.

awaitUtxoProduced :: forall w s e. AsContractError e => Address -> Contract w s e (NonEmpty ChainIndexTx) Source #

Wait until one or more unspent outputs are produced at an address.

utxoIsProduced :: forall w s e. AsContractError e => Address -> Promise w s e (NonEmpty ChainIndexTx) Source #

Wait until one or more unspent outputs are produced at an address.

Tx and tx output confirmation

data RollbackState a Source #

The rollback state of a Cardano transaction

Constructors

Unknown

The transaction is not on the chain. That's all we can say.

Instances

Instances details
Functor RollbackState 
Instance details

Defined in Plutus.ChainIndex.Types

Methods

fmap :: (a -> b) -> RollbackState a -> RollbackState b Source #

(<$) :: a -> RollbackState b -> RollbackState a Source #

Eq a => Eq (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

Ord a => Ord (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

Show a => Show (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

Generic (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

Associated Types

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

ToJSON a => ToJSON (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

FromJSON a => FromJSON (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

Show a => Pretty (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

MeetSemiLattice a => MeetSemiLattice (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

type Rep (RollbackState a) 
Instance details

Defined in Plutus.ChainIndex.Types

type TxStatus = RollbackState () Source #

The status of a Cardano transaction

awaitTxStatusChange :: forall w s e. AsContractError e => TxId -> Contract w s e TxStatus Source #

Wait for the status of a transaction to change

awaitTxConfirmed :: forall w s e. AsContractError e => TxId -> Contract w s e () Source #

Wait until a transaction is confirmed (added to the ledger). If the transaction is never added to the ledger then awaitTxConfirmed never returns

isTxConfirmed :: forall w s e. AsContractError e => TxId -> Promise w s e () Source #

Wait until a transaction is confirmed (added to the ledger).

awaitTxOutStatusChange :: forall w s e. AsContractError e => TxOutRef -> Contract w s e TxOutStatus Source #

Wait for the status of a transaction output to change.

Contract instances

ownInstanceId :: forall w s e. AsContractError e => Contract w s e ContractInstanceId Source #

Get the ContractInstanceId of this instance.

Exposing endpoints

newtype EndpointDescription Source #

Instances

Instances details
Eq EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Ord EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Show EndpointDescription Source # 
Instance details

Defined in Wallet.Types

IsString EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Generic EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Associated Types

type Rep EndpointDescription :: Type -> Type Source #

ToJSON EndpointDescription Source # 
Instance details

Defined in Wallet.Types

FromJSON EndpointDescription Source # 
Instance details

Defined in Wallet.Types

ToSchema EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Pretty EndpointDescription Source # 
Instance details

Defined in Wallet.Types

Lift EndpointDescription Source # 
Instance details

Defined in Wallet.Types

type Rep EndpointDescription Source # 
Instance details

Defined in Wallet.Types

type Rep EndpointDescription = D1 ('MetaData "EndpointDescription" "Wallet.Types" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'True) (C1 ('MetaCons "EndpointDescription" 'PrefixI 'True) (S1 ('MetaSel ('Just "getEndpointDescription") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String)))

endpoint :: forall l a w s e b. (HasEndpoint l a s, AsContractError e, FromJSON a) => (a -> Contract w s e b) -> Promise w s e b Source #

Expose an endpoint, return the data that was entered

handleEndpoint :: forall l a w s e1 e2 b. (HasEndpoint l a s, AsContractError e1, FromJSON a) => (Either e1 a -> Contract w s e2 b) -> Promise w s e2 b Source #

endpointWithMeta :: forall l a w s e meta b. (HasEndpoint l a s, AsContractError e, ToJSON meta, FromJSON a) => meta -> (a -> Contract w s e b) -> Promise w s e b Source #

Expose an endpoint with some metadata. Return the data that was entered.

endpointReq :: forall l a s. HasEndpoint l a s => ActiveEndpoint Source #

endpointResp :: forall l a s. (HasEndpoint l a s, ToJSON a) => a -> PABResp Source #

Public key hashes

ownPaymentPubKeyHash :: forall w s e. AsContractError e => Contract w s e PaymentPubKeyHash Source #

Get the hash of a public key belonging to the wallet that runs this contract. * Any funds paid to this public key hash will be treated as the wallet's own funds * The wallet is able to sign transactions with the private key of this public key, for example, if the public key is added to the requiredSignatures field of Tx. * There is a 1-n relationship between wallets and public keys (although in the mockchain n=1)

Submitting transactions

submitUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e CardanoTx Source #

Send an unbalanced transaction to be balanced and signed. Returns the ID of the final transaction when the transaction was submitted. Throws an error if balancing or signing failed.

submitBalancedTx :: forall w s e. AsContractError e => CardanoTx -> Contract w s e CardanoTx Source #

Send an balanced transaction to be signed. Returns the ID of the final transaction when the transaction was submitted. Throws an error if signing failed.

balanceTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e CardanoTx Source #

Send an unbalanced transaction to be balanced. Returns the balanced transaction. Throws an error if balancing failed.

submitTx :: forall w s e. AsContractError e => TxConstraints Void Void -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints, then submit it to the network. The constraints do not refer to any typed script inputs or outputs.

submitTxConstraints :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => TypedValidator a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints, then submit it to the network. Using the current outputs at the contract address and the contract's own public key to solve the constraints.

submitTxConstraintsSpending :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => TypedValidator a -> Map TxOutRef ChainIndexTxOut -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints using the UTXO map to resolve any input constraints (see InputConstraint)

submitTxConstraintsWith :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e CardanoTx Source #

Build a transaction that satisfies the constraints, then submit it to the network. Using the given constraints.

submitTxConfirmed :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e () Source #

A version of submitTx that waits until the transaction has been confirmed on the ledger before returning.

mkTxConstraints :: forall a w s e. (ToData (RedeemerType a), FromData (DatumType a), ToData (DatumType a), AsContractError e) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s e UnbalancedTx Source #

Build a transaction that satisfies the constraints

yieldUnbalancedTx :: forall w s e. AsContractError e => UnbalancedTx -> Contract w s e () Source #

Take an UnbalancedTx then balance, sign and submit it to the blockchain without returning any results.

Etc.

type ContractRow s = (AllUniqueLabels (Input s), AllUniqueLabels (Output s)) Source #

Constraints on the contract schema, ensuring that the labels of the schema are unique.

pabReq Source #

Arguments

:: forall w s e a. AsContractError e 
=> PABReq

The request to send

-> Prism' PABResp a

Prism for the response

-> Contract w s e a 

mkTxContract :: forall w s a. (FromData (DatumType a), ToData (DatumType a), ToData (RedeemerType a)) => ScriptLookups a -> TxConstraints (RedeemerType a) (DatumType a) -> Contract w s MkTxError UnbalancedTx Source #

A variant of mkTx that runs in the Contract monad, throwing errors and logging its inputs and outputs.

data MkTxLog Source #

Arguments and result of a call to mkTx

Instances

Instances details
Show MkTxLog Source # 
Instance details

Defined in Plutus.Contract.Request

Generic MkTxLog Source # 
Instance details

Defined in Plutus.Contract.Request

Associated Types

type Rep MkTxLog :: Type -> Type Source #

ToJSON MkTxLog Source # 
Instance details

Defined in Plutus.Contract.Request

FromJSON MkTxLog Source # 
Instance details

Defined in Plutus.Contract.Request

type Rep MkTxLog Source # 
Instance details

Defined in Plutus.Contract.Request

type Rep MkTxLog = D1 ('MetaData "MkTxLog" "Plutus.Contract.Request" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'False) (C1 ('MetaCons "MkTxLog" 'PrefixI 'True) (S1 ('MetaSel ('Just "mkTxLogLookups") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ScriptLookups Any)) :*: (S1 ('MetaSel ('Just "mkTxLogTxConstraints") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxConstraints BuiltinData BuiltinData)) :*: S1 ('MetaSel ('Just "mkTxLogResult") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Either MkTxError UnbalancedTx)))))