modify GovernorRedeemer and Governor
* add `MutateDatum` redeemer * add `datumNFT` to `Governor` so that we can identify the datum * Lift `GovernorDatum` and `GovernorRedeemer`
This commit is contained in:
parent
1ce89d3ac6
commit
5ace88290d
1 changed files with 32 additions and 3 deletions
|
|
@ -20,17 +20,35 @@ module Agora.Governor (
|
||||||
governorValidator,
|
governorValidator,
|
||||||
) where
|
) where
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import GHC.Generics qualified as GHC
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
import Agora.Proposal (ProposalId, ProposalThresholds)
|
import Agora.Proposal (ProposalId, ProposalThresholds)
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import Plutarch (popaque)
|
||||||
import Plutarch.Api.V1 (PMintingPolicy, PValidator)
|
import Plutarch.Api.V1 (PMintingPolicy, PValidator)
|
||||||
import PlutusTx qualified
|
import PlutusTx qualified
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import Plutus.V1.Ledger.Value (AssetClass)
|
||||||
|
import PlutusTx qualified
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
-- | Datum for the Governor script.
|
-- | Datum for the Governor script.
|
||||||
data GovernorDatum = GovernorDatum
|
data GovernorDatum = GovernorDatum
|
||||||
{ proposalThresholds :: ProposalThresholds
|
{ proposalThresholds :: ProposalThresholds
|
||||||
-- ^ Gets copied over upon creation of a 'Agora.Proposal.ProposalDatum'.
|
-- ^ Gets copied over upon creation of a 'Agora.Proposal.ProposalDatum'.
|
||||||
, nextProposalId :: ProposalId
|
, nextProposalId :: ProposalId
|
||||||
-- ^ What tag the next proposal will get upon creating.
|
-- ^ What tag the next proposal will get upon creating.
|
||||||
}
|
}
|
||||||
|
deriving stock (Show, GHC.Generic)
|
||||||
|
|
||||||
PlutusTx.makeIsDataIndexed ''GovernorDatum [('GovernorDatum, 0)]
|
PlutusTx.makeIsDataIndexed ''GovernorDatum [('GovernorDatum, 0)]
|
||||||
|
|
||||||
|
|
@ -46,12 +64,23 @@ 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
|
||||||
|
| MutateDatum
|
||||||
|
deriving stock (Show, GHC.Generic)
|
||||||
|
|
||||||
PlutusTx.makeIsDataIndexed ''GovernorRedeemer [('CreateProposal, 0), ('MintGATs, 1)]
|
PlutusTx.makeIsDataIndexed
|
||||||
|
''GovernorRedeemer
|
||||||
|
[('CreateProposal,0)
|
||||||
|
,('MintGATs, 1)
|
||||||
|
,('MutateDatum, 2)
|
||||||
|
]
|
||||||
|
|
||||||
-- | Parameters for creating Governor scripts.
|
-- | Parameters for creating Governor scripts.
|
||||||
data Governor
|
data Governor
|
||||||
= Governor
|
= Governor {
|
||||||
|
-- | NFT that identifies the governor datum
|
||||||
|
datumNFT :: AssetClass
|
||||||
|
}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue