20
20
use codec:: { Decode , Encode , FullCodec , MaxEncodedLen } ;
21
21
use scale_info:: TypeInfo ;
22
22
use sp_core:: { RuntimeDebug , TypedGet } ;
23
+ use sp_runtime:: DispatchError ;
23
24
use sp_std:: fmt:: Debug ;
24
25
25
26
use super :: { fungible, Balance , Preservation :: Expendable } ;
@@ -38,13 +39,15 @@ pub trait Pay {
38
39
type AssetKind ;
39
40
/// An identifier given to an individual payment.
40
41
type Id : FullCodec + MaxEncodedLen + TypeInfo + Clone + Eq + PartialEq + Debug + Copy ;
42
+ /// An error which could be returned by the Pay type
43
+ type Error : Debug ;
41
44
/// Make a payment and return an identifier for later evaluation of success in some off-chain
42
45
/// mechanism (likely an event, but possibly not on this chain).
43
46
fn pay (
44
47
who : & Self :: Beneficiary ,
45
48
asset_kind : Self :: AssetKind ,
46
49
amount : Self :: Balance ,
47
- ) -> Result < Self :: Id , ( ) > ;
50
+ ) -> Result < Self :: Id , Self :: Error > ;
48
51
/// Check how a payment has proceeded. `id` must have been previously returned by `pay` for
49
52
/// the result of this call to be meaningful. Once this returns anything other than
50
53
/// `InProgress` for some `id` it must return `Unknown` rather than the actual result
@@ -81,12 +84,13 @@ impl<A: TypedGet, F: fungible::Mutate<A::Type>> Pay for PayFromAccount<F, A> {
81
84
type Beneficiary = A :: Type ;
82
85
type AssetKind = ( ) ;
83
86
type Id = ( ) ;
87
+ type Error = DispatchError ;
84
88
fn pay (
85
89
who : & Self :: Beneficiary ,
86
90
_: Self :: AssetKind ,
87
91
amount : Self :: Balance ,
88
- ) -> Result < Self :: Id , ( ) > {
89
- <F as fungible:: Mutate < _ > >:: transfer ( & A :: get ( ) , who, amount, Expendable ) . map_err ( |_| ( ) ) ?;
92
+ ) -> Result < Self :: Id , Self :: Error > {
93
+ <F as fungible:: Mutate < _ > >:: transfer ( & A :: get ( ) , who, amount, Expendable ) ?;
90
94
Ok ( ( ) )
91
95
}
92
96
fn check_payment ( _: ( ) ) -> PaymentStatus {
0 commit comments