Skip to content

Commit

Permalink
added nam token address to setting endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianmarco Fraccaroli committed Dec 13, 2023
1 parent 331d469 commit 9d761e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/dto/faucet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use data_encoding::HEXLOWER;
use serde::{Deserialize, Serialize};
use validator::Validate;
Expand Down Expand Up @@ -53,5 +55,6 @@ pub struct FaucetResponseStatusDto {
pub struct FaucetSettingResponse {
pub difficulty: u64,
pub chain_id: String,
pub start_at: i64
pub start_at: i64,
pub tokens_alias_to_address: HashMap<String, String>
}
5 changes: 5 additions & 0 deletions src/handler/faucet.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use axum::{extract::State, Json};
use axum_macros::debug_handler;
use namada_sdk::{
Expand All @@ -22,10 +24,13 @@ use crate::{
pub async fn faucet_settings(
State(state): State<FaucetState>,
) -> Result<Json<FaucetSettingResponse>, ApiError> {
let nam_token_address = rpc::query_native_token(state.sdk.client()).await.unwrap();

let response = FaucetSettingResponse {
difficulty: state.difficulty,
chain_id: state.chain_id,
start_at: state.chain_start,
tokens_alias_to_address: HashMap::from([("NAM".to_string(), nam_token_address.to_string())])
};

Ok(Json(response))
Expand Down

0 comments on commit 9d761e4

Please sign in to comment.