Skip to content

Commit

Permalink
Remove dependency on temporary base16 compatibility shim
Browse files Browse the repository at this point in the history
  • Loading branch information
newhoggy committed Dec 3, 2020
1 parent 2574600 commit 5d34dc4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cabal.project
Expand Up @@ -15,7 +15,7 @@ package cardano-crypto
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-prelude
tag: 742e8525b96bf4b66fb61a00c8298d75d7931d5e
tag: b2d5f869fc613cf0ac26836392ac6c182f7189fd
--sha256: 1132r58bjgdcf7yz3n77nlrkanqcmpn5b5km4nw151yar2dgifsv
subdir:
cardano-prelude
Expand Down
2 changes: 1 addition & 1 deletion cardano-crypto-class/cardano-crypto-class.cabal
Expand Up @@ -73,7 +73,7 @@ library

build-depends: aeson
, base
, base16-bytestring
, base16-bytestring >= 1
, bytestring
, cardano-binary
, cardano-prelude
Expand Down
6 changes: 2 additions & 4 deletions cardano-crypto-class/src/Cardano/Crypto/Hash/Class.hs
Expand Up @@ -81,8 +81,6 @@ import Cardano.Binary
(Encoding, FromCBOR (..), ToCBOR (..), Size, decodeBytes,
serializeEncoding')

import qualified Cardano.Prelude as P

class (KnownNat (SizeHash h), Typeable h) => HashAlgorithm h where
--TODO: eliminate this Typeable constraint needed only for the ToCBOR
-- the ToCBOR should not need it either
Expand Down Expand Up @@ -213,7 +211,7 @@ hashToBytesAsHex = Base16.encode . hashToBytes
-- is invalid hex. The whole byte string must be valid hex, not just a prefix.
--
hashFromBytesAsHex :: HashAlgorithm h => ByteString -> Maybe (Hash h a)
hashFromBytesAsHex = join . either (const Nothing) (Just . hashFromBytes) . P.decodeEitherBase16
hashFromBytesAsHex = join . either (const Nothing) (Just . hashFromBytes) . Base16.decode

instance Show (Hash h a) where
show = show . hashToStringAsHex
Expand Down Expand Up @@ -245,7 +243,7 @@ hashToText = Text.decodeLatin1 . hashToBytesAsHex

parseHash :: HashAlgorithm crypto => Text -> Aeson.Parser (Hash crypto a)
parseHash t =
case P.decodeEitherBase16 (Text.encodeUtf8 t) of
case Base16.decode (Text.encodeUtf8 t) of
Right bytes -> maybe badSize return (hashFromBytes bytes)
Left _ -> badHex
where
Expand Down
20 changes: 10 additions & 10 deletions nix/sources.json
Expand Up @@ -5,10 +5,10 @@
"homepage": "https://input-output-hk.github.io/haskell.nix",
"owner": "input-output-hk",
"repo": "haskell.nix",
"rev": "5fc93a3fd171bb40b97585e5eb2cab43dc467446",
"sha256": "0a4q51jsxsy6z1ljbfr97haffzhwsrai74mzj17ljk8d78c26kfm",
"rev": "131433c36bd05b90a6fb9f15647ca768584c96cc",
"sha256": "088ykxh7sh71ar17hc15x8ygb91n03hg9m60wjmihsz0ix0g62s5",
"type": "tarball",
"url": "https://github.com/input-output-hk/haskell.nix/archive/5fc93a3fd171bb40b97585e5eb2cab43dc467446.tar.gz",
"url": "https://github.com/input-output-hk/haskell.nix/archive/131433c36bd05b90a6fb9f15647ca768584c96cc.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"iohk-nix": {
Expand All @@ -17,10 +17,10 @@
"homepage": null,
"owner": "input-output-hk",
"repo": "iohk-nix",
"rev": "f0542228f98a2590e0f39c507b364321995ad802",
"sha256": "0yhgjg4bj7cv1lmrb9ig2iapv1mslhn6m750zn2x0n1a3ll267yh",
"rev": "9d4dbcaccae1a7230cb8ce1e3bdf5588a290f062",
"sha256": "1n01yf1n922q6kfbsh9ygjpf49i45ly8n4k7pb49cmb347wzhxim",
"type": "tarball",
"url": "https://github.com/input-output-hk/iohk-nix/archive/f0542228f98a2590e0f39c507b364321995ad802.tar.gz",
"url": "https://github.com/input-output-hk/iohk-nix/archive/9d4dbcaccae1a7230cb8ce1e3bdf5588a290f062.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"nixpkgs": {
Expand All @@ -29,10 +29,10 @@
"homepage": null,
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "07e5844fdf6fe99f41229d7392ce81cfe191bcfc",
"sha256": "0p2z6jidm4rlp2yjfl553q234swj1vxl8z0z8ra1hm61lfrlcmb9",
"rev": "92256441fd5d71fbeda08fba08edd0e7a0ebf3bd",
"sha256": "0z7qavxjkgdr2wb95jgd1r032b8zyi7xgsppdljs44bcxaczrys6",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/07e5844fdf6fe99f41229d7392ce81cfe191bcfc.tar.gz",
"url": "https://github.com/NixOS/nixpkgs/archive/92256441fd5d71fbeda08fba08edd0e7a0ebf3bd.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}
}
}

0 comments on commit 5d34dc4

Please sign in to comment.