Skip to content

Commit

Permalink
fix: fix plutus script envelopes and some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
errfrom committed Sep 17, 2024
1 parent 3825bf5 commit 0495ad1
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 59 deletions.
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@
shellHook = ''
mkdir -p scripts
cp -rf ${hydra-auction-onchain}/compiled/*.plutus scripts
for script in scripts/*.plutus; do
jq '. | {cborHex: .cborHex, description: .description, type: "PlutusScriptV2"}' "$script" \
> "$script.tmp"
mv -f "$script.tmp" "$script"
done
'';
packages = with pkgs; [
fd
Expand Down
16 changes: 4 additions & 12 deletions scripts/auction_escrow_validator.plutus

Large diffs are not rendered by default.

11 changes: 4 additions & 7 deletions scripts/auction_metadata_validator.plutus
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"cborHex": "5902945902910100003232323232323232323232323232322223232533300e3370e66601200200401090010991929998082998041800a4410741554354494f4e001533008300100a130014890c5354414e44494e475f42494400149854cc0452412a5472616e73616374696f6e206d757374206275726e2061756374696f6e20746f6b656e2062756e646c65001623370e6660160040080026466e05200000148008c8dd59809991809980998099809800980a000980918098018a99807a4933546172676574207574786f206d75737420636f6e7461696e206f6e652061756374696f6e206d6574616461746120746f6b656e0016323756602460226026002646024602260260026464646666601c444a666024002244a0022a6660266004602e002264446004006602e002266006004602c00246466ebcdd3980b8021ba730170013015301600100120011533011490129707472794f776e496e7075743a20436f756c64206e6f742066696e64206d79206f776e20696e7075740016375860266028004646464a66602266e1d2002002130150011533012491525061747465726e206d61746368206661696c75726520696e2027646f2720626c6f636b206174207372632f506c7574617263682f45787472612f536372697074436f6e746578742e68733a37383a352d31350016301600230110013754602460226026006602260240046eb8c040c04400c88ccc02800800400c5282451041554354494f4e5f4d45544144415441002223333004002480008cccc014009200075a6eac00400c8c008dd480091111980291299980400088028a99980499baf300b300d00100613004300f300d00113002300c0010012323002233002002001230022330020020015573eae695ce2ab9d5744ae848c008dd5000aab9e1",
"description": "Auction metadata validator",
"params": [],
"rawHex": "5902910100003232323232323232323232323232322223232533300e3370e66601200200401090010991929998082998041800a4410741554354494f4e001533008300100a130014890c5354414e44494e475f42494400149854cc0452412a5472616e73616374696f6e206d757374206275726e2061756374696f6e20746f6b656e2062756e646c65001623370e6660160040080026466e05200000148008c8dd59809991809980998099809800980a000980918098018a99807a4933546172676574207574786f206d75737420636f6e7461696e206f6e652061756374696f6e206d6574616461746120746f6b656e0016323756602460226026002646024602260260026464646666601c444a666024002244a0022a6660266004602e002264446004006602e002266006004602c00246466ebcdd3980b8021ba730170013015301600100120011533011490129707472794f776e496e7075743a20436f756c64206e6f742066696e64206d79206f776e20696e7075740016375860266028004646464a66602266e1d2002002130150011533012491525061747465726e206d61746368206661696c75726520696e2027646f2720626c6f636b206174207372632f506c7574617263682f45787472612f536372697074436f6e746578742e68733a37383a352d31350016301600230110013754602460226026006602260240046eb8c040c04400c88ccc02800800400c5282451041554354494f4e5f4d45544144415441002223333004002480008cccc014009200075a6eac00400c8c008dd480091111980291299980400088028a99980499baf300b300d00100613004300f300d00113002300c0010012323002233002002001230022330020020015573eae695ce2ab9d5744ae848c008dd5000aab9e1",
"role": "ValidatorRole",
"version": "ScriptV2"
}
"cborHex": "5902945902910100003232323232323232323232323232322223232533300e3370e66601200200401090010991929998082998041800a4410741554354494f4e001533008300100a130014890c5354414e44494e475f42494400149854cc0452412a5472616e73616374696f6e206d757374206275726e2061756374696f6e20746f6b656e2062756e646c65001623370e6660160040080026466e05200000148008c8dd59809991809980998099809800980a000980918098018a99807a4933546172676574207574786f206d75737420636f6e7461696e206f6e652061756374696f6e206d6574616461746120746f6b656e0016323756602460226026002646024602260260026464646666601c444a666024002244a0022a6660266004602e002264446004006602e002266006004602c00246466ebcdd3980b8021ba730170013015301600100120011533011490129707472794f776e496e7075743a20436f756c64206e6f742066696e64206d79206f776e20696e7075740016375860266028004646464a66602266e1d2002002130150011533012491525061747465726e206d61746368206661696c75726520696e2027646f2720626c6f636b206174207372632f506c7574617263682f45787472612f536372697074436f6e746578742e68733a37383a352d31350016301600230110013754602460226026006602260240046eb8c040c04400c88ccc02800800400c5282451041554354494f4e5f4d45544144415441002223333004002480008cccc014009200075a6eac00400c8c008dd480091111980291299980400088028a99980499baf300b300d00100613004300f300d00113002300c0010012323002233002002001230022330020020015573eae695ce2ab9d5744ae848c008dd5000aab9e1",
"description": "Auction metadata validator",
"type": "PlutusScriptV2"
}
14 changes: 4 additions & 10 deletions scripts/auction_minting_policy.plutus

Large diffs are not rendered by default.

16 changes: 4 additions & 12 deletions scripts/bidder_deposit_validator.plutus

Large diffs are not rendered by default.

14 changes: 4 additions & 10 deletions scripts/standing_bid_validator.plutus

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/Contract/Types/Plutus/AuctionTerms.purs
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ validateAuctionTerms :: AuctionTerms -> V (Array AuctionTermsValidationError) Un
validateAuctionTerms auctionTerms@(AuctionTerms rec) = fold
[ (Plutus.Value.valueToCoin rec.auctionLot == mempty)
`errV` AuctionLotNonZeroAdaError
, (rec.auctionLot `Plutus.Value.gt` mempty) -- FIXME

, (rec.auctionLot `Plutus.Value.gt` mempty)
`errV` NonPositiveAuctionLotValueError
, (isJust sellerPkh)
`errV` SellerAddressLacksPubKeyCredentialError
Expand Down
24 changes: 18 additions & 6 deletions test/Contract/AnnounceAuction.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ module Test.Contract.AnnounceAuction

import Contract.Prelude

import Cardano.Plutus.Types.Value (fromCardano) as Plutus.Value
import Cardano.Plutus.Types.CurrencySymbol (fromScriptHash)
import Cardano.Plutus.Types.Value (Value) as Plutus
import Cardano.Plutus.Types.Value (singleton) as Plutus.Value
import Cardano.Types (Mint, ScriptHash, Value)
import Cardano.Types.BigNum (one) as BigNum
import Cardano.Types.Int (one) as Cardano.Int
import Cardano.Types.Int (Int) as Cardano
import Cardano.Types.Int (one, toBigInt) as Cardano.Int
import Cardano.Types.Mint (singleton) as Mint
import Cardano.Types.PlutusScript (hash) as PlutusScript
import Cardano.Types.Value (singleton) as Value
Expand Down Expand Up @@ -56,7 +59,7 @@ announceAuction = announceAuctionFix identity

announceAuctionFix :: AuctionTermsMutator -> Contract AnnounceAuctionContractResult
announceAuctionFix fixAuctionTerms = do
auctionLotValue <- Plutus.Value.fromCardano <$> mintAuctionLot
auctionLotValue <- mintAuctionLot
biddingStart <-
currentTime <#>
add (mkPosixTimeUnsafe $ Seconds 5.0)
Expand All @@ -71,15 +74,24 @@ announceAuctionFix fixAuctionTerms = do
}
liftedE $ runExceptT $ mkAnnounceAuctionContractWithErrors params

mintAuctionLot :: Contract Value
mintAuctionLot :: Contract Plutus.Value
mintAuctionLot = do
alwaysMintsPolicy <- mkAlwaysMintsPolicy
let
cs :: ScriptHash
cs = PlutusScript.hash alwaysMintsPolicy

mintQuantity :: Cardano.Int
mintQuantity = Cardano.Int.one

auctionLotValue :: Mint
auctionLotValue = Mint.singleton cs auctionLotTokenNameFixture Cardano.Int.one
auctionLotValue = Mint.singleton cs auctionLotTokenNameFixture mintQuantity

auctionLotValuePlutus :: Plutus.Value
auctionLotValuePlutus = Plutus.Value.singleton
(fromScriptHash cs)
(wrap auctionLotTokenNameFixture)
(Cardano.Int.toBigInt mintQuantity)

constraints :: TxConstraints
constraints = Constraints.mustMintValue auctionLotValue
Expand All @@ -92,4 +104,4 @@ mintAuctionLot = do
, constraints = constraints
}
awaitTxConfirmed txHash
pure $ Value.singleton cs auctionLotTokenNameFixture BigNum.one
pure auctionLotValuePlutus

0 comments on commit 0495ad1

Please sign in to comment.