Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix tests in signer crate #19

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions crates/signer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ Sign an Ethereum prefixed message ([EIP-712](https://eips.ethereum.org/EIPS/eip-
use alloy_signer::{Signer, SignerSync};

// Instantiate a signer.
let signer = alloy_signer_wallet::LocalWallet::random();
let signer = alloy_signer_wallet::LocalWallet::random(1);

// Sign a message.
let message = "Some data";
let signature = signer.sign_message_sync(message.as_bytes())?;

// Recover the signer from the message.
let recovered = signature.recover_address_from_msg(message)?;
let recovered = signature.recover_address_from_msg(message, 1)?;
assert_eq!(recovered, signer.address());
# Ok::<_, Box<dyn std::error::Error>>(())
```
Expand All @@ -40,23 +40,23 @@ Sign a transaction:

```rust
use alloy_consensus::TxLegacy;
use alloy_primitives::{U256, address, bytes};
use alloy_primitives::{U256, cAddress, bytes};
use alloy_signer::{Signer, SignerSync};
use alloy_network::{TxSignerSync};
use libgoldilocks::SigningKey;

// Instantiate a signer.
let signer = "dcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7"
.parse::<alloy_signer_wallet::LocalWallet>()?;
let signer = alloy_signer_wallet::LocalWallet::from_signing_key(SigningKey::from_str("dcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7dcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3"), 1);

// Create a transaction.
let mut tx = TxLegacy {
to: address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045").into(),
to: cAddress!("0000d8dA6BF26964aF9D7eEd9e03E53415D37aA96045").into(),
value: U256::from(1_000_000_000),
gas_limit: 2_000_000,
energy_limit: 2_000_000,
nonce: 0,
gas_price: 21_000_000_000,
energy_price: 21_000_000_000,
input: bytes!(),
chain_id: Some(1),
network_id: Some(1),
};

// Sign it.
Expand Down
Loading