commit e36b0a81145b163bdf103d43e31392b272417cbe
parent f40766056e463a82a06eec66d7b08cba1dbcf2d4
Author: Jared Tobin <jared@jtobin.io>
Date: Sun, 22 Jun 2025 12:51:28 +0400
lib: vertical integration
Diffstat:
4 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/flake.lock b/flake.lock
@@ -34,6 +34,37 @@
"type": "github"
}
},
+ "ppad-base16": {
+ "inputs": {
+ "flake-utils": [
+ "ppad-base16",
+ "ppad-nixpkgs",
+ "flake-utils"
+ ],
+ "nixpkgs": [
+ "ppad-base16",
+ "ppad-nixpkgs",
+ "nixpkgs"
+ ],
+ "ppad-nixpkgs": [
+ "ppad-nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1741625558,
+ "narHash": "sha256-ZBDXRD5fsVqA5bGrAlcnhiu67Eo50q0M9614nR3NBwY=",
+ "ref": "master",
+ "rev": "fb63457f2e894eda28250dfe65d0fcd1d195ac2f",
+ "revCount": 24,
+ "type": "git",
+ "url": "git://git.ppad.tech/base16.git"
+ },
+ "original": {
+ "ref": "master",
+ "type": "git",
+ "url": "git://git.ppad.tech/base16.git"
+ }
+ },
"ppad-nixpkgs": {
"inputs": {
"flake-utils": "flake-utils",
@@ -95,6 +126,7 @@
"ppad-nixpkgs",
"nixpkgs"
],
+ "ppad-base16": "ppad-base16",
"ppad-nixpkgs": "ppad-nixpkgs",
"ppad-sha256": "ppad-sha256"
}
diff --git a/flake.nix b/flake.nix
@@ -7,6 +7,12 @@
url = "git://git.ppad.tech/nixpkgs.git";
ref = "master";
};
+ ppad-base16 = {
+ type = "git";
+ url = "git://git.ppad.tech/base16.git";
+ ref = "master";
+ inputs.ppad-nixpkgs.follows = "ppad-nixpkgs";
+ };
ppad-sha256 = {
type = "git";
url = "git://git.ppad.tech/sha256.git";
@@ -18,7 +24,7 @@
};
outputs = { self, nixpkgs, flake-utils, ppad-nixpkgs
- , ppad-sha256
+ , ppad-base16, ppad-sha256
}:
flake-utils.lib.eachDefaultSystem (system:
let
@@ -27,11 +33,14 @@
pkgs = import nixpkgs { inherit system; };
hlib = pkgs.haskell.lib;
+ base16 = ppad-base16.packages.${system}.default;
sha256 = ppad-sha256.packages.${system}.default;
hpkgs = pkgs.haskell.packages.ghc981.extend (new: old: {
+ ppad-base16 = base16;
ppad-sha256 = sha256;
${lib} = new.callCabal2nixWithOptions lib ./. "--enable-profiling" {
+ ppad-base16 = new.ppad-base16;
ppad-sha256 = new.ppad-sha256;
};
});
diff --git a/ppad-base58.cabal b/ppad-base58.cabal
@@ -42,8 +42,8 @@ test-suite base58-tests
build-depends:
aeson
, base
- , base16-bytestring
, bytestring
+ , ppad-base16
, ppad-base58
, tasty
, tasty-hunit
diff --git a/test/Main.hs b/test/Main.hs
@@ -21,10 +21,15 @@ data Valid_Base58Check = Valid_Base58Check {
, vc_payload :: !BS.ByteString
} deriving Show
+decodeLenient :: BS.ByteString -> BS.ByteString
+decodeLenient bs = case B16.decode bs of
+ Nothing -> error "boom"
+ Just v -> v
+
instance A.FromJSON Valid_Base58Check where
parseJSON = A.withObject "Valid_Base58Check" $ \m -> Valid_Base58Check
<$> fmap TE.encodeUtf8 (m .: "string")
- <*> fmap (B16.decodeLenient . TE.encodeUtf8) (m .: "payload")
+ <*> fmap (decodeLenient . TE.encodeUtf8) (m .: "payload")
data Invalid_Base58Check = Invalid_Base58Check {
ic_string :: !BS.ByteString
@@ -69,7 +74,7 @@ data Valid_Base58 = Valid_Base58 {
instance A.FromJSON Valid_Base58 where
parseJSON = A.withObject "Valid_Base58" $ \m -> Valid_Base58
- <$> fmap (B16.decodeLenient . TE.encodeUtf8) (m .: "decodedHex")
+ <$> fmap (decodeLenient . TE.encodeUtf8) (m .: "decodedHex")
<*> fmap TE.encodeUtf8 (m .: "encoded")
execute_base58 :: Valid_Base58 -> TestTree -- XX label