export PGovernorRedeemer

This commit is contained in:
fanghr 2022-04-15 13:11:48 +08:00
parent c432a06d5e
commit b546fc9701

View file

@ -15,6 +15,7 @@ module Agora.Governor (
-- * Plutarch-land -- * Plutarch-land
PGovernorDatum (..), PGovernorDatum (..),
PGovernorRedeemer (..),
-- * Scripts -- * Scripts
governorPolicy, governorPolicy,
@ -28,7 +29,7 @@ import Generics.SOP (Generic, I (I))
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
import Agora.Proposal (ProposalId, ProposalThresholds, PProposalThresholds, PProposalId) import Agora.Proposal (PProposalId, PProposalThresholds, ProposalId, ProposalThresholds)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -71,34 +72,36 @@ data GovernorRedeemer
| -- | Checks that a SINGLE proposal finished correctly, | -- | Checks that a SINGLE proposal finished correctly,
-- and allows minting GATs for each effect script. -- and allows minting GATs for each effect script.
MintGATs MintGATs
-- | Allow effects to mutate the datum | -- | Allow effects to mutate the datum
| MutateDatum MutateDatum
deriving stock (Show, GHC.Generic) deriving stock (Show, GHC.Generic)
PlutusTx.makeIsDataIndexed PlutusTx.makeIsDataIndexed
''GovernorRedeemer ''GovernorRedeemer
[('CreateProposal,0) [ ('CreateProposal, 0)
,('MintGATs, 1) , ('MintGATs, 1)
,('MutateDatum, 2) , ('MutateDatum, 2)
] ]
-- | Parameters for creating Governor scripts. -- | Parameters for creating Governor scripts.
data Governor data Governor = Governor
= Governor { { datumNFT :: AssetClass
-- | NFT that identifies the governor datum -- ^ NFT that identifies the governor datum
datumNFT :: AssetClass
} }
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- | Plutarch-level datum for the Governor script. -- | Plutarch-level datum for the Governor script.
newtype PGovernorDatum (s :: S) = PGovernorDatum
newtype PGovernorDatum (s::S)= PGovernorDatum { getGovernorDatum :: { getGovernorDatum ::
Term s (PDataRecord '[ Term
"proposalThresholds" ':= PProposalThresholds, s
"nextProposalId" ':= PProposalId ( PDataRecord
]) '[ "proposalThresholds" ':= PProposalThresholds
} , "nextProposalId" ':= PProposalId
]
)
}
deriving stock (GHC.Generic) deriving stock (GHC.Generic)
deriving anyclass (Generic) deriving anyclass (Generic)
deriving anyclass (PIsDataRepr) deriving anyclass (PIsDataRepr)
@ -110,9 +113,8 @@ instance PUnsafeLiftDecl PGovernorDatum where type PLifted PGovernorDatum = Gove
deriving via (DerivePConstantViaData GovernorDatum PGovernorDatum) instance (PConstant GovernorDatum) deriving via (DerivePConstantViaData GovernorDatum PGovernorDatum) instance (PConstant GovernorDatum)
-- | Plutarch-level version of 'GovernorRedeemer' -- | Plutarch-level version of 'GovernorRedeemer'
data PGovernorRedeemer (s :: S)
data PGovernorRedeemer (s :: S) = = PCreateProposal (Term s (PDataRecord '[]))
PCreateProposal (Term s (PDataRecord '[]))
| PMintGATs (Term s (PDataRecord '[])) | PMintGATs (Term s (PDataRecord '[]))
| PMutateDatum (Term s (PDataRecord '[])) | PMutateDatum (Term s (PDataRecord '[]))
deriving stock (GHC.Generic) deriving stock (GHC.Generic)