fix: Make clippy happy after new format! format
Took 19 minutes
This commit is contained in:
1192
Cargo.lock
generated
1192
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -69,7 +69,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let mut buffer = String::new();
|
let mut buffer = String::new();
|
||||||
io::stdin()
|
io::stdin()
|
||||||
.read_to_string(&mut buffer)
|
.read_to_string(&mut buffer)
|
||||||
.map_err(|e| format!("Failed to read from stdin: {}", e))?;
|
.map_err(|e| format!("Failed to read from stdin: {e}"))?;
|
||||||
|
|
||||||
if buffer.trim().is_empty() {
|
if buffer.trim().is_empty() {
|
||||||
return Err("No input provided. Expected JSON input on stdin.".into());
|
return Err("No input provided. Expected JSON input on stdin.".into());
|
||||||
@@ -108,8 +108,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// Output the encoded result as JSON to stdout
|
// Output the encoded result as JSON to stdout
|
||||||
println!(
|
println!(
|
||||||
"{}",
|
"{}",
|
||||||
serde_json::to_string(&encoded)
|
serde_json::to_string(&encoded).map_err(|e| format!("Failed to serialize output: {e}"))?
|
||||||
.map_err(|e| format!("Failed to serialize output: {}", e))?
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -116,8 +116,7 @@ impl Permit2 {
|
|||||||
Ok(allowance)
|
Ok(allowance)
|
||||||
}
|
}
|
||||||
Err(err) => Err(EncodingError::RecoverableError(format!(
|
Err(err) => Err(EncodingError::RecoverableError(format!(
|
||||||
"Call to permit2 allowance method failed with error: {:?}",
|
"Call to permit2 allowance method failed with error: {err}"
|
||||||
err
|
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,8 +157,7 @@ impl Permit2 {
|
|||||||
.sign_hash_sync(&hash)
|
.sign_hash_sync(&hash)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
EncodingError::FatalError(format!(
|
EncodingError::FatalError(format!(
|
||||||
"Failed to sign permit2 approval with error: {}",
|
"Failed to sign permit2 approval with error: {e}"
|
||||||
e
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
Ok((permit_single, signature))
|
Ok((permit_single, signature))
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ impl ProtocolApprovalsManager {
|
|||||||
Ok(allowance.is_zero())
|
Ok(allowance.is_zero())
|
||||||
}
|
}
|
||||||
Err(err) => Err(EncodingError::RecoverableError(format!(
|
Err(err) => Err(EncodingError::RecoverableError(format!(
|
||||||
"Allowance call failed with error: {:?}",
|
"Allowance call failed with error: {err}"
|
||||||
err
|
|
||||||
))),
|
))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,8 +90,7 @@ impl StrategyEncoder for SingleSwapStrategyEncoder {
|
|||||||
let number_of_groups = grouped_swaps.len();
|
let number_of_groups = grouped_swaps.len();
|
||||||
if number_of_groups != 1 {
|
if number_of_groups != 1 {
|
||||||
return Err(EncodingError::InvalidInput(format!(
|
return Err(EncodingError::InvalidInput(format!(
|
||||||
"Executor strategy only supports exactly one swap for non-groupable protocols. Found {}",
|
"Executor strategy only supports exactly one swap for non-groupable protocols. Found {number_of_groups}",
|
||||||
number_of_groups
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +118,7 @@ impl StrategyEncoder for SingleSwapStrategyEncoder {
|
|||||||
.get_swap_encoder(&protocol)
|
.get_swap_encoder(&protocol)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
EncodingError::InvalidInput(format!(
|
EncodingError::InvalidInput(format!(
|
||||||
"Swap encoder not found for protocol: {}",
|
"Swap encoder not found for protocol: {protocol}"
|
||||||
protocol
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -303,8 +301,7 @@ impl StrategyEncoder for SequentialSwapStrategyEncoder {
|
|||||||
.get_swap_encoder(&protocol)
|
.get_swap_encoder(&protocol)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
EncodingError::InvalidInput(format!(
|
EncodingError::InvalidInput(format!(
|
||||||
"Swap encoder not found for protocol: {}",
|
"Swap encoder not found for protocol: {protocol}",
|
||||||
protocol
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -547,8 +544,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
|
|||||||
.get_swap_encoder(&protocol)
|
.get_swap_encoder(&protocol)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
EncodingError::InvalidInput(format!(
|
EncodingError::InvalidInput(format!(
|
||||||
"Swap encoder not found for protocol: {}",
|
"Swap encoder not found for protocol: {protocol}",
|
||||||
protocol
|
|
||||||
))
|
))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
@@ -780,7 +776,7 @@ mod tests {
|
|||||||
"0000000000000000000000000000", // padding
|
"0000000000000000000000000000", // padding
|
||||||
));
|
));
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_single_swap_strategy_encoder: {}", hex_calldata);
|
println!("test_single_swap_strategy_encoder: {hex_calldata}");
|
||||||
|
|
||||||
assert_eq!(hex_calldata[..456], expected_input);
|
assert_eq!(hex_calldata[..456], expected_input);
|
||||||
assert_eq!(hex_calldata[1224..], expected_swap);
|
assert_eq!(hex_calldata[1224..], expected_swap);
|
||||||
@@ -862,7 +858,7 @@ mod tests {
|
|||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
|
|
||||||
assert_eq!(hex_calldata, expected_input);
|
assert_eq!(hex_calldata, expected_input);
|
||||||
println!("test_single_swap_strategy_encoder_no_permit2: {}", hex_calldata);
|
println!("test_single_swap_strategy_encoder_no_permit2: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -941,7 +937,7 @@ mod tests {
|
|||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
|
|
||||||
assert_eq!(hex_calldata, expected_input);
|
assert_eq!(hex_calldata, expected_input);
|
||||||
println!("test_single_swap_strategy_encoder_no_transfer_in: {}", hex_calldata);
|
println!("test_single_swap_strategy_encoder_no_transfer_in: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -994,7 +990,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_single_swap_strategy_encoder_wrap: {}", hex_calldata);
|
println!("test_single_swap_strategy_encoder_wrap: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1047,7 +1043,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_split_swap_strategy_encoder_unwrap: {}", hex_calldata);
|
println!("test_split_swap_strategy_encoder_unwrap: {hex_calldata}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1117,8 +1113,8 @@ mod tests {
|
|||||||
.encode_strategy(solution)
|
.encode_strategy(solution)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_sequential_swap_strategy_encoder: {}", _hex_calldata);
|
println!("test_sequential_swap_strategy_encoder: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1178,7 +1174,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_sequential_swap_strategy_encoder_no_permit2: {}", hex_calldata);
|
println!("test_sequential_swap_strategy_encoder_no_permit2: {hex_calldata}");
|
||||||
|
|
||||||
let expected = String::from(concat!(
|
let expected = String::from(concat!(
|
||||||
"e8a980d7", /* function selector */
|
"e8a980d7", /* function selector */
|
||||||
@@ -1338,7 +1334,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(hex_calldata[..456], expected_input);
|
assert_eq!(hex_calldata[..456], expected_input);
|
||||||
assert_eq!(hex_calldata[1224..], expected_swaps);
|
assert_eq!(hex_calldata[1224..], expected_swaps);
|
||||||
println!("test_cyclic_sequential_swap_split_strategy: {}", hex_calldata);
|
println!("test_cyclic_sequential_swap_split_strategy: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
mod optimized_transfers {
|
mod optimized_transfers {
|
||||||
@@ -1415,8 +1411,8 @@ mod tests {
|
|||||||
.encode_strategy(solution)
|
.encode_strategy(solution)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_uniswap_v3_uniswap_v2: {}", _hex_calldata);
|
println!("test_uniswap_v3_uniswap_v2: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1497,8 +1493,8 @@ mod tests {
|
|||||||
.encode_strategy(solution)
|
.encode_strategy(solution)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_uniswap_v3_uniswap_v3: {}", _hex_calldata);
|
println!("test_uniswap_v3_uniswap_v3: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1583,8 +1579,8 @@ mod tests {
|
|||||||
.encode_strategy(solution)
|
.encode_strategy(solution)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_uniswap_v3_curve: {}", _hex_calldata);
|
println!("test_uniswap_v3_curve: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1650,8 +1646,8 @@ mod tests {
|
|||||||
.encode_strategy(solution)
|
.encode_strategy(solution)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_balancer_v2_uniswap_v2: {}", _hex_calldata);
|
println!("test_balancer_v2_uniswap_v2: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -1799,8 +1795,8 @@ mod tests {
|
|||||||
.encode_strategy(solution)
|
.encode_strategy(solution)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("multi_protocol: {}", _hex_calldata);
|
println!("multi_protocol: {hex_calldata}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1898,8 +1894,8 @@ mod tests {
|
|||||||
.encode_strategy(solution)
|
.encode_strategy(solution)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let _hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_split_swap_strategy_encoder: {}", _hex_calldata);
|
println!("test_split_swap_strategy_encoder: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2066,7 +2062,7 @@ mod tests {
|
|||||||
.join("");
|
.join("");
|
||||||
assert_eq!(hex_calldata[..520], expected_input);
|
assert_eq!(hex_calldata[..520], expected_input);
|
||||||
assert_eq!(hex_calldata[1288..], expected_swaps);
|
assert_eq!(hex_calldata[1288..], expected_swaps);
|
||||||
println!("test_split_input_cyclic_swap: {}", hex_calldata);
|
println!("test_split_input_cyclic_swap: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2231,7 +2227,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(hex_calldata[..520], expected_input);
|
assert_eq!(hex_calldata[..520], expected_input);
|
||||||
assert_eq!(hex_calldata[1288..], expected_swaps);
|
assert_eq!(hex_calldata[1288..], expected_swaps);
|
||||||
println!("test_split_output_cyclic_swap: {}", hex_calldata);
|
println!("test_split_output_cyclic_swap: {hex_calldata}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2301,7 +2297,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_single_encoding_strategy_ekubo: {}", hex_calldata);
|
println!("test_single_encoding_strategy_ekubo: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2366,7 +2362,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
|
|
||||||
println!("test_single_encoding_strategy_usv4_eth_in: {}", hex_calldata);
|
println!("test_single_encoding_strategy_usv4_eth_in: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2435,7 +2431,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_single_encoding_strategy_usv4_eth_out: {}", hex_calldata);
|
println!("test_single_encoding_strategy_usv4_eth_out: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2564,7 +2560,7 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(hex_calldata[..456], expected_input);
|
assert_eq!(hex_calldata[..456], expected_input);
|
||||||
assert_eq!(hex_calldata[1224..], expected_swaps);
|
assert_eq!(hex_calldata[1224..], expected_swaps);
|
||||||
println!("test_sequential_encoding_strategy_usv4: {}", hex_calldata);
|
println!("test_sequential_encoding_strategy_usv4: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2627,7 +2623,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_split_encoding_strategy_curve: {}", hex_calldata);
|
println!("test_split_encoding_strategy_curve: {hex_calldata}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -2690,7 +2686,7 @@ mod tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let hex_calldata = encode(&calldata);
|
let hex_calldata = encode(&calldata);
|
||||||
println!("test_single_encoding_strategy_curve_st_eth: {}", hex_calldata);
|
println!("test_single_encoding_strategy_curve_st_eth: {hex_calldata}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ impl SplitSwapValidator {
|
|||||||
if token_swaps.len() == 1 {
|
if token_swaps.len() == 1 {
|
||||||
if token_swaps[0].split != 0.0 {
|
if token_swaps[0].split != 0.0 {
|
||||||
return Err(EncodingError::InvalidInput(format!(
|
return Err(EncodingError::InvalidInput(format!(
|
||||||
"Single swap must have 0% split for token {:?}",
|
"Single swap must have 0% split for token {token}",
|
||||||
token
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@@ -163,16 +162,14 @@ impl SplitSwapValidator {
|
|||||||
match (swap.split == 0.0, i == token_swaps.len() - 1) {
|
match (swap.split == 0.0, i == token_swaps.len() - 1) {
|
||||||
(true, false) => {
|
(true, false) => {
|
||||||
return Err(EncodingError::InvalidInput(format!(
|
return Err(EncodingError::InvalidInput(format!(
|
||||||
"The 0% split for token {:?} must be the last swap",
|
"The 0% split for token {token} must be the last swap",
|
||||||
token
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
(true, true) => found_zero_split = true,
|
(true, true) => found_zero_split = true,
|
||||||
(false, _) => {
|
(false, _) => {
|
||||||
if swap.split < 0.0 {
|
if swap.split < 0.0 {
|
||||||
return Err(EncodingError::InvalidInput(format!(
|
return Err(EncodingError::InvalidInput(format!(
|
||||||
"All splits must be >= 0% for token {:?}",
|
"All splits must be >= 0% for token {token}"
|
||||||
token
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
total_percentage += swap.split;
|
total_percentage += swap.split;
|
||||||
@@ -182,8 +179,7 @@ impl SplitSwapValidator {
|
|||||||
|
|
||||||
if !found_zero_split {
|
if !found_zero_split {
|
||||||
return Err(EncodingError::InvalidInput(format!(
|
return Err(EncodingError::InvalidInput(format!(
|
||||||
"Token {:?} must have exactly one 0% split for remainder handling",
|
"Token {token} must have exactly one 0% split for remainder handling"
|
||||||
token
|
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ impl SwapEncoderRegistry {
|
|||||||
let config_str = if let Some(ref 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 {executors_file_path:?}: {e}",
|
||||||
executors_file_path, e
|
|
||||||
))
|
))
|
||||||
})?
|
})?
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -408,8 +408,7 @@ impl CurveSwapEncoder {
|
|||||||
// StableSwap factory
|
// StableSwap factory
|
||||||
"0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d" => Ok(U8::from(1)),
|
"0x4F8846Ae9380B90d2E71D5e3D042dff3E7ebb40d" => Ok(U8::from(1)),
|
||||||
_ => Err(EncodingError::FatalError(format!(
|
_ => Err(EncodingError::FatalError(format!(
|
||||||
"Unsupported curve factory address: {}",
|
"Unsupported curve factory address: {factory_address}"
|
||||||
factory_address
|
|
||||||
))),
|
))),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -466,8 +465,7 @@ impl CurveSwapEncoder {
|
|||||||
if token_in != native_token_curve_address && token_out != native_token_curve_address
|
if token_in != native_token_curve_address && token_out != native_token_curve_address
|
||||||
{
|
{
|
||||||
Err(EncodingError::RecoverableError(format!(
|
Err(EncodingError::RecoverableError(format!(
|
||||||
"Curve meta registry call failed with error: {:?}",
|
"Curve meta registry call failed with error: {err}"
|
||||||
err
|
|
||||||
)))
|
)))
|
||||||
} else {
|
} else {
|
||||||
let wrapped_token = bytes_to_address(&self.wrapped_native_token_address)?;
|
let wrapped_token = bytes_to_address(&self.wrapped_native_token_address)?;
|
||||||
@@ -832,7 +830,7 @@ mod tests {
|
|||||||
.encode_swap(swap, encoding_context)
|
.encode_swap(swap, encoding_context)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let hex_swap = encode(&encoded_swap);
|
let hex_swap = encode(&encoded_swap);
|
||||||
println!("test_encode_uniswap_v4_simple_swap: {}", hex_swap);
|
println!("test_encode_uniswap_v4_simple_swap: {hex_swap}");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
hex_swap,
|
hex_swap,
|
||||||
@@ -1003,7 +1001,7 @@ mod tests {
|
|||||||
let combined_hex =
|
let combined_hex =
|
||||||
format!("{}{}", encode(&initial_encoded_swap), encode(&second_encoded_swap));
|
format!("{}{}", encode(&initial_encoded_swap), encode(&second_encoded_swap));
|
||||||
|
|
||||||
println!("test_encode_uniswap_v4_sequential_swap: {}", combined_hex);
|
println!("test_encode_uniswap_v4_sequential_swap: {combined_hex}");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
combined_hex,
|
combined_hex,
|
||||||
String::from(concat!(
|
String::from(concat!(
|
||||||
@@ -1032,7 +1030,7 @@ mod tests {
|
|||||||
"00003c"
|
"00003c"
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
println!("{}", combined_hex)
|
println!("{combined_hex}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mod ekubo {
|
mod ekubo {
|
||||||
@@ -1161,7 +1159,7 @@ mod tests {
|
|||||||
let combined_hex =
|
let combined_hex =
|
||||||
format!("{}{}", encode(first_encoded_swap), encode(second_encoded_swap));
|
format!("{}{}", encode(first_encoded_swap), encode(second_encoded_swap));
|
||||||
|
|
||||||
println!("{}", combined_hex);
|
println!("{combined_hex}");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
combined_hex,
|
combined_hex,
|
||||||
// transfer type
|
// transfer type
|
||||||
|
|||||||
@@ -235,8 +235,7 @@ impl TychoExecutorEncoder {
|
|||||||
let number_of_groups = grouped_swaps.len();
|
let number_of_groups = grouped_swaps.len();
|
||||||
if number_of_groups > 1 {
|
if number_of_groups > 1 {
|
||||||
return Err(EncodingError::InvalidInput(format!(
|
return Err(EncodingError::InvalidInput(format!(
|
||||||
"Tycho executor encoder only supports one swap. Found {}",
|
"Tycho executor encoder only supports one swap. Found {number_of_groups}"
|
||||||
number_of_groups
|
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ pub fn bytes_to_address(address: &Bytes) -> Result<Address, EncodingError> {
|
|||||||
if address.len() == 20 {
|
if address.len() == 20 {
|
||||||
Ok(Address::from_slice(address))
|
Ok(Address::from_slice(address))
|
||||||
} else {
|
} else {
|
||||||
Err(EncodingError::InvalidInput(format!("Invalid address: {:?}", address)))
|
Err(EncodingError::InvalidInput(format!("Invalid address: {address}",)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,7 +95,7 @@ pub fn get_token_position(tokens: Vec<Bytes>, token: Bytes) -> Result<U8, Encodi
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|t| *t == token)
|
.position(|t| *t == token)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| {
|
||||||
EncodingError::InvalidInput(format!("Token {:?} not found in tokens array", token))
|
EncodingError::InvalidInput(format!("Token {token} not found in tokens array"))
|
||||||
})?,
|
})?,
|
||||||
);
|
);
|
||||||
Ok(position)
|
Ok(position)
|
||||||
@@ -121,9 +121,7 @@ pub fn get_static_attribute(swap: &Swap, attribute_name: &str) -> Result<Vec<u8>
|
|||||||
.component
|
.component
|
||||||
.static_attributes
|
.static_attributes
|
||||||
.get(attribute_name)
|
.get(attribute_name)
|
||||||
.ok_or_else(|| {
|
.ok_or_else(|| EncodingError::FatalError(format!("Attribute {attribute_name} not found")))?
|
||||||
EncodingError::FatalError(format!("Attribute {} not found", attribute_name))
|
|
||||||
})?
|
|
||||||
.to_vec())
|
.to_vec())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user