Skip to content

Commit

Permalink
feat: account id validation
Browse files Browse the repository at this point in the history
  • Loading branch information
polydez committed Apr 1, 2024
1 parent bedcda8 commit 5167ec6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rpc/src/server/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ use miden_node_proto::generated::{
store::api_client as store_client,
};
use miden_objects::{
transaction::ProvenTransaction, utils::serde::Deserializable, Digest, MIN_PROOF_SECURITY_LEVEL,
accounts::AccountId, transaction::ProvenTransaction, utils::serde::Deserializable, Digest,
MIN_PROOF_SECURITY_LEVEL,
};
use miden_tx::TransactionVerifier;
use tonic::{
Expand Down Expand Up @@ -147,6 +148,15 @@ impl api_server::Api for RpcApi {
) -> std::result::Result<Response<GetPublicAccountDetailsResponse>, Status> {
debug!(target: COMPONENT, request = ?request.get_ref());

// Validating account using conversion:
let _account_id: AccountId = request
.get_ref()
.account_id
.clone()
.ok_or(Status::invalid_argument("account_id is missing"))?
.try_into()
.map_err(|err| Status::invalid_argument(format!("Invalid account id: {err}")))?;

self.store.clone().get_public_account_details(request).await
}
}

0 comments on commit 5167ec6

Please sign in to comment.