Skip to content

Commit

Permalink
Merge pull request #14 from yash-atreya/yash/mig_alloy
Browse files Browse the repository at this point in the history
use alloy bindings
  • Loading branch information
mattsse authored Jun 16, 2024
2 parents ef4afe7 + 951eb60 commit bcb18c9
Show file tree
Hide file tree
Showing 7 changed files with 742 additions and 329 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
run: forge build --sizes

- name: Check bindings are correct
run: forge bind --bindings-path ./crates/bindings --root ./contracts --crate-name bindings --skip-cargo-toml
run: forge bind --bindings-path ./crates/bindings --root ./contracts --crate-name bindings --skip-cargo-toml --alloy
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[workspace]
members = [
"app",
"crates/bindings",
]
members = ["app", "crates/bindings"]

[workspace.dependencies]
bindings = { path = "crates/bindings" }
foundry-contracts = { path = "crates/bindings" }
9 changes: 6 additions & 3 deletions app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bindings = { workspace = true }
ethers = { version = "2", default-features = false, features = ["rustls"] }
foundry-contracts.workspace = true
eyre = "0.6"
tokio = { version = "1.19", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.19", features = ["macros", "rt-multi-thread"] }
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
"providers",
"node-bindings",
] }
18 changes: 9 additions & 9 deletions app/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use bindings::counter::Counter;

use ethers::{prelude::Middleware, providers::test_provider::GOERLI, types::Address};

use alloy::{
primitives::Address,
providers::{builder, Provider},
};
use eyre::Result;
use std::sync::Arc;
use foundry_contracts::counter::Counter;

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

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

let contract = Counter::new(address, provider);
let blk = contract.client().get_block_number().await?;
let _contract = Counter::new(address, provider.clone());

let blk = provider.get_block_number().await?;
println!("Hello, world! {}", blk);
Ok(())
}
10 changes: 5 additions & 5 deletions crates/bindings/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "bindings"
name = "foundry-contracts"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ethers = { version = "2", default-features = false, features = ["abigen"] }
serde = "1"
alloy = { git = "https://github.com/alloy-rs/alloy", features = [
"sol-types",
"contract",
] }
Loading

0 comments on commit bcb18c9

Please sign in to comment.