check proposal state is draft while creating a proposal
This commit is contained in:
parent
74b5e714da
commit
d3c05c1dc2
1 changed files with 19 additions and 18 deletions
|
|
@ -42,7 +42,7 @@ import Agora.AuthorityToken (
|
||||||
import Agora.Proposal (
|
import Agora.Proposal (
|
||||||
PProposalDatum,
|
PProposalDatum,
|
||||||
PProposalId,
|
PProposalId,
|
||||||
PProposalStatus (PExecutable, PFinished),
|
PProposalStatus (PExecutable, PFinished, PVotingReady, PDraft),
|
||||||
PProposalThresholds,
|
PProposalThresholds,
|
||||||
PProposalVotes (PProposalVotes),
|
PProposalVotes (PProposalVotes),
|
||||||
PResultTag (PResultTag),
|
PResultTag (PResultTag),
|
||||||
|
|
@ -328,28 +328,29 @@ governorValidator params =
|
||||||
passert "Proposal datum must be valid" $
|
passert "Proposal datum must be valid" $
|
||||||
proposalDatumValid # outputProposalDatum'
|
proposalDatumValid # outputProposalDatum'
|
||||||
|
|
||||||
proposalParams <-
|
proposalDatum <-
|
||||||
pletFields
|
pletFields
|
||||||
@'["id", "status", "cosigners", "thresholds", "votes"]
|
@'["id", "status", "cosigners", "thresholds", "votes"]
|
||||||
outputProposalDatum'
|
outputProposalDatum'
|
||||||
|
|
||||||
passert "Invalid proposal id in proposal datum" $
|
passert "Invalid proposal id in proposal datum" $
|
||||||
proposalParams.id #== oldParams.nextProposalId
|
proposalDatum.id #== oldParams.nextProposalId
|
||||||
|
|
||||||
passert "Invalid thresholds in proposal datum" $
|
passert "Invalid thresholds in proposal datum" $
|
||||||
proposalParams.thresholds #== oldParams.proposalThresholds
|
proposalDatum.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 proposalDatum.votes
|
||||||
|
|
||||||
-- passert "Initial proposal status should be Draft" $ P.do
|
-- TODO: should we check cosigners here?
|
||||||
-- s <- pmatch $ proposalParams.status
|
|
||||||
-- case s of
|
|
||||||
-- PDraft _ -> pconstant True
|
|
||||||
-- _ -> pconstant False
|
|
||||||
|
|
||||||
-- TODO: proposal impl not done yet
|
let isProposalDraft = pmatch (pfromData proposalDatum.status) $ \case
|
||||||
ptraceError "Not implemented yet"
|
PDraft _ -> pconstant True
|
||||||
|
_ -> pconstant False
|
||||||
|
|
||||||
|
passert "Proposal state should be draft" $ isProposalDraft
|
||||||
|
|
||||||
|
popaque $ pconstant ()
|
||||||
PMintGATs _ -> P.do
|
PMintGATs _ -> P.do
|
||||||
passert "Governor state should not be changed" $
|
passert "Governor state should not be changed" $
|
||||||
-- FIXME: There should be a better way to do this
|
-- FIXME: There should be a better way to do this
|
||||||
|
|
@ -404,11 +405,11 @@ governorValidator params =
|
||||||
pletFields @'["id", "effects", "status", "cosigners", "thresholds", "votes"]
|
pletFields @'["id", "effects", "status", "cosigners", "thresholds", "votes"]
|
||||||
inputProposalDatum'
|
inputProposalDatum'
|
||||||
|
|
||||||
let isExecutable = pmatch (pfromData inputProposalDatum.status) $ \case
|
let isProposalExecutable = pmatch (pfromData inputProposalDatum.status) $ \case
|
||||||
PExecutable _ -> pconstant True
|
PExecutable _ -> pconstant True
|
||||||
_ -> pconstant False
|
_ -> pconstant False
|
||||||
|
|
||||||
passert "Proposal must be in executable state in order to execute effects" $ isExecutable
|
passert "Proposal must be in executable state in order to execute effects" $ isProposalExecutable
|
||||||
|
|
||||||
let fields =
|
let fields =
|
||||||
pdcons @"id" # inputProposalDatum.id
|
pdcons @"id" # inputProposalDatum.id
|
||||||
|
|
@ -485,8 +486,8 @@ governorValidator params =
|
||||||
stateTokenAssetClass :: AssetClass
|
stateTokenAssetClass :: AssetClass
|
||||||
stateTokenAssetClass = governorStateTokenAssetClass params
|
stateTokenAssetClass = governorStateTokenAssetClass params
|
||||||
|
|
||||||
proposalParams :: Proposal
|
proposalDatum :: Proposal
|
||||||
proposalParams =
|
proposalDatum =
|
||||||
Proposal
|
Proposal
|
||||||
{ governorSTAssetClass = stateTokenAssetClass
|
{ governorSTAssetClass = stateTokenAssetClass
|
||||||
}
|
}
|
||||||
|
|
@ -495,7 +496,7 @@ governorValidator params =
|
||||||
proposalSymbol = mintingPolicySymbol policy
|
proposalSymbol = mintingPolicySymbol policy
|
||||||
where
|
where
|
||||||
policy :: MintingPolicy
|
policy :: MintingPolicy
|
||||||
policy = mkMintingPolicy $ proposalPolicy proposalParams
|
policy = mkMintingPolicy $ proposalPolicy proposalDatum
|
||||||
|
|
||||||
pproposalSym :: Term s PCurrencySymbol
|
pproposalSym :: Term s PCurrencySymbol
|
||||||
pproposalSym = phoistAcyclic $ pconstant proposalSymbol
|
pproposalSym = phoistAcyclic $ pconstant proposalSymbol
|
||||||
|
|
@ -507,7 +508,7 @@ governorValidator params =
|
||||||
hash = validatorHash validator
|
hash = validatorHash validator
|
||||||
|
|
||||||
validator :: Validator
|
validator :: Validator
|
||||||
validator = mkValidator $ proposalValidator proposalParams
|
validator = mkValidator $ proposalValidator proposalDatum
|
||||||
|
|
||||||
pproposalValidatorAddress :: Term s PAddress
|
pproposalValidatorAddress :: Term s PAddress
|
||||||
pproposalValidatorAddress = phoistAcyclic $ pconstant proposalValidatorAddress
|
pproposalValidatorAddress = phoistAcyclic $ pconstant proposalValidatorAddress
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue