@@ -102,9 +102,9 @@ async fn eth_flow_tx(web3: Web3) {
102102 . await ;
103103
104104 // Get a quote from the services
105- let buy_token = dai. address ( ) . into_legacy ( ) ;
106- let receiver = H160 ( [ 0x42 ; 20 ] ) ;
107- let sell_amount = to_wei ( 1 ) ;
105+ let buy_token = * dai. address ( ) ;
106+ let receiver = Address :: repeat_byte ( 0x42 ) ;
107+ let sell_amount = eth ( 1 ) ;
108108 let intent = EthFlowTradeIntent {
109109 sell_amount,
110110 buy_token,
@@ -157,7 +157,10 @@ async fn eth_flow_tx(web3: Web3) {
157157 app_data : OrderCreationAppData :: Hash {
158158 hash : app_data:: AppDataHash ( const_hex:: decode ( & hash[ 2 ..] ) . unwrap ( ) . try_into ( ) . unwrap ( ) ) ,
159159 } ,
160- ..intent. to_quote_request ( trader. account ( ) . address ( ) , & onchain. contracts ( ) . weth )
160+ ..intent. to_quote_request (
161+ trader. account ( ) . address ( ) . into_alloy ( ) ,
162+ & onchain. contracts ( ) . weth ,
163+ )
161164 } ;
162165
163166 let quote: OrderQuoteResponse = test_submit_quote ( & services, & quote_request) . await ;
@@ -182,7 +185,7 @@ async fn eth_flow_tx(web3: Web3) {
182185 test_order_availability_in_api (
183186 & services,
184187 & ethflow_order,
185- & trader. address ( ) ,
188+ & trader. address ( ) . into_alloy ( ) ,
186189 onchain. contracts ( ) ,
187190 ethflow_contract,
188191 )
@@ -299,7 +302,7 @@ async fn eth_flow_without_quote(web3: Web3) {
299302 test_order_availability_in_api (
300303 & services,
301304 & ethflow_order,
302- & trader. address ( ) ,
305+ & trader. address ( ) . into_alloy ( ) ,
303306 onchain. contracts ( ) ,
304307 ethflow_contract,
305308 )
@@ -330,11 +333,14 @@ async fn eth_flow_indexing_after_refund(web3: Web3) {
330333 & test_submit_quote (
331334 & services,
332335 & ( EthFlowTradeIntent {
333- sell_amount : 42 . into ( ) ,
334- buy_token : dai. address ( ) . into_legacy ( ) ,
335- receiver : H160 ( [ 42 ; 20 ] ) ,
336+ sell_amount : alloy :: primitives :: U256 :: from ( 42 ) ,
337+ buy_token : * dai. address ( ) ,
338+ receiver : Address :: repeat_byte ( 42 ) ,
336339 } )
337- . to_quote_request ( dummy_trader. account ( ) . address ( ) , & onchain. contracts ( ) . weth ) ,
340+ . to_quote_request (
341+ dummy_trader. account ( ) . address ( ) . into_alloy ( ) ,
342+ & onchain. contracts ( ) . weth ,
343+ ) ,
338344 )
339345 . await ,
340346 valid_to,
@@ -356,7 +362,7 @@ async fn eth_flow_indexing_after_refund(web3: Web3) {
356362
357363 // Create the actual order that should be picked up by the services and matched.
358364 let buy_token = dai. address ( ) . into_legacy ( ) ;
359- let receiver = H160 ( [ 0x42 ; 20 ] ) ;
365+ let receiver = Address :: repeat_byte ( 0x42 ) ;
360366 let sell_amount = to_wei ( 1 ) ;
361367 let valid_to = chrono:: offset:: Utc :: now ( ) . timestamp ( ) as u32
362368 + timestamp_of_current_block_in_seconds ( & web3. alloy )
@@ -367,11 +373,14 @@ async fn eth_flow_indexing_after_refund(web3: Web3) {
367373 & test_submit_quote (
368374 & services,
369375 & ( EthFlowTradeIntent {
370- sell_amount,
371- buy_token,
376+ sell_amount : sell_amount . into_alloy ( ) ,
377+ buy_token : buy_token . into_alloy ( ) ,
372378 receiver,
373379 } )
374- . to_quote_request ( trader. account ( ) . address ( ) , & onchain. contracts ( ) . weth ) ,
380+ . to_quote_request (
381+ trader. account ( ) . address ( ) . into_alloy ( ) ,
382+ & onchain. contracts ( ) . weth ,
383+ ) ,
375384 )
376385 . await ,
377386 valid_to,
@@ -451,7 +460,7 @@ async fn submit_order(
451460async fn test_order_availability_in_api (
452461 services : & Services < ' _ > ,
453462 order : & ExtendedEthFlowOrder ,
454- owner : & H160 ,
463+ owner : & Address ,
455464 contracts : & Contracts ,
456465 ethflow_contract : & CoWSwapEthFlow :: Instance ,
457466) {
@@ -460,16 +469,26 @@ async fn test_order_availability_in_api(
460469 let is_available = || async { services. get_order ( & uid) . await . is_ok ( ) } ;
461470 wait_for_condition ( TIMEOUT , is_available) . await . unwrap ( ) ;
462471
463- test_orders_query ( services, order, owner, contracts, ethflow_contract) . await ;
472+ test_orders_query (
473+ services,
474+ order,
475+ & owner. into_legacy ( ) ,
476+ contracts,
477+ ethflow_contract,
478+ )
479+ . await ;
464480
465481 // Api returns eth flow orders for both eth-flow contract address and actual
466482 // owner
467- for address in [ owner, & ethflow_contract. address ( ) . into_legacy ( ) ] {
483+ for address in [
484+ & owner. into_legacy ( ) ,
485+ & ethflow_contract. address ( ) . into_legacy ( ) ,
486+ ] {
468487 test_account_query (
469488 address,
470489 services. client ( ) ,
471490 order,
472- owner,
491+ & owner. into_legacy ( ) ,
473492 contracts,
474493 ethflow_contract,
475494 )
@@ -821,18 +840,18 @@ impl From<CoWSwapEthFlow::CoWSwapEthFlow::ordersReturn> for EthFlowOrderOnchainS
821840}
822841
823842pub struct EthFlowTradeIntent {
824- pub sell_amount : U256 ,
825- pub buy_token : H160 ,
826- pub receiver : H160 ,
843+ pub sell_amount : alloy :: primitives :: U256 ,
844+ pub buy_token : Address ,
845+ pub receiver : Address ,
827846}
828847
829848impl EthFlowTradeIntent {
830849 // How a user trade intent is converted into a quote request by the frontend
831- pub fn to_quote_request ( & self , from : H160 , weth : & WETH9 :: Instance ) -> OrderQuoteRequest {
850+ pub fn to_quote_request ( & self , from : Address , weth : & WETH9 :: Instance ) -> OrderQuoteRequest {
832851 OrderQuoteRequest {
833852 from,
834853 // Even if the user sells ETH, we request a quote for WETH
835- sell_token : weth. address ( ) . into_legacy ( ) ,
854+ sell_token : * weth. address ( ) ,
836855 buy_token : self . buy_token ,
837856 receiver : Some ( self . receiver ) ,
838857 validity : Validity :: For ( 3600 ) ,
@@ -843,7 +862,7 @@ impl EthFlowTradeIntent {
843862 } ,
844863 side : OrderQuoteSide :: Sell {
845864 sell_amount : model:: quote:: SellAmount :: AfterFee {
846- value : NonZeroU256 :: try_from ( self . sell_amount ) . unwrap ( ) ,
865+ value : NonZeroU256 :: try_from ( self . sell_amount . into_legacy ( ) ) . unwrap ( ) ,
847866 } ,
848867 } ,
849868 buy_token_balance : BuyTokenDestination :: Erc20 ,
@@ -898,7 +917,7 @@ async fn eth_flow_zero_buy_amount(web3: Web3) {
898917 test_order_availability_in_api (
899918 & services,
900919 & ethflow_order,
901- & trader. address ( ) ,
920+ & trader. address ( ) . into_alloy ( ) ,
902921 onchain. contracts ( ) ,
903922 ethflow_contract,
904923 )
0 commit comments