From 805b11330d2852b5c2678a00e66abc102818b741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Thu, 25 Apr 2024 12:20:35 +0200 Subject: [PATCH 1/2] Hide filesystem functions in crypto behind feature flag. --- kairos-crypto/Cargo.toml | 3 ++- kairos-crypto/src/implementations/casper.rs | 3 +++ kairos-crypto/src/lib.rs | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/kairos-crypto/Cargo.toml b/kairos-crypto/Cargo.toml index 894086ed..f0c0213f 100644 --- a/kairos-crypto/Cargo.toml +++ b/kairos-crypto/Cargo.toml @@ -7,6 +7,7 @@ license.workspace = true [features] default = ["crypto-casper"] crypto-casper = ["casper-types"] +fs = ["casper-types/std"] # TODO: Change `std` -> `std-fs-io` in the future version. [lib] @@ -15,4 +16,4 @@ hex = "0.4" thiserror = "1" # Casper signer implementation. -casper-types = { version = "4", optional = true, features = ["std"] } # TODO: Change `std` -> `std-fs-io` in the future version. +casper-types = { version = "4", optional = true } diff --git a/kairos-crypto/src/implementations/casper.rs b/kairos-crypto/src/implementations/casper.rs index 9b0fcc57..645a73da 100644 --- a/kairos-crypto/src/implementations/casper.rs +++ b/kairos-crypto/src/implementations/casper.rs @@ -1,5 +1,7 @@ use casper_types::bytesrepr::{FromBytes, ToBytes}; use casper_types::{crypto, PublicKey, SecretKey, Signature}; + +#[cfg(feature = "fs")] use std::path::Path; use crate::CryptoError; @@ -11,6 +13,7 @@ pub struct Signer { } impl CryptoSigner for Signer { + #[cfg(feature = "fs")] fn from_private_key_file>(file: P) -> Result where Self: Sized, diff --git a/kairos-crypto/src/lib.rs b/kairos-crypto/src/lib.rs index a8f31aeb..e45477cf 100644 --- a/kairos-crypto/src/lib.rs +++ b/kairos-crypto/src/lib.rs @@ -1,11 +1,13 @@ pub mod error; pub mod implementations; +#[cfg(feature = "fs")] use std::path::Path; use error::CryptoError; pub trait CryptoSigner { + #[cfg(feature = "fs")] fn from_private_key_file>(file: P) -> Result where Self: Sized; From 343a6c2f08454eee493cd008caf999c44b68e914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Thu, 25 Apr 2024 12:20:53 +0200 Subject: [PATCH 2/2] Enable crypto's `fs` in CLI. --- kairos-cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kairos-cli/Cargo.toml b/kairos-cli/Cargo.toml index df53204e..69535981 100644 --- a/kairos-cli/Cargo.toml +++ b/kairos-cli/Cargo.toml @@ -18,7 +18,7 @@ casper-types = { version = "4.0.1", features = ["std"] } # TODO: Change `std` -> clap = { version = "4.5", features = ["derive", "deprecated"] } hex = "0.4" thiserror = "1" -kairos-crypto = { path = "../kairos-crypto" } +kairos-crypto = { path = "../kairos-crypto", features = ["fs"] } [dev-dependencies] assert_cmd = "2"