fix: Don't have a DEFAULT_CONFIG_PATH in bin

This is unnecessary since we already have the executor address loaded at build time

--- don't change below this line ---
ENG-4088 Took 8 minutes


Took 7 seconds
This commit is contained in:
Diana Carvalho
2025-02-07 12:24:26 +00:00
parent cad9f394cd
commit d7f20aa74f
6 changed files with 11 additions and 14 deletions

View File

@@ -1,6 +1,5 @@
pub use clap::Parser; pub use clap::Parser;
pub const DEFAULT_ROUTER_ADDRESS: &str = "0xaa820C29648D5EA543d712cC928377Bd7206a0E7"; pub const DEFAULT_ROUTER_ADDRESS: &str = "0xaa820C29648D5EA543d712cC928377Bd7206a0E7";
pub const DEFAULT_CONFIG_PATH: &str = "src/encoding/config/executor_addresses.json";
#[derive(Parser)] #[derive(Parser)]
/// Encode swap transactions for the Tycho router /// Encode swap transactions for the Tycho router
@@ -45,6 +44,6 @@ pub struct Cli {
pub private_key: Option<String>, pub private_key: Option<String>,
/// Path to the executor addresses configuration file /// Path to the executor addresses configuration file
#[arg(short, default_value = DEFAULT_CONFIG_PATH)] #[arg(short)]
pub config_path: String, pub config_path: Option<String>,
} }

View File

@@ -33,7 +33,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
// Encode the solution // 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 // Output the encoded result as JSON to stdout
println!( println!(
@@ -48,16 +48,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
fn encode_swaps( fn encode_swaps(
input: &str, input: &str,
router_address: &str, router_address: &str,
config_path: &str, config_path: Option<String>,
private_key: Option<String>, private_key: Option<String>,
) -> Result<Value, Box<dyn std::error::Error>> { ) -> Result<Value, Box<dyn std::error::Error>> {
let solution: Solution = serde_json::from_str(input)?; let solution: Solution = serde_json::from_str(input)?;
let chain = Chain::Ethereum; let chain = Chain::Ethereum;
let strategy_selector = let strategy_selector = EVMStrategyEncoderRegistry::new(chain, config_path, private_key)?;
EVMStrategyEncoderRegistry::new(chain.into(), config_path, private_key)?; let encoder = EVMTychoEncoder::new(strategy_selector, router_address.to_string(), chain)?;
let encoder =
EVMTychoEncoder::new(strategy_selector, router_address.to_string(), chain.into())?;
let transactions = encoder.encode_router_calldata(vec![solution])?; let transactions = encoder.encode_router_calldata(vec![solution])?;
Ok(serde_json::json!({ Ok(serde_json::json!({

View File

@@ -22,7 +22,7 @@ pub struct EVMStrategyEncoderRegistry {
impl StrategyEncoderRegistry for EVMStrategyEncoderRegistry { impl StrategyEncoderRegistry for EVMStrategyEncoderRegistry {
fn new( fn new(
chain: tycho_core::dto::Chain, chain: tycho_core::dto::Chain,
executors_file_path: Option<&str>, executors_file_path: Option<String>,
signer_pk: Option<String>, signer_pk: Option<String>,
) -> Result<Self, EncodingError> { ) -> Result<Self, EncodingError> {
let chain = Chain::from(chain); let chain = Chain::from(chain);

View File

@@ -18,10 +18,10 @@ impl SwapEncoderRegistry {
/// Populates the registry with the `SwapEncoders` for the given blockchain by parsing the /// Populates the registry with the `SwapEncoders` for the given blockchain by parsing the
/// executors' addresses in the file at the given path. /// executors' addresses in the file at the given path.
pub fn new( pub fn new(
executors_file_path: Option<&str>, executors_file_path: Option<String>,
blockchain: Chain, blockchain: Chain,
) -> Result<Self, EncodingError> { ) -> Result<Self, EncodingError> {
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| { fs::read_to_string(path).map_err(|e| {
EncodingError::FatalError(format!( EncodingError::FatalError(format!(
"Error reading executors file from {:?}: {}", "Error reading executors file from {:?}: {}",

View File

@@ -167,7 +167,7 @@ mod tests {
impl StrategyEncoderRegistry for MockStrategyRegistry { impl StrategyEncoderRegistry for MockStrategyRegistry {
fn new( fn new(
_chain: tycho_core::dto::Chain, _chain: tycho_core::dto::Chain,
_executors_file_path: Option<&str>, _executors_file_path: Option<String>,
_signer_pk: Option<String>, _signer_pk: Option<String>,
) -> Result<MockStrategyRegistry, EncodingError> { ) -> Result<MockStrategyRegistry, EncodingError> {
Ok(Self { strategy: Box::new(MockStrategy) }) Ok(Self { strategy: Box::new(MockStrategy) })

View File

@@ -20,7 +20,7 @@ pub trait StrategyEncoder {
pub trait StrategyEncoderRegistry { pub trait StrategyEncoderRegistry {
fn new( fn new(
chain: Chain, chain: Chain,
executors_file_path: Option<&str>, executors_file_path: Option<String>,
signer_pk: Option<String>, signer_pk: Option<String>,
) -> Result<Self, EncodingError> ) -> Result<Self, EncodingError>
where where