Skip to content

Commit

Permalink
Remove getters in prices (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
MJLNSN authored Aug 15, 2024
1 parent 53efdc6 commit be28046
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pallets/prices/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@ pub mod pallet {

/// Mapping from currency id to it's emergency price
#[pallet::storage]
#[pallet::getter(fn emergency_price)]
pub type EmergencyPrice<T: Config> =
StorageMap<_, Twox64Concat, CurrencyId, Price, OptionQuery>;

/// Mapping from foreign vault token to our's vault token
#[pallet::storage]
#[pallet::getter(fn foreign_to_native_asset)]
pub type ForeignToNativeAsset<T: Config> =
StorageMap<_, Twox64Concat, CurrencyId, CurrencyId, OptionQuery>;

Expand Down Expand Up @@ -181,7 +179,7 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
// get emergency price, the timestamp is zero
fn get_emergency_price(asset_id: &CurrencyId) -> Option<PriceDetail> {
Self::emergency_price(asset_id).and_then(|p| {
EmergencyPrice::<T>::get(asset_id).and_then(|p| {
let mantissa = Self::get_asset_mantissa(asset_id)?;
log::trace!(
target: "prices::get_emergency_price",
Expand Down Expand Up @@ -241,7 +239,7 @@ impl<T: Config> PriceFeeder for Pallet<T> {

fn get_normal_price(asset_id: &CurrencyId) -> Option<u128> {
let decimals = Self::get_asset_mantissa(asset_id)?;
Self::emergency_price(asset_id)
EmergencyPrice::<T>::get(asset_id)
.and_then(|p| Some(p.into_inner().saturating_div(decimals)))
.or_else(|| {
T::Source::get(&asset_id)
Expand Down

0 comments on commit be28046

Please sign in to comment.