Skip to content

Commit

Permalink
use alloy namespace, no need to use explicit Ethereum network identif…
Browse files Browse the repository at this point in the history
…ier anymore but `<_>` is required
  • Loading branch information
zerosnacks committed Mar 21, 2024
1 parent f71ac1e commit 52f8edd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 30 deletions.
10 changes: 1 addition & 9 deletions examples/contracts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,7 @@ homepage.workspace = true
repository.workspace = true

[dev-dependencies]
alloy-contract.workspace = true
alloy-network.workspace = true
alloy-node-bindings.workspace = true
alloy-primitives.workspace = true
alloy-provider.workspace = true
alloy-rpc-client.workspace = true
alloy-signer-wallet.workspace = true
alloy-sol-types = { workspace = true, features = ["json"] }
alloy-transport-http.workspace = true
alloy.workspace = true

eyre.workspace = true
reqwest.workspace = true
Expand Down
16 changes: 9 additions & 7 deletions examples/contracts/examples/deploy_from_artifact.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! Example of deploying a contract from an artifact to Anvil and interacting with it.
use alloy_network::EthereumSigner;
use alloy_node_bindings::Anvil;
use alloy_primitives::U256;
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use alloy_signer_wallet::LocalWallet;
use alloy_sol_types::sol;
use alloy::{
network::EthereumSigner,
node_bindings::Anvil,
primitives::U256,
providers::{Provider, ProviderBuilder},
rpc::client::RpcClient,
signers::wallet::LocalWallet,
sol,
};
use eyre::Result;

// Codegen from artifact.
Expand Down
16 changes: 9 additions & 7 deletions examples/contracts/examples/deploy_from_contract.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! Example of deploying a contract from Solidity code to Anvil and interacting with it.
use alloy_network::EthereumSigner;
use alloy_node_bindings::Anvil;
use alloy_primitives::U256;
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use alloy_signer_wallet::LocalWallet;
use alloy_sol_types::sol;
use alloy::{
network::EthereumSigner,
node_bindings::Anvil,
primitives::U256,
providers::{Provider, ProviderBuilder},
rpc::client::RpcClient,
signers::wallet::LocalWallet,
sol,
};
use eyre::Result;

// Codegen from embedded Solidity code and precompiled bytecode.
Expand Down
10 changes: 3 additions & 7 deletions examples/contracts/examples/generate.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//! Example of generating code from ABI file to interact with the contract.
use alloy_network::Ethereum;
use alloy_node_bindings::Anvil;
use alloy_provider::ProviderBuilder;
use alloy_rpc_client::RpcClient;
use alloy_sol_types::sol;
use alloy::{node_bindings::Anvil, providers::ProviderBuilder, rpc::client::RpcClient, sol};
use eyre::Result;

// Codegen from ABI file to interact with the contract.
Expand All @@ -21,8 +17,8 @@ async fn main() -> Result<()> {
let anvil = Anvil::new().fork("https://eth.llamarpc.com").try_spawn()?;

// Create a provider.
let provider = ProviderBuilder::<_, Ethereum>::new()
.on_client(RpcClient::new_http(anvil.endpoint().parse()?));
let provider =
ProviderBuilder::<_>::new().on_client(RpcClient::new_http(anvil.endpoint().parse()?));

// Create a contract instance.
let contract = IERC20::new("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2".parse()?, provider);
Expand Down

0 comments on commit 52f8edd

Please sign in to comment.