11import  Schema  from  '@cardano-ogmios/schema' ; 
2- import  {  CardanoProvider ,  Ogmios ,  Transaction ,  CardanoSerializationLib ,  CSL  }  from  '@cardano-sdk/core' ; 
2+ import  {  CardanoProvider ,  Ogmios ,  Transaction ,  CardanoSerializationLib ,  CSL ,   ProviderError  }  from  '@cardano-sdk/core' ; 
33import  {  UtxoRepository  }  from  './types' ; 
44import  {  dummyLogger ,  Logger  }  from  'ts-log' ; 
55import  {  defaultSelectionConstraints  }  from  '@cardano-sdk/cip2' ; 
66import  {  computeImplicitCoin ,  createTransactionInternals ,  InitializeTxProps ,  TxInternals  }  from  './Transaction' ; 
7- import  {  KeyManagement ,  TransactionTracker  }  from  '.' ; 
7+ import  {  KeyManagement ,  TransactionError ,   TransactionFailure ,   TransactionTracker  }  from  '.' ; 
88
99export  interface  SubmitTxResult  { 
1010  /** 
1111   * Resolves when transaction is submitted. 
12-    * Rejects with ProviderError . 
12+    * Rejects with {TransactionError} . 
1313   */ 
1414  submitted : Promise < void > ; 
1515  /** 
1616   * Resolves when transaction is submitted and confirmed. 
17-    * Rejects with TransactionError. 
17+    * Rejects with { TransactionError} . 
1818   */ 
1919  confirmed : Promise < void > ; 
2020} 
@@ -23,12 +23,6 @@ export interface SingleAddressWallet {
2323  initializeTx : ( props : InitializeTxProps )  =>  Promise < TxInternals > ; 
2424  name : string ; 
2525  signTx : ( body : CSL . TransactionBody ,  hash : CSL . TransactionHash )  =>  Promise < CSL . Transaction > ; 
26-   /** 
27-    * Submits transaction. 
28-    * 
29-    * @returns  {Promise<SubmitTxResult> } promise that resolves when transaction is submitted, 
30-    * but not confirmed yet. Rejects with TransactionError { FailedToSubmit } 
31-    */ 
3226  submitTx : ( tx : CSL . Transaction )  =>  SubmitTxResult ; 
3327} 
3428
@@ -92,10 +86,16 @@ export const createSingleAddressWallet = async (
9286    name, 
9387    signTx, 
9488    submitTx : ( tx )  =>  { 
95-       const  submitted  =  provider . submitTx ( tx ) ; 
89+       const  submitted  =  provider . submitTx ( tx ) . catch ( ( error )  =>  { 
90+         if  ( error  instanceof  ProviderError )  { 
91+           throw  new  TransactionError ( TransactionFailure . FailedToSubmit ,  error ,  error . detail ) ; 
92+         } 
93+         throw  new  TransactionError ( TransactionFailure . FailedToSubmit ,  error ) ; 
94+       } ) ; 
95+       const  confirmed  =  txTracker . trackTransaction ( tx ,  submitted ) ; 
9696      return  { 
9797        submitted, 
98-         confirmed :  submitted . then ( ( )   =>   txTracker . trackTransaction ( tx ) ) 
98+         confirmed
9999      } ; 
100100    } 
101101  } ; 
0 commit comments