Skip to content

Commit

Permalink
submitTx
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed Feb 14, 2020
1 parent dfd92f0 commit c7aff1f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 1 addition & 2 deletions plutus-playground-server/usecases/Vesting.hs
Expand Up @@ -167,8 +167,7 @@ vestFundsC
-> Contract s T.Text ()
vestFundsC vesting = do
let tx = payIntoContract (totalAmount vesting)
lookups = scriptLookups (scriptInstance vesting)
void $ submitTxConstraintsWith lookups tx
void $ submitTxConstraints (scriptInstance vesting) lookups tx

data Liveness = Alive | Dead

Expand Down
Expand Up @@ -51,7 +51,6 @@ import Ledger.Validation (PendingTx, PendingTx' (..))
import Ledger.Value (Value, lt, geq)
import Ledger.Constraints (TxConstraints)
import qualified Ledger.Constraints as Constraints
import Ledger.Constraints.OffChain (ScriptLookups(..), scriptLookups)

import qualified Language.Plutus.Contract.Typed.Tx as Typed
import Language.Plutus.Contract
Expand Down Expand Up @@ -247,7 +246,7 @@ pay inst escrow vl = do
pk <- ownPubKey
let tx = Constraints.mustPayToScript (Ledger.pubKeyHash pk) vl
<> Constraints.mustValidateIn (Ledger.interval 1 (escrowDeadline escrow))
submitTxConstraintsWith (scriptLookups inst) tx
submitTxConstraints inst tx

newtype RedeemSuccess = RedeemSuccess TxId
deriving (Haskell.Eq, Show)
Expand Down Expand Up @@ -292,9 +291,7 @@ redeem inst escrow = do
then throwing _RedeemFailed DeadlinePassed
else if (foldMap (Tx.txOutValue . Tx.txOutTxOut) unspentOutputs) `lt` targetTotal escrow
then throwing _RedeemFailed NotEnoughFundsAtAddress
else
let lookups = (scriptLookups inst) { slTxOutputs = unspentOutputs } in
RedeemSuccess <$> submitTxConstraintsWith lookups tx
else RedeemSuccess <$> submitTxConstraintsUtxo inst unspentOutputs tx

newtype RefundSuccess = RefundSuccess TxId
deriving (Haskell.Eq, Show)
Expand Down Expand Up @@ -330,9 +327,7 @@ refund inst escrow = do
tx' = Typed.collectFromScriptFilter flt unspentOutputs Refund
<> Constraints.mustValidateIn (from (succ $ escrowDeadline escrow))
if Constraints.modifiesUtxoSet tx'
then
let lookups = (scriptLookups inst) { slTxOutputs = unspentOutputs } in
RefundSuccess <$> submitTxConstraintsWith lookups tx'
then RefundSuccess <$> submitTxConstraintsUtxo inst unspentOutputs tx'
else throwing _RefundFailed ()

-- | Pay some money into the escrow contract. Then release all funds to their
Expand Down

0 comments on commit c7aff1f

Please sign in to comment.