diff --git a/src/bin/lib/cli.rs b/src/bin/lib/cli.rs index 25e8786..6fd23fa 100644 --- a/src/bin/lib/cli.rs +++ b/src/bin/lib/cli.rs @@ -1,6 +1,5 @@ pub use clap::Parser; pub const DEFAULT_ROUTER_ADDRESS: &str = "0xaa820C29648D5EA543d712cC928377Bd7206a0E7"; -pub const DEFAULT_CONFIG_PATH: &str = "src/encoding/config/executor_addresses.json"; #[derive(Parser)] /// Encode swap transactions for the Tycho router @@ -45,6 +44,6 @@ pub struct Cli { pub private_key: Option, /// Path to the executor addresses configuration file - #[arg(short, default_value = DEFAULT_CONFIG_PATH)] - pub config_path: String, + #[arg(short)] + pub config_path: Option, } diff --git a/src/bin/tycho-encode.rs b/src/bin/tycho-encode.rs index 62bb74d..0727118 100644 --- a/src/bin/tycho-encode.rs +++ b/src/bin/tycho-encode.rs @@ -33,7 +33,7 @@ fn main() -> Result<(), Box> { } // Encode the solution - let encoded = encode_swaps(&buffer, &cli.router_address, &cli.config_path, cli.private_key)?; + let encoded = encode_swaps(&buffer, &cli.router_address, cli.config_path, cli.private_key)?; // Output the encoded result as JSON to stdout println!( @@ -48,16 +48,14 @@ fn main() -> Result<(), Box> { fn encode_swaps( input: &str, router_address: &str, - config_path: &str, + config_path: Option, private_key: Option, ) -> Result> { let solution: Solution = serde_json::from_str(input)?; let chain = Chain::Ethereum; - let strategy_selector = - EVMStrategyEncoderRegistry::new(chain.into(), config_path, private_key)?; - let encoder = - EVMTychoEncoder::new(strategy_selector, router_address.to_string(), chain.into())?; + let strategy_selector = EVMStrategyEncoderRegistry::new(chain, config_path, private_key)?; + let encoder = EVMTychoEncoder::new(strategy_selector, router_address.to_string(), chain)?; let transactions = encoder.encode_router_calldata(vec![solution])?; Ok(serde_json::json!({ diff --git a/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs b/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs index ddcfcd9..71b266d 100644 --- a/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs +++ b/src/encoding/evm/strategy_encoder/strategy_encoder_registry.rs @@ -22,7 +22,7 @@ pub struct EVMStrategyEncoderRegistry { impl StrategyEncoderRegistry for EVMStrategyEncoderRegistry { fn new( chain: tycho_core::dto::Chain, - executors_file_path: Option<&str>, + executors_file_path: Option, signer_pk: Option, ) -> Result { let chain = Chain::from(chain); diff --git a/src/encoding/evm/swap_encoder/swap_encoder_registry.rs b/src/encoding/evm/swap_encoder/swap_encoder_registry.rs index 006b28f..30599d3 100644 --- a/src/encoding/evm/swap_encoder/swap_encoder_registry.rs +++ b/src/encoding/evm/swap_encoder/swap_encoder_registry.rs @@ -18,10 +18,10 @@ impl SwapEncoderRegistry { /// Populates the registry with the `SwapEncoders` for the given blockchain by parsing the /// executors' addresses in the file at the given path. pub fn new( - executors_file_path: Option<&str>, + executors_file_path: Option, blockchain: Chain, ) -> Result { - let config_str = if let Some(path) = executors_file_path { + let config_str = if let Some(ref path) = executors_file_path { fs::read_to_string(path).map_err(|e| { EncodingError::FatalError(format!( "Error reading executors file from {:?}: {}", diff --git a/src/encoding/evm/tycho_encoder.rs b/src/encoding/evm/tycho_encoder.rs index d9912ff..6d9ef6a 100644 --- a/src/encoding/evm/tycho_encoder.rs +++ b/src/encoding/evm/tycho_encoder.rs @@ -167,7 +167,7 @@ mod tests { impl StrategyEncoderRegistry for MockStrategyRegistry { fn new( _chain: tycho_core::dto::Chain, - _executors_file_path: Option<&str>, + _executors_file_path: Option, _signer_pk: Option, ) -> Result { Ok(Self { strategy: Box::new(MockStrategy) }) diff --git a/src/encoding/strategy_encoder.rs b/src/encoding/strategy_encoder.rs index 89a128f..40d6471 100644 --- a/src/encoding/strategy_encoder.rs +++ b/src/encoding/strategy_encoder.rs @@ -20,7 +20,7 @@ pub trait StrategyEncoder { pub trait StrategyEncoderRegistry { fn new( chain: Chain, - executors_file_path: Option<&str>, + executors_file_path: Option, signer_pk: Option, ) -> Result where