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
3 changes: 2 additions & 1 deletion contracts/predictify-hybrid/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2405,12 +2405,13 @@ impl EventEmitter {
outcomes: &Vec<String>,
admin: &Address,
end_time: u64,
creation_fee_amount: i128,
) {
let event = EventCreatedEvent {
event_id: event_id.clone(),
description: description.clone(),
outcomes: outcomes.clone(),
creation_fee_amount: crate::fees::MARKET_CREATION_FEE,
creation_fee_amount,
admin: admin.clone(),
end_time,
nonce: Self::get_and_increment_nonce(env, symbol_short!("evt_crt").clone()),
Expand Down
11 changes: 11 additions & 0 deletions contracts/predictify-hybrid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,10 @@ impl PredictifyHybrid {
panic_with_error!(env, Error::InvalidQuestion);
}

if end_time <= env.ledger().timestamp() {
panic_with_error!(env, Error::InvalidDuration);
}

// Validate oracle configuration
if let Err(e) = oracle_config.validate(&env) {
panic_with_error!(env, e);
Expand All @@ -825,6 +829,12 @@ impl PredictifyHybrid {
None => (false, OracleConfig::none_sentinel(&env)),
};

// Charge creation fee after validation
let creation_fee_amount = match crate::fees::FeeManager::process_creation_fee(&env, &admin) {
Ok(fee) => fee,
Err(e) => panic_with_error!(env, e),
};

// Create a new event
let event = Event {
id: event_id.clone(),
Expand Down Expand Up @@ -853,6 +863,7 @@ impl PredictifyHybrid {
&outcomes,
&admin,
end_time,
creation_fee_amount,
);

// Record statistics
Expand Down
Loading