Skip to content

Commit dbc2002

Browse files
authored
Merge pull request #370 from CHEF-SAVY/fix/issue-76-deposit-release-auth
fix: restrict creation deposit release to the market creator
2 parents 90be195 + 6f323cd commit dbc2002

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

contracts/predict-iq/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,9 @@ impl PredictIQ {
290290
pub fn claim_creation_deposit(
291291
e: Env,
292292
market_id: u64,
293+
caller: Address,
293294
) -> Result<(), ErrorCode> {
294-
crate::modules::markets::claim_creation_deposit(&e, market_id)
295+
crate::modules::markets::claim_creation_deposit(&e, market_id, caller)
295296
}
296297

297298
// Governance and Upgrade Functions

contracts/predict-iq/src/modules/markets.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,15 @@ pub fn set_creation_deposit(e: &Env, amount: i128) -> Result<(), ErrorCode> {
331331
pub fn claim_creation_deposit(
332332
e: &Env,
333333
market_id: u64,
334+
caller: soroban_sdk::Address,
334335
) -> Result<(), ErrorCode> {
335336
let mut market = get_market(e, market_id).ok_or(ErrorCode::MarketNotFound)?;
336337

337-
// 1. Only the creator can claim their own deposit
338-
market.creator.require_auth();
338+
// Only the creator can claim their own deposit
339+
if caller != market.creator {
340+
return Err(ErrorCode::NotAuthorized);
341+
}
342+
caller.require_auth();
339343

340344
// 2. Market must be fully resolved
341345
if market.status != MarketStatus::Resolved {

0 commit comments

Comments
 (0)