Skip to content

Commit

Permalink
Use PaymentId from common in payments pallet
Browse files Browse the repository at this point in the history
  • Loading branch information
olanod committed Feb 7, 2024
1 parent dec9f1e commit fbea3ef
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pallets/payments/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ pub mod pallet {
_,
(
NMapKey<Blake2_128Concat, T::AccountId>,
NMapKey<Blake2_128Concat, T::AccountId>,
// NMapKey<Blake2_128Concat, T::AccountId>,
NMapKey<Blake2_128Concat, T::PaymentId>,
),
PaymentDetail<T>,
Expand Down Expand Up @@ -313,18 +313,17 @@ pub mod pallet {
#[pallet::weight(<T as Config>::WeightInfo::release())]
pub fn release(
origin: OriginFor<T>,
beneficiary: AccountIdLookupOf<T>,
// beneficiary: AccountIdLookupOf<T>,
payment_id: T::PaymentId,
) -> DispatchResultWithPostInfo {
let sender = ensure_signed(origin)?;
let beneficiary = T::Lookup::lookup(beneficiary)?;
// let beneficiary = T::Lookup::lookup(beneficiary)?;

// ensure the payment is in Created state
let payment =
Payment::<T>::get((&sender, &beneficiary, &payment_id)).map_err(|_| Error::<T>::InvalidPayment)?;
let payment = Payment::<T>::get((&sender, &payment_id)).map_err(|_| Error::<T>::InvalidPayment)?;
ensure!(payment.state == PaymentState::Created, Error::<T>::InvalidAction);

Self::settle_payment(&sender, &beneficiary, &payment_id, None)?;
Self::settle_payment(&sender, &payment_id, None)?;

Self::deposit_event(Event::PaymentReleased { sender, beneficiary });
Ok(().into())
Expand Down

0 comments on commit fbea3ef

Please sign in to comment.