@@ -5,7 +5,10 @@ use parity_scale_codec::{Decode, Encode};
5
5
use scale_info:: TypeInfo ;
6
6
use serde:: { Deserialize , Serialize } ;
7
7
use sp_core:: H256 ;
8
- use sp_runtime:: traits:: { BlakeTwo256 , Extrinsic , Hash as HashT } ;
8
+ use sp_runtime:: {
9
+ traits:: { BlakeTwo256 , Extrinsic , Hash as HashT } ,
10
+ transaction_validity:: InvalidTransaction ,
11
+ } ;
9
12
use sp_std:: vec:: Vec ;
10
13
11
14
// All Tuxedo chains use the same BlakeTwo256 hash.
@@ -197,6 +200,20 @@ pub enum UtxoError<ConstraintCheckerError> {
197
200
MissingInput ,
198
201
}
199
202
203
+ // Substrate requires this supposedly reusable error type, but it is actually tied pretty tightly
204
+ // to the accounts model and some specific FRAME signed extensions. We map it the best we can.
205
+ impl < ConstraintCheckerError > From < UtxoError < ConstraintCheckerError > > for InvalidTransaction {
206
+ fn from ( utxo_error : UtxoError < ConstraintCheckerError > ) -> Self {
207
+ match utxo_error {
208
+ UtxoError :: DuplicateInput => InvalidTransaction :: Custom ( 255 ) ,
209
+ UtxoError :: PreExistingOutput => InvalidTransaction :: Custom ( 254 ) ,
210
+ UtxoError :: ConstraintCheckerError ( _) => InvalidTransaction :: Custom ( 0 ) ,
211
+ UtxoError :: VerifierError => InvalidTransaction :: BadProof ,
212
+ UtxoError :: MissingInput => InvalidTransaction :: Future ,
213
+ }
214
+ }
215
+ }
216
+
200
217
/// The Result of dispatching a UTXO transaction.
201
218
pub type DispatchResult < ConstraintCheckerError > = Result < ( ) , UtxoError < ConstraintCheckerError > > ;
202
219
0 commit comments