chore: Do not use expect

--- don't change below this line ---
ENG-4063 Took 57 minutes


Took 17 seconds

Took 45 seconds
This commit is contained in:
Diana Carvalho
2025-01-21 10:07:16 +00:00
parent 7890f26812
commit 979cdf7437
6 changed files with 40 additions and 34 deletions

View File

@@ -1,9 +1,12 @@
use std::str::FromStr;
use num_bigint::BigUint;
use tycho_core::Bytes;
use crate::encoding::{
errors::EncodingError,
evm::utils::encode_input,
models::{NativeAction, Solution, Transaction, PROPELLER_ROUTER_ADDRESS},
models::{NativeAction, Solution, Transaction},
router_encoder::RouterEncoder,
strategy_encoder::StrategySelector,
user_approvals_manager::{Approval, UserApprovalsManager},
@@ -13,12 +16,13 @@ use crate::encoding::{
pub struct EVMRouterEncoder<S: StrategySelector, A: UserApprovalsManager> {
strategy_selector: S,
approvals_manager: A,
router_address: String,
}
#[allow(dead_code)]
impl<S: StrategySelector, A: UserApprovalsManager> EVMRouterEncoder<S, A> {
pub fn new(strategy_selector: S, approvals_manager: A) -> Self {
EVMRouterEncoder { strategy_selector, approvals_manager }
pub fn new(strategy_selector: S, approvals_manager: A, router_address: String) -> Self {
EVMRouterEncoder { strategy_selector, approvals_manager, router_address }
}
}
impl<S: StrategySelector, A: UserApprovalsManager> RouterEncoder<S, A> for EVMRouterEncoder<S, A> {
@@ -61,7 +65,9 @@ impl<S: StrategySelector, A: UserApprovalsManager> RouterEncoder<S, A> for EVMRo
spender: solution
.router_address
.clone()
.unwrap_or(PROPELLER_ROUTER_ADDRESS.clone()),
.unwrap_or(Bytes::from_str(&self.router_address).map_err(|_| {
EncodingError::FatalError("Invalid router address".to_string())
})?),
amount: solution.given_amount.clone(),
owner: solution.sender.clone(),
});