pattern match on PGovernorRedeemer directly
This commit is contained in:
parent
139f8add30
commit
00a3931df8
1 changed files with 7 additions and 9 deletions
|
|
@ -21,8 +21,8 @@ import Agora.AuthorityToken (
|
||||||
singleAuthorityTokenBurned,
|
singleAuthorityTokenBurned,
|
||||||
)
|
)
|
||||||
import Agora.Governor (
|
import Agora.Governor (
|
||||||
GovernorRedeemer (..),
|
|
||||||
PGovernorDatum (PGovernorDatum),
|
PGovernorDatum (PGovernorDatum),
|
||||||
|
PGovernorRedeemer (..),
|
||||||
pgetNextProposalId,
|
pgetNextProposalId,
|
||||||
pisGovernorDatumValid,
|
pisGovernorDatumValid,
|
||||||
)
|
)
|
||||||
|
|
@ -71,7 +71,6 @@ import Plutarch.Api.V2 (
|
||||||
import Plutarch.Builtin (ppairDataBuiltin)
|
import Plutarch.Builtin (ppairDataBuiltin)
|
||||||
import Plutarch.Extra.AssetClass (passetClass, passetClassValueOf)
|
import Plutarch.Extra.AssetClass (passetClass, passetClassValueOf)
|
||||||
import Plutarch.Extra.Field (pletAllC)
|
import Plutarch.Extra.Field (pletAllC)
|
||||||
import Plutarch.Extra.IsData (pmatchEnumFromData)
|
|
||||||
import Plutarch.Extra.List (pfirstJust)
|
import Plutarch.Extra.List (pfirstJust)
|
||||||
import Plutarch.Extra.Map (
|
import Plutarch.Extra.Map (
|
||||||
plookup,
|
plookup,
|
||||||
|
|
@ -253,6 +252,8 @@ governorValidator as =
|
||||||
plam $ \datum' redeemer' ctx' -> unTermCont $ do
|
plam $ \datum' redeemer' ctx' -> unTermCont $ do
|
||||||
ctxF <- pletAllC ctx'
|
ctxF <- pletAllC ctx'
|
||||||
|
|
||||||
|
redeemer <- pfromData . fst <$> ptryFromC redeemer'
|
||||||
|
|
||||||
txInfo' <- pletC $ pfromData $ ctxF.txInfo
|
txInfo' <- pletC $ pfromData $ ctxF.txInfo
|
||||||
txInfoF <- pletFieldsC @'["mint", "inputs", "outputs", "datums", "signatories", "validRange"] txInfo'
|
txInfoF <- pletFieldsC @'["mint", "inputs", "outputs", "datums", "signatories", "validRange"] txInfo'
|
||||||
|
|
||||||
|
|
@ -289,8 +290,8 @@ governorValidator as =
|
||||||
pguardC "New datum is valid" $ pisGovernorDatumValid # newGovernorDatum
|
pguardC "New datum is valid" $ pisGovernorDatumValid # newGovernorDatum
|
||||||
|
|
||||||
pure $
|
pure $
|
||||||
pmatchEnumFromData redeemer' $ \case
|
pmatch redeemer $ \case
|
||||||
Just CreateProposal -> unTermCont $ do
|
PCreateProposal -> unTermCont $ do
|
||||||
-- Check that the transaction advances proposal id.
|
-- Check that the transaction advances proposal id.
|
||||||
|
|
||||||
let expectedNextProposalId = pgetNextProposalId # oldGovernorDatumF.nextProposalId
|
let expectedNextProposalId = pgetNextProposalId # oldGovernorDatumF.nextProposalId
|
||||||
|
|
@ -435,7 +436,7 @@ governorValidator as =
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
Just MintGATs -> unTermCont $ do
|
PMintGATs -> unTermCont $ do
|
||||||
pguardC "Governor state should not be changed" $ newGovernorDatum #== oldGovernorDatum
|
pguardC "Governor state should not be changed" $ newGovernorDatum #== oldGovernorDatum
|
||||||
|
|
||||||
-- Filter out proposal inputs and ouputs using PST and the address of proposal validator.
|
-- Filter out proposal inputs and ouputs using PST and the address of proposal validator.
|
||||||
|
|
@ -560,15 +561,12 @@ governorValidator as =
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
|
||||||
Just MutateGovernor -> unTermCont $ do
|
PMutateGovernor -> unTermCont $ do
|
||||||
-- Check that a GAT is burnt.
|
-- Check that a GAT is burnt.
|
||||||
pguardC "One valid GAT burnt" $
|
pguardC "One valid GAT burnt" $
|
||||||
singleAuthorityTokenBurned atSymbol txInfoF.inputs txInfoF.mint
|
singleAuthorityTokenBurned atSymbol txInfoF.inputs txInfoF.mint
|
||||||
|
|
||||||
pure $ popaque $ pconstant ()
|
pure $ popaque $ pconstant ()
|
||||||
|
|
||||||
--------------------------------------------------------------------------
|
|
||||||
Nothing -> ptraceError "Unknown redeemer"
|
|
||||||
where
|
where
|
||||||
-- The currency symbol of authority token.
|
-- The currency symbol of authority token.
|
||||||
atSymbol :: forall (s :: S). Term s PCurrencySymbol
|
atSymbol :: forall (s :: S). Term s PCurrencySymbol
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue