Skip to content

Commit c08a64d

Browse files
authored
Merge pull request #109 from mlabs-haskell/euonymos/final-clean-up
Final code clean-up
2 parents 2a866fd + 92c7301 commit c08a64d

File tree

14 files changed

+60
-245
lines changed

14 files changed

+60
-245
lines changed

cabal.project

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ source-repository-package
2222
tag: d5b0e7ce07258482d53704ce19383013b1fa6610
2323
--sha256: 6+Os/mQDzBOU+TkTD+n/T1MFcI+Mn0/tcBMJhLRfqyA=
2424

25-
-- FIXME: Cannot use new commit, because it requires `plutus-ledger-api==1.29`
25+
-- Cannot use new commit, because it requires `plutus-ledger-api==1.29`
2626
source-repository-package
2727
type: git
2828
location: https://github.com/Plutonomicon/plutarch-plutus

cem-script.cabal

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ flag dev
1515
default: True
1616
manual: False
1717

18-
common common-lang
19-
-- Options from MLabs styleguide
18+
flag force-recomp
19+
description: Compile with -fforce-recomp and -Wunused-packages
20+
default: False
2021

22+
common common-lang
2123
ghc-options:
2224
-Wall -Wcompat -Wincomplete-record-updates
2325
-Wincomplete-uni-patterns -Wredundant-constraints
@@ -26,6 +28,12 @@ common common-lang
2628
if !flag(dev)
2729
ghc-options: -Werror
2830

31+
if flag(dev)
32+
default-extensions: PartialTypeSignatures
33+
34+
if flag(force-recomp)
35+
ghc-options: -fforce-recomp -Wunused-packages
36+
2937
build-depends:
3038
, base
3139
, extra
@@ -53,9 +61,6 @@ common common-lang
5361
UndecidableInstances
5462
ViewPatterns
5563

56-
if flag(dev)
57-
default-extensions: PartialTypeSignatures
58-
5964
default-language: GHC2021
6065

6166
common common-onchain
@@ -150,7 +155,6 @@ library
150155
Cardano.CEM.Indexing.Tx
151156
Cardano.CEM.Monads
152157
Cardano.CEM.Monads.CLB
153-
Cardano.CEM.Monads.L1
154158
Cardano.CEM.OffChain
155159
Cardano.CEM.OnChain
156160
Cardano.CEM.Testing.StateMachine

src-lib/cardano-extras/Cardano/Extras.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,6 @@ mintedTokens ::
275275
[(AssetName, Quantity)] ->
276276
Cardano.TxMintValue BuildTx Era
277277
mintedTokens script redeemer assets =
278-
-- FIXME: is hardcoding era correct?
279278
TxMintValue Cardano.MaryEraOnwardsBabbage mintedTokens' mintedWitnesses'
280279
where
281280
mintedTokens' = valueFromList (fmap (first (AssetId policyId)) assets)

src-lib/data-spine/Data/Spine.hs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ deriveSpine name = do
8888
suffix = "Spine"
8989
spineName = addSuffix name suffix
9090
spineDec <- deriveTags name suffix [''Eq, ''Ord, ''Enum, ''Show]
91-
-- TODO: derive Sing
92-
-- TODO: derive HasField (OfSpine ...)
9391

9492
decls <-
9593
[d|

src/Cardano/CEM.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class
111111
type EqShow datatype =
112112
( Prelude.Eq datatype
113113
, Prelude.Show datatype
114-
-- TODO: add IsData here? (now it breaks Plutus compilation)
114+
-- Shoul we add IsData here? (now it breaks Plutus compilation)
115115
)
116116

117117
{- | All associated types for 'CEMScript' class defined separately to simplify
@@ -223,7 +223,7 @@ data TxFanKind
223223
-- | Constraint on a single tx fan
224224
data TxFanFilter script = MkTxFanFilter
225225
{ address :: AddressSpec
226-
, rest :: FilterDatum script -- TODO: not ideal naming
226+
, datumFilter :: FilterDatum script
227227
}
228228
deriving stock (Show, Prelude.Eq)
229229

@@ -252,8 +252,8 @@ bySameCEM = UnsafeBySameCEM . toBuiltinData
252252

253253
-- | How many tx fans should satify a 'TxFansConstraint'
254254
data Quantifier
255-
= ExactlyNFans Integer -- TODO: use natural numbers
256-
| FansWithTotalValueOfAtLeast Value -- TODO: use natural numbers
255+
= ExactlyNFans Integer -- Here we'd better use natural numbers
256+
| FansWithTotalValueOfAtLeast Value
257257
deriving stock (Show)
258258

259259
-- | A constraint on Tx inputs or Outputs.

src/Cardano/CEM/Indexing/Event.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ import Prelude
4343
(3) For the final transition the situation is like (2) except the target
4444
datum is missing, which doesn't matter.
4545
46-
4746
TODO: How we can improve this in the future:
4847
* API is probably bad, as we always have some transition like Init state -
4948
which you can decode, as you have State. If one changes data

src/Cardano/CEM/Monads.hs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ data CEMAction script
2929
deriving stock instance
3030
(CEMScript script) => Show (CEMAction script)
3131

32-
-- FIXME: use generic Some
3332
data SomeCEMAction where
3433
MkSomeCEMAction ::
3534
forall script.
@@ -38,7 +37,6 @@ data SomeCEMAction where
3837
SomeCEMAction
3938

4039
instance Show SomeCEMAction where
41-
-- FIXME: show script name
4240
show :: SomeCEMAction -> String
4341
show (MkSomeCEMAction action) = show action
4442

@@ -54,8 +52,7 @@ data TxSpec = MkTxSpec
5452
data BlockchainParams = MkBlockchainParams
5553
{ protocolParameters :: PParams LedgerEra
5654
, systemStart :: SystemStart
57-
, -- FIXME: rename
58-
eraHistory :: LedgerEpochInfo
55+
, ledgerEpochInfo :: LedgerEpochInfo
5956
, stakePools :: Set PoolId
6057
}
6158
deriving stock (Show)

src/Cardano/CEM/Monads/CLB.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ instance
6060
queryBlockchainParams = do
6161
protocolParameters <- gets (mockConfigProtocol . mockConfig)
6262
slotConfig <- gets (mockConfigSlotConfig . mockConfig)
63-
eraHistory <- LedgerEpochInfo <$> getEpochInfo
63+
ledgerEpochInfo <- LedgerEpochInfo <$> getEpochInfo
6464
let systemStart =
6565
SystemStart $ posixTimeToUTCTime $ scSlotZeroTime slotConfig
6666
return $
6767
MkBlockchainParams
6868
{ protocolParameters
6969
, systemStart
70-
, eraHistory
70+
, ledgerEpochInfo
7171
, -- Staking is not supported
7272
stakePools = Set.empty
7373
}

src/Cardano/CEM/Monads/L1.hs

Lines changed: 0 additions & 151 deletions
This file was deleted.

src/Cardano/CEM/Monads/L1Commons.hs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,22 @@
33
-- | Code common for resolving Tx of backends which use `cardano-api`
44
module Cardano.CEM.Monads.L1Commons where
55

6-
import Prelude
7-
8-
import Data.List (nub)
9-
import Data.Map qualified as Map
10-
11-
-- Cardano imports
126
import Cardano.Api hiding (queryUtxo)
137
import Cardano.Api.Shelley (LedgerProtocolParameters (..))
14-
15-
-- Project imports
168
import Cardano.CEM.Monads
179
import Cardano.CEM.OffChain
1810
import Cardano.Extras
11+
import Data.List (nub)
12+
import Data.Map qualified as Map
1913
import Data.Maybe (mapMaybe)
14+
import Prelude
2015

21-
-- Main function
22-
16+
-- | Main function
2317
cardanoTxBodyFromResolvedTx ::
2418
(MonadQueryUtxo m, MonadBlockchainParams m) =>
2519
ResolvedTx ->
2620
m (Either (TxBodyErrorAutoBalance Era) (TxBodyContent BuildTx Era, TxBody Era, TxInMode, UTxO Era))
2721
cardanoTxBodyFromResolvedTx (MkResolvedTx {..}) = do
28-
-- (lowerBound, upperBound) <- convertValidityBound validityBound
29-
30-
-- FIXME: proper fee coverage selection
3122
utxo <- queryUtxo $ ByAddresses [signingKeyToAddress signer]
3223
let
3324
feeTxIns = Map.keys $ unUTxO utxo
@@ -41,8 +32,7 @@ cardanoTxBodyFromResolvedTx (MkResolvedTx {..}) = do
4132

4233
let preBody =
4334
TxBodyContent
44-
{ -- FIXME: duplicate TxIn for coin-selection redeemer bug
45-
txIns = nub allTxIns
35+
{ txIns = nub allTxIns -- duplicate TxIn for coin-selection redeemer bug
4636
, txInsCollateral =
4737
TxInsCollateral AlonzoEraOnwardsBabbage feeTxIns
4838
, txInsReference =
@@ -98,14 +88,14 @@ cardanoTxBodyFromResolvedTx (MkResolvedTx {..}) = do
9888
recordFee txInsUtxo body@(TxBody content) = do
9989
case txFee content of
10090
TxFeeExplicit era coin -> do
101-
MkBlockchainParams {protocolParameters, systemStart, eraHistory} <-
91+
MkBlockchainParams {protocolParameters, systemStart, ledgerEpochInfo} <-
10292
queryBlockchainParams
10393
Right report <-
10494
return $
10595
evaluateTransactionExecutionUnits
10696
(shelleyBasedToCardanoEra era)
10797
systemStart
108-
eraHistory
98+
ledgerEpochInfo
10999
(LedgerProtocolParameters protocolParameters)
110100
txInsUtxo
111101
body
@@ -150,13 +140,13 @@ callBodyAutoBalance
150140
preBody
151141
utxo
152142
changeAddress = do
153-
MkBlockchainParams {protocolParameters, systemStart, eraHistory, stakePools} <-
143+
MkBlockchainParams {protocolParameters, systemStart, ledgerEpochInfo, stakePools} <-
154144
queryBlockchainParams
155145
let result =
156146
makeTransactionBodyAutoBalance @Era
157147
shelleyBasedEra
158148
systemStart
159-
eraHistory
149+
ledgerEpochInfo
160150
(LedgerProtocolParameters protocolParameters)
161151
stakePools
162152
Map.empty -- Stake credentials

0 commit comments

Comments
 (0)