Skip to content

Commit

Permalink
function renames. docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed Jun 6, 2023
1 parent ea33169 commit 8142091
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
29 changes: 15 additions & 14 deletions pallets/loans-ref/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
//!
//! The following actions are performed over loans:
//!
//! | Extrinsics | Role |
//! |------------------------------------|-----------|
//! | [`Pallet::create()`] | Borrower |
//! | [`Pallet::borrow()`] | Borrower |
//! | [`Pallet::repay()`] | Borrower |
//! | [`Pallet::write_off()`] | Any |
//! | [`Pallet::admin_write_off()`] | LoanAdmin |
//! | [`Pallet::close()`] | Borrower |
//! | Extrinsics | Role |
//! |-------------------------------|-----------|
//! | [`Pallet::create()`] | Borrower |
//! | [`Pallet::borrow()`] | Borrower |
//! | [`Pallet::repay()`] | Borrower |
//! | [`Pallet::write_off()`] | Any |
//! | [`Pallet::admin_write_off()`] | LoanAdmin |
//! | [`Pallet::close()`] | Borrower |
//!
//! The following actions are performed over a pool of loans:
//!
Expand All @@ -35,10 +35,10 @@
//!
//! The following actions are performed based on changes:
//!
//! | Extrinsics | Role |
//! |--------------------------------|-----------|
//! | [`Pallet::propose_change()`] | LoanAdmin |
//! | [`Pallet::apply_change()`] | Borrower |
//! | Extrinsics | Role |
//! |------------------------------|-----------|
//! | [`Pallet::propose_change()`] | LoanAdmin |
//! | [`Pallet::apply_change()`] | |
//!
//! The whole pallet is optimized for the more expensive extrinsic that is
//! [`Pallet::update_portfolio_valuation()`] that should go through all active
Expand Down Expand Up @@ -717,7 +717,8 @@ pub mod pallet {
}

/// Propose a change.
/// The change is not performed until you call [`Pallet::modify()`].
/// The change is not performed until you call
/// [`Pallet::apply_change()`].
#[pallet::weight(100_000_000)]
#[pallet::call_index(8)]
pub fn propose_change(
Expand Down Expand Up @@ -748,7 +749,7 @@ pub mod pallet {
let Change::Loan(loan_id, mutation) = T::ChangeGuard::released(pool_id, change_id)?;

let (_, _count) = Self::update_active_loan(pool_id, loan_id, |loan| {
loan.modify_with(mutation.clone())
loan.mutate_with(mutation.clone())
})?;

Self::deposit_event(Event::<T>::Modified {
Expand Down
4 changes: 2 additions & 2 deletions pallets/loans-ref/src/loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,13 +411,13 @@ impl<T: Config> ActiveLoan<T> {
Ok((loan, self.borrower))
}

pub fn modify_with(&mut self, mutation: LoanMutation<T::Rate>) -> DispatchResult {
pub fn mutate_with(&mut self, mutation: LoanMutation<T::Rate>) -> DispatchResult {
match mutation {
LoanMutation::Maturity(maturity) => self.schedule.maturity = maturity,
LoanMutation::InterestPayments(payments) => self.schedule.interest_payments = payments,
LoanMutation::PayDownSchedule(schedule) => self.schedule.pay_down_schedule = schedule,
LoanMutation::Internal(mutation) => match &mut self.pricing {
ActivePricing::Internal(inner) => inner.modify_with(mutation)?,
ActivePricing::Internal(inner) => inner.mutate_with(mutation)?,
ActivePricing::External(_) => {
Err(Error::<T>::from(ModificationError::InternalPricingExpected))?
}
Expand Down
2 changes: 1 addition & 1 deletion pallets/loans-ref/src/pricing/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl<T: Config> InternalActivePricing<T> {
}
}

pub fn modify_with(&mut self, mutation: InternalMutation<T::Rate>) -> DispatchResult {
pub fn mutate_with(&mut self, mutation: InternalMutation<T::Rate>) -> DispatchResult {
match mutation {
InternalMutation::InterestRate(rate) => {
let new_interest_rate = rate.ensure_add(self.write_off_penalty)?;
Expand Down

0 comments on commit 8142091

Please sign in to comment.