From d9a449304c060faeb1e1cc4759dfdc66159279b9 Mon Sep 17 00:00:00 2001 From: mik-tf Date: Mon, 8 Sep 2025 15:44:39 -0400 Subject: [PATCH] docs: mark MC base currency implementation as completed in redesign plan --- docs/dev/design/marketplace-redesign-plan.md | 14 +++--- src/controllers/dashboard.rs | 4 +- src/controllers/wallet.rs | 12 ++--- src/models/builders.rs | 4 +- src/services/instant_purchase.rs | 2 +- src/services/navbar.rs | 16 +++---- src/services/user_persistence.rs | 4 +- src/static/js/dashboard_cart.js | 4 +- src/static/js/dashboard_orders.js | 2 +- src/static/js/dashboard_wallet.js | 4 +- src/views/dashboard/cart.html | 4 +- src/views/dashboard/index.html | 4 +- src/views/dashboard/orders.html | 2 +- src/views/dashboard/wallet.html | 6 +-- user_data/user111_at_example_com.json | 49 ++++++++++++++++++++ user_data/user321_at_example_com.json | 49 ++++++++++++++++++++ 16 files changed, 139 insertions(+), 41 deletions(-) create mode 100644 user_data/user111_at_example_com.json create mode 100644 user_data/user321_at_example_com.json diff --git a/docs/dev/design/marketplace-redesign-plan.md b/docs/dev/design/marketplace-redesign-plan.md index ef8d92f..931686d 100644 --- a/docs/dev/design/marketplace-redesign-plan.md +++ b/docs/dev/design/marketplace-redesign-plan.md @@ -35,14 +35,14 @@ This document outlines the comprehensive redesign of the Project Mycelium market - [x] Update backend currency handling ### 2. Currency System Overhaul -- [ ] **Implement Mycelium Credit (MC)** - - [ ] Update currency service to use MC as base - - [ ] Set initial exchange rate: 1 MC = 1 USD - - [ ] Update currency conversion logic if needed - - [ ] Update pricing calculations if needed +- [x] **Implement Mycelium Credit (MC)** + - [x] Update currency service to use MC as base + - [x] Set initial exchange rate: 1 MC = 1 USD + - [x] Update currency conversion logic if needed + - [x] Update pricing calculations if needed -- [ ] **Currency Display Preferences** - - [ ] Add AED to supported currencies (see /dashboard/settings Currency Preferences) +- [x] **Currency Display Preferences** + - [x] Add AED to supported currencies (see /dashboard/settings Currency Preferences) ### 3. Statistics & Grid Integration - [ ] **TF Grid Statistics** diff --git a/src/controllers/dashboard.rs b/src/controllers/dashboard.rs index 24b4f9e..b548591 100644 --- a/src/controllers/dashboard.rs +++ b/src/controllers/dashboard.rs @@ -734,7 +734,7 @@ impl DashboardController { if let Ok(Some(user_email)) = session.get::("user_email") { ctx.insert("user_email", &user_email); if let Some(user_data) = crate::services::user_persistence::UserPersistence::load_user_data(&user_email) { - ctx.insert("user_display_currency", &user_data.display_currency.unwrap_or_else(|| "USD".to_string())); + ctx.insert("user_display_currency", &user_data.display_currency.unwrap_or_else(|| "MC".to_string())); ctx.insert("user_quick_topup_amounts", &user_data.quick_topup_amounts.unwrap_or_else(|| vec![ rust_decimal_macros::dec!(10), rust_decimal_macros::dec!(25), @@ -743,7 +743,7 @@ impl DashboardController { ])); } else { // Default values if no persistent data found - ctx.insert("user_display_currency", &"USD".to_string()); + ctx.insert("user_display_currency", &"MC".to_string()); ctx.insert("user_quick_topup_amounts", &vec![ rust_decimal_macros::dec!(10), rust_decimal_macros::dec!(25), diff --git a/src/controllers/wallet.rs b/src/controllers/wallet.rs index 8c008e1..a7bb7fb 100644 --- a/src/controllers/wallet.rs +++ b/src/controllers/wallet.rs @@ -180,9 +180,9 @@ impl WalletController { let (currency, effective_currency) = match currency_service.get_currency(&display_currency) { Some(c) => (c, display_currency.clone()), None => { - let usd = currency_service.get_currency("USD").expect("USD currency must be available"); - display_currency = "USD".to_string(); - (usd, "USD".to_string()) + let mc = currency_service.get_currency("MC").expect("MC currency must be available"); + display_currency = "MC".to_string(); + (mc, "MC".to_string()) } }; @@ -258,9 +258,9 @@ impl WalletController { let (currency, effective_currency) = match currency_service.get_currency(&display_currency) { Some(c) => (c, display_currency.clone()), None => { - let usd = currency_service.get_currency("USD").expect("USD currency must be available"); - display_currency = "USD".to_string(); - (usd, "USD".to_string()) + let mc = currency_service.get_currency("MC").expect("MC currency must be available"); + display_currency = "MC".to_string(); + (mc, "MC".to_string()) } }; diff --git a/src/models/builders.rs b/src/models/builders.rs index 36309c2..b5e8bcf 100644 --- a/src/models/builders.rs +++ b/src/models/builders.rs @@ -886,7 +886,7 @@ impl CurrencyServiceBuilder { return Err("Base currency cannot be empty".to_string()); } - let display_currency = self.display_currency.unwrap_or_else(|| "USD".to_string()); + let display_currency = self.display_currency.unwrap_or_else(|| "MC".to_string()); Ok(crate::services::currency::CurrencyService::new_with_display_config( cache_duration, @@ -1225,7 +1225,7 @@ impl SessionDataBuilder { name: self.name, country: self.country, timezone: self.timezone, - display_currency: Some("USD".to_string()), + display_currency: Some("MC".to_string()), quick_topup_amounts: Some(vec![dec!(10), dec!(25), dec!(50), dec!(100)]), ..Default::default() } diff --git a/src/services/instant_purchase.rs b/src/services/instant_purchase.rs index cb45aad..809af6c 100644 --- a/src/services/instant_purchase.rs +++ b/src/services/instant_purchase.rs @@ -325,7 +325,7 @@ impl InstantPurchaseService { let mut persistent_data = UserPersistence::load_user_data(&user_email) .unwrap_or_else(|| crate::services::user_persistence::UserPersistentData { user_email: user_email.clone(), - display_currency: Some("USD".to_string()), + display_currency: Some("MC".to_string()), quick_topup_amounts: Some(vec![dec!(10), dec!(25), dec!(50), dec!(100)]), ..Default::default() }); diff --git a/src/services/navbar.rs b/src/services/navbar.rs index 191ef1f..db23413 100644 --- a/src/services/navbar.rs +++ b/src/services/navbar.rs @@ -79,16 +79,16 @@ impl NavbarService { // Get user's preferred display currency let mut display_currency = self.currency_service.get_user_preferred_currency(session); - // Get currency info for formatting; fall back to USD if invalid + // Get currency info for formatting; fall back to MC if invalid let (currency, effective_currency) = match self.currency_service.get_currency(&display_currency) { Some(c) => (c, display_currency.clone()), None => { - let usd = self + let mc = self .currency_service - .get_currency("USD") - .expect("USD currency must be available"); - display_currency = "USD".to_string(); - (usd, "USD".to_string()) + .get_currency("MC") + .expect("MC currency must be available"); + display_currency = "MC".to_string(); + (mc, "MC".to_string()) } }; @@ -150,8 +150,8 @@ impl NavbarService { user_email: String::new(), wallet_balance: Decimal::ZERO, wallet_balance_formatted: "Not logged in".to_string(), - display_currency: "USD".to_string(), - currency_symbol: "$".to_string(), + display_currency: "MC".to_string(), + currency_symbol: "⚡".to_string(), quick_actions: vec![ QuickAction { id: "login".to_string(), diff --git a/src/services/user_persistence.rs b/src/services/user_persistence.rs index 9d5026a..107d63a 100644 --- a/src/services/user_persistence.rs +++ b/src/services/user_persistence.rs @@ -1352,7 +1352,7 @@ impl UserPersistence { UserPersistentData { user_email: user_email.to_string(), wallet_balance_usd: dec!(0), - display_currency: Some("USD".to_string()), + display_currency: Some("MC".to_string()), quick_topup_amounts: Some(vec![dec!(10), dec!(25), dec!(50), dec!(100)]), ..Default::default() } @@ -1363,7 +1363,7 @@ impl UserPersistence { UserPersistentData { user_email: user_email.to_string(), wallet_balance_usd: balance, - display_currency: Some("USD".to_string()), + display_currency: Some("MC".to_string()), quick_topup_amounts: Some(vec![dec!(10), dec!(25), dec!(50), dec!(100)]), ..Default::default() } diff --git a/src/static/js/dashboard_cart.js b/src/static/js/dashboard_cart.js index 30001eb..f26f0f4 100644 --- a/src/static/js/dashboard_cart.js +++ b/src/static/js/dashboard_cart.js @@ -15,8 +15,8 @@ } const hyd = readHydration('hydration-dashboard-cart'); - const currencySymbol = (hyd && hyd.currency_symbol) || '$'; - const displayCurrency = (hyd && hyd.display_currency) || 'USD'; + const currencySymbol = (hyd && hyd.currency_symbol) || '⚡'; + const displayCurrency = (hyd && hyd.display_currency) || 'MC'; const showToast = (window.showToast) ? window.showToast : function (msg, type) { // Fallback: log to console in case toast helper isn't available diff --git a/src/static/js/dashboard_orders.js b/src/static/js/dashboard_orders.js index 69d881c..fb02a59 100644 --- a/src/static/js/dashboard_orders.js +++ b/src/static/js/dashboard_orders.js @@ -2,7 +2,7 @@ (function () { 'use strict'; - let HYDRATION = { currency_symbol: '$', display_currency: 'USD' }; + let HYDRATION = { currency_symbol: '⚡', display_currency: 'MC' }; function parseHydration() { try { diff --git a/src/static/js/dashboard_wallet.js b/src/static/js/dashboard_wallet.js index 137b60b..d16c734 100644 --- a/src/static/js/dashboard_wallet.js +++ b/src/static/js/dashboard_wallet.js @@ -15,8 +15,8 @@ } const hyd = readHydration('wallet-hydration'); - const currencySymbol = (hyd && hyd.currency_symbol) || '$'; - const displayCurrency = (hyd && hyd.display_currency) || 'USD'; + const currencySymbol = (hyd && hyd.currency_symbol) || '⚡'; + const displayCurrency = (hyd && hyd.display_currency) || 'MC'; function showSuccessToast(message) { try { diff --git a/src/views/dashboard/cart.html b/src/views/dashboard/cart.html index eef5683..325e243 100644 --- a/src/views/dashboard/cart.html +++ b/src/views/dashboard/cart.html @@ -73,7 +73,7 @@
- Your {{ display_currency | default(value="USD") }} Credits: + Your {{ display_currency | default(value="MC") }} Credits: {{ currency_symbol | default(value="$") }}0.00
@@ -197,7 +197,7 @@ {% endblock %} diff --git a/src/views/dashboard/index.html b/src/views/dashboard/index.html index 1af0c50..8416214 100644 --- a/src/views/dashboard/index.html +++ b/src/views/dashboard/index.html @@ -50,7 +50,7 @@
Wallet Balance

{{ currency_symbol | default(value="$") }}{% if user_metrics is defined and user_metrics.wallet_balance is defined %}{{ user_metrics.wallet_balance | format_decimal(precision=2) }}{% else %}0{% endif %}

- Credits ({{ display_currency | default(value="USD") }}) + Credits ({{ display_currency | default(value="MC") }})
@@ -266,7 +266,7 @@ diff --git a/src/views/dashboard/wallet.html b/src/views/dashboard/wallet.html index 23c2b65..08a4e72 100644 --- a/src/views/dashboard/wallet.html +++ b/src/views/dashboard/wallet.html @@ -20,7 +20,7 @@ {{ currency_symbol | default(value="$") }}0.00 {% endif %} - Credits ({{ display_currency | default(value="USD") }}) + Credits ({{ display_currency | default(value="MC") }}) @@ -270,7 +270,7 @@
- Rate: 1 Credit = {{ currency_symbol | default(value="$") }}1 {{ display_currency | default(value="USD") }}
+ Rate: 1 Credit = {{ currency_symbol | default(value="⚡") }}1 {{ display_currency | default(value="MC") }}
Total Cost: {{ currency_symbol | default(value="$") }}0.00
@@ -435,7 +435,7 @@ diff --git a/user_data/user111_at_example_com.json b/user_data/user111_at_example_com.json new file mode 100644 index 0000000..2ea3310 --- /dev/null +++ b/user_data/user111_at_example_com.json @@ -0,0 +1,49 @@ +{ + "user_email": "user111@example.com", + "wallet_balance_usd": 0.0, + "transactions": [], + "staked_amount_usd": 0.0, + "pool_positions": {}, + "name": "user111", + "country": null, + "timezone": null, + "password_hash": "$2b$12$0I0taABmXC9qgK/oe1ynjO/eVIG4sdguLm6DLQffvbjU33jkSe6Ti", + "services": [], + "service_requests": [], + "service_bookings": [], + "availability": null, + "slas": [], + "apps": [], + "application_deployments": [], + "deleted": null, + "deleted_at": null, + "deletion_reason": null, + "nodes": [], + "resource_provider_earnings": [], + "resource_provider_settings": null, + "slice_products": [], + "user_activities": [], + "user_preferences": null, + "usage_statistics": null, + "orders": [], + "active_product_rentals": [], + "resource_provider_rental_earnings": [], + "node_rentals": [], + "node_groups": [], + "slice_rentals": [], + "slice_assignments": [], + "display_currency": "MC", + "quick_topup_amounts": [ + 10.0, + 25.0, + 50.0, + 100.0 + ], + "auto_topup_settings": null, + "products": [], + "owned_products": [], + "owned_product_ids": [], + "ssh_keys": [], + "message_threads": null, + "messages": null +} \ No newline at end of file diff --git a/user_data/user321_at_example_com.json b/user_data/user321_at_example_com.json new file mode 100644 index 0000000..a753663 --- /dev/null +++ b/user_data/user321_at_example_com.json @@ -0,0 +1,49 @@ +{ + "user_email": "user321@example.com", + "wallet_balance_usd": 0.0, + "transactions": [], + "staked_amount_usd": 0.0, + "pool_positions": {}, + "name": "user321", + "country": null, + "timezone": null, + "password_hash": "$2b$12$3I5q1NB/ukv2isB6p5RN1ecn6Wkb92gmD2O5gzQ8YF3veOLUa1JXu", + "services": [], + "service_requests": [], + "service_bookings": [], + "availability": null, + "slas": [], + "apps": [], + "application_deployments": [], + "deleted": null, + "deleted_at": null, + "deletion_reason": null, + "nodes": [], + "resource_provider_earnings": [], + "resource_provider_settings": null, + "slice_products": [], + "user_activities": [], + "user_preferences": null, + "usage_statistics": null, + "orders": [], + "active_product_rentals": [], + "resource_provider_rental_earnings": [], + "node_rentals": [], + "node_groups": [], + "slice_rentals": [], + "slice_assignments": [], + "display_currency": "MC", + "quick_topup_amounts": [ + 10.0, + 25.0, + 50.0, + 100.0 + ], + "auto_topup_settings": null, + "products": [], + "owned_products": [], + "owned_product_ids": [], + "ssh_keys": [], + "message_threads": null, + "messages": null +} \ No newline at end of file