Skip to content

Commit 2f27e6e

Browse files
jmg-duartexdecentralix
authored andcommitted
Migrate GasHog to alloy (cowprotocol#3761)
1 parent 93ffa09 commit 2f27e6e

File tree

4 files changed

+23
-17
lines changed

4 files changed

+23
-17
lines changed

crates/contracts/build.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,9 +1030,6 @@ fn main() {
10301030
// Test Contract for incrementing arbitrary counters.
10311031
generate_contract("Counter");
10321032

1033-
// Test Contract for using up a specified amount of gas.
1034-
generate_contract("GasHog");
1035-
10361033
// Contract for Uniswap's Permit2 contract.
10371034
generate_contract_with_config("Permit2", |builder| {
10381035
builder

crates/contracts/src/alloy.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,11 @@ pub mod support {
613613
);
614614
}
615615

616+
pub mod test {
617+
// Test Contract for using up a specified amount of gas.
618+
crate::bindings!(GasHog);
619+
}
620+
616621
pub use alloy::providers::DynProvider as Provider;
617622

618623
/// Extension trait to attach some useful functions to the contract instance.

crates/contracts/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ pub mod support {
9797
pub mod test {
9898
include_contracts! {
9999
Counter;
100-
GasHog;
101100
}
102101
}
103102

crates/e2e/tests/e2e/smart_contract_orders.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use {
2-
e2e::{
3-
setup::{eth, safe::Safe, *},
4-
tx,
5-
},
2+
e2e::setup::{eth, safe::Safe, *},
63
ethcontract::{Bytes, H160, U256},
7-
ethrpc::alloy::conversions::{IntoAlloy, IntoLegacy},
4+
ethrpc::alloy::{
5+
CallBuilderExt,
6+
conversions::{IntoAlloy, IntoLegacy},
7+
},
88
model::{
99
order::{OrderCreation, OrderCreationAppData, OrderKind, OrderStatus, OrderUid},
1010
signature::Signature,
@@ -156,8 +156,7 @@ async fn erc1271_gas_limit(web3: Web3) {
156156
let mut onchain = OnchainComponents::deploy(web3.clone()).await;
157157

158158
let [solver] = onchain.make_solvers(to_wei(1)).await;
159-
let trader = contracts::test::GasHog::builder(&web3)
160-
.deploy()
159+
let trader = contracts::alloy::test::GasHog::Instance::deploy(web3.alloy.clone())
161160
.await
162161
.unwrap();
163162

@@ -166,11 +165,17 @@ async fn erc1271_gas_limit(web3: Web3) {
166165
.await;
167166

168167
// Fund trader accounts and approve relayer
169-
cow.fund(trader.address(), to_wei(5)).await;
170-
tx!(
171-
solver.account(),
172-
trader.approve(cow.address(), onchain.contracts().allowance, to_wei(10))
173-
);
168+
cow.fund(trader.address().into_legacy(), to_wei(5)).await;
169+
trader
170+
.approve(
171+
cow.address().into_alloy(),
172+
onchain.contracts().allowance.into_alloy(),
173+
eth(10),
174+
)
175+
.from(solver.address().into_alloy())
176+
.send_and_watch()
177+
.await
178+
.unwrap();
174179

175180
let services = Services::new(&onchain).await;
176181
services
@@ -195,7 +200,7 @@ async fn erc1271_gas_limit(web3: Web3) {
195200
valid_to: model::time::now_in_epoch_seconds() + 300,
196201
kind: OrderKind::Sell,
197202
signature: Signature::Eip1271(signature.to_vec()),
198-
from: Some(trader.address()),
203+
from: Some(trader.address().into_legacy()),
199204
..Default::default()
200205
};
201206

0 commit comments

Comments
 (0)