Skip to content

Commit

Permalink
ormolu
Browse files Browse the repository at this point in the history
  • Loading branch information
polinavino committed May 4, 2021
1 parent 155d797 commit 4bfb3d8
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 27 deletions.
7 changes: 4 additions & 3 deletions alonzo/impl/src/Cardano/Ledger/Alonzo/PlutusScriptApi.hs
Expand Up @@ -45,7 +45,10 @@ import Cardano.Ledger.Era (Crypto, Era, ValidateScript (..))
import Cardano.Ledger.Mary.Value (PolicyID (..))
import qualified Cardano.Ledger.Mary.Value as Mary (Value (..))
import Cardano.Ledger.ShelleyMA.Timelocks (evalTimelock)
import Cardano.Slotting.EpochInfo
import Cardano.Slotting.Time (SystemStart)
import Data.Coders
import Data.Functor.Identity
import Data.List (foldl')
import qualified Data.Map as Map
import Data.Maybe (isJust, maybeToList)
Expand All @@ -69,9 +72,7 @@ import Shelley.Spec.Ledger.TxBody
witKeyHash,
)
import Shelley.Spec.Ledger.UTxO (UTxO (..))
import Cardano.Slotting.EpochInfo
import Cardano.Slotting.Time (SystemStart)
import Data.Functor.Identity

-- ===============================================================
-- From the specification, Figure 8 "Scripts and their Arguments"
-- ===============================================================
Expand Down
10 changes: 5 additions & 5 deletions alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxo.hs
Expand Up @@ -47,6 +47,7 @@ import Cardano.Ledger.ShelleyMA.Rules.Utxo (consumed)
import Cardano.Ledger.ShelleyMA.Timelocks (ValidityInterval (..), inInterval)
import qualified Cardano.Ledger.Val as Val
import Cardano.Prelude (HeapWords (..))
import Cardano.Slotting.EpochInfo.API (epochInfoSlotToUTCTime)
import Cardano.Slotting.Slot (SlotNo)
import Control.Iterate.SetAlgebra (dom, eval, (⊆), (◁), (➖))
import Control.Monad.Trans.Reader (asks)
Expand Down Expand Up @@ -85,9 +86,9 @@ import Shelley.Spec.Ledger.BaseTypes
( Network,
ShelleyBase,
StrictMaybe (..),
networkId,
epochInfoWithErr,
systemStart
networkId,
systemStart,
)
import qualified Shelley.Spec.Ledger.LedgerState as Shelley
import qualified Shelley.Spec.Ledger.STS.Utxo as Shelley
Expand All @@ -99,7 +100,6 @@ import Shelley.Spec.Ledger.UTxO
txouts,
unUTxO,
)
import Cardano.Slotting.EpochInfo.API (epochInfoSlotToUTCTime)

-- | Compute an estimate of the size of storing one UTxO entry.
-- This function implements the UTxO entry size estimate done by scaledMinDeposit in the ShelleyMA era
Expand All @@ -109,7 +109,7 @@ utxoEntrySize txout
-- no non-ada assets, no hash datum case
case dh of
SNothing -> adaOnlyUTxOSize
SJust _ -> adaOnlyUTxOSize + dataHashSize dh
SJust _ -> adaOnlyUTxOSize + dataHashSize dh
-- add the size of Value and the size of datum hash (if present) to base UTxO size
-- max function is a safeguard (in case calculation returns a smaller size than an ada-only entry)
| otherwise = max adaOnlyUTxOSize (utxoEntrySizeWithoutVal + Val.size v + dataHashSize dh)
Expand Down Expand Up @@ -327,7 +327,7 @@ utxoTransition = do
case i_f of
SNothing -> pure ()
SJust ifj -> case (epochInfoSlotToUTCTime ei sysSt ifj) of
Left _ -> False ?!# OutsideForecast ifj -- error translating slot
Left _ -> False ?!# OutsideForecast ifj -- error translating slot
Right _ -> pure ()

not (Set.null (Alonzo.txins @era txb)) ?!# InputSetEmptyUTxO
Expand Down
9 changes: 3 additions & 6 deletions alonzo/impl/src/Cardano/Ledger/Alonzo/Rules/Utxos.hs
Expand Up @@ -12,11 +12,6 @@

module Cardano.Ledger.Alonzo.Rules.Utxos where

import Control.Monad.Trans.Reader (asks)
import Shelley.Spec.Ledger.BaseTypes
( epochInfo,
systemStart
)
import Cardano.Binary (FromCBOR (..), ToCBOR (..))
import Cardano.Ledger.Alonzo.Language (Language)
import Cardano.Ledger.Alonzo.PlutusScriptApi
Expand Down Expand Up @@ -45,7 +40,7 @@ import Cardano.Ledger.Shelley.Constraints (PParamsDelta)
import qualified Cardano.Ledger.Val as Val
import Control.Iterate.SetAlgebra (eval, (∪), (⋪), (◁))
import Control.Monad.Except (MonadError (throwError))
import Control.Monad.Trans.Reader (runReader)
import Control.Monad.Trans.Reader (asks, runReader)
import Control.State.Transition.Extended
import Data.Coders
import Data.Foldable (toList)
Expand All @@ -59,7 +54,9 @@ import Shelley.Spec.Ledger.BaseTypes
( Globals,
ShelleyBase,
StrictMaybe (..),
epochInfo,
strictMaybeToMaybe,
systemStart,
)
import Shelley.Spec.Ledger.LedgerState (PPUPState (..), UTxOState (..), keyRefunds)
import qualified Shelley.Spec.Ledger.LedgerState as Shelley
Expand Down
13 changes: 6 additions & 7 deletions alonzo/impl/src/Cardano/Ledger/Alonzo/TxInfo.hs
Expand Up @@ -9,12 +9,10 @@ module Cardano.Ledger.Alonzo.TxInfo where

-- =============================================

import Cardano.Ledger.Alonzo.TxWitness (TxWitness)
import Cardano.Crypto.Hash.Class (Hash (UnsafeHash))
import Cardano.Ledger.Alonzo.Data (Data (..), getPlutusData)
import Cardano.Ledger.Alonzo.Scripts (CostModel (..), ExUnits (..), Script (..))
import Cardano.Ledger.Alonzo.Tx
import Data.Time.Clock (UTCTime (..))
import Cardano.Ledger.Alonzo.TxBody
( certs',
inputs',
Expand All @@ -27,6 +25,7 @@ import Cardano.Ledger.Alonzo.TxBody
wdrls',
)
import qualified Cardano.Ledger.Alonzo.TxBody as Alonzo (TxBody (..), TxOut (..))
import Cardano.Ledger.Alonzo.TxWitness (TxWitness)
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Core as Core (TxBody, TxOut, Value)
import qualified Cardano.Ledger.Crypto as CC (Crypto)
Expand All @@ -35,13 +34,17 @@ import qualified Cardano.Ledger.Mary.Value as Mary (AssetName (..), PolicyID (..
import Cardano.Ledger.SafeHash
import Cardano.Ledger.ShelleyMA.Timelocks (ValidityInterval (..))
import Cardano.Ledger.Val (Val (..))
import Cardano.Slotting.EpochInfo
import Cardano.Slotting.Slot (EpochNo (..), SlotNo (..))
import Cardano.Slotting.Time (SystemStart)
import Control.DeepSeq (deepseq)
import Data.ByteString as BS (ByteString, length)
import Data.ByteString.Short as SBS (ShortByteString, fromShort)
import Data.Functor.Identity
import qualified Data.Map as Map
import Data.Maybe (mapMaybe)
import qualified Data.Set as Set
import Data.Time.Clock (UTCTime (..))
import Data.Typeable (Typeable)
import GHC.Records (HasField (..))
import qualified Plutus.V1.Ledger.Ada as P (adaSymbol, adaToken)
Expand Down Expand Up @@ -78,9 +81,6 @@ import qualified PlutusTx as P (Data (..))
import qualified PlutusTx.IsData.Class as P (IsData (..))
import Shelley.Spec.Ledger.Address (Addr (..), RewardAcnt (..))
import Shelley.Spec.Ledger.BaseTypes (StrictMaybe (..))
import Cardano.Slotting.EpochInfo
import Cardano.Slotting.Time (SystemStart)
import Data.Functor.Identity
import Shelley.Spec.Ledger.Credential (Credential (KeyHashObj, ScriptHashObj), Ptr (..), StakeReference (..))
import Shelley.Spec.Ledger.Keys (KeyHash (..), hashKey)
import Shelley.Spec.Ledger.Scripts (ScriptHash (..))
Expand Down Expand Up @@ -183,7 +183,6 @@ transVITime ei sysS (ValidityInterval SNothing (SJust i)) =
transVITime ei sysS (ValidityInterval (SJust i) (SJust j)) =
TimeInterval (SJust (runIdentity $ epochInfoSlotToUTCTime ei sysS i)) (SJust (runIdentity $ epochInfoSlotToUTCTime ei sysS j))


-- ========================================
-- translate TxIn and TxOut

Expand Down Expand Up @@ -297,7 +296,7 @@ transScriptPurpose (Certifying dcert) = P.Certifying (transDCert dcert)
-- | Compute a Digest of the current transaction to pass to the script
-- This is the major component of the valContext function.
txInfo ::
forall era tx .
forall era tx.
( Era era,
Core.TxOut era ~ Alonzo.TxOut era,
Core.TxBody era ~ Alonzo.TxBody era,
Expand Down
Expand Up @@ -84,12 +84,12 @@ import Data.Text (Text)
import qualified Data.Text as Text
import Data.Text.Encoding (encodeUtf8)
import Data.Word (Word16, Word64, Word8)
import GHC.Exception.Type (Exception)
import GHC.Generics (Generic)
import NoThunks.Class (NoThunks (..))
import Numeric.Natural (Natural)
import Shelley.Spec.Ledger.Serialization (decodeRecordSum, ratioFromCBOR, ratioToCBOR)
import Shelley.Spec.NonIntegral (ln')
import GHC.Exception.Type (Exception)

data E34

Expand Down
Expand Up @@ -40,8 +40,8 @@ import NoThunks.Class (NoThunks (..))
import Shelley.Spec.Ledger.BaseTypes
( Globals (..),
ShelleyBase,
epochInfo,
invalidKey,
epochInfo
)
import Shelley.Spec.Ledger.Credential (Credential)
import Shelley.Spec.Ledger.HardForks as HardForks
Expand Down
Expand Up @@ -44,7 +44,7 @@ import Data.Word (Word64, Word8)
import GHC.Generics (Generic)
import GHC.Records (HasField (getField))
import NoThunks.Class (NoThunks (..))
import Shelley.Spec.Ledger.BaseTypes (Globals (..), Network, ShelleyBase, invalidKey, networkId, epochInfo)
import Shelley.Spec.Ledger.BaseTypes (Globals (..), Network, ShelleyBase, epochInfo, invalidKey, networkId)
import qualified Shelley.Spec.Ledger.HardForks as HardForks
import Shelley.Spec.Ledger.Keys (KeyHash (..), KeyRole (..))
import Shelley.Spec.Ledger.LedgerState (PState (..))
Expand Down
Expand Up @@ -34,8 +34,8 @@ import Shelley.Spec.Ledger.BaseTypes
( Globals (activeSlotCoeff, epochInfo, securityParameter),
Network (Testnet),
StrictMaybe (..),
truncateUnitInterval,
epochInfo,
truncateUnitInterval,
)
import Shelley.Spec.Ledger.Credential (Credential (..), StakeReference (..))
import Shelley.Spec.Ledger.Genesis (ShelleyGenesisStaking (..))
Expand Down
Expand Up @@ -121,10 +121,10 @@ import Shelley.Spec.Ledger.BaseTypes
Nonce,
ShelleyBase,
UnitInterval,
epochInfo,
mkActiveSlotCoeff,
mkNonceFromOutputVRF,
mkUnitInterval,
epochInfo,
)
import Shelley.Spec.Ledger.BlockChain (BHBody (..), Block, TxSeq, bhbody, bheader)
import Shelley.Spec.Ledger.Credential (Credential (..), StakeReference (..))
Expand Down
Expand Up @@ -56,7 +56,7 @@ import Shelley.Spec.Ledger.API
Delegation (..),
LEDGER,
)
import Shelley.Spec.Ledger.BaseTypes (epochInfo, StrictMaybe (..))
import Shelley.Spec.Ledger.BaseTypes (StrictMaybe (..), epochInfo)
import Shelley.Spec.Ledger.BlockChain
( Block (..),
TxSeq (..),
Expand Down

0 comments on commit 4bfb3d8

Please sign in to comment.