-- File auto generated by purescript-bridge! -- module Agora.Proposal where import Prelude import Agora.Proposal.Time (ProposalStartingTime, ProposalTimingConfig) import Agora.SafeMoney (GTTag) import Data.Bounded.Generic (genericBottom, genericTop) import Data.Enum (class Enum) import Data.Enum.Generic (genericPred, genericSucc) import Data.Generic.Rep (class Generic) import Data.Lens (Iso', Lens', Prism', iso, prism') import Data.Lens.Iso.Newtype (_Newtype) import Data.Lens.Record (prop) import Data.Maybe (Maybe(..)) import Data.Newtype (class Newtype) import Data.Tagged (Tagged) import GHC.Num.Integer (Integer) import PlutusLedgerApi.V1.Crypto (PubKeyHash) import PlutusLedgerApi.V1.Scripts (DatumHash, ValidatorHash) import PlutusLedgerApi.V1.Value (AssetClass) import PlutusTx.AssocMap (Map) import Type.Proxy (Proxy(Proxy)) newtype ProposalId = ProposalId { proposalTag :: Integer } derive instance Generic ProposalId _ derive instance Newtype ProposalId _ -------------------------------------------------------------------------------- _ProposalId :: Iso' ProposalId {proposalTag :: Integer} _ProposalId = _Newtype -------------------------------------------------------------------------------- newtype ResultTag = ResultTag { getResultTag :: Integer } derive instance Generic ResultTag _ derive instance Newtype ResultTag _ -------------------------------------------------------------------------------- _ResultTag :: Iso' ResultTag {getResultTag :: Integer} _ResultTag = _Newtype -------------------------------------------------------------------------------- data ProposalStatus = Draft | VotingReady | Locked | Finished derive instance Generic ProposalStatus _ instance Enum ProposalStatus where succ = genericSucc pred = genericPred instance Bounded ProposalStatus where bottom = genericBottom top = genericTop -------------------------------------------------------------------------------- _Draft :: Prism' ProposalStatus Unit _Draft = prism' (const Draft) case _ of Draft -> Just unit _ -> Nothing _VotingReady :: Prism' ProposalStatus Unit _VotingReady = prism' (const VotingReady) case _ of VotingReady -> Just unit _ -> Nothing _Locked :: Prism' ProposalStatus Unit _Locked = prism' (const Locked) case _ of Locked -> Just unit _ -> Nothing _Finished :: Prism' ProposalStatus Unit _Finished = prism' (const Finished) case _ of Finished -> Just unit _ -> Nothing -------------------------------------------------------------------------------- newtype ProposalThresholds = ProposalThresholds { countVoting :: Tagged GTTag Integer , create :: Tagged GTTag Integer , startVoting :: Tagged GTTag Integer } derive instance Generic ProposalThresholds _ derive instance Newtype ProposalThresholds _ -------------------------------------------------------------------------------- _ProposalThresholds :: Iso' ProposalThresholds {countVoting :: Tagged GTTag Integer, create :: Tagged GTTag Integer, startVoting :: Tagged GTTag Integer} _ProposalThresholds = _Newtype -------------------------------------------------------------------------------- newtype ProposalVotes = ProposalVotes { getProposalVotes :: Map ResultTag Integer } derive instance Generic ProposalVotes _ derive instance Newtype ProposalVotes _ -------------------------------------------------------------------------------- _ProposalVotes :: Iso' ProposalVotes {getProposalVotes :: Map ResultTag Integer} _ProposalVotes = _Newtype -------------------------------------------------------------------------------- newtype ProposalDatum = ProposalDatum { proposalId :: ProposalId , effects :: Map ResultTag (Map ValidatorHash DatumHash) , status :: ProposalStatus , cosigners :: Array PubKeyHash , thresholds :: ProposalThresholds , votes :: ProposalVotes , timingConfig :: ProposalTimingConfig , startingTime :: ProposalStartingTime } derive instance Generic ProposalDatum _ derive instance Newtype ProposalDatum _ -------------------------------------------------------------------------------- _ProposalDatum :: Iso' ProposalDatum {proposalId :: ProposalId, effects :: Map ResultTag (Map ValidatorHash DatumHash), status :: ProposalStatus, cosigners :: Array PubKeyHash, thresholds :: ProposalThresholds, votes :: ProposalVotes, timingConfig :: ProposalTimingConfig, startingTime :: ProposalStartingTime} _ProposalDatum = _Newtype -------------------------------------------------------------------------------- data ProposalRedeemer = Vote ResultTag | Cosign (Array PubKeyHash) | Unlock ResultTag | AdvanceProposal derive instance Generic ProposalRedeemer _ -------------------------------------------------------------------------------- _Vote :: Prism' ProposalRedeemer ResultTag _Vote = prism' Vote case _ of (Vote a) -> Just a _ -> Nothing _Cosign :: Prism' ProposalRedeemer (Array PubKeyHash) _Cosign = prism' Cosign case _ of (Cosign a) -> Just a _ -> Nothing _Unlock :: Prism' ProposalRedeemer ResultTag _Unlock = prism' Unlock case _ of (Unlock a) -> Just a _ -> Nothing _AdvanceProposal :: Prism' ProposalRedeemer Unit _AdvanceProposal = prism' (const AdvanceProposal) case _ of AdvanceProposal -> Just unit _ -> Nothing -------------------------------------------------------------------------------- newtype Proposal = Proposal { governorSTAssetClass :: AssetClass , stakeSTAssetClass :: AssetClass , maximumCosigners :: Integer } derive instance Generic Proposal _ derive instance Newtype Proposal _ -------------------------------------------------------------------------------- _Proposal :: Iso' Proposal {governorSTAssetClass :: AssetClass, stakeSTAssetClass :: AssetClass, maximumCosigners :: Integer} _Proposal = _Newtype