diff --git a/docs/api-documentation.md b/docs/api-documentation.md index 0716b2cb..f91c75b9 100644 --- a/docs/api-documentation.md +++ b/docs/api-documentation.md @@ -16,6 +16,9 @@ transaction hash confirming the token transfer. - Each address is subject to rate limiting to prevent abuse. - This API only distributes Calibnet `tFIL` and `tUSDFC` tokens. +- For native token claims, the API returns the Ethereum transaction hash if + resolvable via `Filecoin.EthGetTransactionHashByCid`; otherwise, it returns + the CID. --- diff --git a/src/faucet/server_api.rs b/src/faucet/server_api.rs index 8250b4d1..976c9cbb 100644 --- a/src/faucet/server_api.rs +++ b/src/faucet/server_api.rs @@ -309,11 +309,16 @@ async fn handle_native_claim( { Ok(LotusJson(smsg)) => { let cid = rpc.mpool_push(smsg).await.map_err(ServerFnError::new)?; - let tx_hash = rpc + Ok(rpc .eth_get_transaction_hash_by_cid(cid) .await - .map_err(ServerFnError::new)?; - Ok(tx_hash.to_string()) + .map(|tx_hash| tx_hash.to_string()) + .unwrap_or_else(|err| { + log::warn!( + "Failed to resolve tx hash for CID {cid}: {err}. Returning CID instead." + ); + cid.to_string() + })) } Err(err) => Err(handle_faucet_error(err)), }