Skip to content

Commit

Permalink
Merge branch 'main' into zerosnacks/middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
zerosnacks committed Mar 19, 2024
2 parents 227af88 + ea4247b commit 7cdd8e0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 27 deletions.
1 change: 0 additions & 1 deletion examples/wallets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ alloy-signer-ledger.workspace = true
alloy-signer-trezor.workspace = true
alloy-signer-wallet = { workspace = true, features = ["mnemonic", "yubihsm"] }
alloy-sol-types.workspace = true
alloy-transport-http.workspace = true

eyre.workspace = true
reqwest.workspace = true
Expand Down
12 changes: 4 additions & 8 deletions examples/wallets/examples/ledger_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,22 @@

use alloy_network::EthereumSigner;
use alloy_primitives::{address, U256};
use alloy_provider::{Provider, ProviderBuilder, RootProvider};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use alloy_rpc_types::request::TransactionRequest;
use alloy_signer_ledger::{HDPath, LedgerSigner};
use alloy_transport_http::Http;
use eyre::Result;
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<()> {
// Instantiate the application by acquiring a lock on the Ledger device.
let signer = LedgerSigner::new(HDPath::LedgerLive(0), Some(1)).await?;

// Create a provider with the signer and the network.
let http = Http::<Client>::new("http://localhost:8545".parse()?);

// Initialize the provider.
// Create a provider with the signer.
let http = "http://localhost:8545".parse()?;
let provider = ProviderBuilder::new()
.signer(EthereumSigner::from(signer))
.provider(RootProvider::new(RpcClient::new(http, true)));
.on_client(RpcClient::new_http(http));

// Create a transaction.
let tx = TransactionRequest {
Expand Down
10 changes: 4 additions & 6 deletions examples/wallets/examples/private_key_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
use alloy_network::EthereumSigner;
use alloy_node_bindings::Anvil;
use alloy_primitives::U256;
use alloy_provider::{Provider, ProviderBuilder, RootProvider};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use alloy_rpc_types::request::TransactionRequest;
use alloy_signer_wallet::LocalWallet;
use alloy_transport_http::Http;
use eyre::Result;
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<()> {
Expand All @@ -20,11 +18,11 @@ async fn main() -> Result<()> {
let alice: LocalWallet = anvil.keys()[0].clone().into();
let bob: LocalWallet = anvil.keys()[1].clone().into();

// Create a provider with a signer and the network.
let http = Http::<Client>::new(anvil.endpoint().parse()?);
// Create a provider with the signer.
let http = "http://localhost:8545".parse()?;
let provider = ProviderBuilder::new()
.signer(EthereumSigner::from(alice))
.provider(RootProvider::new(RpcClient::new(http, true)));
.on_client(RpcClient::new_http(http));

// Create a transaction.
let tx = TransactionRequest {
Expand Down
10 changes: 4 additions & 6 deletions examples/wallets/examples/trezor_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,22 @@

use alloy_network::EthereumSigner;
use alloy_primitives::{address, U256};
use alloy_provider::{Provider, ProviderBuilder, RootProvider};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use alloy_rpc_types::request::TransactionRequest;
use alloy_signer_trezor::{TrezorHDPath, TrezorSigner};
use alloy_transport_http::Http;
use eyre::Result;
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<()> {
// Instantiate the application by acquiring a lock on the Trezor device.
let signer = TrezorSigner::new(TrezorHDPath::TrezorLive(0), Some(1)).await?;

// Create a provider with the signer and the network.
let http = Http::<Client>::new("http://localhost:8545".parse()?);
// Create a provider with the signer.
let http = "http://localhost:8545".parse()?;
let provider = ProviderBuilder::new()
.signer(EthereumSigner::from(signer))
.provider(RootProvider::new(RpcClient::new(http, true)));
.on_client(RpcClient::new_http(http));

// Create a transaction.
let tx = TransactionRequest {
Expand Down
10 changes: 4 additions & 6 deletions examples/wallets/examples/yubi_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@

use alloy_network::EthereumSigner;
use alloy_primitives::{address, U256};
use alloy_provider::{Provider, ProviderBuilder, RootProvider};
use alloy_provider::{Provider, ProviderBuilder};
use alloy_rpc_client::RpcClient;
use alloy_rpc_types::request::TransactionRequest;
use alloy_signer_wallet::{
yubihsm::{Connector, Credentials, UsbConfig},
YubiWallet,
};
use alloy_transport_http::Http;
use eyre::Result;
use reqwest::Client;

#[tokio::main]
async fn main() -> Result<()> {
Expand All @@ -24,11 +22,11 @@ async fn main() -> Result<()> {
// to generate a new keypair.
let signer = YubiWallet::connect(connector, Credentials::default(), 0);

// Create a provider with the signer and the network.
let http = Http::<Client>::new("http://localhost:8545".parse()?);
// Create a provider with the signer.
let http = "http://localhost:8545".parse()?;
let provider = ProviderBuilder::new()
.signer(EthereumSigner::from(signer))
.provider(RootProvider::new(RpcClient::new(http, true)));
.on_client(RpcClient::new_http(http));

// Create a transaction.
let tx = TransactionRequest {
Expand Down

0 comments on commit 7cdd8e0

Please sign in to comment.