Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove getters in prices. #1367

Merged
merged 1 commit into from
Aug 15, 2024
Merged
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
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