Skip to content

Commit

Permalink
clean up logs (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy-t-wang authored Oct 18, 2024
1 parent 81a50f6 commit 34dd10a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
14 changes: 1 addition & 13 deletions src/routes/api/v1/ens_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,20 @@ pub async fn ens_gateway(
},
};

tracing::info!("Request payload: {:?}", request_payload);
let (req_data, name, method) = decode_payload(&request_payload)
.map_err(|_| ENSErrorResponse::new("Failed to decode payload."))?;

tracing::info!("Decoded payload: {:?}", request_payload);
let username = name
.strip_suffix(&format!(".{}", config.ens_domain))
.ok_or_else(|| ENSErrorResponse::new("Name not found."))?;

tracing::info!("Found Username: {:?}", request_payload);
let record = sqlx::query_as!(Name, "SELECT * FROM names WHERE username = $1", username)
.fetch_one(&db)
.await
.map_err(|_| ENSErrorResponse::new("Name not found."))?;

tracing::info!("Found Record: {:?}", record);
let result: Vec<u8> = match method {
Method::Text(node, key) => {
tracing::info!("Text: {:?}", record.address);

if node != namehash(&name) {
return Err(ENSErrorResponse::new("Invalid node hash provided."));
}
Expand All @@ -70,19 +64,13 @@ pub async fn ens_gateway(
if node != namehash(&name) {
return Err(ENSErrorResponse::new("Invalid node hash provided."));
}
tracing::info!("Address: {:?}", record.address);

(Address::parse_checksummed(record.address, None).unwrap()).abi_encode()
},
Method::AddrMultichain | Method::Name => {
tracing::info!("AddrMultichain: {:?}", record.address);

return Err(ENSErrorResponse::new("Not implemented."));
},
_ => {
tracing::info!("No Method: {:?}", record.address);
().abi_encode()
},
_ => ().abi_encode(),
};

sign_response(config, result, &req_data, request_payload.sender)
Expand Down
1 change: 0 additions & 1 deletion src/types/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ impl ErrorResponse {
impl<E: std::error::Error> From<E> for ErrorResponse {
fn from(err: E) -> Self {
tracing::error!(err = ?err);

Self::server_error("Internal Server Error".to_string())
}
}
Expand Down

0 comments on commit 34dd10a

Please sign in to comment.