Skip to content

Commit

Permalink
Update references to reorganised reexported terms
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Oct 3, 2024
1 parent 729f364 commit d8dabb5
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 60 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ repository cardano-haskell-packages
source-repository-package
type: git
location: https://github.com/intersectmbo/cardano-api.git
tag: 74086ede72321f5e455f9bdf4d4a854d58edd1f1
tag: a4f4fbdc1dce80f9e6e2f39155b288c543c5a027
subdir: cardano-api
--sha256: sha256-0zolhYSNSvpeXDaeBRITV08X/9k9cYeaEL+c7Y5l9DE=
--sha256: sha256-pANaH73+3ZxRE1Pqd7/h9Oiop81Wz1GJACB2+/8FZY4=

-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
Expand Down
5 changes: 2 additions & 3 deletions cardano-cli/src/Cardano/CLI/Byron/Commands.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ module Cardano.CLI.Byron.Commands
where

import Cardano.Api hiding (GenesisParameters)
import Cardano.Api.Byron hiding (GenesisParameters)
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron

import Cardano.CLI.Byron.Genesis
import Cardano.CLI.Byron.Key
Expand Down Expand Up @@ -108,7 +107,7 @@ data NodeCmds
Byron.SystemTag
Byron.InstallerHash
FilePath
ByronProtocolParametersUpdate
Byron.ByronProtocolParametersUpdate
| -- | Update proposal filepath.
SubmitUpdateProposal
SocketPath
Expand Down
37 changes: 18 additions & 19 deletions cardano-cli/src/Cardano/CLI/Byron/Delegation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Cardano.CLI.Byron.Delegation
where

import Cardano.Api.Byron
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Ledger as L

import Cardano.CLI.Byron.Key (ByronKeyFailure, renderByronKeyFailure)
Expand Down Expand Up @@ -53,12 +52,12 @@ renderByronDelegationError = \case
-- issuer key, for a given protocol magic and coming into effect at given epoch.
issueByronGenesisDelegation
:: ProtocolMagicId
-> Byron.EpochNumber
-> EpochNumber
-> Crypto.SigningKey
-> Crypto.VerificationKey
-> Byron.Certificate
-> Certificate
issueByronGenesisDelegation magic epoch issuerSK delegateVK' =
Byron.signCertificate magic delegateVK' epoch $
signCertificate magic delegateVK' epoch $
Crypto.noPassSafeSigner issuerSK

-- | Verify that a certificate signifies genesis delegation by assumed genesis key
Expand All @@ -74,59 +73,59 @@ checkByronGenesisDelegation (CertificateFile certF) magic issuer delegate = do
ecert <- liftIO $ canonicalDecodePretty <$> LB.readFile certF
case ecert of
Left e -> left $ DlgCertificateDeserialisationFailed certF e
Right (cert :: Byron.Certificate) -> do
Right (cert :: Certificate) -> do
let issues = checkDlgCert cert magic issuer delegate
unless (null issues) $
left $
CertificateValidationErrors certF issues

checkDlgCert
:: Byron.ACertificate a
:: ACertificate a
-> ProtocolMagicId
-> Crypto.VerificationKey
-> Crypto.VerificationKey
-> [Text]
checkDlgCert cert magic issuerVK' delegateVK' =
mconcat
[ [ sformat "Certificate does not have a valid signature."
| not (Byron.isValid magic' cert')
| not (isValid magic' cert')
]
, [ sformat
("Certificate issuer " . vkF . " doesn't match expected: " . vkF)
(Byron.issuerVK cert)
(issuerVK cert)
issuerVK'
| Byron.issuerVK cert /= issuerVK'
| issuerVK cert /= issuerVK'
]
, [ sformat
("Certificate delegate " . vkF . " doesn't match expected: " . vkF)
(Byron.delegateVK cert)
(delegateVK cert)
delegateVK'
| Byron.delegateVK cert /= delegateVK'
| delegateVK cert /= delegateVK'
]
]
where
magic' :: L.Annotated ProtocolMagicId ByteString
magic' = L.Annotated magic (L.serialize' L.byronProtVer magic)

epoch :: Byron.EpochNumber
epoch = L.unAnnotated $ Byron.aEpoch cert
epoch :: EpochNumber
epoch = L.unAnnotated $ aEpoch cert

cert' :: Byron.ACertificate ByteString
cert' :: ACertificate ByteString
cert' =
let unannotated =
cert
{ Byron.aEpoch = L.Annotated epoch ()
, Byron.annotation = ()
{ aEpoch = L.Annotated epoch ()
, annotation = ()
}
in unannotated
{ Byron.annotation = L.serialize' L.byronProtVer unannotated
, Byron.aEpoch = L.Annotated epoch (L.serialize' L.byronProtVer epoch)
{ annotation = L.serialize' L.byronProtVer unannotated
, aEpoch = L.Annotated epoch (L.serialize' L.byronProtVer epoch)
}

vkF :: forall r. Format r (Crypto.VerificationKey -> r)
vkF = Crypto.fullVerificationKeyF

serialiseDelegationCert :: Byron.Certificate -> ByteString
serialiseDelegationCert :: Certificate -> ByteString
serialiseDelegationCert = LB.toStrict . canonicalEncodePretty

serialiseByronWitness :: SomeByronSigningKey -> ByteString
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Byron/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ where
import Cardano.Api (Key (..), NetworkId, writeSecrets)
import Cardano.Api.Byron (ByronKey, SerialiseAsRawBytes (..), SigningKey (..),
toByronRequiresNetworkMagic)
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron

import Cardano.CLI.Byron.Delegation
import Cardano.CLI.Byron.Key
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/Byron/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Cardano.CLI.Byron.Key
where

import Cardano.Api.Byron
import Cardano.Api.Byron.Misc

import Cardano.CLI.Types.Common
import qualified Cardano.Crypto.Signing as Crypto
Expand Down
5 changes: 2 additions & 3 deletions cardano-cli/src/Cardano/CLI/Byron/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ module Cardano.CLI.Byron.Parsers
where

import Cardano.Api hiding (GenesisParameters, UpdateProposal, parseFilePath)
import Cardano.Api.Byron (Address (..), ByronProtocolParametersUpdate (..),
toByronLovelace)
import qualified Cardano.Api.Byron.Misc as Byron
import Cardano.Api.Byron (ByronProtocolParametersUpdate (..), toByronLovelace)
import qualified Cardano.Api.Byron as Byron
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley (ReferenceScript (ReferenceScriptNone))

Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Byron/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ where

import Cardano.Api hiding (GenesisParameters, UpdateProposal)
import Cardano.Api.Byron (SomeByronSigningKey (..), serializeByronTx)
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron

import Cardano.CLI.Byron.Commands
import Cardano.CLI.Byron.Delegation
Expand Down
27 changes: 13 additions & 14 deletions cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ module Cardano.CLI.Byron.Tx
where

import Cardano.Api
import Cardano.Api.Byron
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import qualified Cardano.Api.Ledger as L

import qualified Cardano.Binary as Binary
Expand Down Expand Up @@ -85,7 +84,7 @@ prettyAddress (ByronAddress addr) =
addr

-- TODO: Move to cardano-api
readByronTx :: TxFile In -> ExceptT ByronTxError IO (ATxAux ByteString)
readByronTx :: TxFile In -> ExceptT ByronTxError IO (Byron.ATxAux ByteString)
readByronTx (File fp) = do
txBS <- liftIO $ LB.readFile fp
case fromCborTxAux txBS of
Expand All @@ -94,7 +93,7 @@ readByronTx (File fp) = do

-- | The 'GenTx' is all the kinds of transactions that can be submitted
-- and \"normal\" Byron transactions are just one of the kinds.
normalByronTxToGenTx :: ATxAux ByteString -> GenTx ByronBlock
normalByronTxToGenTx :: Byron.ATxAux ByteString -> GenTx ByronBlock
normalByronTxToGenTx tx' = Byron.ByronTx (Byron.byronIdTx tx') tx'

-- | Given a genesis, and a pair of a genesis public key and address,
Expand Down Expand Up @@ -145,12 +144,12 @@ genesisUTxOTxIn gc vk genAddr =
txSpendGenesisUTxOByronPBFT
:: Byron.Config
-> NetworkId
-> SomeByronSigningKey
-> Byron.SomeByronSigningKey
-> Address ByronAddr
-> [TxOut CtxTx ByronEra]
-> ATxAux ByteString
-> Byron.ATxAux ByteString
txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs =
let txins = [(fromByronTxIn txIn, BuildTxWith (KeyWitness KeyWitnessForSpending))]
let txins = [(Byron.fromByronTxIn txIn, BuildTxWith (KeyWitness KeyWitnessForSpending))]
in case makeByronTransactionBody txins outs of
Left err -> error $ "Error occurred while creating a Byron genesis based UTxO transaction: " <> show err
Right txBody ->
Expand All @@ -166,10 +165,10 @@ txSpendGenesisUTxOByronPBFT gc nId sk (ByronAddress bAddr) outs =
-- signed by the given key.
txSpendUTxOByronPBFT
:: NetworkId
-> SomeByronSigningKey
-> Byron.SomeByronSigningKey
-> [TxIn]
-> [TxOut CtxTx ByronEra]
-> ATxAux ByteString
-> Byron.ATxAux ByteString
txSpendUTxOByronPBFT nId sk txIns outs = do
let apiTxIns = [(txIn, BuildTxWith (KeyWitness KeyWitnessForSpending)) | txIn <- txIns]

Expand All @@ -180,11 +179,11 @@ txSpendUTxOByronPBFT nId sk txIns outs = do
in makeSignedByronTransaction [bWit] txBody

fromByronWitness
:: SomeByronSigningKey -> NetworkId -> L.Annotated L.Tx ByteString -> KeyWitness ByronEra
:: Byron.SomeByronSigningKey -> NetworkId -> L.Annotated L.Tx ByteString -> KeyWitness ByronEra
fromByronWitness bw nId txBody =
case bw of
AByronSigningKeyLegacy sk -> makeByronKeyWitness nId txBody sk
AByronSigningKey sk' -> makeByronKeyWitness nId txBody sk'
Byron.AByronSigningKeyLegacy sk -> makeByronKeyWitness nId txBody sk
Byron.AByronSigningKey sk' -> makeByronKeyWitness nId txBody sk'

-- | Submit a transaction to a node specified by topology info.
nodeSubmitTx
Expand All @@ -210,7 +209,7 @@ nodeSubmitTx nodeSocketPath network gentx = do
return ()

-- TODO: remove these local definitions when the updated ledger lib is available
fromCborTxAux :: LB.ByteString -> Either Binary.DecoderError (ATxAux B.ByteString)
fromCborTxAux :: LB.ByteString -> Either Binary.DecoderError (Byron.ATxAux B.ByteString)
fromCborTxAux lbs =
annotationBytes lbs
<$> Binary.decodeFullDecoder
Expand All @@ -221,5 +220,5 @@ fromCborTxAux lbs =
annotationBytes :: Functor f => LB.ByteString -> f L.ByteSpan -> f B.ByteString
annotationBytes bytes = fmap (LB.toStrict . L.slice bytes)

toCborTxAux :: ATxAux ByteString -> LB.ByteString
toCborTxAux :: Byron.ATxAux ByteString -> LB.ByteString
toCborTxAux = LB.fromStrict . Byron.aTaAnnotation -- The ByteString anotation is the CBOR encoded version.
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ where
import Cardano.Api (NetworkId, SerialiseAsRawBytes (..), SocketPath)
import Cardano.Api.Byron (AsType (AsByronUpdateProposal), ByronProtocolParametersUpdate,
ByronUpdateProposal, makeByronUpdateProposal, toByronLedgerUpdateProposal)
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron

import Cardano.CLI.Byron.Genesis (ByronGenesisError)
import Cardano.CLI.Byron.Key (ByronKeyFailure, readByronSigningKey)
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Commands/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module Cardano.CLI.EraBased.Commands.Genesis
)
where

import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import Cardano.Api.Ledger (Coin)
import Cardano.Api.Shelley

Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Cardano.CLI.EraBased.Options.Genesis
where

import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath)
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import Cardano.Api.Ledger (Coin (..))

import Cardano.CLI.Environment (EnvCli (..))
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
import Cardano.Api
import Cardano.Api.Byron (toByronLovelace, toByronProtocolMagicId,
toByronRequiresNetworkMagic)
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron hiding (GenesisParameters, SigningKey)
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley

Expand Down
3 changes: 1 addition & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ where
import Cardano.Api hiding (ConwayEra)
import Cardano.Api.Ledger (AlonzoGenesis, ConwayGenesis, StandardCrypto)
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley (Address (ShelleyAddress), ShelleyGenesis, ShelleyLedgerEra,
decodeAlonzoGenesis)
import Cardano.Api.Shelley (ShelleyGenesis, ShelleyLedgerEra, decodeAlonzoGenesis)

import Cardano.CLI.Types.Common
import Cardano.CLI.Types.Errors.GenesisCmdError
Expand Down
1 change: 0 additions & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ where

import Cardano.Api hiding (QueryInShelleyBasedEra (..))
import qualified Cardano.Api as Api
import Cardano.Api.Byron hiding (QueryInShelleyBasedEra (..))
import Cardano.Api.Ledger (strictMaybeToMaybe)
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley hiding (QueryInShelleyBasedEra (..))
Expand Down
7 changes: 3 additions & 4 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ module Cardano.CLI.EraBased.Run.Transaction
where

import Cardano.Api
import Cardano.Api.Byron hiding (SomeByronSigningKey (..))
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import qualified Cardano.Api.Experimental as Exp
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley
Expand Down Expand Up @@ -1645,9 +1644,9 @@ mkShelleyBootstrapWitness
mkShelleyBootstrapWitness _ Nothing _ (ShelleyBootstrapWitnessSigningKeyData _ Nothing) =
Left MissingNetworkIdOrByronAddressError
mkShelleyBootstrapWitness sbe (Just nw) txBody (ShelleyBootstrapWitnessSigningKeyData skey Nothing) =
Right $ makeShelleyBootstrapWitness sbe (WitnessNetworkId nw) txBody skey
Right $ makeShelleyBootstrapWitness sbe (Byron.WitnessNetworkId nw) txBody skey
mkShelleyBootstrapWitness sbe _ txBody (ShelleyBootstrapWitnessSigningKeyData skey (Just addr)) =
Right $ makeShelleyBootstrapWitness sbe (WitnessByronAddress addr) txBody skey
Right $ makeShelleyBootstrapWitness sbe (Byron.WitnessByronAddress addr) txBody skey

-- | Attempt to construct Shelley bootstrap witnesses until an error is
-- encountered.
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Helpers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Cardano.CLI.Helpers
where

import Cardano.Api (AnyCardanoEra (..), CardanoEra (ConwayEra), ToCardanoEra (..))
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import qualified Cardano.Api.Ledger as L

import Cardano.CLI.Pretty (Doc, pretty, pshow)
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Cardano.Api as Api
import Cardano.Api.Byron (KeyWitness (ByronKeyWitness))
import Cardano.Api.Ledger (extractHash, strictMaybeToMaybe)
import qualified Cardano.Api.Ledger as L
import Cardano.Api.Shelley (Address (ShelleyAddress), Hash (..),
import Cardano.Api.Shelley (Hash (..),
KeyWitness (ShelleyBootstrapWitness, ShelleyKeyWitness), Proposal (..),
ShelleyLedgerEra, StakeAddress (..), Tx (ShelleyTx),
fromShelleyPaymentCredential, fromShelleyStakeReference,
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Commands/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Cardano.CLI.Legacy.Commands.Genesis
)
where

import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import Cardano.Api.Ledger (Coin)
import Cardano.Api.Shelley

Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module Cardano.CLI.Legacy.Options
where

import Cardano.Api hiding (QueryInShelleyBasedEra (..), parseFilePath)
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import Cardano.Api.Ledger (Coin (..))

import Cardano.CLI.Environment
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/Legacy/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Cardano.CLI.Legacy.Run.Genesis
where

import Cardano.Api
import qualified Cardano.Api.Byron.Misc as Byron
import qualified Cardano.Api.Byron as Byron
import Cardano.Api.Ledger (Coin (..))

import Cardano.CLI.EraBased.Commands.Genesis
Expand Down

0 comments on commit d8dabb5

Please sign in to comment.