Skip to content

Commit 1dd0850

Browse files
committed
CreateAccountUseCaseImpl: do not generate unrelated new private keys
1 parent a2cd8df commit 1dd0850

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

src/domain/accounts/services/src/use_cases/create_account_use_case_impl.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl CreateAccountUseCaseImpl {
108108
Ok(())
109109
}
110110

111-
async fn save_private_key(
111+
async fn maybe_save_private_key(
112112
&self,
113113
account_id: &odf::AccountID,
114114
key: odf::metadata::SigningKey,
@@ -161,10 +161,6 @@ impl CreateAccountUseCase for CreateAccountUseCaseImpl {
161161
) -> Result<Account, CreateAccountError> {
162162
self.save_account(account, password).await?;
163163

164-
// Generate a new private key.
165-
let (private_key, _) = odf::AccountID::new_generated_ed25519();
166-
self.save_private_key(&account.id, private_key).await?;
167-
168164
if !quiet {
169165
self.notify_account_created(account).await?;
170166
}
@@ -205,7 +201,8 @@ impl CreateAccountUseCase for CreateAccountUseCaseImpl {
205201
};
206202

207203
self.save_account(&account, &password).await?;
208-
self.save_private_key(&account.id, account_key).await?;
204+
self.maybe_save_private_key(&account.id, account_key)
205+
.await?;
209206

210207
self.notify_account_created(&account).await?;
211208

src/domain/signing/services/tests/tests/test_sign_eip712_use_case_impl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ const ADMIN: &str = "admin";
6969

7070
#[test]
7171
fn test_has_access_by_name_matrix() {
72-
let f = SignEip712UseCaseImpl::has_access_by_account_name;
73-
7472
for (subject_account_name, target_account_name, expected) in [
7573
// molecule
7674
(MOLECULE, MOLECULE, true),
@@ -87,7 +85,10 @@ fn test_has_access_by_name_matrix() {
8785
(MOLECULE_DEV, "molecule.devops", false),
8886
(MOLECULE_DEV, "molecule.dev.probe8503325863", true),
8987
] {
90-
let actual = f(subject_account_name, target_account_name);
88+
let actual = SignEip712UseCaseImpl::has_access_by_account_name(
89+
subject_account_name,
90+
target_account_name,
91+
);
9192

9293
assert_eq!(
9394
expected, actual,
@@ -647,7 +648,6 @@ impl SignEip712UseCaseHarness {
647648
[5; _],
648649
),
649650
// Accounts
650-
// NOTE: for InMemoryDidSecretKeyRepository we rewrite keys with pregenerated values
651651
(
652652
DidEntity::new_account(molecule_account_id().to_string()),
653653
[6; _],

0 commit comments

Comments
 (0)