Skip to content
Closed
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
11 changes: 4 additions & 7 deletions contracts/tholos-v2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ impl TholosV2 {
/// the new assertion id. Emits `Asserted`.
pub fn assert_outcome(env: Env, asserter: Address, outcome: bool) -> Result<u64, Error> {
asserter.require_auth();
Self::enter_reentrancy_guard(&env)?;
Self::require_not_paused(&env)?;

let policy: PolicySnapshotV2 = env
Expand All @@ -975,7 +976,6 @@ impl TholosV2 {
// not-yet-incremented id.
let id = Self::create_pending_assertion(&env, asserter.clone(), outcome)?;

Self::enter_reentrancy_guard(&env)?;
token::Client::new(&env, &policy.token).transfer(
&asserter,
env.current_contract_address(),
Expand Down Expand Up @@ -1039,7 +1039,6 @@ impl TholosV2 {
assertion.final_outcome = Some(assertion.outcome);
assertion.finalizer = Some(caller.clone());
Self::set_assertion(&env, id, &assertion);

Self::enter_reentrancy_guard(&env)?;
let token_client = token::Client::new(&env, &assertion.policy.token);
if reward > 0 {
Expand Down Expand Up @@ -1072,6 +1071,7 @@ impl TholosV2 {
/// Emits `Disputed`.
pub fn dispute(env: Env, disputer: Address, id: u64) -> Result<(), Error> {
disputer.require_auth();
Self::enter_reentrancy_guard(&env)?;

let mut assertion: AssertionV2 = env
.storage()
Expand Down Expand Up @@ -1138,7 +1138,6 @@ impl TholosV2 {
};
Self::set_resolution(&env, id, &resolution, &policy);

Self::enter_reentrancy_guard(&env)?;
token::Client::new(&env, &policy.token).transfer(
&disputer,
env.current_contract_address(),
Expand Down Expand Up @@ -1185,7 +1184,7 @@ impl TholosV2 {
commitment: BytesN<32>,
) -> Result<(), Error> {
voter.require_auth();

Self::enter_reentrancy_guard(&env)?;
let assertion: AssertionV2 = env
.storage()
.persistent()
Expand Down Expand Up @@ -1280,7 +1279,6 @@ impl TholosV2 {
resolution.eligible_total = new_total;
Self::set_resolution(&env, id, &resolution, &assertion.policy);

Self::enter_reentrancy_guard(&env)?;
token::Client::new(&env, &assertion.policy.token).transfer(
&voter,
env.current_contract_address(),
Expand Down Expand Up @@ -1973,7 +1971,7 @@ impl TholosV2 {
) -> Result<i128, Error> {
owner.require_auth();
Self::check_reentrancy_guard(&env)?;

Self::enter_reentrancy_guard(&env)?;
let assertion: AssertionV2 = env
.storage()
.persistent()
Expand Down Expand Up @@ -2015,7 +2013,6 @@ impl TholosV2 {
.ok_or(Error::SettlementArithmeticOverflow)?;
Self::set_resolution(&env, id, &resolution, &assertion.policy);

Self::enter_reentrancy_guard(&env)?;
token::Client::new(&env, &assertion.policy.token).transfer(
&env.current_contract_address(),
&destination,
Expand Down
Loading