Skip to content

Commit 519b0de

Browse files
committed
Added #352 aggregate bonded announcing
1 parent 1be9cec commit 519b0de

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/service/TransactionService.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ export class TransactionService implements ITransactionService {
4242

4343
private readonly transactionHttp: TransactionHttp;
4444
private readonly receiptHttp: ReceiptHttp;
45+
private readonly listener: Listener;
4546
/**
4647
* Constructor
4748
* @param url Base catapult-rest url
4849
*/
4950
constructor(url: string) {
5051
this.transactionHttp = new TransactionHttp(url);
5152
this.receiptHttp = new ReceiptHttp(url);
53+
this.listener = new Listener(url);
5254
}
5355

5456
/**
@@ -187,4 +189,39 @@ export class TransactionService implements ITransactionService {
187189
map((statement) => transaction.resolveAliases(statement, aggregateIndex)),
188190
);
189191
}
192+
193+
/**
194+
* @param signedTransaction Signed transaction to be announced.
195+
* @returns {Observable<Transaction>}
196+
*/
197+
public announce(signedTransaction: SignedTransaction): Observable<Transaction> {
198+
return this.transactionHttp.announce(signedTransaction).pipe(
199+
flatMap(() => this.listener.confirmed(signedTransaction.getSignerAddress(), signedTransaction.hash)),
200+
);
201+
}
202+
203+
/**
204+
* Announce aggregate transaction
205+
* @param signedTransaction Signed aggregate bonded transaction.
206+
* @returns {Observable<AggregateTransaction>}
207+
*/
208+
public announceAggregateBonded(signedTransaction: SignedTransaction): Observable<AggregateTransaction> {
209+
return this.transactionHttp.announceAggregateBonded(signedTransaction).pipe(
210+
flatMap(() => this.listener.aggregateBondedAdded(signedTransaction.getSignerAddress(), signedTransaction.hash)),
211+
);
212+
}
213+
214+
/**
215+
* Announce aggregate bonded transaction with lock fund
216+
* @param signedHashLockTransaction Signed hash lock transaction.
217+
* @param signedAggregateTransaction Signed aggregate bonded transaction.
218+
* @returns {Observable<AggregateTransaction>}
219+
*/
220+
public announceHashLockAggregateBonded(signedHashLockTransaction: SignedTransaction,
221+
signedAggregateTransaction: SignedTransaction): Observable<AggregateTransaction> {
222+
return this.announce(signedHashLockTransaction).pipe(
223+
flatMap(() => this.announceAggregateBonded(signedAggregateTransaction)),
224+
);
225+
226+
}
190227
}

0 commit comments

Comments
 (0)