Skip to content

Commit

Permalink
fourmolu the whole project with new version
Browse files Browse the repository at this point in the history
  • Loading branch information
Cmdv committed Dec 13, 2024
1 parent 9bed37a commit 4b83780
Show file tree
Hide file tree
Showing 95 changed files with 1,862 additions and 1,669 deletions.
2 changes: 1 addition & 1 deletion cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Babbage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ mkUTxOBabbage :: AlonzoTx StandardBabbage -> [(TxIn StandardCrypto, BabbageTxOut
mkUTxOBabbage = mkUTxOAlonzo

mkUTxOCollBabbage ::
(BabbageEraTxBody era) =>
BabbageEraTxBody era =>
AlonzoTx era ->
[(TxIn (EraCrypto era), TxOut era)]
mkUTxOCollBabbage tx = Map.toList $ unUTxO $ collOuts $ getField @"body" tx
Expand Down
146 changes: 73 additions & 73 deletions cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Conway.hs
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,17 @@ mkPaymentTx' inputIndex outputIndices fees donation state' = do
NoDatum
SNothing

pure $
mkSimpleTx True $
consPaymentTxBody
inputs
mempty
mempty
(StrictSeq.fromList $ outputs <> [change])
SNothing
(Coin fees)
mempty
(Coin donation)
pure
$ mkSimpleTx True
$ consPaymentTxBody
inputs
mempty
mempty
(StrictSeq.fromList $ outputs <> [change])
SNothing
(Coin fees)
mempty
(Coin donation)
where
mkOutputs (outIx, val) = do
addr <- resolveAddress outIx state'
Expand Down Expand Up @@ -268,17 +268,17 @@ mkLockByScriptTx inputIndex txOutTypes amount fees state' = do
NoDatum
SNothing

pure $
mkSimpleTx True $
consPaymentTxBody
inputs
mempty
mempty
(StrictSeq.fromList $ outputs <> [change])
SNothing
(Coin fees)
mempty
(Coin 0)
pure
$ mkSimpleTx True
$ consPaymentTxBody
inputs
mempty
mempty
(StrictSeq.fromList $ outputs <> [change])
SNothing
(Coin fees)
mempty
(Coin 0)

mkUnlockScriptTx ::
[ConwayUTxOIndex] ->
Expand Down Expand Up @@ -348,9 +348,9 @@ mkDCertPoolTx consDCert state' = do

mkDCertTxPools :: ConwayLedgerState -> Either ForgingError (AlonzoTx StandardConway)
mkDCertTxPools state' =
Right $
mkSimpleTx True $
consCertTxBody Nothing (allPoolStakeCert' state') (Withdrawals mempty)
Right
$ mkSimpleTx True
$ consCertTxBody Nothing (allPoolStakeCert' state') (Withdrawals mempty)

mkSimpleTx :: Bool -> ConwayTxBody StandardConway -> AlonzoTx StandardConway
mkSimpleTx isValid' txBody =
Expand Down Expand Up @@ -394,9 +394,9 @@ mkScriptDCertTx consCert isValid' state' = do
cred <- resolveStakeCreds stakeIndex state'
pure $ mkDCert cred

pure $
mkScriptTx isValid' (mapMaybe prepareRedeemer . zip [0 ..] $ consCert) $
consCertTxBody Nothing dcerts (Withdrawals mempty)
pure
$ mkScriptTx isValid' (mapMaybe prepareRedeemer . zip [0 ..] $ consCert)
$ consCertTxBody Nothing dcerts (Withdrawals mempty)
where
prepareRedeemer (n, (StakeIndexScript bl, shouldAddRedeemer, _))
| not shouldAddRedeemer = Nothing
Expand Down Expand Up @@ -428,24 +428,24 @@ mkMultiAssetsScriptTx inputIx colInputIx outputIx refInput minted succeeds fees
refInputs' = Set.fromList $ map (fst . fst) refs
colInputs' = Set.singleton $ fst colInput

pure $
mkScriptTx succeeds (mkScriptInps (map fst inputs) ++ mkScriptMint' minted) $
consTxBody
inputs'
colInputs'
refInputs'
(StrictSeq.fromList outputs)
SNothing
(Coin fees)
mempty
mempty -- TODO[sgillespie]: minted?
(Withdrawals mempty)
(Coin 0)
pure
$ mkScriptTx succeeds (mkScriptInps (map fst inputs) ++ mkScriptMint' minted)
$ consTxBody
inputs'
colInputs'
refInputs'
(StrictSeq.fromList outputs)
SNothing
(Coin fees)
mempty
mempty -- TODO[sgillespie]: minted?
(Withdrawals mempty)
(Coin 0)
where
mkOuts (outIx, val) = do
addr <- resolveAddress outIx state'
pure $
BabbageTxOut
pure
$ BabbageTxOut
addr
val
(DatumHash $ hashData @StandardConway plutusDataList)
Expand All @@ -468,19 +468,19 @@ mkDepositTxPools inputIndex deposit state' = do
NoDatum
SNothing

pure $
mkSimpleTx True $
consTxBody
input
mempty
mempty
(StrictSeq.fromList [change])
SNothing
(Coin 0)
mempty
(allPoolStakeCert' state')
(Withdrawals mempty)
(Coin 0)
pure
$ mkSimpleTx True
$ consTxBody
input
mempty
mempty
(StrictSeq.fromList [change])
SNothing
(Coin 0)
mempty
(allPoolStakeCert' state')
(Withdrawals mempty)
(Coin 0)

mkRegisterDRepTx ::
Credential 'DRepRole StandardCrypto ->
Expand Down Expand Up @@ -663,8 +663,8 @@ mkFullTx n m state' = do
refInputPairs <- fmap fst <$> mapM (`resolveUTxOIndex` state') refInputs
collateralInput <- Set.singleton . fst . fst <$> resolveUTxOIndex collateralInputs state'

pure $
AlonzoTx
pure
$ AlonzoTx
{ body =
txBody
(mkInputs inputPairs)
Expand Down Expand Up @@ -748,8 +748,8 @@ mkFullTx n m state' = do
, ConwayTxCertPool $ Core.RegPool poolParams1
, ConwayTxCertPool $ Core.RetirePool (Prelude.head unregisteredPools) (EpochNo 0)
, ConwayTxCertDeleg $ ConwayUnRegCert (unregisteredStakeCredentials !! 2) SNothing
, ConwayTxCertDeleg $
ConwayDelegCert
, ConwayTxCertDeleg
$ ConwayDelegCert
(unregisteredStakeCredentials !! 1)
(DelegStake $ unregisteredPools !! 2)
]
Expand All @@ -766,8 +766,8 @@ mkFullTx n m state' = do

-- Withdrawals
withdrawals =
Withdrawals $
Map.fromList
Withdrawals
$ Map.fromList
[ (RewardAccount Testnet (unregisteredStakeCredentials !! 1), Coin 100)
, (RewardAccount Testnet (unregisteredStakeCredentials !! 1), Coin 100)
]
Expand Down Expand Up @@ -899,17 +899,17 @@ mkUnlockScriptTx' inputIndex colInputIndex outputIndex refInput colOut succeeds
NoDatum
SNothing

pure $
mkScriptTx succeeds (mkScriptInps inputPairs) $
consPaymentTxBody
inputs
colInputs
refInputs
(StrictSeq.singleton output)
(maybeToStrictMaybe colOut)
(Coin fees)
mempty
(Coin 0)
pure
$ mkScriptTx succeeds (mkScriptInps inputPairs)
$ consPaymentTxBody
inputs
colInputs
refInputs
(StrictSeq.singleton output)
(maybeToStrictMaybe colOut)
(Coin fees)
mempty
(Coin 0)

allPoolStakeCert' :: ConwayLedgerState -> [ConwayTxCert StandardConway]
allPoolStakeCert' st = map (mkRegTxCert SNothing) (getCreds st)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ forgeBlocksChunked interpreter vs f = forM (chunksOf 500 vs) $ \blockCreds -> do
registerDRepsAndDelegateVotes :: Interpreter -> IO CardanoBlock
registerDRepsAndDelegateVotes interpreter = do
blockTxs <-
withConwayLedgerState interpreter $
registerDRepAndDelegateVotes'
withConwayLedgerState interpreter
$ registerDRepAndDelegateVotes'
(Prelude.head unregisteredDRepIds)
(StakeIndex 4)

Expand Down
34 changes: 18 additions & 16 deletions cardano-chain-gen/src/Cardano/Mock/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ queryDRepDistrAmount drepHash epochNo = do
(distr :& hash) <-
from
$ table @Db.DrepDistr
`innerJoin` table @Db.DrepHash
`on` (\(distr :& hash) -> (hash ^. Db.DrepHashId) ==. (distr ^. Db.DrepDistrHashId))
`innerJoin` table @Db.DrepHash
`on` (\(distr :& hash) -> (hash ^. Db.DrepHashId) ==. (distr ^. Db.DrepDistrHashId))

where_ $ hash ^. Db.DrepHashRaw ==. just (val drepHash)
where_ $ distr ^. Db.DrepDistrEpochNo ==. val epochNo
Expand Down Expand Up @@ -140,14 +140,14 @@ queryConstitutionAnchor epochNo = do
(_ :& anchor :& epochState) <-
from

Check warning on line 141 in cardano-chain-gen/src/Cardano/Mock/Query.hs

View workflow job for this annotation

GitHub Actions / build

Suggestion in queryConstitutionAnchor in module Cardano.Mock.Query: Fuse on/on ▫︎ Found: "from $ table @Db.Constitution `innerJoin` table @Db.VotingAnchor\n `on`\n (\\ (constit :& anchor)\n -> (constit ^. Db.ConstitutionVotingAnchorId)\n ==. (anchor ^. Db.VotingAnchorId))\n `innerJoin` table @Db.EpochState\n `on`\n (\\ (constit :& _ :& epoch)\n -> just (constit ^. Db.ConstitutionId)\n ==. (epoch ^. Db.EpochStateConstitutionId))" ▫︎ Perhaps: "(from $ table @Db.Constitution `innerJoin` table @Db.VotingAnchor)\n `on`\n (((\\ (constit :& anchor)\n -> (constit ^. Db.ConstitutionVotingAnchorId)\n ==. (anchor ^. Db.VotingAnchorId))\n `innerJoin` table @Db.EpochState)\n . (\\ (constit :& _ :& epoch)\n -> just (constit ^. Db.ConstitutionId)\n ==. (epoch ^. Db.EpochStateConstitutionId)))"
$ table @Db.Constitution
`innerJoin` table @Db.VotingAnchor
`on` ( \(constit :& anchor) ->
(constit ^. Db.ConstitutionVotingAnchorId) ==. (anchor ^. Db.VotingAnchorId)
)
`innerJoin` table @Db.EpochState
`on` ( \(constit :& _ :& epoch) ->
just (constit ^. Db.ConstitutionId) ==. (epoch ^. Db.EpochStateConstitutionId)
)
`innerJoin` table @Db.VotingAnchor
`on` ( \(constit :& anchor) ->
(constit ^. Db.ConstitutionVotingAnchorId) ==. (anchor ^. Db.VotingAnchorId)
)
`innerJoin` table @Db.EpochState
`on` ( \(constit :& _ :& epoch) ->
just (constit ^. Db.ConstitutionId) ==. (epoch ^. Db.EpochStateConstitutionId)
)

where_ (epochState ^. Db.EpochStateEpochNo ==. val epochNo)

Expand Down Expand Up @@ -193,11 +193,13 @@ queryVoteCounts txHash idx = do
(vote :& tx) <-
from
$ table @Db.VotingProcedure
`innerJoin` table @Db.Tx
`on` (\(vote :& tx) -> vote ^. Db.VotingProcedureTxId ==. tx ^. Db.TxId)
where_ $
vote ^. Db.VotingProcedureVote ==. val v
&&. tx ^. Db.TxHash ==. val txHash
&&. vote ^. Db.VotingProcedureIndex ==. val idx
`innerJoin` table @Db.Tx
`on` (\(vote :& tx) -> vote ^. Db.VotingProcedureTxId ==. tx ^. Db.TxId)
where_
$ vote
^. Db.VotingProcedureVote
==. val v
&&. tx ^. Db.TxHash ==. val txHash
&&. vote ^. Db.VotingProcedureIndex ==. val idx
pure countRows
pure (maybe 0 unValue res)
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ checkEpochDisabledArg =
-- Forge some blocks
void $ forgeAndSubmitBlocks interpreter mockServer 50
-- Add two blocks with transactions
void $
withConwayFindLeaderAndSubmitTx interpreter mockServer $
Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0
void $
withConwayFindLeaderAndSubmitTx interpreter mockServer $
Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0
void
$ withConwayFindLeaderAndSubmitTx interpreter mockServer
$ Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0
void
$ withConwayFindLeaderAndSubmitTx interpreter mockServer
$ Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0
-- Add some more empty blocks
void $ forgeAndSubmitBlocks interpreter mockServer 60

Expand All @@ -48,12 +48,12 @@ checkEpochEnabled =
-- Forge some blocks
void $ forgeAndSubmitBlocks interpreter mockServer 50
-- Add two blocks with transactions
void $
withConwayFindLeaderAndSubmitTx interpreter mockServer $
Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0
void $
withConwayFindLeaderAndSubmitTx interpreter mockServer $
Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0
void
$ withConwayFindLeaderAndSubmitTx interpreter mockServer
$ Conway.mkPaymentTx (UTxOIndex 0) (UTxOIndex 1) 10_000 10_000 0
void
$ withConwayFindLeaderAndSubmitTx interpreter mockServer
$ Conway.mkPaymentTx (UTxOIndex 1) (UTxOIndex 0) 10_000 10_000 0
-- Add some more empty blocks
void $ forgeAndSubmitBlocks interpreter mockServer 60

Expand Down
Loading

0 comments on commit 4b83780

Please sign in to comment.