Skip to content

Commit

Permalink
Merge pull request #66 from alloy-rs/aws_signer
Browse files Browse the repository at this point in the history
feat(wallets): aws signer
  • Loading branch information
yash-atreya authored Apr 26, 2024
2 parents 9e818aa + 0a18c9e commit 89f90ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ alloy = { git = "https://github.com/alloy-rs/alloy", rev = "9aea693", features =
"rpc-types-eth",
"rpc-types-trace",
"signers",
"signer-aws",
"signer-keystore",
"signer-ledger",
"signer-mnemonic",
Expand Down
2 changes: 2 additions & 0 deletions examples/wallets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ workspace = true

[dev-dependencies]
alloy.workspace = true
aws-sdk-kms = { version = "1", default-features = false }
aws-config = { version = "1", default-features = false }

eyre.workspace = true
rand = "0.8.5"
Expand Down
22 changes: 22 additions & 0 deletions examples/wallets/examples/aws_signer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//! Example showing how to use the AWS KMS signer.
use alloy::signers::{aws::AwsSigner, Signer};
use aws_config::BehaviorVersion;
use eyre::Result;

#[tokio::main]
async fn main() -> Result<()> {
let Ok(key_id) = std::env::var("AWS_KEY_ID") else {
return Ok(());
};
let config = aws_config::load_defaults(BehaviorVersion::latest()).await;
let client = aws_sdk_kms::Client::new(&config);

let signer = AwsSigner::new(client, key_id, Some(1)).await.unwrap();

let message = "Hello, world!";

let sig = signer.sign_message(message.as_bytes()).await.unwrap();
assert_eq!(sig.recover_address_from_msg(message).unwrap(), signer.address());

Ok(())
}

0 comments on commit 89f90ed

Please sign in to comment.