Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ tweets_req_interval_in_secs = 60
[alert]
webhook_url = "https://www.webhook_url.com"

[feature_flags]
wallet_feature_flags_config_file = "../wallet_feature_flags/default_feature_flags.json"
[remote_configs]
wallet_configs_file = "../wallet_configs/default_configs.json"
4 changes: 2 additions & 2 deletions config/example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ tweets_req_interval_in_secs = 60
[alert]
webhook_url = "https://www.webhook_url.com"

[feature_flags]
wallet_feature_flags_config_file = "../wallet_feature_flags/default_feature_flags.json"
[remote_configs]
wallet_configs_file = "../wallet_configs/default_configs.json"

# Example environment variable overrides:
# TASKMASTER_BLOCKCHAIN__NODE_URL="ws://remote-node:9944"
Expand Down
4 changes: 2 additions & 2 deletions config/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ tweets_req_interval_in_secs = 1
[alert]
webhook_url = "https://www.webhook_url.com"

[feature_flags]
wallet_feature_flags_config_file = "../wallet_feature_flags/test_feature_flags.json"
[remote_configs]
wallet_configs_file = "../wallet_configs/test_configs.json"
17 changes: 8 additions & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ pub struct Config {
pub raid_leaderboard: RaidLeaderboardConfig,
pub alert: AlertConfig,
pub x_association: XAssociationConfig,
pub feature_flags: FeatureFlagsConfig,
pub remote_configs: RemoteConfigsConfig,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FeatureFlagsConfig {
pub wallet_feature_flags_config_file: String,
pub struct RemoteConfigsConfig {
pub wallet_configs_file: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -160,13 +160,12 @@ impl Config {
}

fn resolve_relative_paths(&mut self, config_path: &str) {
let feature_flags_path = Path::new(&self.feature_flags.wallet_feature_flags_config_file);
if feature_flags_path.is_absolute() {
let wallet_configs_path = Path::new(&self.remote_configs.wallet_configs_file);
if wallet_configs_path.is_absolute() {
return;
}
let base_dir = Path::new(config_path).parent().expect("Failed to get base directory");
self.feature_flags.wallet_feature_flags_config_file =
base_dir.join(feature_flags_path).to_string_lossy().to_string();
self.remote_configs.wallet_configs_file = base_dir.join(wallet_configs_path).to_string_lossy().to_string();
}
}

Expand Down Expand Up @@ -229,8 +228,8 @@ impl Default for Config {
x_association: XAssociationConfig {
keywords: "quantus".to_string(),
},
feature_flags: FeatureFlagsConfig {
wallet_feature_flags_config_file: "wallet_feature_flags/default_feature_flags.json".to_string(),
remote_configs: RemoteConfigsConfig {
wallet_configs_file: "wallet_configs/default_configs.json".to_string(),
},
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
db_persistence::DbError,
handlers::{address::AddressHandlerError, auth::AuthHandlerError, referral::ReferralHandlerError, HandlerError},
models::ModelError,
services::{graphql_client::GraphqlError, wallet_feature_flags_service::WalletFeatureFlagsError},
services::{graphql_client::GraphqlError, wallet_config_service::WalletConfigsError},
};

#[derive(Debug, thiserror::Error)]
Expand All @@ -27,7 +27,7 @@ pub enum AppError {
#[error("Server error: {0}")]
Server(String),
#[error("Wallet feature flags error: {0}")]
WalletFeatureFlags(#[from] WalletFeatureFlagsError),
WalletConfigs(#[from] WalletConfigsError),
#[error("Join error: {0}")]
Join(#[from] tokio::task::JoinError),
#[error("GraphQL error: {0}")]
Expand All @@ -52,7 +52,7 @@ impl IntoResponse for AppError {
),

// --- Wallet Feature Flags ---
AppError::WalletFeatureFlags(err) => map_wallet_feature_flags_error(err),
AppError::WalletConfigs(err) => map_wallet_configs_error(err),

// --- Model ---
AppError::Model(err) => (StatusCode::BAD_REQUEST, err.to_string()),
Expand Down Expand Up @@ -172,6 +172,6 @@ fn map_db_error(err: DbError) -> (StatusCode, String) {
}
}

fn map_wallet_feature_flags_error(err: WalletFeatureFlagsError) -> (StatusCode, String) {
fn map_wallet_configs_error(err: WalletConfigsError) -> (StatusCode, String) {
(StatusCode::INTERNAL_SERVER_ERROR, err.to_string())
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use serde_json::Value;

use crate::{handlers::SuccessResponse, http_server::AppState, AppError};

pub async fn handle_get_wallet_feature_flags(
pub async fn handle_get_wallet_configs(
State(state): State<AppState>,
) -> Result<Json<SuccessResponse<Value>>, AppError> {
let flags = state.wallet_feature_flags_service.get_wallet_feature_flags()?;
let flags = state.wallet_config_service.get_wallet_configs()?;

Ok(SuccessResponse::new(flags))
}
2 changes: 1 addition & 1 deletion src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use crate::{

pub mod address;
pub mod auth;
pub mod config;
pub mod raid_quest;
pub mod referral;
pub mod relevant_tweet;
pub mod tweet_author;
pub mod wallet_feature_flags;

#[derive(Debug, thiserror::Error)]
pub enum HandlerError {
Expand Down
8 changes: 4 additions & 4 deletions src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
db_persistence::DbPersistence,
metrics::{metrics_handler, track_metrics, Metrics},
routes::api_routes,
services::wallet_feature_flags_service::WalletFeatureFlagsService,
services::wallet_config_service::WalletConfigService,
Config, GraphqlClient,
};
use chrono::{DateTime, Utc};
Expand All @@ -24,7 +24,7 @@ pub struct AppState {
pub db: Arc<DbPersistence>,
pub metrics: Arc<Metrics>,
pub graphql_client: Arc<GraphqlClient>,
pub wallet_feature_flags_service: Arc<WalletFeatureFlagsService>,
pub wallet_config_service: Arc<WalletConfigService>,
pub config: Arc<Config>,
pub challenges: Arc<RwLock<HashMap<String, Challenge>>>,
pub oauth_sessions: Arc<Mutex<HashMap<String, PkceCodeVerifier>>>,
Expand Down Expand Up @@ -85,8 +85,8 @@ pub async fn start_server(
db,
metrics: Arc::new(Metrics::new()),
graphql_client,
wallet_feature_flags_service: Arc::new(WalletFeatureFlagsService::new(
config.feature_flags.wallet_feature_flags_config_file.clone(),
wallet_config_service: Arc::new(WalletConfigService::new(
config.remote_configs.wallet_configs_file.clone(),
)?),
config,
twitter_gateway,
Expand Down
7 changes: 7 additions & 0 deletions src/routes/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use axum::{routing::get, Router};

use crate::{handlers::config::handle_get_wallet_configs, http_server::AppState};

pub fn config_routes() -> Router<AppState> {
Router::new().route("/configs/wallet", get(handle_get_wallet_configs))
}
6 changes: 3 additions & 3 deletions src/routes/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use auth::auth_routes;
use axum::Router;
use config::config_routes;
use referral::referral_routes;
use wallet_feature_flags::wallet_feature_flags_routes;

use crate::{
http_server::AppState,
Expand All @@ -13,11 +13,11 @@ use crate::{

pub mod address;
pub mod auth;
pub mod config;
pub mod raid_quest;
pub mod referral;
pub mod relevant_tweet;
pub mod tweet_author;
pub mod wallet_feature_flags;

pub fn api_routes(state: AppState) -> Router<AppState> {
Router::new()
Expand All @@ -26,6 +26,6 @@ pub fn api_routes(state: AppState) -> Router<AppState> {
.merge(auth_routes(state.clone()))
.merge(relevant_tweet_routes(state.clone()))
.merge(tweet_author_routes(state.clone()))
.merge(wallet_feature_flags_routes())
.merge(config_routes())
.merge(raid_quest_routes(state))
}
7 changes: 0 additions & 7 deletions src/routes/wallet_feature_flags.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/services/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pub mod raid_leaderboard_service;
pub mod signature_service;
pub mod telegram_service;
pub mod tweet_synchronizer_service;
pub mod wallet_feature_flags_service;
pub mod wallet_config_service;
Loading
Loading