fix: Make executor_address a String instead of Address
--- don't change below this line --- ENG-4075 <#DTT#>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::cmp::min;
|
use std::{cmp::min, str::FromStr};
|
||||||
|
|
||||||
use alloy_primitives::Address;
|
use alloy_primitives::Address;
|
||||||
use alloy_sol_types::SolValue;
|
use alloy_sol_types::SolValue;
|
||||||
@@ -97,7 +97,13 @@ impl StrategyEncoder for SequentialStrategyEncoder {
|
|||||||
};
|
};
|
||||||
let protocol_data = swap_encoder.encode_swap(swap.clone(), encoding_context)?;
|
let protocol_data = swap_encoder.encode_swap(swap.clone(), encoding_context)?;
|
||||||
let executor_address = swap_encoder.executor_address();
|
let executor_address = swap_encoder.executor_address();
|
||||||
let swap_data = self.encode_protocol_header(protocol_data, executor_address, 0, 0, 0);
|
let swap_data = self.encode_protocol_header(
|
||||||
|
protocol_data,
|
||||||
|
Address::from_str(executor_address).expect("Couldn't convert executor address"),
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
);
|
||||||
swaps.push(swap_data);
|
swaps.push(swap_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,22 +1,17 @@
|
|||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use alloy_primitives::Address;
|
|
||||||
|
|
||||||
use crate::encoding::swap_encoder::swap_struct_encoder::{
|
use crate::encoding::swap_encoder::swap_struct_encoder::{
|
||||||
BalancerV2SwapEncoder, SwapEncoder, UniswapV2SwapEncoder,
|
BalancerV2SwapEncoder, SwapEncoder, UniswapV2SwapEncoder,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct SwapEncoderBuilder {
|
pub struct SwapEncoderBuilder {
|
||||||
protocol_system: String,
|
protocol_system: String,
|
||||||
executor_address: Address,
|
executor_address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SwapEncoderBuilder {
|
impl SwapEncoderBuilder {
|
||||||
pub fn new(protocol_system: &str, executor_address: &str) -> Self {
|
pub fn new(protocol_system: &str, executor_address: &str) -> Self {
|
||||||
SwapEncoderBuilder {
|
SwapEncoderBuilder {
|
||||||
protocol_system: protocol_system.to_string(),
|
protocol_system: protocol_system.to_string(),
|
||||||
executor_address: Address::from_str(executor_address)
|
executor_address: executor_address.to_string(),
|
||||||
.unwrap_or_else(|_| panic!("Invalid address: {}", executor_address)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,20 +11,20 @@ use crate::encoding::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub trait SwapEncoder: Sync + Send {
|
pub trait SwapEncoder: Sync + Send {
|
||||||
fn new(executor_address: Address) -> Self
|
fn new(executor_address: String) -> Self
|
||||||
where
|
where
|
||||||
Self: Sized;
|
Self: Sized;
|
||||||
fn encode_swap(&self, swap: Swap, encoding_context: EncodingContext) -> Result<Vec<u8>, Error>;
|
fn encode_swap(&self, swap: Swap, encoding_context: EncodingContext) -> Result<Vec<u8>, Error>;
|
||||||
fn executor_address(&self) -> Address;
|
fn executor_address(&self) -> &str;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UniswapV2SwapEncoder {
|
pub struct UniswapV2SwapEncoder {
|
||||||
executor_address: Address,
|
executor_address: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UniswapV2SwapEncoder {}
|
impl UniswapV2SwapEncoder {}
|
||||||
impl SwapEncoder for UniswapV2SwapEncoder {
|
impl SwapEncoder for UniswapV2SwapEncoder {
|
||||||
fn new(executor_address: Address) -> Self {
|
fn new(executor_address: String) -> Self {
|
||||||
Self { executor_address }
|
Self { executor_address }
|
||||||
}
|
}
|
||||||
fn encode_swap(
|
fn encode_swap(
|
||||||
@@ -35,18 +35,18 @@ impl SwapEncoder for UniswapV2SwapEncoder {
|
|||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn executor_address(&self) -> Address {
|
fn executor_address(&self) -> &str {
|
||||||
self.executor_address
|
&self.executor_address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BalancerV2SwapEncoder {
|
pub struct BalancerV2SwapEncoder {
|
||||||
executor_address: Address,
|
executor_address: String,
|
||||||
vault_address: Address,
|
vault_address: Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SwapEncoder for BalancerV2SwapEncoder {
|
impl SwapEncoder for BalancerV2SwapEncoder {
|
||||||
fn new(executor_address: Address) -> Self {
|
fn new(executor_address: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
executor_address,
|
executor_address,
|
||||||
vault_address: Address::from_str("0xba12222222228d8ba445958a75a0704d566bf2c8")
|
vault_address: Address::from_str("0xba12222222228d8ba445958a75a0704d566bf2c8")
|
||||||
@@ -79,8 +79,8 @@ impl SwapEncoder for BalancerV2SwapEncoder {
|
|||||||
Ok(args.abi_encode())
|
Ok(args.abi_encode())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn executor_address(&self) -> Address {
|
fn executor_address(&self) -> &str {
|
||||||
self.executor_address
|
&self.executor_address
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user