From ef951d5a82e0693ff7cfcac8bd010665409f5fdf Mon Sep 17 00:00:00 2001 From: FiveMovesAhead Date: Fri, 22 Nov 2024 19:41:07 +0800 Subject: [PATCH] Player name is nullable if no ENS. --- tig-structs/src/core.rs | 2 +- tig-utils/src/eth.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tig-structs/src/core.rs b/tig-structs/src/core.rs index a777a79..8dcb1b0 100644 --- a/tig-structs/src/core.rs +++ b/tig-structs/src/core.rs @@ -349,7 +349,7 @@ serializable_struct_with_getters! { // Player child structs serializable_struct_with_getters! { PlayerDetails { - name: String, + name: Option, is_multisig: bool, } } diff --git a/tig-utils/src/eth.rs b/tig-utils/src/eth.rs index 448afe0..3542f67 100644 --- a/tig-utils/src/eth.rs +++ b/tig-utils/src/eth.rs @@ -255,7 +255,7 @@ mod web3_feature { } ]"#; - pub async fn lookup_ens_name(rpc_url: &str, address: &str) -> Result { + pub async fn lookup_ens_name(rpc_url: &str, address: &str) -> Result> { let transport = web3::transports::Http::new(rpc_url)?; let eth = web3::Web3::new(transport).eth(); @@ -271,11 +271,11 @@ mod web3_feature { .query("getNames", (addresses,), None, Options::default(), None) .await?; - // Return first name or address if empty + // Return first name or none if empty Ok(if !names[0].is_empty() { - names[0].clone() + Some(names[0].clone()) } else { - address.to_string() + None }) } }