encode some enum types as integer on chain

This commit is contained in:
Hongrui Fang 2022-06-23 19:24:36 +08:00
parent 6fe5e2b78a
commit 516f6bacda
6 changed files with 140 additions and 117 deletions

View file

@ -45,6 +45,11 @@ import Plutarch.DataRepr (
PIsDataReprInstances (PIsDataReprInstances), PIsDataReprInstances (PIsDataReprInstances),
) )
import Plutarch.Extra.Comonad (pextract) import Plutarch.Extra.Comonad (pextract)
import Plutarch.Extra.IsData (
DerivePConstantViaEnum (..),
EnumIsData (..),
)
import Plutarch.Extra.Other (DerivePNewtype' (..))
import Plutarch.Extra.TermCont (pletC, pletFieldsC, pmatchC) import Plutarch.Extra.TermCont (pletC, pletFieldsC, pmatchC)
import Plutarch.Lift (PConstantDecl, PUnsafeLiftDecl (..)) import Plutarch.Lift (PConstantDecl, PUnsafeLiftDecl (..))
import Plutarch.SafeMoney (PDiscrete (..)) import Plutarch.SafeMoney (PDiscrete (..))
@ -92,15 +97,27 @@ data GovernorRedeemer
MintGATs MintGATs
| -- | Allows effects to mutate the parameters. | -- | Allows effects to mutate the parameters.
MutateGovernor MutateGovernor
deriving stock (Show, GHC.Generic) deriving stock
( -- | @since 0.1.0
-- | @since 0.1.0 Show
PlutusTx.makeIsDataIndexed , -- | @since 0.1.0
''GovernorRedeemer GHC.Generic
[ ('CreateProposal, 0) , -- | @since 0.2.0
, ('MintGATs, 1) Enum
, ('MutateGovernor, 2) , -- | @since 0.2.0
] Bounded
)
deriving anyclass
( -- | @since 0.2.0
Generic
)
deriving
( -- | @since 0.1.0
PlutusTx.ToData
, -- | @since 0.1.0
PlutusTx.FromData
)
via (EnumIsData GovernorRedeemer)
{- | Parameters for creating Governor scripts. {- | Parameters for creating Governor scripts.
@ -172,10 +189,8 @@ deriving via PAsData (PIsDataReprInstances PGovernorDatum) instance PTryFrom PDa
@since 0.1.0 @since 0.1.0
-} -}
data PGovernorRedeemer (s :: S) newtype PGovernorRedeemer (s :: S)
= PCreateProposal (Term s (PDataRecord '[])) = PGovernorRedeemer (Term s PInteger)
| PMintGATs (Term s (PDataRecord '[]))
| PMutateGovernor (Term s (PDataRecord '[]))
deriving stock deriving stock
( -- | @since 0.1.0 ( -- | @since 0.1.0
GHC.Generic GHC.Generic
@ -184,26 +199,19 @@ data PGovernorRedeemer (s :: S)
( -- | @since 0.1.0 ( -- | @since 0.1.0
Generic Generic
) )
deriving anyclass
( -- | @since 0.1.0
PIsDataRepr
)
deriving deriving
( -- | @since 0.1.0 ( -- | @since 0.1.0
PlutusType PlutusType
, -- | @since 0.1.0 , -- | @since 0.1.0
PIsData PIsData
) )
via PIsDataReprInstances PGovernorRedeemer via (DerivePNewtype' PGovernorRedeemer)
-- | @since 0.1.0 -- | @since 0.1.0
instance PUnsafeLiftDecl PGovernorRedeemer where type PLifted PGovernorRedeemer = GovernorRedeemer instance PUnsafeLiftDecl PGovernorRedeemer where type PLifted PGovernorRedeemer = GovernorRedeemer
-- | @since 0.1.0 -- | @since 0.1.0
deriving via (DerivePConstantViaData GovernorRedeemer PGovernorRedeemer) instance (PConstantDecl GovernorRedeemer) deriving via (DerivePConstantViaEnum GovernorRedeemer PGovernorRedeemer) instance (PConstantDecl GovernorRedeemer)
-- | @since 0.1.0
deriving via PAsData (PIsDataReprInstances PGovernorRedeemer) instance PTryFrom PData (PAsData PGovernorRedeemer)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View file

@ -39,18 +39,17 @@ import Agora.AuthorityToken (
) )
import Agora.Governor ( import Agora.Governor (
Governor (gstOutRef, gtClassRef, maximumCosigners), Governor (gstOutRef, gtClassRef, maximumCosigners),
GovernorRedeemer (..),
PGovernorDatum (PGovernorDatum), PGovernorDatum (PGovernorDatum),
PGovernorRedeemer (PCreateProposal, PMintGATs, PMutateGovernor),
governorDatumValid, governorDatumValid,
pgetNextProposalId, pgetNextProposalId,
) )
import Agora.Proposal ( import Agora.Proposal (
PProposalDatum (..), PProposalDatum (..),
PProposalId (..), PProposalId (..),
PProposalStatus (PFinished),
PResultTag, PResultTag,
Proposal (..), Proposal (..),
ProposalStatus (Draft, Locked), ProposalStatus (Draft, Finished, Locked),
pemptyVotesFor, pemptyVotesFor,
pneutralOption, pneutralOption,
proposalDatumValid, proposalDatumValid,
@ -105,20 +104,20 @@ import Plutarch.Api.V1.AssetClass (
passetClass, passetClass,
passetClassValueOf, passetClassValueOf,
) )
import Plutarch.Api.V1.ScriptContext (pfindTxInByTxOutRef, pisUTXOSpent, ptryFindDatum, ptxSignedBy, pvalueSpent)
import "liqwid-plutarch-extra" Plutarch.Api.V1.Value (psymbolValueOf)
import Plutarch.Extra.IsData (pmatchEnumFromData)
import Plutarch.Extra.Map ( import Plutarch.Extra.Map (
pkeys, pkeys,
plookup, plookup,
plookup', plookup',
) )
import Plutarch.Extra.Maybe (pisDJust)
import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC, ptryFromC)
import Plutarch.SafeMoney (PDiscrete (..), pvalueDiscrete') import Plutarch.SafeMoney (PDiscrete (..), pvalueDiscrete')
import Plutarch.TryFrom ()
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
import Plutarch.Api.V1.ScriptContext (pfindTxInByTxOutRef, pisUTXOSpent, ptryFindDatum, ptxSignedBy, pvalueSpent)
import "liqwid-plutarch-extra" Plutarch.Api.V1.Value (psymbolValueOf)
import Plutarch.Extra.Maybe (pisDJust)
import Plutarch.Extra.TermCont
import PlutusLedgerApi.V1 ( import PlutusLedgerApi.V1 (
CurrencySymbol (..), CurrencySymbol (..),
MintingPolicy, MintingPolicy,
@ -280,7 +279,6 @@ governorPolicy gov =
governorValidator :: Governor -> ClosedTerm PValidator governorValidator :: Governor -> ClosedTerm PValidator
governorValidator gov = governorValidator gov =
plam $ \datum' redeemer' ctx' -> unTermCont $ do plam $ \datum' redeemer' ctx' -> unTermCont $ do
(pfromData -> redeemer, _) <- ptryFromC redeemer'
ctxF <- pletFieldsC @'["txInfo", "purpose"] ctx' ctxF <- pletFieldsC @'["txInfo", "purpose"] ctx'
txInfo' <- pletC $ pfromData $ ctxF.txInfo txInfo' <- pletC $ pfromData $ ctxF.txInfo
@ -330,8 +328,8 @@ governorValidator gov =
pguardC "New datum is not valid" $ governorDatumValid # newGovernorDatum pguardC "New datum is not valid" $ governorDatumValid # newGovernorDatum
pure $ pure $
pmatch redeemer $ \case pmatchEnumFromData redeemer' $ \case
PCreateProposal _ -> unTermCont $ do Just CreateProposal -> 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
@ -516,7 +514,7 @@ governorValidator gov =
-------------------------------------------------------------------------- --------------------------------------------------------------------------
PMintGATs _ -> unTermCont $ do Just MintGATs -> 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.
@ -583,7 +581,7 @@ governorValidator gov =
PProposalDatum PProposalDatum
( #proposalId .= proposalInputDatumF.proposalId ( #proposalId .= proposalInputDatumF.proposalId
.& #effects .= proposalInputDatumF.effects .& #effects .= proposalInputDatumF.effects
.& #status .= pdata (pcon $ PFinished pdnil) .& #status .= pconstantData Finished
.& #cosigners .= proposalInputDatumF.cosigners .& #cosigners .= proposalInputDatumF.cosigners
.& #thresholds .= proposalInputDatumF.thresholds .& #thresholds .= proposalInputDatumF.thresholds
.& #votes .= proposalInputDatumF.votes .& #votes .= proposalInputDatumF.votes
@ -667,9 +665,12 @@ governorValidator gov =
-------------------------------------------------------------------------- --------------------------------------------------------------------------
PMutateGovernor _ -> unTermCont $ do Just MutateGovernor -> unTermCont $ do
-- Check that a GAT is burnt. -- Check that a GAT is burnt.
pure $ popaque $ singleAuthorityTokenBurned patSymbol ctxF.txInfo txInfoF.mint pure $ popaque $ singleAuthorityTokenBurned patSymbol ctxF.txInfo txInfoF.mint
--------------------------------------------------------------------------
Nothing -> ptraceError "Unknown redeemer"
where where
-- Get th amount of governance tokens in a value. -- Get th amount of governance tokens in a value.
pgtValueOf :: Term s (PValue _ _ :--> PDiscrete GTTag) pgtValueOf :: Term s (PValue _ _ :--> PDiscrete GTTag)

View file

@ -51,9 +51,14 @@ import Plutarch.Api.V1 (
PValidatorHash, PValidatorHash,
) )
import Plutarch.DataRepr (DerivePConstantViaData (..), PDataFields, PIsDataReprInstances (..)) import Plutarch.DataRepr (DerivePConstantViaData (..), PDataFields, PIsDataReprInstances (..))
import Plutarch.Extra.IsData (
DerivePConstantViaEnum (..),
EnumIsData (..),
)
import Plutarch.Extra.List (pnotNull) import Plutarch.Extra.List (pnotNull)
import Plutarch.Extra.Map qualified as PM import Plutarch.Extra.Map qualified as PM
import Plutarch.Extra.Map.Unsorted qualified as PUM import Plutarch.Extra.Map.Unsorted qualified as PUM
import Plutarch.Extra.Other (DerivePNewtype' (..))
import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC) import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC)
import Plutarch.Lift ( import Plutarch.Lift (
DerivePConstantViaNewtype (..), DerivePConstantViaNewtype (..),
@ -173,10 +178,24 @@ data ProposalStatus
Show Show
, -- | @since 0.1.0 , -- | @since 0.1.0
GHC.Generic GHC.Generic
, -- | @since 0.2.0
Enum
, -- | @since 0.2.0
Bounded
) )
deriving anyclass
-- | @since 0.1.0 ( -- | @since 0.2.0
PlutusTx.makeIsDataIndexed ''ProposalStatus [('Draft, 0), ('VotingReady, 1), ('Locked, 2), ('Finished, 3)] Generic
)
deriving
( -- | @since 0.1.0
PlutusTx.FromData
, -- | @since 0.1.0
PlutusTx.ToData
, -- | @since 0.1.0
PlutusTx.UnsafeFromData
)
via (EnumIsData ProposalStatus)
{- | The threshold values for various state transitions to happen. {- | The threshold values for various state transitions to happen.
This data is stored centrally (in the 'Agora.Governor.Governor') and copied over This data is stored centrally (in the 'Agora.Governor.Governor') and copied over
@ -433,13 +452,7 @@ deriving via
@since 0.1.0 @since 0.1.0
-} -}
data PProposalStatus (s :: S) newtype PProposalStatus (s :: S) = PProposalStatus (Term s PInteger)
= -- TODO: 'PProposalStatus' ought te be encoded as 'PInteger'.
-- e.g. like Tilde used 'pmatchEnum'.
PDraft (Term s (PDataRecord '[]))
| PVotingReady (Term s (PDataRecord '[]))
| PLocked (Term s (PDataRecord '[]))
| PFinished (Term s (PDataRecord '[]))
deriving stock deriving stock
( -- | @since 0.1.0 ( -- | @since 0.1.0
GHC.Generic GHC.Generic
@ -448,10 +461,6 @@ data PProposalStatus (s :: S)
( -- | @since 0.1.0 ( -- | @since 0.1.0
Generic Generic
) )
deriving anyclass
( -- | @since 0.1.0
PIsDataRepr
)
deriving deriving
( -- | @since 0.1.0 ( -- | @since 0.1.0
PlutusType PlutusType
@ -460,16 +469,16 @@ data PProposalStatus (s :: S)
, -- | @since 0.1.0 , -- | @since 0.1.0
PEq PEq
) )
via PIsDataReprInstances PProposalStatus via (DerivePNewtype' PProposalStatus)
-- | @since 0.1.0 -- | @since 0.1.0
instance PUnsafeLiftDecl PProposalStatus where type PLifted PProposalStatus = ProposalStatus instance PUnsafeLiftDecl PProposalStatus where type PLifted PProposalStatus = ProposalStatus
-- | @since 0.1.0 -- | @since 0.1.0
deriving via PAsData (PIsDataReprInstances PProposalStatus) instance PTryFrom PData (PAsData PProposalStatus) deriving via PAsData (DerivePNewtype' PProposalStatus) instance PTryFrom PData (PAsData PProposalStatus)
-- | @since 0.1.0 -- | @since 0.1.0
deriving via (DerivePConstantViaData ProposalStatus PProposalStatus) instance (PConstantDecl ProposalStatus) deriving via (DerivePConstantViaEnum ProposalStatus PProposalStatus) instance (PConstantDecl ProposalStatus)
{- | Plutarch-level version of 'ProposalThresholds'. {- | Plutarch-level version of 'ProposalThresholds'.

View file

@ -13,7 +13,6 @@ module Agora.Proposal.Scripts (
import Agora.Proposal ( import Agora.Proposal (
PProposalDatum (PProposalDatum), PProposalDatum (PProposalDatum),
PProposalRedeemer (..), PProposalRedeemer (..),
PProposalStatus (..),
PProposalVotes (PProposalVotes), PProposalVotes (PProposalVotes),
Proposal (governorSTAssetClass, stakeSTAssetClass), Proposal (governorSTAssetClass, stakeSTAssetClass),
ProposalStatus (..), ProposalStatus (..),
@ -55,6 +54,7 @@ import Plutarch.Api.V1.ScriptContext (
) )
import "liqwid-plutarch-extra" Plutarch.Api.V1.Value (psymbolValueOf) import "liqwid-plutarch-extra" Plutarch.Api.V1.Value (psymbolValueOf)
import Plutarch.Extra.Comonad (pextract) import Plutarch.Extra.Comonad (pextract)
import Plutarch.Extra.IsData (pmatchEnum)
import Plutarch.Extra.List (pisUniqBy) import Plutarch.Extra.List (pisUniqBy)
import Plutarch.Extra.Map (plookup, pupdate) import Plutarch.Extra.Map (plookup, pupdate)
import Plutarch.Extra.Maybe (pisJust) import Plutarch.Extra.Maybe (pisJust)
@ -510,19 +510,21 @@ proposalValidator proposal =
inLockedPeriod <- pletC $ isLockingPeriod # proposalF.timingConfig # proposalF.startingTime # currentTime inLockedPeriod <- pletC $ isLockingPeriod # proposalF.timingConfig # proposalF.startingTime # currentTime
inExecutionPeriod <- pletC $ isExecutionPeriod # proposalF.timingConfig # proposalF.startingTime # currentTime inExecutionPeriod <- pletC $ isExecutionPeriod # proposalF.timingConfig # proposalF.startingTime # currentTime
proposalStatus <- pletC $ pto $ pfromData proposalF.status
-- Check the timings. -- Check the timings.
let isFinished = proposalF.status #== pconstantData Finished let isFinished = proposalF.status #== pconstantData Finished
notTooLate = pmatch (pfromData proposalF.status) $ \case notTooLate = pmatchEnum proposalStatus $ \case
PDraft _ -> inDraftPeriod Draft -> inDraftPeriod
-- Can only advance after the voting period is over. -- Can only advance after the voting period is over.
PVotingReady _ -> inLockedPeriod VotingReady -> inLockedPeriod
PLocked _ -> inExecutionPeriod Locked -> inExecutionPeriod
_ -> pconstant False _ -> pconstant False
notTooEarly = pmatch (pfromData proposalF.status) $ \case notTooEarly = pmatchEnum (pto $ pfromData proposalF.status) $ \case
PVotingReady _ -> pnot # inVotingPeriod VotingReady -> pnot # inVotingPeriod
PLocked _ -> pnot # inLockedPeriod Locked -> pnot # inLockedPeriod
_ -> pconstant True _ -> pconstant True
pguardC "Cannot advance ahead of time" notTooEarly pguardC "Cannot advance ahead of time" notTooEarly
@ -534,8 +536,8 @@ proposalValidator proposal =
pif pif
notTooLate notTooLate
-- On time: advance to next status. -- On time: advance to next status.
( pmatch (pfromData proposalF.status) $ \case ( pmatchEnum proposalStatus $ \case
PDraft _ -> unTermCont $ do Draft -> unTermCont $ do
-- TODO: Perform other necessary checks. -- TODO: Perform other necessary checks.
-- 'Draft' -> 'VotingReady' -- 'Draft' -> 'VotingReady'
@ -543,7 +545,7 @@ proposalValidator proposal =
proposalOutStatus #== pconstantData VotingReady proposalOutStatus #== pconstantData VotingReady
pure $ popaque (pconstant ()) pure $ popaque (pconstant ())
PVotingReady _ -> unTermCont $ do VotingReady -> unTermCont $ do
-- 'VotingReady' -> 'Locked' -- 'VotingReady' -> 'Locked'
pguardC "Proposal status set to Locked" $ pguardC "Proposal status set to Locked" $
proposalOutStatus #== pconstantData Locked proposalOutStatus #== pconstantData Locked
@ -554,7 +556,7 @@ proposalValidator proposal =
$ pfromData thresholdsF.execute $ pfromData thresholdsF.execute
pure $ popaque (pconstant ()) pure $ popaque (pconstant ())
PLocked _ -> unTermCont $ do Locked -> unTermCont $ do
-- 'Locked' -> 'Finished' -- 'Locked' -> 'Finished'
pguardC "Proposal status set to Finished" $ pguardC "Proposal status set to Finished" $
proposalOutStatus #== pconstantData Finished proposalOutStatus #== pconstantData Finished

View file

@ -12,15 +12,13 @@ module Agora.Treasury (module Agora.Treasury) where
import Agora.AuthorityToken (singleAuthorityTokenBurned) import Agora.AuthorityToken (singleAuthorityTokenBurned)
import GHC.Generics qualified as GHC import GHC.Generics qualified as GHC
import Generics.SOP (Generic, I (I)) import Generics.SOP (Generic)
import Plutarch.Api.V1 (PValidator) import Plutarch.Api.V1 (PValidator)
import Plutarch.Api.V1.Contexts (PScriptPurpose (PMinting)) import Plutarch.Api.V1.Contexts (PScriptPurpose (PMinting))
import "plutarch" Plutarch.Api.V1.Value (PValue) import "plutarch" Plutarch.Api.V1.Value (PValue)
import Plutarch.DataRepr ( import Plutarch.Extra.IsData (DerivePConstantViaEnum (..), EnumIsData (..), pmatchEnumFromData)
DerivePConstantViaData (..), import Plutarch.Extra.Other (DerivePNewtype' (..))
PIsDataReprInstances (PIsDataReprInstances), import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC)
)
import Plutarch.Extra.TermCont (pguardC, pletC, pletFieldsC, pmatchC, ptryFromC)
import Plutarch.Lift (PConstantDecl (..), PLifted (..), PUnsafeLiftDecl) import Plutarch.Lift (PConstantDecl (..), PLifted (..), PUnsafeLiftDecl)
import Plutarch.TryFrom () import Plutarch.TryFrom ()
import PlutusLedgerApi.V1.Value (CurrencySymbol) import PlutusLedgerApi.V1.Value (CurrencySymbol)
@ -40,13 +38,22 @@ data TreasuryRedeemer
Show Show
, -- | @since 0.1.0 , -- | @since 0.1.0
GHC.Generic GHC.Generic
, -- | @since 0.2.0
Enum
, -- | @since 0.2.0
Bounded
) )
deriving anyclass
-- | @since 0.1.0 ( -- | @since 0.2.0
PlutusTx.makeIsDataIndexed Generic
''TreasuryRedeemer )
[ ('SpendTreasuryGAT, 0) deriving
] ( -- | @since 0.1.0
PlutusTx.ToData
, -- | @since 0.1.0
PlutusTx.FromData
)
via (EnumIsData TreasuryRedeemer)
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -56,9 +63,7 @@ PlutusTx.makeIsDataIndexed
@since 0.1.0 @since 0.1.0
-} -}
newtype PTreasuryRedeemer (s :: S) newtype PTreasuryRedeemer (s :: S)
= -- | Alters treasury parameters, subject to the burning of a = PTreasuryRedeemer (Term s PInteger)
-- governance authority token.
PSpendTreasuryGAT (Term s (PDataRecord '[]))
deriving stock deriving stock
( -- | @since 0.1.0 ( -- | @since 0.1.0
GHC.Generic GHC.Generic
@ -66,8 +71,6 @@ newtype PTreasuryRedeemer (s :: S)
deriving anyclass deriving anyclass
( -- | @since 0.1.0 ( -- | @since 0.1.0
Generic Generic
, -- | @since 0.1.0
PIsDataRepr
) )
deriving deriving
( -- | @since 0.1.0 ( -- | @since 0.1.0
@ -75,13 +78,7 @@ newtype PTreasuryRedeemer (s :: S)
, -- | @since 0.1.0 , -- | @since 0.1.0
PIsData PIsData
) )
via PIsDataReprInstances PTreasuryRedeemer via (DerivePNewtype' PTreasuryRedeemer)
-- | @since 0.1.0
deriving via
PAsData (PIsDataReprInstances PTreasuryRedeemer)
instance
PTryFrom PData (PAsData PTreasuryRedeemer)
-- | @since 0.1.0 -- | @since 0.1.0
instance PUnsafeLiftDecl PTreasuryRedeemer where instance PUnsafeLiftDecl PTreasuryRedeemer where
@ -89,7 +86,7 @@ instance PUnsafeLiftDecl PTreasuryRedeemer where
-- | @since 0.1.0 -- | @since 0.1.0
deriving via deriving via
(DerivePConstantViaData TreasuryRedeemer PTreasuryRedeemer) (DerivePConstantViaEnum TreasuryRedeemer PTreasuryRedeemer)
instance instance
(PConstantDecl TreasuryRedeemer) (PConstantDecl TreasuryRedeemer)
@ -105,8 +102,6 @@ treasuryValidator ::
CurrencySymbol -> CurrencySymbol ->
ClosedTerm PValidator ClosedTerm PValidator
treasuryValidator gatCs' = plam $ \_datum redeemer ctx' -> unTermCont $ do treasuryValidator gatCs' = plam $ \_datum redeemer ctx' -> unTermCont $ do
(treasuryRedeemer, _) <- ptryFromC redeemer
-- plet required fields from script context. -- plet required fields from script context.
ctx <- pletFieldsC @["txInfo", "purpose"] ctx' ctx <- pletFieldsC @["txInfo", "purpose"] ctx'
@ -114,7 +109,15 @@ treasuryValidator gatCs' = plam $ \_datum redeemer ctx' -> unTermCont $ do
PMinting _ <- pmatchC ctx.purpose PMinting _ <- pmatchC ctx.purpose
-- Ensure redeemer type is valid. -- Ensure redeemer type is valid.
PSpendTreasuryGAT _ <- pmatchC $ pfromData treasuryRedeemer let redeemerValid =
pmatchEnumFromData
redeemer
( \case
Just SpendTreasuryGAT -> pconstant True
_ -> pconstant False
)
pguardC "Redeemer should be SpendTreasuryGAT" redeemerValid
-- Get the minted value from txInfo. -- Get the minted value from txInfo.
txInfo' <- pletC ctx.txInfo txInfo' <- pletC ctx.txInfo

View file

@ -2,36 +2,36 @@ name,cpu,mem,size
Agora/Effects/Treasury Withdrawal Effect/effect/Simple,333327612,830203,3674 Agora/Effects/Treasury Withdrawal Effect/effect/Simple,333327612,830203,3674
Agora/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries ,492387542,1197315,3986 Agora/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries ,492387542,1197315,3986
Agora/Effects/Treasury Withdrawal Effect/effect/Mixed Assets,456007605,1104500,3859 Agora/Effects/Treasury Withdrawal Effect/effect/Mixed Assets,456007605,1104500,3859
Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/governor validator should pass,90397270,249528,8807 Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/governor validator should pass,87839169,243032,8733
Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/effect validator should pass,106082031,292993,3609 Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/effect validator should pass,106082031,292993,3609
Agora/Stake/policy/stakeCreation,52241265,152127,2514 Agora/Stake/policy/stakeCreation,52241265,152127,2514
Agora/Stake/validator/stakeDepositWithdraw deposit,180880812,492023,4431 Agora/Stake/validator/stakeDepositWithdraw deposit,180880812,492023,4431
Agora/Stake/validator/stakeDepositWithdraw withdraw,180880812,492023,4419 Agora/Stake/validator/stakeDepositWithdraw withdraw,180880812,492023,4419
Agora/Proposal/policy/proposalCreation,23140177,69194,1519 Agora/Proposal/policy/proposalCreation,23140177,69194,1517
Agora/Proposal/validator/cosignature/proposal,338483402,961112,8620 Agora/Proposal/validator/cosignature/proposal,339142002,963240,8640
Agora/Proposal/validator/cosignature/stake,126327509,315061,4968 Agora/Proposal/validator/cosignature/stake,126327509,315061,4964
Agora/Proposal/validator/voting/proposal,296656410,830692,8549 Agora/Proposal/validator/voting/proposal,296502589,833052,8568
Agora/Proposal/validator/voting/stake,121170376,320853,4942 Agora/Proposal/validator/voting/stake,121170376,320853,4937
Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady,294340341,825452,8447 Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady,291922922,820018,8473
Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked,306801371,861382,8456 Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked,307211397,861958,8482
Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished,295193386,827555,8456 Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished,295603412,828131,8482
Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished,293210540,822722,8449 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished,291426433,819116,8475
Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished,291801629,820017,8450 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished,292844967,822421,8476
Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished,292932607,822421,8450 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished,293975945,824825,8476
"Agora/Proposal/validator/unlocking/legal/1 proposals, voter, unlock stake + retract votes, VotingReady",302502183,848154,8500 "Agora/Proposal/validator/unlocking/legal/1 proposals, voter, unlock stake + retract votes, VotingReady",303185955,850282,8520
"Agora/Proposal/validator/unlocking/legal/1 proposals, creator, unlock stake, Finished",273224492,773388,8504 "Agora/Proposal/validator/unlocking/legal/1 proposals, creator, unlock stake, Finished",273908264,775516,8524
"Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/1 proposals, voter, unlock stake, Finished",268700821,763033,8504 "Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/1 proposals, voter, unlock stake, Finished",269372007,765161,8524
"Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/1 proposals, voter, unlock stake, Locked",268700821,763033,8504 "Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/1 proposals, voter, unlock stake, Locked",269372007,765161,8524
"Agora/Proposal/validator/unlocking/legal/42 proposals, voter, unlock stake + retract votes, VotingReady",2908014422,8180225,30018 "Agora/Proposal/validator/unlocking/legal/42 proposals, voter, unlock stake + retract votes, VotingReady",2908698194,8182353,29874
"Agora/Proposal/validator/unlocking/legal/42 proposals, creator, unlock stake, Finished",2616129517,7383326,30287 "Agora/Proposal/validator/unlocking/legal/42 proposals, creator, unlock stake, Finished",2616813289,7385454,30143
"Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/42 proposals, voter, unlock stake, Finished",2464384686,6936321,30187 "Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/42 proposals, voter, unlock stake, Finished",2465055872,6938449,30042
"Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/42 proposals, voter, unlock stake, Locked",2464384686,6936321,30187 "Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/42 proposals, voter, unlock stake, Locked",2465055872,6938449,30042
Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple,21017788,55883,806 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple,21017788,55883,806
Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,33204186,88241,900 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,33204186,88241,900
Agora/Treasury/Validator/Positive/Allows for effect changes,29938856,79744,1391 Agora/Treasury/Validator/Positive/Allows for effect changes,30996258,82579,1462
Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple,21017788,55883,806 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple,21017788,55883,806
Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,33204186,88241,900 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,33204186,88241,900
Agora/Governor/policy/GST minting,51007235,144191,2034 Agora/Governor/policy/GST minting,51007235,144191,2034
Agora/Governor/validator/proposal creation,317651809,854963,9323 Agora/Governor/validator/proposal creation,315830140,850201,9247
Agora/Governor/validator/GATs minting,423756405,1151000,9444 Agora/Governor/validator/GATs minting,421359049,1145136,9364
Agora/Governor/validator/mutate governor state,91544121,254987,8908 Agora/Governor/validator/mutate governor state,88986020,248491,8834

1 name cpu mem size
2 Agora/Effects/Treasury Withdrawal Effect/effect/Simple 333327612 830203 3674
3 Agora/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries 492387542 1197315 3986
4 Agora/Effects/Treasury Withdrawal Effect/effect/Mixed Assets 456007605 1104500 3859
5 Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/governor validator should pass 90397270 87839169 249528 243032 8807 8733
6 Agora/Effects/Governor Mutation Effect/validator/valid new governor datum/effect validator should pass 106082031 292993 3609
7 Agora/Stake/policy/stakeCreation 52241265 152127 2514
8 Agora/Stake/validator/stakeDepositWithdraw deposit 180880812 492023 4431
9 Agora/Stake/validator/stakeDepositWithdraw withdraw 180880812 492023 4419
10 Agora/Proposal/policy/proposalCreation 23140177 69194 1519 1517
11 Agora/Proposal/validator/cosignature/proposal 338483402 339142002 961112 963240 8620 8640
12 Agora/Proposal/validator/cosignature/stake 126327509 315061 4968 4964
13 Agora/Proposal/validator/voting/proposal 296656410 296502589 830692 833052 8549 8568
14 Agora/Proposal/validator/voting/stake 121170376 320853 4942 4937
15 Agora/Proposal/validator/advancing/successfully advance to next state/Draft -> VotringReady 294340341 291922922 825452 820018 8447 8473
16 Agora/Proposal/validator/advancing/successfully advance to next state/VotingReady -> Locked 306801371 307211397 861382 861958 8456 8482
17 Agora/Proposal/validator/advancing/successfully advance to next state/Locked -> Finished 295193386 295603412 827555 828131 8456 8482
18 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Draft -> Finished 293210540 291426433 822722 819116 8449 8475
19 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/VotingReady -> Finished 291801629 292844967 820017 822421 8450 8476
20 Agora/Proposal/validator/advancing/successfully advance to failed state: timeout/Locked -> Finished 292932607 293975945 822421 824825 8450 8476
21 Agora/Proposal/validator/unlocking/legal/1 proposals, voter, unlock stake + retract votes, VotingReady 302502183 303185955 848154 850282 8500 8520
22 Agora/Proposal/validator/unlocking/legal/1 proposals, creator, unlock stake, Finished 273224492 273908264 773388 775516 8504 8524
23 Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/1 proposals, voter, unlock stake, Finished 268700821 269372007 763033 765161 8504 8524
24 Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/1 proposals, voter, unlock stake, Locked 268700821 269372007 763033 765161 8504 8524
25 Agora/Proposal/validator/unlocking/legal/42 proposals, voter, unlock stake + retract votes, VotingReady 2908014422 2908698194 8180225 8182353 30018 29874
26 Agora/Proposal/validator/unlocking/legal/42 proposals, creator, unlock stake, Finished 2616129517 2616813289 7383326 7385454 30287 30143
27 Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/42 proposals, voter, unlock stake, Finished 2464384686 2465055872 6936321 6938449 30187 30042
28 Agora/Proposal/validator/unlocking/legal/voter unlocks stake after voting/42 proposals, voter, unlock stake, Locked 2464384686 2465055872 6936321 6938449 30187 30042
29 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple 21017788 55883 806
30 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs 33204186 88241 900
31 Agora/Treasury/Validator/Positive/Allows for effect changes 29938856 30996258 79744 82579 1391 1462
32 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct simple 21017788 55883 806
33 Agora/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs 33204186 88241 900
34 Agora/Governor/policy/GST minting 51007235 144191 2034
35 Agora/Governor/validator/proposal creation 317651809 315830140 854963 850201 9323 9247
36 Agora/Governor/validator/GATs minting 423756405 421359049 1151000 1145136 9444 9364
37 Agora/Governor/validator/mutate governor state 91544121 88986020 254987 248491 8908 8834