diff --git a/ethereum-core-counts.json b/ethereum-core-counts.json deleted file mode 100644 index fb08dbb..0000000 --- a/ethereum-core-counts.json +++ /dev/null @@ -1 +0,0 @@ -{"ETHEREUM.BLOCKS":42,"ETHEREUM.BLOCK_DETAILS":43,"ETHEREUM.TRANSACTIONS":6436,"ETHEREUM.TRANSACTION_DETAILS":6607,"ETHEREUM.CONTRACTS":56,"ETHEREUM.TOKENS":1,"ETHEREUM.NFTS":38,"ETHEREUM.NATIVETOKEN_TRANSFERS":3100,"ETHEREUM.FUNGIBLETOKEN_WALLETS":12959,"ETHEREUM.ERC1155_OWNERS":21} \ No newline at end of file diff --git a/sdk/src/args.rs b/sdk/src/args.rs index bcb23dc..2e6b346 100644 --- a/sdk/src/args.rs +++ b/sdk/src/args.rs @@ -1,5 +1,5 @@ -use crate::{parse_postprocessing_level, PostprocessingLevel, SxTClient}; -use clap::Parser; +use crate::{PostprocessingLevel, SxTClient}; +use clap::{Parser, ValueEnum}; /// Struct to define and parse command-line arguments for Proof of SQL Client. /// @@ -85,10 +85,33 @@ pub struct SdkArgs { long, value_name = "POSTPROCESSING_LEVEL", default_value = "cheap", - value_parser = parse_postprocessing_level, + value_enum, help = "Level of postprocessing allowed, default is `Cheap`" )] - pub postprocessing_level: PostprocessingLevel, + pub postprocessing_level: PostprocessingLevelArg, +} + +/// Level of postprocessing allowed. +/// +/// We have it as a separate enum from `PostprocessingLevel` so that the core of the lib won't depend on `clap`. +#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] +pub enum PostprocessingLevelArg { + /// No postprocessing allowed + None, + /// Only cheap postprocessing allowed + Cheap, + /// All postprocessing allowed + All, +} + +impl From for PostprocessingLevel { + fn from(arg: PostprocessingLevelArg) -> Self { + match arg { + PostprocessingLevelArg::None => PostprocessingLevel::None, + PostprocessingLevelArg::Cheap => PostprocessingLevel::Cheap, + PostprocessingLevelArg::All => PostprocessingLevel::All, + } + } } impl From<&SdkArgs> for SxTClient { @@ -100,6 +123,6 @@ impl From<&SdkArgs> for SxTClient { args.sxt_api_key.clone(), args.verifier_setup.clone(), ) - .with_postprocessing(args.postprocessing_level) + .with_postprocessing(args.postprocessing_level.into()) } } diff --git a/sdk/src/client.rs b/sdk/src/client.rs index 4fa221f..822023f 100644 --- a/sdk/src/client.rs +++ b/sdk/src/client.rs @@ -12,7 +12,7 @@ use proof_of_sql::{ }; use prover::{ProverContextRange, ProverQuery, ProverResponse}; use reqwest::Client; -use std::{collections::HashMap, path::Path, str::FromStr}; +use std::{collections::HashMap, path::Path}; mod prover { tonic::include_proto!("sxt.core"); @@ -31,33 +31,6 @@ pub enum PostprocessingLevel { All, } -impl FromStr for PostprocessingLevel { - type Err = String; - - fn from_str(s: &str) -> Result { - match s.to_lowercase().as_str() { - "none" => Ok(PostprocessingLevel::None), - "cheap" => Ok(PostprocessingLevel::Cheap), - "all" => Ok(PostprocessingLevel::All), - _ => Err(format!("Invalid value for PostprocessingLevel: {}", s)), - } - } -} - -impl std::fmt::Display for PostprocessingLevel { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - PostprocessingLevel::None => write!(f, "none"), - PostprocessingLevel::Cheap => write!(f, "cheap"), - PostprocessingLevel::All => write!(f, "expensive"), - } - } -} - -pub(crate) fn parse_postprocessing_level(s: &str) -> Result { - s.parse() -} - /// Space and Time (SxT) client #[derive(Debug, Clone)] pub struct SxTClient { diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index e91745b..f367b0f 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -1,9 +1,8 @@ mod args; -pub use args::SdkArgs; +pub use args::{PostprocessingLevelArg, SdkArgs}; mod auth; pub use auth::get_access_token; mod client; -pub(crate) use client::parse_postprocessing_level; pub use client::{PostprocessingLevel, SxTClient}; mod substrate; pub use substrate::query_commitments;