Skip to content

Commit

Permalink
wIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Jul 22, 2024
1 parent 0b9802b commit 04f540f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 25 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ extra-packages: Cabal, process
if impl(ghc < 9.8)
constraints: interpolatedstring-perl6:setup.time source

program-options
ghc-options: -Werror
-- program-options
-- ghc-options: -Werror

package cryptonite
-- Using RDRAND instead of /dev/urandom as an entropy source for key
Expand Down
6 changes: 3 additions & 3 deletions cardano-api/internal/Cardano/Api/Experimental/Eras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module Cardano.Api.Experimental.Eras
( -- * New Era interface
BabbageEra
, ConwayEra
, Era
, pattern CurrentEra
, pattern UpcomingEra
, Era(..)
, UseEra
, AvailableErasToSbe
, ToConstrainedEra
, UninhabitableType
, EraCurrentlyNonExistent
, useEra
, protocolVersionToSbe
)
Expand Down
18 changes: 13 additions & 5 deletions cardano-api/internal/Cardano/Api/Experimental/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ import qualified Cardano.Ledger.Core as Ledger

import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import Data.Void
import Lens.Micro




testSigner :: Either UnsignedTxError (UnsignedTx ConwayEra)
testSigner = makeUnsignedTx CurrentEra undefined
--testSigner :: Either UnsignedTxError _
-- testSigner = makeUnsignedTx UpcomingEra undefined



t :: Either UnsignedTxError (Ledger.TxBody BabbageEra)
t = eraSpecificLedgerTxBody CurrentEra undefined undefined

-- | A transaction that can contain everything
-- except key witnesses
Expand Down Expand Up @@ -112,6 +116,10 @@ makeUnsignedTx era bc = do
& L.auxDataTxL .~ maybeToStrictMaybe (toAuxiliaryData sbe (txMetadata bc) (txAuxScripts bc))
& L.isValidTxL .~ txScriptValidityToIsValid apiScriptValidity





eraSpecificLedgerTxBody
:: Era era
-> Ledger.TxBody (ToConstrainedEra era)
Expand Down Expand Up @@ -144,8 +152,8 @@ eraSpecificLedgerTxBody_
-> Ledger.TxBody (ToConstrainedEra era)
-> TxBodyContent BuildTx (AvailableErasToSbe era)
-> Either UnsignedTxError (Ledger.TxBody (ToConstrainedEra era))
eraSpecificLedgerTxBody_ UpcomingEra ledgerbody _bc =
case UpcomingEra :: Era Void of {}
eraSpecificLedgerTxBody_ UpcomingEra ledgerbody _bc = return ledgerbody

-- sbe <- maybe (Left $ error "eraSpecificLedgerTxBody: TODO") Right $ protocolVersionToSbe CurrentEra
--
-- setUpdateProposal <- first UnsignedTxError $ convTxUpdateProposal sbe (txUpdateProposal bc)
Expand Down
18 changes: 3 additions & 15 deletions cardano-api/internal/Cardano/Api/Protocol/AvailableEras.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
Expand Down Expand Up @@ -33,12 +34,8 @@ import qualified Cardano.Api.Eras.Core as Api

import qualified Cardano.Ledger.Babbage as Ledger
import qualified Cardano.Ledger.Conway as Ledger
import Ouroboros.Consensus.HardFork.Combinator.State (Current)

import Control.Monad
import Data.Kind
import Data.Type.Equality (testEquality, (:~:) (Refl))
import Data.Void
import GHC.TypeLits

-- | Users typically interact with the latest features on the mainnet or experiment with features
Expand Down Expand Up @@ -81,19 +78,9 @@ data Era era where
-- | The era currently active on Cardano's mainnet.
CurrentEra :: Era ConwayEra
-- | The era planned for the next hardfork on Cardano's mainnet.
UpcomingEra :: Era Void


--instance Functor Era where
-- fmap f CurrentEra = const (void f) CurrentEra
UpcomingEra :: Era (UninhabitableType EraCurrentlyNonExistent)

data Dumb a where
DumbA :: Dumb Int
-- TODO: Figure out if its possible to write a functor instance for a GADT like yours
instance Functor Dumb where
fmap _ DumbA = (DumbA :: Dumb Int)

-- fmap _ UpcomingEra = UpcomingEra


{- | How to deprecate an era
Expand Down Expand Up @@ -150,6 +137,7 @@ Consumers of this library must pick one of the two eras while
this library is responsibile for what happens at the boundary of the eras.
-}


protocolVersionToSbe
:: Era era
-> Maybe (ShelleyBasedEra (AvailableErasToSbe era))
Expand Down

0 comments on commit 04f540f

Please sign in to comment.