simplify code
Co-authored-by: Emily Martins <emi@haskell.fyi>
This commit is contained in:
parent
4dc311d370
commit
7294c01ebb
2 changed files with 6 additions and 14 deletions
|
|
@ -45,7 +45,7 @@ import Agora.AuthorityToken (
|
||||||
import Agora.Proposal (
|
import Agora.Proposal (
|
||||||
PProposalDatum (..),
|
PProposalDatum (..),
|
||||||
PProposalId,
|
PProposalId,
|
||||||
PProposalStatus (PDraft, PExecutable, PFinished),
|
PProposalStatus (PFinished),
|
||||||
PProposalThresholds,
|
PProposalThresholds,
|
||||||
Proposal (..),
|
Proposal (..),
|
||||||
ProposalId,
|
ProposalId,
|
||||||
|
|
@ -53,7 +53,7 @@ import Agora.Proposal (
|
||||||
pnextProposalId,
|
pnextProposalId,
|
||||||
proposalDatumValid,
|
proposalDatumValid,
|
||||||
proposalPolicy,
|
proposalPolicy,
|
||||||
proposalValidator,
|
proposalValidator,ProposalStatus (Draft, Executable)
|
||||||
)
|
)
|
||||||
import Agora.Utils (
|
import Agora.Utils (
|
||||||
findOutputsToAddress,
|
findOutputsToAddress,
|
||||||
|
|
@ -419,11 +419,7 @@ governorValidator gov =
|
||||||
|
|
||||||
-- TODO: should we check cosigners here?
|
-- TODO: should we check cosigners here?
|
||||||
|
|
||||||
let isProposalDraft = pmatch (pfromData proposalDatum.status) $ \case
|
passert "Proposal state should be draft" $ proposalDatum.status #== pconstantData Draft
|
||||||
PDraft _ -> pconstant True
|
|
||||||
_ -> pconstant False
|
|
||||||
|
|
||||||
passert "Proposal state should be draft" isProposalDraft
|
|
||||||
|
|
||||||
popaque $ pconstant ()
|
popaque $ pconstant ()
|
||||||
PMintGATs _ -> P.do
|
PMintGATs _ -> P.do
|
||||||
|
|
@ -480,11 +476,8 @@ governorValidator gov =
|
||||||
pletFields @'["id", "effects", "status", "cosigners", "thresholds", "votes"]
|
pletFields @'["id", "effects", "status", "cosigners", "thresholds", "votes"]
|
||||||
inputProposalDatum'
|
inputProposalDatum'
|
||||||
|
|
||||||
let isProposalExecutable = pmatch (pfromData inputProposalDatum.status) $ \case
|
passert "Proposal must be in executable state in order to execute effects" $
|
||||||
PExecutable _ -> pconstant True
|
inputProposalDatum.status #== pconstantData Executable
|
||||||
_ -> pconstant False
|
|
||||||
|
|
||||||
passert "Proposal must be in executable state in order to execute effects" isProposalExecutable
|
|
||||||
|
|
||||||
let expectedOutputDatum =
|
let expectedOutputDatum =
|
||||||
pforgetData $
|
pforgetData $
|
||||||
|
|
|
||||||
|
|
@ -530,9 +530,8 @@ hasOnlyOneTokenOfAssetClass' ac@(AssetClass (as, _)) = phoistAcyclic $
|
||||||
plam $ \vs -> P.do
|
plam $ \vs -> P.do
|
||||||
let ps = pconstant as
|
let ps = pconstant as
|
||||||
|
|
||||||
psymbolValueOf # ps # vs #== 1
|
hasOnlyOneTokenOfCurrencySymbol # ps # vs
|
||||||
#&& passetClassValueOf' ac # vs #== 1
|
#&& passetClassValueOf' ac # vs #== 1
|
||||||
#&& (plength #$ pto $ pto $ pto vs) #== 1
|
|
||||||
|
|
||||||
-- | The entire value only contains one token of the specific currency symbol.
|
-- | The entire value only contains one token of the specific currency symbol.
|
||||||
hasOnlyOneTokenOfCurrencySymbol :: Term s (PCurrencySymbol :--> PValue :--> PBool)
|
hasOnlyOneTokenOfCurrencySymbol :: Term s (PCurrencySymbol :--> PValue :--> PBool)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue