Skip to content

Commit

Permalink
move reward token id check after the contract check in OracleBoxWrapp…
Browse files Browse the repository at this point in the history
…er::new

to check the contract id before checking the reward token id #298;
  • Loading branch information
greenhat committed Jul 3, 2023
1 parent db174e0 commit 93db583
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions core/src/box_kind/oracle_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,6 @@ impl OracleBoxWrapper {
return Err(OracleBoxError::UnknownOracleTokenId);
}

let reward_token_id = b
.tokens
.as_ref()
.ok_or(OracleBoxError::NoTokens)?
.get(1)
.ok_or(OracleBoxError::NoRewardToken)?
.token_id;

if reward_token_id != inputs.reward_token_id.token_id() {
log::error!(
"found reward token id {reward_token_id:?} in oracle box but expected {expected_reward_token_id:?}",
reward_token_id = reward_token_id,
expected_reward_token_id = inputs.reward_token_id.token_id()
);
}

// We won't be analysing the actual address since there exists multiple oracle boxes that
// will be inputs for the 'refresh pool' operation.
let _ = b
Expand All @@ -128,6 +112,22 @@ impl OracleBoxWrapper {
contract: contract.clone(),
});

let reward_token_id = b
.tokens
.as_ref()
.ok_or(OracleBoxError::NoTokens)?
.get(1)
.ok_or(OracleBoxError::NoRewardToken)?
.token_id;

if reward_token_id != inputs.reward_token_id.token_id() {
log::error!(
"found reward token id {reward_token_id:?} in oracle box but expected {expected_reward_token_id:?}",
reward_token_id = reward_token_id,
expected_reward_token_id = inputs.reward_token_id.token_id()
);
}

let posted_oracle_box = OracleBoxWrapper::Posted(PostedOracleBox {
ergo_box: b,
contract,
Expand Down

0 comments on commit 93db583

Please sign in to comment.