Skip to content

Commit

Permalink
Update ethcontract-rs version (#2644)
Browse files Browse the repository at this point in the history
# Description
Bump `ethcontract-rs` version to make use of this performance
improvement: cowprotocol/ethcontract-rs#970

## How to test
CI
existing tests
  • Loading branch information
MartinquaXD authored Apr 22, 2024
1 parent 03748ae commit 98e13ae
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 28 deletions.
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ cached = { version = "0.44", default-features = false }
chrono = { version = "0.4", default-features = false }
clap = { version = "4", features = ["derive", "env"] }
derivative = "2"
ethcontract = { version = "0.25.4", default-features = false, features = ["aws-kms"] }
ethcontract-generate = { version = "0.25", default-features = false }
ethcontract-mock = { version = "0.25", default-features = false }
ethcontract = { version = "0.25.6", default-features = false, features = ["aws-kms"] }
ethcontract-generate = { version = "0.25.6", default-features = false }
ethcontract-mock = { version = "0.25.6", default-features = false }
ethereum-types = "0.14"
futures = "0.3"
gas-estimation = { git = "https://github.com/cowprotocol/gas-estimation", tag = "v0.7.3", features = ["web3_", "tokio_"] }
Expand Down
1 change: 1 addition & 0 deletions crates/autopilot/src/decoded_settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ impl DecodedSettlement {

pub fn new(input: &[u8]) -> Result<Self, DecodingError> {
let function = GPv2Settlement::raw_contract()
.interface
.abi
.function("settle")
.unwrap();
Expand Down
1 change: 1 addition & 0 deletions crates/autopilot/src/domain/settlement/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl Settlement {
domain_separator: &eth::DomainSeparator,
) -> Result<Self, Error> {
let function = contracts::GPv2Settlement::raw_contract()
.interface
.abi
.function("settle")
.unwrap();
Expand Down
6 changes: 5 additions & 1 deletion crates/contracts/src/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ use {
};

fn role_id(target: H160, function_name: &str) -> Bytes<[u8; 32]> {
let function = match BalancerV2Vault::raw_contract().abi.function(function_name) {
let function = match BalancerV2Vault::raw_contract()
.interface
.abi
.function(function_name)
{
Ok(function) => function,
Err(_) => return Bytes([0u8; 32]),
};
Expand Down
6 changes: 5 additions & 1 deletion crates/shared/src/price_estimation/trade_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,11 @@ struct SettleOutput {

impl SettleOutput {
fn decode(output: &[u8], kind: OrderKind) -> Result<Self> {
let function = Solver::raw_contract().abi.function("swap").unwrap();
let function = Solver::raw_contract()
.interface
.abi
.function("swap")
.unwrap();
let tokens = function.decode_output(output).context("decode")?;
let (gas_used, balances): (U256, Vec<U256>) = Tokenize::from_token(Token::Tuple(tokens))?;

Expand Down
24 changes: 12 additions & 12 deletions crates/shared/src/sources/balancer_v2/pools/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,11 @@ mod tests {
let mock = Mock::new(42);
let web3 = mock.web3();

let pool = mock.deploy(BalancerV2BasePool::raw_contract().abi.clone());
let pool = mock.deploy(BalancerV2BasePool::raw_contract().interface.abi.clone());
pool.expect_call(BalancerV2BasePool::signatures().get_pool_id())
.returns(Bytes(pool_id.0));

let vault = mock.deploy(BalancerV2Vault::raw_contract().abi.clone());
let vault = mock.deploy(BalancerV2Vault::raw_contract().interface.abi.clone());
vault
.expect_call(BalancerV2Vault::signatures().get_pool_tokens())
.predicate((predicate::eq(Bytes(pool_id.0)),))
Expand Down Expand Up @@ -414,13 +414,13 @@ mod tests {
let mock = Mock::new(42);
let web3 = mock.web3();

let pool = mock.deploy(BalancerV2BasePool::raw_contract().abi.clone());
let pool = mock.deploy(BalancerV2BasePool::raw_contract().interface.abi.clone());
pool.expect_call(BalancerV2BasePool::signatures().get_paused_state())
.returns((false, 0.into(), 0.into()));
pool.expect_call(BalancerV2BasePool::signatures().get_swap_fee_percentage())
.returns(bfp!("0.003").as_uint256());

let vault = mock.deploy(BalancerV2Vault::raw_contract().abi.clone());
let vault = mock.deploy(BalancerV2Vault::raw_contract().interface.abi.clone());
vault
.expect_call(BalancerV2Vault::signatures().get_pool_tokens())
.predicate((predicate::eq(Bytes(pool_id.0)),))
Expand Down Expand Up @@ -483,13 +483,13 @@ mod tests {
let mock = Mock::new(42);
let web3 = mock.web3();

let pool = mock.deploy(BalancerV2BasePool::raw_contract().abi.clone());
let pool = mock.deploy(BalancerV2BasePool::raw_contract().interface.abi.clone());
pool.expect_call(BalancerV2BasePool::signatures().get_paused_state())
.returns((false, 0.into(), 0.into()));
pool.expect_call(BalancerV2BasePool::signatures().get_swap_fee_percentage())
.returns(0.into());

let vault = mock.deploy(BalancerV2Vault::raw_contract().abi.clone());
let vault = mock.deploy(BalancerV2Vault::raw_contract().interface.abi.clone());
vault
.expect_call(BalancerV2Vault::signatures().get_pool_tokens())
.predicate((predicate::eq(Bytes(Default::default())),))
Expand Down Expand Up @@ -532,7 +532,7 @@ mod tests {
let mock = Mock::new(42);
let web3 = mock.web3();

let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().abi.clone());
let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().interface.abi.clone());
pool.expect_call(BalancerV2WeightedPool::signatures().get_paused_state())
.returns((false, 0.into(), 0.into()));
pool.expect_call(BalancerV2WeightedPool::signatures().get_swap_fee_percentage())
Expand Down Expand Up @@ -576,7 +576,7 @@ mod tests {
version: Default::default(),
};

let vault = mock.deploy(BalancerV2Vault::raw_contract().abi.clone());
let vault = mock.deploy(BalancerV2Vault::raw_contract().interface.abi.clone());
vault
.expect_call(BalancerV2Vault::signatures().get_pool_tokens())
.predicate((predicate::eq(Bytes(pool_info.common.id.0)),))
Expand Down Expand Up @@ -630,13 +630,13 @@ mod tests {
let mock = Mock::new(42);
let web3 = mock.web3();

let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().abi.clone());
let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().interface.abi.clone());
pool.expect_call(BalancerV2WeightedPool::signatures().get_paused_state())
.returns((true, 0.into(), 0.into()));
pool.expect_call(BalancerV2WeightedPool::signatures().get_swap_fee_percentage())
.returns(Default::default());

let vault = mock.deploy(BalancerV2Vault::raw_contract().abi.clone());
let vault = mock.deploy(BalancerV2Vault::raw_contract().interface.abi.clone());
vault
.expect_call(BalancerV2Vault::signatures().get_pool_tokens())
.returns(Default::default());
Expand Down Expand Up @@ -690,13 +690,13 @@ mod tests {
let mock = Mock::new(42);
let web3 = mock.web3();

let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().abi.clone());
let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().interface.abi.clone());
pool.expect_call(BalancerV2WeightedPool::signatures().get_paused_state())
.returns((false, 0.into(), 0.into()));
pool.expect_call(BalancerV2WeightedPool::signatures().get_swap_fee_percentage())
.returns(Default::default());

let vault = mock.deploy(BalancerV2Vault::raw_contract().abi.clone());
let vault = mock.deploy(BalancerV2Vault::raw_contract().interface.abi.clone());
vault
.expect_call(BalancerV2Vault::signatures().get_pool_tokens())
.returns(Default::default());
Expand Down
2 changes: 1 addition & 1 deletion crates/shared/src/sources/balancer_v2/pools/weighted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ mod tests {
let mock = Mock::new(42);
let web3 = mock.web3();

let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().abi.clone());
let pool = mock.deploy(BalancerV2WeightedPool::raw_contract().interface.abi.clone());
pool.expect_call(BalancerV2WeightedPool::signatures().get_normalized_weights())
.returns(weights.iter().copied().map(Bfp::as_uint256).collect());

Expand Down
3 changes: 3 additions & 0 deletions crates/shared/src/sources/uniswap_v3/event_fetching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ impl ParseLog for UniswapV3Event {
H256(BURN_TOPIC) => Ok(UniswapV3Event::Burn(
log.clone().decode(
UniswapV3Pool::raw_contract()
.interface
.abi
.event("Burn")
.expect("generated event decode"),
Expand All @@ -49,6 +50,7 @@ impl ParseLog for UniswapV3Event {
H256(MINT_TOPIC) => Ok(UniswapV3Event::Mint(
log.clone().decode(
UniswapV3Pool::raw_contract()
.interface
.abi
.event("Mint")
.expect("generated event decode"),
Expand All @@ -57,6 +59,7 @@ impl ParseLog for UniswapV3Event {
H256(SWAP_TOPIC) => Ok(UniswapV3Event::Swap(
log.clone().decode(
UniswapV3Pool::raw_contract()
.interface
.abi
.event("Swap")
.expect("generated event decode"),
Expand Down

0 comments on commit 98e13ae

Please sign in to comment.