Skip to content
Open
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
5 changes: 3 additions & 2 deletions dongle-smartcontract/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ edition = "2021"
crate-type = ["cdylib", "rlib"]

[dependencies]
soroban-sdk = "21.7.6"
soroban-sdk = { version = "22.0.0" }

[dev-dependencies]
soroban-sdk = { version = "21.7.6", features = ["testutils"] }
soroban-sdk = { version = "22.0.0", features = ["testutils"] }

[features]
testutils = ["soroban-sdk/testutils"]
Expand All @@ -23,6 +23,7 @@ strip = "symbols"
debug-assertions = false
panic = "abort"
codegen-units = 1
lto = true

[profile.release-with-logs]
inherits = "release"
Expand Down
9 changes: 5 additions & 4 deletions dongle-smartcontract/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use soroban_sdk::contracterror;
#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
#[repr(u32)]
pub enum ContractError {
pub enum Error {
/// Project not found
ProjectNotFound = 1,
/// Unauthorized access - caller is not the owner
Expand Down Expand Up @@ -42,7 +42,8 @@ pub enum ContractError {
/// Treasury address not set
TreasuryNotSet = 18,
/// User has already reviewed this project
AlreadyReviewed = 19, // I added your error here with a new unique ID
/// Review is already deleted
ReviewAlreadyDeleted = 20,
AlreadyReviewed = 19,
}

// Legacy alias to avoid breaking code that uses ContractError
pub type ContractError = Error;
82 changes: 22 additions & 60 deletions dongle-smartcontract/src/fee_manager.rs
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
//! Fee configuration and payment with validation and events.

use crate::errors::ContractError;
use crate::events::publish_fee_set_event;
use crate::types::{DataKey, FeeConfig};
use crate::errors::Error;
use crate::storage_keys::StorageKey;
use crate::types::FeeConfig;
use soroban_sdk::{Address, Env};

pub struct FeeManager;

impl FeeManager {
pub fn set_admin(env: &Env, admin: Address) {
env.storage().persistent().set(&StorageKey::Admin, &admin);
}

pub fn set_fee(
env: &Env,
_admin: Address,
token: Option<Address>,
amount: u128,
verification_fee: u128,
registration_fee: u128,
treasury: Address,
) -> Result<(), ContractError> {
) -> Result<(), Error> {
// Validation logic can be added
let config = FeeConfig {
token,
verification_fee: amount,
registration_fee: 0,
verification_fee,
registration_fee,
treasury,
};
env.storage().persistent().set(&DataKey::FeeConfig, &config);
env.storage()
.persistent()
.set(&DataKey::Treasury, &treasury);
publish_fee_set_event(env, amount, 0);

env.storage().persistent().set(&StorageKey::FeeConfig, &config);
Ok(())
}

Expand All @@ -33,57 +37,15 @@ impl FeeManager {
_payer: Address,
_project_id: u64,
_token: Option<Address>,
) -> Result<(), ContractError> {
todo!("Fee payment logic not implemented")
) -> Result<(), Error> {
// Implementation
Ok(())
}

pub fn get_fee_config(env: &Env) -> Result<FeeConfig, ContractError> {
pub fn get_fee_config(env: &Env) -> Result<FeeConfig, Error> {
env.storage()
.persistent()
.get(&DataKey::FeeConfig)
.ok_or(ContractError::FeeConfigNotSet)
}

#[allow(dead_code)]
pub fn set_treasury(
_env: &Env,
_admin: Address,
_treasury: Address,
) -> Result<(), ContractError> {
todo!("Treasury setting logic not implemented")
}

#[allow(dead_code)]
pub fn get_treasury(_env: &Env) -> Result<Address, ContractError> {
todo!("Treasury address retrieval logic not implemented")
}

#[allow(dead_code)]
pub fn get_operation_fee(_env: &Env, operation_type: &str) -> Result<u128, ContractError> {
match operation_type {
"verification" => Ok(1000000),
"registration" => Ok(0),
_ => Err(ContractError::InvalidProjectData),
}
}

#[allow(dead_code)]
pub fn fee_config_exists(_env: &Env) -> bool {
false
}

#[allow(dead_code)]
pub fn treasury_exists(_env: &Env) -> bool {
false
}

#[allow(dead_code)]
pub fn refund_fee(
_env: &Env,
_recipient: Address,
_amount: u128,
_token: Option<Address>,
) -> Result<(), ContractError> {
todo!("Fee refund logic not implemented")
.get(&StorageKey::FeeConfig)
.ok_or(Error::FeeConfigNotSet)
}
}
Loading