Skip to content

Commit

Permalink
fix unwrap error
Browse files Browse the repository at this point in the history
  • Loading branch information
alyn509 committed Oct 4, 2024
1 parent 075bfbd commit 980745f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions contracts/core/price-aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,11 @@ pub trait PriceAggregator:
last_sub_time_mapper.set(current_timestamp);

self.create_new_round(token_pair.clone(), submissions, decimals);
let round_id = self.rounds().get(&token_pair).unwrap().len();
let wrapped_rounds = self.rounds().get(&token_pair);
let mut round_id = 0;
if wrapped_rounds.is_some() {
round_id = wrapped_rounds.unwrap().len();
}
self.add_submission_event(&caller, &price, round_id);
}

Expand Down Expand Up @@ -285,7 +289,11 @@ pub trait PriceAggregator:
.push(&price_feed);
self.emit_new_round_event(&token_pair, &price_feed);
} else {
let round_id = self.rounds().get(&token_pair).unwrap().len();
let wrapped_rounds = self.rounds().get(&token_pair);
let mut round_id = 0;
if wrapped_rounds.is_some() {
round_id = wrapped_rounds.unwrap().len();
}
self.discard_round_event(&token_pair.from.clone(), &token_pair.to.clone(), round_id);
}
}
Expand Down

0 comments on commit 980745f

Please sign in to comment.