Skip to content

Commit

Permalink
remove old loans migration
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Mar 15, 2024
1 parent a4eb604 commit 5997323
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 178 deletions.
59 changes: 0 additions & 59 deletions pallets/loans/src/entities/loans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,62 +580,3 @@ impl<T: Config> TryFrom<(T::PoolId, ActiveLoan<T>)> for ActiveLoanInfo<T> {
})
}
}

/// Migration module that contains old loans types.
/// Can be removed once chains contains pallet-loans version v3
pub(crate) mod v2 {
use cfg_traits::Seconds;
use parity_scale_codec::Decode;

use crate::{
entities::pricing::{external::v2::ExternalActivePricing, internal::InternalActivePricing},
types::{LoanRestrictions, RepaidAmount, RepaymentSchedule},
AssetOf, Config,
};

#[derive(Decode)]
pub enum ActivePricing<T: Config> {
Internal(InternalActivePricing<T>),
External(ExternalActivePricing<T>),
}

#[derive(Decode)]
pub struct ActiveLoan<T: Config> {
schedule: RepaymentSchedule,
collateral: AssetOf<T>,
restrictions: LoanRestrictions,
borrower: T::AccountId,
write_off_percentage: T::Rate,
origination_date: Seconds,
pricing: ActivePricing<T>,
total_borrowed: T::Balance,
total_repaid: RepaidAmount<T::Balance>,
repayments_on_schedule_until: Seconds,
}

impl<T: Config> ActiveLoan<T> {
pub fn migrate(self) -> crate::entities::loans::ActiveLoan<T> {
crate::entities::loans::ActiveLoan {
schedule: self.schedule,
collateral: self.collateral,
restrictions: self.restrictions,
borrower: self.borrower,
write_off_percentage: self.write_off_percentage,
origination_date: self.origination_date,
pricing: match self.pricing {
ActivePricing::Internal(inner) => {
crate::entities::pricing::ActivePricing::Internal(inner)
}
ActivePricing::External(inner) => {
crate::entities::pricing::ActivePricing::External(
inner.migrate(self.origination_date),
)
}
},
total_borrowed: self.total_borrowed,
total_repaid: self.total_repaid,
repayments_on_schedule_until: self.repayments_on_schedule_until,
}
}
}
}
35 changes: 0 additions & 35 deletions pallets/loans/src/entities/pricing/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,38 +288,3 @@ impl<T: Config> ExternalActivePricing<T> {
Ok(())
}
}

/// Migration module that contains old loans types.
/// Can be removed once chains contains pallet-loans version v3
pub(crate) mod v2 {
use cfg_traits::Seconds;
use parity_scale_codec::Decode;

use crate::{
entities::{interest::ActiveInterestRate, pricing::external::ExternalPricing},
Config,
};

#[derive(Decode)]
pub struct ExternalActivePricing<T: Config> {
info: ExternalPricing<T>,
outstanding_quantity: T::Quantity,
interest: ActiveInterestRate<T>,
latest_settlement_price: T::Balance,
}

impl<T: Config> ExternalActivePricing<T> {
pub fn migrate(
self,
settlement_price_updated: Seconds,
) -> crate::entities::pricing::external::ExternalActivePricing<T> {
crate::entities::pricing::external::ExternalActivePricing {
info: self.info,
outstanding_quantity: self.outstanding_quantity,
interest: self.interest,
latest_settlement_price: self.latest_settlement_price,
settlement_price_updated,
}
}
}
}
9 changes: 0 additions & 9 deletions pallets/loans/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ mod tests;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarking;

mod migrations;

pub use pallet::*;
pub use weights::WeightInfo;

Expand Down Expand Up @@ -438,13 +436,6 @@ pub mod pallet {
}
}

#[pallet::hooks]
impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
migrations::migrate_from_v2_to_v3::<T>()
}
}

#[pallet::call]
impl<T: Config> Pallet<T> {
/// Creates a new loan against the collateral provided
Expand Down
75 changes: 0 additions & 75 deletions pallets/loans/src/migrations.rs

This file was deleted.

0 comments on commit 5997323

Please sign in to comment.