Skip to content

Commit bcb18c9

Browse files
authored
Merge pull request #14 from yash-atreya/yash/mig_alloy
use alloy bindings
2 parents ef4afe7 + 951eb60 commit bcb18c9

File tree

7 files changed

+742
-329
lines changed

7 files changed

+742
-329
lines changed

.github/workflows/contracts.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ jobs:
4747
run: forge build --sizes
4848

4949
- name: Check bindings are correct
50-
run: forge bind --bindings-path ./crates/bindings --root ./contracts --crate-name bindings --skip-cargo-toml
50+
run: forge bind --bindings-path ./crates/bindings --root ./contracts --crate-name bindings --skip-cargo-toml --alloy

Cargo.toml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
[workspace]
2-
members = [
3-
"app",
4-
"crates/bindings",
5-
]
2+
members = ["app", "crates/bindings"]
63

74
[workspace.dependencies]
8-
bindings = { path = "crates/bindings" }
5+
foundry-contracts = { path = "crates/bindings" }

app/Cargo.toml

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
bindings = { workspace = true }
10-
ethers = { version = "2", default-features = false, features = ["rustls"] }
9+
foundry-contracts.workspace = true
1110
eyre = "0.6"
12-
tokio = { version = "1.19", features = ["macros", "rt-multi-thread"] }
11+
tokio = { version = "1.19", features = ["macros", "rt-multi-thread"] }
12+
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
13+
"providers",
14+
"node-bindings",
15+
] }

app/src/main.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
use bindings::counter::Counter;
2-
3-
use ethers::{prelude::Middleware, providers::test_provider::GOERLI, types::Address};
4-
1+
use alloy::{
2+
primitives::Address,
3+
providers::{builder, Provider},
4+
};
55
use eyre::Result;
6-
use std::sync::Arc;
6+
use foundry_contracts::counter::Counter;
77

88
#[tokio::main]
99
async fn main() -> Result<()> {
10-
let provider = GOERLI.provider();
11-
let provider = Arc::new(provider);
10+
let provider = builder().with_recommended_fillers().on_anvil_with_wallet();
1211

1312
let address = "0x0000000000000000000000000000000000000000".parse::<Address>()?;
1413

15-
let contract = Counter::new(address, provider);
16-
let blk = contract.client().get_block_number().await?;
14+
let _contract = Counter::new(address, provider.clone());
15+
16+
let blk = provider.get_block_number().await?;
1717
println!("Hello, world! {}", blk);
1818
Ok(())
1919
}

crates/bindings/Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
2-
name = "bindings"
2+
name = "foundry-contracts"
33
version = "0.1.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
86
[dependencies]
9-
ethers = { version = "2", default-features = false, features = ["abigen"] }
10-
serde = "1"
7+
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
8+
"sol-types",
9+
"contract",
10+
] }

0 commit comments

Comments
 (0)