Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt to inject/convert change in API #981

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ write-ghc-environment-files: always
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-api
subdir: cardano-api
tag: 997122eb2a2ef6815bf2fd4757c1b32820833879
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ pUpdateProtocolParametersCmd
pUpdateProtocolParametersCmd =
caseShelleyToBabbageOrConwayEraOnwards
( \shelleyToBab ->
let sbe = inject shelleyToBab
let sbe = convert shelleyToBab
in subParser "create-protocol-parameters-update"
$ Opt.info
( Cmd.GovernanceActionProtocolParametersUpdateCmdArgs
(inject shelleyToBab)
(convert shelleyToBab)
<$> fmap Just (pUpdateProtocolParametersPreConway shelleyToBab)
<*> pure Nothing
<*> dpGovActionProtocolParametersUpdate sbe
Expand All @@ -199,11 +199,11 @@ pUpdateProtocolParametersCmd =
$ Opt.progDesc "Create a protocol parameters update."
)
( \conwayOnwards ->
let sbe = inject conwayOnwards
let sbe = convert conwayOnwards
in subParser "create-protocol-parameters-update"
$ Opt.info
( Cmd.GovernanceActionProtocolParametersUpdateCmdArgs
(inject conwayOnwards)
(convert conwayOnwards)
Nothing
<$> fmap Just (pUpdateProtocolParametersPostConway conwayOnwards)
<*> dpGovActionProtocolParametersUpdate sbe
Expand Down
2 changes: 1 addition & 1 deletion cardano-cli/src/Cardano/CLI/EraBased/Options/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -688,5 +688,5 @@ pQueryNoArgCmdArgs w envCli =
<$> pSocketPath envCli
<*> pConsensusModeParams
<*> pNetworkId envCli
<*> pTarget (inject w :: ShelleyBasedEra era)
<*> pTarget (convert w)
<*> optional pOutputFile
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pStakeAddressDeregistrationCertificateCmd =
( \shelleyToBabbage ->
subParser "deregistration-certificate"
$ Opt.info
( StakeAddressDeregistrationCertificateCmd (inject shelleyToBabbage)
( StakeAddressDeregistrationCertificateCmd (convert shelleyToBabbage)
<$> pStakeIdentifier Nothing
<*> pure Nothing
<*> pOutputFile
Expand All @@ -131,7 +131,7 @@ pStakeAddressDeregistrationCertificateCmd =
( \conwayOnwards ->
subParser "deregistration-certificate"
$ Opt.info
( StakeAddressDeregistrationCertificateCmd (inject conwayOnwards)
( StakeAddressDeregistrationCertificateCmd (convert conwayOnwards)
<$> pStakeIdentifier Nothing
<*> fmap Just pKeyRegistDeposit
<*> pOutputFile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ pTransactionBuildEstimateCmd eon' _envCli = do
where
pCmd :: Exp.Era era -> Parser (TransactionCmds era)
pCmd era' = do
let sbe = inject era'
let sbe = convert era'
fmap TransactionBuildEstimateCmd $
TransactionBuildEstimateCmdArgs era'
<$> optional pScriptValidity
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,11 @@ generateShelleyNodeSecrets shelleyDelegateKeys shelleyGenesisvkeys = do
createOpCert (kesKey, delegateKey) = either (error . show) id eResult
where
eResult = issueOperationalCertificate kesKey (Right delegateKey) (KESPeriod 0) counter
counter = OperationalCertificateIssueCounter 0 (convert . getVerificationKey $ delegateKey)
convert
counter = OperationalCertificateIssueCounter 0 (convertFun . getVerificationKey $ delegateKey)
convertFun
:: VerificationKey GenesisDelegateExtendedKey
-> VerificationKey StakePoolKey
convert =
convertFun =
( castVerificationKey
:: VerificationKey GenesisDelegateKey
-> VerificationKey StakePoolKey
Expand Down
6 changes: 3 additions & 3 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance.hs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ runGovernanceMIRCertificatePayStakeAddrs w mirPot sAddrs rwdAmts oFp = do
makeMIRCertificate $
MirCertificateRequirements w mirPot $
shelleyToBabbageEraConstraints w mirTarget
sbe :: ShelleyBasedEra era = inject w
sbe = convert w

firstExceptT GovernanceCmdTextEnvWriteError
. newExceptT
Expand All @@ -115,7 +115,7 @@ runGovernanceCreateMirCertificateTransferToTreasuryCmd w ll oFp = do
let mirTarget = L.SendToOppositePotMIR ll

let mirCert = makeMIRCertificate $ MirCertificateRequirements w L.ReservesMIR mirTarget
sbe :: ShelleyBasedEra era = inject w
sbe = convert w

firstExceptT GovernanceCmdTextEnvWriteError
. newExceptT
Expand All @@ -137,7 +137,7 @@ runGovernanceCreateMirCertificateTransferToReservesCmd w ll oFp = do
let mirTarget = L.SendToOppositePotMIR ll

let mirCert = makeMIRCertificate $ MirCertificateRequirements w L.TreasuryMIR mirTarget
sbe :: ShelleyBasedEra era = inject w
sbe = convert w

firstExceptT GovernanceCmdTextEnvWriteError
. newExceptT
Expand Down
16 changes: 8 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Actions.hs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ runGovernanceActionInfoCmd

carryHashChecks checkProposalHash proposalAnchor ProposalCheck

let sbe :: ShelleyBasedEra era = inject eon
let sbe = convert eon
govAction = InfoAct
proposalProcedure = createProposalProcedure sbe networkId deposit depositStakeCredential govAction proposalAnchor

Expand Down Expand Up @@ -147,7 +147,7 @@ runGovernanceActionCreateNoConfidenceCmd

carryHashChecks checkProposalHash proposalAnchor ProposalCheck

let sbe :: ShelleyBasedEra era = inject eon
let sbe = convert eon
previousGovernanceAction =
MotionOfNoConfidence $
L.maybeToStrictMaybe $
Expand Down Expand Up @@ -214,7 +214,7 @@ runGovernanceActionCreateConstitutionCmd
prevGovActId
constitutionAnchor
(toShelleyScriptHash <$> L.maybeToStrictMaybe constitutionScript)
sbe :: ShelleyBasedEra era = inject eon
sbe = convert eon
proposalProcedure = createProposalProcedure sbe networkId deposit depositStakeCredential govAct proposalAnchor

carryHashChecks checkConstitutionHash constitutionAnchor ConstitutionCheck
Expand Down Expand Up @@ -248,7 +248,7 @@ runGovernanceActionUpdateCommitteeCmd
, Cmd.mPrevGovernanceActionId
, Cmd.outFile
} = do
let sbe :: ShelleyBasedEra era = inject eon
let sbe = convert eon
govActIdentifier =
L.maybeToStrictMaybe $
shelleyBasedEraConstraints sbe $
Expand Down Expand Up @@ -315,7 +315,7 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do
caseShelleyToBabbageOrConwayEraOnwards
( \sToB -> do
let oFp = uppFilePath eraBasedPParams'
anyEra = AnyShelleyBasedEra (inject sToB :: ShelleyBasedEra era)
anyEra = AnyShelleyBasedEra (convert sToB)
UpdateProtocolParametersPreConway _stB expEpoch genesisVerKeys <-
hoistMaybe (GovernanceActionsValueUpdateProtocolParametersNotFound anyEra) $
uppPreConway eraBasedPParams'
Expand All @@ -341,7 +341,7 @@ runGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams' = do
)
( \conwayOnwards -> do
let oFp = uppFilePath eraBasedPParams'
anyEra = AnyShelleyBasedEra (inject conwayOnwards :: ShelleyBasedEra era)
anyEra = AnyShelleyBasedEra (convert conwayOnwards)

UpdateProtocolParametersConwayOnwards
_cOnwards
Expand Down Expand Up @@ -453,7 +453,7 @@ runGovernanceActionTreasuryWithdrawalCmd
firstExceptT GovernanceActionsReadStakeCredErrror $ getStakeCredentialFromIdentifier stakeIdentifier
pure (networkId, stakeCredential, lovelace)

let sbe :: ShelleyBasedEra era = inject eon
let sbe = convert eon
treasuryWithdrawals =
TreasuryWithdrawal
withdrawals
Expand Down Expand Up @@ -501,7 +501,7 @@ runGovernanceActionHardforkInitCmd

carryHashChecks checkProposalHash proposalAnchor ProposalCheck

let sbe :: ShelleyBasedEra era = inject eon
let sbe = convert eon
govActIdentifier =
L.maybeToStrictMaybe $
shelleyBasedEraConstraints sbe $
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ runGovernanceGenesisKeyDelegationCertificate
firstExceptT GovernanceCmdTextEnvWriteError
. newExceptT
$ writeLazyByteStringFile oFp
$ shelleyBasedEraConstraints (inject stb :: ShelleyBasedEra era)
$ shelleyBasedEraConstraints (convert stb)
$ textEnvelopeToJSON (Just genKeyDelegCertDesc) genKeyDelegCert
where
genKeyDelegCertDesc :: TextEnvelopeDescr
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Governance/Vote.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ runGovernanceVoteCreateCmd
, outFile
} = do
let (govActionTxId, govActionIndex) = governanceAction
sbe :: ShelleyBasedEra era = inject eon -- TODO: Conway era - update vote creation related function to take ConwayEraOnwards
sbe = convert eon -- TODO: Conway era - update vote creation related function to take ConwayEraOnwards
mAnchor' =
fmap
( \pca@PotentiallyCheckedAnchor{pcaAnchor = (VoteUrl url, voteHash)} ->
Expand Down Expand Up @@ -104,7 +104,7 @@ runGovernanceVoteViewCmd
, voteFile
, mOutFile
} = do
let sbe :: ShelleyBasedEra era = inject eon
let sbe :: ShelleyBasedEra era = convert eon

shelleyBasedEraConstraints sbe $ do
voteProcedures <-
Expand Down
10 changes: 5 additions & 5 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ runTransactionBuildCmd
, treasuryDonation -- Maybe TxTreasuryDonation
, buildOutputOptions
} = do
let eon = inject currentEra
let eon = convert currentEra
era' = toCardanoEra eon

-- The user can specify an era prior to the era that the node is currently in.
Expand Down Expand Up @@ -217,9 +217,9 @@ runTransactionBuildCmd

let returnAddrHashes =
fromList
[ StakeCredentialByKey returnAddrHash
[ stakeCred
| (proposal, _) <- proposals
, let (_, returnAddrHash, _) = fromProposalProcedure eon proposal -- fromProposalProcedure needs to be adjusted so that it works with script hashes.
, let (_, stakeCred, _) = fromProposalProcedure eon proposal -- fromProposalProcedure needs to be adjusted so that it works with script hashes.
]
treasuryWithdrawalAddresses =
fromList
Expand Down Expand Up @@ -395,7 +395,7 @@ runTransactionBuildEstimateCmd -- TODO change type
, currentTreasuryValueAndDonation
, txBodyOutFile
} = do
let sbe = inject currentEra
let sbe = convert currentEra
meo = inject @(BabbageEraOnwards era) $ inject currentEra

ledgerPParams <-
Expand Down Expand Up @@ -523,7 +523,7 @@ runTransactionBuildEstimateCmd -- TODO change type
let noWitTx = makeSignedTransaction [] balancedTxBody
lift
( cardanoEraConstraints (toCardanoEra meo) $
writeTxFileTextEnvelopeCddl (inject meo) txBodyOutFile noWitTx
writeTxFileTextEnvelopeCddl (convert meo) txBodyOutFile noWitTx
)
& onLeft (left . TxCmdWriteFileError)

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 @@ -789,7 +789,7 @@ friendlyLovelace value = String $ docToText (pretty value)
friendlyMintValue :: forall era. TxMintValue ViewTx era -> Aeson.Value
friendlyMintValue = \case
TxMintNone -> Null
txMintValue@(TxMintValue w _) -> friendlyValue @era (inject w) $ txMintValueToValue txMintValue
txMintValue@(TxMintValue w _) -> friendlyValue @era (convert w) $ txMintValueToValue txMintValue

friendlyTxOutValue :: TxOutValue era -> Aeson.Value
friendlyTxOutValue = \case
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ readSingleVote w (voteFp, mScriptWitFiles) = do
case mScriptWitFiles of
Nothing -> pure $ (,Nothing) <$> votProceds
sWitFile -> do
let sbe = inject w
let sbe = convert w
runExceptT $ do
sWits <-
firstExceptT VoteErrorScriptWitness $
Expand Down Expand Up @@ -1031,7 +1031,7 @@ readProposal w (fp, mScriptWit) = do
case mScriptWit of
Nothing -> pure $ (,Nothing) <$> prop
sWitFile -> do
let sbe = inject w
let sbe = convert w
runExceptT $ do
sWit <-
firstExceptT ProposalErrorScriptWitness $
Expand Down
50 changes: 25 additions & 25 deletions cardano-cli/src/Cardano/CLI/Run/Key.hs
Original file line number Diff line number Diff line change
Expand Up @@ -244,35 +244,35 @@ runConvertByronKeyCmd
} =
case (byronKeyType, inFile) of
(ByronPaymentKey format, ASigningKeyFile skeyPathOld) ->
convertByronSigningKey mPwd format convert skeyPathOld outFile
convertByronSigningKey mPwd format toSigningKey skeyPathOld outFile
where
convert :: Byron.SigningKey -> SigningKey ByronKey
convert = ByronSigningKey
toSigningKey :: Byron.SigningKey -> SigningKey ByronKey
toSigningKey = ByronSigningKey
(ByronGenesisKey format, ASigningKeyFile skeyPathOld) ->
convertByronSigningKey mPwd format convert skeyPathOld outFile
convertByronSigningKey mPwd format toSigningKey skeyPathOld outFile
where
convert :: Byron.SigningKey -> SigningKey GenesisExtendedKey
convert (Byron.SigningKey xsk) = GenesisExtendedSigningKey xsk
toSigningKey :: Byron.SigningKey -> SigningKey GenesisExtendedKey
toSigningKey (Byron.SigningKey xsk) = GenesisExtendedSigningKey xsk
(ByronDelegateKey format, ASigningKeyFile skeyPathOld) ->
convertByronSigningKey mPwd format convert skeyPathOld outFile
convertByronSigningKey mPwd format toSigningKey skeyPathOld outFile
where
convert :: Byron.SigningKey -> SigningKey GenesisDelegateExtendedKey
convert (Byron.SigningKey xsk) = GenesisDelegateExtendedSigningKey xsk
toSigningKey :: Byron.SigningKey -> SigningKey GenesisDelegateExtendedKey
toSigningKey (Byron.SigningKey xsk) = GenesisDelegateExtendedSigningKey xsk
(ByronPaymentKey NonLegacyByronKeyFormat, AVerificationKeyFile vkeyPathOld) ->
convertByronVerificationKey convert vkeyPathOld outFile
convertByronVerificationKey toVerificationKey vkeyPathOld outFile
where
convert :: Byron.VerificationKey -> VerificationKey ByronKey
convert = ByronVerificationKey
toVerificationKey :: Byron.VerificationKey -> VerificationKey ByronKey
toVerificationKey = ByronVerificationKey
(ByronGenesisKey NonLegacyByronKeyFormat, AVerificationKeyFile vkeyPathOld) ->
convertByronVerificationKey convert vkeyPathOld outFile
convertByronVerificationKey toVerificationKey vkeyPathOld outFile
where
convert :: Byron.VerificationKey -> VerificationKey GenesisExtendedKey
convert (Byron.VerificationKey xvk) = GenesisExtendedVerificationKey xvk
toVerificationKey :: Byron.VerificationKey -> VerificationKey GenesisExtendedKey
toVerificationKey (Byron.VerificationKey xvk) = GenesisExtendedVerificationKey xvk
(ByronDelegateKey NonLegacyByronKeyFormat, AVerificationKeyFile vkeyPathOld) ->
convertByronVerificationKey convert vkeyPathOld outFile
convertByronVerificationKey toVerificationKey vkeyPathOld outFile
where
convert :: Byron.VerificationKey -> VerificationKey GenesisDelegateExtendedKey
convert (Byron.VerificationKey xvk) =
toVerificationKey :: Byron.VerificationKey -> VerificationKey GenesisDelegateExtendedKey
toVerificationKey (Byron.VerificationKey xvk) =
GenesisDelegateExtendedVerificationKey xvk
(ByronPaymentKey LegacyByronKeyFormat, AVerificationKeyFile{}) ->
legacyVerificationKeysNotSupported
Expand Down Expand Up @@ -302,7 +302,7 @@ convertByronSigningKey
-> File () Out
-- ^ Output file: new format
-> ExceptT KeyCmdError IO ()
convertByronSigningKey mPwd byronFormat convert skeyPathOld skeyPathNew = do
convertByronSigningKey mPwd byronFormat convertFun skeyPathOld skeyPathNew = do
sKey <-
firstExceptT KeyCmdByronKeyFailure $
Byron.readByronSigningKey byronFormat skeyPathOld
Expand All @@ -319,7 +319,7 @@ convertByronSigningKey mPwd byronFormat convert skeyPathOld skeyPathNew = do
ByronApi.AByronSigningKey (ByronSigningKey sk) -> return sk

let sk' :: SigningKey keyrole
sk' = convert unprotectedSk
sk' = convertFun unprotectedSk

firstExceptT KeyCmdWriteFileError . newExceptT $
writeLazyByteStringFile skeyPathNew $
Expand All @@ -334,13 +334,13 @@ convertByronVerificationKey
-> File () Out
-- ^ Output file: new format
-> ExceptT KeyCmdError IO ()
convertByronVerificationKey convert vkeyPathOld vkeyPathNew = do
convertByronVerificationKey convertFun vkeyPathOld vkeyPathNew = do
vk <-
firstExceptT KeyCmdByronKeyFailure $
Byron.readPaymentVerificationKey vkeyPathOld

let vk' :: VerificationKey keyrole
vk' = convert vk
vk' = convertFun vk

firstExceptT KeyCmdWriteFileError . newExceptT $
writeLazyByteStringFile vkeyPathNew $
Expand All @@ -362,14 +362,14 @@ runConvertByronGenesisVKeyCmd
$ b64ByronVKey

let vk' :: VerificationKey GenesisKey
vk' = convert vk
vk' = convertFun vk

firstExceptT KeyCmdWriteFileError . newExceptT $
writeLazyByteStringFile vkeyPathNew $
textEnvelopeToJSON Nothing vk'
where
convert :: Byron.VerificationKey -> VerificationKey GenesisKey
convert (Byron.VerificationKey xvk) =
convertFun :: Byron.VerificationKey -> VerificationKey GenesisKey
convertFun (Byron.VerificationKey xvk) =
castVerificationKey (GenesisExtendedVerificationKey xvk)

--------------------------------------------------------------------------------
Expand Down
Loading