Added review changes

This commit is contained in:
Jack Hodgkinson 2022-05-06 10:36:21 +01:00
parent 6aa4ed732a
commit 7572bb4da2
5 changed files with 85 additions and 115 deletions

View file

@ -9,6 +9,8 @@ module Spec.Sample.Shared (
-- * Misc
signer,
signer2,
minAda,
withMinAda,
-- * Components
@ -30,8 +32,16 @@ module Spec.Sample.Shared (
proposalPolicySymbol,
proposalValidatorHash,
proposalValidatorAddress,
-- ** Treasury
treasuryOut,
gatTn,
gatCs,
mockTrEffect,
trCredential,
) where
import Agora.Effect.NoOp (noOpValidator)
import Agora.Governor (
Governor (Governor),
governorPolicy,
@ -47,6 +57,8 @@ import Agora.Proposal.Scripts (
)
import Agora.Stake (Stake (..))
import Agora.Stake.Scripts (stakePolicy, stakeValidator)
import Agora.Treasury (treasuryValidator)
import Agora.Utils (validatorHashToTokenName)
import Plutarch.Api.V1 (
mintingPolicySymbol,
mkMintingPolicy,
@ -62,7 +74,11 @@ import Plutus.V1.Ledger.Api (
MintingPolicy (..),
PubKeyHash,
)
import Plutus.V1.Ledger.Contexts (
TxOut (..),
)
import Plutus.V1.Ledger.Scripts (Validator, ValidatorHash)
import Plutus.V1.Ledger.Value (TokenName, Value)
import Plutus.V1.Ledger.Value qualified as Value
--------------------------------------------------------------------------------
@ -131,3 +147,42 @@ defaultProposalThresholds =
, create = Tagged 1
, startVoting = Tagged 10
}
------------------------------------------------------------------
treasuryOut :: TxOut
treasuryOut =
TxOut
{ txOutAddress = Address trCredential Nothing
, txOutValue = minAda
, txOutDatumHash = Nothing
}
{- | Arbitrary 'CurrencySymbol', representing the 'CurrencySymbol'
of a valid governance authority token (GAT).
-}
gatCs :: CurrencySymbol
gatCs = "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"
trValidator :: Validator
trValidator = mkValidator (treasuryValidator gatCs)
-- | `ScriptCredential` used for the dummy treasury validator.
trCredential :: Credential
trCredential = ScriptCredential $ validatorHash trValidator
-- | `TokenName` for GAT generated from address of `mockTrEffect`.
gatTn :: TokenName
gatTn = validatorHashToTokenName $ validatorHash mockTrEffect
-- | Mock treasury effect script, used for testing.
mockTrEffect :: Validator
mockTrEffect = mkValidator $ noOpValidator gatCs
------------------------------------------------------------------
minAda :: Value
minAda = Value.singleton "" "" 10_000_000
withMinAda :: Value -> Value
withMinAda v = v <> minAda