Skip to content

Commit 7637136

Browse files
authored
Remove old EncodedEthflowOrder (#3863)
# Description Removes EncodedEthflowOrder, the structure and encode function was basically replaced by alloy's generated types # Changes <!-- List of detailed changes (how the change is accomplished) --> - [ ] Removes EncodedEthflowOrder and it's related friends ## How to test Compile and test <!-- ## Related Issues Fixes # -->
1 parent 98cfa66 commit 7637136

File tree

1 file changed

+1
-74
lines changed

1 file changed

+1
-74
lines changed

crates/refunder/src/ethflow_order.rs

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use {
55
ethrpc::alloy::conversions::IntoAlloy,
66
number::conversions::big_decimal_to_u256,
77
};
8+
89
// Data structure reflecting the contract ethflow order
910
// https://github.com/cowprotocol/ethflowcontract/blob/main/src/libraries/EthFlowOrder.sol#L19
1011
#[derive(Clone)]
@@ -20,22 +21,6 @@ pub struct EthflowOrder {
2021
pub quote_id: i64,
2122
}
2223

23-
impl EthflowOrder {
24-
pub fn encode(&self) -> EncodedEthflowOrder {
25-
(
26-
self.buy_token,
27-
self.receiver,
28-
self.sell_amount,
29-
self.buy_amount,
30-
self.app_data,
31-
self.fee_amount,
32-
self.valid_to,
33-
self.partially_fillable,
34-
self.quote_id,
35-
)
36-
}
37-
}
38-
3924
impl From<EthflowOrder> for CoWSwapEthFlow::EthFlowOrder::Data {
4025
fn from(value: EthflowOrder) -> Self {
4126
CoWSwapEthFlow::EthFlowOrder::Data {
@@ -52,18 +37,6 @@ impl From<EthflowOrder> for CoWSwapEthFlow::EthFlowOrder::Data {
5237
}
5338
}
5439

55-
pub type EncodedEthflowOrder = (
56-
H160, // buyToken
57-
H160, // receiver
58-
U256, // sellAmount
59-
U256, // buyAmount
60-
Bytes<[u8; 32]>, // appData
61-
U256, // feeAmount
62-
u32, // validTo
63-
bool, // flags
64-
i64, // quoteId
65-
);
66-
6740
pub fn order_to_ethflow_data(order: Order, ethflow_order_placement: EthOrderData) -> EthflowOrder {
6841
EthflowOrder {
6942
buy_token: H160(order.buy_token.0),
@@ -78,49 +51,3 @@ pub fn order_to_ethflow_data(order: Order, ethflow_order_placement: EthOrderData
7851
quote_id: 0i64, // quoteId is not important for refunding and will be ignored
7952
}
8053
}
81-
82-
#[cfg(test)]
83-
mod tests {
84-
use {super::*, database::byte_array::ByteArray, number::conversions::u256_to_big_decimal};
85-
86-
#[test]
87-
fn test_order_to_ethflow_data() {
88-
let buy_token = ByteArray([1u8; 20]);
89-
let receiver = ByteArray([3u8; 20]);
90-
let sell_amount = U256::from_dec_str("1").unwrap();
91-
let buy_amount = U256::from_dec_str("2").unwrap();
92-
let app_data = ByteArray([3u8; 32]);
93-
let fee_amount = U256::from_dec_str("3").unwrap();
94-
let valid_to = 234u32;
95-
96-
let order = Order {
97-
buy_token,
98-
receiver: Some(receiver),
99-
sell_amount: u256_to_big_decimal(&sell_amount),
100-
buy_amount: u256_to_big_decimal(&buy_amount),
101-
valid_to: valid_to.into(),
102-
app_data,
103-
fee_amount: u256_to_big_decimal(&fee_amount),
104-
..Default::default()
105-
};
106-
let ethflow_order = EthOrderData {
107-
valid_to: valid_to.into(),
108-
..Default::default()
109-
};
110-
let expected_encoded_order = (
111-
H160(order.buy_token.0),
112-
H160(order.receiver.unwrap().0),
113-
big_decimal_to_u256(&order.sell_amount).unwrap(),
114-
big_decimal_to_u256(&order.buy_amount).unwrap(),
115-
Bytes(order.app_data.0),
116-
big_decimal_to_u256(&order.fee_amount).unwrap(),
117-
ethflow_order.valid_to as u32,
118-
order.partially_fillable,
119-
0i64,
120-
);
121-
assert_eq!(
122-
order_to_ethflow_data(order, ethflow_order).encode(),
123-
expected_encoded_order
124-
);
125-
}
126-
}

0 commit comments

Comments
 (0)