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
44 changes: 44 additions & 0 deletions Contract/earn-quest/src/assets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use soroban_sdk::{contracttype, Address, Env, Symbol};

use crate::errors::Error;

/// Supported asset types for multi-asset quest rewards
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum AssetType {
/// Native Stellar XLM token
Native,
/// USDC stablecoin
Usdc,
/// Custom project or community token
Custom,
}

/// Configuration for a supported reward asset
#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct AssetConfig {
/// On-chain address of the token contract
pub address: Address,
/// Classification of the asset
pub asset_type: AssetType,
/// Minimum allowed reward amount in the token's base unit
pub min_amount: i128,
}

/// Return the canonical symbol string for a given asset type
pub fn asset_symbol(env: &Env, asset_type: &AssetType) -> Symbol {
match asset_type {
AssetType::Native => Symbol::new(env, "XLM"),
AssetType::Usdc => Symbol::new(env, "USDC"),
AssetType::Custom => Symbol::new(env, "CUSTOM"),
}
}

/// Validate that a proposed reward amount satisfies the asset's minimum requirement
pub fn validate_reward_amount(config: &AssetConfig, amount: i128) -> Result<(), Error> {
if amount <= 0 || amount < config.min_amount {
return Err(Error::InvalidRewardAmount);
}
Ok(())
}
1 change: 1 addition & 0 deletions Contract/earn-quest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use soroban_sdk::{contract, contractimpl, Address, BytesN, Env, Symbol};

mod admin;
pub mod assets;
mod errors;
mod escrow;
mod init;
Expand Down
Loading