Applied Emily's suggestions

This commit is contained in:
Jack Hodgkinson 2022-05-09 12:17:49 +01:00
parent a59ffb221d
commit a8bb884eab
4 changed files with 36 additions and 42 deletions

View file

@ -39,6 +39,7 @@ module Spec.Sample.Shared (
gatCs,
mockTrEffect,
trCredential,
wrongEffHash,
) where
import Agora.Effect.NoOp (noOpValidator)
@ -77,7 +78,7 @@ import Plutus.V1.Ledger.Api (
import Plutus.V1.Ledger.Contexts (
TxOut (..),
)
import Plutus.V1.Ledger.Scripts (Validator, ValidatorHash)
import Plutus.V1.Ledger.Scripts (Validator, ValidatorHash (..))
import Plutus.V1.Ledger.Value (TokenName, Value)
import Plutus.V1.Ledger.Value qualified as Value
@ -179,6 +180,14 @@ gatTn = validatorHashToTokenName $ validatorHash mockTrEffect
mockTrEffect :: Validator
mockTrEffect = mkValidator $ noOpValidator gatCs
{- | A SHA-256 hash which (in all certainty) should not match the
hash of the dummy effect script.
-}
wrongEffHash :: ValidatorHash
wrongEffHash =
ValidatorHash
"a21bc4a1d95600f9fa0a00b97ed0fa49a152a72de76253cb706f90b4b40f837b"
------------------------------------------------------------------
minAda :: Value

View file

@ -14,6 +14,7 @@ module Spec.Sample.Treasury (
treasuryRef,
gatTn,
walletIn,
trCtxGATNameNotAddress,
) where
import Plutarch.Api.V1 (validatorHash)
@ -44,6 +45,7 @@ import Spec.Sample.Shared (
signer,
treasuryOut,
withMinAda,
wrongEffHash,
)
import Spec.Util (datumPair)
@ -133,3 +135,25 @@ walletIn =
addressBs :: BuiltinByteString
(ValidatorHash addressBs) = validatorHash mockTrEffect
trCtxGATNameNotAddress :: ScriptContext
trCtxGATNameNotAddress =
let txInfo = validCtx.scriptContextTxInfo
inputs = txInfo.txInfoInputs
effectIn = inputs !! 1
invalidEff =
effectIn
{ txInInfoResolved =
effectIn.txInInfoResolved
{ txOutAddress = Address (ScriptCredential wrongEffHash) Nothing
}
}
in validCtx
{ scriptContextTxInfo =
txInfo
{ txInfoInputs =
[ head inputs
, invalidEff
]
}
}