From 8a23efd048f4902b5da42af11880d515e73353a5 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Wed, 19 Oct 2022 18:50:16 +0000 Subject: [PATCH] optional params like this do not work. need hashmap --- web3_proxy/src/frontend/users.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/web3_proxy/src/frontend/users.rs b/web3_proxy/src/frontend/users.rs index df814911..93e5c6b4 100644 --- a/web3_proxy/src/frontend/users.rs +++ b/web3_proxy/src/frontend/users.rs @@ -46,7 +46,7 @@ pub async fn user_login_get( ClientIp(ip): ClientIp, // TODO: what does axum's error handling look like if the path fails to parse? // TODO: allow ENS names here? - Path((user_address, message_eip)): Path<(Address, Option)>, + Path(mut params): Path>, Query(query): Query>, ) -> FrontendResult { // give these named variables so that we drop them at the very end of this function @@ -69,6 +69,14 @@ pub async fn user_login_get( let expiration_time = issued_at.add(Duration::new(expire_seconds as i64, 0)); + let user_address: Address = params + .remove("user_address") + // TODO: map_err so this becomes a 500. routing must be bad + .context("impossible")? + .parse() + // TODO: map_err so this becomes a 401 + .context("bad input")?; + // TODO: get most of these from the app config let message = Message { // TODO: should domain be llamanodes, or llamarpc, or the subdomain of llamarpc? @@ -100,7 +108,9 @@ pub async fn user_login_get( // there are multiple ways to sign messages and not all wallets support them // TODO: default message eip from config? - let message_eip = message_eip.unwrap_or_else(|| "eip4361".to_string()); + let message_eip = params + .remove("message_eip") + .unwrap_or_else(|| "eip4361".to_string()); let message: String = match message_eip.as_str() { "eip191_bytes" => Bytes::from(message.eip191_bytes().unwrap()).to_string(),