Skip to content

Commit

Permalink
No longer allow ResolveOrigin to report a market (#1266)
Browse files Browse the repository at this point in the history
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
maltekliemann and mergify[bot] authored Apr 5, 2024
1 parent b1af666 commit 415bef2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
12 changes: 3 additions & 9 deletions zrml/prediction-markets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3047,14 +3047,10 @@ mod pallet {
}

let sender_is_oracle = sender == market.oracle;
let origin_has_permission = T::ResolveOrigin::ensure_origin(origin).is_ok();
let sender_is_outsider = !sender_is_oracle && !origin_has_permission;
let sender_is_outsider = !sender_is_oracle;

if should_check_origin {
ensure!(
sender_is_oracle || origin_has_permission,
Error::<T>::ReporterNotOracle
);
ensure!(sender_is_oracle, Error::<T>::ReporterNotOracle);
} else if sender_is_outsider {
let outsider_bond = T::OutsiderBond::get();

Expand Down Expand Up @@ -3096,9 +3092,7 @@ mod pallet {
) -> DispatchResultWithPostInfo {
<zrml_market_commons::Pallet<T>>::mutate_market(&market_id, |market| {
let sender = ensure_signed(origin.clone())?;
let sender_is_oracle = sender == market.oracle;
let origin_has_permission = T::ResolveOrigin::ensure_origin(origin).is_ok();
ensure!(sender_is_oracle || origin_has_permission, Error::<T>::ReporterNotOracle);
ensure!(sender == market.oracle, Error::<T>::ReporterNotOracle);
market.report = Some(market_report.clone());
market.status = MarketStatus::Reported;
Ok(())
Expand Down
13 changes: 0 additions & 13 deletions zrml/prediction-markets/src/tests/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,6 @@ fn it_allows_to_report_the_outcome_of_a_market() {
assert_eq!(market_after.status, MarketStatus::Reported);
assert_eq!(report.outcome, OutcomeReport::Categorical(1));
assert_eq!(report.by, market_after.oracle);

// Reset and report again as approval origin
let _ = MarketCommons::mutate_market(&0, |market| {
market.status = MarketStatus::Closed;
market.report = None;
Ok(())
});

assert_ok!(PredictionMarkets::report(
RuntimeOrigin::signed(SUDO),
0,
OutcomeReport::Categorical(1)
));
});
}

Expand Down

0 comments on commit 415bef2

Please sign in to comment.