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
8 changes: 5 additions & 3 deletions dongle-smartcontract/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use soroban_sdk::contracterror;

/// Error types for the Dongle smart contract
#[contracterror]
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
Expand Down Expand Up @@ -53,7 +52,10 @@ pub enum ContractError {
InvalidProjectDescriptionFormat = 23,
/// User has exceeded maximum number of projects allowed
MaxProjectsExceeded = 24,
/// Fee already paid for this project in the current verification cycle
FeeAlreadyPaid = 25,
/// Token provided does not match the configured payment token
InvalidToken = 26,
}

// Legacy alias to avoid breaking any code that uses `Error` directly
pub type Error = ContractError;
pub type Error = ContractError;
6 changes: 5 additions & 1 deletion dongle-smartcontract/src/fee_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ impl FeeManager {
.get(&StorageKey::Treasury)
.ok_or(ContractError::TreasuryNotSet)?;

if Self::is_fee_paid(env, project_id) {
return Err(ContractError::FeeAlreadyPaid);
}

if config.token != token {
return Err(ContractError::InvalidProjectData);
return Err(ContractError::InvalidToken);
}

let amount = config.verification_fee;
Expand Down
4 changes: 2 additions & 2 deletions dongle-smartcontract/src/tests/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use soroban_sdk::{testutils::Address as _, Address, Env, String, Vec};
///
/// This is the most basic setup function used by most tests.
pub fn setup_contract(env: &Env) -> (DongleContractClient<'_>, Address) {
let contract_id = env.register(DongleContract, ());
let contract_id = env.register_contract(None, DongleContract);
let client = DongleContractClient::new(env, &contract_id);

let admin = Address::generate(env);
Expand Down Expand Up @@ -87,4 +87,4 @@ pub fn assert_project_state(
assert_eq!(project.name, String::from_str(env, expected_name));
assert_eq!(project.owner, *expected_owner);
assert_eq!(project.verification_status, expected_status);
}
}
Loading
Loading