Skip to content
Permalink
Browse files

cardano-cli: further cleanup

  • Loading branch information...
deepfire committed Sep 11, 2019
1 parent a48540e commit 39e0ad2924e3e9c6b1c65aae56d1ce129f96282c
Showing with 11 additions and 7 deletions.
  1. +5 −0 cardano-node/src/Cardano/CLI/Delegation.hs
  2. +6 −7 cardano-node/src/Cardano/CLI/Legacy/Byron.hs
@@ -88,8 +88,13 @@ checkDlgCert cert magic issuerVK' delegateVK' =
]
]
where
magic' :: Annotated ProtocolMagicId ByteString
magic' = Annotated magic (serialize' magic)

epoch :: EpochNumber
epoch = unAnnotated $ Dlg.aEpoch cert

cert' :: Dlg.ACertificate ByteString
cert' = cert { Dlg.aEpoch = Annotated epoch (serialize' epoch) }

vk :: forall r. F.Format r (Crypto.VerificationKey -> r)
@@ -19,9 +19,8 @@ module Cardano.CLI.Legacy.Byron (
import qualified Codec.CBOR.Decoding as D
import qualified Codec.CBOR.Encoding as E
import Control.Lens (LensLike, _Left)
import Control.Monad
import qualified Data.Binary as Binary
import Data.Coerce
import Data.Coerce (coerce)
import Data.Semigroup ((<>))
import Data.Text (Text)
import qualified Data.Text as T
@@ -31,7 +30,7 @@ import qualified Crypto.SCRAPE as Scrape

import Cardano.Prelude hiding (option)

import qualified Cardano.Crypto.Wallet as CC
import qualified Cardano.Crypto.Wallet as Wallet
import Cardano.Crypto.Signing (SigningKey(..))

-- LegacyDelegateKey is a subset of the UserSecret's from the legacy codebase:
@@ -60,12 +59,12 @@ decodeBinary = do
| LB.null bs -> Right res
| otherwise -> Left "decodeBinary: unconsumed input"

encodeXPrv :: CC.XPrv -> E.Encoding
encodeXPrv a = E.encodeBytes $ CC.unXPrv a
encodeXPrv :: Wallet.XPrv -> E.Encoding
encodeXPrv a = E.encodeBytes $ Wallet.unXPrv a

decodeXPrv :: D.Decoder s CC.XPrv
decodeXPrv :: D.Decoder s Wallet.XPrv
decodeXPrv =
toCborError . over _Left T.pack . CC.xprv =<< D.decodeBytesCanonical
toCborError . over _Left T.pack . Wallet.xprv =<< D.decodeBytesCanonical

where over :: LensLike Identity s t a b -> (a -> b) -> s -> t
over = coerce

0 comments on commit 39e0ad2

Please sign in to comment.
You can’t perform that action at this time.