From a4ba86369c5dfe2e172659b0b0ce01b343c6c9fd Mon Sep 17 00:00:00 2001 From: josojo Date: Mon, 7 Nov 2022 18:23:36 +0100 Subject: [PATCH 1/5] [Ethflow] using the newest contract --- Cargo.lock | 20 ++++++------ Cargo.toml | 6 ++-- crates/autopilot/src/arguments.rs | 2 +- .../src/database/onchain_order_events.rs | 31 ++++++++++++++++--- .../onchain_order_events/ethflow_events.rs | 5 ++- .../contracts/artifacts/CoWSwapEthFlow.json | 2 +- .../artifacts/CoWSwapOnchainOrders.json | 2 +- crates/contracts/build.rs | 11 +------ crates/contracts/src/bin/vendor.rs | 8 ++--- crates/refunder/src/arguments.rs | 6 ++++ crates/refunder/src/lib.rs | 4 +-- 11 files changed, 58 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dcbebe6f6e..2264ee2722 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -952,9 +952,9 @@ dependencies = [ [[package]] name = "ethcontract" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40baf7ecc443e95ea63e474eab55e7ac89f7037455965eea376cfb423d198ca1" +checksum = "8f9b2d716419d21413168ce2cbe74eec79e3a7c91e73446508013d0ec7d7c7b8" dependencies = [ "arrayvec", "ethcontract-common", @@ -976,9 +976,9 @@ dependencies = [ [[package]] name = "ethcontract-common" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8423588a5ed834d59412cfcf8f06a67da364053f8b1a08e1af4722a12f04b699" +checksum = "8312590754c75b14aa2e7f0f759f3dc68817398ab5bb1115552fea2751b623fc" dependencies = [ "ethabi", "hex", @@ -992,9 +992,9 @@ dependencies = [ [[package]] name = "ethcontract-derive" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97207b72151c208ab72d13e09733bf7a63df370d409a12cf9404f31ca3efa08e" +checksum = "942653d82ad2ade8fcf25dc065516653d1c965cf6c1982de5cc079fdd6dba93c" dependencies = [ "anyhow", "ethcontract-common", @@ -1006,9 +1006,9 @@ dependencies = [ [[package]] name = "ethcontract-generate" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95cfb062312527a4d5fe53c134a06a1c5fdb32abe83266bdce3a3c00edf35c47" +checksum = "fdaf86f28ebe51e92aaab1d477458f8bd991880bf557881b4daae69529c76e42" dependencies = [ "Inflector", "anyhow", @@ -1022,9 +1022,9 @@ dependencies = [ [[package]] name = "ethcontract-mock" -version = "0.22.0" +version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0568fc157193aba2f5855f464434d42c422e1cafb90154b0a2b72dfcccae682b" +checksum = "c248f7d5b465507f3d45df5fa91dd0fc743f2b9580cab2117b861e4242fee589" dependencies = [ "ethcontract", "hex", diff --git a/Cargo.toml b/Cargo.toml index 7575f1eeae..0d9ffff2aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,9 +10,9 @@ cached = { version = "0.39", default-features = false } chrono = { version = "0.4", default-features = false } clap = { version = "4", features = ["derive", "env"] } derivative = "2" -ethcontract = { version = "0.22", default-features = false } -ethcontract-generate = { version = "0.22", default-features = false } -ethcontract-mock = { version = "0.22", default-features = false } +ethcontract = { version = "0.23", default-features = false } +ethcontract-generate = { version = "0.23", default-features = false } +ethcontract-mock = { version = "0.23", default-features = false } futures = "0.3" gas-estimation = { git = "https://github.com/cowprotocol/gas-estimation", tag = "v0.7.1", features = ["web3_", "tokio_"] } hex = { version = "0.4", default-features = false } diff --git a/crates/autopilot/src/arguments.rs b/crates/autopilot/src/arguments.rs index 3743ac0ba3..7778d53f6b 100644 --- a/crates/autopilot/src/arguments.rs +++ b/crates/autopilot/src/arguments.rs @@ -23,7 +23,7 @@ pub struct Arguments { pub price_estimation: price_estimation::Arguments, /// Address of the ethflow contract - #[clap(long, env, default_value = "31172bb2b5f97e8e89cf3376495d7bc7252f5a53")] + #[clap(long, env, default_value = "26c3801b4840dab317cedfd7aeaf9f45fdd22830")] pub ethflow_contract: H160, // Feature flag for ethflow diff --git a/crates/autopilot/src/database/onchain_order_events.rs b/crates/autopilot/src/database/onchain_order_events.rs index 18f6448f5d..4860a70758 100644 --- a/crates/autopilot/src/database/onchain_order_events.rs +++ b/crates/autopilot/src/database/onchain_order_events.rs @@ -133,8 +133,15 @@ impl EventStoring events: Vec>, range: RangeInclusive, ) -> Result<()> { - let (custom_onchain_data, quotes, broadcasted_order_data, orders) = - self.extract_custom_and_general_order_data(events).await?; + let order_placement_events = events + .into_iter() + .filter(|EthContractEvent { data, .. }| { + matches!(data, ContractEvent::OrderPlacement(_)) + }) + .collect(); + let (custom_onchain_data, quotes, broadcasted_order_data, orders) = self + .extract_custom_and_general_order_data(order_placement_events) + .await?; let _timer = Metrics::get() .database_queries @@ -174,8 +181,15 @@ impl EventStoring } async fn append_events(&mut self, events: Vec>) -> Result<()> { - let (custom_order_data, quotes, broadcasted_order_data, orders) = - self.extract_custom_and_general_order_data(events).await?; + let order_placement_events = events + .into_iter() + .filter(|EthContractEvent { data, .. }| { + matches!(data, ContractEvent::OrderPlacement(_)) + }) + .collect(); + let (custom_order_data, quotes, broadcasted_order_data, orders) = self + .extract_custom_and_general_order_data(order_placement_events) + .await?; let _timer = Metrics::get() .database_queries @@ -299,7 +313,14 @@ async fn parse_general_onchain_order_placement_data( Some(meta) => meta, None => return Err(anyhow!("event without metadata")), }; - let ContractEvent::OrderPlacement(event) = data; + let event = match data { + ContractEvent::OrderPlacement(event) => event, + _ => { + return Err(anyhow!( + "parse_general_onchain_order_placement_data should not reach this state" + )) + } + }; let (order_data, owner, signing_scheme, order_uid) = extract_order_data_from_onchain_order_placement_event(&event, domain_separator)?; diff --git a/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs b/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs index 1105656a87..8055918558 100644 --- a/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs +++ b/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs @@ -48,7 +48,10 @@ impl OnchainOrderParsing for EthFlowOnchainOrderP Some(meta) => meta, None => return Some(Err(anyhow!("event without metadata"))), }; - let ContractEvent::OrderPlacement(event) = data; + let event = match data { + ContractEvent::OrderPlacement(event) => event, + _ => return None, + }; match convert_to_quote_id_and_user_valid_to(event) { Ok((quote_id, user_valid_to)) => Some(Ok(( meta_to_event_index(meta), diff --git a/crates/contracts/artifacts/CoWSwapEthFlow.json b/crates/contracts/artifacts/CoWSwapEthFlow.json index 2ca2fbbc4a..675dcd40f6 100644 --- a/crates/contracts/artifacts/CoWSwapEthFlow.json +++ b/crates/contracts/artifacts/CoWSwapEthFlow.json @@ -1 +1 @@ -{"abi":[{"inputs":[{"internalType":"contract ICoWSwapSettlement","name":"_cowSwapSettlement","type":"address"},{"internalType":"contract IERC20","name":"_wrappedNativeToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EthTransferFailed","type":"error"},{"inputs":[],"name":"IncorrectEthAmount","type":"error"},{"inputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"NotAllowedToDeleteOrder","type":"error"},{"inputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"OrderIsAlreadyOwned","type":"error"},{"inputs":[],"name":"ReceiverMustBeSet","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"contract IERC20","name":"sellToken","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes32","name":"kind","type":"bytes32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"bytes32","name":"sellTokenBalance","type":"bytes32"},{"internalType":"bytes32","name":"buyTokenBalance","type":"bytes32"}],"indexed":false,"internalType":"struct GPv2Order.Data","name":"order","type":"tuple"},{"components":[{"internalType":"enum ICoWSwapOnchainOrders.OnchainSigningScheme","name":"scheme","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct ICoWSwapOnchainOrders.OnchainSignature","name":"signature","type":"tuple"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"OrderPlacement","type":"event"},{"inputs":[],"name":"cowSwapSettlement","outputs":[{"internalType":"contract ICoWSwapSettlement","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"int64","name":"quoteId","type":"int64"}],"internalType":"struct EthFlowOrder.Data","name":"order","type":"tuple"}],"name":"createOrder","outputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"int64","name":"quoteId","type":"int64"}],"internalType":"struct EthFlowOrder.Data","name":"order","type":"tuple"}],"name":"deleteOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"orders","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint32","name":"validTo","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"}]} \ No newline at end of file +{"abi":[{"inputs":[{"internalType":"contract ICoWSwapSettlement","name":"_cowSwapSettlement","type":"address"},{"internalType":"contract IWrappedNativeToken","name":"_wrappedNativeToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"EthTransferFailed","type":"error"},{"inputs":[],"name":"IncorrectEthAmount","type":"error"},{"inputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"NotAllowedToInvalidateOrder","type":"error"},{"inputs":[],"name":"NotAllowedZeroSellAmount","type":"error"},{"inputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"name":"OrderIsAlreadyOwned","type":"error"},{"inputs":[],"name":"ReceiverMustBeSet","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes","name":"orderUid","type":"bytes"}],"name":"OrderInvalidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"contract IERC20","name":"sellToken","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes32","name":"kind","type":"bytes32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"bytes32","name":"sellTokenBalance","type":"bytes32"},{"internalType":"bytes32","name":"buyTokenBalance","type":"bytes32"}],"indexed":false,"internalType":"struct GPv2Order.Data","name":"order","type":"tuple"},{"components":[{"internalType":"enum ICoWSwapOnchainOrders.OnchainSigningScheme","name":"scheme","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct ICoWSwapOnchainOrders.OnchainSignature","name":"signature","type":"tuple"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"OrderPlacement","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes","name":"orderUid","type":"bytes"},{"indexed":true,"internalType":"address","name":"refunder","type":"address"}],"name":"OrderRefund","type":"event"},{"inputs":[],"name":"cowSwapSettlement","outputs":[{"internalType":"contract ICoWSwapSettlement","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"int64","name":"quoteId","type":"int64"}],"internalType":"struct EthFlowOrder.Data","name":"order","type":"tuple"}],"name":"createOrder","outputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"int64","name":"quoteId","type":"int64"}],"internalType":"struct EthFlowOrder.Data","name":"order","type":"tuple"}],"name":"invalidateOrder","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"int64","name":"quoteId","type":"int64"}],"internalType":"struct EthFlowOrder.Data[]","name":"orderArray","type":"tuple[]"}],"name":"invalidateOrdersIgnoringNotAllowed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"orderHash","type":"bytes32"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"isValidSignature","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"orders","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint32","name":"validTo","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"unwrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"wrap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrapAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"contract IWrappedNativeToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]} \ No newline at end of file diff --git a/crates/contracts/artifacts/CoWSwapOnchainOrders.json b/crates/contracts/artifacts/CoWSwapOnchainOrders.json index 5db99a99ad..e834de9d2c 100644 --- a/crates/contracts/artifacts/CoWSwapOnchainOrders.json +++ b/crates/contracts/artifacts/CoWSwapOnchainOrders.json @@ -1 +1 @@ -{"abi":[{"inputs":[{"internalType":"address","name":"settlementContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"contract IERC20","name":"sellToken","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes32","name":"kind","type":"bytes32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"bytes32","name":"sellTokenBalance","type":"bytes32"},{"internalType":"bytes32","name":"buyTokenBalance","type":"bytes32"}],"indexed":false,"internalType":"struct GPv2Order.Data","name":"order","type":"tuple"},{"components":[{"internalType":"enum ICoWSwapOnchainOrders.OnchainSigningScheme","name":"scheme","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct ICoWSwapOnchainOrders.OnchainSignature","name":"signature","type":"tuple"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"OrderPlacement","type":"event"}]} \ No newline at end of file +{"abi":[{"inputs":[{"internalType":"address","name":"settlementContractAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes","name":"orderUid","type":"bytes"}],"name":"OrderInvalidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"components":[{"internalType":"contract IERC20","name":"sellToken","type":"address"},{"internalType":"contract IERC20","name":"buyToken","type":"address"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint256","name":"sellAmount","type":"uint256"},{"internalType":"uint256","name":"buyAmount","type":"uint256"},{"internalType":"uint32","name":"validTo","type":"uint32"},{"internalType":"bytes32","name":"appData","type":"bytes32"},{"internalType":"uint256","name":"feeAmount","type":"uint256"},{"internalType":"bytes32","name":"kind","type":"bytes32"},{"internalType":"bool","name":"partiallyFillable","type":"bool"},{"internalType":"bytes32","name":"sellTokenBalance","type":"bytes32"},{"internalType":"bytes32","name":"buyTokenBalance","type":"bytes32"}],"indexed":false,"internalType":"struct GPv2Order.Data","name":"order","type":"tuple"},{"components":[{"internalType":"enum ICoWSwapOnchainOrders.OnchainSigningScheme","name":"scheme","type":"uint8"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct ICoWSwapOnchainOrders.OnchainSignature","name":"signature","type":"tuple"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"OrderPlacement","type":"event"}]} \ No newline at end of file diff --git a/crates/contracts/build.rs b/crates/contracts/build.rs index ac26188067..5c7a5f7b89 100644 --- a/crates/contracts/build.rs +++ b/crates/contracts/build.rs @@ -19,16 +19,7 @@ fn main() { println!("cargo:rerun-if-changed=build.rs"); generate_contract_with_config("CoWSwapEthFlow", |builder| { - builder - .contract_mod_override("cowswap_eth_flow") - .add_network( - "5", - Network { - address: addr("0x31172bb2b5f97e8e89cf3376495d7bc7252f5a53"), - // - deployment_information: Some(DeploymentInformation::BlockNumber(7621348)), - }, - ) + builder.contract_mod_override("cowswap_eth_flow") }); generate_contract_with_config("CoWSwapOnchainOrders", |builder| { builder.contract_mod_override("cowswap_onchain_orders") diff --git a/crates/contracts/src/bin/vendor.rs b/crates/contracts/src/bin/vendor.rs index 2e10137240..f65f60fed5 100644 --- a/crates/contracts/src/bin/vendor.rs +++ b/crates/contracts/src/bin/vendor.rs @@ -124,13 +124,13 @@ fn run() -> Result<()> { )? .github( "CoWSwapOnchainOrders", - "cowprotocol/ethflowcontract/v0.0.0/\ - rc-artifacts/artifacts/CoWSwapOnchainOrders.sol/CoWSwapOnchainOrders.json" + "cowprotocol/ethflowcontract/v0.0.0-rc.1\ + -artifacts/artifacts/CoWSwapOnchainOrders.sol/CoWSwapOnchainOrders.json" )? .github( "CoWSwapEthFlow", - "cowprotocol/ethflowcontract/v0.0.0/\ - rc-artifacts/artifacts/CoWSwapEthFlow.sol/CoWSwapEthFlow.json" + "cowprotocol/ethflowcontract/v0.0.0-rc.1\ + -artifacts/artifacts/CoWSwapEthFlow.sol/CoWSwapEthFlow.json" )? .npm( "ERC20", diff --git a/crates/refunder/src/arguments.rs b/crates/refunder/src/arguments.rs index 38cd5cd385..2a3bf0fc4f 100644 --- a/crates/refunder/src/arguments.rs +++ b/crates/refunder/src/arguments.rs @@ -1,5 +1,6 @@ use clap::Parser; use shared::{ethrpc, http_client}; +use ethcontract::H160; use std::time::Duration; use url::Url; @@ -35,6 +36,10 @@ pub struct Arguments { /// The Ethereum node URL to connect to. #[clap(long, env, default_value = "http://localhost:8545")] pub node_url: Url, + + /// Address of the ethflow contract + #[clap(long, env, default_value = "26c3801b4840dab317cedfd7aeaf9f45fdd22830")] + pub ethflow_contract: H160, } impl std::fmt::Display for Arguments { @@ -45,6 +50,7 @@ impl std::fmt::Display for Arguments { writeln!(f, "min_slippage_bps: {}", self.min_slippage_bps)?; writeln!(f, "db_url: SECRET")?; writeln!(f, "node_url: {}", self.node_url)?; + writeln!(f, "ethflow_contract: {}", self.ethflow_contract)?; Ok(()) } } diff --git a/crates/refunder/src/lib.rs b/crates/refunder/src/lib.rs index 7eddbdc07d..84b2ca57aa 100644 --- a/crates/refunder/src/lib.rs +++ b/crates/refunder/src/lib.rs @@ -13,9 +13,7 @@ pub async fn main(args: arguments::Arguments) { let pg_pool = PgPool::connect_lazy(args.db_url.as_str()).expect("failed to create database"); let http_factory = HttpClientFactory::new(&args.http_client); let web3 = shared::ethrpc::web3(&args.ethrpc, &http_factory, &args.node_url, "base"); - let ethflow_contract = CoWSwapEthFlow::deployed(&web3) - .await - .expect("Could not find the CoWSwapEthFlow contract"); + let ethflow_contract = CoWSwapEthFlow::at(&web3, args.ethflow_contract); let refunder = RefundService::new( pg_pool, web3, From c23abe0f3c02f0afa8431d2a662c1c9c9e659bef Mon Sep 17 00:00:00 2001 From: josojo Date: Mon, 7 Nov 2022 18:44:25 +0100 Subject: [PATCH 2/5] fix clippy --- crates/refunder/src/arguments.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/refunder/src/arguments.rs b/crates/refunder/src/arguments.rs index 2a3bf0fc4f..3faa20febd 100644 --- a/crates/refunder/src/arguments.rs +++ b/crates/refunder/src/arguments.rs @@ -1,6 +1,6 @@ use clap::Parser; -use shared::{ethrpc, http_client}; use ethcontract::H160; +use shared::{ethrpc, http_client}; use std::time::Duration; use url::Url; From 52e8469febaece4326c470d354b16f00ad9ed9a6 Mon Sep 17 00:00:00 2001 From: josojo Date: Mon, 7 Nov 2022 20:08:46 +0100 Subject: [PATCH 3/5] nick's suggestion about address --- crates/autopilot/src/arguments.rs | 2 +- crates/refunder/src/arguments.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/autopilot/src/arguments.rs b/crates/autopilot/src/arguments.rs index 7778d53f6b..6f10aaa280 100644 --- a/crates/autopilot/src/arguments.rs +++ b/crates/autopilot/src/arguments.rs @@ -23,7 +23,7 @@ pub struct Arguments { pub price_estimation: price_estimation::Arguments, /// Address of the ethflow contract - #[clap(long, env, default_value = "26c3801b4840dab317cedfd7aeaf9f45fdd22830")] + #[clap(long, env, default_value = "0x26c3801b4840dab317cedfd7aeaf9f45fdd22830")] pub ethflow_contract: H160, // Feature flag for ethflow diff --git a/crates/refunder/src/arguments.rs b/crates/refunder/src/arguments.rs index 3faa20febd..eb168588bb 100644 --- a/crates/refunder/src/arguments.rs +++ b/crates/refunder/src/arguments.rs @@ -38,7 +38,7 @@ pub struct Arguments { pub node_url: Url, /// Address of the ethflow contract - #[clap(long, env, default_value = "26c3801b4840dab317cedfd7aeaf9f45fdd22830")] + #[clap(long, env, default_value = "0x26c3801b4840dab317cedfd7aeaf9f45fdd22830")] pub ethflow_contract: H160, } From 713bdb0b2ce7c922465be8243b4d0e487b75ddf5 Mon Sep 17 00:00:00 2001 From: josojo Date: Mon, 7 Nov 2022 20:10:32 +0100 Subject: [PATCH 4/5] clippy fix --- crates/autopilot/src/arguments.rs | 6 +++++- crates/refunder/src/arguments.rs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/autopilot/src/arguments.rs b/crates/autopilot/src/arguments.rs index 6f10aaa280..3d3218aa47 100644 --- a/crates/autopilot/src/arguments.rs +++ b/crates/autopilot/src/arguments.rs @@ -23,7 +23,11 @@ pub struct Arguments { pub price_estimation: price_estimation::Arguments, /// Address of the ethflow contract - #[clap(long, env, default_value = "0x26c3801b4840dab317cedfd7aeaf9f45fdd22830")] + #[clap( + long, + env, + default_value = "0x26c3801b4840dab317cedfd7aeaf9f45fdd22830" + )] pub ethflow_contract: H160, // Feature flag for ethflow diff --git a/crates/refunder/src/arguments.rs b/crates/refunder/src/arguments.rs index eb168588bb..7b3ad381b3 100644 --- a/crates/refunder/src/arguments.rs +++ b/crates/refunder/src/arguments.rs @@ -38,7 +38,11 @@ pub struct Arguments { pub node_url: Url, /// Address of the ethflow contract - #[clap(long, env, default_value = "0x26c3801b4840dab317cedfd7aeaf9f45fdd22830")] + #[clap( + long, + env, + default_value = "0x26c3801b4840dab317cedfd7aeaf9f45fdd22830" + )] pub ethflow_contract: H160, } From a6bfcd7fc509bb53cfe319b2ec8dc696395626ce Mon Sep 17 00:00:00 2001 From: josojo Date: Tue, 8 Nov 2022 11:17:36 +0100 Subject: [PATCH 5/5] Martin's suggestion --- crates/autopilot/src/arguments.rs | 2 +- crates/refunder/src/arguments.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/autopilot/src/arguments.rs b/crates/autopilot/src/arguments.rs index 3d3218aa47..5f9ff2dd28 100644 --- a/crates/autopilot/src/arguments.rs +++ b/crates/autopilot/src/arguments.rs @@ -140,7 +140,7 @@ impl std::fmt::Display for Arguments { write!(f, "{}", self.token_owner_finder)?; write!(f, "{}", self.price_estimation)?; display_option(f, "tracing_node_url", &self.tracing_node_url)?; - writeln!(f, "ethflow contract: {}", self.ethflow_contract)?; + writeln!(f, "ethflow contract: {:?}", self.ethflow_contract)?; writeln!(f, "enable_ethflow_orders: {}", self.enable_ethflow_orders)?; writeln!(f, "metrics_address: {}", self.metrics_address)?; writeln!(f, "db_url: SECRET")?; diff --git a/crates/refunder/src/arguments.rs b/crates/refunder/src/arguments.rs index 7b3ad381b3..9a68180051 100644 --- a/crates/refunder/src/arguments.rs +++ b/crates/refunder/src/arguments.rs @@ -54,7 +54,7 @@ impl std::fmt::Display for Arguments { writeln!(f, "min_slippage_bps: {}", self.min_slippage_bps)?; writeln!(f, "db_url: SECRET")?; writeln!(f, "node_url: {}", self.node_url)?; - writeln!(f, "ethflow_contract: {}", self.ethflow_contract)?; + writeln!(f, "ethflow_contract: {:?}", self.ethflow_contract)?; Ok(()) } }