module Ledger.Conway.Foreign.HSLedger.Certs where

open import Ledger.Conway.Foreign.HSLedger.Address
open import Ledger.Conway.Foreign.HSLedger.BaseTypes renaming (⟦_,_,_⟧ᵈ to ⟦_,_,_⟧ᵈ'; DState to DState'
                                                              ; ⟦_,_⟧ᵛ to ⟦_,_⟧ᵛ'; GState to GState') hiding (CertEnv)
open import Ledger.Conway.Foreign.HSLedger.Gov.Core
open import Ledger.Conway.Foreign.HSLedger.PParams

open import Ledger.Conway.Conformance.Certs govStructure using (⟦_,_,_,_⟧ᵈ; ⟦_,_,_⟧ᵛ; DState; GState; CertEnv)

open import Ledger.Conway.Conformance.Certs.Properties govStructure
  using ( Computational-DELEG
        ; Computational-GOVCERT
        ; Computational-POOL
        )

instance
  HsTy-StakePoolParams = autoHsType StakePoolParams
  Conv-StakePoolParams = autoConvert StakePoolParams

  HsTy-DepositPurpose = autoHsType DepositPurpose
  Conv-DepositPurpose = autoConvert DepositPurpose

  HsTy-DelegEnv = autoHsType DelegEnv
     withConstructor "MkDelegEnv"
     withName "DelegEnv"
  Conv-DelegEnv = autoConvert DelegEnv

  HsTy-PState = autoHsType PState
     withConstructor "MkPState"
     fieldPrefix "ps"
  Conv-PState = autoConvert PState

  HsTy-CertEnv = autoHsType CertEnv
     withConstructor "MkCertEnv"
     fieldPrefix "ce"
  Conv-CertEnv = autoConvert CertEnv

  HsTy-DState = autoHsType DState
     withConstructor "MkDState"
     withName "DState"
     fieldPrefix "ds"
  Conv-DState = autoConvert DState

  HsTy-DCert = autoHsType DCert
  Conv-DCert = autoConvert DCert

  HsTy-GState = autoHsType GState
     withConstructor "MkGState"
     fieldPrefix "gs"
  Conv-GState = autoConvert GState

  Conv-DState-DState' : Convertible DState DState'
  Conv-DState-DState' .to $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1746}{\htmlId{1746}{\htmlClass{Bound}{\text{voteDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1759}{\htmlId{1759}{\htmlClass{Bound}{\text{stakeDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1773}{\htmlId{1773}{\htmlClass{Bound}{\text{rewards}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1783}{\htmlId{1783}{\htmlClass{Bound}{\text{deposits}}}}\, \end{pmatrix}$ = $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1746}{\htmlId{1799}{\htmlClass{Bound}{\text{voteDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1759}{\htmlId{1812}{\htmlClass{Bound}{\text{stakeDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1759}{\htmlId{1826}{\htmlClass{Bound}{\text{stakeDelegs}}}}\, \end{pmatrix}$
  Conv-DState-DState' .from $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1872}{\htmlId{1872}{\htmlClass{Bound}{\text{voteDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1885}{\htmlId{1885}{\htmlClass{Bound}{\text{stakeDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1899}{\htmlId{1899}{\htmlClass{Bound}{\text{rewards}}}}\, \end{pmatrix}$         = $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1872}{\htmlId{1923}{\htmlClass{Bound}{\text{voteDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1885}{\htmlId{1936}{\htmlClass{Bound}{\text{stakeDelegs}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#1885}{\htmlId{1950}{\htmlClass{Bound}{\text{stakeDelegs}}}}\, \\ \,\href{Class.HasEmptySet.html#287}{\htmlId{1964}{\htmlClass{Field}{\text{∅}}}}\, \end{pmatrix}$

  Conv-GState-GState' : Convertible GState GState'
  Conv-GState-GState' .to $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2049}{\htmlId{2049}{\htmlClass{Bound}{\text{dreps}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2057}{\htmlId{2057}{\htmlClass{Bound}{\text{ccHotKeys}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2069}{\htmlId{2069}{\htmlClass{Bound}{\text{deposits}}}}\, \end{pmatrix}$ = $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2049}{\htmlId{2085}{\htmlClass{Bound}{\text{dreps}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2057}{\htmlId{2093}{\htmlClass{Bound}{\text{ccHotKeys}}}}\, \end{pmatrix}$
  Conv-GState-GState' .from $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2137}{\htmlId{2137}{\htmlClass{Bound}{\text{dreps}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2145}{\htmlId{2145}{\htmlClass{Bound}{\text{ccHotKeys}}}}\, \end{pmatrix}$         = $\begin{pmatrix} \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2137}{\htmlId{2171}{\htmlClass{Bound}{\text{dreps}}}}\, \\ \,\href{Ledger.Conway.Foreign.HSLedger.Certs.html#2145}{\htmlId{2179}{\htmlClass{Bound}{\text{ccHotKeys}}}}\, \\ \,\href{Class.HasEmptySet.html#287}{\htmlId{2191}{\htmlClass{Field}{\text{∅}}}}\, \end{pmatrix}$

-- deleg-step : HsType (DelegEnv → DState → DCert → ComputationResult String DState)
-- deleg-step = to (compute Computational-DELEG)

-- {-# COMPILE GHC deleg-step as delegStep #-}

deleg-step : HsType (DelegEnv  DState  DCert  ComputationResult String DState)
deleg-step = to (compute Computational-DELEG)

{-# COMPILE GHC deleg-step as delegStep #-}

pool-step : HsType (PParams  PState  DCert  ComputationResult String PState)
pool-step = to (compute Computational-POOL)

{-# COMPILE GHC pool-step as poolStep #-}

-- govcert-step : HsType (CertEnv → GState → DCert → ComputationResult String GState)
-- govcert-step = to (compute Computational-GOVCERT)

-- {-# COMPILE GHC govcert-step as govCertStep #-}

govcert-step : HsType (CertEnv  GState  DCert  ComputationResult String GState)
govcert-step = to (compute Computational-GOVCERT)

{-# COMPILE GHC govcert-step as govCertStep #-}