15
15
*/
16
16
17
17
import { AccountRoutesApi } from 'nem2-library' ;
18
- import 'rxjs/add/observable/fromPromise' ;
19
- import 'rxjs/add/operator/map' ;
20
- import 'rxjs/add/operator/mergeMap' ;
21
- import { Observable } from 'rxjs/Observable' ;
18
+ import { from as observableFrom , Observable } from 'rxjs' ;
19
+ import { map , mergeMap } from 'rxjs/operators' ;
22
20
import { AccountInfo } from '../model/account/AccountInfo' ;
23
21
import { Address } from '../model/account/Address' ;
24
22
import { MultisigAccountGraphInfo } from '../model/account/MultisigAccountGraphInfo' ;
@@ -64,7 +62,7 @@ export class AccountHttp extends Http implements AccountRepository {
64
62
* @returns Observable<AccountInfo>
65
63
*/
66
64
public getAccountInfo ( address : Address ) : Observable < AccountInfo > {
67
- return Observable . fromPromise ( this . accountRoutesApi . getAccountInfo ( address . plain ( ) ) ) . map ( ( accountInfoDTO ) => {
65
+ return observableFrom ( this . accountRoutesApi . getAccountInfo ( address . plain ( ) ) ) . pipe ( map ( ( accountInfoDTO ) => {
68
66
return new AccountInfo (
69
67
accountInfoDTO . meta ,
70
68
Address . createFromEncoded ( accountInfoDTO . account . address ) ,
@@ -78,7 +76,7 @@ export class AccountHttp extends Http implements AccountRepository {
78
76
new UInt64 ( accountInfoDTO . account . importance ) ,
79
77
new UInt64 ( accountInfoDTO . account . importanceHeight ) ,
80
78
) ;
81
- } ) ;
79
+ } ) ) ;
82
80
}
83
81
84
82
/**
@@ -90,8 +88,8 @@ export class AccountHttp extends Http implements AccountRepository {
90
88
const accountIdsBody = {
91
89
accountIds : addresses . map ( ( address ) => address . plain ( ) ) ,
92
90
} ;
93
- return Observable . fromPromise (
94
- this . accountRoutesApi . getAccountsInfo ( accountIdsBody ) ) . map ( ( accountsInfoMetaDataDTO ) => {
91
+ return observableFrom (
92
+ this . accountRoutesApi . getAccountsInfo ( accountIdsBody ) ) . pipe ( map ( ( accountsInfoMetaDataDTO ) => {
95
93
return accountsInfoMetaDataDTO . map ( ( accountInfoDTO ) => {
96
94
return new AccountInfo (
97
95
accountInfoDTO . meta ,
@@ -104,7 +102,7 @@ export class AccountHttp extends Http implements AccountRepository {
104
102
new UInt64 ( accountInfoDTO . account . importanceHeight ) ,
105
103
) ;
106
104
} ) ;
107
- } ) ;
105
+ } ) ) ;
108
106
}
109
107
110
108
/**
@@ -113,9 +111,9 @@ export class AccountHttp extends Http implements AccountRepository {
113
111
* @returns Observable<MultisigAccountInfo>
114
112
*/
115
113
public getMultisigAccountInfo ( address : Address ) : Observable < MultisigAccountInfo > {
116
- return this . getNetworkTypeObservable ( )
117
- . flatMap ( ( networkType ) => Observable . fromPromise (
118
- this . accountRoutesApi . getAccountMultisig ( address . plain ( ) ) ) . map ( ( multisigAccountInfoDTO ) => {
114
+ return this . getNetworkTypeObservable ( ) . pipe (
115
+ mergeMap ( ( networkType ) => observableFrom (
116
+ this . accountRoutesApi . getAccountMultisig ( address . plain ( ) ) ) . pipe ( map ( ( multisigAccountInfoDTO ) => {
119
117
return new MultisigAccountInfo (
120
118
PublicAccount . createFromPublicKey ( multisigAccountInfoDTO . multisig . account , networkType ) ,
121
119
multisigAccountInfoDTO . multisig . minApproval ,
@@ -125,7 +123,7 @@ export class AccountHttp extends Http implements AccountRepository {
125
123
multisigAccountInfoDTO . multisig . multisigAccounts
126
124
. map ( ( multisigAccount ) => PublicAccount . createFromPublicKey ( multisigAccount , networkType ) ) ,
127
125
) ;
128
- } ) ) ;
126
+ } ) ) ) ) ;
129
127
}
130
128
131
129
/**
@@ -134,9 +132,9 @@ export class AccountHttp extends Http implements AccountRepository {
134
132
* @returns Observable<MultisigAccountGraphInfo>
135
133
*/
136
134
public getMultisigAccountGraphInfo ( address : Address ) : Observable < MultisigAccountGraphInfo > {
137
- return this . getNetworkTypeObservable ( )
138
- . flatMap ( ( networkType ) => Observable . fromPromise (
139
- this . accountRoutesApi . getAccountMultisigGraph ( address . plain ( ) ) ) . map ( ( multisigAccountGraphInfosDTO ) => {
135
+ return this . getNetworkTypeObservable ( ) . pipe (
136
+ mergeMap ( ( networkType ) => observableFrom (
137
+ this . accountRoutesApi . getAccountMultisigGraph ( address . plain ( ) ) ) . pipe ( map ( ( multisigAccountGraphInfosDTO ) => {
140
138
const multisigAccounts = new Map < number , MultisigAccountInfo [ ] > ( ) ;
141
139
multisigAccountGraphInfosDTO . map ( ( multisigAccountGraphInfoDTO ) => {
142
140
multisigAccounts . set ( multisigAccountGraphInfoDTO . level ,
@@ -153,7 +151,7 @@ export class AccountHttp extends Http implements AccountRepository {
153
151
) ;
154
152
} ) ;
155
153
return new MultisigAccountGraphInfo ( multisigAccounts ) ;
156
- } ) ) ;
154
+ } ) ) ) ) ;
157
155
}
158
156
159
157
/**
@@ -164,13 +162,13 @@ export class AccountHttp extends Http implements AccountRepository {
164
162
*/
165
163
public transactions ( publicAccount : PublicAccount ,
166
164
queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
167
- return Observable . fromPromise (
168
- this . accountRoutesApi . transactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) )
169
- . map ( ( transactionsDTO ) => {
165
+ return observableFrom (
166
+ this . accountRoutesApi . transactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
167
+ map ( ( transactionsDTO ) => {
170
168
return transactionsDTO . map ( ( transactionDTO ) => {
171
169
return CreateTransactionFromDTO ( transactionDTO ) ;
172
170
} ) ;
173
- } ) ;
171
+ } ) ) ;
174
172
}
175
173
176
174
/**
@@ -182,13 +180,13 @@ export class AccountHttp extends Http implements AccountRepository {
182
180
*/
183
181
public incomingTransactions ( publicAccount : PublicAccount ,
184
182
queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
185
- return Observable . fromPromise (
186
- this . accountRoutesApi . incomingTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) )
187
- . map ( ( transactionsDTO ) => {
183
+ return observableFrom (
184
+ this . accountRoutesApi . incomingTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
185
+ map ( ( transactionsDTO ) => {
188
186
return transactionsDTO . map ( ( transactionDTO ) => {
189
187
return CreateTransactionFromDTO ( transactionDTO ) ;
190
188
} ) ;
191
- } ) ;
189
+ } ) ) ;
192
190
}
193
191
194
192
/**
@@ -200,13 +198,13 @@ export class AccountHttp extends Http implements AccountRepository {
200
198
*/
201
199
public outgoingTransactions ( publicAccount : PublicAccount ,
202
200
queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
203
- return Observable . fromPromise (
204
- this . accountRoutesApi . outgoingTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) )
205
- . map ( ( transactionsDTO ) => {
201
+ return observableFrom (
202
+ this . accountRoutesApi . outgoingTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
203
+ map ( ( transactionsDTO ) => {
206
204
return transactionsDTO . map ( ( transactionDTO ) => {
207
205
return CreateTransactionFromDTO ( transactionDTO ) ;
208
206
} ) ;
209
- } ) ;
207
+ } ) ) ;
210
208
}
211
209
212
210
/**
@@ -219,13 +217,13 @@ export class AccountHttp extends Http implements AccountRepository {
219
217
*/
220
218
public unconfirmedTransactions ( publicAccount : PublicAccount ,
221
219
queryParams ?: QueryParams ) : Observable < Transaction [ ] > {
222
- return Observable . fromPromise (
223
- this . accountRoutesApi . unconfirmedTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) )
224
- . map ( ( transactionsDTO ) => {
220
+ return observableFrom (
221
+ this . accountRoutesApi . unconfirmedTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
222
+ map ( ( transactionsDTO ) => {
225
223
return transactionsDTO . map ( ( transactionDTO ) => {
226
224
return CreateTransactionFromDTO ( transactionDTO ) ;
227
225
} ) ;
228
- } ) ;
226
+ } ) ) ;
229
227
}
230
228
231
229
/**
@@ -238,12 +236,12 @@ export class AccountHttp extends Http implements AccountRepository {
238
236
public aggregateBondedTransactions ( publicAccount : PublicAccount ,
239
237
queryParams ?: QueryParams ) : Observable < AggregateTransaction [ ] > {
240
238
241
- return Observable . fromPromise (
242
- this . accountRoutesApi . partialTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) )
243
- . map ( ( transactionsDTO ) => {
239
+ return observableFrom (
240
+ this . accountRoutesApi . partialTransactions ( publicAccount . publicKey , queryParams != null ? queryParams : { } ) ) . pipe (
241
+ map ( ( transactionsDTO ) => {
244
242
return transactionsDTO . map ( ( transactionDTO ) => {
245
243
return CreateTransactionFromDTO ( transactionDTO ) as AggregateTransaction ;
246
244
} ) ;
247
- } ) ;
245
+ } ) ) ;
248
246
}
249
247
}
0 commit comments