chore: Move ple_encode to EVMStrategyEncoder
--- don't change below this line --- ENG-4081 Took 3 minutes
This commit is contained in:
@@ -10,9 +10,7 @@ use crate::encoding::{
|
|||||||
evm::{
|
evm::{
|
||||||
approvals::permit2::Permit2,
|
approvals::permit2::Permit2,
|
||||||
swap_encoder::SWAP_ENCODER_REGISTRY,
|
swap_encoder::SWAP_ENCODER_REGISTRY,
|
||||||
utils::{
|
utils::{biguint_to_u256, bytes_to_address, encode_input, percentage_to_uint24},
|
||||||
biguint_to_u256, bytes_to_address, encode_input, percentage_to_uint24, ple_encode,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
models::{EncodingContext, NativeAction, Solution},
|
models::{EncodingContext, NativeAction, Solution},
|
||||||
strategy_encoder::StrategyEncoder,
|
strategy_encoder::StrategyEncoder,
|
||||||
@@ -42,6 +40,17 @@ pub trait EVMStrategyEncoder: StrategyEncoder {
|
|||||||
let hash = keccak256(selector.as_bytes());
|
let hash = keccak256(selector.as_bytes());
|
||||||
FixedBytes::<4>::from([hash[0], hash[1], hash[2], hash[3]])
|
FixedBytes::<4>::from([hash[0], hash[1], hash[2], hash[3]])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ple_encode(&self, action_data_array: Vec<Vec<u8>>) -> Vec<u8> {
|
||||||
|
let mut encoded_action_data: Vec<u8> = Vec::new();
|
||||||
|
|
||||||
|
for action_data in action_data_array {
|
||||||
|
let args = (encoded_action_data, action_data.len() as u16, action_data);
|
||||||
|
encoded_action_data = args.abi_encode_packed();
|
||||||
|
}
|
||||||
|
|
||||||
|
encoded_action_data
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct SplitSwapStrategyEncoder {
|
pub struct SplitSwapStrategyEncoder {
|
||||||
@@ -139,7 +148,7 @@ impl StrategyEncoder for SplitSwapStrategyEncoder {
|
|||||||
swaps.push(swap_data);
|
swaps.push(swap_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
let encoded_swaps = ple_encode(swaps);
|
let encoded_swaps = self.ple_encode(swaps);
|
||||||
let (mut unwrap, mut wrap) = (false, false);
|
let (mut unwrap, mut wrap) = (false, false);
|
||||||
if solution.native_action.is_some() {
|
if solution.native_action.is_some() {
|
||||||
match solution.native_action.unwrap() {
|
match solution.native_action.unwrap() {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use alloy_primitives::{aliases::U24, Address, Keccak256, U256};
|
use alloy_primitives::{aliases::U24, Address, Keccak256, U256};
|
||||||
use alloy_sol_types::SolValue;
|
|
||||||
use num_bigint::BigUint;
|
use num_bigint::BigUint;
|
||||||
use tycho_core::Bytes;
|
use tycho_core::Bytes;
|
||||||
|
|
||||||
@@ -23,18 +22,6 @@ pub fn biguint_to_u256(value: &BigUint) -> U256 {
|
|||||||
U256::from_be_slice(&bytes)
|
U256::from_be_slice(&bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub fn ple_encode(action_data_array: Vec<Vec<u8>>) -> Vec<u8> {
|
|
||||||
let mut encoded_action_data: Vec<u8> = Vec::new();
|
|
||||||
|
|
||||||
for action_data in action_data_array {
|
|
||||||
let args = (encoded_action_data, action_data.len() as u16, action_data);
|
|
||||||
encoded_action_data = args.abi_encode_packed();
|
|
||||||
}
|
|
||||||
|
|
||||||
encoded_action_data
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn encode_input(selector: &str, mut encoded_args: Vec<u8>) -> Vec<u8> {
|
pub fn encode_input(selector: &str, mut encoded_args: Vec<u8>) -> Vec<u8> {
|
||||||
let mut hasher = Keccak256::new();
|
let mut hasher = Keccak256::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user