chore: fix clippy warnings and nightly fmt
This commit is contained in:
@@ -1,44 +1,46 @@
|
||||
use crate::encoding::approvals::interface::{Approval, UserApprovalsManager};
|
||||
use crate::encoding::models::{NativeAction, Solution, Transaction, PROPELLER_ROUTER_ADDRESS};
|
||||
use crate::encoding::strategy_selector::StrategySelector;
|
||||
use crate::encoding::utils::{encode_input, ple_encode};
|
||||
use alloy_sol_types::SolValue;
|
||||
use anyhow::Error;
|
||||
use num_bigint::BigUint;
|
||||
|
||||
use crate::encoding::{
|
||||
approvals::interface::{Approval, UserApprovalsManager},
|
||||
models::{NativeAction, Solution, Transaction, PROPELLER_ROUTER_ADDRESS},
|
||||
strategy_selector::StrategySelector,
|
||||
utils::{encode_input, ple_encode},
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct RouterEncoder<S: StrategySelector, A: UserApprovalsManager> {
|
||||
strategy_selector: S,
|
||||
approvals_manager: A,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl<S: StrategySelector, A: UserApprovalsManager> RouterEncoder<S, A> {
|
||||
pub fn new(strategy_selector: S, approvals_manager: A) -> Self {
|
||||
RouterEncoder {
|
||||
strategy_selector,
|
||||
approvals_manager,
|
||||
}
|
||||
RouterEncoder { strategy_selector, approvals_manager }
|
||||
}
|
||||
pub fn encode_router_calldata(&self, solutions: Vec<Solution>) -> Result<Transaction, Error> {
|
||||
let approvals_calldata = self.handle_approvals(&solutions)?; // TODO: where should we append this?
|
||||
let _approvals_calldata = self.handle_approvals(&solutions)?; // TODO: where should we append this?
|
||||
let mut calldata_list: Vec<Vec<u8>> = Vec::new();
|
||||
let encode_for_batch_execute = solutions.len() > 1;
|
||||
let mut value = BigUint::ZERO;
|
||||
for solution in solutions.iter() {
|
||||
let exact_out = solution.exact_out.clone();
|
||||
let straight_to_pool = solution.straight_to_pool.clone();
|
||||
let exact_out = solution.exact_out;
|
||||
let straight_to_pool = solution.straight_to_pool;
|
||||
|
||||
let strategy = self.strategy_selector.select_strategy(&solution);
|
||||
let strategy = self
|
||||
.strategy_selector
|
||||
.select_strategy(solution);
|
||||
let method_calldata = strategy.encode_strategy((*solution).clone())?;
|
||||
|
||||
let contract_interaction = if encode_for_batch_execute {
|
||||
let args = (strategy.action_type(exact_out) as u16, method_calldata);
|
||||
args.abi_encode()
|
||||
} else if straight_to_pool {
|
||||
method_calldata
|
||||
} else {
|
||||
if straight_to_pool {
|
||||
method_calldata
|
||||
} else {
|
||||
encode_input(strategy.selector(exact_out), method_calldata)
|
||||
}
|
||||
encode_input(strategy.selector(exact_out), method_calldata)
|
||||
};
|
||||
calldata_list.push(contract_interaction);
|
||||
|
||||
@@ -56,7 +58,7 @@ impl<S: StrategySelector, A: UserApprovalsManager> RouterEncoder<S, A> {
|
||||
Ok(Transaction { data, value })
|
||||
}
|
||||
|
||||
fn handle_approvals(&self, solutions: &Vec<Solution>) -> Result<Vec<u8>, Error> {
|
||||
fn handle_approvals(&self, solutions: &[Solution]) -> Result<Vec<u8>, Error> {
|
||||
let mut approvals = Vec::new();
|
||||
for solution in solutions.iter() {
|
||||
approvals.push(Approval {
|
||||
@@ -69,6 +71,8 @@ impl<S: StrategySelector, A: UserApprovalsManager> RouterEncoder<S, A> {
|
||||
owner: solution.sender.clone(),
|
||||
});
|
||||
}
|
||||
Ok(self.approvals_manager.encode_approvals(approvals))
|
||||
Ok(self
|
||||
.approvals_manager
|
||||
.encode_approvals(approvals))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user