1616
1717import { Observable } from 'rxjs' ;
1818import { mergeMap , toArray } from 'rxjs/operators' ;
19+ import { flatMap } from 'rxjs/operators' ;
20+ import { Listener } from '../infrastructure/Listener' ;
1921import { ReceiptHttp } from '../infrastructure/ReceiptHttp' ;
2022import { TransactionHttp } from '../infrastructure/TransactionHttp' ;
23+ import { Address } from '../model/account/Address' ;
24+ import { MosaicId } from '../model/mosaic/MosaicId' ;
25+ import { NamespaceId } from '../model/namespace/NamespaceId' ;
26+ import { ResolutionType } from '../model/receipt/ResolutionType' ;
27+ import { Statement } from '../model/receipt/Statement' ;
28+ import { AggregateTransaction } from '../model/transaction/AggregateTransaction' ;
29+ import { SignedTransaction } from '../model/transaction/SignedTransaction' ;
2130import { Transaction } from '../model/transaction/Transaction' ;
2231import { ITransactionService } from './interfaces/ITransactionService' ;
2332
@@ -28,13 +37,15 @@ export class TransactionService implements ITransactionService {
2837
2938 private readonly transactionHttp : TransactionHttp ;
3039 private readonly receiptHttp : ReceiptHttp ;
40+ private readonly listener : Listener ;
3141 /**
3242 * Constructor
3343 * @param url Base catapult-rest url
3444 */
3545 constructor ( url : string ) {
3646 this . transactionHttp = new TransactionHttp ( url ) ;
3747 this . receiptHttp = new ReceiptHttp ( url ) ;
48+ this . listener = new Listener ( url ) ;
3849 }
3950
4051 /**
@@ -48,4 +59,39 @@ export class TransactionService implements ITransactionService {
4859 toArray ( ) ,
4960 ) ;
5061 }
62+
63+ /**
64+ * @param signedTransaction Signed transaction to be announced.
65+ * @returns {Observable<Transaction> }
66+ */
67+ public announce ( signedTransaction : SignedTransaction ) : Observable < Transaction > {
68+ return this . transactionHttp . announce ( signedTransaction ) . pipe (
69+ flatMap ( ( ) => this . listener . confirmed ( signedTransaction . getSignerAddress ( ) , signedTransaction . hash ) ) ,
70+ ) ;
71+ }
72+
73+ /**
74+ * Announce aggregate transaction
75+ * @param signedTransaction Signed aggregate bonded transaction.
76+ * @returns {Observable<AggregateTransaction> }
77+ */
78+ public announceAggregateBonded ( signedTransaction : SignedTransaction ) : Observable < AggregateTransaction > {
79+ return this . transactionHttp . announceAggregateBonded ( signedTransaction ) . pipe (
80+ flatMap ( ( ) => this . listener . aggregateBondedAdded ( signedTransaction . getSignerAddress ( ) , signedTransaction . hash ) ) ,
81+ ) ;
82+ }
83+
84+ /**
85+ * Announce aggregate bonded transaction with lock fund
86+ * @param signedHashLockTransaction Signed hash lock transaction.
87+ * @param signedAggregateTransaction Signed aggregate bonded transaction.
88+ * @returns {Observable<AggregateTransaction> }
89+ */
90+ public announceHashLockAggregateBonded ( signedHashLockTransaction : SignedTransaction ,
91+ signedAggregateTransaction : SignedTransaction ) : Observable < AggregateTransaction > {
92+ return this . announce ( signedHashLockTransaction ) . pipe (
93+ flatMap ( ( ) => this . announceAggregateBonded ( signedAggregateTransaction ) ) ,
94+ ) ;
95+
96+ }
5197}
0 commit comments