...
Some checks are pending
Rhai Tests / Run Rhai Tests (push) Waiting to run

This commit is contained in:
despiegk 2025-05-12 06:14:16 +03:00
parent 8aa2b2da26
commit e47e163285
31 changed files with 62 additions and 67 deletions

View File

@ -11,45 +11,42 @@ categories = ["os", "filesystem", "api-bindings"]
readme = "README.md"
[dependencies]
tera = "1.19.0" # Template engine for text rendering
# Cross-platform functionality
libc = "0.2"
anyhow = "1.0.98"
base64 = "0.21.0" # Base64 encoding/decoding
cfg-if = "1.0"
thiserror = "1.0" # For error handling
redis = "0.22.0" # Redis client
postgres = "0.19.4" # PostgreSQL client
tokio-postgres = "0.7.8" # Async PostgreSQL client
postgres-types = "0.2.5" # PostgreSQL type conversions
chacha20poly1305 = "0.10.1" # ChaCha20Poly1305 AEAD cipher
clap = "2.33" # Command-line argument parsing
dirs = "5.0.1" # Directory paths
env_logger = "0.10.0" # Logger implementation
ethers = { version = "2.0.7", features = ["legacy"] } # Ethereum library
glob = "0.3.1" # For file pattern matching
jsonrpsee = "0.25.1"
k256 = { version = "0.13.1", features = ["ecdsa"] } # Elliptic curve cryptography
lazy_static = "1.4.0" # For lazy initialization of static variables
libc = "0.2"
log = "0.4" # Logging facade
once_cell = "1.18.0" # Lazy static initialization
postgres = "0.19.4" # PostgreSQL client
postgres-types = "0.2.5" # PostgreSQL type conversions
r2d2 = "0.8.10"
r2d2_postgres = "0.18.2"
rand = "0.8.5" # Random number generation
redis = "0.22.0" # Redis client
regex = "1.8.1" # For regex pattern matching
rhai = { version = "1.12.0", features = ["sync"] } # Embedded scripting language
serde = { version = "1.0", features = [
"derive",
] } # For serialization/deserialization
serde_json = "1.0" # For JSON handling
glob = "0.3.1" # For file pattern matching
tempfile = "3.5" # For temporary file operations
log = "0.4" # Logging facade
env_logger = "0.10.0" # Logger implementation
rhai = { version = "1.12.0", features = ["sync"] } # Embedded scripting language
rand = "0.8.5" # Random number generation
clap = "2.33" # Command-line argument parsing
r2d2 = "0.8.10"
r2d2_postgres = "0.18.2"
# Crypto dependencies
base64 = "0.21.0" # Base64 encoding/decoding
k256 = { version = "0.13.1", features = ["ecdsa"] } # Elliptic curve cryptography
once_cell = "1.18.0" # Lazy static initialization
sha2 = "0.10.7" # SHA-2 hash functions
chacha20poly1305 = "0.10.1" # ChaCha20Poly1305 AEAD cipher
ethers = { version = "2.0.7", features = ["legacy"] } # Ethereum library
dirs = "5.0.1" # Directory paths
uuid = { version = "1.16.0", features = ["v4"] }
tokio-test = "0.4.4"
zinit-client = { git = "https://github.com/threefoldtech/zinit", branch = "json_rpc", package = "zinit-client" }
anyhow = "1.0.98"
jsonrpsee = "0.25.1"
tempfile = "3.5" # For temporary file operations
tera = "1.19.0" # Template engine for text rendering
thiserror = "1.0" # For error handling
tokio = "1.45.0"
tokio-postgres = "0.7.8" # Async PostgreSQL client
tokio-test = "0.4.4"
uuid = { version = "1.16.0", features = ["v4"] }
zinit-client = { git = "https://github.com/threefoldtech/zinit", branch = "json_rpc", package = "zinit-client" }
# Optional features for specific OS functionality
[target.'cfg(unix)'.dependencies]
@ -63,9 +60,9 @@ windows = { version = "0.48", features = [
] }
[dev-dependencies]
mockall = "0.11.4" # For mocking in tests
tempfile = "3.5" # For tests that need temporary files/directories
tokio = { version = "1.28", features = ["full", "test-util"] } # For async testing
mockall = "0.11.4" # For mocking in tests
[[bin]]
name = "herodo"

View File

@ -46,9 +46,7 @@ pub mod redisclient;
pub mod rhai;
pub mod text;
pub mod virt;
pub mod hero_vault;
pub mod rhai;
pub mod cmd;
pub mod vault;
pub mod zinit_client;
// Version information

View File

@ -11,8 +11,8 @@ use tokio::runtime::Runtime;
use ethers::types::{Address, U256};
use std::str::FromStr;
use crate::hero_vault::{keypair, symmetric, ethereum};
use crate::hero_vault::ethereum::{prepare_function_arguments, convert_token_to_rhai};
use crate::vault::{keypair, symmetric, ethereum};
use crate::vault::ethereum::{prepare_function_arguments, convert_token_to_rhai};
// Global Tokio runtime for blocking async operations
static RUNTIME: Lazy<Mutex<Runtime>> = Lazy::new(|| {

View File

@ -8,7 +8,7 @@ use std::sync::Arc;
use std::str::FromStr;
use serde::{Serialize, Deserialize};
use crate::hero_vault::error::CryptoError;
use crate::vault::error::CryptoError;
use super::wallet::EthereumWallet;
use super::networks::NetworkConfig;

View File

@ -2,7 +2,7 @@
use ethers::prelude::*;
use crate::hero_vault::error::CryptoError;
use crate::vault::error::CryptoError;
use super::networks::{self, NetworkConfig};
/// Creates a provider for a specific network.

View File

@ -4,7 +4,7 @@ use std::sync::Mutex;
use std::collections::HashMap;
use once_cell::sync::Lazy;
use crate::hero_vault::error::CryptoError;
use crate::vault::error::CryptoError;
use super::wallet::EthereumWallet;
use super::networks::{self, NetworkConfig};
@ -16,7 +16,7 @@ static ETH_WALLETS: Lazy<Mutex<HashMap<String, Vec<EthereumWallet>>>> = Lazy::ne
/// Creates an Ethereum wallet from the currently selected keypair for a specific network.
pub fn create_ethereum_wallet_for_network(network: NetworkConfig) -> Result<EthereumWallet, CryptoError> {
// Get the currently selected keypair
let keypair = crate::hero_vault::keypair::get_selected_keypair()?;
let keypair = crate::vault::keypair::get_selected_keypair()?;
// Create an Ethereum wallet from the keypair
let wallet = EthereumWallet::from_keypair(&keypair, network)?;
@ -77,7 +77,7 @@ pub fn clear_ethereum_wallets_for_network(network_name: &str) {
/// Creates an Ethereum wallet from a name and the currently selected keypair for a specific network.
pub fn create_ethereum_wallet_from_name_for_network(name: &str, network: NetworkConfig) -> Result<EthereumWallet, CryptoError> {
// Get the currently selected keypair
let keypair = crate::hero_vault::keypair::get_selected_keypair()?;
let keypair = crate::vault::keypair::get_selected_keypair()?;
// Create an Ethereum wallet from the name and keypair
let wallet = EthereumWallet::from_name_and_keypair(name, &keypair, network)?;

View File

@ -3,7 +3,7 @@
use ethers::types::Address;
use std::str::FromStr;
use crate::hero_vault::ethereum::*;
use crate::vault::ethereum::*;
#[test]
fn test_contract_creation() {

View File

@ -3,7 +3,7 @@
use ethers::types::Address;
use std::str::FromStr;
use crate::hero_vault::ethereum::*;
use crate::vault::ethereum::*;
#[test]
fn test_contract_creation() {

View File

@ -1,6 +1,6 @@
//! Tests for Ethereum network functionality.
use crate::hero_vault::ethereum::*;
use crate::vault::ethereum::*;
#[test]
fn test_network_config() {

View File

@ -1,7 +1,7 @@
//! Tests for Ethereum transaction functionality.
use crate::hero_vault::ethereum::*;
use crate::hero_vault::keypair::KeyPair;
use crate::vault::ethereum::*;
use crate::vault::keypair::KeyPair;
use ethers::types::U256;
use std::str::FromStr;

View File

@ -1,7 +1,7 @@
//! Tests for Ethereum wallet functionality.
use crate::hero_vault::ethereum::*;
use crate::hero_vault::keypair::KeyPair;
use crate::vault::ethereum::*;
use crate::vault::keypair::KeyPair;
use ethers::utils::hex;
#[test]
@ -64,8 +64,8 @@ fn test_wallet_management() {
clear_ethereum_wallets();
// Create a key space and keypair
crate::hero_vault::keypair::create_space("test_space").unwrap();
crate::hero_vault::keypair::create_keypair("test_keypair3").unwrap();
crate::vault::keypair::create_space("test_space").unwrap();
crate::vault::keypair::create_keypair("test_keypair3").unwrap();
// Create wallets for different networks
let gnosis_wallet = create_ethereum_wallet_for_network(networks::gnosis()).unwrap();

View File

@ -2,7 +2,7 @@
use ethers::prelude::*;
use crate::hero_vault::error::CryptoError;
use crate::vault::error::CryptoError;
use super::wallet::EthereumWallet;
use super::networks::NetworkConfig;

View File

@ -7,8 +7,8 @@ use k256::ecdsa::SigningKey;
use std::str::FromStr;
use sha2::{Sha256, Digest};
use crate::hero_vault::error::CryptoError;
use crate::hero_vault::keypair::KeyPair;
use crate::vault::error::CryptoError;
use crate::vault::keypair::KeyPair;
use super::networks::NetworkConfig;
/// An Ethereum wallet derived from a keypair.

View File

@ -8,7 +8,7 @@ use once_cell::sync::Lazy;
use std::sync::Mutex;
use sha2::{Sha256, Digest};
use crate::hero_vault::error::CryptoError;
use crate::vault::error::CryptoError;
/// A keypair for signing and verifying messages.
#[derive(Debug, Clone, Serialize, Deserialize)]
@ -226,7 +226,7 @@ impl KeyPair {
};
// Encrypt the message using the derived key
let ciphertext = crate::hero_vault::symmetric::encrypt_with_key(&shared_secret, message)
let ciphertext = crate::vault::symmetric::encrypt_with_key(&shared_secret, message)
.map_err(|e| CryptoError::EncryptionFailed(e.to_string()))?;
// Format: ephemeral_public_key || ciphertext
@ -263,7 +263,7 @@ impl KeyPair {
};
// Decrypt the message using the derived key
crate::hero_vault::symmetric::decrypt_with_key(&shared_secret, actual_ciphertext)
crate::vault::symmetric::decrypt_with_key(&shared_secret, actual_ciphertext)
.map_err(|e| CryptoError::DecryptionFailed(e.to_string()))
}
}

View File

@ -45,18 +45,18 @@ impl From<serde_json::Error> for KvsError {
}
}
impl From<KvsError> for crate::hero_vault::error::CryptoError {
impl From<KvsError> for crate::vault::error::CryptoError {
fn from(err: KvsError) -> Self {
crate::hero_vault::error::CryptoError::SerializationError(err.to_string())
crate::vault::error::CryptoError::SerializationError(err.to_string())
}
}
impl From<crate::hero_vault::error::CryptoError> for KvsError {
fn from(err: crate::hero_vault::error::CryptoError) -> Self {
impl From<crate::vault::error::CryptoError> for KvsError {
fn from(err: crate::vault::error::CryptoError) -> Self {
match err {
crate::hero_vault::error::CryptoError::EncryptionFailed(msg) => KvsError::Encryption(msg),
crate::hero_vault::error::CryptoError::DecryptionFailed(msg) => KvsError::Decryption(msg),
crate::hero_vault::error::CryptoError::SerializationError(msg) => KvsError::Serialization(msg),
crate::vault::error::CryptoError::EncryptionFailed(msg) => KvsError::Encryption(msg),
crate::vault::error::CryptoError::DecryptionFailed(msg) => KvsError::Decryption(msg),
crate::vault::error::CryptoError::SerializationError(msg) => KvsError::Serialization(msg),
_ => KvsError::Other(err.to_string()),
}
}

View File

@ -1,7 +1,7 @@
//! Implementation of a simple key-value store using the filesystem.
use crate::hero_vault::kvs::error::{KvsError, Result};
use crate::hero_vault::symmetric;
use crate::vault::kvs::error::{KvsError, Result};
use crate::vault::symmetric;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::collections::HashMap;
use std::fs;

View File

@ -6,8 +6,8 @@ use rand::{rngs::OsRng, RngCore};
use serde::{Serialize, Deserialize};
use sha2::{Sha256, Digest};
use crate::hero_vault::error::CryptoError;
use crate::hero_vault::keypair::KeySpace;
use crate::vault::error::CryptoError;
use crate::vault::keypair::KeySpace;
/// The size of the nonce in bytes.
const NONCE_SIZE: usize = 12;