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

Add script support when making hot key authorisation certificates #476

Merged
Merged
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
10 changes: 4 additions & 6 deletions cardano-api/internal/Cardano/Api/Certificate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -408,19 +408,17 @@ makeDrepRegistrationCertificate (DRepRegistrationRequirements conwayOnwards vcre
data CommitteeHotKeyAuthorizationRequirements era where
CommitteeHotKeyAuthorizationRequirements
:: ConwayEraOnwards era
-> Ledger.KeyHash Ledger.ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> Ledger.KeyHash Ledger.HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> Ledger.Credential Ledger.ColdCommitteeRole (EraCrypto (ShelleyLedgerEra era))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

-> Ledger.Credential Ledger.HotCommitteeRole (EraCrypto (ShelleyLedgerEra era))
-> CommitteeHotKeyAuthorizationRequirements era

makeCommitteeHotKeyAuthorizationCertificate :: ()
=> CommitteeHotKeyAuthorizationRequirements era
-> Certificate era
makeCommitteeHotKeyAuthorizationCertificate (CommitteeHotKeyAuthorizationRequirements cOnwards coldKeyHash hotKeyHash) =
makeCommitteeHotKeyAuthorizationCertificate (CommitteeHotKeyAuthorizationRequirements cOnwards coldKeyCredential hotKeyCredential) =
ConwayCertificate cOnwards
. Ledger.ConwayTxCertGov
$ Ledger.ConwayAuthCommitteeHotKey
(Ledger.KeyHashObj coldKeyHash)
(Ledger.KeyHashObj hotKeyHash)
$ Ledger.ConwayAuthCommitteeHotKey coldKeyCredential hotKeyCredential

data CommitteeColdkeyResignationRequirements era where
CommitteeColdkeyResignationRequirements
Expand Down
12 changes: 9 additions & 3 deletions cardano-api/internal/Cardano/Api/Monad/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Cardano.Api.Monad.Error
, modifyError
, handleIOExceptionsWith
, handleIOExceptionsLiftWith
, hoistIOEither

, module Control.Monad.Except
, module Control.Monad.IO.Class
Expand All @@ -34,7 +35,7 @@ import Data.Bifunctor (first)
type MonadTransError e t m = (Monad m, MonadTrans t, MonadError e (t m))
--
-- | Same as 'MonadTransError', but with also 'MonadIO' constraint
type MonadIOTransError e t m = (MonadIO m, MonadIO (t m), MonadTrans t, MonadError e (t m))
type MonadIOTransError e t m = (MonadIO m, MonadIO (t m), MonadCatch m, MonadTrans t, MonadError e (t m))
smelc marked this conversation as resolved.
Show resolved Hide resolved

-- | Modify an 'ExceptT' error and lift it to 'MonadError' transformer stack.
--
Expand Down Expand Up @@ -69,10 +70,9 @@ handleIOExceptionsWith f act = liftEither . first f =<< try act
handleIOExceptionsLiftWith
:: MonadIOTransError e' t m
=> Exception e
=> MonadCatch m
=> (e -> e') -- ^ mapping function
-> m a -- ^ action that can throw
-> t m a -- ^ action with caucht error lifted into 'MonadError' stack
-> t m a -- ^ action with caught error lifted into 'MonadError' stack
handleIOExceptionsLiftWith f act = liftEither =<< lift (first f <$> try act)

-- | Lift 'ExceptT' into 'MonadTransError'
Expand All @@ -81,3 +81,9 @@ liftExceptT :: MonadTransError e t m
-> t m a
liftExceptT = modifyError id


-- | Lift an 'IO' action that returns 'Either' into 'MonadIOTransError'
hoistIOEither :: MonadIOTransError e t m
=> IO (Either e a)
-> t m a
hoistIOEither = liftExceptT . ExceptT . liftIO
Loading