View on GitHub
File Changes
import           Test.Tasty

                      
import           Language.Plutus.Contract              as Con
-
import           Language.Plutus.Contract.Tx           as Tx
import           Language.Plutus.Contract.Test
import           Language.Plutus.Contract.Util         (loopM)
import           Language.PlutusTx.Lattice
import qualified Language.PlutusTx                     as PlutusTx
import           Ledger                                (Address)
+
import qualified Ledger.Constraints                    as Constraints
import qualified Ledger                                as Ledger
import qualified Ledger.Ada                            as Ada
+
import qualified Ledger.Crypto                         as Crypto
import           Prelude                               hiding (not)
import qualified Wallet.Emulator                       as EM

                      
            (waitingForSlot w1 20 /\ interestingAddress w1 someAddress)
            (handleBlockchainEvents w1 >> addBlocks 1)

                      
-
        , let smallTx = produceOutput (Tx.pubKeyTxOut (Ada.lovelaceValueOf 10) (walletPubKey (Wallet 2)))
+
        , let smallTx = Constraints.mustPayToPubKey (Crypto.pubKeyHash $ walletPubKey (Wallet 2)) (Ada.lovelaceValueOf 10)
          in cp "handle several blockchain events"
                (submitTx smallTx >> submitTx smallTx)
                (assertDone w1 (const True) "all blockchain events should be processed"
            (handleBlockchainEvents w2)

                      
        , cp "await tx confirmed"
-
            (let t = payToPubKey (Ada.lovelaceValueOf 10) (walletPubKey w2) 
+
            (let t = Constraints.mustPayToPubKey (Crypto.pubKeyHash $ walletPubKey w2)  (Ada.lovelaceValueOf 10) 
             in submitTx t >>= awaitTxConfirmed)
            (assertDone w1 (const True) "should be done"
            /\ walletFundsChange w2 (Ada.lovelaceValueOf 10))
    , submitTxConstraints
    , submitTxConstraintsUtxo
    , submitTxConstraintsWith
+
    , submitUnbalancedTx
    -- ** Creating transactions
    , module Tx
    -- ** Tx confirmation
import           Data.Row
import           Data.Text.Prettyprint.Doc
import           Data.Text.Prettyprint.Doc.Extras
+
import           Data.Void                                         (Void)
import           GHC.Generics                                      (Generic)

                      
import           Language.Plutus.Contract.Effects.AwaitTxConfirmed (HasTxConfirmation, awaitTxConfirmed)
-- | 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.
-
submitTx :: forall s e. (HasWriteTx s, Req.AsContractError e) => UnbalancedTx -> Contract s e TxId
+
submitUnbalancedTx :: forall s e. (HasWriteTx s, Req.AsContractError e) => UnbalancedTx -> Contract s e TxId
-- See Note [Injecting errors into the user's error type]
-
submitTx t =
+
submitUnbalancedTx t =
  let req = request @TxSymbol @_ @_ @s (PendingTransactions [t]) in
  req >>= either (throwing Req._WalletError) pure . view writeTxResponse

                      
+
-- | 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.
+
submitTx :: forall s e.
+
  ( HasWriteTx s
+
  , Req.AsContractError e
+
  )
+
  => TxConstraints Void Void
+
  -> Contract s e TxId
+
submitTx = submitTxConstraintsWith @Void mempty
+

                      
-- | 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.
  => ScriptInstance a
  -> TxConstraints (RedeemerType a) (DataType a)
  -> Contract s e TxId
-
submitTxConstraints inst constraints = do
-
  submitTxConstraintsWith (Constraints.scriptLookups inst) constraints
+
submitTxConstraints inst = submitTxConstraintsWith (Constraints.scriptLookups inst)

                      
submitTxConstraintsUtxo
  :: forall a s e.
  -> Contract s e TxId
submitTxConstraintsWith sl constraints = do
  tx <- either (throwing _ConstraintResolutionError) pure (Constraints.mkTx sl constraints)
-
  submitTx tx
+
  submitUnbalancedTx tx

                      
-- | A version of 'submitTx' that waits until the transaction has been
--   confirmed on the ledger before returning.
  )
  => UnbalancedTx
  -> Contract s e ()
-
submitTxConfirmed t = submitTx t >>= awaitTxConfirmed
+
submitTxConfirmed t = submitUnbalancedTx t >>= awaitTxConfirmed

                      
event
  :: forall s. (HasType TxSymbol WriteTxResponse (Input s), AllUniqueLabels (Input s))