15
15
*/
16
16
17
17
import { combineLatest , merge , Observable , of } from 'rxjs' ;
18
- import { first , flatMap , map , mergeMap , toArray } from 'rxjs/operators' ;
19
- import { IListener } from '../infrastructure/IListener' ;
20
- import { ReceiptPaginationStreamer } from '../infrastructure/paginationStreamer/ReceiptPaginationStreamer' ;
21
- import { ReceiptRepository } from '../infrastructure/ReceiptRepository' ;
22
- import { TransactionGroup } from '../infrastructure/TransactionGroup' ;
23
- import { TransactionRepository } from '../infrastructure/TransactionRepository' ;
24
- import { Address } from '../model/account/Address' ;
25
- import { NamespaceId } from '../model/namespace/NamespaceId' ;
26
- import { Statement } from '../model/receipt/Statement' ;
27
- import { AccountAddressRestrictionTransaction } from '../model/transaction/AccountAddressRestrictionTransaction' ;
28
- import { AggregateTransaction } from '../model/transaction/AggregateTransaction' ;
29
- import { LockFundsTransaction } from '../model/transaction/LockFundsTransaction' ;
30
- import { MosaicAddressRestrictionTransaction } from '../model/transaction/MosaicAddressRestrictionTransaction' ;
31
- import { MosaicGlobalRestrictionTransaction } from '../model/transaction/MosaicGlobalRestrictionTransaction' ;
32
- import { MosaicMetadataTransaction } from '../model/transaction/MosaicMetadataTransaction' ;
33
- import { MosaicSupplyChangeTransaction } from '../model/transaction/MosaicSupplyChangeTransaction' ;
34
- import { SecretLockTransaction } from '../model/transaction/SecretLockTransaction' ;
35
- import { SecretProofTransaction } from '../model/transaction/SecretProofTransaction' ;
36
- import { SignedTransaction } from '../model/transaction/SignedTransaction' ;
37
- import { Transaction } from '../model/transaction/Transaction' ;
38
- import { TransactionStatusError } from '../model/transaction/TransactionStatusError' ;
39
- import { TransactionType } from '../model/transaction/TransactionType' ;
40
- import { TransferTransaction } from '../model/transaction/TransferTransaction' ;
41
- import { ITransactionService } from './interfaces/ITransactionService' ;
18
+ import { first , map , mergeMap , toArray } from 'rxjs/operators' ;
19
+ import { IListener , ReceiptRepository , TransactionGroup , TransactionRepository } from '../infrastructure' ;
20
+ import { ReceiptPaginationStreamer } from '../infrastructure/paginationStreamer' ;
21
+ import { Address } from '../model/account' ;
22
+ import { NamespaceId } from '../model/namespace' ;
23
+ import { Statement } from '../model/receipt' ;
24
+ import {
25
+ AccountAddressRestrictionTransaction ,
26
+ AggregateTransaction ,
27
+ LockFundsTransaction ,
28
+ MosaicAddressRestrictionTransaction ,
29
+ MosaicGlobalRestrictionTransaction ,
30
+ MosaicMetadataTransaction ,
31
+ MosaicSupplyChangeTransaction ,
32
+ SecretLockTransaction ,
33
+ SecretProofTransaction ,
34
+ SignedTransaction ,
35
+ Transaction ,
36
+ TransactionStatusError ,
37
+ TransactionType ,
38
+ TransferTransaction ,
39
+ } from '../model/transaction' ;
40
+ import { ITransactionService } from './interfaces' ;
42
41
43
42
/**
44
43
* Transaction Service
@@ -73,13 +72,18 @@ export class TransactionService implements ITransactionService {
73
72
*/
74
73
public announce ( signedTransaction : SignedTransaction , listener : IListener ) : Observable < Transaction > {
75
74
const signerAddress = signedTransaction . getSignerAddress ( ) ;
76
- this . transactionRepository . announce ( signedTransaction ) ;
77
- return this . getTransactionOrRaiseError (
78
- listener ,
79
- signerAddress ,
80
- signedTransaction . hash ,
81
- listener . confirmed ( signerAddress , signedTransaction . hash ) ,
82
- ) ;
75
+ return this . transactionRepository
76
+ . announce ( signedTransaction )
77
+ . pipe (
78
+ mergeMap ( ( ) =>
79
+ this . getTransactionOrRaiseError (
80
+ listener ,
81
+ signerAddress ,
82
+ signedTransaction . hash ,
83
+ listener . confirmed ( signerAddress , signedTransaction . hash ) ,
84
+ ) ,
85
+ ) ,
86
+ ) ;
83
87
}
84
88
85
89
/**
@@ -93,7 +97,7 @@ export class TransactionService implements ITransactionService {
93
97
const signerAddress = signedTransaction . getSignerAddress ( ) ;
94
98
const transactionObservable = this . transactionRepository
95
99
. announceAggregateBonded ( signedTransaction )
96
- . pipe ( flatMap ( ( ) => listener . aggregateBondedAdded ( signerAddress , signedTransaction . hash ) ) ) ;
100
+ . pipe ( mergeMap ( ( ) => listener . aggregateBondedAdded ( signerAddress , signedTransaction . hash ) ) ) ;
97
101
return this . getTransactionOrRaiseError ( listener , signerAddress , signedTransaction . hash , transactionObservable ) ;
98
102
}
99
103
@@ -113,7 +117,7 @@ export class TransactionService implements ITransactionService {
113
117
listener : IListener ,
114
118
) : Observable < AggregateTransaction > {
115
119
return this . announce ( signedHashLockTransaction , listener ) . pipe (
116
- flatMap ( ( ) => this . announceAggregateBonded ( signedAggregateTransaction , listener ) ) ,
120
+ mergeMap ( ( ) => this . announceAggregateBonded ( signedAggregateTransaction , listener ) ) ,
117
121
) ;
118
122
}
119
123
0 commit comments