Skip to content

Commit 08ef521

Browse files
committed
wip: remove more StandardCrypto
1 parent 5a1a53e commit 08ef521

File tree

19 files changed

+184
-206
lines changed

19 files changed

+184
-206
lines changed

lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ module Internal.Cardano.Write.Tx
3535

3636
-- ** Misc
3737
, StandardCrypto
38-
, StandardBabbage
39-
, StandardConway
38+
, BabbageEra
39+
, ConwayEra
4040

4141
-- * PParams
4242
, PParams
@@ -223,8 +223,8 @@ import Numeric.Natural
223223
( Natural
224224
)
225225
import Ouroboros.Consensus.Shelley.Eras
226-
( StandardBabbage
227-
, StandardConway
226+
( BabbageEra
227+
, ConwayEra
228228
)
229229

230230
import qualified Cardano.Api as CardanoApi

lib/local-cluster/test/unit/Cardano/Wallet/Launch/Cluster/Http/ServiceSpec.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,13 @@ import Data.Set
146146
)
147147
import Ouroboros.Consensus.Cardano.Block
148148
( CardanoBlock
149-
, StandardAllegra
150-
, StandardAlonzo
151-
, StandardBabbage
152-
, StandardConway
149+
, AllegraEra
150+
, AlonzoEra
151+
, BabbageEra
152+
, ConwayEra
153153
, StandardCrypto
154-
, StandardMary
155-
, StandardShelley
154+
, MaryEra
155+
, ShelleyEra
156156
)
157157
import Streaming
158158
( MonadIO (liftIO)
@@ -464,28 +464,28 @@ txOutFromOutput = case theEra :: Era era of
464464
fromByronTxOut (Byron.TxOut addr amount) =
465465
TxOut (serialize' addr) (fromIntegral $ unsafeGetLovelace amount)
466466

467-
fromShelleyTxOut :: SL.ShelleyTxOut StandardShelley -> TxOut
467+
fromShelleyTxOut :: SL.ShelleyTxOut ShelleyEra -> TxOut
468468
fromShelleyTxOut (SL.ShelleyTxOut addr (Coin amount)) =
469469
TxOut (SL.serialiseAddr addr) amount
470470

471-
fromAllegraTxOut :: SL.ShelleyTxOut StandardAllegra -> TxOut
471+
fromAllegraTxOut :: SL.ShelleyTxOut AllegraEra -> TxOut
472472
fromAllegraTxOut (SL.ShelleyTxOut addr (Coin amount)) =
473473
TxOut (SL.serialiseAddr addr) amount
474474

475-
fromMaryTxOut :: SL.ShelleyTxOut StandardMary -> TxOut
475+
fromMaryTxOut :: SL.ShelleyTxOut MaryEra -> TxOut
476476
fromMaryTxOut (SL.ShelleyTxOut addr (MaryValue (Coin amount) _)) =
477477
TxOut (SL.serialiseAddr addr) amount
478478

479-
fromAlonzoTxOut :: Alonzo.AlonzoTxOut StandardAlonzo -> TxOut
479+
fromAlonzoTxOut :: Alonzo.AlonzoTxOut AlonzoEra -> TxOut
480480
fromAlonzoTxOut (Alonzo.AlonzoTxOut addr (MaryValue (Coin amount) _) _) =
481481
TxOut (SL.serialiseAddr addr) amount
482482

483-
fromBabbageTxOut :: Babbage.BabbageTxOut StandardBabbage -> TxOut
483+
fromBabbageTxOut :: Babbage.BabbageTxOut BabbageEra -> TxOut
484484
fromBabbageTxOut
485485
(Babbage.BabbageTxOut addr (MaryValue (Coin amount) _) _ _) =
486486
TxOut (SL.serialiseAddr addr) amount
487487

488-
fromConwayTxOut :: Babbage.BabbageTxOut StandardConway -> TxOut
488+
fromConwayTxOut :: Babbage.BabbageTxOut ConwayEra -> TxOut
489489
fromConwayTxOut
490490
(Babbage.BabbageTxOut addr (MaryValue (Coin amount) _) _ _) =
491491
TxOut (SL.serialiseAddr addr) amount

lib/network-layer/src/Cardano/Wallet/Network/LocalStateQuery/Extra.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ import Ouroboros.Consensus.Protocol.TPraos
5656
( TPraos
5757
)
5858
import Ouroboros.Consensus.Shelley.Eras
59-
( StandardAllegra
60-
, StandardAlonzo
61-
, StandardBabbage
62-
, StandardConway
59+
( AllegraEra
60+
, AlonzoEra
61+
, BabbageEra
62+
, ConwayEra
6363
, StandardCrypto
64-
, StandardMary
65-
, StandardShelley
64+
, MaryEra
65+
, ShelleyEra
6666
)
6767

6868
import qualified Cardano.Wallet.Read as Read
@@ -125,12 +125,12 @@ onAnyEra' a b c d e f g =
125125
-- @PParams@ in alonzo.
126126
onAnyEra
127127
:: LSQ Byron.ByronBlock m a
128-
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) StandardShelley) m a
129-
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) StandardAllegra) m a
130-
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) StandardMary) m a
131-
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) StandardAlonzo) m a
132-
-> LSQ (Shelley.ShelleyBlock (Praos StandardCrypto) StandardBabbage) m a
133-
-> LSQ (Shelley.ShelleyBlock (Praos StandardCrypto) StandardConway) m a
128+
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) ShelleyEra) m a
129+
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) AllegraEra) m a
130+
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) MaryEra) m a
131+
-> LSQ (Shelley.ShelleyBlock (TPraos StandardCrypto) AlonzoEra) m a
132+
-> LSQ (Shelley.ShelleyBlock (Praos StandardCrypto) BabbageEra) m a
133+
-> LSQ (Shelley.ShelleyBlock (Praos StandardCrypto) ConwayEra) m a
134134
-> LSQ (CardanoBlock StandardCrypto) m a
135135
onAnyEra onByron onShelley onAllegra onMary onAlonzo onBabbage onConway =
136136
currentEra >>= \case

lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Convert.hs

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,17 @@ module Cardano.Wallet.Primitive.Ledger.Convert
5757

5858
import Prelude
5959

60-
import Cardano.Address.Script
60+
import Cardano.Address.KeyHash
6161
( KeyHash (..)
6262
, KeyRole (..)
63-
, Script (..)
63+
)
64+
import Cardano.Address.Script
65+
( Script (..)
6466
)
6567
import Cardano.Crypto.Hash
6668
( hashFromBytes
6769
, hashToBytes
6870
)
69-
import Cardano.Ledger.Api
70-
( Babbage
71-
, Conway
72-
)
7371
import Cardano.Slotting.Slot
7472
( SlotNo (..)
7573
)
@@ -147,9 +145,8 @@ import Numeric.Natural
147145
( Natural
148146
)
149147
import Ouroboros.Consensus.Shelley.Eras
150-
( StandardBabbage
151-
, StandardConway
152-
, StandardCrypto
148+
( BabbageEra
149+
, ConwayEra
153150
)
154151

155152
import qualified Cardano.Crypto.Hash.Class as Crypto
@@ -165,7 +162,7 @@ import qualified Cardano.Ledger.DRep as Ledger
165162
import qualified Cardano.Ledger.Keys as Ledger
166163
import qualified Cardano.Ledger.Mary.Value as Ledger
167164
import qualified Cardano.Ledger.Plutus.Language as Ledger
168-
import qualified Cardano.Ledger.SafeHash as SafeHash
165+
import qualified Cardano.Ledger.Hashes as Hashes
169166
import qualified Cardano.Ledger.Shelley.API as Ledger
170167
import qualified Cardano.Ledger.Shelley.Scripts as Scripts
171168
import qualified Cardano.Wallet.Primitive.Types.Coin as Coin
@@ -217,16 +214,16 @@ toWalletCoin (Ledger.Coin c) = Coin.unsafeFromIntegral c
217214
-- that is similar to the wallet's 'TokenBundle' type. The ada quantity is
218215
-- stored as a separate value, and asset quantities are stored in a nested map.
219216

220-
instance Convert TokenBundle (Ledger.MaryValue StandardCrypto) where
217+
instance Convert TokenBundle Ledger.MaryValue where
221218
toLedger = toLedgerTokenBundle
222219
toWallet = toWalletTokenBundle
223220

224-
toLedgerTokenBundle :: TokenBundle -> Ledger.MaryValue StandardCrypto
221+
toLedgerTokenBundle :: TokenBundle -> Ledger.MaryValue
225222
toLedgerTokenBundle bundle =
226223
Ledger.MaryValue ledgerAda ledgerTokens
227224
where
228225
ledgerAda = toLedgerCoin $ TokenBundle.getCoin bundle
229-
ledgerTokens :: Ledger.MultiAsset StandardCrypto
226+
ledgerTokens :: Ledger.MultiAsset
230227
ledgerTokens = bundle
231228
& view #tokens
232229
& TokenMap.toNestedMap
@@ -237,7 +234,7 @@ toLedgerTokenBundle bundle =
237234
& Map.mapKeys toLedgerAssetName
238235
& Map.map toLedgerTokenQuantity
239236

240-
toWalletTokenBundle :: Ledger.MaryValue StandardCrypto -> TokenBundle
237+
toWalletTokenBundle :: Ledger.MaryValue -> TokenBundle
241238
toWalletTokenBundle
242239
(Ledger.MaryValue ledgerAda (Ledger.MultiAsset ledgerTokens)) =
243240
TokenBundle.fromNestedMap (walletAda, walletTokens)
@@ -270,11 +267,11 @@ toWalletAssetName (Ledger.AssetName bytes) =
270267
-- Conversions for 'TokenPolicyId'
271268
--------------------------------------------------------------------------------
272269

273-
instance Convert TokenPolicyId (Ledger.PolicyID StandardCrypto) where
270+
instance Convert TokenPolicyId Ledger.PolicyID where
274271
toLedger = toLedgerTokenPolicyId
275272
toWallet = toWalletTokenPolicyId
276273

277-
toLedgerTokenPolicyId :: TokenPolicyId -> Ledger.PolicyID StandardCrypto
274+
toLedgerTokenPolicyId :: TokenPolicyId -> Ledger.PolicyID
278275
toLedgerTokenPolicyId p@(UnsafeTokenPolicyId (Hash bytes)) =
279276
case hashFromBytes bytes of
280277
Just hash ->
@@ -286,7 +283,7 @@ toLedgerTokenPolicyId p@(UnsafeTokenPolicyId (Hash bytes)) =
286283
, pretty p
287284
]
288285

289-
toWalletTokenPolicyId :: Ledger.PolicyID StandardCrypto -> TokenPolicyId
286+
toWalletTokenPolicyId :: Ledger.PolicyID -> TokenPolicyId
290287
toWalletTokenPolicyId (Ledger.PolicyID (Ledger.ScriptHash hash)) =
291288
UnsafeTokenPolicyId (Hash (hashToBytes hash))
292289

@@ -316,20 +313,20 @@ toWalletTokenQuantity q
316313
-- Conversions for 'TxIn'
317314
--------------------------------------------------------------------------------
318315

319-
instance Convert TxIn (Ledger.TxIn StandardCrypto) where
316+
instance Convert TxIn Ledger.TxIn where
320317
toLedger (TxIn tid ix) =
321318
Ledger.TxIn (toLedgerHash tid) (toEnum $ intCast ix)
322319
where
323320
toLedgerHash (Hash h) =
324321
Ledger.TxId
325-
$ SafeHash.unsafeMakeSafeHash
322+
$ Hashes.unsafeMakeSafeHash
326323
$ Crypto.UnsafeHash
327324
$ toShort h
328325

329326
toWallet (Ledger.TxIn (Ledger.TxId tid) ix) =
330327
TxIn (convertId tid) (convertIx ix)
331328
where
332-
convertId = Hash . Crypto.hashToBytes . SafeHash.extractHash
329+
convertId = Hash . Crypto.hashToBytes . Hashes.extractHash
333330

334331
convertIx = fromMaybe err . intCastMaybe . fromEnum
335332
where
@@ -343,19 +340,19 @@ instance Convert TxIn (Ledger.TxIn StandardCrypto) where
343340
-- Conversions for 'Address'
344341
--------------------------------------------------------------------------------
345342

346-
instance Convert Address (Ledger.Addr StandardCrypto) where
343+
instance Convert Address Ledger.Addr where
347344
toLedger = toLedgerAddress
348345
toWallet = toWalletAddress
349346

350-
toLedgerAddress :: Address -> Ledger.Addr StandardCrypto
347+
toLedgerAddress :: Address -> Ledger.Addr
351348
toLedgerAddress (Address bytes) = case Ledger.decodeAddrLenient bytes of
352349
Just addr -> addr
353350
Nothing -> error $ unwords
354351
[ "toLedger @Address: Invalid address:"
355352
, pretty (Address bytes)
356353
]
357354

358-
toWalletAddress :: Ledger.Addr StandardCrypto -> Address
355+
toWalletAddress :: Ledger.Addr -> Address
359356
toWalletAddress = Address . Ledger.serialiseAddr
360357

361358
--------------------------------------------------------------------------------
@@ -364,7 +361,7 @@ toWalletAddress = Address . Ledger.serialiseAddr
364361

365362
toBabbageTxOut
366363
:: TxOut
367-
-> Babbage.BabbageTxOut StandardBabbage
364+
-> Babbage.BabbageTxOut BabbageEra
368365
toBabbageTxOut (TxOut addr bundle) =
369366
Babbage.BabbageTxOut
370367
(toLedger addr)
@@ -374,7 +371,7 @@ toBabbageTxOut (TxOut addr bundle) =
374371

375372
toConwayTxOut
376373
:: TxOut
377-
-> Babbage.BabbageTxOut StandardConway
374+
-> Babbage.BabbageTxOut ConwayEra
378375
toConwayTxOut (TxOut addr bundle) =
379376
Babbage.BabbageTxOut
380377
(toLedger addr)
@@ -384,14 +381,14 @@ toConwayTxOut (TxOut addr bundle) =
384381

385382
-- NOTE: Inline scripts and datums will be lost in the conversion.
386383
fromConwayTxOut
387-
:: Babbage.BabbageTxOut StandardConway
384+
:: Babbage.BabbageTxOut ConwayEra
388385
-> TxOut
389386
fromConwayTxOut (Babbage.BabbageTxOut addr val _ _)
390387
= TxOut (toWallet addr) (toWallet val)
391388

392389
-- NOTE: Inline scripts and datums will be lost in the conversion.
393390
fromBabbageTxOut
394-
:: Babbage.BabbageTxOut StandardBabbage
391+
:: Babbage.BabbageTxOut BabbageEra
395392
-> TxOut
396393
fromBabbageTxOut (Babbage.BabbageTxOut addr val _ _)
397394
= TxOut (toWallet addr) (toWallet val)
@@ -400,22 +397,22 @@ fromBabbageTxOut (Babbage.BabbageTxOut addr val _ _)
400397
-- Conversions for 'UTxO'
401398
--------------------------------------------------------------------------------
402399

403-
toLedgerUTxOBabbage :: UTxO -> Ledger.UTxO Babbage
400+
toLedgerUTxOBabbage :: UTxO -> Ledger.UTxO BabbageEra
404401
toLedgerUTxOBabbage (UTxO m) = Ledger.UTxO
405402
$ Map.mapKeys toLedger
406403
$ Map.map toBabbageTxOut m
407404

408-
toLedgerUTxOConway :: UTxO -> Ledger.UTxO Conway
405+
toLedgerUTxOConway :: UTxO -> Ledger.UTxO ConwayEra
409406
toLedgerUTxOConway (UTxO m) = Ledger.UTxO
410407
$ Map.mapKeys toLedger
411408
$ Map.map toConwayTxOut m
412409

413-
toWalletUTxOBabbage :: Ledger.UTxO Babbage -> UTxO
410+
toWalletUTxOBabbage :: Ledger.UTxO BabbageEra -> UTxO
414411
toWalletUTxOBabbage (Ledger.UTxO m) = UTxO
415412
$ Map.mapKeys toWallet
416413
$ Map.map fromBabbageTxOut m
417414

418-
toWalletUTxOConway :: Ledger.UTxO Conway -> UTxO
415+
toWalletUTxOConway :: Ledger.UTxO ConwayEra -> UTxO
419416
toWalletUTxOConway (Ledger.UTxO m) = UTxO
420417
$ Map.mapKeys toWallet
421418
$ Map.map fromConwayTxOut m
@@ -516,7 +513,7 @@ toLedgerTimelockScript s = case s of
516513
toLedgerDelegatee
517514
:: Maybe PoolId
518515
-> Maybe DRep
519-
-> Conway.Delegatee StandardCrypto
516+
-> Conway.Delegatee
520517
toLedgerDelegatee poolM vaM = case (poolM, vaM) of
521518
(Just poolId, Nothing) ->
522519
Conway.DelegStake (toKeyHash poolId)
@@ -534,7 +531,7 @@ toLedgerDelegatee poolM vaM = case (poolM, vaM) of
534531
toKeyHash (PoolId pid) = Ledger.KeyHash . Crypto.UnsafeHash $ toShort pid
535532

536533
toLedgerDRep
537-
:: DRep -> Ledger.DRep StandardCrypto
534+
:: DRep -> Ledger.DRep
538535
toLedgerDRep = \case
539536
Abstain -> Ledger.DRepAlwaysAbstain
540537
NoConfidence -> Ledger.DRepAlwaysNoConfidence

lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralInputs.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ getCollateralInputs = case theEra @era of
3737
Conway -> mkShelleyTxCollateralInputsIns
3838

3939
mkShelleyTxCollateralInputsIns
40-
:: (Foldable t, CollateralInputsType era ~ t (SH.TxIn crypto))
40+
:: (Foldable t, CollateralInputsType era ~ t SH.TxIn)
4141
=> CollateralInputs era -- ^
4242
-> [W.TxIn]
4343
mkShelleyTxCollateralInputsIns (CollateralInputs ins) = fromShelleyTxIns ins

lib/primitive/lib/Cardano/Wallet/Primitive/Ledger/Read/Tx/Features/CollateralOutputs.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import Data.Maybe.Strict
2626
( strictMaybeToMaybe
2727
)
2828
import Ouroboros.Consensus.Shelley.Eras
29-
( StandardBabbage
30-
, StandardConway
29+
( BabbageEra
30+
, ConwayEra
3131
)
3232

3333
import qualified Cardano.Ledger.Babbage as Babbage
@@ -52,13 +52,13 @@ getCollateralOutputs = case theEra @era of
5252
fromConwayTxOut <$> strictMaybeToMaybe mo
5353

5454
fromBabbageTxOut
55-
:: Babbage.BabbageTxOut StandardBabbage
55+
:: Babbage.BabbageTxOut BabbageEra
5656
-> W.TxOut
5757
fromBabbageTxOut (Babbage.BabbageTxOut addr value _datum _refScript) =
5858
W.TxOut (fromShelleyAddress addr) (toWalletTokenBundle value)
5959

6060
fromConwayTxOut
61-
:: Babbage.BabbageTxOut StandardConway
61+
:: Babbage.BabbageTxOut ConwayEra
6262
-> W.TxOut
6363
fromConwayTxOut (Babbage.BabbageTxOut addr value _datum _refScript) =
6464
W.TxOut (fromShelleyAddress addr) (toWalletTokenBundle value)

0 commit comments

Comments
 (0)