Skip to content

Commit 3b9d581

Browse files
committed
don't inject cache into credential in signer abstraction
1 parent 621d721 commit 3b9d581

2 files changed

Lines changed: 7 additions & 21 deletions

File tree

core/src/signer.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use vault_sdk::VaultClient;
1515
use vault_types::enclave::encrypted::eoa::MessageFormat;
1616

1717
use crate::{
18-
credentials::{SigningCredential, KmsClientCache},
18+
credentials::SigningCredential,
1919
defs::AddressDef,
2020
error::{EngineError, SerialisableAwsSdkError, SerialisableAwsSignerError},
2121
execution_options::aa::{EntrypointAndFactoryDetails, EntrypointAndFactoryDetailsDeserHelper},
@@ -204,16 +204,14 @@ pub trait AccountSigner {
204204
pub struct EoaSigner {
205205
pub vault_client: VaultClient,
206206
pub iaw_client: IAWClient,
207-
pub kms_client_cache: KmsClientCache,
208207
}
209208

210209
impl EoaSigner {
211210
/// Create a new EOA signer
212-
pub fn new(vault_client: VaultClient, iaw_client: IAWClient, kms_client_cache: KmsClientCache) -> Self {
211+
pub fn new(vault_client: VaultClient, iaw_client: IAWClient) -> Self {
213212
Self {
214213
vault_client,
215214
iaw_client,
216-
kms_client_cache,
217215
}
218216
}
219217
}
@@ -274,10 +272,7 @@ impl AccountSigner for EoaSigner {
274272
Ok(iaw_result.signature)
275273
}
276274
SigningCredential::AwsKms(creds) => {
277-
// Clone and inject the cache into the credentials
278-
let mut creds_with_cache = creds.clone();
279-
creds_with_cache.kms_client_cache = Some(self.kms_client_cache.clone());
280-
let signer = creds_with_cache.get_signer(options.chain_id).await?;
275+
let signer = creds.get_signer(options.chain_id).await?;
281276
let message = match format {
282277
MessageFormat::Text => message.to_string().into_bytes(),
283278
MessageFormat::Hex => {
@@ -357,10 +352,7 @@ impl AccountSigner for EoaSigner {
357352
}
358353

359354
SigningCredential::AwsKms(creds) => {
360-
// Clone and inject the cache into the credentials
361-
let mut creds_with_cache = creds.clone();
362-
creds_with_cache.kms_client_cache = Some(self.kms_client_cache.clone());
363-
let signer = creds_with_cache.get_signer(options.chain_id).await?;
355+
let signer = creds.get_signer(options.chain_id).await?;
364356

365357
// TODO: create serialisable error for @alloy-signer::error::Error
366358
let signature = signer
@@ -428,10 +420,7 @@ impl AccountSigner for EoaSigner {
428420
Ok(iaw_result.signature)
429421
}
430422
SigningCredential::AwsKms(creds) => {
431-
// Clone and inject the cache into the credentials
432-
let mut creds_with_cache = creds.clone();
433-
creds_with_cache.kms_client_cache = Some(self.kms_client_cache.clone());
434-
let signer = creds_with_cache.get_signer(options.chain_id).await?;
423+
let signer = creds.get_signer(options.chain_id).await?;
435424
let mut transaction = transaction.clone();
436425

437426
// TODO: create serialisable error for @alloy-signer::error::Error
@@ -511,10 +500,7 @@ impl AccountSigner for EoaSigner {
511500
Ok(iaw_result.signed_authorization)
512501
}
513502
SigningCredential::AwsKms(creds) => {
514-
// Clone and inject the cache into the credentials
515-
let mut creds_with_cache = creds.clone();
516-
creds_with_cache.kms_client_cache = Some(self.kms_client_cache.clone());
517-
let signer = creds_with_cache.get_signer(options.chain_id).await?;
503+
let signer = creds.get_signer(options.chain_id).await?;
518504
let authorization_hash = authorization.signature_hash();
519505

520506
let signature = signer.sign_hash(&authorization_hash).await.map_err(|e| {

server/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async fn main() -> anyhow::Result<()> {
5959
vault_client: vault_client.clone(),
6060
iaw_client: iaw_client.clone(),
6161
});
62-
let eoa_signer = Arc::new(EoaSigner::new(vault_client.clone(), iaw_client, kms_client_cache.clone()));
62+
let eoa_signer = Arc::new(EoaSigner::new(vault_client.clone(), iaw_client));
6363
let redis_client = twmq::redis::Client::open(config.redis.url.as_str())?;
6464

6565
let authorization_cache = EoaAuthorizationCache::new(

0 commit comments

Comments
 (0)