module Ledger.Conway.Foreign.Gov.Core where
open import Foreign.Convertible
open import Foreign.Convertible.Deriving
open import Foreign.HaskellTypes.Deriving
open import Ledger.Prelude
open import Ledger.Prelude.Foreign.HSTypes
open import Ledger.Prelude.Foreign.Util
open import Ledger.Core.Foreign.Address
open import Ledger.Conway.Foreign.HSStructures hiding (Vote)
open import Ledger.Conway.Specification.Gov.Actions govStructure using (Vote)
instance
HsTy-GovRole = autoHsType GovRole
Conv-GovRole = autoConvert GovRole
HsTy-Anchor = autoHsType Anchor
Conv-Anchor = autoConvert Anchor
HsTy-VDeleg = autoHsType VDeleg
Conv-VDeleg = autoConvert VDeleg
HsTy-Vote = autoHsType Vote
Conv-Vote = autoConvert Vote
HsTy-GovVotes = autoHsType GovVotes
Conv-GovVotes = autoConvert GovVotes
GovVoter' : Type
GovVoter' = GovRole × Credential
instance
mkGovVoter' : Convertible GovVoter GovVoter'
mkGovVoter' .to $\begin{pmatrix} \,\href{Ledger.Conway.Specification.Gov.Actions.html#423}{\htmlId{944}{\htmlClass{InductiveConstructor}{\text{CC}}}}\, \\ \,\href{Ledger.Conway.Foreign.Gov.Core.html#951}{\htmlId{951}{\htmlClass{Bound}{\text{c}}}}\, \end{pmatrix}$ = CC , c
mkGovVoter' .to $\begin{pmatrix} \,\href{Ledger.Conway.Specification.Gov.Actions.html#426}{\htmlId{988}{\htmlClass{InductiveConstructor}{\text{DRep}}}}\, \\ \,\href{Ledger.Conway.Foreign.Gov.Core.html#995}{\htmlId{995}{\htmlClass{Bound}{\text{c}}}}\, \end{pmatrix}$ = DRep , c
mkGovVoter' .to $\begin{pmatrix} \,\href{Ledger.Conway.Specification.Gov.Actions.html#431}{\htmlId{1032}{\htmlClass{InductiveConstructor}{\text{SPO}}}}\, \\ \,\href{Ledger.Conway.Foreign.Gov.Core.html#1039}{\htmlId{1039}{\htmlClass{Bound}{\text{c}}}}\, \end{pmatrix}$ = SPO , KeyHashObj c
mkGovVoter' .from (CC , c) = $\begin{pmatrix} \,\href{Ledger.Conway.Specification.Gov.Actions.html#423}{\htmlId{1104}{\htmlClass{InductiveConstructor}{\text{CC}}}}\, \\ \,\href{Ledger.Conway.Foreign.Gov.Core.html#1095}{\htmlId{1111}{\htmlClass{Bound}{\text{c}}}}\, \end{pmatrix}$
mkGovVoter' .from (DRep , c) = $\begin{pmatrix} \,\href{Ledger.Conway.Specification.Gov.Actions.html#426}{\htmlId{1154}{\htmlClass{InductiveConstructor}{\text{DRep}}}}\, \\ \,\href{Ledger.Conway.Foreign.Gov.Core.html#1145}{\htmlId{1161}{\htmlClass{Bound}{\text{c}}}}\, \end{pmatrix}$
mkGovVoter' .from (SPO , c) =
case c of λ where
(KeyHashObj kh) → $\begin{pmatrix} \,\href{Ledger.Conway.Specification.Gov.Actions.html#431}{\htmlId{1250}{\htmlClass{InductiveConstructor}{\text{SPO}}}}\, \\ \,\href{Ledger.Conway.Foreign.Gov.Core.html#1242}{\htmlId{1256}{\htmlClass{Bound}{\text{kh}}}}\, \end{pmatrix}$
(ScriptObj _) → error "mkGovVoter: Converting from SPO with ScriptObj credential"
HsTy-GovVoter = MkHsType GovVoter (HsType GovVoter')
Conv-GovVoter : Convertible GovVoter (HsType GovVoter')
Conv-GovVoter = mkGovVoter' ⨾ Convertible-Pair
unquoteDecl = do
hsTypeAlias GovVoter
record GovVote' : Type where
field
gid : GovActionID
voter : GovVoter'
vote : Vote
anchor : Maybe Anchor
instance
mkGovVote' : Convertible GovVote GovVote'
mkGovVote' = λ where
.to v → let module v = GovVote v in record { gid = v.gid ; voter = to v.voter ; vote = v.vote ; anchor = v.anchor }
.from v → let module v = GovVote' v in record { gid = v.gid ; voter = from v.voter ; vote = v.vote ; anchor = v.anchor }
HsTy-GovVote' = autoHsType GovVote' ⊣ withConstructor "MkGovVote"
• withName "GovVote"
Conv-GovVote' = autoConvert GovVote'
HsTy-GovVote = MkHsType GovVote (HsType GovVote')
Conv-GovVote = mkGovVote' ⨾ Conv-GovVote'