remove all unnecessary mint only one kind of token checks

This commit is contained in:
fanghr 2022-04-21 22:22:49 +08:00
parent 12a0e3046e
commit 74b5e714da

View file

@ -42,7 +42,7 @@ import Agora.AuthorityToken (
import Agora.Proposal ( import Agora.Proposal (
PProposalDatum, PProposalDatum,
PProposalId, PProposalId,
PProposalStatus (PFinished, PExecutable), PProposalStatus (PExecutable, PFinished),
PProposalThresholds, PProposalThresholds,
PProposalVotes (PProposalVotes), PProposalVotes (PProposalVotes),
PResultTag (PResultTag), PResultTag (PResultTag),
@ -55,7 +55,6 @@ import Agora.Proposal (
proposalValidator, proposalValidator,
) )
import Agora.Utils ( import Agora.Utils (
containsSingleCurrencySymbol,
findOutputsToAddress, findOutputsToAddress,
hasOnlyOneTokenOfCurrencySymbol, hasOnlyOneTokenOfCurrencySymbol,
mustBePDJust, mustBePDJust,
@ -162,9 +161,9 @@ PlutusTx.makeIsDataIndexed
-- | Parameters for creating Governor scripts. -- | Parameters for creating Governor scripts.
data Governor = Governor data Governor = Governor
{ stORef :: TxOutRef, { stORef :: TxOutRef
-- ^ An utxo, which will be spent to mint the state token for the governor validator. -- ^ An utxo, which will be spent to mint the state token for the governor validator.
stName :: TokenName , stName :: TokenName
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -231,9 +230,6 @@ governorPolicy params =
psymbolValueOf # ownSymbol # mintValue #== 1 psymbolValueOf # ownSymbol # mintValue #== 1
#&& passetClassValueOf # ownSymbol # pconstant governorStateTokenName # mintValue #== 1 #&& passetClassValueOf # ownSymbol # pconstant governorStateTokenName # mintValue #== 1
passert "Nothing is minted other than the state token" $
containsSingleCurrencySymbol # mintValue
popaque (pconstant ()) popaque (pconstant ())
{- Validator for Governors. {- Validator for Governors.
@ -323,24 +319,28 @@ governorValidator params =
passert "The utxo paid to the proposal validator must have datum" $ passert "The utxo paid to the proposal validator must have datum" $
pisDJust # output.datumHash pisDJust # output.datumHash
let inputProposalDatum' = outputProposalDatum' <-
mustFindDatum' @PProposalDatum plet $
# output.datumHash mustFindDatum' @PProposalDatum
# ctx.txInfo # output.datumHash
# ctx.txInfo
passert "Proposal datum must be valid" $
proposalDatumValid # outputProposalDatum'
proposalParams <- proposalParams <-
pletFields pletFields
@'["id", "status", "cosigners", "thresholds", "votes"] @'["id", "status", "cosigners", "thresholds", "votes"]
inputProposalDatum' outputProposalDatum'
passert "Invalid proposal id in proposal parameters" $ passert "Invalid proposal id in proposal datum" $
proposalParams.id #== oldParams.nextProposalId proposalParams.id #== oldParams.nextProposalId
passert "Invalid thresholds in proposal parameters" $ passert "Invalid thresholds in proposal datum" $
proposalParams.thresholds #== oldParams.proposalThresholds proposalParams.thresholds #== oldParams.proposalThresholds
-- passert "Initial proposal votes should be empty" $ passert "Initial proposal votes should be empty" $
-- pnull #$ pto $ pto $ pfromData proposalParams.votes pnull #$ pto $ pto $ pfromData proposalParams.votes
-- passert "Initial proposal status should be Draft" $ P.do -- passert "Initial proposal status should be Draft" $ P.do
-- s <- pmatch $ proposalParams.status -- s <- pmatch $ proposalParams.status
@ -348,9 +348,6 @@ governorValidator params =
-- PDraft _ -> pconstant True -- PDraft _ -> pconstant True
-- _ -> pconstant False -- _ -> pconstant False
passert "Proposal datum must be valid" $
proposalDatumValid # inputProposalDatum'
-- TODO: proposal impl not done yet -- TODO: proposal impl not done yet
ptraceError "Not implemented yet" ptraceError "Not implemented yet"
PMintGATs _ -> P.do PMintGATs _ -> P.do
@ -449,9 +446,6 @@ governorValidator params =
passert "Required amount of GATs should be minted" $ passert "Required amount of GATs should be minted" $
psymbolValueOf # pproposalSym # txInfo.mint #== gatCount psymbolValueOf # pproposalSym # txInfo.mint #== gatCount
passert "No token should be minted other than GAT" $
containsSingleCurrencySymbol # txInfo.mint
outputsWithGAT <- outputsWithGAT <-
plet $ plet $
pfilter pfilter
@ -486,9 +480,6 @@ governorValidator params =
# (pconstant ()) # (pconstant ())
# outputsWithGAT # outputsWithGAT
PMutateGovernor _ -> P.do PMutateGovernor _ -> P.do
passert "No token should be burnt other than GAT" $
containsSingleCurrencySymbol # txInfo.mint
popaque $ singleAuthorityTokenBurned pgatSym ctx.txInfo txInfo.mint popaque $ singleAuthorityTokenBurned pgatSym ctx.txInfo txInfo.mint
where where
stateTokenAssetClass :: AssetClass stateTokenAssetClass :: AssetClass