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
14 changes: 14 additions & 0 deletions contracts/teachlink/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ pub enum RewardsError {
RateCannotBeNegative = 305,
}

/// Mobile platform module errors
#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum MobilePlatformError {
DeviceNotSupported = 400,
InsufficientStorage = 401,
NetworkUnavailable = 402,
AuthenticationFailed = 403,
SyncFailed = 404,
PaymentFailed = 405,
SecurityViolation = 406,
FeatureNotAvailable = 407,
}

/// Common errors that can be used across modules
#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
Expand Down
88 changes: 86 additions & 2 deletions contracts/teachlink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod events;
// mod learning_paths;
mod liquidity;
mod message_passing;
// mod mobile_platform;
mod mobile_platform;
mod multichain;
mod notification;
mod notification_events_basic;
Expand All @@ -126,7 +126,12 @@ mod tokenization;
mod types;
pub mod validation;

pub use errors::{BridgeError, EscrowError, RewardsError};
pub use crate::types::{
ColorBlindMode, ComponentConfig, DeviceInfo, FeedbackCategory, FocusStyle, FontSize,
LayoutDensity, MobileAccessibilitySettings, MobilePreferences, MobileProfile, NetworkType,
OnboardingStage, OnboardingStatus, ThemePreference, UserFeedback, VideoQuality,
};
pub use errors::{BridgeError, EscrowError, MobilePlatformError, RewardsError};
pub use types::{
AlertConditionType, AlertRule, ArbitratorProfile, AtomicSwap, AuditRecord, BackupManifest,
BackupSchedule, BridgeMetrics, BridgeProposal, BridgeTransaction, CachedBridgeSummary,
Expand Down Expand Up @@ -1303,6 +1308,85 @@ impl TeachLinkBridge {
notification::NotificationManager::send_notification(&env, recipient, channel, content)
}

// ========== Mobile UI/UX Functions ==========

/// Initialize mobile profile for user
pub fn initialize_mobile_profile(
env: Env,
user: Address,
device_info: DeviceInfo,
preferences: MobilePreferences,
) -> Result<(), MobilePlatformError> {
mobile_platform::MobilePlatformManager::initialize_mobile_profile(
&env, user, device_info, preferences
).map_err(|_| MobilePlatformError::DeviceNotSupported)
}

/// Update accessibility settings
pub fn update_accessibility_settings(
env: Env,
user: Address,
settings: MobileAccessibilitySettings,
) -> Result<(), MobilePlatformError> {
mobile_platform::MobilePlatformManager::update_accessibility_settings(
&env, user, settings
).map_err(|_| MobilePlatformError::DeviceNotSupported)
}

/// Update personalization settings
pub fn update_personalization(
env: Env,
user: Address,
preferences: MobilePreferences,
) -> Result<(), MobilePlatformError> {
mobile_platform::MobilePlatformManager::update_personalization(
&env, user, preferences
).map_err(|_| MobilePlatformError::DeviceNotSupported)
}

/// Record onboarding progress
pub fn record_onboarding_progress(
env: Env,
user: Address,
stage: OnboardingStage,
) -> Result<(), MobilePlatformError> {
mobile_platform::MobilePlatformManager::record_onboarding_progress(
&env, user, stage
).map_err(|_| MobilePlatformError::DeviceNotSupported)
}

/// Submit user feedback
pub fn submit_user_feedback(
env: Env,
user: Address,
rating: u32,
comment: Bytes,
category: FeedbackCategory,
) -> Result<u64, MobilePlatformError> {
mobile_platform::MobilePlatformManager::submit_user_feedback(
&env, user, rating, comment, category
).map_err(|_| MobilePlatformError::DeviceNotSupported)
}

/// Get user allocated experiment variants
pub fn get_user_experiment_variants(
env: Env,
user: Address,
) -> Map<u64, Symbol> {
mobile_platform::MobilePlatformManager::get_user_experiment_variants(&env, user)
}

/// Get design system configuration
pub fn get_design_system_config(env: Env) -> ComponentConfig {
mobile_platform::MobilePlatformManager::get_design_system_config(&env)
}

/// Set design system configuration (admin only)
pub fn set_design_system_config(env: Env, config: ComponentConfig) {
// In a real implementation, we would check for admin authorization here
mobile_platform::MobilePlatformManager::set_design_system_config(&env, config)
}

/// Schedule notification for future delivery
pub fn schedule_notification(
env: Env,
Expand Down
Loading