diff --git a/frame/salary/src/lib.rs b/frame/salary/src/lib.rs index 0b2b4b47d8b70..1279a30717752 100644 --- a/frame/salary/src/lib.rs +++ b/frame/salary/src/lib.rs @@ -436,8 +436,8 @@ pub mod pallet { claimant.last_active = status.cycle_index; - let id = T::Paymaster::pay(&beneficiary, (), payout) - .map_err(|()| Error::::PayError)?; + let id = + T::Paymaster::pay(&beneficiary, (), payout).map_err(|_| Error::::PayError)?; claimant.status = Attempted { registered, id, amount: payout }; diff --git a/frame/salary/src/tests.rs b/frame/salary/src/tests.rs index 1b7bc6cbb6df5..081a240b079f0 100644 --- a/frame/salary/src/tests.rs +++ b/frame/salary/src/tests.rs @@ -103,12 +103,13 @@ impl Pay for TestPay { type Balance = u64; type Id = u64; type AssetKind = (); + type Error = (); fn pay( who: &Self::Beneficiary, _: Self::AssetKind, amount: Self::Balance, - ) -> Result { + ) -> Result { PAID.with(|paid| *paid.borrow_mut().entry(*who).or_default() += amount); Ok(LAST_ID.with(|lid| { let x = *lid.borrow(); diff --git a/frame/support/src/traits/tokens/pay.rs b/frame/support/src/traits/tokens/pay.rs index 23bd113bfef56..3ef7dd883857f 100644 --- a/frame/support/src/traits/tokens/pay.rs +++ b/frame/support/src/traits/tokens/pay.rs @@ -20,6 +20,7 @@ use codec::{Decode, Encode, FullCodec, MaxEncodedLen}; use scale_info::TypeInfo; use sp_core::{RuntimeDebug, TypedGet}; +use sp_runtime::DispatchError; use sp_std::fmt::Debug; use super::{fungible, Balance, Preservation::Expendable}; @@ -38,13 +39,15 @@ pub trait Pay { type AssetKind; /// An identifier given to an individual payment. type Id: FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy; + /// An error which could be returned by the Pay type + type Error: Debug; /// Make a payment and return an identifier for later evaluation of success in some off-chain /// mechanism (likely an event, but possibly not on this chain). fn pay( who: &Self::Beneficiary, asset_kind: Self::AssetKind, amount: Self::Balance, - ) -> Result; + ) -> Result; /// Check how a payment has proceeded. `id` must have been previously returned by `pay` for /// the result of this call to be meaningful. Once this returns anything other than /// `InProgress` for some `id` it must return `Unknown` rather than the actual result @@ -81,12 +84,13 @@ impl> Pay for PayFromAccount { type Beneficiary = A::Type; type AssetKind = (); type Id = (); + type Error = DispatchError; fn pay( who: &Self::Beneficiary, _: Self::AssetKind, amount: Self::Balance, - ) -> Result { - >::transfer(&A::get(), who, amount, Expendable).map_err(|_| ())?; + ) -> Result { + >::transfer(&A::get(), who, amount, Expendable)?; Ok(()) } fn check_payment(_: ()) -> PaymentStatus {