Skip to content

Commit

Permalink
update result type and use replace for indexeddb
Browse files Browse the repository at this point in the history
  • Loading branch information
borngraced committed Jan 10, 2025
1 parent cda913d commit 9e50c9f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
22 changes: 4 additions & 18 deletions mm2src/mm2_main/src/lp_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ cfg_wasm32! {
cfg_native! {
use mnemonics_storage::{read_all_wallet_names, read_encrypted_passphrase_if_available, save_encrypted_passphrase, WalletsStorageError};
}

#[cfg(not(target_arch = "wasm32"))] mod mnemonics_storage;
#[cfg(target_arch = "wasm32")] mod mnemonics_wasm_db;

Expand Down Expand Up @@ -549,25 +548,10 @@ pub struct SeedPasswordUpdateRequest {
/// It contains a boolean indicating whether the operation was successful.
#[derive(Serialize)]
pub struct SeedPasswordUpdateResponse {
/// `true` if the password update was successful, `false` otherwise.
successful: bool,
result: String,
}

/// RPC function to handle a request for updating the seed storage password.
///
/// # Arguments
/// - `ctx`: The shared context (`MmArc`) for the application.
/// - `req`: The `SeedPasswordUpdateRequest` containing the current and new passwords.
///
/// # Example
/// ```ignore
/// let request = SeedPasswordUpdateRequest {
/// current_password: "old_password".to_string(),
/// new_password: "new_password".to_string(),
/// };
/// let response = update_seed_storage_password_rpc(ctx, request).await?;
/// assert!(response.successful);
/// ```
pub async fn update_seed_storage_password_rpc(
ctx: MmArc,
req: SeedPasswordUpdateRequest,
Expand All @@ -591,5 +575,7 @@ pub async fn update_seed_storage_password_rpc(
// save new encrypted mnemonic data with new password
save_encrypted_passphrase(&ctx, &wallet_name, &encrypted_data).await?;

Ok(SeedPasswordUpdateResponse { successful: true })
Ok(SeedPasswordUpdateResponse {
result: "Success".to_string(),
})
}
4 changes: 3 additions & 1 deletion mm2src/mm2_main/src/lp_wallet/mnemonics_wasm_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ pub(super) async fn save_encrypted_passphrase(
}
})?,
};
table.add_item(&mnemonics_table_item).await?;
table
.replace_item_by_unique_index("wallet_name", wallet_name, &mnemonics_table_item)
.await?;

Ok(())
}
Expand Down

0 comments on commit 9e50c9f

Please sign in to comment.