renamed shared sample
This commit is contained in:
parent
02ce2cfcaa
commit
f48591d03a
8 changed files with 55 additions and 55 deletions
|
|
@ -43,10 +43,10 @@ import PlutusLedgerApi.V2 (
|
|||
)
|
||||
import Property.Generator (genInput, genOutput)
|
||||
import Sample.Shared (
|
||||
govAssetClass,
|
||||
govSymbol,
|
||||
govValidatorHash,
|
||||
governor,
|
||||
governorAssetClass,
|
||||
governorSymbol,
|
||||
governorValidatorHash,
|
||||
gstUTXORef,
|
||||
)
|
||||
import Test.Tasty (TestTree)
|
||||
|
|
@ -171,12 +171,12 @@ governorMintingProperty =
|
|||
{- Note:
|
||||
I don't think it's easily possible to randomize orefs. We can't really pass pass `Governor` type to `actual` function.
|
||||
-}
|
||||
gst = assetClassValue govAssetClass 1
|
||||
gst = assetClassValue governorAssetClass 1
|
||||
mintAmount x = mint . mconcat $ replicate x gst
|
||||
outputToGov =
|
||||
output $
|
||||
mconcat
|
||||
[ script govValidatorHash
|
||||
[ script governorValidatorHash
|
||||
, withValue gst
|
||||
, withDatum govDatum
|
||||
]
|
||||
|
|
@ -205,7 +205,7 @@ governorMintingProperty =
|
|||
GovernorOutputNotFound -> referencedInput <> mintAmount 1
|
||||
GovernorPolicyCorrect -> referencedInput <> outputToGov <> mintAmount 1
|
||||
|
||||
return . buildMinting' $ inputs <> outputs <> comp <> withMinting govSymbol
|
||||
return . buildMinting' $ inputs <> outputs <> comp <> withMinting governorSymbol
|
||||
|
||||
expected :: ScriptContext -> Maybe ()
|
||||
expected sc =
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ import PlutusTx.AssocMap qualified as AssocMap
|
|||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
authorityTokenSymbol,
|
||||
govAssetClass,
|
||||
govValidatorAddress,
|
||||
governorAssetClass,
|
||||
governorValidatorAddress,
|
||||
minAda,
|
||||
mkRedeemer,
|
||||
signer,
|
||||
|
|
@ -99,7 +99,7 @@ mkEffectDatum newGovDatum =
|
|||
-}
|
||||
mkEffectTxInfo :: GovernorDatum -> TxInfo
|
||||
mkEffectTxInfo newGovDatum =
|
||||
let gst = Value.assetClassValue govAssetClass 1
|
||||
let gst = Value.assetClassValue governorAssetClass 1
|
||||
at = Value.assetClassValue atAssetClass 1
|
||||
|
||||
-- One authority token is burnt in the process.
|
||||
|
|
@ -121,7 +121,7 @@ mkEffectTxInfo newGovDatum =
|
|||
governorInput :: TxOut
|
||||
governorInput =
|
||||
TxOut
|
||||
{ txOutAddress = govValidatorAddress
|
||||
{ txOutAddress = governorValidatorAddress
|
||||
, txOutValue = gst
|
||||
, txOutDatum = OutputDatumHash $ toDatumHash governorInputDatum
|
||||
, txOutReferenceScript = Nothing
|
||||
|
|
@ -152,7 +152,7 @@ mkEffectTxInfo newGovDatum =
|
|||
governorOutput :: TxOut
|
||||
governorOutput =
|
||||
TxOut
|
||||
{ txOutAddress = govValidatorAddress
|
||||
{ txOutAddress = governorValidatorAddress
|
||||
, txOutValue = mconcat [gst, minAda]
|
||||
, txOutDatum = OutputDatumHash $ toDatumHash governorOutputDatum
|
||||
, txOutReferenceScript = Nothing
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ import PlutusLedgerApi.V2 (
|
|||
import Sample.Shared (
|
||||
agoraScripts,
|
||||
authorityTokenSymbol,
|
||||
govAssetClass,
|
||||
govValidator,
|
||||
govValidatorHash,
|
||||
governorAssetClass,
|
||||
governorValidator,
|
||||
governorValidatorHash,
|
||||
minAda,
|
||||
)
|
||||
import Test.Specification (SpecificationTree, testValidator)
|
||||
|
|
@ -145,19 +145,19 @@ governorRedeemer = MutateGovernor
|
|||
|
||||
mkGovernorBuilder :: forall b. CombinableBuilder b => GovernorParameters -> b
|
||||
mkGovernorBuilder ps =
|
||||
let gst = Value.assetClassValue govAssetClass 1
|
||||
let gst = Value.assetClassValue governorAssetClass 1
|
||||
value = sortValue $ gst <> minAda
|
||||
gstOutput =
|
||||
if ps.stealGST
|
||||
then pubKey $ head pubKeyHashes
|
||||
else script govValidatorHash
|
||||
else script governorValidatorHash
|
||||
withGSTDatum =
|
||||
maybe mempty withDatum $
|
||||
mkGovernorOutputDatum ps.governorOutputDatumValidity
|
||||
in mconcat
|
||||
[ input $
|
||||
mconcat
|
||||
[ script govValidatorHash
|
||||
[ script governorValidatorHash
|
||||
, withDatum governorInputDatum
|
||||
, withValue value
|
||||
, withRef governorRef
|
||||
|
|
@ -237,7 +237,7 @@ mkTestCase name pb (Validity forGov) =
|
|||
testValidator
|
||||
forGov
|
||||
name
|
||||
govValidator
|
||||
governorValidator
|
||||
governorInputDatum
|
||||
governorRedeemer
|
||||
(mkSpending mutate pb governorRef)
|
||||
|
|
|
|||
|
|
@ -108,10 +108,10 @@ import Sample.Proposal.Shared (
|
|||
import Sample.Shared (
|
||||
authorityTokenPolicy,
|
||||
authorityTokenSymbol,
|
||||
govAssetClass,
|
||||
govValidator,
|
||||
govValidatorHash,
|
||||
governor,
|
||||
governorAssetClass,
|
||||
governorValidator,
|
||||
governorValidatorHash,
|
||||
minAda,
|
||||
proposalPolicySymbol,
|
||||
proposalValidator,
|
||||
|
|
@ -432,19 +432,19 @@ governorRef = TxOutRef governorTxRef 2
|
|||
-}
|
||||
mkGovernorBuilder :: forall b. CombinableBuilder b => GovernorParameters -> b
|
||||
mkGovernorBuilder ps =
|
||||
let gst = Value.assetClassValue govAssetClass 1
|
||||
let gst = Value.assetClassValue governorAssetClass 1
|
||||
value = sortValue $ gst <> minAda
|
||||
in mconcat
|
||||
[ input $
|
||||
mconcat
|
||||
[ script govValidatorHash
|
||||
[ script governorValidatorHash
|
||||
, withValue value
|
||||
, withRef governorRef
|
||||
, withDatum governorInputDatum
|
||||
]
|
||||
, output $
|
||||
mconcat
|
||||
[ script govValidatorHash
|
||||
[ script governorValidatorHash
|
||||
, withValue value
|
||||
, withRef governorRef
|
||||
, withDatum (mkGovernorOutputDatum ps)
|
||||
|
|
@ -542,7 +542,7 @@ mkTestTree name pb val =
|
|||
testValidator
|
||||
(fromJust val.forGovernorValidator)
|
||||
"governor"
|
||||
govValidator
|
||||
governorValidator
|
||||
governorInputDatum
|
||||
governorRedeemer
|
||||
(spend governorRef)
|
||||
|
|
|
|||
|
|
@ -72,10 +72,10 @@ import PlutusLedgerApi.V2 (
|
|||
import Sample.Proposal.Shared (stakeTxRef)
|
||||
import Sample.Shared (
|
||||
fromDiscrete,
|
||||
govAssetClass,
|
||||
govValidator,
|
||||
govValidatorHash,
|
||||
governor,
|
||||
governorAssetClass,
|
||||
governorValidator,
|
||||
governorValidatorHash,
|
||||
minAda,
|
||||
proposalPolicy,
|
||||
proposalPolicySymbol,
|
||||
|
|
@ -284,7 +284,7 @@ createProposal ps = builder
|
|||
where
|
||||
pst = Value.singleton proposalPolicySymbol "" 1
|
||||
sst = Value.assetClassValue stakeAssetClass 1
|
||||
gst = Value.assetClassValue govAssetClass 1
|
||||
gst = Value.assetClassValue governorAssetClass 1
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -323,14 +323,14 @@ createProposal ps = builder
|
|||
timeRange $ mkTimeRange ps
|
||||
, input $
|
||||
mconcat
|
||||
[ script govValidatorHash
|
||||
[ script governorValidatorHash
|
||||
, withValue governorValue
|
||||
, withDatum governorInputDatum
|
||||
, withRef governorRef
|
||||
]
|
||||
, output $
|
||||
mconcat
|
||||
[ script govValidatorHash
|
||||
[ script governorValidatorHash
|
||||
, withValue governorValue
|
||||
, withDatum (mkGovernorOutputDatum ps)
|
||||
]
|
||||
|
|
@ -466,7 +466,7 @@ mkTestTree
|
|||
testValidator
|
||||
validForGovernorValidator
|
||||
"governor"
|
||||
govValidator
|
||||
governorValidator
|
||||
governorInputDatum
|
||||
governorRedeemer
|
||||
(spend governorRef)
|
||||
|
|
|
|||
|
|
@ -31,12 +31,12 @@ module Sample.Shared (
|
|||
|
||||
-- ** Governor
|
||||
governor,
|
||||
govPolicy,
|
||||
govValidator,
|
||||
govSymbol,
|
||||
govAssetClass,
|
||||
govValidatorAddress,
|
||||
govValidatorHash,
|
||||
governorPolicy,
|
||||
governorValidator,
|
||||
governorSymbol,
|
||||
governorAssetClass,
|
||||
governorValidatorAddress,
|
||||
governorValidatorHash,
|
||||
gstUTXORef,
|
||||
|
||||
-- ** Proposal
|
||||
|
|
@ -170,23 +170,23 @@ stakeAddress = Address (ScriptCredential stakeValidatorHash) Nothing
|
|||
gstUTXORef :: TxOutRef
|
||||
gstUTXORef = TxOutRef "f28cd7145c24e66fd5bcd2796837aeb19a48a2656e7833c88c62a2d0450bd00d" 0
|
||||
|
||||
govPolicy :: MintingPolicy
|
||||
govPolicy = MintingPolicy $ agoraScripts ! "agora:governorPolicy"
|
||||
governorPolicy :: MintingPolicy
|
||||
governorPolicy = MintingPolicy $ agoraScripts ! "agora:governorPolicy"
|
||||
|
||||
govValidator :: Validator
|
||||
govValidator = Validator $ agoraScripts ! "agora:governorValidator"
|
||||
governorValidator :: Validator
|
||||
governorValidator = Validator $ agoraScripts ! "agora:governorValidator"
|
||||
|
||||
govSymbol :: CurrencySymbol
|
||||
govSymbol = mintingPolicySymbol govPolicy
|
||||
governorSymbol :: CurrencySymbol
|
||||
governorSymbol = mintingPolicySymbol governorPolicy
|
||||
|
||||
govAssetClass :: AssetClass
|
||||
govAssetClass = AssetClass (govSymbol, "")
|
||||
governorAssetClass :: AssetClass
|
||||
governorAssetClass = AssetClass (governorSymbol, "")
|
||||
|
||||
govValidatorHash :: ValidatorHash
|
||||
govValidatorHash = validatorHash govValidator
|
||||
governorValidatorHash :: ValidatorHash
|
||||
governorValidatorHash = validatorHash governorValidator
|
||||
|
||||
govValidatorAddress :: Address
|
||||
govValidatorAddress = scriptHashAddress govValidatorHash
|
||||
governorValidatorAddress :: Address
|
||||
governorValidatorAddress = scriptHashAddress governorValidatorHash
|
||||
|
||||
proposalPolicy :: MintingPolicy
|
||||
proposalPolicy = MintingPolicy $ agoraScripts ! "agora:proposalPolicy"
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import Sample.Effect.GovernorMutation (
|
|||
mkEffectTxInfo,
|
||||
validNewGovernorDatum,
|
||||
)
|
||||
import Sample.Shared (govValidator)
|
||||
import Sample.Shared (governorValidator)
|
||||
import Test.Specification (
|
||||
SpecificationTree,
|
||||
effectFailsWith,
|
||||
|
|
@ -31,7 +31,7 @@ specs =
|
|||
"valid new governor datum"
|
||||
[ validatorSucceedsWith
|
||||
"governor validator should pass"
|
||||
govValidator
|
||||
governorValidator
|
||||
( GovernorDatum
|
||||
def
|
||||
(ProposalId 0)
|
||||
|
|
@ -54,7 +54,7 @@ specs =
|
|||
"invalid new governor datum"
|
||||
[ validatorFailsWith
|
||||
"governor validator should fail"
|
||||
govValidator
|
||||
governorValidator
|
||||
( GovernorDatum
|
||||
def
|
||||
(ProposalId 0)
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ mutateGovernorValidator ::
|
|||
:--> PValidator
|
||||
)
|
||||
mutateGovernorValidator =
|
||||
plam $ \govValidatorHash gtSymbol -> makeEffect @PMutateGovernorDatum $
|
||||
plam $ \govValidatorHash gstSymbol -> makeEffect @PMutateGovernorDatum $
|
||||
\_gatCs (effectDatum :: Term _ PMutateGovernorDatum) _ txInfo -> unTermCont $ do
|
||||
effectDatumF <- pletAllC effectDatum
|
||||
txInfoF <- pletFieldsC @'["inputs", "outputs", "datums", "redeemers"] txInfo
|
||||
|
|
@ -188,7 +188,7 @@ mutateGovernorValidator =
|
|||
inputF.outRef #== effectDatumF.governorRef
|
||||
, ptraceIfFalse "Governor UTxO should carry GST" $
|
||||
psymbolValueOf
|
||||
# gtSymbol
|
||||
# gstSymbol
|
||||
# (pfield @"value" # inputF.resolved)
|
||||
#== 1
|
||||
, ptraceIfFalse "Governor validator run" $
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue