Use liqwid-script-export
commit ec70bfd539fe2e27fd48f5f76395400287ac72d7
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Tue Oct 18 18:58:59 2022 -0500
use LSE
commit 25fff9b3ad1f2dde4cd7cf36977530b06a87d23c
Merge: 01cd3aa 1821dd6
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Tue Oct 18 18:17:45 2022 -0500
Merge branch 'staging' into seungheonoh/ply
commit 01cd3aa7a235e6fe6658246ca1026fa26dc71a83
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 12:02:03 2022 +0800
update benchmark
commit a8513244892ce33cfdc9edf8cd501c4985ae8008
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 11:59:22 2022 +0800
fix tests
commit 20ca40823485c2e2f78253643cf4453ac7b7ddd5
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 11:57:37 2022 +0800
better import
commit a19fe49424210891bd03db71e4083fc1e0edfd98
Author: Hongrui Fang <chfanghr@gmail.com>
Date: Tue Oct 11 11:08:20 2022 +0800
update flake inputs
commit c93b21f1f9441e5c6f54525bf7c6a54757ec36cc
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 12:54:12 2022 -0500
tried to make tests pass
commit 1046ae1237299a33c58b48661bdb6d325a22147e
Merge: 2bf4e36 363bd83
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 12:18:48 2022 -0500
Merge branch 'staging' into seungheonoh/ply
commit 2bf4e3627c1b229f58078695082da85c80efd560
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 10:48:36 2022 -0500
remove junkpile
commit a1dbc9ad9e531fe0d0a0480c4aef9cf9ffa90f1d
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Mon Oct 10 10:47:25 2022 -0500
versions
commit 4542a06ac733858297d3a48c53368fad19dedc43
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Thu Oct 6 22:57:48 2022 -0500
script exporting interface
commit 6bd8c1a1d57e4bf9dc25c3068a9c8eae6bf6a19d
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Thu Oct 6 22:58:41 2022 -0500
fixed tests
commit d3ce2cf95633d336f3e621833677bd5bf10ee2c8
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sun Oct 2 00:55:18 2022 -0500
fixed tests
commit 1ae64c9f692652b77b0506013853b2ba44267c65
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sat Oct 1 13:28:20 2022 -0500
linker
commit db88cb75c7b74843141ad8ab4e6522b66d0dcfbc
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sat Oct 1 01:03:50 2022 -0500
exporting scripts
commit 6389fce28e885a8a7f8669629c266f59c0edb51f
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Sat Oct 1 00:51:49 2022 -0500
made scripts parameterized on the script level
commit aea1e518a8890550bdebd0e5251da11d915c53a9
Author: Seungheon Oh <seungheon.ooh@gmail.com>
Date: Wed Sep 28 19:53:29 2022 -0500
Use `TypedScriptEnvelope` for `Agora.Bootstrap`
This commit is contained in:
parent
1821dd6a88
commit
d2018afd4d
38 changed files with 8614 additions and 2330 deletions
|
|
@ -13,14 +13,14 @@ module Sample.Effect.GovernorMutation (
|
|||
|
||||
import Agora.Effect.GovernorMutation (
|
||||
MutateGovernorDatum (..),
|
||||
mutateGovernorValidator,
|
||||
)
|
||||
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (MutateGovernor))
|
||||
import Agora.Proposal (ProposalId (..), ProposalThresholds (..))
|
||||
import Agora.Utils (validatorHashToTokenName)
|
||||
import Data.Default.Class (Default (def))
|
||||
import Data.Map
|
||||
import Data.Tagged (Tagged (..))
|
||||
import Plutarch.Api.V2 (mkValidator, validatorHash)
|
||||
import Plutarch.Api.V2 (validatorHash)
|
||||
import PlutusLedgerApi.V1 qualified as Interval (always)
|
||||
import PlutusLedgerApi.V1.Address (scriptHashAddress)
|
||||
import PlutusLedgerApi.V1.Value (AssetClass, assetClass)
|
||||
|
|
@ -38,14 +38,13 @@ import PlutusLedgerApi.V2 (
|
|||
TxInfo (..),
|
||||
TxOut (..),
|
||||
TxOutRef (TxOutRef),
|
||||
Validator,
|
||||
Validator (Validator),
|
||||
ValidatorHash (..),
|
||||
)
|
||||
import PlutusTx.AssocMap qualified as AssocMap
|
||||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
authorityTokenSymbol,
|
||||
deterministicTracingConfing,
|
||||
govAssetClass,
|
||||
govValidatorAddress,
|
||||
minAda,
|
||||
|
|
@ -56,7 +55,7 @@ import Test.Util (datumPair, toDatumHash)
|
|||
|
||||
-- | The effect validator instance.
|
||||
effectValidator :: Validator
|
||||
effectValidator = mkValidator deterministicTracingConfing $ mutateGovernorValidator agoraScripts
|
||||
effectValidator = Validator $ agoraScripts ! "agora:mutateGovernorValidator"
|
||||
|
||||
-- | The hash of the validator instance.
|
||||
effectValidatorHash :: ValidatorHash
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ Description: Sample based testing for Treasury Withdrawal Effect
|
|||
This module provides samples for Treasury Withdrawal Effect tests.
|
||||
-}
|
||||
module Sample.Effect.TreasuryWithdrawal (
|
||||
validator,
|
||||
inputTreasury,
|
||||
inputUser,
|
||||
inputGAT,
|
||||
|
|
@ -21,9 +22,9 @@ module Sample.Effect.TreasuryWithdrawal (
|
|||
|
||||
import Agora.Effect.TreasuryWithdrawal (
|
||||
TreasuryWithdrawalDatum (TreasuryWithdrawalDatum),
|
||||
treasuryWithdrawalValidator,
|
||||
)
|
||||
import Plutarch.Api.V2 (mkValidator, validatorHash)
|
||||
import Data.Map ((!))
|
||||
import Plutarch.Api.V2 (validatorHash)
|
||||
import PlutusLedgerApi.V1.Interval qualified as Interval (always)
|
||||
import PlutusLedgerApi.V1.Value qualified as Value (singleton)
|
||||
import PlutusLedgerApi.V2 (
|
||||
|
|
@ -41,18 +42,18 @@ import PlutusLedgerApi.V2 (
|
|||
TxInfo (..),
|
||||
TxOut (..),
|
||||
TxOutRef (TxOutRef),
|
||||
Validator,
|
||||
Validator (Validator),
|
||||
ValidatorHash (ValidatorHash),
|
||||
Value,
|
||||
toBuiltinData,
|
||||
)
|
||||
import PlutusTx.AssocMap qualified as AssocMap
|
||||
import Sample.Shared (deterministicTracingConfing)
|
||||
import Sample.Shared (agoraScripts, authorityTokenSymbol)
|
||||
import Test.Util (scriptCredentials, userCredentials)
|
||||
|
||||
-- | A sample Currency Symbol.
|
||||
currSymbol :: CurrencySymbol
|
||||
currSymbol = "9c04a69c7133e26061fe5a15adaf4f79cd51e47ef22a2e3c91a36f04"
|
||||
currSymbol = authorityTokenSymbol
|
||||
|
||||
-- | A sample 'PubKeyHash'.
|
||||
signer :: PubKeyHash
|
||||
|
|
@ -147,7 +148,7 @@ buildReceiversOutputFromDatum (TreasuryWithdrawalDatum xs _) = f <$> xs
|
|||
|
||||
-- | Effect validator instance.
|
||||
validator :: Validator
|
||||
validator = mkValidator deterministicTracingConfing $ treasuryWithdrawalValidator currSymbol
|
||||
validator = Validator $ agoraScripts ! "agora:treasuryWithdrawalValidator"
|
||||
|
||||
-- | 'TokenName' that represents the hash of the 'Agora.Stake.Stake' validator.
|
||||
validatorHashTN :: TokenName
|
||||
|
|
|
|||
|
|
@ -21,18 +21,20 @@ module Sample.Governor.Initialize (
|
|||
|
||||
import Agora.Bootstrap (agoraScripts)
|
||||
import Agora.Governor (Governor (..), GovernorDatum (..))
|
||||
import Agora.Linker (linker)
|
||||
import Agora.Proposal (ProposalId (..), ProposalThresholds (..))
|
||||
import Agora.Proposal.Time (
|
||||
MaxTimeRangeWidth (MaxTimeRangeWidth),
|
||||
ProposalTimingConfig (ProposalTimingConfig),
|
||||
)
|
||||
import Agora.Scripts (
|
||||
AgoraScripts (compiledGovernorPolicy),
|
||||
governorSTAssetClass,
|
||||
governorSTSymbol,
|
||||
governorValidatorHash,
|
||||
)
|
||||
import Data.Default (Default (..))
|
||||
import Data.Map (Map, (!))
|
||||
import Data.Text (Text)
|
||||
import Optics (view)
|
||||
import Plutarch.Api.V2 (
|
||||
mintingPolicySymbol,
|
||||
validatorHash,
|
||||
)
|
||||
import Plutarch.Context (
|
||||
input,
|
||||
mint,
|
||||
|
|
@ -49,13 +51,18 @@ import PlutusLedgerApi.V1.Value (AssetClass (..))
|
|||
import PlutusLedgerApi.V1.Value qualified as Value
|
||||
import PlutusLedgerApi.V2 (
|
||||
CurrencySymbol,
|
||||
MintingPolicy (MintingPolicy),
|
||||
Script,
|
||||
TxOutRef (TxOutRef),
|
||||
Validator (Validator),
|
||||
ValidatorHash,
|
||||
)
|
||||
import Sample.Shared (
|
||||
deterministicTracingConfing,
|
||||
minAda,
|
||||
)
|
||||
import Sample.Shared qualified as Shared
|
||||
import ScriptExport.ScriptInfo (runLinker)
|
||||
import Test.Specification (SpecificationTree, testPolicy)
|
||||
import Test.Util (CombinableBuilder, mkMinting, pubKeyHashes, sortValue)
|
||||
|
||||
|
|
@ -110,17 +117,31 @@ governor =
|
|||
{ gstOutRef = witnessRef
|
||||
}
|
||||
|
||||
scripts :: AgoraScripts
|
||||
scripts = agoraScripts Shared.deterministicTracingConfing governor
|
||||
scripts :: Map Text Script
|
||||
scripts =
|
||||
either
|
||||
(error . show)
|
||||
(view #scripts)
|
||||
( runLinker
|
||||
linker
|
||||
(agoraScripts deterministicTracingConfing)
|
||||
governor
|
||||
)
|
||||
|
||||
govAssetClass :: AssetClass
|
||||
govAssetClass = governorSTAssetClass scripts
|
||||
govPolicy :: MintingPolicy
|
||||
govPolicy = MintingPolicy $ scripts ! "agora:governorPolicy"
|
||||
|
||||
govValidatorHash :: ValidatorHash
|
||||
govValidatorHash = governorValidatorHash scripts
|
||||
govValidator :: Validator
|
||||
govValidator = Validator $ scripts ! "agora:governorValidator"
|
||||
|
||||
govSymbol :: CurrencySymbol
|
||||
govSymbol = governorSTSymbol scripts
|
||||
govSymbol = mintingPolicySymbol govPolicy
|
||||
|
||||
govAssetClass :: AssetClass
|
||||
govAssetClass = AssetClass (govSymbol, "")
|
||||
|
||||
govValidatorHash :: ValidatorHash
|
||||
govValidatorHash = validatorHash govValidator
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -274,6 +295,6 @@ mkTestCase name ps valid =
|
|||
testPolicy
|
||||
valid
|
||||
name
|
||||
scripts.compiledGovernorPolicy
|
||||
govPolicy
|
||||
()
|
||||
(mkMinting mintGST ps govSymbol)
|
||||
|
|
|
|||
|
|
@ -16,13 +16,12 @@ module Sample.Governor.Mutate (
|
|||
invalidBundles,
|
||||
) where
|
||||
|
||||
import Agora.Effect.NoOp (noOpValidator)
|
||||
import Agora.Governor (GovernorDatum (..), GovernorRedeemer (MutateGovernor))
|
||||
import Agora.Proposal (ProposalId (ProposalId), ProposalThresholds (..))
|
||||
import Agora.Scripts (AgoraScripts (..))
|
||||
import Agora.Utils (scriptHashToTokenName)
|
||||
import Data.Default (def)
|
||||
import Plutarch.Api.V2 (PMintingPolicy, PValidator, mintingPolicySymbol, mkMintingPolicy, mkValidator, validatorHash)
|
||||
import Data.Map ((!))
|
||||
import Plutarch.Api.V2 (PMintingPolicy, mintingPolicySymbol, mkMintingPolicy, validatorHash)
|
||||
import Plutarch.Context (
|
||||
input,
|
||||
mint,
|
||||
|
|
@ -39,6 +38,7 @@ import PlutusLedgerApi.V2 (
|
|||
Data,
|
||||
ScriptHash (ScriptHash),
|
||||
TxOutRef (TxOutRef),
|
||||
Validator (Validator),
|
||||
ValidatorHash,
|
||||
Value,
|
||||
toData,
|
||||
|
|
@ -47,6 +47,7 @@ import Sample.Shared (
|
|||
agoraScripts,
|
||||
authorityTokenSymbol,
|
||||
govAssetClass,
|
||||
govValidator,
|
||||
govValidatorHash,
|
||||
minAda,
|
||||
)
|
||||
|
|
@ -171,11 +172,11 @@ mkGovernorBuilder ps =
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
mockEffectValidator :: ClosedTerm PValidator
|
||||
mockEffectValidator = noOpValidator authorityTokenSymbol
|
||||
mockEffectValidator :: Validator
|
||||
mockEffectValidator = Validator $ agoraScripts ! "agora:noOpValidator"
|
||||
|
||||
mockEffectValidatorHash :: ValidatorHash
|
||||
mockEffectValidatorHash = validatorHash $ mkValidator def mockEffectValidator
|
||||
mockEffectValidatorHash = validatorHash mockEffectValidator
|
||||
|
||||
mockAuthScript :: ClosedTerm PMintingPolicy
|
||||
mockAuthScript = plam $ \_ _ -> popaque $ pcon PUnit
|
||||
|
|
@ -236,7 +237,7 @@ mkTestCase name pb (Validity forGov) =
|
|||
testValidator
|
||||
forGov
|
||||
name
|
||||
agoraScripts.compiledGovernorValidator
|
||||
govValidator
|
||||
governorInputDatum
|
||||
governorRedeemer
|
||||
(mkSpending mutate pb governorRef)
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ import Agora.Proposal.Time (
|
|||
votingTime
|
||||
),
|
||||
)
|
||||
import Agora.Scripts (AgoraScripts (..))
|
||||
import Agora.Stake (
|
||||
StakeDatum (..),
|
||||
)
|
||||
|
|
@ -107,13 +106,15 @@ import Sample.Proposal.Shared (
|
|||
stakeTxRef,
|
||||
)
|
||||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
authorityTokenPolicy,
|
||||
authorityTokenSymbol,
|
||||
govAssetClass,
|
||||
govValidator,
|
||||
govValidatorHash,
|
||||
governor,
|
||||
minAda,
|
||||
proposalPolicySymbol,
|
||||
proposalValidator,
|
||||
proposalValidatorHash,
|
||||
signer,
|
||||
stakeAssetClass,
|
||||
|
|
@ -532,7 +533,7 @@ mkTestTree name pb val =
|
|||
testValidator
|
||||
val.forProposalValidator
|
||||
"proposal"
|
||||
agoraScripts.compiledProposalValidator
|
||||
proposalValidator
|
||||
proposalInputDatum
|
||||
proposalRedeemer
|
||||
(spend proposalRef)
|
||||
|
|
@ -541,7 +542,7 @@ mkTestTree name pb val =
|
|||
testValidator
|
||||
(fromJust val.forGovernorValidator)
|
||||
"governor"
|
||||
agoraScripts.compiledGovernorValidator
|
||||
govValidator
|
||||
governorInputDatum
|
||||
governorRedeemer
|
||||
(spend governorRef)
|
||||
|
|
@ -554,7 +555,7 @@ mkTestTree name pb val =
|
|||
( testPolicy
|
||||
(fromJust val.forAuthorityTokenPolicy)
|
||||
"authority"
|
||||
agoraScripts.compiledAuthorityTokenPolicy
|
||||
authorityTokenPolicy
|
||||
authorityTokenRedeemer
|
||||
(mkMinting advance pb authorityTokenSymbol)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import Agora.Proposal.Time (
|
|||
ProposalTimingConfig (draftTime),
|
||||
)
|
||||
import Agora.SafeMoney (GTTag)
|
||||
import Agora.Scripts (AgoraScripts (..))
|
||||
import Agora.Stake (
|
||||
ProposalLock (Cosigned, Created),
|
||||
StakeDatum (..),
|
||||
|
|
@ -74,13 +73,14 @@ import PlutusLedgerApi.V2 (
|
|||
)
|
||||
import Sample.Proposal.Shared (proposalTxRef, stakeTxRef)
|
||||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
fromDiscrete,
|
||||
governor,
|
||||
minAda,
|
||||
proposalPolicySymbol,
|
||||
proposalValidator,
|
||||
proposalValidatorHash,
|
||||
stakeAssetClass,
|
||||
stakeValidator,
|
||||
stakeValidatorHash,
|
||||
)
|
||||
import Test.Specification (
|
||||
|
|
@ -333,7 +333,7 @@ mkTestTree name ps val =
|
|||
testValidator
|
||||
val.forProposalValidator
|
||||
"proposal"
|
||||
agoraScripts.compiledProposalValidator
|
||||
proposalValidator
|
||||
(mkProposalInputDatum ps)
|
||||
proposalRedeemer
|
||||
(spend proposalRef)
|
||||
|
|
@ -342,7 +342,7 @@ mkTestTree name ps val =
|
|||
testValidator
|
||||
val.forStakeValidator
|
||||
"stake"
|
||||
agoraScripts.compiledStakeValidator
|
||||
stakeValidator
|
||||
(mkStakeInputDatum ps)
|
||||
stakeRedeemer
|
||||
(spend stakeRef)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ import Agora.Proposal.Time (
|
|||
ProposalStartingTime (..),
|
||||
)
|
||||
import Agora.SafeMoney (GTTag)
|
||||
import Agora.Scripts (AgoraScripts (..))
|
||||
import Agora.Stake (
|
||||
ProposalLock (..),
|
||||
StakeDatum (..),
|
||||
|
|
@ -72,18 +71,20 @@ import PlutusLedgerApi.V2 (
|
|||
)
|
||||
import Sample.Proposal.Shared (stakeTxRef)
|
||||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
fromDiscrete,
|
||||
govAssetClass,
|
||||
govValidator,
|
||||
govValidatorHash,
|
||||
governor,
|
||||
minAda,
|
||||
proposalPolicy,
|
||||
proposalPolicySymbol,
|
||||
proposalStartingTimeFromTimeRange,
|
||||
proposalValidatorHash,
|
||||
signer,
|
||||
signer2,
|
||||
stakeAssetClass,
|
||||
stakeValidator,
|
||||
stakeValidatorHash,
|
||||
)
|
||||
import Test.Specification (SpecificationTree, group, testPolicy, testValidator)
|
||||
|
|
@ -457,7 +458,7 @@ mkTestTree
|
|||
testPolicy
|
||||
validForProposalPolicy
|
||||
"proposal"
|
||||
agoraScripts.compiledProposalPolicy
|
||||
proposalPolicy
|
||||
proposalPolicyRedeemer
|
||||
(mint proposalPolicySymbol)
|
||||
|
||||
|
|
@ -465,7 +466,7 @@ mkTestTree
|
|||
testValidator
|
||||
validForGovernorValidator
|
||||
"governor"
|
||||
agoraScripts.compiledGovernorValidator
|
||||
govValidator
|
||||
governorInputDatum
|
||||
governorRedeemer
|
||||
(spend governorRef)
|
||||
|
|
@ -474,7 +475,7 @@ mkTestTree
|
|||
testValidator
|
||||
validForStakeValidator
|
||||
"stake"
|
||||
agoraScripts.compiledStakeValidator
|
||||
stakeValidator
|
||||
(mkStakeInputDatum ps)
|
||||
stakeRedeemer
|
||||
(spend stakeRef)
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ import Agora.Proposal (
|
|||
ResultTag (..),
|
||||
)
|
||||
import Agora.Proposal.Time (ProposalStartingTime (ProposalStartingTime), ProposalTimingConfig (..))
|
||||
import Agora.Scripts (AgoraScripts (..))
|
||||
import Agora.Stake (
|
||||
ProposalLock (..),
|
||||
StakeDatum (..),
|
||||
|
|
@ -72,12 +71,13 @@ import PlutusLedgerApi.V2 (
|
|||
)
|
||||
import Sample.Proposal.Shared (stakeTxRef)
|
||||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
governor,
|
||||
minAda,
|
||||
proposalPolicySymbol,
|
||||
proposalValidator,
|
||||
proposalValidatorHash,
|
||||
stakeAssetClass,
|
||||
stakeValidator,
|
||||
stakeValidatorHash,
|
||||
)
|
||||
import Test.Specification (SpecificationTree, group, testValidator)
|
||||
|
|
@ -379,7 +379,7 @@ mkTestTree name ps val = group name [stake, proposal]
|
|||
testValidator
|
||||
val.forStakeValidator
|
||||
"stake"
|
||||
agoraScripts.compiledStakeValidator
|
||||
stakeValidator
|
||||
(mkStakeInputDatum ps.stakeParameters)
|
||||
stakeRedeemer
|
||||
(spend $ mkStakeRef 1)
|
||||
|
|
@ -388,7 +388,7 @@ mkTestTree name ps val = group name [stake, proposal]
|
|||
testValidator
|
||||
val.forProposalValidator
|
||||
"proposal"
|
||||
agoraScripts.compiledProposalValidator
|
||||
proposalValidator
|
||||
(mkProposalInputDatum ps.stakeParameters ps.proposalParameters)
|
||||
proposalRedeemer
|
||||
(spend proposalRef)
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ import Agora.Proposal.Time (
|
|||
ProposalStartingTime (ProposalStartingTime),
|
||||
ProposalTimingConfig (draftTime, votingTime),
|
||||
)
|
||||
import Agora.Scripts (AgoraScripts (..))
|
||||
import Agora.Stake (
|
||||
ProposalLock (Voted),
|
||||
StakeDatum (..),
|
||||
|
|
@ -70,12 +69,13 @@ import PlutusLedgerApi.V2 (Credential (PubKeyCredential), PubKeyHash)
|
|||
import PlutusLedgerApi.V2.Contexts (TxOutRef (TxOutRef))
|
||||
import Sample.Proposal.Shared (proposalTxRef)
|
||||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
governor,
|
||||
minAda,
|
||||
proposalPolicySymbol,
|
||||
proposalValidator,
|
||||
proposalValidatorHash,
|
||||
stakeAssetClass,
|
||||
stakeValidator,
|
||||
stakeValidatorHash,
|
||||
)
|
||||
import Test.Specification (SpecificationTree, group, testValidator)
|
||||
|
|
@ -385,7 +385,7 @@ mkTestTree name ps val = group name $ catMaybes [proposal, stake]
|
|||
testValidator
|
||||
val.forProposalValidator
|
||||
"proposal"
|
||||
agoraScripts.compiledProposalValidator
|
||||
proposalValidator
|
||||
proposalInputDatum
|
||||
(mkProposalRedeemer ps.voteParameters)
|
||||
(spend $ mkProposalRef 1)
|
||||
|
|
@ -399,7 +399,7 @@ mkTestTree name ps val = group name $ catMaybes [proposal, stake]
|
|||
testValidator
|
||||
val.forStakeValidator
|
||||
"stake"
|
||||
agoraScripts.compiledStakeValidator
|
||||
stakeValidator
|
||||
(mkStakeInputDatum ps.stakeParameters.stakeInputParameters)
|
||||
(mkStakeRedeemer ps.stakeParameters.stakeOutputParameters)
|
||||
(spend stakeRef)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ module Sample.Shared (
|
|||
signer2,
|
||||
minAda,
|
||||
deterministicTracingConfing,
|
||||
mkEffect,
|
||||
mkRedeemer,
|
||||
fromDiscrete,
|
||||
|
||||
|
|
@ -24,6 +23,8 @@ module Sample.Shared (
|
|||
|
||||
-- ** Stake
|
||||
stakeAssetClass,
|
||||
stakePolicy,
|
||||
stakeValidator,
|
||||
stakeValidatorHash,
|
||||
stakeAddress,
|
||||
stakeSymbol,
|
||||
|
|
@ -39,12 +40,15 @@ module Sample.Shared (
|
|||
gstUTXORef,
|
||||
|
||||
-- ** Proposal
|
||||
proposalPolicy,
|
||||
proposalPolicySymbol,
|
||||
proposalValidator,
|
||||
proposalValidatorHash,
|
||||
proposalValidatorAddress,
|
||||
proposalStartingTimeFromTimeRange,
|
||||
|
||||
-- ** Authority
|
||||
authorityTokenPolicy,
|
||||
authorityTokenSymbol,
|
||||
|
||||
-- ** Treasury
|
||||
|
|
@ -53,42 +57,37 @@ module Sample.Shared (
|
|||
gatCs,
|
||||
mockTrEffect,
|
||||
mockTrEffectHash,
|
||||
trValidator,
|
||||
trCredential,
|
||||
wrongEffHash,
|
||||
) where
|
||||
|
||||
import Agora.Bootstrap qualified as Bootstrap
|
||||
import Agora.Effect.NoOp (noOpValidator)
|
||||
import Agora.Governor (Governor (Governor))
|
||||
import Agora.Linker (linker)
|
||||
import Agora.Proposal (ProposalThresholds (..))
|
||||
import Agora.Proposal.Time (
|
||||
MaxTimeRangeWidth (..),
|
||||
ProposalStartingTime (ProposalStartingTime),
|
||||
ProposalTimingConfig (..),
|
||||
)
|
||||
import Agora.Scripts qualified as Scripts
|
||||
import Agora.Treasury (treasuryValidator)
|
||||
import Agora.Utils (
|
||||
CompiledEffect (CompiledEffect),
|
||||
CompiledMintingPolicy (getCompiledMintingPolicy),
|
||||
CompiledValidator (getCompiledValidator),
|
||||
validatorHashToTokenName,
|
||||
)
|
||||
import Data.Coerce (coerce)
|
||||
import Data.Default.Class (Default (..))
|
||||
import Data.Map (Map, (!))
|
||||
import Data.Tagged (Tagged (..))
|
||||
import Data.Text (Text)
|
||||
import Optics (view)
|
||||
import Plutarch (Config (..), TracingMode (DetTracing))
|
||||
import Plutarch.Api.V2 (
|
||||
PValidator,
|
||||
mintingPolicySymbol,
|
||||
mkValidator,
|
||||
validatorHash,
|
||||
)
|
||||
import Plutarch.SafeMoney (Discrete (Discrete))
|
||||
import PlutusLedgerApi.V1.Address (scriptHashAddress)
|
||||
import PlutusLedgerApi.V1.Contexts (TxOut (..))
|
||||
import PlutusLedgerApi.V1.Scripts (Validator, ValidatorHash (..))
|
||||
import PlutusLedgerApi.V1.Value (AssetClass, TokenName)
|
||||
import PlutusLedgerApi.V1.Value (AssetClass (AssetClass), TokenName, Value)
|
||||
import PlutusLedgerApi.V1.Value qualified as Value (
|
||||
assetClass,
|
||||
singleton,
|
||||
|
|
@ -101,15 +100,26 @@ import PlutusLedgerApi.V2 (
|
|||
Interval (..),
|
||||
LowerBound (..),
|
||||
MintingPolicy (..),
|
||||
OutputDatum (NoOutputDatum),
|
||||
POSIXTimeRange,
|
||||
PubKeyHash,
|
||||
Redeemer (..),
|
||||
Script,
|
||||
ToData (toBuiltinData),
|
||||
TxOut (
|
||||
TxOut,
|
||||
txOutAddress,
|
||||
txOutDatum,
|
||||
txOutReferenceScript,
|
||||
txOutValue
|
||||
),
|
||||
TxOutRef (TxOutRef),
|
||||
UpperBound (..),
|
||||
Value,
|
||||
Validator (Validator),
|
||||
ValidatorHash (ValidatorHash),
|
||||
)
|
||||
import PlutusTx qualified
|
||||
import ScriptExport.ScriptInfo (runLinker)
|
||||
|
||||
-- Plutarch compiler configauration.
|
||||
-- TODO: add the ability to change this value. Maybe wrap everything in a
|
||||
|
|
@ -128,17 +138,31 @@ governor = Governor oref gt mc
|
|||
"LQ"
|
||||
mc = 20
|
||||
|
||||
agoraScripts :: Scripts.AgoraScripts
|
||||
agoraScripts = Bootstrap.agoraScripts deterministicTracingConfing governor
|
||||
agoraScripts :: Map Text Script
|
||||
agoraScripts =
|
||||
either
|
||||
(error . show)
|
||||
(view #scripts)
|
||||
( runLinker
|
||||
linker
|
||||
(Bootstrap.agoraScripts deterministicTracingConfing)
|
||||
governor
|
||||
)
|
||||
|
||||
stakePolicy :: MintingPolicy
|
||||
stakePolicy = MintingPolicy $ agoraScripts ! "agora:stakePolicy"
|
||||
|
||||
stakeSymbol :: CurrencySymbol
|
||||
stakeSymbol = Scripts.stakeSTSymbol agoraScripts
|
||||
stakeSymbol = mintingPolicySymbol stakePolicy
|
||||
|
||||
stakeAssetClass :: AssetClass
|
||||
stakeAssetClass = Scripts.stakeSTAssetClass agoraScripts
|
||||
stakeAssetClass = AssetClass (stakeSymbol, validatorHashToTokenName stakeValidatorHash)
|
||||
|
||||
stakeValidator :: Validator
|
||||
stakeValidator = Validator $ agoraScripts ! "agora:stakeValidator"
|
||||
|
||||
stakeValidatorHash :: ValidatorHash
|
||||
stakeValidatorHash = Scripts.stakeValidatorHash agoraScripts
|
||||
stakeValidatorHash = validatorHash stakeValidator
|
||||
|
||||
stakeAddress :: Address
|
||||
stakeAddress = Address (ScriptCredential stakeValidatorHash) Nothing
|
||||
|
|
@ -147,25 +171,28 @@ gstUTXORef :: TxOutRef
|
|||
gstUTXORef = TxOutRef "f28cd7145c24e66fd5bcd2796837aeb19a48a2656e7833c88c62a2d0450bd00d" 0
|
||||
|
||||
govPolicy :: MintingPolicy
|
||||
govPolicy = agoraScripts.compiledGovernorPolicy.getCompiledMintingPolicy
|
||||
govPolicy = MintingPolicy $ agoraScripts ! "agora:governorPolicy"
|
||||
|
||||
govValidator :: Validator
|
||||
govValidator = agoraScripts.compiledGovernorValidator.getCompiledValidator
|
||||
govValidator = Validator $ agoraScripts ! "agora:governorValidator"
|
||||
|
||||
govSymbol :: CurrencySymbol
|
||||
govSymbol = mintingPolicySymbol govPolicy
|
||||
|
||||
govAssetClass :: AssetClass
|
||||
govAssetClass = Scripts.governorSTAssetClass agoraScripts
|
||||
govAssetClass = AssetClass (govSymbol, "")
|
||||
|
||||
govValidatorHash :: ValidatorHash
|
||||
govValidatorHash = Scripts.governorValidatorHash agoraScripts
|
||||
govValidatorHash = validatorHash govValidator
|
||||
|
||||
govValidatorAddress :: Address
|
||||
govValidatorAddress = scriptHashAddress govValidatorHash
|
||||
|
||||
proposalPolicy :: MintingPolicy
|
||||
proposalPolicy = MintingPolicy $ agoraScripts ! "agora:proposalPolicy"
|
||||
|
||||
proposalPolicySymbol :: CurrencySymbol
|
||||
proposalPolicySymbol = Scripts.proposalSTSymbol agoraScripts
|
||||
proposalPolicySymbol = mintingPolicySymbol proposalPolicy
|
||||
|
||||
-- | A sample 'PubKeyHash'.
|
||||
signer :: PubKeyHash
|
||||
|
|
@ -175,8 +202,11 @@ signer = "8a30896c4fd5e79843e4ca1bd2cdbaa36f8c0bc3be7401214142019c"
|
|||
signer2 :: PubKeyHash
|
||||
signer2 = "8a30896c4fd5e79843e4ca1bd2cdbaa36f8c0bc3be74012141420192"
|
||||
|
||||
proposalValidator :: Validator
|
||||
proposalValidator = Validator $ agoraScripts ! "agora:proposalValidator"
|
||||
|
||||
proposalValidatorHash :: ValidatorHash
|
||||
proposalValidatorHash = Scripts.proposalValidatoHash agoraScripts
|
||||
proposalValidatorHash = validatorHash proposalValidator
|
||||
|
||||
proposalValidatorAddress :: Address
|
||||
proposalValidatorAddress = scriptHashAddress proposalValidatorHash
|
||||
|
|
@ -194,8 +224,11 @@ instance Default ProposalThresholds where
|
|||
, cosign = Tagged 100
|
||||
}
|
||||
|
||||
authorityTokenPolicy :: MintingPolicy
|
||||
authorityTokenPolicy = MintingPolicy $ agoraScripts ! "agora:authorityTokenPolicy"
|
||||
|
||||
authorityTokenSymbol :: CurrencySymbol
|
||||
authorityTokenSymbol = Scripts.authorityTokenSymbol agoraScripts
|
||||
authorityTokenSymbol = mintingPolicySymbol authorityTokenPolicy
|
||||
|
||||
{- | Default value of 'Agora.Governor.GovernorDatum.proposalTimings'.
|
||||
For testing purpose only.
|
||||
|
|
@ -224,9 +257,6 @@ proposalStartingTimeFromTimeRange
|
|||
ProposalStartingTime $ (l + u) `div` 2
|
||||
proposalStartingTimeFromTimeRange _ = error "Given time range should be finite and closed"
|
||||
|
||||
mkEffect :: (PlutusTx.ToData datum) => ClosedTerm PValidator -> CompiledEffect datum
|
||||
mkEffect v = CompiledEffect $ mkValidator deterministicTracingConfing v
|
||||
|
||||
mkRedeemer :: forall redeemer. PlutusTx.ToData redeemer => redeemer -> Redeemer
|
||||
mkRedeemer = Redeemer . toBuiltinData
|
||||
|
||||
|
|
@ -240,17 +270,18 @@ treasuryOut =
|
|||
TxOut
|
||||
{ txOutAddress = Address trCredential Nothing
|
||||
, txOutValue = minAda
|
||||
, txOutDatumHash = Nothing
|
||||
, txOutDatum = NoOutputDatum
|
||||
, txOutReferenceScript = Nothing
|
||||
}
|
||||
|
||||
{- | Arbitrary 'CurrencySymbol', representing the 'CurrencySymbol'
|
||||
of a valid governance authority token (GAT).
|
||||
-}
|
||||
gatCs :: CurrencySymbol
|
||||
gatCs = "73475cb40a568e8da8a045ced110137e159f890ac4da883b6b17dc651b3a8049"
|
||||
gatCs = authorityTokenSymbol
|
||||
|
||||
trValidator :: Validator
|
||||
trValidator = mkValidator def (treasuryValidator gatCs)
|
||||
trValidator = Validator $ agoraScripts ! "agora:treasuryValidator"
|
||||
|
||||
-- | `ScriptCredential` used for the dummy treasury validator.
|
||||
trCredential :: Credential
|
||||
|
|
@ -262,7 +293,7 @@ gatTn = validatorHashToTokenName $ validatorHash mockTrEffect
|
|||
|
||||
-- | Mock treasury effect script, used for testing.
|
||||
mockTrEffect :: Validator
|
||||
mockTrEffect = mkValidator def $ noOpValidator gatCs
|
||||
mockTrEffect = Validator $ agoraScripts ! "agora:noOpValidator"
|
||||
|
||||
-- | Mock treasury effect validator hash
|
||||
mockTrEffectHash :: ValidatorHash
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ module Sample.Stake.SetDelegate (
|
|||
) where
|
||||
|
||||
import Agora.Governor (Governor (gtClassRef))
|
||||
import Agora.Scripts (AgoraScripts (..))
|
||||
import Agora.Stake (
|
||||
StakeDatum (..),
|
||||
StakeRedeemer (ClearDelegate, DelegateTo),
|
||||
|
|
@ -47,13 +46,13 @@ import PlutusLedgerApi.V2 (
|
|||
TxOutRef (TxOutRef),
|
||||
)
|
||||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
fromDiscrete,
|
||||
governor,
|
||||
minAda,
|
||||
signer,
|
||||
signer2,
|
||||
stakeAssetClass,
|
||||
stakeValidator,
|
||||
stakeValidatorHash,
|
||||
)
|
||||
import Test.Specification (SpecificationTree, testValidator)
|
||||
|
|
@ -159,7 +158,7 @@ mkTestCase name ps valid =
|
|||
testValidator
|
||||
valid
|
||||
name
|
||||
agoraScripts.compiledStakeValidator
|
||||
stakeValidator
|
||||
(mkStakeInputDatum ps)
|
||||
(mkStakeRedeemer ps)
|
||||
(setDelegate ps)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue