Skip to content

Commit

Permalink
a few u32 vs usize conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
alyn509 committed Oct 9, 2024
1 parent 2250319 commit 29f4029
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 5 additions & 5 deletions contracts/core/price-aggregator/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ multiversx_sc::imports!();
multiversx_sc::derive_imports!();

use crate::price_aggregator_data::{TimestampedPrice, TokenPair};
pub type RoundId = usize;
pub type RoundId = u32;
pub type Round = usize;
pub type Block = u64;
pub type Epoch = u64;
Expand Down Expand Up @@ -31,14 +31,14 @@ pub trait EventsModule {
fn emit_new_round_event(
&self,
token_pair: &TokenPair<Self::Api>,
round_id: RoundId,
round: Round,
price_feed: &TimestampedPrice<Self::Api>,
) {
let epoch = self.blockchain().get_block_epoch();
self.new_round_event(
&token_pair.from.clone(),
&token_pair.to.clone(),
round_id,
round,
&NewRoundEvent {
price: price_feed.price.clone(),
timestamp: price_feed.timestamp,
Expand All @@ -61,15 +61,15 @@ pub trait EventsModule {
fn emit_discard_submission_event(
&self,
token_pair: &TokenPair<Self::Api>,
round_id: RoundId,
round: Round,
submission_timestamp: Timestamp,
first_submission_timestamp: Timestamp,
has_caller_already_submitted: bool,
) {
self.discard_submission_event(
&token_pair.from.clone(),
&token_pair.to.clone(),
round_id,
round,
&DiscardSubmissionEvent {
submission_timestamp,
first_submission_timestamp,
Expand Down
6 changes: 3 additions & 3 deletions contracts/core/price-aggregator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ mod events;
pub mod median;
pub mod price_aggregator_data;

use events::{RoundId, Timestamp};
use events::{Round, Timestamp};
use multiversx_sc_modules::staking;
use price_aggregator_data::{OracleStatus, PriceFeed, TimestampedPrice, TokenPair};

Expand Down Expand Up @@ -270,7 +270,7 @@ pub trait PriceAggregator:
fn create_new_round(
&self,
token_pair: TokenPair<Self::Api>,
round_id: RoundId,
round: Round,
mut submissions: MapMapper<ManagedAddress, BigUint>,
decimals: u8,
) {
Expand Down Expand Up @@ -304,7 +304,7 @@ pub trait PriceAggregator:
.or_default()
.get()
.push(&price_feed);
self.emit_new_round_event(&token_pair, round_id, &price_feed);
self.emit_new_round_event(&token_pair, round, &price_feed);
}
}

Expand Down
8 changes: 5 additions & 3 deletions contracts/core/price-aggregator/src/price_aggregator_data.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use crate::events::{RoundId, Timestamp};

multiversx_sc::imports!();
multiversx_sc::derive_imports!();

Expand All @@ -11,10 +13,10 @@ pub struct TokenPair<M: ManagedTypeApi> {
#[type_abi]
#[derive(NestedEncode, NestedDecode, TopEncode, TopDecode)]
pub struct PriceFeed<M: ManagedTypeApi> {
pub round_id: u32,
pub round_id: RoundId,
pub from: ManagedBuffer<M>,
pub to: ManagedBuffer<M>,
pub timestamp: u64,
pub timestamp: Timestamp,
pub price: BigUint<M>,
pub decimals: u8,
}
Expand All @@ -23,7 +25,7 @@ pub struct PriceFeed<M: ManagedTypeApi> {
#[derive(TopEncode, TopDecode, Debug, PartialEq, Eq)]
pub struct TimestampedPrice<M: ManagedTypeApi> {
pub price: BigUint<M>,
pub timestamp: u64,
pub timestamp: Timestamp,
pub decimals: u8,
}

Expand Down

0 comments on commit 29f4029

Please sign in to comment.