{-# LANGUAGE TemplateHaskell #-}
module Agora.Proposal (
Proposal (..),
ProposalDatum (..),
ProposalRedeemer (..),
ProposalStatus (..),
ProposalThresholds (..),
ProposalVotes (..),
ProposalId (..),
ResultTag (..),
emptyVotesFor,
PProposalDatum (..),
PProposalRedeemer (..),
PProposalStatus (..),
PProposalThresholds (..),
PProposalVotes (..),
PProposalId (..),
PResultTag (..),
proposalDatumValid,
pemptyVotesFor,
pwinner,
pwinner',
pneutralOption,
pretractVotes,
) where
import Agora.Proposal.Time (PProposalStartingTime, PProposalTimingConfig, ProposalStartingTime, ProposalTimingConfig)
import Agora.SafeMoney (GTTag)
import Agora.Utils (mustBePJust)
import Data.Tagged (Tagged)
import GHC.Generics qualified as GHC
import Generics.SOP (Generic, I (I))
import Plutarch.Api.V1 (
KeyGuarantees (Unsorted),
PDatumHash,
PMap,
PPubKeyHash,
PValidatorHash,
)
import Plutarch.DataRepr (DerivePConstantViaData (..), PDataFields, PIsDataReprInstances (..))
import Plutarch.Extra.List (pnotNull)
import Plutarch.Extra.Map qualified as PM
import Plutarch.Extra.Map.Unsorted qualified as PUM
import Plutarch.Extra.TermCont (pguardC, pletC)
import Plutarch.Lift (
DerivePConstantViaNewtype (..),
PConstantDecl,
PUnsafeLiftDecl (..),
)
import Plutarch.SafeMoney (PDiscrete)
import PlutusLedgerApi.V1 (DatumHash, PubKeyHash, ValidatorHash)
import PlutusLedgerApi.V1.Value (AssetClass)
import PlutusTx qualified
import PlutusTx.AssocMap qualified as AssocMap
newtype ProposalId = ProposalId {ProposalId -> Integer
proposalTag :: Integer}
deriving newtype
(
ProposalId -> BuiltinData
(ProposalId -> BuiltinData) -> ToData ProposalId
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: ProposalId -> BuiltinData
$ctoBuiltinData :: ProposalId -> BuiltinData
PlutusTx.ToData
,
BuiltinData -> Maybe ProposalId
(BuiltinData -> Maybe ProposalId) -> FromData ProposalId
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe ProposalId
$cfromBuiltinData :: BuiltinData -> Maybe ProposalId
PlutusTx.FromData
,
BuiltinData -> ProposalId
(BuiltinData -> ProposalId) -> UnsafeFromData ProposalId
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> ProposalId
$cunsafeFromBuiltinData :: BuiltinData -> ProposalId
PlutusTx.UnsafeFromData
)
deriving stock
(
ProposalId -> ProposalId -> Bool
(ProposalId -> ProposalId -> Bool)
-> (ProposalId -> ProposalId -> Bool) -> Eq ProposalId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProposalId -> ProposalId -> Bool
$c/= :: ProposalId -> ProposalId -> Bool
== :: ProposalId -> ProposalId -> Bool
$c== :: ProposalId -> ProposalId -> Bool
Eq
,
Int -> ProposalId -> ShowS
[ProposalId] -> ShowS
ProposalId -> String
(Int -> ProposalId -> ShowS)
-> (ProposalId -> String)
-> ([ProposalId] -> ShowS)
-> Show ProposalId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProposalId] -> ShowS
$cshowList :: [ProposalId] -> ShowS
show :: ProposalId -> String
$cshow :: ProposalId -> String
showsPrec :: Int -> ProposalId -> ShowS
$cshowsPrec :: Int -> ProposalId -> ShowS
Show
,
(forall x. ProposalId -> Rep ProposalId x)
-> (forall x. Rep ProposalId x -> ProposalId) -> Generic ProposalId
forall x. Rep ProposalId x -> ProposalId
forall x. ProposalId -> Rep ProposalId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProposalId x -> ProposalId
$cfrom :: forall x. ProposalId -> Rep ProposalId x
GHC.Generic
)
newtype ResultTag = ResultTag {ResultTag -> Integer
getResultTag :: Integer}
deriving stock
(
ResultTag -> ResultTag -> Bool
(ResultTag -> ResultTag -> Bool)
-> (ResultTag -> ResultTag -> Bool) -> Eq ResultTag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResultTag -> ResultTag -> Bool
$c/= :: ResultTag -> ResultTag -> Bool
== :: ResultTag -> ResultTag -> Bool
$c== :: ResultTag -> ResultTag -> Bool
Eq
,
Int -> ResultTag -> ShowS
[ResultTag] -> ShowS
ResultTag -> String
(Int -> ResultTag -> ShowS)
-> (ResultTag -> String)
-> ([ResultTag] -> ShowS)
-> Show ResultTag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResultTag] -> ShowS
$cshowList :: [ResultTag] -> ShowS
show :: ResultTag -> String
$cshow :: ResultTag -> String
showsPrec :: Int -> ResultTag -> ShowS
$cshowsPrec :: Int -> ResultTag -> ShowS
Show
,
Eq ResultTag
Eq ResultTag
-> (ResultTag -> ResultTag -> Ordering)
-> (ResultTag -> ResultTag -> Bool)
-> (ResultTag -> ResultTag -> Bool)
-> (ResultTag -> ResultTag -> Bool)
-> (ResultTag -> ResultTag -> Bool)
-> (ResultTag -> ResultTag -> ResultTag)
-> (ResultTag -> ResultTag -> ResultTag)
-> Ord ResultTag
ResultTag -> ResultTag -> Bool
ResultTag -> ResultTag -> Ordering
ResultTag -> ResultTag -> ResultTag
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ResultTag -> ResultTag -> ResultTag
$cmin :: ResultTag -> ResultTag -> ResultTag
max :: ResultTag -> ResultTag -> ResultTag
$cmax :: ResultTag -> ResultTag -> ResultTag
>= :: ResultTag -> ResultTag -> Bool
$c>= :: ResultTag -> ResultTag -> Bool
> :: ResultTag -> ResultTag -> Bool
$c> :: ResultTag -> ResultTag -> Bool
<= :: ResultTag -> ResultTag -> Bool
$c<= :: ResultTag -> ResultTag -> Bool
< :: ResultTag -> ResultTag -> Bool
$c< :: ResultTag -> ResultTag -> Bool
compare :: ResultTag -> ResultTag -> Ordering
$ccompare :: ResultTag -> ResultTag -> Ordering
Ord
,
(forall x. ResultTag -> Rep ResultTag x)
-> (forall x. Rep ResultTag x -> ResultTag) -> Generic ResultTag
forall x. Rep ResultTag x -> ResultTag
forall x. ResultTag -> Rep ResultTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResultTag x -> ResultTag
$cfrom :: forall x. ResultTag -> Rep ResultTag x
GHC.Generic
)
deriving newtype
(
ResultTag -> BuiltinData
(ResultTag -> BuiltinData) -> ToData ResultTag
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: ResultTag -> BuiltinData
$ctoBuiltinData :: ResultTag -> BuiltinData
PlutusTx.ToData
,
BuiltinData -> Maybe ResultTag
(BuiltinData -> Maybe ResultTag) -> FromData ResultTag
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe ResultTag
$cfromBuiltinData :: BuiltinData -> Maybe ResultTag
PlutusTx.FromData
,
BuiltinData -> ResultTag
(BuiltinData -> ResultTag) -> UnsafeFromData ResultTag
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> ResultTag
$cunsafeFromBuiltinData :: BuiltinData -> ResultTag
PlutusTx.UnsafeFromData
)
data ProposalStatus
=
Draft
|
VotingReady
|
Locked
|
Finished
deriving stock
(
ProposalStatus -> ProposalStatus -> Bool
(ProposalStatus -> ProposalStatus -> Bool)
-> (ProposalStatus -> ProposalStatus -> Bool) -> Eq ProposalStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProposalStatus -> ProposalStatus -> Bool
$c/= :: ProposalStatus -> ProposalStatus -> Bool
== :: ProposalStatus -> ProposalStatus -> Bool
$c== :: ProposalStatus -> ProposalStatus -> Bool
Eq
,
Int -> ProposalStatus -> ShowS
[ProposalStatus] -> ShowS
ProposalStatus -> String
(Int -> ProposalStatus -> ShowS)
-> (ProposalStatus -> String)
-> ([ProposalStatus] -> ShowS)
-> Show ProposalStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProposalStatus] -> ShowS
$cshowList :: [ProposalStatus] -> ShowS
show :: ProposalStatus -> String
$cshow :: ProposalStatus -> String
showsPrec :: Int -> ProposalStatus -> ShowS
$cshowsPrec :: Int -> ProposalStatus -> ShowS
Show
,
(forall x. ProposalStatus -> Rep ProposalStatus x)
-> (forall x. Rep ProposalStatus x -> ProposalStatus)
-> Generic ProposalStatus
forall x. Rep ProposalStatus x -> ProposalStatus
forall x. ProposalStatus -> Rep ProposalStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProposalStatus x -> ProposalStatus
$cfrom :: forall x. ProposalStatus -> Rep ProposalStatus x
GHC.Generic
)
PlutusTx.makeIsDataIndexed ''ProposalStatus [('Draft, 0), ('VotingReady, 1), ('Locked, 2), ('Finished, 3)]
data ProposalThresholds = ProposalThresholds
{ ProposalThresholds -> Tagged @Type GTTag Integer
execute :: Tagged GTTag Integer
, ProposalThresholds -> Tagged @Type GTTag Integer
create :: Tagged GTTag Integer
, ProposalThresholds -> Tagged @Type GTTag Integer
vote :: Tagged GTTag Integer
}
deriving stock
(
ProposalThresholds -> ProposalThresholds -> Bool
(ProposalThresholds -> ProposalThresholds -> Bool)
-> (ProposalThresholds -> ProposalThresholds -> Bool)
-> Eq ProposalThresholds
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProposalThresholds -> ProposalThresholds -> Bool
$c/= :: ProposalThresholds -> ProposalThresholds -> Bool
== :: ProposalThresholds -> ProposalThresholds -> Bool
$c== :: ProposalThresholds -> ProposalThresholds -> Bool
Eq
,
Int -> ProposalThresholds -> ShowS
[ProposalThresholds] -> ShowS
ProposalThresholds -> String
(Int -> ProposalThresholds -> ShowS)
-> (ProposalThresholds -> String)
-> ([ProposalThresholds] -> ShowS)
-> Show ProposalThresholds
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProposalThresholds] -> ShowS
$cshowList :: [ProposalThresholds] -> ShowS
show :: ProposalThresholds -> String
$cshow :: ProposalThresholds -> String
showsPrec :: Int -> ProposalThresholds -> ShowS
$cshowsPrec :: Int -> ProposalThresholds -> ShowS
Show
,
(forall x. ProposalThresholds -> Rep ProposalThresholds x)
-> (forall x. Rep ProposalThresholds x -> ProposalThresholds)
-> Generic ProposalThresholds
forall x. Rep ProposalThresholds x -> ProposalThresholds
forall x. ProposalThresholds -> Rep ProposalThresholds x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProposalThresholds x -> ProposalThresholds
$cfrom :: forall x. ProposalThresholds -> Rep ProposalThresholds x
GHC.Generic
)
PlutusTx.makeIsDataIndexed ''ProposalThresholds [('ProposalThresholds, 0)]
newtype ProposalVotes = ProposalVotes
{ ProposalVotes -> Map ResultTag Integer
getProposalVotes :: AssocMap.Map ResultTag Integer
}
deriving newtype
(
ProposalVotes -> BuiltinData
(ProposalVotes -> BuiltinData) -> ToData ProposalVotes
forall a. (a -> BuiltinData) -> ToData a
toBuiltinData :: ProposalVotes -> BuiltinData
$ctoBuiltinData :: ProposalVotes -> BuiltinData
PlutusTx.ToData
,
BuiltinData -> Maybe ProposalVotes
(BuiltinData -> Maybe ProposalVotes) -> FromData ProposalVotes
forall a. (BuiltinData -> Maybe a) -> FromData a
fromBuiltinData :: BuiltinData -> Maybe ProposalVotes
$cfromBuiltinData :: BuiltinData -> Maybe ProposalVotes
PlutusTx.FromData
,
BuiltinData -> ProposalVotes
(BuiltinData -> ProposalVotes) -> UnsafeFromData ProposalVotes
forall a. (BuiltinData -> a) -> UnsafeFromData a
unsafeFromBuiltinData :: BuiltinData -> ProposalVotes
$cunsafeFromBuiltinData :: BuiltinData -> ProposalVotes
PlutusTx.UnsafeFromData
)
deriving stock
(
ProposalVotes -> ProposalVotes -> Bool
(ProposalVotes -> ProposalVotes -> Bool)
-> (ProposalVotes -> ProposalVotes -> Bool) -> Eq ProposalVotes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProposalVotes -> ProposalVotes -> Bool
$c/= :: ProposalVotes -> ProposalVotes -> Bool
== :: ProposalVotes -> ProposalVotes -> Bool
$c== :: ProposalVotes -> ProposalVotes -> Bool
Eq
,
Int -> ProposalVotes -> ShowS
[ProposalVotes] -> ShowS
ProposalVotes -> String
(Int -> ProposalVotes -> ShowS)
-> (ProposalVotes -> String)
-> ([ProposalVotes] -> ShowS)
-> Show ProposalVotes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProposalVotes] -> ShowS
$cshowList :: [ProposalVotes] -> ShowS
show :: ProposalVotes -> String
$cshow :: ProposalVotes -> String
showsPrec :: Int -> ProposalVotes -> ShowS
$cshowsPrec :: Int -> ProposalVotes -> ShowS
Show
,
(forall x. ProposalVotes -> Rep ProposalVotes x)
-> (forall x. Rep ProposalVotes x -> ProposalVotes)
-> Generic ProposalVotes
forall x. Rep ProposalVotes x -> ProposalVotes
forall x. ProposalVotes -> Rep ProposalVotes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProposalVotes x -> ProposalVotes
$cfrom :: forall x. ProposalVotes -> Rep ProposalVotes x
GHC.Generic
)
emptyVotesFor :: forall a. AssocMap.Map ResultTag a -> ProposalVotes
emptyVotesFor :: forall a. Map ResultTag a -> ProposalVotes
emptyVotesFor = Map ResultTag Integer -> ProposalVotes
ProposalVotes (Map ResultTag Integer -> ProposalVotes)
-> (Map ResultTag a -> Map ResultTag Integer)
-> Map ResultTag a
-> ProposalVotes
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ResultTag -> a -> Integer)
-> Map ResultTag a -> Map ResultTag Integer
forall k a b. (k -> a -> b) -> Map k a -> Map k b
AssocMap.mapWithKey (Integer -> a -> Integer
forall a b. a -> b -> a
const (Integer -> a -> Integer)
-> (ResultTag -> Integer) -> ResultTag -> a -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ResultTag -> Integer
forall a b. a -> b -> a
const Integer
0)
data ProposalDatum = ProposalDatum
{ ProposalDatum -> ProposalId
proposalId :: ProposalId
, ProposalDatum -> Map ResultTag (Map ValidatorHash DatumHash)
effects :: AssocMap.Map ResultTag (AssocMap.Map ValidatorHash DatumHash)
, ProposalDatum -> ProposalStatus
status :: ProposalStatus
, ProposalDatum -> [PubKeyHash]
cosigners :: [PubKeyHash]
, ProposalDatum -> ProposalThresholds
thresholds :: ProposalThresholds
, ProposalDatum -> ProposalVotes
votes :: ProposalVotes
, ProposalDatum -> ProposalTimingConfig
timingConfig :: ProposalTimingConfig
, ProposalDatum -> ProposalStartingTime
startingTime :: ProposalStartingTime
}
deriving stock
(
ProposalDatum -> ProposalDatum -> Bool
(ProposalDatum -> ProposalDatum -> Bool)
-> (ProposalDatum -> ProposalDatum -> Bool) -> Eq ProposalDatum
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProposalDatum -> ProposalDatum -> Bool
$c/= :: ProposalDatum -> ProposalDatum -> Bool
== :: ProposalDatum -> ProposalDatum -> Bool
$c== :: ProposalDatum -> ProposalDatum -> Bool
Eq
,
Int -> ProposalDatum -> ShowS
[ProposalDatum] -> ShowS
ProposalDatum -> String
(Int -> ProposalDatum -> ShowS)
-> (ProposalDatum -> String)
-> ([ProposalDatum] -> ShowS)
-> Show ProposalDatum
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProposalDatum] -> ShowS
$cshowList :: [ProposalDatum] -> ShowS
show :: ProposalDatum -> String
$cshow :: ProposalDatum -> String
showsPrec :: Int -> ProposalDatum -> ShowS
$cshowsPrec :: Int -> ProposalDatum -> ShowS
Show
,
(forall x. ProposalDatum -> Rep ProposalDatum x)
-> (forall x. Rep ProposalDatum x -> ProposalDatum)
-> Generic ProposalDatum
forall x. Rep ProposalDatum x -> ProposalDatum
forall x. ProposalDatum -> Rep ProposalDatum x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProposalDatum x -> ProposalDatum
$cfrom :: forall x. ProposalDatum -> Rep ProposalDatum x
GHC.Generic
)
PlutusTx.makeIsDataIndexed ''ProposalDatum [('ProposalDatum, 0)]
data ProposalRedeemer
=
Vote ResultTag
|
Cosign [PubKeyHash]
|
Unlock ResultTag
|
AdvanceProposal
deriving stock
(
ProposalRedeemer -> ProposalRedeemer -> Bool
(ProposalRedeemer -> ProposalRedeemer -> Bool)
-> (ProposalRedeemer -> ProposalRedeemer -> Bool)
-> Eq ProposalRedeemer
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProposalRedeemer -> ProposalRedeemer -> Bool
$c/= :: ProposalRedeemer -> ProposalRedeemer -> Bool
== :: ProposalRedeemer -> ProposalRedeemer -> Bool
$c== :: ProposalRedeemer -> ProposalRedeemer -> Bool
Eq
,
Int -> ProposalRedeemer -> ShowS
[ProposalRedeemer] -> ShowS
ProposalRedeemer -> String
(Int -> ProposalRedeemer -> ShowS)
-> (ProposalRedeemer -> String)
-> ([ProposalRedeemer] -> ShowS)
-> Show ProposalRedeemer
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProposalRedeemer] -> ShowS
$cshowList :: [ProposalRedeemer] -> ShowS
show :: ProposalRedeemer -> String
$cshow :: ProposalRedeemer -> String
showsPrec :: Int -> ProposalRedeemer -> ShowS
$cshowsPrec :: Int -> ProposalRedeemer -> ShowS
Show
,
(forall x. ProposalRedeemer -> Rep ProposalRedeemer x)
-> (forall x. Rep ProposalRedeemer x -> ProposalRedeemer)
-> Generic ProposalRedeemer
forall x. Rep ProposalRedeemer x -> ProposalRedeemer
forall x. ProposalRedeemer -> Rep ProposalRedeemer x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ProposalRedeemer x -> ProposalRedeemer
$cfrom :: forall x. ProposalRedeemer -> Rep ProposalRedeemer x
GHC.Generic
)
PlutusTx.makeIsDataIndexed
''ProposalRedeemer
[ ('Vote, 0)
, ('Cosign, 1)
, ('Unlock, 2)
, ('AdvanceProposal, 3)
]
data Proposal = Proposal
{ Proposal -> AssetClass
governorSTAssetClass :: AssetClass
, Proposal -> AssetClass
stakeSTAssetClass :: AssetClass
, Proposal -> Integer
maximumCosigners :: Integer
}
deriving stock
(
Int -> Proposal -> ShowS
[Proposal] -> ShowS
Proposal -> String
(Int -> Proposal -> ShowS)
-> (Proposal -> String) -> ([Proposal] -> ShowS) -> Show Proposal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Proposal] -> ShowS
$cshowList :: [Proposal] -> ShowS
show :: Proposal -> String
$cshow :: Proposal -> String
showsPrec :: Int -> Proposal -> ShowS
$cshowsPrec :: Int -> Proposal -> ShowS
Show
,
Proposal -> Proposal -> Bool
(Proposal -> Proposal -> Bool)
-> (Proposal -> Proposal -> Bool) -> Eq Proposal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Proposal -> Proposal -> Bool
$c/= :: Proposal -> Proposal -> Bool
== :: Proposal -> Proposal -> Bool
$c== :: Proposal -> Proposal -> Bool
Eq
,
(forall x. Proposal -> Rep Proposal x)
-> (forall x. Rep Proposal x -> Proposal) -> Generic Proposal
forall x. Rep Proposal x -> Proposal
forall x. Proposal -> Rep Proposal x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Proposal x -> Proposal
$cfrom :: forall x. Proposal -> Rep Proposal x
GHC.Generic
)
newtype PResultTag (s :: S) = PResultTag (Term s PInteger)
deriving
(
PCon PResultTag
PMatch PResultTag
PCon PResultTag
-> PMatch PResultTag
-> (forall (s :: S) (b :: PType).
PResultTag s -> Term s (PInner PResultTag b))
-> (forall (s :: S) (b :: PType).
Term s (PInner PResultTag b)
-> (PResultTag s -> Term s b) -> Term s b)
-> PlutusType PResultTag
forall (s :: S) (b :: PType).
Term s (PInner PResultTag b)
-> (PResultTag s -> Term s b) -> Term s b
forall (s :: S) (b :: PType).
PResultTag s -> Term s (PInner PResultTag b)
forall (a :: PType).
PCon a
-> PMatch a
-> (forall (s :: S) (b :: PType). a s -> Term s (PInner a b))
-> (forall (s :: S) (b :: PType).
Term s (PInner a b) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PResultTag b)
-> (PResultTag s -> Term s b) -> Term s b
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PResultTag b)
-> (PResultTag s -> Term s b) -> Term s b
pcon' :: forall (s :: S) (b :: PType).
PResultTag s -> Term s (PInner PResultTag b)
$cpcon' :: forall (s :: S) (b :: PType).
PResultTag s -> Term s (PInner PResultTag b)
PlutusType
,
(forall (s :: S). Term s (PAsData PResultTag) -> Term s PResultTag)
-> (forall (s :: S). Term s PResultTag -> Term s PData)
-> PIsData PResultTag
forall (s :: S). Term s (PAsData PResultTag) -> Term s PResultTag
forall (s :: S). Term s PResultTag -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
pdataImpl :: forall (s :: S). Term s PResultTag -> Term s PData
$cpdataImpl :: forall (s :: S). Term s PResultTag -> Term s PData
pfromDataImpl :: forall (s :: S). Term s (PAsData PResultTag) -> Term s PResultTag
$cpfromDataImpl :: forall (s :: S). Term s (PAsData PResultTag) -> Term s PResultTag
PIsData
,
(forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool)
-> PEq PResultTag
forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
#== :: forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
$c#== :: forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
PEq
,
PEq PResultTag
PEq PResultTag
-> (forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool)
-> (forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool)
-> POrd PResultTag
forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
forall (t :: PType).
PEq t
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> POrd t
#< :: forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
$c#< :: forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
#<= :: forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
$c#<= :: forall (s :: S).
Term s PResultTag -> Term s PResultTag -> Term s PBool
POrd
)
via (DerivePNewtype PResultTag PInteger)
instance PUnsafeLiftDecl PResultTag where type PLifted PResultTag = ResultTag
deriving via
(DerivePConstantViaNewtype ResultTag PResultTag PInteger)
instance
(PConstantDecl ResultTag)
deriving via
PAsData (DerivePNewtype PResultTag PInteger)
instance
PTryFrom PData (PAsData PResultTag)
newtype PProposalId (s :: S) = PProposalId (Term s PInteger)
deriving
(
PCon PProposalId
PMatch PProposalId
PCon PProposalId
-> PMatch PProposalId
-> (forall (s :: S) (b :: PType).
PProposalId s -> Term s (PInner PProposalId b))
-> (forall (s :: S) (b :: PType).
Term s (PInner PProposalId b)
-> (PProposalId s -> Term s b) -> Term s b)
-> PlutusType PProposalId
forall (s :: S) (b :: PType).
Term s (PInner PProposalId b)
-> (PProposalId s -> Term s b) -> Term s b
forall (s :: S) (b :: PType).
PProposalId s -> Term s (PInner PProposalId b)
forall (a :: PType).
PCon a
-> PMatch a
-> (forall (s :: S) (b :: PType). a s -> Term s (PInner a b))
-> (forall (s :: S) (b :: PType).
Term s (PInner a b) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalId b)
-> (PProposalId s -> Term s b) -> Term s b
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalId b)
-> (PProposalId s -> Term s b) -> Term s b
pcon' :: forall (s :: S) (b :: PType).
PProposalId s -> Term s (PInner PProposalId b)
$cpcon' :: forall (s :: S) (b :: PType).
PProposalId s -> Term s (PInner PProposalId b)
PlutusType
,
(forall (s :: S).
Term s (PAsData PProposalId) -> Term s PProposalId)
-> (forall (s :: S). Term s PProposalId -> Term s PData)
-> PIsData PProposalId
forall (s :: S). Term s (PAsData PProposalId) -> Term s PProposalId
forall (s :: S). Term s PProposalId -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
pdataImpl :: forall (s :: S). Term s PProposalId -> Term s PData
$cpdataImpl :: forall (s :: S). Term s PProposalId -> Term s PData
pfromDataImpl :: forall (s :: S). Term s (PAsData PProposalId) -> Term s PProposalId
$cpfromDataImpl :: forall (s :: S). Term s (PAsData PProposalId) -> Term s PProposalId
PIsData
,
(forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool)
-> PEq PProposalId
forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
#== :: forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
$c#== :: forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
PEq
,
PEq PProposalId
PEq PProposalId
-> (forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool)
-> (forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool)
-> POrd PProposalId
forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
forall (t :: PType).
PEq t
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> (forall (s :: S). Term s t -> Term s t -> Term s PBool)
-> POrd t
#< :: forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
$c#< :: forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
#<= :: forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
$c#<= :: forall (s :: S).
Term s PProposalId -> Term s PProposalId -> Term s PBool
POrd
)
via (DerivePNewtype PProposalId PInteger)
deriving via
PAsData (DerivePNewtype PProposalId PInteger)
instance
PTryFrom PData (PAsData PProposalId)
instance PUnsafeLiftDecl PProposalId where type PLifted PProposalId = ProposalId
deriving via
(DerivePConstantViaNewtype ProposalId PProposalId PInteger)
instance
(PConstantDecl ProposalId)
data PProposalStatus (s :: S)
=
PDraft (Term s (PDataRecord '[]))
| PVotingReady (Term s (PDataRecord '[]))
| PLocked (Term s (PDataRecord '[]))
| PFinished (Term s (PDataRecord '[]))
deriving stock
(
(forall x. PProposalStatus s -> Rep (PProposalStatus s) x)
-> (forall x. Rep (PProposalStatus s) x -> PProposalStatus s)
-> Generic (PProposalStatus s)
forall x. Rep (PProposalStatus s) x -> PProposalStatus s
forall x. PProposalStatus s -> Rep (PProposalStatus s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PProposalStatus s) x -> PProposalStatus s
forall (s :: S) x. PProposalStatus s -> Rep (PProposalStatus s) x
$cto :: forall (s :: S) x. Rep (PProposalStatus s) x -> PProposalStatus s
$cfrom :: forall (s :: S) x. PProposalStatus s -> Rep (PProposalStatus s) x
GHC.Generic
)
deriving anyclass
(
All @[Type] (SListI @Type) (Code (PProposalStatus s))
All @[Type] (SListI @Type) (Code (PProposalStatus s))
-> (PProposalStatus s -> Rep (PProposalStatus s))
-> (Rep (PProposalStatus s) -> PProposalStatus s)
-> Generic (PProposalStatus s)
Rep (PProposalStatus s) -> PProposalStatus s
PProposalStatus s -> Rep (PProposalStatus s)
forall a.
All @[Type] (SListI @Type) (Code a)
-> (a -> Rep a) -> (Rep a -> a) -> Generic a
forall {s :: S}.
All @[Type] (SListI @Type) (Code (PProposalStatus s))
forall (s :: S). Rep (PProposalStatus s) -> PProposalStatus s
forall (s :: S). PProposalStatus s -> Rep (PProposalStatus s)
to :: Rep (PProposalStatus s) -> PProposalStatus s
$cto :: forall (s :: S). Rep (PProposalStatus s) -> PProposalStatus s
from :: PProposalStatus s -> Rep (PProposalStatus s)
$cfrom :: forall (s :: S). PProposalStatus s -> Rep (PProposalStatus s)
Generic
)
deriving anyclass
(
PIsData PProposalStatus
PlutusType PProposalStatus
PlutusType PProposalStatus
-> PIsData PProposalStatus
-> (forall (s :: S).
PProposalStatus s
-> Term s (PDataSum (PIsDataReprRepr PProposalStatus)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalStatus))
-> (PProposalStatus s -> Term s b) -> Term s b)
-> PIsDataRepr PProposalStatus
forall (s :: S).
PProposalStatus s
-> Term s (PDataSum (PIsDataReprRepr PProposalStatus))
forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalStatus))
-> (PProposalStatus s -> Term s b) -> Term s b
forall (a :: PType).
PlutusType a
-> PIsData a
-> (forall (s :: S). a s -> Term s (PDataSum (PIsDataReprRepr a)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr a))
-> (a s -> Term s b) -> Term s b)
-> PIsDataRepr a
pmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalStatus))
-> (PProposalStatus s -> Term s b) -> Term s b
$cpmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalStatus))
-> (PProposalStatus s -> Term s b) -> Term s b
pconRepr :: forall (s :: S).
PProposalStatus s
-> Term s (PDataSum (PIsDataReprRepr PProposalStatus))
$cpconRepr :: forall (s :: S).
PProposalStatus s
-> Term s (PDataSum (PIsDataReprRepr PProposalStatus))
PIsDataRepr
)
deriving
(
PCon PProposalStatus
PMatch PProposalStatus
PCon PProposalStatus
-> PMatch PProposalStatus
-> (forall (s :: S) (b :: PType).
PProposalStatus s -> Term s (PInner PProposalStatus b))
-> (forall (s :: S) (b :: PType).
Term s (PInner PProposalStatus b)
-> (PProposalStatus s -> Term s b) -> Term s b)
-> PlutusType PProposalStatus
forall (s :: S) (b :: PType).
Term s (PInner PProposalStatus b)
-> (PProposalStatus s -> Term s b) -> Term s b
forall (s :: S) (b :: PType).
PProposalStatus s -> Term s (PInner PProposalStatus b)
forall (a :: PType).
PCon a
-> PMatch a
-> (forall (s :: S) (b :: PType). a s -> Term s (PInner a b))
-> (forall (s :: S) (b :: PType).
Term s (PInner a b) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalStatus b)
-> (PProposalStatus s -> Term s b) -> Term s b
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalStatus b)
-> (PProposalStatus s -> Term s b) -> Term s b
pcon' :: forall (s :: S) (b :: PType).
PProposalStatus s -> Term s (PInner PProposalStatus b)
$cpcon' :: forall (s :: S) (b :: PType).
PProposalStatus s -> Term s (PInner PProposalStatus b)
PlutusType
,
(forall (s :: S).
Term s (PAsData PProposalStatus) -> Term s PProposalStatus)
-> (forall (s :: S). Term s PProposalStatus -> Term s PData)
-> PIsData PProposalStatus
forall (s :: S).
Term s (PAsData PProposalStatus) -> Term s PProposalStatus
forall (s :: S). Term s PProposalStatus -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
pdataImpl :: forall (s :: S). Term s PProposalStatus -> Term s PData
$cpdataImpl :: forall (s :: S). Term s PProposalStatus -> Term s PData
pfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalStatus) -> Term s PProposalStatus
$cpfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalStatus) -> Term s PProposalStatus
PIsData
,
(forall (s :: S).
Term s PProposalStatus -> Term s PProposalStatus -> Term s PBool)
-> PEq PProposalStatus
forall (s :: S).
Term s PProposalStatus -> Term s PProposalStatus -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
#== :: forall (s :: S).
Term s PProposalStatus -> Term s PProposalStatus -> Term s PBool
$c#== :: forall (s :: S).
Term s PProposalStatus -> Term s PProposalStatus -> Term s PBool
PEq
)
via PIsDataReprInstances PProposalStatus
instance PUnsafeLiftDecl PProposalStatus where type PLifted PProposalStatus = ProposalStatus
deriving via PAsData (PIsDataReprInstances PProposalStatus) instance PTryFrom PData (PAsData PProposalStatus)
deriving via (DerivePConstantViaData ProposalStatus PProposalStatus) instance (PConstantDecl ProposalStatus)
newtype PProposalThresholds (s :: S) = PProposalThresholds
{ forall (s :: S).
PProposalThresholds s
-> Term
s
(PDataRecord
((':)
@PLabeledType
("execute" ':= PDiscrete @Type GTTag)
((':)
@PLabeledType
("create" ':= PDiscrete @Type GTTag)
((':)
@PLabeledType
("vote" ':= PDiscrete @Type GTTag)
('[] @PLabeledType)))))
getProposalThresholds ::
Term
s
( PDataRecord
'[ "execute" ':= PDiscrete GTTag
, "create" ':= PDiscrete GTTag
, "vote" ':= PDiscrete GTTag
]
)
}
deriving stock
(
(forall x. PProposalThresholds s -> Rep (PProposalThresholds s) x)
-> (forall x.
Rep (PProposalThresholds s) x -> PProposalThresholds s)
-> Generic (PProposalThresholds s)
forall x. Rep (PProposalThresholds s) x -> PProposalThresholds s
forall x. PProposalThresholds s -> Rep (PProposalThresholds s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x.
Rep (PProposalThresholds s) x -> PProposalThresholds s
forall (s :: S) x.
PProposalThresholds s -> Rep (PProposalThresholds s) x
$cto :: forall (s :: S) x.
Rep (PProposalThresholds s) x -> PProposalThresholds s
$cfrom :: forall (s :: S) x.
PProposalThresholds s -> Rep (PProposalThresholds s) x
GHC.Generic
)
deriving anyclass
(
All @[Type] (SListI @Type) (Code (PProposalThresholds s))
All @[Type] (SListI @Type) (Code (PProposalThresholds s))
-> (PProposalThresholds s -> Rep (PProposalThresholds s))
-> (Rep (PProposalThresholds s) -> PProposalThresholds s)
-> Generic (PProposalThresholds s)
Rep (PProposalThresholds s) -> PProposalThresholds s
PProposalThresholds s -> Rep (PProposalThresholds s)
forall a.
All @[Type] (SListI @Type) (Code a)
-> (a -> Rep a) -> (Rep a -> a) -> Generic a
forall {s :: S}.
All @[Type] (SListI @Type) (Code (PProposalThresholds s))
forall (s :: S).
Rep (PProposalThresholds s) -> PProposalThresholds s
forall (s :: S).
PProposalThresholds s -> Rep (PProposalThresholds s)
to :: Rep (PProposalThresholds s) -> PProposalThresholds s
$cto :: forall (s :: S).
Rep (PProposalThresholds s) -> PProposalThresholds s
from :: PProposalThresholds s -> Rep (PProposalThresholds s)
$cfrom :: forall (s :: S).
PProposalThresholds s -> Rep (PProposalThresholds s)
Generic
)
deriving anyclass
(
PIsData PProposalThresholds
PlutusType PProposalThresholds
PlutusType PProposalThresholds
-> PIsData PProposalThresholds
-> (forall (s :: S).
PProposalThresholds s
-> Term s (PDataSum (PIsDataReprRepr PProposalThresholds)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalThresholds))
-> (PProposalThresholds s -> Term s b) -> Term s b)
-> PIsDataRepr PProposalThresholds
forall (s :: S).
PProposalThresholds s
-> Term s (PDataSum (PIsDataReprRepr PProposalThresholds))
forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalThresholds))
-> (PProposalThresholds s -> Term s b) -> Term s b
forall (a :: PType).
PlutusType a
-> PIsData a
-> (forall (s :: S). a s -> Term s (PDataSum (PIsDataReprRepr a)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr a))
-> (a s -> Term s b) -> Term s b)
-> PIsDataRepr a
pmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalThresholds))
-> (PProposalThresholds s -> Term s b) -> Term s b
$cpmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalThresholds))
-> (PProposalThresholds s -> Term s b) -> Term s b
pconRepr :: forall (s :: S).
PProposalThresholds s
-> Term s (PDataSum (PIsDataReprRepr PProposalThresholds))
$cpconRepr :: forall (s :: S).
PProposalThresholds s
-> Term s (PDataSum (PIsDataReprRepr PProposalThresholds))
PIsDataRepr
)
deriving
(
PCon PProposalThresholds
PMatch PProposalThresholds
PCon PProposalThresholds
-> PMatch PProposalThresholds
-> (forall (s :: S) (b :: PType).
PProposalThresholds s -> Term s (PInner PProposalThresholds b))
-> (forall (s :: S) (b :: PType).
Term s (PInner PProposalThresholds b)
-> (PProposalThresholds s -> Term s b) -> Term s b)
-> PlutusType PProposalThresholds
forall (s :: S) (b :: PType).
Term s (PInner PProposalThresholds b)
-> (PProposalThresholds s -> Term s b) -> Term s b
forall (s :: S) (b :: PType).
PProposalThresholds s -> Term s (PInner PProposalThresholds b)
forall (a :: PType).
PCon a
-> PMatch a
-> (forall (s :: S) (b :: PType). a s -> Term s (PInner a b))
-> (forall (s :: S) (b :: PType).
Term s (PInner a b) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalThresholds b)
-> (PProposalThresholds s -> Term s b) -> Term s b
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalThresholds b)
-> (PProposalThresholds s -> Term s b) -> Term s b
pcon' :: forall (s :: S) (b :: PType).
PProposalThresholds s -> Term s (PInner PProposalThresholds b)
$cpcon' :: forall (s :: S) (b :: PType).
PProposalThresholds s -> Term s (PInner PProposalThresholds b)
PlutusType
,
(forall (s :: S).
Term s (PAsData PProposalThresholds) -> Term s PProposalThresholds)
-> (forall (s :: S). Term s PProposalThresholds -> Term s PData)
-> PIsData PProposalThresholds
forall (s :: S).
Term s (PAsData PProposalThresholds) -> Term s PProposalThresholds
forall (s :: S). Term s PProposalThresholds -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
pdataImpl :: forall (s :: S). Term s PProposalThresholds -> Term s PData
$cpdataImpl :: forall (s :: S). Term s PProposalThresholds -> Term s PData
pfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalThresholds) -> Term s PProposalThresholds
$cpfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalThresholds) -> Term s PProposalThresholds
PIsData
,
(forall (s :: S).
Term s PProposalThresholds
-> Term s (PDataRecord (PFields PProposalThresholds)))
-> PDataFields PProposalThresholds
forall (s :: S).
Term s PProposalThresholds
-> Term s (PDataRecord (PFields PProposalThresholds))
forall (a :: PType).
(forall (s :: S). Term s a -> Term s (PDataRecord (PFields a)))
-> PDataFields a
ptoFields :: forall (s :: S).
Term s PProposalThresholds
-> Term s (PDataRecord (PFields PProposalThresholds))
$cptoFields :: forall (s :: S).
Term s PProposalThresholds
-> Term s (PDataRecord (PFields PProposalThresholds))
PDataFields
)
via (PIsDataReprInstances PProposalThresholds)
deriving via
PAsData (PIsDataReprInstances PProposalThresholds)
instance
PTryFrom PData (PAsData PProposalThresholds)
instance PUnsafeLiftDecl PProposalThresholds where type PLifted PProposalThresholds = ProposalThresholds
deriving via
(DerivePConstantViaData ProposalThresholds PProposalThresholds)
instance
(PConstantDecl ProposalThresholds)
newtype PProposalVotes (s :: S)
= PProposalVotes (Term s (PMap 'Unsorted PResultTag PInteger))
deriving
(
PCon PProposalVotes
PMatch PProposalVotes
PCon PProposalVotes
-> PMatch PProposalVotes
-> (forall (s :: S) (b :: PType).
PProposalVotes s -> Term s (PInner PProposalVotes b))
-> (forall (s :: S) (b :: PType).
Term s (PInner PProposalVotes b)
-> (PProposalVotes s -> Term s b) -> Term s b)
-> PlutusType PProposalVotes
forall (s :: S) (b :: PType).
Term s (PInner PProposalVotes b)
-> (PProposalVotes s -> Term s b) -> Term s b
forall (s :: S) (b :: PType).
PProposalVotes s -> Term s (PInner PProposalVotes b)
forall (a :: PType).
PCon a
-> PMatch a
-> (forall (s :: S) (b :: PType). a s -> Term s (PInner a b))
-> (forall (s :: S) (b :: PType).
Term s (PInner a b) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalVotes b)
-> (PProposalVotes s -> Term s b) -> Term s b
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalVotes b)
-> (PProposalVotes s -> Term s b) -> Term s b
pcon' :: forall (s :: S) (b :: PType).
PProposalVotes s -> Term s (PInner PProposalVotes b)
$cpcon' :: forall (s :: S) (b :: PType).
PProposalVotes s -> Term s (PInner PProposalVotes b)
PlutusType
,
(forall (s :: S).
Term s (PAsData PProposalVotes) -> Term s PProposalVotes)
-> (forall (s :: S). Term s PProposalVotes -> Term s PData)
-> PIsData PProposalVotes
forall (s :: S).
Term s (PAsData PProposalVotes) -> Term s PProposalVotes
forall (s :: S). Term s PProposalVotes -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
pdataImpl :: forall (s :: S). Term s PProposalVotes -> Term s PData
$cpdataImpl :: forall (s :: S). Term s PProposalVotes -> Term s PData
pfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalVotes) -> Term s PProposalVotes
$cpfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalVotes) -> Term s PProposalVotes
PIsData
)
via (DerivePNewtype PProposalVotes (PMap 'Unsorted PResultTag PInteger))
deriving via
PAsData (DerivePNewtype PProposalVotes (PMap 'Unsorted PResultTag PInteger))
instance
PTryFrom PData (PAsData PProposalVotes)
pretractVotes :: Term s (PResultTag :--> PInteger :--> PProposalVotes :--> PProposalVotes)
pretractVotes :: forall (s :: S).
Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes)))
pretractVotes = (forall (s :: S).
Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes))))
-> Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes))))
-> Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes))))
-> (forall (s :: S).
Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes))))
-> Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes)))
forall a b. (a -> b) -> a -> b
$
(Term s PResultTag
-> Term s (PInteger @S)
-> Term s PProposalVotes
-> Term s PProposalVotes)
-> Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes)))
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term s PResultTag
-> Term s (PInteger @S)
-> Term s PProposalVotes
-> Term s PProposalVotes)
-> Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes))))
-> (Term s PResultTag
-> Term s (PInteger @S)
-> Term s PProposalVotes
-> Term s PProposalVotes)
-> Term
s
(PResultTag
:--> (PInteger @S :--> (PProposalVotes :--> PProposalVotes)))
forall a b. (a -> b) -> a -> b
$ \Term s PResultTag
rt Term s (PInteger @S)
count Term s PProposalVotes
votes ->
let voteMap :: Term _ (PMap 'Unsorted PResultTag PInteger)
voteMap :: Term s (PMap 'Unsorted PResultTag (PInteger @S))
voteMap = Term s PProposalVotes
-> forall (b :: PType). Term s (PInner PProposalVotes b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto Term s PProposalVotes
votes
in PProposalVotes s -> Term s PProposalVotes
forall (a :: PType) (s :: S). PCon a => a s -> Term s a
pcon (PProposalVotes s -> Term s PProposalVotes)
-> PProposalVotes s -> Term s PProposalVotes
forall a b. (a -> b) -> a -> b
$
Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s
forall (s :: S).
Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s
PProposalVotes (Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s)
-> Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s
forall a b. (a -> b) -> a -> b
$
Term
s
((PInteger @S :--> PMaybe (PInteger @S))
:--> (PResultTag
:--> (PMap 'Unsorted PResultTag (PInteger @S)
:--> PMap 'Unsorted PResultTag (PInteger @S))))
forall (k :: PType) (v :: PType) (keys :: KeyGuarantees) (s :: S).
(PIsData k, PIsData v) =>
Term
s
((v :--> PMaybe v)
:--> (k :--> (PMap keys k v :--> PMap keys k v)))
PM.pupdate
# plam
( \oldCount -> unTermCont $ do
newCount <- pletC $ oldCount - count
pguardC "Resulting vote count greater or equal to 0" $ 0 #<= newCount
pure $ pcon $ PJust newCount
)
# rt
# voteMap
instance PUnsafeLiftDecl PProposalVotes where type PLifted PProposalVotes = ProposalVotes
deriving via
(DerivePConstantViaNewtype ProposalVotes PProposalVotes (PMap 'Unsorted PResultTag PInteger))
instance
(PConstantDecl ProposalVotes)
pemptyVotesFor :: forall s a. (PIsData a) => Term s (PMap 'Unsorted PResultTag a :--> PProposalVotes)
pemptyVotesFor :: forall (s :: S) (a :: PType).
PIsData a =>
Term s (PMap 'Unsorted PResultTag a :--> PProposalVotes)
pemptyVotesFor =
ClosedTerm (PMap 'Unsorted PResultTag a :--> PProposalVotes)
-> Term s (PMap 'Unsorted PResultTag a :--> PProposalVotes)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PMap 'Unsorted PResultTag a :--> PProposalVotes)
-> Term s (PMap 'Unsorted PResultTag a :--> PProposalVotes))
-> ClosedTerm (PMap 'Unsorted PResultTag a :--> PProposalVotes)
-> Term s (PMap 'Unsorted PResultTag a :--> PProposalVotes)
forall a b. (a -> b) -> a -> b
$
(Term s (PMap 'Unsorted PResultTag a) -> Term s PProposalVotes)
-> Term s (PMap 'Unsorted PResultTag a :--> PProposalVotes)
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam
( \Term s (PMap 'Unsorted PResultTag a)
m ->
PProposalVotes s -> Term s PProposalVotes
forall (a :: PType) (s :: S). PCon a => a s -> Term s a
pcon (PProposalVotes s -> Term s PProposalVotes)
-> PProposalVotes s -> Term s PProposalVotes
forall a b. (a -> b) -> a -> b
$
Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s
forall (s :: S).
Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s
PProposalVotes (Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s)
-> Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> PProposalVotes s
forall a b. (a -> b) -> a -> b
$ Term
s
((a :--> PInteger @S)
:--> (PMap 'Unsorted PResultTag a
:--> PMap 'Unsorted PResultTag (PInteger @S)))
forall (k :: PType) (a :: PType) (b :: PType)
(keys :: KeyGuarantees) (s :: S).
(PIsData k, PIsData a, PIsData b) =>
Term s ((a :--> b) :--> (PMap keys k a :--> PMap keys k b))
PM.pmap Term
s
((a :--> PInteger @S)
:--> (PMap 'Unsorted PResultTag a
:--> PMap 'Unsorted PResultTag (PInteger @S)))
-> Term s (a :--> PInteger @S)
-> Term
s
(PMap 'Unsorted PResultTag a
:--> PMap 'Unsorted PResultTag (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term s a -> Term s (PInteger @S)) -> Term s (a :--> PInteger @S)
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam (Term s (PInteger @S) -> Term s a -> Term s (PInteger @S)
forall a b. a -> b -> a
const (Term s (PInteger @S) -> Term s a -> Term s (PInteger @S))
-> Term s (PInteger @S) -> Term s a -> Term s (PInteger @S)
forall a b. (a -> b) -> a -> b
$ PLifted (PInteger @S) -> Term s (PInteger @S)
forall (p :: PType) (s :: S). PLift p => PLifted p -> Term s p
pconstant PLifted (PInteger @S)
0) Term
s
(PMap 'Unsorted PResultTag a
:--> PMap 'Unsorted PResultTag (PInteger @S))
-> Term s (PMap 'Unsorted PResultTag a)
-> Term s (PMap 'Unsorted PResultTag (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PMap 'Unsorted PResultTag a)
m
)
newtype PProposalDatum (s :: S) = PProposalDatum
{ forall (s :: S).
PProposalDatum s
-> Term
s
(PDataRecord
((':)
@PLabeledType
("proposalId" ':= PProposalId)
((':)
@PLabeledType
("effects"
':= PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
((':)
@PLabeledType
("status" ':= PProposalStatus)
((':)
@PLabeledType
("cosigners" ':= PBuiltinList (PAsData PPubKeyHash))
((':)
@PLabeledType
("thresholds" ':= PProposalThresholds)
((':)
@PLabeledType
("votes" ':= PProposalVotes)
((':)
@PLabeledType
("timingConfig" ':= PProposalTimingConfig)
((':)
@PLabeledType
("startingTime" ':= PProposalStartingTime)
('[] @PLabeledType))))))))))
getProposalDatum ::
Term
s
( PDataRecord
'[ "proposalId" ':= PProposalId
, "effects" ':= PMap 'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
, "status" ':= PProposalStatus
, "cosigners" ':= PBuiltinList (PAsData PPubKeyHash)
, "thresholds" ':= PProposalThresholds
, "votes" ':= PProposalVotes
, "timingConfig" ':= PProposalTimingConfig
, "startingTime" ':= PProposalStartingTime
]
)
}
deriving stock
(
(forall x. PProposalDatum s -> Rep (PProposalDatum s) x)
-> (forall x. Rep (PProposalDatum s) x -> PProposalDatum s)
-> Generic (PProposalDatum s)
forall x. Rep (PProposalDatum s) x -> PProposalDatum s
forall x. PProposalDatum s -> Rep (PProposalDatum s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x. Rep (PProposalDatum s) x -> PProposalDatum s
forall (s :: S) x. PProposalDatum s -> Rep (PProposalDatum s) x
$cto :: forall (s :: S) x. Rep (PProposalDatum s) x -> PProposalDatum s
$cfrom :: forall (s :: S) x. PProposalDatum s -> Rep (PProposalDatum s) x
GHC.Generic
)
deriving anyclass
(
All @[Type] (SListI @Type) (Code (PProposalDatum s))
All @[Type] (SListI @Type) (Code (PProposalDatum s))
-> (PProposalDatum s -> Rep (PProposalDatum s))
-> (Rep (PProposalDatum s) -> PProposalDatum s)
-> Generic (PProposalDatum s)
Rep (PProposalDatum s) -> PProposalDatum s
PProposalDatum s -> Rep (PProposalDatum s)
forall a.
All @[Type] (SListI @Type) (Code a)
-> (a -> Rep a) -> (Rep a -> a) -> Generic a
forall {s :: S}.
All @[Type] (SListI @Type) (Code (PProposalDatum s))
forall (s :: S). Rep (PProposalDatum s) -> PProposalDatum s
forall (s :: S). PProposalDatum s -> Rep (PProposalDatum s)
to :: Rep (PProposalDatum s) -> PProposalDatum s
$cto :: forall (s :: S). Rep (PProposalDatum s) -> PProposalDatum s
from :: PProposalDatum s -> Rep (PProposalDatum s)
$cfrom :: forall (s :: S). PProposalDatum s -> Rep (PProposalDatum s)
Generic
)
deriving anyclass
(
PIsData PProposalDatum
PlutusType PProposalDatum
PlutusType PProposalDatum
-> PIsData PProposalDatum
-> (forall (s :: S).
PProposalDatum s
-> Term s (PDataSum (PIsDataReprRepr PProposalDatum)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalDatum))
-> (PProposalDatum s -> Term s b) -> Term s b)
-> PIsDataRepr PProposalDatum
forall (s :: S).
PProposalDatum s
-> Term s (PDataSum (PIsDataReprRepr PProposalDatum))
forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalDatum))
-> (PProposalDatum s -> Term s b) -> Term s b
forall (a :: PType).
PlutusType a
-> PIsData a
-> (forall (s :: S). a s -> Term s (PDataSum (PIsDataReprRepr a)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr a))
-> (a s -> Term s b) -> Term s b)
-> PIsDataRepr a
pmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalDatum))
-> (PProposalDatum s -> Term s b) -> Term s b
$cpmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalDatum))
-> (PProposalDatum s -> Term s b) -> Term s b
pconRepr :: forall (s :: S).
PProposalDatum s
-> Term s (PDataSum (PIsDataReprRepr PProposalDatum))
$cpconRepr :: forall (s :: S).
PProposalDatum s
-> Term s (PDataSum (PIsDataReprRepr PProposalDatum))
PIsDataRepr
)
deriving
(
PCon PProposalDatum
PMatch PProposalDatum
PCon PProposalDatum
-> PMatch PProposalDatum
-> (forall (s :: S) (b :: PType).
PProposalDatum s -> Term s (PInner PProposalDatum b))
-> (forall (s :: S) (b :: PType).
Term s (PInner PProposalDatum b)
-> (PProposalDatum s -> Term s b) -> Term s b)
-> PlutusType PProposalDatum
forall (s :: S) (b :: PType).
Term s (PInner PProposalDatum b)
-> (PProposalDatum s -> Term s b) -> Term s b
forall (s :: S) (b :: PType).
PProposalDatum s -> Term s (PInner PProposalDatum b)
forall (a :: PType).
PCon a
-> PMatch a
-> (forall (s :: S) (b :: PType). a s -> Term s (PInner a b))
-> (forall (s :: S) (b :: PType).
Term s (PInner a b) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalDatum b)
-> (PProposalDatum s -> Term s b) -> Term s b
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalDatum b)
-> (PProposalDatum s -> Term s b) -> Term s b
pcon' :: forall (s :: S) (b :: PType).
PProposalDatum s -> Term s (PInner PProposalDatum b)
$cpcon' :: forall (s :: S) (b :: PType).
PProposalDatum s -> Term s (PInner PProposalDatum b)
PlutusType
,
(forall (s :: S).
Term s (PAsData PProposalDatum) -> Term s PProposalDatum)
-> (forall (s :: S). Term s PProposalDatum -> Term s PData)
-> PIsData PProposalDatum
forall (s :: S).
Term s (PAsData PProposalDatum) -> Term s PProposalDatum
forall (s :: S). Term s PProposalDatum -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
pdataImpl :: forall (s :: S). Term s PProposalDatum -> Term s PData
$cpdataImpl :: forall (s :: S). Term s PProposalDatum -> Term s PData
pfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalDatum) -> Term s PProposalDatum
$cpfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalDatum) -> Term s PProposalDatum
PIsData
,
(forall (s :: S).
Term s PProposalDatum
-> Term s (PDataRecord (PFields PProposalDatum)))
-> PDataFields PProposalDatum
forall (s :: S).
Term s PProposalDatum
-> Term s (PDataRecord (PFields PProposalDatum))
forall (a :: PType).
(forall (s :: S). Term s a -> Term s (PDataRecord (PFields a)))
-> PDataFields a
ptoFields :: forall (s :: S).
Term s PProposalDatum
-> Term s (PDataRecord (PFields PProposalDatum))
$cptoFields :: forall (s :: S).
Term s PProposalDatum
-> Term s (PDataRecord (PFields PProposalDatum))
PDataFields
,
(forall (s :: S).
Term s PProposalDatum -> Term s PProposalDatum -> Term s PBool)
-> PEq PProposalDatum
forall (s :: S).
Term s PProposalDatum -> Term s PProposalDatum -> Term s PBool
forall (t :: PType).
(forall (s :: S). Term s t -> Term s t -> Term s PBool) -> PEq t
#== :: forall (s :: S).
Term s PProposalDatum -> Term s PProposalDatum -> Term s PBool
$c#== :: forall (s :: S).
Term s PProposalDatum -> Term s PProposalDatum -> Term s PBool
PEq
)
via (PIsDataReprInstances PProposalDatum)
deriving via PAsData (PIsDataReprInstances PProposalDatum) instance PTryFrom PData (PAsData PProposalDatum)
instance PUnsafeLiftDecl PProposalDatum where type PLifted PProposalDatum = ProposalDatum
deriving via (DerivePConstantViaData ProposalDatum PProposalDatum) instance (PConstantDecl ProposalDatum)
data PProposalRedeemer (s :: S)
= PVote (Term s (PDataRecord '["resultTag" ':= PResultTag]))
| PCosign (Term s (PDataRecord '["newCosigners" ':= PBuiltinList (PAsData PPubKeyHash)]))
| PUnlock (Term s (PDataRecord '["resultTag" ':= PResultTag]))
| PAdvanceProposal (Term s (PDataRecord '[]))
deriving stock
(
(forall x. PProposalRedeemer s -> Rep (PProposalRedeemer s) x)
-> (forall x. Rep (PProposalRedeemer s) x -> PProposalRedeemer s)
-> Generic (PProposalRedeemer s)
forall x. Rep (PProposalRedeemer s) x -> PProposalRedeemer s
forall x. PProposalRedeemer s -> Rep (PProposalRedeemer s) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (s :: S) x.
Rep (PProposalRedeemer s) x -> PProposalRedeemer s
forall (s :: S) x.
PProposalRedeemer s -> Rep (PProposalRedeemer s) x
$cto :: forall (s :: S) x.
Rep (PProposalRedeemer s) x -> PProposalRedeemer s
$cfrom :: forall (s :: S) x.
PProposalRedeemer s -> Rep (PProposalRedeemer s) x
GHC.Generic
)
deriving anyclass
(
All @[Type] (SListI @Type) (Code (PProposalRedeemer s))
All @[Type] (SListI @Type) (Code (PProposalRedeemer s))
-> (PProposalRedeemer s -> Rep (PProposalRedeemer s))
-> (Rep (PProposalRedeemer s) -> PProposalRedeemer s)
-> Generic (PProposalRedeemer s)
Rep (PProposalRedeemer s) -> PProposalRedeemer s
PProposalRedeemer s -> Rep (PProposalRedeemer s)
forall a.
All @[Type] (SListI @Type) (Code a)
-> (a -> Rep a) -> (Rep a -> a) -> Generic a
forall {s :: S}.
All @[Type] (SListI @Type) (Code (PProposalRedeemer s))
forall (s :: S). Rep (PProposalRedeemer s) -> PProposalRedeemer s
forall (s :: S). PProposalRedeemer s -> Rep (PProposalRedeemer s)
to :: Rep (PProposalRedeemer s) -> PProposalRedeemer s
$cto :: forall (s :: S). Rep (PProposalRedeemer s) -> PProposalRedeemer s
from :: PProposalRedeemer s -> Rep (PProposalRedeemer s)
$cfrom :: forall (s :: S). PProposalRedeemer s -> Rep (PProposalRedeemer s)
Generic
)
deriving anyclass
(
PIsData PProposalRedeemer
PlutusType PProposalRedeemer
PlutusType PProposalRedeemer
-> PIsData PProposalRedeemer
-> (forall (s :: S).
PProposalRedeemer s
-> Term s (PDataSum (PIsDataReprRepr PProposalRedeemer)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalRedeemer))
-> (PProposalRedeemer s -> Term s b) -> Term s b)
-> PIsDataRepr PProposalRedeemer
forall (s :: S).
PProposalRedeemer s
-> Term s (PDataSum (PIsDataReprRepr PProposalRedeemer))
forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalRedeemer))
-> (PProposalRedeemer s -> Term s b) -> Term s b
forall (a :: PType).
PlutusType a
-> PIsData a
-> (forall (s :: S). a s -> Term s (PDataSum (PIsDataReprRepr a)))
-> (forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr a))
-> (a s -> Term s b) -> Term s b)
-> PIsDataRepr a
pmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalRedeemer))
-> (PProposalRedeemer s -> Term s b) -> Term s b
$cpmatchRepr :: forall (s :: S) (b :: PType).
Term s (PDataSum (PIsDataReprRepr PProposalRedeemer))
-> (PProposalRedeemer s -> Term s b) -> Term s b
pconRepr :: forall (s :: S).
PProposalRedeemer s
-> Term s (PDataSum (PIsDataReprRepr PProposalRedeemer))
$cpconRepr :: forall (s :: S).
PProposalRedeemer s
-> Term s (PDataSum (PIsDataReprRepr PProposalRedeemer))
PIsDataRepr
)
deriving
(
PCon PProposalRedeemer
PMatch PProposalRedeemer
PCon PProposalRedeemer
-> PMatch PProposalRedeemer
-> (forall (s :: S) (b :: PType).
PProposalRedeemer s -> Term s (PInner PProposalRedeemer b))
-> (forall (s :: S) (b :: PType).
Term s (PInner PProposalRedeemer b)
-> (PProposalRedeemer s -> Term s b) -> Term s b)
-> PlutusType PProposalRedeemer
forall (s :: S) (b :: PType).
Term s (PInner PProposalRedeemer b)
-> (PProposalRedeemer s -> Term s b) -> Term s b
forall (s :: S) (b :: PType).
PProposalRedeemer s -> Term s (PInner PProposalRedeemer b)
forall (a :: PType).
PCon a
-> PMatch a
-> (forall (s :: S) (b :: PType). a s -> Term s (PInner a b))
-> (forall (s :: S) (b :: PType).
Term s (PInner a b) -> (a s -> Term s b) -> Term s b)
-> PlutusType a
pmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalRedeemer b)
-> (PProposalRedeemer s -> Term s b) -> Term s b
$cpmatch' :: forall (s :: S) (b :: PType).
Term s (PInner PProposalRedeemer b)
-> (PProposalRedeemer s -> Term s b) -> Term s b
pcon' :: forall (s :: S) (b :: PType).
PProposalRedeemer s -> Term s (PInner PProposalRedeemer b)
$cpcon' :: forall (s :: S) (b :: PType).
PProposalRedeemer s -> Term s (PInner PProposalRedeemer b)
PlutusType
,
(forall (s :: S).
Term s (PAsData PProposalRedeemer) -> Term s PProposalRedeemer)
-> (forall (s :: S). Term s PProposalRedeemer -> Term s PData)
-> PIsData PProposalRedeemer
forall (s :: S).
Term s (PAsData PProposalRedeemer) -> Term s PProposalRedeemer
forall (s :: S). Term s PProposalRedeemer -> Term s PData
forall (a :: PType).
(forall (s :: S). Term s (PAsData a) -> Term s a)
-> (forall (s :: S). Term s a -> Term s PData) -> PIsData a
pdataImpl :: forall (s :: S). Term s PProposalRedeemer -> Term s PData
$cpdataImpl :: forall (s :: S). Term s PProposalRedeemer -> Term s PData
pfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalRedeemer) -> Term s PProposalRedeemer
$cpfromDataImpl :: forall (s :: S).
Term s (PAsData PProposalRedeemer) -> Term s PProposalRedeemer
PIsData
)
via PIsDataReprInstances PProposalRedeemer
deriving via
PAsData (PIsDataReprInstances PProposalRedeemer)
instance
PTryFrom PData (PAsData PProposalRedeemer)
instance PUnsafeLiftDecl PProposalRedeemer where type PLifted PProposalRedeemer = ProposalRedeemer
deriving via (DerivePConstantViaData ProposalRedeemer PProposalRedeemer) instance (PConstantDecl ProposalRedeemer)
proposalDatumValid :: Proposal -> Term s (Agora.Proposal.PProposalDatum :--> PBool)
proposalDatumValid :: forall (s :: S). Proposal -> Term s (PProposalDatum :--> PBool)
proposalDatumValid Proposal
proposal =
ClosedTerm (PProposalDatum :--> PBool)
-> Term s (PProposalDatum :--> PBool)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm (PProposalDatum :--> PBool)
-> Term s (PProposalDatum :--> PBool))
-> ClosedTerm (PProposalDatum :--> PBool)
-> Term s (PProposalDatum :--> PBool)
forall a b. (a -> b) -> a -> b
$
(Term s PProposalDatum -> Term s PBool)
-> Term s (PProposalDatum :--> PBool)
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term s PProposalDatum -> Term s PBool)
-> Term s (PProposalDatum :--> PBool))
-> (Term s PProposalDatum -> Term s PBool)
-> Term s (PProposalDatum :--> PBool)
forall a b. (a -> b) -> a -> b
$ \Term s PProposalDatum
datum' -> TermCont @PBool s (Term s PBool) -> Term s PBool
forall (a :: PType) (s :: S). TermCont @a s (Term s a) -> Term s a
unTermCont (TermCont @PBool s (Term s PBool) -> Term s PBool)
-> TermCont @PBool s (Term s PBool) -> Term s PBool
forall a b. (a -> b) -> a -> b
$ do
HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
datum <- ((HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
-> Term s PBool)
-> Term s PBool)
-> TermCont
@PBool
s
(HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type))))))
forall a (s :: S) (r :: PType).
((a -> Term s r) -> Term s r) -> TermCont @r s a
tcont (((HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
-> Term s PBool)
-> Term s PBool)
-> TermCont
@PBool
s
(HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))))
-> ((HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
-> Term s PBool)
-> Term s PBool)
-> TermCont
@PBool
s
(HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type))))))
forall a b. (a -> b) -> a -> b
$ forall (fs :: [Symbol]) (a :: PType) (s :: S) (b :: PType)
(ps :: [PLabeledType]) (bs :: [ToBind]).
(PDataFields a,
(ps :: [PLabeledType]) ~ (PFields a :: [PLabeledType]),
(bs :: [ToBind]) ~ (Bindings ps fs :: [ToBind]),
BindFields ps bs) =>
Term s a -> (HRecOf a fs s -> Term s b) -> Term s b
pletFields @'["effects", "cosigners", "votes"] (Term s PProposalDatum
-> (HRecOf
PProposalDatum
((':)
@Symbol
"effects"
((':) @Symbol "cosigners" ((':) @Symbol "votes" ('[] @Symbol))))
s
-> Term s PBool)
-> Term s PBool)
-> Term s PProposalDatum
-> (HRecOf
PProposalDatum
((':)
@Symbol
"effects"
((':) @Symbol "cosigners" ((':) @Symbol "votes" ('[] @Symbol))))
s
-> Term s PBool)
-> Term s PBool
forall a b. (a -> b) -> a -> b
$ Term s PProposalDatum
datum'
let atLeastOneNegativeResult :: Term s PBool
atLeastOneNegativeResult =
Term
s
((PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))
:--> PBool)
:--> (PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PBool))
forall (list :: PType -> PType) (a :: PType) (s :: S).
PIsListLike list a =>
Term s ((a :--> PBool) :--> (list a :--> PBool))
pany
# phoistAcyclic
(plam $ \m -> pnull #$ pto $ pfromData $ psndBuiltin # m)
#$ pto
$ pfromData datum.effects
Term s PBool -> TermCont @PBool s (Term s PBool)
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s PBool -> TermCont @PBool s (Term s PBool))
-> Term s PBool -> TermCont @PBool s (Term s PBool)
forall a b. (a -> b) -> a -> b
$
(Term s PBool -> Term s PBool -> Term s PBool)
-> [Term s PBool] -> Term s PBool
forall (t :: Type -> Type) a.
Foldable t =>
(a -> a -> a) -> t a -> a
foldr1
Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
(#&&)
[ Term s (PString @S) -> Term s PBool -> Term s PBool
forall (s :: S).
Term s (PString @S) -> Term s PBool -> Term s PBool
ptraceIfFalse Term s (PString @S)
"Proposal has at least one ResultTag has no effects" Term s PBool
atLeastOneNegativeResult
, Term s (PString @S) -> Term s PBool -> Term s PBool
forall (s :: S).
Term s (PString @S) -> Term s PBool -> Term s PBool
ptraceIfFalse Term s (PString @S)
"Proposal has at least one cosigner" (Term s PBool -> Term s PBool) -> Term s PBool -> Term s PBool
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinList (PAsData PPubKeyHash) :--> PBool)
forall (a :: PType) (s :: S) (list :: PType -> PType).
PIsListLike list a =>
Term s (list a :--> PBool)
pnotNull Term s (PBuiltinList (PAsData PPubKeyHash) :--> PBool)
-> Term s (PBuiltinList (PAsData PPubKeyHash)) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData (PBuiltinList (PAsData PPubKeyHash)))
-> Term s (PBuiltinList (PAsData PPubKeyHash))
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
datum.cosigners
, Term s (PString @S) -> Term s PBool -> Term s PBool
forall (s :: S).
Term s (PString @S) -> Term s PBool -> Term s PBool
ptraceIfFalse Term s (PString @S)
"Proposal has fewer cosigners than the limit" (Term s PBool -> Term s PBool) -> Term s PBool -> Term s PBool
forall a b. (a -> b) -> a -> b
$ Term s (PBuiltinList (PAsData PPubKeyHash) :--> PInteger @S)
forall (list :: PType -> PType) (a :: PType) (s :: S).
PIsListLike list a =>
Term s (list a :--> PInteger @S)
plength Term s (PBuiltinList (PAsData PPubKeyHash) :--> PInteger @S)
-> Term s (PBuiltinList (PAsData PPubKeyHash))
-> Term s (PInteger @S)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PAsData (PBuiltinList (PAsData PPubKeyHash)))
-> Term s (PBuiltinList (PAsData PPubKeyHash))
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
datum.cosigners Term s (PInteger @S) -> Term s (PInteger @S) -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#<= PLifted (PInteger @S) -> Term s (PInteger @S)
forall (p :: PType) (s :: S). PLift p => PLifted p -> Term s p
pconstant Proposal
proposal.maximumCosigners
, Term s (PString @S) -> Term s PBool -> Term s PBool
forall (s :: S).
Term s (PString @S) -> Term s PBool -> Term s PBool
ptraceIfFalse Term s (PString @S)
"Proposal votes and effects are compatible with each other" (Term s PBool -> Term s PBool) -> Term s PBool -> Term s PBool
forall a b. (a -> b) -> a -> b
$ Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> (PMap 'Unsorted PResultTag (PInteger @S) :--> PBool))
forall (k :: PType) (a :: PType) (b :: PType) (s :: S).
(POrd k, PIsData k) =>
Term s (PMap 'Unsorted k a :--> (PMap 'Unsorted k b :--> PBool))
PUM.pkeysEqual Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> (PMap 'Unsorted PResultTag (PInteger @S) :--> PBool))
-> Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
-> Term s (PMap 'Unsorted PResultTag (PInteger @S) :--> PBool)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
datum.effects Term s (PMap 'Unsorted PResultTag (PInteger @S) :--> PBool)
-> Term s (PMap 'Unsorted PResultTag (PInteger @S)) -> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PProposalVotes
-> forall (b :: PType). Term s (PInner PProposalVotes b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto (Term s (PAsData PProposalVotes) -> Term s PProposalVotes
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData HRec
((':)
@(Symbol, Type)
'("effects",
Term
s
(PAsData
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))))
((':)
@(Symbol, Type)
'("cosigners",
Term s (PAsData (PBuiltinList (PAsData PPubKeyHash))))
((':)
@(Symbol, Type)
'("votes", Term s (PAsData PProposalVotes))
('[] @(Symbol, Type)))))
datum.votes)
]
pwinner ::
Term
s
( PProposalVotes
:--> PInteger
:--> PResultTag
:--> PResultTag
)
pwinner :: forall (s :: S).
Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag)))
pwinner = (forall (s :: S).
Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag))))
-> Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag))))
-> Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag))))
-> (forall (s :: S).
Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag))))
-> Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag)))
forall a b. (a -> b) -> a -> b
$
(Term s PProposalVotes
-> Term s (PInteger @S) -> Term s PResultTag -> Term s PResultTag)
-> Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag)))
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term s PProposalVotes
-> Term s (PInteger @S) -> Term s PResultTag -> Term s PResultTag)
-> Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag))))
-> (Term s PProposalVotes
-> Term s (PInteger @S) -> Term s PResultTag -> Term s PResultTag)
-> Term
s
(PProposalVotes
:--> (PInteger @S :--> (PResultTag :--> PResultTag)))
forall a b. (a -> b) -> a -> b
$ \Term s PProposalVotes
votes Term s (PInteger @S)
quorum Term s PResultTag
neutral -> Term s (PMaybe PResultTag)
-> (PMaybe PResultTag s -> Term s PResultTag) -> Term s PResultTag
forall (a :: PType) (s :: S) (b :: PType).
PMatch a =>
Term s a -> (a s -> Term s b) -> Term s b
pmatch (Term s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
forall (s :: S).
Term s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
pwinner' Term s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
-> Term s PProposalVotes
-> Term s (PInteger @S :--> PMaybe PResultTag)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PProposalVotes
votes Term s (PInteger @S :--> PMaybe PResultTag)
-> Term s (PInteger @S) -> Term s (PMaybe PResultTag)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PInteger @S)
quorum) ((PMaybe PResultTag s -> Term s PResultTag) -> Term s PResultTag)
-> (PMaybe PResultTag s -> Term s PResultTag) -> Term s PResultTag
forall a b. (a -> b) -> a -> b
$ \case
PMaybe PResultTag s
PNothing -> Term s PResultTag
neutral
PJust Term s PResultTag
winner -> Term s PResultTag
winner
pwinner' ::
Term
s
( PProposalVotes
:--> PInteger
:--> PMaybe PResultTag
)
pwinner' :: forall (s :: S).
Term s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
pwinner' = (forall (s :: S).
Term s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag)))
-> Term
s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
Term s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag)))
-> Term
s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag)))
-> (forall (s :: S).
Term s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag)))
-> Term
s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
forall a b. (a -> b) -> a -> b
$
(Term s PProposalVotes
-> Term s (PInteger @S) -> Term s (PMaybe PResultTag))
-> Term
s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term s PProposalVotes
-> Term s (PInteger @S) -> Term s (PMaybe PResultTag))
-> Term
s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag)))
-> (Term s PProposalVotes
-> Term s (PInteger @S) -> Term s (PMaybe PResultTag))
-> Term
s (PProposalVotes :--> (PInteger @S :--> PMaybe PResultTag))
forall a b. (a -> b) -> a -> b
$ \Term s PProposalVotes
votes Term s (PInteger @S)
quorum -> TermCont @(PMaybe PResultTag) s (Term s (PMaybe PResultTag))
-> Term s (PMaybe PResultTag)
forall (a :: PType) (s :: S). TermCont @a s (Term s a) -> Term s a
unTermCont (TermCont @(PMaybe PResultTag) s (Term s (PMaybe PResultTag))
-> Term s (PMaybe PResultTag))
-> TermCont @(PMaybe PResultTag) s (Term s (PMaybe PResultTag))
-> Term s (PMaybe PResultTag)
forall a b. (a -> b) -> a -> b
$ do
Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
winner <- Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> TermCont
@(PMaybe PResultTag)
s
(Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
forall {r :: PType} (s :: S) (a :: PType).
Term s a -> TermCont @r s (Term s a)
pletC (Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> TermCont
@(PMaybe PResultTag)
s
(Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> TermCont
@(PMaybe PResultTag)
s
(Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
forall a b. (a -> b) -> a -> b
$ Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (s :: S).
Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
phighestVotes Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s PProposalVotes
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s PProposalVotes
votes
Term s PResultTag
winnerResultTag <- Term s PResultTag
-> TermCont @(PMaybe PResultTag) s (Term s PResultTag)
forall {r :: PType} (s :: S) (a :: PType).
Term s a -> TermCont @r s (Term s a)
pletC (Term s PResultTag
-> TermCont @(PMaybe PResultTag) s (Term s PResultTag))
-> Term s PResultTag
-> TermCont @(PMaybe PResultTag) s (Term s PResultTag)
forall a b. (a -> b) -> a -> b
$ Term s (PAsData PResultTag) -> Term s PResultTag
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData PResultTag) -> Term s PResultTag)
-> Term s (PAsData PResultTag) -> Term s PResultTag
forall a b. (a -> b) -> a -> b
$ Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData PResultTag)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData PResultTag)
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PAsData PResultTag)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
winner
Term s (PInteger @S)
highestVotes <- Term s (PInteger @S)
-> TermCont @(PMaybe PResultTag) s (Term s (PInteger @S))
forall {r :: PType} (s :: S) (a :: PType).
Term s a -> TermCont @r s (Term s a)
pletC (Term s (PInteger @S)
-> TermCont @(PMaybe PResultTag) s (Term s (PInteger @S)))
-> Term s (PInteger @S)
-> TermCont @(PMaybe PResultTag) s (Term s (PInteger @S))
forall a b. (a -> b) -> a -> b
$ Term s (PAsData (PInteger @S)) -> Term s (PInteger @S)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PInteger @S)) -> Term s (PInteger @S))
-> Term s (PAsData (PInteger @S)) -> Term s (PInteger @S)
forall a b. (a -> b) -> a -> b
$ Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData (PInteger @S))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PAsData (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
winner
let l :: Term _ (PBuiltinList _)
l :: Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
l = Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> forall (b :: PType).
Term s (PInner (PMap 'Unsorted PResultTag (PInteger @S)) b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto (Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> forall (b :: PType).
Term s (PInner (PMap 'Unsorted PResultTag (PInteger @S)) b))
-> Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> forall (b :: PType).
Term s (PInner (PMap 'Unsorted PResultTag (PInteger @S)) b)
forall a b. (a -> b) -> a -> b
$ Term s PProposalVotes
-> forall (b :: PType). Term s (PInner PProposalVotes b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto Term s PProposalVotes
votes
f ::
Term
_
( PBuiltinPair (PAsData PResultTag) (PAsData PInteger)
:--> PInteger
:--> PInteger
)
f :: Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S))
f = (Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PInteger @S) -> Term s (PInteger @S))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S))
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PInteger @S) -> Term s (PInteger @S))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S)))
-> (Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PInteger @S) -> Term s (PInteger @S))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S))
forall a b. (a -> b) -> a -> b
$ \(Term s (PAsData (PInteger @S)) -> Term s (PInteger @S)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PInteger @S)) -> Term s (PInteger @S))
-> (Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PInteger @S)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin #) -> Term s (PInteger @S)
thisVotes) Term s (PInteger @S)
i ->
Term s PBool
-> Term s (PInteger @S)
-> Term s (PInteger @S)
-> Term s (PInteger @S)
forall (s :: S) (a :: PType).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
(Term s (PInteger @S)
thisVotes Term s (PInteger @S) -> Term s (PInteger @S) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PInteger @S)
highestVotes)
(Term s (PInteger @S)
i Term s (PInteger @S)
-> Term s (PInteger @S) -> Term s (PInteger @S)
forall a. Num a => a -> a -> a
+ Term s (PInteger @S)
1)
Term s (PInteger @S)
i
noDuplicateHighestVotes :: Term s PBool
noDuplicateHighestVotes =
Term s (PString @S) -> Term s PBool -> Term s PBool
forall (s :: S).
Term s (PString @S) -> Term s PBool -> Term s PBool
ptraceIfFalse Term s (PString @S)
"Ambiguous winner" (Term s PBool -> Term s PBool) -> Term s PBool -> Term s PBool
forall a b. (a -> b) -> a -> b
$
Term
s
((PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S))
:--> (PInteger @S
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PInteger @S)))
forall (list :: PType -> PType) (a :: PType) (s :: S) (b :: PType).
PIsListLike list a =>
Term s ((a :--> (b :--> b)) :--> (b :--> (list a :--> b)))
pfoldr Term
s
((PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S))
:--> (PInteger @S
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PInteger @S)))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S))
-> Term
s
(PInteger @S
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PInteger @S :--> PInteger @S))
f Term
s
(PInteger @S
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PInteger @S))
-> Term s (PInteger @S)
-> Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PInteger @S)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PInteger @S)
0 Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PInteger @S)
-> Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term s (PInteger @S)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
l Term s (PInteger @S) -> Term s (PInteger @S) -> Term s PBool
forall (t :: PType) (s :: S).
PEq t =>
Term s t -> Term s t -> Term s PBool
#== Term s (PInteger @S)
1
exceedQuorum :: Term s PBool
exceedQuorum =
Term s (PString @S) -> Term s PBool -> Term s PBool
forall (s :: S).
Term s (PString @S) -> Term s PBool -> Term s PBool
ptraceIfFalse Term s (PString @S)
"Highest vote count should exceed the minimum threshold" (Term s PBool -> Term s PBool) -> Term s PBool -> Term s PBool
forall a b. (a -> b) -> a -> b
$
Term s (PInteger @S)
quorum Term s (PInteger @S) -> Term s (PInteger @S) -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s (PInteger @S)
highestVotes
Term s (PMaybe PResultTag)
-> TermCont @(PMaybe PResultTag) s (Term s (PMaybe PResultTag))
forall (f :: Type -> Type) a. Applicative f => a -> f a
pure (Term s (PMaybe PResultTag)
-> TermCont @(PMaybe PResultTag) s (Term s (PMaybe PResultTag)))
-> Term s (PMaybe PResultTag)
-> TermCont @(PMaybe PResultTag) s (Term s (PMaybe PResultTag))
forall a b. (a -> b) -> a -> b
$
Term s PBool
-> Term s (PMaybe PResultTag)
-> Term s (PMaybe PResultTag)
-> Term s (PMaybe PResultTag)
forall (s :: S) (a :: PType).
Term s PBool -> Term s a -> Term s a -> Term s a
pif
(Term s PBool
noDuplicateHighestVotes Term s PBool -> Term s PBool -> Term s PBool
forall (s :: S). Term s PBool -> Term s PBool -> Term s PBool
#&& Term s PBool
exceedQuorum)
(PMaybe PResultTag s -> Term s (PMaybe PResultTag)
forall (a :: PType) (s :: S). PCon a => a s -> Term s a
pcon (PMaybe PResultTag s -> Term s (PMaybe PResultTag))
-> PMaybe PResultTag s -> Term s (PMaybe PResultTag)
forall a b. (a -> b) -> a -> b
$ Term s PResultTag -> PMaybe PResultTag s
forall (a :: PType) (s :: S). Term s a -> PMaybe a s
PJust Term s PResultTag
winnerResultTag)
(PMaybe PResultTag s -> Term s (PMaybe PResultTag)
forall (a :: PType) (s :: S). PCon a => a s -> Term s a
pcon PMaybe PResultTag s
forall (a :: PType) (s :: S). PMaybe a s
PNothing)
phighestVotes ::
Term
s
( PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData PInteger)
)
phighestVotes :: forall (s :: S).
Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
phighestVotes = (forall (s :: S).
Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> (forall (s :: S).
Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall a b. (a -> b) -> a -> b
$
(Term s PProposalVotes
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term s PProposalVotes
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> (Term s PProposalVotes
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PProposalVotes
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall a b. (a -> b) -> a -> b
$ \Term s PProposalVotes
votes ->
let l :: Term _ (PBuiltinList _)
l :: Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
l = Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> forall (b :: PType).
Term s (PInner (PMap 'Unsorted PResultTag (PInteger @S)) b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto (Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> forall (b :: PType).
Term s (PInner (PMap 'Unsorted PResultTag (PInteger @S)) b))
-> Term s (PMap 'Unsorted PResultTag (PInteger @S))
-> forall (b :: PType).
Term s (PInner (PMap 'Unsorted PResultTag (PInteger @S)) b)
forall a b. (a -> b) -> a -> b
$ Term s PProposalVotes
-> forall (b :: PType). Term s (PInner PProposalVotes b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto Term s PProposalVotes
votes
f ::
Term
_
( PBuiltinPair (PAsData PResultTag) (PAsData PInteger)
:--> PBuiltinPair (PAsData PResultTag) (PAsData PInteger)
:--> PBuiltinPair (PAsData PResultTag) (PAsData PInteger)
)
f :: Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
f = ClosedTerm
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))))
-> ClosedTerm
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
forall a b. (a -> b) -> a -> b
$
(Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))))
-> (Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
forall a b. (a -> b) -> a -> b
$ \Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
this Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
last ->
let lastVotes :: Term s (PInteger @S)
lastVotes = Term s (PAsData (PInteger @S)) -> Term s (PInteger @S)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PInteger @S)) -> Term s (PInteger @S))
-> Term s (PAsData (PInteger @S)) -> Term s (PInteger @S)
forall a b. (a -> b) -> a -> b
$ Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData (PInteger @S))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PAsData (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
last
thisVotes :: Term s (PInteger @S)
thisVotes = Term s (PAsData (PInteger @S)) -> Term s (PInteger @S)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PInteger @S)) -> Term s (PInteger @S))
-> Term s (PAsData (PInteger @S)) -> Term s (PInteger @S)
forall a b. (a -> b) -> a -> b
$ Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PAsData (PInteger @S))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term s (PAsData (PInteger @S))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
this
in Term s PBool
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (s :: S) (a :: PType).
Term s PBool -> Term s a -> Term s a -> Term s a
pif (Term s (PInteger @S)
lastVotes Term s (PInteger @S) -> Term s (PInteger @S) -> Term s PBool
forall (t :: PType) (s :: S).
POrd t =>
Term s t -> Term s t -> Term s PBool
#< Term s (PInteger @S)
thisVotes) Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
this Term s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
last
in Term
s
((PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))))
forall (list :: PType -> PType) (a :: PType) (s :: S) (b :: PType).
PIsListLike list a =>
Term s ((a :--> (b :--> b)) :--> (b :--> (list a :--> b)))
pfoldr Term
s
((PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
ClosedTerm
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
f Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))
:--> (PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# (Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> a)
phead Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
l) Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
:--> PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
-> Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
-> Term
s (PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
s
(PBuiltinList
(PBuiltinPair (PAsData PResultTag) (PAsData (PInteger @S))))
l
pneutralOption ::
Term
s
( PMap 'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag
)
pneutralOption :: forall (s :: S).
Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag)
pneutralOption = (forall (s :: S).
Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag))
-> Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic ((forall (s :: S).
Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag))
-> Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag))
-> (forall (s :: S).
Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag))
-> Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag)
forall a b. (a -> b) -> a -> b
$
(Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
-> Term s PResultTag)
-> Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag)
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
-> Term s PResultTag)
-> Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag))
-> (Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
-> Term s PResultTag)
-> Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash)
:--> PResultTag)
forall a b. (a -> b) -> a -> b
$ \Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
effects ->
let l :: Term _ (PBuiltinList (PBuiltinPair (PAsData PResultTag) _))
l :: Term
s
(PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
l = Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
-> forall (b :: PType).
Term
s
(PInner
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto Term
s
(PMap
'Unsorted PResultTag (PMap 'Unsorted PValidatorHash PDatumHash))
effects
f :: Term _ (PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted _ _)) :--> PBool)
f :: Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
f = ClosedTerm
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
-> Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
forall (a :: PType) (s :: S).
HasCallStack =>
ClosedTerm a -> Term s a
phoistAcyclic (ClosedTerm
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
-> Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool))
-> ClosedTerm
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
-> Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
forall a b. (a -> b) -> a -> b
$
(Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w)))
-> Term s PBool)
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
forall a (b :: PType) (s :: S) (c :: PType).
PLamN a b s =>
(Term s c -> a) -> Term s (c :--> b)
plam ((Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w)))
-> Term s PBool)
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool))
-> (Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w)))
-> Term s PBool)
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
forall a b. (a -> b) -> a -> b
$ \((Term s (PAsData (PMap 'Unsorted w w))
-> Term s (PMap 'Unsorted w w)
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData (PMap 'Unsorted w w))
-> Term s (PMap 'Unsorted w w))
-> (Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w)))
-> Term s (PAsData (PMap 'Unsorted w w)))
-> Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w)))
-> Term s (PMap 'Unsorted w w)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Term
s
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PAsData (PMap 'Unsorted w w))
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> b)
psndBuiltin #) -> Term s (PMap 'Unsorted w w)
el)) ->
let el' :: Term _ (PBuiltinList _)
el' :: Term s (PBuiltinList (PBuiltinPair (PAsData w) (PAsData w)))
el' = Term s (PMap 'Unsorted w w)
-> forall (b :: PType). Term s (PInner (PMap 'Unsorted w w) b)
forall (s :: S) (a :: PType).
Term s a -> forall (b :: PType). Term s (PInner a b)
pto Term s (PMap 'Unsorted w w)
el
in Term
s (PBuiltinList (PBuiltinPair (PAsData w) (PAsData w)) :--> PBool)
forall (list :: PType -> PType) (a :: PType) (s :: S).
(PListLike list, PElemConstraint list a) =>
Term s (list a :--> PBool)
pnull Term
s (PBuiltinList (PBuiltinPair (PAsData w) (PAsData w)) :--> PBool)
-> Term s (PBuiltinList (PBuiltinPair (PAsData w) (PAsData w)))
-> Term s PBool
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PBuiltinList (PBuiltinPair (PAsData w) (PAsData w)))
el'
in Term s (PAsData PResultTag) -> Term s PResultTag
forall (a :: PType) (s :: S).
PIsData a =>
Term s (PAsData a) -> Term s a
pfromData (Term s (PAsData PResultTag) -> Term s PResultTag)
-> Term s (PAsData PResultTag) -> Term s PResultTag
forall a b. (a -> b) -> a -> b
$ Term
s
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))
:--> PAsData PResultTag)
forall (s :: S) (a :: PType) (b :: PType).
Term s (PBuiltinPair a b :--> a)
pfstBuiltin Term
s
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))
:--> PAsData PResultTag)
-> Term
s
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
-> Term s (PAsData PResultTag)
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
s
(PString @S
:--> (PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
forall (a :: PType) (s :: S).
Term s (PString @S :--> (PMaybe a :--> a))
mustBePJust Term
s
(PString @S
:--> (PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
-> Term s (PString @S)
-> Term
s
(PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term s (PString @S)
"No neutral option" Term
s
(PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
-> Term
s
(PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
-> Term
s
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
#$ Term
s
((PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))
:--> PBool)
:--> (PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))))
forall (l :: PType -> PType) (a :: PType) (s :: S).
PIsListLike l a =>
Term s ((a :--> PBool) :--> (l a :--> PMaybe a))
pfind Term
s
((PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))
:--> PBool)
:--> (PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))))
-> Term
s
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))
:--> PBool)
-> Term
s
(PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
s
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))
:--> PBool)
forall {w :: S} {w :: PType} {w :: PType}.
Term
w
(PBuiltinPair (PAsData PResultTag) (PAsData (PMap 'Unsorted w w))
:--> PBool)
f Term
s
(PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash)))
:--> PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
-> Term
s
(PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
-> Term
s
(PMaybe
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
forall (s :: S) (a :: PType) (b :: PType).
Term s (a :--> b) -> Term s a -> Term s b
# Term
s
(PBuiltinList
(PBuiltinPair
(PAsData PResultTag)
(PAsData (PMap 'Unsorted PValidatorHash PDatumHash))))
l