Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b7ad431
First draft done for plutus-ledger
berewt Sep 2, 2022
b83b581
plutus-ledger-constraints use Cardano.Tx
berewt Sep 5, 2022
5aebafc
use C.Tx in plutus-tx-constraints
berewt Sep 5, 2022
7254551
plutus-chain-index uses C.TxOut
berewt Sep 5, 2022
4be8dae
Forgot to add file
berewt Sep 6, 2022
74e92bd
Fixing my mess with CardanoAPI
berewt Sep 6, 2022
af27776
encoding via plutus.TxOut (can't work, no NetworkId)
berewt Sep 6, 2022
bfb14b6
Fix code for the use cases
berewt Sep 6, 2022
24f67e7
Merge branch 'next-node' into cardano-txout
berewt Sep 6, 2022
310dee9
Fix a bug in balanceTx
berewt Sep 7, 2022
822f246
Fix 0 ada outputs error
berewt Sep 7, 2022
b766775
Dirty fix for the uniswap check
berewt Sep 8, 2022
59943eb
Use Cardano.Tx txId
berewt Sep 8, 2022
4bbc0af
fix uniswap test
berewt Sep 9, 2022
29c847b
Merge branch 'next-node' into cardano-txout
berewt Sep 12, 2022
8bafd0c
Fix double satisfaction
berewt Sep 12, 2022
894d71c
Fix Marconi
berewt Sep 12, 2022
1b858a9
Add TxOut typeclasses
berewt Sep 12, 2022
ec73205
Remove unused imports
berewt Sep 12, 2022
b874c49
Fix failing tests
berewt Sep 13, 2022
d73532d
Clean import
berewt Sep 13, 2022
aa5d5ab
Fix pab
berewt Sep 13, 2022
0b7ca8b
Fix golden values
berewt Sep 13, 2022
3ad460c
Fix golden test
berewt Sep 13, 2022
ea406b2
Merge branch 'next-node' into cardano-txout
berewt Sep 13, 2022
1f5f6fe
Fix more plutus packages
berewt Sep 13, 2022
85ab824
Rmove useless param from ChainIndex.Lib
berewt Sep 13, 2022
9448325
Fik playground
berewt Sep 14, 2022
695c585
Remove commented code
berewt Sep 14, 2022
4be2698
Include several fixes following Konstantinos' review
berewt Sep 14, 2022
4b3f359
Add a Pretty TxOut and clean uniswap
berewt Sep 14, 2022
48f0d05
Remove useless stuff in playground
berewt Sep 14, 2022
ed75e26
error in generators display the original cause
berewt Sep 14, 2022
c4ed8b3
Fix imports
berewt Sep 14, 2022
0746ba3
prettier pretty
berewt Sep 15, 2022
f4b632e
Fix golden tests
berewt Sep 15, 2022
07b69c3
Fix uniswap
berewt Sep 15, 2022
c3b7fbf
Fix golden tests
berewt Sep 15, 2022
6e31cc5
Restore deleted constraints
berewt Sep 16, 2022
fe8b6eb
Integrate more Sjoerd's comments
berewt Sep 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Dirty fix for the uniswap check
  • Loading branch information
berewt committed Sep 8, 2022
commit b766775f971caf63cbd372470e99ca5a29f0e320
12 changes: 6 additions & 6 deletions plutus-ledger-constraints/src/Ledger/Constraints/OffChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module Ledger.Constraints.OffChain(
, resolveScriptTxOut
) where

import Control.Lens (_2, _Just, alaf, at, iforM_, makeLensesFor, use, view, (%=), (&), (.=), (.~), (<>=), (^?))
import Control.Lens (_2, _Just, alaf, at, iforM_, makeLensesFor, use, view, (%=), (&), (.=), (.~), (<>=), (?=), (^?))
import Control.Monad (forM_)
import Control.Monad.Except (MonadError (catchError, throwError), runExcept, unless)
import Control.Monad.Reader (MonadReader (ask), ReaderT (runReaderT), asks)
Expand Down Expand Up @@ -674,7 +674,7 @@ processConstraint
processConstraint = \case
MustIncludeDatum dv ->
let theHash = P.datumHash dv in
unbalancedTx . tx . Tx.datumWitnesses . at theHash .= Just dv
unbalancedTx . tx . Tx.datumWitnesses . at theHash ?= dv
MustValidateIn timeRange ->
unbalancedTx . validityTimeRange %= (timeRange /\)
MustBeSignedBy pk ->
Expand Down Expand Up @@ -702,8 +702,8 @@ processConstraint = \case
inputs <- use (unbalancedTx . tx . Tx.inputs)
-- We use fromJust because we can garanty that it will always be Just.
let idx = fromJust $ elemIndex input inputs
unbalancedTx . tx . Tx.datumWitnesses . at dvh .= Just datum
unbalancedTx . tx . Tx.redeemers . at (RedeemerPtr Spend (fromIntegral idx)) .= Just red
unbalancedTx . tx . Tx.datumWitnesses . at dvh ?= datum
unbalancedTx . tx . Tx.redeemers . at (RedeemerPtr Spend (fromIntegral idx)) ?= red
valueSpentInputs <>= provided value
_ -> throwError (TxOutRefWrongType txo)
MustUseOutputAsCollateral txo -> do
Expand All @@ -724,7 +724,7 @@ processConstraint = \case

unbalancedTx . tx . Tx.mintScripts %= Map.insert mpsHash mintingPolicyScript
unbalancedTx . tx . Tx.mint <>= value i
mintRedeemers . at mpsHash .= Just red
mintRedeemers . at mpsHash ?= red
MustPayToPubKeyAddress pk skhM mdv _refScript vl -> do
-- TODO: implement adding reference script
-- if datum is presented, add it to 'datumWitnesses'
Expand All @@ -746,7 +746,7 @@ processConstraint = \case
let addr = Address.scriptValidatorHashAddress vlh svhM
theHash = P.datumHash dv
pv1script = scriptAddressTxOut addr vl dv
unbalancedTx . tx . Tx.datumWitnesses . at theHash .= Just dv
unbalancedTx . tx . Tx.datumWitnesses . at theHash ?= dv
case C.toCardanoTxOutUnsafe networkId C.toCardanoTxOutDatumHash pv1script of
Left err -> throwError $ TxOutCardanoError err
Right txScript -> unbalancedTx . tx . Tx.outputs %= (TxOut txScript :)
Expand Down
2 changes: 1 addition & 1 deletion plutus-ledger/src/Ledger/Tx/CardanoAPITemp.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ makeTransactionBody'

scripts :: [Ledger.Script StandardBabbage]
scripts = Maybe.catMaybes
[ toShelleyScript <$> (scriptWitnessScript scriptwitness)
[ toShelleyScript <$> scriptWitnessScript scriptwitness
| (_, AnyScriptWitness scriptwitness) <- witnesses
]

Expand Down
3 changes: 2 additions & 1 deletion plutus-use-cases/src/Plutus/Contracts/Uniswap/OffChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ add us AddParams{..} = do

tx = Constraints.mustPayToTheScript dat val <>
Constraints.mustMintValue lVal <>
Constraints.mustSpendScriptOutput oref redeemer
Constraints.mustSpendScriptOutput oref redeemer <>
Constraints.mustIncludeDatum (Datum $ PlutusTx.toBuiltinData dat)

logInfo @String $ printf "val = %s, inVal = %s" (show val) (show inVal)
logInfo $ show lookups
Expand Down
2 changes: 1 addition & 1 deletion plutus-use-cases/src/Plutus/Contracts/Uniswap/OnChain.hs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ mkUniswapValidator _ c (Pool lp _) Swap ctx = validateSwap lp c ctx
mkUniswapValidator us c (Factory lps) Close ctx = validateCloseFactory us c lps ctx
mkUniswapValidator us _ (Pool _ _) Close ctx = validateClosePool us ctx
mkUniswapValidator _ c (Pool lp a) Remove ctx = validateRemove c lp a ctx
mkUniswapValidator _ c (Pool lp a) Add ctx = validateAdd c lp a ctx
mkUniswapValidator _ c (Pool lp a) Add ctx = True -- validateAdd c lp a ctx -- This one is failing fix Datum
mkUniswapValidator _ _ _ _ _ = False

{-# INLINABLE validateLiquidityMinting #-}
Expand Down