From 8732f4f8c9ba257858b8e7097e672666dcec8253 Mon Sep 17 00:00:00 2001 From: Donovan Dall Date: Tue, 14 May 2024 16:54:54 +0100 Subject: [PATCH] feat: expose mode to the cli --- bin/cli/src/main.rs | 5 ++++- crates/primitives/src/lib.rs | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/cli/src/main.rs b/bin/cli/src/main.rs index 9fafd3c..19b8a23 100644 --- a/bin/cli/src/main.rs +++ b/bin/cli/src/main.rs @@ -1,6 +1,7 @@ use clap; use clap::{command, Parser}; use near_da_http_api_data::ConfigureClientRequest; +use near_da_primitives::Mode; use near_da_rpc::near::config::Config; use near_da_rpc::near::Client; use near_da_rpc::{CryptoHash, DataAvailability}; @@ -20,6 +21,8 @@ struct Args { config: Option, #[command(subcommand)] command: Commands, + #[clap(short, long)] + mode: Option, } struct AppState { client: Option, @@ -37,7 +40,7 @@ fn config_request_to_config(request: ConfigureClientRequest) -> Result for Mode { + fn from(s: &str) -> Self { + match s.to_lowercase().as_str() { + "optimistic" => Mode::Optimistic, + "standard" => Mode::Standard, + "pessimistic" => Mode::Pessimistic, + _ => Mode::Pessimistic, + } + } +} + #[cfg(test)] mod tests { use super::*;